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

Open
#862 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
testing

Research direction

Start by examining responseHeaderEquals() and getResponseHeader(), focusing on the typed $value parameter and the behavior when a header is absent. Reproduce the NULL case in the existing assertion tests, then make the supported absence check work and verify both existing-header and missing-header behavior.

Written by the indexing model from the issue text.

Description

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.

Dominant language
PHP
Stars
1.6k
Forks
286
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from minkphp/Mink

All issues in minkphp/Mink

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.