mirror of
https://github.com/pestphp/pest.git
synced 2026-03-13 03:07:22 +01:00
Merge pull request #466 from pestphp/rename_tap
Renames `tap` to `defer`.
This commit is contained in:
@ -52,9 +52,9 @@ final class HigherOrderCallables
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tap into the test case to perform an action and return the test case.
|
* Execute the given callable after the test has executed the setup method.
|
||||||
*/
|
*/
|
||||||
public function tap(callable $callable): object
|
public function defer(callable $callable): object
|
||||||
{
|
{
|
||||||
Reflection::bindCallableWithData($callable);
|
Reflection::bindCallableWithData($callable);
|
||||||
|
|
||||||
|
|||||||
@ -21,9 +21,9 @@ it('resolves expect callables correctly')
|
|||||||
test('does not treat method names as callables')
|
test('does not treat method names as callables')
|
||||||
->expect('it')->toBeString();
|
->expect('it')->toBeString();
|
||||||
|
|
||||||
it('can tap into the test')
|
it('can defer a method until after test setup')
|
||||||
->expect('foo')->toBeString()
|
->expect('foo')->toBeString()
|
||||||
->tap(function () { expect($this)->toBeInstanceOf(TestCase::class); })
|
->defer(function () { expect($this)->toBeInstanceOf(TestCase::class); })
|
||||||
->toBe('foo')
|
->toBe('foo')
|
||||||
->and('hello world')->toBeString();
|
->and('hello world')->toBeString();
|
||||||
|
|
||||||
@ -32,15 +32,15 @@ it('can pass datasets into the expect callables')
|
|||||||
->expect(function (...$numbers) { return $numbers; })->toBe([1, 2, 3])
|
->expect(function (...$numbers) { return $numbers; })->toBe([1, 2, 3])
|
||||||
->and(function (...$numbers) { return $numbers; })->toBe([1, 2, 3]);
|
->and(function (...$numbers) { return $numbers; })->toBe([1, 2, 3]);
|
||||||
|
|
||||||
it('can pass datasets into the tap callable')
|
it('can pass datasets into the defer callable')
|
||||||
->with([[1, 2, 3]])
|
->with([[1, 2, 3]])
|
||||||
->tap(function (...$numbers) { expect($numbers)->toBe([1, 2, 3]); });
|
->defer(function (...$numbers) { expect($numbers)->toBe([1, 2, 3]); });
|
||||||
|
|
||||||
it('can pass shared datasets into callables')
|
it('can pass shared datasets into callables')
|
||||||
->with('numbers.closure.wrapped')
|
->with('numbers.closure.wrapped')
|
||||||
->expect(function ($value) { return $value; })
|
->expect(function ($value) { return $value; })
|
||||||
->and(function ($value) { return $value; })
|
->and(function ($value) { return $value; })
|
||||||
->tap(function ($value) { expect($value)->toBeInt(); })
|
->defer(function ($value) { expect($value)->toBeInt(); })
|
||||||
->toBeInt();
|
->toBeInt();
|
||||||
|
|
||||||
afterEach()->assertTrue(true);
|
afterEach()->assertTrue(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user