You are here

function AdminTest::testCompactMode in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/src/Tests/System/AdminTest.php \Drupal\system\Tests\System\AdminTest::testCompactMode()

Test compact mode.

File

core/modules/system/src/Tests/System/AdminTest.php, line 151
Contains \Drupal\system\Tests\System\AdminTest.

Class

AdminTest
Tests output on administrative pages and compact mode functionality.

Namespace

Drupal\system\Tests\System

Code

function testCompactMode() {

  // The front page defaults to 'user/login', which redirects to 'user/{user}'
  // for authenticated users. We cannot use '<front>', since this does not
  // match the redirected url.
  $frontpage_url = 'user/' . $this->adminUser
    ->id();
  $this
    ->drupalGet('admin/compact/on');
  $this
    ->assertResponse(200, 'A valid page is returned after turning on compact mode.');
  $this
    ->assertUrl($frontpage_url, array(), 'The user is redirected to the front page after turning on compact mode.');
  $this
    ->assertTrue($this->cookies['Drupal.visitor.admin_compact_mode']['value'], 'Compact mode turns on.');
  $this
    ->drupalGet('admin/compact/on');
  $this
    ->assertTrue($this->cookies['Drupal.visitor.admin_compact_mode']['value'], 'Compact mode remains on after a repeat call.');
  $this
    ->drupalGet('');
  $this
    ->assertTrue($this->cookies['Drupal.visitor.admin_compact_mode']['value'], 'Compact mode persists on new requests.');
  $this
    ->drupalGet('admin/compact/off');
  $this
    ->assertResponse(200, 'A valid page is returned after turning off compact mode.');
  $this
    ->assertUrl($frontpage_url, array(), 'The user is redirected to the front page after turning off compact mode.');
  $this
    ->assertEqual($this->cookies['Drupal.visitor.admin_compact_mode']['value'], 'deleted', 'Compact mode turns off.');
  $this
    ->drupalGet('admin/compact/off');
  $this
    ->assertEqual($this->cookies['Drupal.visitor.admin_compact_mode']['value'], 'deleted', 'Compact mode remains off after a repeat call.');
  $this
    ->drupalGet('');
  $this
    ->assertTrue($this->cookies['Drupal.visitor.admin_compact_mode']['value'], 'Compact mode persists on new requests.');
}