Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[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
base:7.4
Are you sure you want to change the base?
[HttpFoundation] Constraint ResponseHeaderSame now shows the actual header value#49227
Uh oh!
There was an error while loading.Please reload this page.
Conversation
621b10e
to2cab626
CompareI like this! A quick question: what happens if the header doesn't exist? Should we expect a message error like this?
|
I guess most people check for header existence before they assert the header value, but I think it makes sense to add the |
2cab626
to29ae98d
Compare29ae98d
to39bfb97
Compare39bfb97
tob421a7f
Compareb421a7f
to90e11a4
Comparepublic function __construct(string $headerName, string $expectedValue) | ||
public function __construct(string $headerName, string $expectedValue, bool $logicalNot = false) |
There was a problem hiding this comment.
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.
8854686
toadafb8b
Compareadafb8b
to81ecde5
Compare
Uh oh!
There was an error while loading.Please reload this page.
I am using the
BrowserKitAssertionsTrait::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:it would be helpful to see: