Mink
Mink copied to clipboard
responseHeaderEquals() can no longer be used to check for existence
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.
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.
As headers are strings, how any of them can be NULL
?
For example the Access-Control-Allow-Origin
exists or missing
@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.