From 0346450a513c6c670aff48a7065860aa1757acd2 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Sun, 10 Oct 2021 01:09:45 +0200 Subject: [PATCH] adds test to check if pipes can add parameters to an expectation --- tests/.snapshots/success.txt | 3 ++- tests/Features/Expect/pipe.php | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index eb3c3000..e8990cbb 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -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 \ No newline at end of file diff --git a/tests/Features/Expect/pipe.php b/tests/Features/Expect/pipe.php index 6234a502..e8574acf 100644 --- a/tests/Features/Expect/pipe.php +++ b/tests/Features/Expect/pipe.php @@ -1,8 +1,10 @@ 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); +});