mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
add custom message to failed expectations
This commit is contained in:
@ -242,36 +242,43 @@
|
||||
PASS Tests\Features\Expect\toBe
|
||||
✓ strict comparisons
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeArray
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeBool
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeCallable
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeDirectory
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeEmpty
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeFalse
|
||||
✓ strict comparisons
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeFalsy
|
||||
@ -286,116 +293,139 @@
|
||||
✓ passes as not falsy with (1) #2
|
||||
✓ passes as not falsy with (-1)
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeFile
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeFloat
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeGreatherThan
|
||||
✓ passes
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeGreatherThanOrEqual
|
||||
✓ passes
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeIn
|
||||
✓ passes
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeInfinite
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeInstanceOf
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeInt
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeIterable
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeJson
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeLessThan
|
||||
✓ passes
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeLessThanOrEqual
|
||||
✓ passes
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeNAN
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeNull
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeNumeric
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeObject
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeReadableDirectory
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeReadableFile
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeResource
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeScalar
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeString
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeTrue
|
||||
✓ strict comparisons
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeTruthy
|
||||
@ -410,16 +440,19 @@
|
||||
✓ passes as not truthy with (0)
|
||||
✓ passes as not truthy with ('0')
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeWritableDirectory
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toBeWritableFile
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toContain
|
||||
@ -438,31 +471,36 @@
|
||||
PASS Tests\Features\Expect\toContainOnlyInstancesOf
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toEndWith
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toEqual
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toEqualCanonicalizing
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toEqualWithDelta
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toHaveCount
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toHaveKey
|
||||
@ -473,7 +511,9 @@
|
||||
✓ pass with value check and nested key
|
||||
✓ pass with value check and plain key with dots
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ failures with nested key
|
||||
✓ failures with nested key and custom message
|
||||
✓ failures with plain key with dots
|
||||
✓ fails with wrong value
|
||||
✓ fails with wrong value and nested key
|
||||
@ -489,7 +529,9 @@
|
||||
✓ pass
|
||||
✓ pass with multi-dimensional arrays
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ failures with multi-dimensional arrays
|
||||
✓ failures with multi-dimensional arrays and custom message
|
||||
✓ not failures
|
||||
✓ not failures with multi-dimensional arrays
|
||||
|
||||
@ -501,45 +543,50 @@
|
||||
✓ it passes with array
|
||||
✓ it passes with *not*
|
||||
✓ it properly fails with *not*
|
||||
✓ it fails with (1)
|
||||
✓ it fails with (1.5)
|
||||
✓ it fails with (true)
|
||||
✓ it fails with (null)
|
||||
✓ it fails
|
||||
✓ it fails with message
|
||||
|
||||
PASS Tests\Features\Expect\toHaveProperties
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toHaveProperty
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toMatch
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toMatchArray
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toMatchConstraint
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toMatchObject
|
||||
✓ pass
|
||||
✓ pass with class
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toStartWith
|
||||
✓ pass
|
||||
✓ failures
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
|
||||
PASS Tests\Features\Expect\toThrow
|
||||
@ -551,6 +598,7 @@
|
||||
✓ failures 5
|
||||
✓ failures 6
|
||||
✓ failures 7
|
||||
✓ failures with custom message
|
||||
✓ not failures
|
||||
✓ closure missing parameter
|
||||
✓ closure missing type-hint
|
||||
@ -767,4 +815,4 @@
|
||||
PASS Tests\Visual\Version
|
||||
✓ visual snapshot of help command output
|
||||
|
||||
Tests: 4 incomplete, 1 todo, 18 skipped, 511 passed (1286 assertions)
|
||||
Tests: 4 incomplete, 1 todo, 18 skipped, 559 passed (1450 assertions)
|
||||
@ -15,6 +15,10 @@ test('failures', function () {
|
||||
expect(1)->toBe(2);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(1)->toBe(2, 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(1)->not->toBe(1);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(null)->toBeArray();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(null)->toBeArray('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(['a', 'b', 'c'])->not->toBeArray();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(null)->toBeBool();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(null)->toBeBool('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(false)->not->toBeBool();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -14,6 +14,12 @@ test('failures', function () {
|
||||
expect($hello)->toBeCallable();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
$hello = 5;
|
||||
|
||||
expect($hello)->toBeCallable('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(function () {
|
||||
return 42;
|
||||
|
||||
@ -12,6 +12,10 @@ test('failures', function () {
|
||||
expect('/random/path/whatever')->toBeDirectory();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect('/random/path/whatever')->toBeDirectory('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect('.')->not->toBeDirectory();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -12,6 +12,11 @@ test('failures', function () {
|
||||
expect(' ')->toBeEmpty();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect([1, 2])->toBeEmpty('oh no!');
|
||||
expect(' ')->toBeEmpty('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect([])->not->toBeEmpty();
|
||||
expect(null)->not->toBeEmpty();
|
||||
|
||||
@ -10,6 +10,10 @@ test('failures', function () {
|
||||
expect('')->toBeFalse();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect('')->toBeFalse('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(false)->not->toBe(false);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -14,6 +14,10 @@ test('failures', function () {
|
||||
expect(1)->toBeFalsy();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(1)->toBeFalsy('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(null)->not->toBeFalsy();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -18,6 +18,10 @@ test('failures', function () {
|
||||
expect('/random/path/whatever.file')->toBeFile();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect('/random/path/whatever.file')->toBeFile('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect($this->tempFile)->not->toBeFile();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(42)->toBeFloat();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(42)->toBeFloat('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(log(3))->not->toBeFloat();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(4)->toBeGreaterThan(4);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(4)->toBeGreaterThan(4, 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(5)->not->toBeGreaterThan(4);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(4)->toBeGreaterThanOrEqual(4.1);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(4)->toBeGreaterThanOrEqual(4.1, 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(5)->not->toBeGreaterThanOrEqual(5);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect('d')->toBeIn(['a', 'b', 'c']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect('d')->toBeIn(['a', 'b', 'c'], 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect('a')->not->toBeIn(['a', 'b', 'c']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(asin(2))->toBeInfinite();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(asin(2))->toBeInfinite('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(INF)->not->toBeInfinite();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(new Exception())->toBeInstanceOf(RuntimeException::class);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(new Exception())->toBeInstanceOf(RuntimeException::class, 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(new Exception())->not->toBeInstanceOf(Exception::class);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(42.0)->toBeInt();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(42.0)->toBeInt('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(6 * 7)->not->toBeInt();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(42)->toBeIterable();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(42)->toBeIterable('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
function gen(): iterable
|
||||
{
|
||||
|
||||
@ -12,6 +12,10 @@ test('failures', function () {
|
||||
expect(':"world"}')->toBeJson();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(':"world"}')->toBeJson('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect('{"hello":"world"}')->not->toBeJson();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(4)->toBeLessThan(4);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(4)->toBeLessThan(4, 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(5)->not->toBeLessThan(6);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(4)->toBeLessThanOrEqual(3.9);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(4)->toBeLessThanOrEqual(3.9, 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(5)->not->toBeLessThanOrEqual(5);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(1)->toBeNan();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(1)->toBeNan('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(acos(1.5))->not->toBeNan();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect('hello')->toBeNull();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect('hello')->toBeNull('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(null)->not->toBeNull();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(null)->toBeNumeric();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(null)->toBeNumeric('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(6 * 7)->not->toBeNumeric();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(null)->toBeObject();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(null)->toBeObject('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect((object) 'ciao')->not->toBeObject();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -10,6 +10,10 @@ test('failures', function () {
|
||||
expect('/random/path/whatever')->toBeReadableDirectory();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect('/random/path/whatever')->toBeReadableDirectory('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(sys_get_temp_dir())->not->toBeReadableDirectory();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -18,6 +18,10 @@ test('failures', function () {
|
||||
expect('/random/path/whatever.file')->toBeReadableFile();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect('/random/path/whatever.file')->toBeReadableFile('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect($this->tempFile)->not->toBeReadableFile();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -17,6 +17,10 @@ test('failures', function () {
|
||||
expect(null)->toBeResource();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(null)->toBeResource('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () use ($resource) {
|
||||
expect($resource)->not->toBeResource();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -10,6 +10,10 @@ test('failures', function () {
|
||||
expect(null)->toBeScalar();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(null)->toBeScalar('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(42)->not->toBeScalar();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(null)->toBeString();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(null)->toBeString('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect('42')->not->toBeString();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -10,6 +10,10 @@ test('failures', function () {
|
||||
expect('')->toBeTrue();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect('')->toBeTrue('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(false)->not->toBe(false);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -14,6 +14,10 @@ test('failures', function () {
|
||||
expect(null)->toBeTruthy();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(null)->toBeTruthy('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(1)->not->toBeTruthy();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -10,6 +10,10 @@ test('failures', function () {
|
||||
expect('/random/path/whatever')->toBeWritableDirectory();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect('/random/path/whatever')->toBeWritableDirectory('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(sys_get_temp_dir())->not->toBeWritableDirectory();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -18,6 +18,10 @@ test('failures', function () {
|
||||
expect('/random/path/whatever.file')->toBeWritableFile();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect('/random/path/whatever.file')->toBeWritableFile('oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect($this->tempFile)->not->toBeWritableFile();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -15,6 +15,10 @@ test('failures', function () {
|
||||
expect($this->times)->toContainOnlyInstancesOf(DateTime::class);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect($this->times)->toContainOnlyInstancesOf(DateTime::class, 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect($this->times)->not->toContainOnlyInstancesOf(DateTimeImmutable::class);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -10,6 +10,10 @@ test('failures', function () {
|
||||
expect('username')->toEndWith('password');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect('username')->toEndWith('password', 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect('username')->not->toEndWith('name');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -10,6 +10,10 @@ test('failures', function () {
|
||||
expect(['a', 'b', 'c'])->toEqual(['a', 'b']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(['a', 'b', 'c'])->toEqual(['a', 'b'], 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect('042')->not->toEqual(42);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect([3, 2, 1])->toEqualCanonicalizing([1, 2]);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect([3, 2, 1])->toEqualCanonicalizing([1, 2], 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(['a', 'b', 'c'])->not->toEqualCanonicalizing(['b', 'a', 'c']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -6,9 +6,9 @@ test('pass', function () {
|
||||
expect(1.0)->toEqualWithDelta(1.3, .4);
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect(1.0)->toEqualWithDelta(1.5, .1);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
test('failures with custom message', function () {
|
||||
expect(1.0)->toEqualWithDelta(1.5, .1, 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(1.0)->not->toEqualWithDelta(1.6, .7);
|
||||
|
||||
@ -10,6 +10,10 @@ test('failures', function () {
|
||||
expect([1, 2, 3])->toHaveCount(4);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with message', function () {
|
||||
expect([1, 2, 3])->toHaveCount(4, 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect([1, 2, 3])->not->toHaveCount(3);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -24,10 +24,18 @@ test('failures', function () use ($test_array) {
|
||||
expect($test_array)->toHaveKey('foo');
|
||||
})->throws(ExpectationFailedException::class, "Failed asserting that an array has the key 'foo'");
|
||||
|
||||
test('failures with custom message', function () use ($test_array) {
|
||||
expect($test_array)->toHaveKey('foo', message: 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('failures with nested key', function () use ($test_array) {
|
||||
expect($test_array)->toHaveKey('d.bar');
|
||||
})->throws(ExpectationFailedException::class, "Failed asserting that an array has the key 'd.bar'");
|
||||
|
||||
test('failures with nested key and custom message', function () use ($test_array) {
|
||||
expect($test_array)->toHaveKey('d.bar', message: 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('failures with plain key with dots', function () use ($test_array) {
|
||||
expect($test_array)->toHaveKey('missing.key.with.dots');
|
||||
})->throws(ExpectationFailedException::class, "Failed asserting that an array has the key 'missing.key.with.dots'");
|
||||
|
||||
@ -14,10 +14,18 @@ test('failures', function () {
|
||||
expect(['a' => 1, 'b', 'c' => 'world', 'foo' => ['bar' => 'baz']])->toHaveKeys(['a', 'd', 'foo.bar', 'hello.world']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(['a' => 1, 'b', 'c' => 'world', 'foo' => ['bar' => 'baz']])->toHaveKeys(['a', 'd', 'foo.bar', 'hello.world'], 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('failures with multi-dimensional arrays', function () {
|
||||
expect(['a' => 1, 'b', 'c' => 'world', 'foo' => ['bar' => ['bir' => 'biz']]])->toHaveKeys(['a', 'd', 'foo' => ['bar' => 'bir'], 'hello.world']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with multi-dimensional arrays and custom message', function () {
|
||||
expect(['a' => 1, 'b', 'c' => 'world', 'foo' => ['bar' => ['bir' => 'biz']]])->toHaveKeys(['a', 'd', 'foo' => ['bar' => 'bir'], 'hello.world'], 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(['a' => 1, 'b', 'c' => 'world', 'foo' => ['bar' => 'baz']])->not->toHaveKeys(['foo.bar', 'c', 'z']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -20,9 +20,13 @@ it('passes with *not*', function () {
|
||||
});
|
||||
|
||||
it('properly fails with *not*', function () {
|
||||
expect('pest')->not->toHaveLength(4);
|
||||
expect('pest')->not->toHaveLength(4, 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
it('fails', function () {
|
||||
expect([1, 1.5, true, null])->toHaveLength(1);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
it('fails', function ($value) {
|
||||
expect($value)->toHaveLength(1);
|
||||
})->with([1, 1.5, true, null])->throws(BadMethodCallException::class);
|
||||
it('fails with message', function () {
|
||||
expect([1, 1.5, true, null])->toHaveLength(1, 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
@ -17,6 +17,13 @@ test('failures', function () {
|
||||
expect($object)->toHaveProperties(['name', 'age']);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
$object = new stdClass();
|
||||
$object->name = 'Jhon';
|
||||
|
||||
expect($object)->toHaveProperties(['name', 'age'], 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
$object = new stdClass();
|
||||
$object->name = 'Jhon';
|
||||
|
||||
@ -17,6 +17,10 @@ test('failures', function () use ($obj) {
|
||||
expect($obj)->toHaveProperty('bar');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with message', function () use ($obj) {
|
||||
expect($obj)->toHaveProperty(name: 'bar', message: 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () use ($obj) {
|
||||
expect($obj)->not->toHaveProperty('foo');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -10,6 +10,10 @@ test('failures', function () {
|
||||
expect('Hello World')->toMatch('/^hello$/i');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect('Hello World')->toMatch('/^hello$/i', 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect('Hello World')->not->toMatch('/^hello wo.*$/i');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -24,6 +24,13 @@ test('failures', function () {
|
||||
]);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect($this->user)->toMatchArray([
|
||||
'name' => 'Not the same name',
|
||||
'email' => 'enunomaduro@gmail.com',
|
||||
], 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect($this->user)->not->toMatchArray([
|
||||
'id' => 1,
|
||||
|
||||
@ -11,6 +11,10 @@ test('failures', function () {
|
||||
expect(false)->toMatchConstraint(new IsTrue());
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(false)->toMatchConstraint(new IsTrue(), 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(true)->not->toMatchConstraint(new IsTrue());
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -36,6 +36,13 @@ test('failures', function () {
|
||||
]);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect($this->user)->toMatchObject([
|
||||
'name' => 'Not the same name',
|
||||
'email' => 'enunomaduro@gmail.com',
|
||||
], 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect($this->user)->not->toMatchObject([
|
||||
'id' => 1,
|
||||
|
||||
@ -10,6 +10,10 @@ test('failures', function () {
|
||||
expect('username')->toStartWith('password');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect('username')->toStartWith('password', 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect('username')->not->toStartWith('user');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -79,6 +79,12 @@ test('failures 7', function () {
|
||||
})->toThrow(RuntimeException::class, 'expected message');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('failures with custom message', function () {
|
||||
expect(function () {
|
||||
throw new RuntimeException('actual message');
|
||||
})->toThrow(RuntimeException::class, 'expected message', 'oh no!');
|
||||
})->throws(ExpectationFailedException::class, 'oh no!');
|
||||
|
||||
test('not failures', function () {
|
||||
expect(function () {
|
||||
throw new RuntimeException();
|
||||
|
||||
Reference in New Issue
Block a user