ToolbarIntegrationTest.php in Drupal 9
File
core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php
View source
<?php
namespace Drupal\Tests\toolbar\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class ToolbarIntegrationTest extends WebDriverTestBase {
protected static $modules = [
'toolbar',
'node',
];
protected $defaultTheme = 'stark';
public function testToolbarToggling() {
$admin_user = $this
->drupalCreateUser([
'access toolbar',
'administer site configuration',
'access content overview',
]);
$this
->drupalLogin($admin_user);
$this
->getSession()
->resizeWindow(1200, 600);
$this
->drupalGet('<front>');
$this
->assertNotEmpty($this
->assertSession()
->waitForElement('css', 'body.toolbar-horizontal'));
$this
->assertNotEmpty($this
->assertSession()
->waitForElementVisible('css', '.toolbar-tray'));
$page = $this
->getSession()
->getPage();
$content = $page
->findLink('Content');
$this
->assertTrue($content
->isVisible(), 'Toolbar tray is open by default.');
$page
->clickLink('Manage');
$this
->assertFalse($content
->isVisible(), 'Toolbar tray is closed after clicking the "Manage" link.');
$page
->clickLink('Manage');
$this
->assertTrue($content
->isVisible(), 'Toolbar tray is visible again after clicking the "Manage" button a second time.');
$tray = $page
->findById('toolbar-item-administration-tray');
$this
->assertFalse($tray
->hasClass('toolbar-tray-vertical'), 'Toolbar tray is not vertically oriented by default.');
$page
->pressButton('Vertical orientation');
$this
->assertTrue($tray
->hasClass('toolbar-tray-vertical'), 'After toggling the orientation the toolbar tray is now displayed vertically.');
$page
->pressButton('Horizontal orientation');
$this
->assertTrue($tray
->hasClass('toolbar-tray-horizontal'), 'After toggling the orientation a second time the toolbar tray is displayed horizontally again.');
}
}