function WebAssert::responseHeaderExists

Same name in other branches
  1. 10 core/tests/Drupal/Tests/WebAssert.php \Drupal\Tests\WebAssert::responseHeaderExists()
  2. 11.x core/tests/Drupal/Tests/WebAssert.php \Drupal\Tests\WebAssert::responseHeaderExists()

Asserts that the current response header has a specific entry.

Parameters

string $name: The name of the header entry to check existence of.

string $message: The failure message.

File

core/tests/Drupal/Tests/WebAssert.php, line 78

Class

WebAssert
Defines a class with methods for asserting presence of elements during tests.

Namespace

Drupal\Tests

Code

public function responseHeaderExists(string $name, string $message = '') : void {
    if ($message === '') {
        $message = "Failed asserting that the response has a '{$name}' header.";
    }
    $headers = $this->session
        ->getResponseHeaders();
    $constraint = new ArrayHasKey($name);
    Assert::assertThat($headers, $constraint, $message);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.