You are here

public function MaintenanceMode::testUser1 in Metatag 8

Put the site into maintenance mode, see what the meta tags are.

File

tests/src/Functional/MaintenanceMode.php, line 43

Class

MaintenanceMode
Verify handling of maintenance mode pages.

Namespace

Drupal\Tests\metatag\Functional

Code

public function testUser1() {

  // Load the user 1 profile page.
  $this
    ->drupalGet('/user/1');
  $session = $this
    ->assertSession();

  // Confirm the page title is correct.
  $session
    ->responseContains('<title>Access denied | ');
  $session
    ->responseNotContains('<title>admin | ');
  $session
    ->responseNotContains('<title>Site under maintenance | ');

  // Put the site into maintenance mode.
  \Drupal::state()
    ->set('system.maintenance_mode', TRUE);
  Cache::invalidateTags([
    'rendered',
  ]);

  // Load the user 1 profile page again.
  $this
    ->drupalGet('/user/1');

  // Confirm the page title has changed.
  $session
    ->responseNotContains('<title>Access denied | ');
  $session
    ->responseNotContains('<title>admin | ');
  $session
    ->responseContains('<title>Site under maintenance | ');
}