mirror of
https://github.com/pestphp/pest.git
synced 2026-03-07 00:07:22 +01:00
adds test to check if pipes can add parameters to an expectation
This commit is contained in:
@ -186,6 +186,7 @@
|
||||
✓ intercept stops the pipeline
|
||||
✓ interception is called only when filter is met
|
||||
✓ intercept can be filtered with a closure
|
||||
✓ intercept can add new parameters to the expectation
|
||||
|
||||
PASS Tests\Features\Expect\ray
|
||||
✓ ray calls do not fail when ray is not installed
|
||||
@ -730,5 +731,5 @@
|
||||
✓ it is a test
|
||||
✓ it uses correct parent class
|
||||
|
||||
Tests: 4 incompleted, 9 skipped, 486 passed
|
||||
Tests: 4 incompleted, 9 skipped, 487 passed
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
use function PHPUnit\Framework\assertEquals;
|
||||
use function PHPUnit\Framework\assertEqualsIgnoringCase;
|
||||
use function PHPUnit\Framework\assertInstanceOf;
|
||||
use function PHPUnit\Framework\assertIsNumeric;
|
||||
use function PHPUnit\Framework\assertSame;
|
||||
|
||||
class Number
|
||||
{
|
||||
@ -118,6 +120,19 @@ expect()->pipe('toBe', function ($next, $expected) use ($state) {
|
||||
$next();
|
||||
});
|
||||
|
||||
/*
|
||||
* Overrides toBe check strings ignoring case
|
||||
*/
|
||||
expect()->intercept('toBe', function ($value) {
|
||||
return is_string($value);
|
||||
}, function ($expected, $ignoreCase = false) {
|
||||
if ($ignoreCase) {
|
||||
assertEqualsIgnoringCase($expected, $this->value);
|
||||
} else {
|
||||
assertSame($expected, $this->value);
|
||||
}
|
||||
});
|
||||
|
||||
test('pipe is applied and can stop pipeline', function () use ($state) {
|
||||
$letter = new Character('A');
|
||||
|
||||
@ -219,3 +234,7 @@ test('intercept can be filtered with a closure', function () use ($state) {
|
||||
->runCount->toHaveKey('wildcard', 1)
|
||||
->appliedCount->toHaveKey('wildcard', 1);
|
||||
});
|
||||
|
||||
test('intercept can add new parameters to the expectation', function () {
|
||||
expect('Foo')->toBe('foo', true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user