function WebTestBase::assertHeader

Check if a HTTP response header exists and has the expected value.

Parameters

string $header: The header key, example: Content-Type

string $value: The header value.

string $message: (optional) A message to display with the assertion.

string $group: (optional) The group this message is in, which is displayed in a column in test output. Use 'Debug' to indicate this is debugging output. Do not translate this string. Defaults to 'Other'; most tests do not override this default.

Return value

bool TRUE if the assertion succeeded, FALSE otherwise.

1 call to WebTestBase::assertHeader()
UITestBase::drupalGet in core/modules/views_ui/src/Tests/UITestBase.php
Retrieves a Drupal path or an absolute path.

File

core/modules/simpletest/src/WebTestBase.php, line 1903

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function assertHeader($header, $value, $message = '', $group = 'Browser') {
    $header_value = $this->drupalGetHeader($header);
    return $this->assertTrue($header_value == $value, $message ? $message : 'HTTP response header ' . $header . ' with value ' . $value . ' found, actual value: ' . $header_value, $group);
}

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