Skip to content

[FrameworkBundle] Allow BrowserKit relative URL redirect assert #44629

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 0 commits into from
Oct 1, 2023

Conversation

julienfalque
Copy link
Contributor

Q A
Branch? 6.1
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

In tests, when asserting a redirect happens, it can be convenient to skip the host part in the expected location, assuming it is the same as the one from the request's URL.

@carsonbot carsonbot added this to the 6.1 milestone Dec 14, 2021
@julienfalque julienfalque force-pushed the relative-redirect-assert branch 5 times, most recently from c605745 to d864b80 Compare December 14, 2021 19:26
@fabpot fabpot modified the milestones: 6.1, 6.2 May 20, 2022
@julienfalque julienfalque force-pushed the relative-redirect-assert branch from d864b80 to a720f67 Compare May 28, 2022 09:28
@nicolas-grekas nicolas-grekas modified the milestones: 6.2, 6.3 Nov 5, 2022
@@ -47,7 +47,13 @@ public static function assertResponseRedirects(string $expectedLocation = null,
{
$constraint = new ResponseConstraint\ResponseIsRedirected();
if ($expectedLocation) {
$constraint = LogicalAnd::fromConstraints($constraint, new ResponseConstraint\ResponseHeaderSame('Location', $expectedLocation));
if (class_exists(ResponseConstraint\ResponseHeaderLocationSame::class)) {
$locationConstraint = new ResponseConstraint\ResponseHeaderLocationSame(self::getRequest(), $expectedLocation);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to have a more generic ResponseHeaderUrlSame for all headers consisting of a URL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. The behavior for Location depends on the URL of the request, would this behavior make sense for any kind of URL?

@julienfalque julienfalque force-pushed the relative-redirect-assert branch 3 times, most recently from 59deba5 to 6cdb5d4 Compare December 14, 2022 20:00
@nicolas-grekas nicolas-grekas modified the milestones: 6.3, 6.4 May 23, 2023
@fabpot
Copy link
Member

fabpot commented Oct 1, 2023

Thank you @julienfalque.

@fabpot fabpot closed this Oct 1, 2023
@fabpot fabpot force-pushed the relative-redirect-assert branch from 6cdb5d4 to fb4e9ae Compare October 1, 2023 07:06
@fabpot fabpot merged commit 0f8efc1 into symfony:6.4 Oct 1, 2023
@julienfalque julienfalque deleted the relative-redirect-assert branch October 17, 2023 12:28
@fabpot fabpot mentioned this pull request Oct 21, 2023
@fabpot fabpot mentioned this pull request Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants