mirror of
https://github.com/pestphp/pest.git
synced 2026-03-11 02:07:23 +01:00
Uses Collision ^7.0
This commit is contained in:
@ -40,8 +40,12 @@ it('works inside of each', function () {
|
||||
it('works with sequence', function () {
|
||||
expect(new HasMethods())
|
||||
->books()->sequence(
|
||||
function ($book) { $book->title->toEqual('Foo')->cost->toEqual(20); },
|
||||
function ($book) { $book->title->toEqual('Bar')->cost->toEqual(30); },
|
||||
function ($book) {
|
||||
$book->title->toEqual('Foo')->cost->toEqual(20);
|
||||
},
|
||||
function ($book) {
|
||||
$book->title->toEqual('Bar')->cost->toEqual(30);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@ -54,8 +58,12 @@ it('can compose complex expectations', function () {
|
||||
->attributes()->toBeArray()
|
||||
->books()->toBeArray->each->not->toBeEmpty
|
||||
->books()->sequence(
|
||||
function ($book) { $book->title->toEqual('Foo')->cost->toEqual(20); },
|
||||
function ($book) { $book->title->toEqual('Bar')->cost->toEqual(30); },
|
||||
function ($book) {
|
||||
$book->title->toEqual('Foo')->cost->toEqual(20);
|
||||
},
|
||||
function ($book) {
|
||||
$book->title->toEqual('Bar')->cost->toEqual(30);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@ -9,8 +9,12 @@ it('can access methods and properties', function () {
|
||||
})->books()->toBeArray()
|
||||
->posts->toBeArray->each->not->toBeEmpty
|
||||
->books()->sequence(
|
||||
function ($book) { $book->title->toEqual('Foo')->cost->toEqual(20); },
|
||||
function ($book) { $book->title->toEqual('Bar')->cost->toEqual(30); },
|
||||
function ($book) {
|
||||
$book->title->toEqual('Foo')->cost->toEqual(20);
|
||||
},
|
||||
function ($book) {
|
||||
$book->title->toEqual('Bar')->cost->toEqual(30);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@ -53,7 +57,9 @@ it('can start a new higher order expectation using the and syntax without nestin
|
||||
->toBeInstanceOf(HasMethodsAndProperties::class)
|
||||
->meta
|
||||
->sequence(
|
||||
function ($value, $key) { $value->toBeArray()->and($key)->toBe('foo'); },
|
||||
function ($value, $key) {
|
||||
$value->toBeArray()->and($key)->toBe('foo');
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@ -35,8 +35,12 @@ it('works inside of each', function () {
|
||||
it('works with sequence', function () {
|
||||
expect(['books' => [['title' => 'Foo', 'cost' => 20], ['title' => 'Bar', 'cost' => 30]]])
|
||||
->books->sequence(
|
||||
function ($book) { $book->title->toEqual('Foo')->cost->toEqual(20); },
|
||||
function ($book) { $book->title->toEqual('Bar')->cost->toEqual(30); },
|
||||
function ($book) {
|
||||
$book->title->toEqual('Foo')->cost->toEqual(20);
|
||||
},
|
||||
function ($book) {
|
||||
$book->title->toEqual('Bar')->cost->toEqual(30);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@ -51,10 +55,16 @@ it('can compose complex expectations', function () {
|
||||
it('works with objects', function () {
|
||||
expect(new HasProperties())
|
||||
->name->toEqual('foo')->not->toEqual('world')
|
||||
->posts->toHaveCount(2)->each(function ($post) { $post->is_published->toBeTrue(); })
|
||||
->posts->toHaveCount(2)->each(function ($post) {
|
||||
$post->is_published->toBeTrue();
|
||||
})
|
||||
->posts->sequence(
|
||||
function ($post) { $post->title->toEqual('Foo'); },
|
||||
function ($post) { $post->title->toEqual('Bar'); },
|
||||
function ($post) {
|
||||
$post->title->toEqual('Foo');
|
||||
},
|
||||
function ($post) {
|
||||
$post->title->toEqual('Bar');
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@ -9,17 +9,17 @@ beforeEach(function () {
|
||||
it('pass', function () {
|
||||
expect('baz')
|
||||
->match('foo', [
|
||||
'bar' => function ($value) {
|
||||
$this->matched = 'bar';
|
||||
'bar' => function ($value) {
|
||||
$this->matched = 'bar';
|
||||
|
||||
return $value->toEqual('bar');
|
||||
},
|
||||
'foo' => function ($value) {
|
||||
$this->matched = 'baz';
|
||||
return $value->toEqual('bar');
|
||||
},
|
||||
'foo' => function ($value) {
|
||||
$this->matched = 'baz';
|
||||
|
||||
return $value->toEqual('baz');
|
||||
},
|
||||
]
|
||||
return $value->toEqual('baz');
|
||||
},
|
||||
]
|
||||
)
|
||||
->toEqual($this->matched);
|
||||
|
||||
@ -29,30 +29,30 @@ it('pass', function () {
|
||||
it('failures', function () {
|
||||
expect(true)
|
||||
->match('foo', [
|
||||
'bar' => function ($value) {
|
||||
return $value->toBeTrue();
|
||||
},
|
||||
'foo' => function ($value) {
|
||||
return $value->toBeFalse();
|
||||
},
|
||||
]
|
||||
'bar' => function ($value) {
|
||||
return $value->toBeTrue();
|
||||
},
|
||||
'foo' => function ($value) {
|
||||
return $value->toBeFalse();
|
||||
},
|
||||
]
|
||||
);
|
||||
})->throws(ExpectationFailedException::class, 'true is false');
|
||||
|
||||
it('runs with truthy', function () {
|
||||
expect('foo')
|
||||
->match(1, [
|
||||
'bar' => function ($value) {
|
||||
$this->matched = 'bar';
|
||||
'bar' => function ($value) {
|
||||
$this->matched = 'bar';
|
||||
|
||||
return $value->toEqual('bar');
|
||||
},
|
||||
true => function ($value) {
|
||||
$this->matched = 'foo';
|
||||
return $value->toEqual('bar');
|
||||
},
|
||||
true => function ($value) {
|
||||
$this->matched = 'foo';
|
||||
|
||||
return $value->toEqual('foo');
|
||||
},
|
||||
]
|
||||
return $value->toEqual('foo');
|
||||
},
|
||||
]
|
||||
)
|
||||
->toEqual($this->matched);
|
||||
|
||||
@ -62,17 +62,17 @@ it('runs with truthy', function () {
|
||||
it('runs with falsy', function () {
|
||||
expect('foo')
|
||||
->match(false, [
|
||||
'bar' => function ($value) {
|
||||
$this->matched = 'bar';
|
||||
'bar' => function ($value) {
|
||||
$this->matched = 'bar';
|
||||
|
||||
return $value->toEqual('bar');
|
||||
},
|
||||
false => function ($value) {
|
||||
$this->matched = 'foo';
|
||||
return $value->toEqual('bar');
|
||||
},
|
||||
false => function ($value) {
|
||||
$this->matched = 'foo';
|
||||
|
||||
return $value->toEqual('foo');
|
||||
},
|
||||
]
|
||||
return $value->toEqual('foo');
|
||||
},
|
||||
]
|
||||
)
|
||||
->toEqual($this->matched);
|
||||
|
||||
@ -82,7 +82,9 @@ it('runs with falsy', function () {
|
||||
it('runs with truthy closure condition', function () {
|
||||
expect('foo')
|
||||
->match(
|
||||
function () { return '1'; }, [
|
||||
function () {
|
||||
return '1';
|
||||
}, [
|
||||
'bar' => function ($value) {
|
||||
$this->matched = 'bar';
|
||||
|
||||
@ -103,7 +105,9 @@ it('runs with truthy closure condition', function () {
|
||||
it('runs with falsy closure condition', function () {
|
||||
expect('foo')
|
||||
->match(
|
||||
function () { return '0'; }, [
|
||||
function () {
|
||||
return '0';
|
||||
}, [
|
||||
'bar' => function ($value) {
|
||||
$this->matched = 'bar';
|
||||
|
||||
@ -124,9 +128,9 @@ it('runs with falsy closure condition', function () {
|
||||
it('can be passed non-callable values', function () {
|
||||
expect('foo')
|
||||
->match('pest', [
|
||||
'bar' => 'foo',
|
||||
'pest' => 'baz',
|
||||
]
|
||||
'bar' => 'foo',
|
||||
'pest' => 'baz',
|
||||
]
|
||||
);
|
||||
})->throws(ExpectationFailedException::class, 'two strings are equal');
|
||||
|
||||
@ -137,7 +141,9 @@ it('fails with unhandled match', function () {
|
||||
it('can be used in higher order tests')
|
||||
->expect(true)
|
||||
->match(
|
||||
function () { return true; }, [
|
||||
function () {
|
||||
return true;
|
||||
}, [
|
||||
false => function ($value) {
|
||||
return $value->toBeFalse();
|
||||
},
|
||||
|
||||
@ -36,7 +36,8 @@ class Symbol
|
||||
|
||||
class State
|
||||
{
|
||||
public array $runCount = [];
|
||||
public array $runCount = [];
|
||||
|
||||
public array $appliedCount = [];
|
||||
|
||||
public function __construct()
|
||||
@ -132,16 +133,16 @@ test('pipe is applied and can stop pipeline', function () use ($state) {
|
||||
expect($char)->toBe(new Char('A'))
|
||||
->and($state)
|
||||
->runCount->toMatchArray([
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
])
|
||||
->appliedCount->toMatchArray([
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
]);
|
||||
});
|
||||
|
||||
@ -151,16 +152,16 @@ test('pipe is run and can let the pipeline keep going', function () use ($state)
|
||||
expect(3)->toBe(3)
|
||||
->and($state)
|
||||
->runCount->toMatchArray([
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 1,
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 1,
|
||||
])
|
||||
->appliedCount->toMatchArray([
|
||||
'char' => 0,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'char' => 0,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
]);
|
||||
});
|
||||
|
||||
@ -172,16 +173,16 @@ test('pipe works with negated expectation', function () use ($state) {
|
||||
expect($char)->not->toBe(new Char('B'))
|
||||
->and($state)
|
||||
->runCount->toMatchArray([
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
])
|
||||
->appliedCount->toMatchArray([
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'char' => 1,
|
||||
'number' => 0,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
]);
|
||||
});
|
||||
|
||||
@ -204,16 +205,16 @@ test('interceptor stops the pipeline', function () use ($state) {
|
||||
expect($number)->toBe(new Number(1))
|
||||
->and($state)
|
||||
->runCount->toMatchArray([
|
||||
'char' => 1,
|
||||
'number' => 1,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'char' => 1,
|
||||
'number' => 1,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
])
|
||||
->appliedCount->toMatchArray([
|
||||
'char' => 0,
|
||||
'number' => 1,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
'char' => 0,
|
||||
'number' => 1,
|
||||
'wildcard' => 0,
|
||||
'symbol' => 0,
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@ -9,9 +9,15 @@ test('an exception is thrown if the the type is not iterable', function () {
|
||||
test('allows for sequences of checks to be run on iterable data', function () {
|
||||
expect([1, 2, 3])
|
||||
->sequence(
|
||||
function ($expectation) { $expectation->toBeInt()->toEqual(1); },
|
||||
function ($expectation) { $expectation->toBeInt()->toEqual(2); },
|
||||
function ($expectation) { $expectation->toBeInt()->toEqual(3); },
|
||||
function ($expectation) {
|
||||
$expectation->toBeInt()->toEqual(1);
|
||||
},
|
||||
function ($expectation) {
|
||||
$expectation->toBeInt()->toEqual(2);
|
||||
},
|
||||
function ($expectation) {
|
||||
$expectation->toBeInt()->toEqual(3);
|
||||
},
|
||||
);
|
||||
|
||||
expect(static::getCount())->toBe(6);
|
||||
@ -20,9 +26,15 @@ test('allows for sequences of checks to be run on iterable data', function () {
|
||||
test('loops back to the start if it runs out of sequence items', function () {
|
||||
expect([1, 2, 3, 1, 2, 3, 1, 2])
|
||||
->sequence(
|
||||
function ($expectation) { $expectation->toBeInt()->toEqual(1); },
|
||||
function ($expectation) { $expectation->toBeInt()->toEqual(2); },
|
||||
function ($expectation) { $expectation->toBeInt()->toEqual(3); },
|
||||
function ($expectation) {
|
||||
$expectation->toBeInt()->toEqual(1);
|
||||
},
|
||||
function ($expectation) {
|
||||
$expectation->toBeInt()->toEqual(2);
|
||||
},
|
||||
function ($expectation) {
|
||||
$expectation->toBeInt()->toEqual(3);
|
||||
},
|
||||
);
|
||||
|
||||
expect(static::getCount())->toBe(16);
|
||||
@ -31,9 +43,15 @@ test('loops back to the start if it runs out of sequence items', function () {
|
||||
test('fails if the number of iterable items is greater than the number of expectations', function () {
|
||||
expect([1, 2])
|
||||
->sequence(
|
||||
function ($expectation) { $expectation->toBeInt()->toEqual(1); },
|
||||
function ($expectation) { $expectation->toBeInt()->toEqual(2); },
|
||||
function ($expectation) { $expectation->toBeInt()->toEqual(3); },
|
||||
function ($expectation) {
|
||||
$expectation->toBeInt()->toEqual(1);
|
||||
},
|
||||
function ($expectation) {
|
||||
$expectation->toBeInt()->toEqual(2);
|
||||
},
|
||||
function ($expectation) {
|
||||
$expectation->toBeInt()->toEqual(3);
|
||||
},
|
||||
);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -60,7 +78,9 @@ test('it can be passed non-callable values', function () {
|
||||
test('it can be passed a mixture of value types', function () {
|
||||
expect(['foo', 'bar', 'baz'])->sequence(
|
||||
'foo',
|
||||
function ($expectation) { $expectation->toEqual('bar')->toBeString(); },
|
||||
function ($expectation) {
|
||||
$expectation->toEqual('bar')->toBeString();
|
||||
},
|
||||
'baz'
|
||||
);
|
||||
|
||||
|
||||
@ -3,7 +3,8 @@
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('pass', function () {
|
||||
expect(function () {})->toBeCallable();
|
||||
expect(function () {
|
||||
})->toBeCallable();
|
||||
expect(null)->not->toBeCallable();
|
||||
});
|
||||
|
||||
@ -14,5 +15,7 @@ test('failures', function () {
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect(function () { return 42; })->not->toBeCallable();
|
||||
expect(function () {
|
||||
return 42;
|
||||
})->not->toBeCallable();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
$test_array = [
|
||||
'a' => 1,
|
||||
'a' => 1,
|
||||
'b',
|
||||
'c' => 'world',
|
||||
'd' => [
|
||||
'c' => 'world',
|
||||
'd' => [
|
||||
'e' => 'hello',
|
||||
],
|
||||
'key.with.dots' => false,
|
||||
|
||||
@ -19,7 +19,8 @@ test('pass', function () {
|
||||
|
||||
test('pass with class', function () {
|
||||
expect(new class() {
|
||||
public $name = 'Nuno';
|
||||
public $name = 'Nuno';
|
||||
|
||||
public $email = 'enunomaduro@gmail.com';
|
||||
})->toMatchObject([
|
||||
'name' => 'Nuno',
|
||||
|
||||
@ -3,60 +3,98 @@
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('passes', function () {
|
||||
expect(function () { throw new RuntimeException(); })->toThrow(RuntimeException::class);
|
||||
expect(function () { throw new RuntimeException(); })->toThrow(Exception::class);
|
||||
expect(function () { throw new RuntimeException(); })->toThrow(function (RuntimeException $e) {});
|
||||
expect(function () { throw new RuntimeException('actual message'); })->toThrow(function (Exception $e) {
|
||||
expect(function () {
|
||||
throw new RuntimeException();
|
||||
})->toThrow(RuntimeException::class);
|
||||
expect(function () {
|
||||
throw new RuntimeException();
|
||||
})->toThrow(Exception::class);
|
||||
expect(function () {
|
||||
throw new RuntimeException();
|
||||
})->toThrow(function (RuntimeException $e) {
|
||||
});
|
||||
expect(function () {
|
||||
throw new RuntimeException('actual message');
|
||||
})->toThrow(function (Exception $e) {
|
||||
expect($e->getMessage())->toBe('actual message');
|
||||
});
|
||||
expect(function () {})->not->toThrow(Exception::class);
|
||||
expect(function () { throw new RuntimeException('actual message'); })->toThrow('actual message');
|
||||
expect(function () { throw new Exception(); })->not->toThrow(RuntimeException::class);
|
||||
expect(function () { throw new RuntimeException('actual message'); })->toThrow(RuntimeException::class, 'actual message');
|
||||
expect(function () { throw new RuntimeException('actual message'); })->toThrow(function (RuntimeException $e) {}, 'actual message');
|
||||
expect(function () {
|
||||
})->not->toThrow(Exception::class);
|
||||
expect(function () {
|
||||
throw new RuntimeException('actual message');
|
||||
})->toThrow('actual message');
|
||||
expect(function () {
|
||||
throw new Exception();
|
||||
})->not->toThrow(RuntimeException::class);
|
||||
expect(function () {
|
||||
throw new RuntimeException('actual message');
|
||||
})->toThrow(RuntimeException::class, 'actual message');
|
||||
expect(function () {
|
||||
throw new RuntimeException('actual message');
|
||||
})->toThrow(function (RuntimeException $e) {
|
||||
}, 'actual message');
|
||||
});
|
||||
|
||||
test('failures 1', function () {
|
||||
expect(function () {})->toThrow(RuntimeException::class);
|
||||
expect(function () {
|
||||
})->toThrow(RuntimeException::class);
|
||||
})->throws(ExpectationFailedException::class, 'Exception "' . RuntimeException::class . '" not thrown.');
|
||||
|
||||
test('failures 2', function () {
|
||||
expect(function () {})->toThrow(function (RuntimeException $e) {});
|
||||
expect(function () {
|
||||
})->toThrow(function (RuntimeException $e) {
|
||||
});
|
||||
})->throws(ExpectationFailedException::class, 'Exception "' . RuntimeException::class . '" not thrown.');
|
||||
|
||||
test('failures 3', function () {
|
||||
expect(function () { throw new Exception(); })->toThrow(function (RuntimeException $e) {});
|
||||
expect(function () {
|
||||
throw new Exception();
|
||||
})->toThrow(function (RuntimeException $e) {
|
||||
});
|
||||
})->throws(ExpectationFailedException::class, 'Failed asserting that Exception Object');
|
||||
|
||||
test('failures 4', function () {
|
||||
expect(function () { throw new Exception('actual message'); })
|
||||
expect(function () {
|
||||
throw new Exception('actual message');
|
||||
})
|
||||
->toThrow(function (Exception $e) {
|
||||
expect($e->getMessage())->toBe('expected message');
|
||||
});
|
||||
})->throws(ExpectationFailedException::class, 'Failed asserting that two strings are identical');
|
||||
|
||||
test('failures 5', function () {
|
||||
expect(function () { throw new Exception('actual message'); })->toThrow('expected message');
|
||||
expect(function () {
|
||||
throw new Exception('actual message');
|
||||
})->toThrow('expected message');
|
||||
})->throws(ExpectationFailedException::class, 'Failed asserting that \'actual message\' contains "expected message".');
|
||||
|
||||
test('failures 6', function () {
|
||||
expect(function () {})->toThrow('actual message');
|
||||
expect(function () {
|
||||
})->toThrow('actual message');
|
||||
})->throws(ExpectationFailedException::class, 'Exception with message "actual message" not thrown');
|
||||
|
||||
test('failures 7', function () {
|
||||
expect(function () { throw new RuntimeException('actual message'); })->toThrow(RuntimeException::class, 'expected message');
|
||||
expect(function () {
|
||||
throw new RuntimeException('actual message');
|
||||
})->toThrow(RuntimeException::class, 'expected message');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect(function () { throw new RuntimeException(); })->not->toThrow(RuntimeException::class);
|
||||
expect(function () {
|
||||
throw new RuntimeException();
|
||||
})->not->toThrow(RuntimeException::class);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('closure missing parameter', function () {
|
||||
expect(function () {})->toThrow(function () {});
|
||||
expect(function () {
|
||||
})->toThrow(function () {
|
||||
});
|
||||
})->throws(InvalidArgumentException::class, 'The given closure must have a single parameter type-hinted as the class string.');
|
||||
|
||||
test('closure missing type-hint', function () {
|
||||
expect(function () {})->toThrow(function ($e) {});
|
||||
expect(function () {
|
||||
})->toThrow(function ($e) {
|
||||
});
|
||||
})->throws(InvalidArgumentException::class, 'The given closure\'s parameter must be type-hinted as the class string.');
|
||||
|
||||
it('can handle a non-defined exception', function () {
|
||||
|
||||
@ -67,7 +67,9 @@ it('skips with falsy', function () {
|
||||
it('runs with truthy closure condition', function () {
|
||||
expect($this->unlessObject)
|
||||
->unless(
|
||||
function () { return '0'; },
|
||||
function () {
|
||||
return '0';
|
||||
},
|
||||
function ($value) {
|
||||
return $value->trueValue->toBeTrue();
|
||||
}
|
||||
@ -80,7 +82,9 @@ it('runs with truthy closure condition', function () {
|
||||
it('skips with falsy closure condition', function () {
|
||||
expect($this->unlessObject)
|
||||
->unless(
|
||||
function () { return '1'; },
|
||||
function () {
|
||||
return '1';
|
||||
},
|
||||
function ($value) {
|
||||
return $value->trueValue->toBeFalse(); // fails
|
||||
}
|
||||
@ -93,7 +97,9 @@ it('skips with falsy closure condition', function () {
|
||||
it('can be used in higher order tests')
|
||||
->expect(true)
|
||||
->unless(
|
||||
function () { return false; },
|
||||
function () {
|
||||
return false;
|
||||
},
|
||||
function ($value) {
|
||||
return $value->toBeFalse();
|
||||
}
|
||||
|
||||
@ -67,7 +67,9 @@ it('skips with falsy', function () {
|
||||
it('runs with truthy closure condition', function () {
|
||||
expect($this->whenObject)
|
||||
->when(
|
||||
function () { return '1'; },
|
||||
function () {
|
||||
return '1';
|
||||
},
|
||||
function ($value) {
|
||||
return $value->trueValue->toBeTrue();
|
||||
}
|
||||
@ -80,7 +82,9 @@ it('runs with truthy closure condition', function () {
|
||||
it('skips with falsy closure condition', function () {
|
||||
expect($this->whenObject)
|
||||
->when(
|
||||
function () { return '0'; },
|
||||
function () {
|
||||
return '0';
|
||||
},
|
||||
function ($value) {
|
||||
return $value->trueValue->toBeFalse(); // fails
|
||||
}
|
||||
@ -93,7 +97,9 @@ it('skips with falsy closure condition', function () {
|
||||
it('can be used in higher order tests')
|
||||
->expect(false)
|
||||
->when(
|
||||
function () { return true; },
|
||||
function () {
|
||||
return true;
|
||||
},
|
||||
function ($value) {
|
||||
return $value->toBeTrue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user