Skip to content

Commit 7de96ad

Browse files
crynoboneshaedrich
andauthored
[12.x] Fix TestResponse::assertSessionMissing() when given an array of keys (#55800)
* [12.x] Fix `TestResponse::assertSessionMissing()` when given an array of keys PR #55763 remove `else` from `is_array($key)` condition which cause regression bug to occur on existing application. Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Update tests/Testing/TestResponseTest.php Co-authored-by: Sebastian Hädrich <11225821+shaedrich@users.noreply.github.com> --------- Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> Co-authored-by: Sebastian Hädrich <11225821+shaedrich@users.noreply.github.com>
1 parent ae955ad commit 7de96ad

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Illuminate/Testing/TestResponse.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,8 @@ public function assertSessionMissing($key, $value = null)
16701670
foreach ($key as $value) {
16711671
$this->assertSessionMissing($value);
16721672
}
1673+
1674+
return $this;
16731675
}
16741676

16751677
if (is_null($value)) {

tests/Testing/TestResponseTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use JsonSerializable;
2828
use Mockery as m;
2929
use PHPUnit\Framework\AssertionFailedError;
30+
use PHPUnit\Framework\Attributes\TestWith;
3031
use PHPUnit\Framework\ExpectationFailedException;
3132
use PHPUnit\Framework\TestCase;
3233
use Symfony\Component\HttpFoundation\BinaryFileResponse;
@@ -2807,7 +2808,10 @@ public function testAssertSessionMissing()
28072808
$response->assertSessionMissing('foo');
28082809
}
28092810

2810-
public function testAssertSessionMissingValue()
2811+
#[TestWith(['foo', 'badvalue'])]
2812+
#[TestWith(['foo', null])]
2813+
#[TestWith([['foo', 'bar'], null])]
2814+
public function testAssertSessionMissingValue(array|string $key, mixed $value)
28112815
{
28122816
$this->expectException(AssertionFailedError::class);
28132817

@@ -2816,7 +2820,7 @@ public function testAssertSessionMissingValue()
28162820
$store->put('foo', 'goodvalue');
28172821

28182822
$response = TestResponse::fromBaseResponse(new Response());
2819-
$response->assertSessionMissing('foo', 'badvalue');
2823+
$response->assertSessionMissing($key, $value);
28202824
}
28212825

28222826
public function testAssertSessionHasInput()

0 commit comments

Comments
 (0)