You are here

protected function WebTestBase::assertHeader in SimpleTest 8.3

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.

File

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);
}