Skip to content

[12.x] Update assertSessionMissing() signature to match assertSessionHas() #55763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025

Conversation

nexxai
Copy link
Contributor

@nexxai nexxai commented May 17, 2025

Problem

Until now, it has been impossible to check the session to confirm that a specific value is not set.

For example: let's say I have a session key called guest_id which contains a value that must rotate to a new randomly generated string on every page view. Prior to this patch, there was no easy way to validate that the value had actually changed. You could assert that the key was the same or that the value was missing, but you could not check that it had rotated to some new unknown value.

NOTE: This is not a breaking change

Proposed solution

I mostly replicated the logic from assertSessionHas() above to allow a user to provide a specific value that must not be set in a specific key. Also like assertSessionHas(), it preserves the original logic where if no value is provided, it just checks that the key is missing altogether.

@nexxai nexxai changed the title [12.x] Update assertSessionMissing() to allow checking for specific value [12.x] Update assertSessionMissing() signature to match assertSessionHas() May 18, 2025
@taylorotwell taylorotwell merged commit 2dcbcec into laravel:12.x May 19, 2025
61 checks passed
@jasonmccreary
Copy link
Contributor

PSA: While this is not a breaking change, if you were accidentally passing a second argument to assertSessionMissing (say from a copy/paste oversight), this assertion will suddenly fail in Laravel 12.15. If so, just remove the second argument as you never should have been passing it anyway. 😅

crynobone added a commit that referenced this pull request May 21, 2025
… 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>
taylorotwell pushed a commit that referenced this pull request May 21, 2025
… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants