You are here

public function HttpResponseHeadersTestCase::testHeaderRuleVisibilityListedEmpty in HTTP Response Headers 7

Test header rule with empty "pages".

File

./http_response_headers.test, line 79
Tests for http_response_headers.module.

Class

HttpResponseHeadersTestCase
@file Tests for http_response_headers.module.

Code

public function testHeaderRuleVisibilityListedEmpty() {

  // Create a random name for the header rule.
  $name = $this
    ->randomName(8);
  $visibility_options = array();
  $visibility_options['visibility'] = BLOCK_VISIBILITY_LISTED;
  $header = 'Cache-Control';
  $header_value = 'max-age=3600';
  $this
    ->createHeaderRule(strtolower($name), $name, $header, $header_value, $visibility_options);
  $this
    ->drupalGet('');
  $headers = $this
    ->drupalGetHeaders();
  $this
    ->assertNotEqual($headers[strtolower($header)], $header_value, 'Header rule was not applied according to visibility rules.');
  $this
    ->drupalGet('user');
  $headers = $this
    ->drupalGetHeaders();
  $this
    ->assertNotEqual($headers[strtolower($header)], $header_value, 'Header rule was not applied according to visibility rules regardless of path case.');

  // Confirm that the header rule is not applied to anonymous users.
  $this
    ->drupalLogout();
  $this
    ->drupalGet('');
  $headers = $this
    ->drupalGetHeaders();
  $this
    ->assertNotEqual($headers[strtolower($header)], $header_value, 'Header rule was not applied to anonymous user.');
}