Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpFoundation] Constraint ResponseHeaderSame now shows the actual header value#49227

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jschaedl wants to merge2 commits intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromjschaedl:more-talkative-response-header-same-constraint

Conversation

jschaedl
Copy link
Contributor

@jschaedljschaedl commentedFeb 3, 2023
edited
Loading

QA
Branch?7.1
Bug fix?no
New feature?small adjustment
Deprecations?no
Tickets-
LicenseMIT
Doc PR-

I am using theBrowserKitAssertionsTrait::assertResponseHeaderSame(...) quite a lot in my functional tests and it would be nice to see the actual header value in case the expected one doesn't match. So instead of just seeing:

Failed asserting that the Response has header "Cache-Control" with value "public".

it would be helpful to see:

Failed asserting that the Response has header "Cache-Control" with value "public", value of header "Cache-Control" is "no-cache, private".

@carsonbotcarsonbot added this to the6.3 milestoneFeb 3, 2023
@jschaedljschaedlforce-pushed themore-talkative-response-header-same-constraint branch from621b10e to2cab626CompareFebruary 3, 2023 16:31
@javiereguiluz
Copy link
Member

I like this! A quick question: what happens if the header doesn't exist? Should we expect a message error like this?

Failed asserting that the Response has header "Cache-Control" with value "public",the header "Cache-Control" was not included in the response.
jschaedl and xabbuh reacted with thumbs up emoji

@jschaedl
Copy link
ContributorAuthor

Hi@javiereguiluz,

I guess most people check for header existence before they assert the header value, but I think it makes sense to add thenull case, yes.

@jschaedljschaedlforce-pushed themore-talkative-response-header-same-constraint branch from2cab626 to29ae98dCompareFebruary 6, 2023 11:36
@nicolas-grekasnicolas-grekas modified the milestones:6.3,6.4May 23, 2023
@jschaedljschaedlforce-pushed themore-talkative-response-header-same-constraint branch from29ae98d to39bfb97CompareOctober 11, 2023 19:57
@jschaedljschaedlforce-pushed themore-talkative-response-header-same-constraint branch from39bfb97 tob421a7fCompareNovember 12, 2023 09:27
@nicolas-grekasnicolas-grekas modified the milestones:6.4,7.1Nov 15, 2023
@jschaedljschaedlforce-pushed themore-talkative-response-header-same-constraint branch fromb421a7f to90e11a4CompareNovember 26, 2023 18:38

public function __construct(string $headerName, string $expectedValue)
public function __construct(string $headerName, string $expectedValue, bool $logicalNot = false)
Copy link
ContributorAuthor

@jschaedljschaedlNov 26, 2023
edited
Loading

Choose a reason for hiding this comment

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

Why is this needed?

Let me try to explain:

The test case for theassertResponseHeaderNotSame

publicfunctiontestAssertResponseHeaderNotSame(){$this->getResponseTester(newResponse())->assertResponseHeaderNotSame('Cache-Control','public');$this->expectException(AssertionFailedError::class);$this->expectExceptionMessage('Failed asserting that the Response does not have header "Cache-Control" with value "no-cache, private", value of header "Cache-Control" is "no-cache, private".');$this->getResponseTester(newResponse())->assertResponseHeaderNotSame('Cache-Control','no-cache, private');}

failed with:

Failed asserting that exception message

'Failed asserting that the Response does not have header "Cache-Control" with value "no-cache, private", value of header "Cache-Control" isnot "no-cache, private".'

contains

'Failed asserting that the Response does not have header "Cache-Control" with value "no-cache, private", value of header "Cache-Control" is "no-cache, private".'.

  • Please notice thenot in the actual exception message.

This is happening because theassertResponseHeaderNotSame assertion uses aResponseHeaderSame constraint internally. This constraint is wrapped by aLogicalNot which is in fact the reason all messages for this constraint are negated.

So the best idea I had so far is to "ignore" the logical not case.

@jschaedljschaedlforce-pushed themore-talkative-response-header-same-constraint branch 2 times, most recently from8854686 toadafb8bCompareNovember 29, 2023 17:09
@jschaedljschaedlforce-pushed themore-talkative-response-header-same-constraint branch fromadafb8b to81ecde5CompareNovember 29, 2023 21:45
@xabbuhxabbuh modified the milestones:7.1,7.2May 15, 2024
@fabpotfabpot modified the milestones:7.2,7.3Nov 20, 2024
@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

6 participants
@jschaedl@javiereguiluz@fabpot@nicolas-grekas@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp