Skip to content
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

responseHeaderEquals() can no longer be used to check for existence #862

Open
longwave opened this issue Dec 10, 2023 · 3 comments
Open

Comments

@longwave
Copy link

longwave commented Dec 10, 2023

Previously in Drupal we used responseHeaderEquals() to check for the non-existence of a header by looking for NULL:

    $this->assertSession()->responseHeaderEquals('Access-Control-Allow-Origin', NULL);

Since Mink 1.11 this no longer works as $value is typed as string, although getResponseHeader() can still return NULL:

    public function responseHeaderEquals(string $name, string $value)
    {
        $actual = $this->session->getResponseHeader($name);

There appears to be no supported way to check that a header does not exist. We had in fact already added responseHeader[Not]Exists() helper methods to Drupal, but after upgrading to Mink 1.11 we found we had not converted all cases to use them.

@stof
Copy link
Member

stof commented Dec 11, 2023

In 1.10.0, the documented signature of the method was already saying that the type for $value was string: https://github.com/minkphp/Mink/blob/v1.10.0/src/WebAssert.php#L149-L156

The fact that you passed null and it worked was an undefined behavior.

@andypost
Copy link
Contributor

As headers are strings, how any of them can be NULL?
For example the Access-Control-Allow-Origin exists or missing

@stof
Copy link
Member

stof commented Dec 11, 2023

@andypost I think this was working by luck because getResponseHeader returns null when the header is missing (so this was testing that the header is missing by comparing it to null). But this was never intended to work.

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

No branches or pull requests

3 participants