function AdminTest::testCompactMode
Same name in other branches
- 9 core/modules/system/tests/src/Functional/System/AdminTest.php \Drupal\Tests\system\Functional\System\AdminTest::testCompactMode()
- 8.9.x core/modules/system/tests/src/Functional/System/AdminTest.php \Drupal\Tests\system\Functional\System\AdminTest::testCompactMode()
- 10 core/modules/system/tests/src/Functional/System/AdminTest.php \Drupal\Tests\system\Functional\System\AdminTest::testCompactMode()
Tests compact mode.
File
-
core/
modules/ system/ tests/ src/ Functional/ System/ AdminTest.php, line 153
Class
- AdminTest
- Tests output on administrative pages and compact mode functionality.
Namespace
Drupal\Tests\system\Functional\SystemCode
public function testCompactMode() : void {
$session = $this->getSession();
// 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->assertSession()
->statusCodeEquals(200);
// Verify that the user is redirected to the front page after turning on
// compact mode.
$this->assertSession()
->addressEquals($frontpage_url);
$this->assertEquals('1', $session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode turns on.');
$this->drupalGet('admin/compact/on');
$this->assertEquals('1', $session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode remains on after a repeat call.');
$this->drupalGet('');
$this->assertEquals('1', $session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode persists on new requests.');
$this->drupalGet('admin/compact/off');
$this->assertSession()
->statusCodeEquals(200);
// Verify that the user is redirected to the front page after turning off
// compact mode.
$this->assertSession()
->addressEquals($frontpage_url);
$this->assertNull($session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode turns off.');
$this->drupalGet('admin/compact/off');
$this->assertNull($session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode remains off after a repeat call.');
$this->drupalGet('');
$this->assertNull($session->getCookie('Drupal.visitor.admin_compact_mode'), 'Compact mode persists off new requests.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.