Version 1
[yaffs-website] / web / core / modules / toolbar / tests / src / FunctionalJavascript / ToolbarIntegrationTest.php
1 <?php
2
3 namespace Drupal\Tests\toolbar\FunctionalJavascript;
4
5 use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
6
7 /**
8  * Tests the JavaScript functionality of the toolbar.
9  *
10  * @group toolbar
11  */
12 class ToolbarIntegrationTest extends JavascriptTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static $modules = ['toolbar', 'node'];
18
19   /**
20    * Tests if the toolbar can be toggled with JavaScript.
21    */
22   public function testToolbarToggling() {
23     $admin_user = $this->drupalCreateUser([
24       'access toolbar',
25       'administer site configuration',
26       'access content overview',
27     ]);
28     $this->drupalLogin($admin_user);
29
30     $this->drupalGet('<front>');
31     $page = $this->getSession()->getPage();
32
33     // Test that it is possible to toggle the toolbar tray.
34     $content = $page->findLink('Content');
35     $this->assertTrue($content->isVisible(), 'Toolbar tray is open by default.');
36     $page->clickLink('Manage');
37     $this->assertFalse($content->isVisible(), 'Toolbar tray is closed after clicking the "Manage" link.');
38     $page->clickLink('Manage');
39     $this->assertTrue($content->isVisible(), 'Toolbar tray is visible again after clicking the "Manage" button a second time.');
40
41     // Test toggling the toolbar tray between horizontal and vertical.
42     $tray = $page->findById('toolbar-item-administration-tray');
43     $this->assertFalse($tray->hasClass('toolbar-tray-vertical'), 'Toolbar tray is not vertically oriented by default.');
44     $page->pressButton('Vertical orientation');
45     $this->assertTrue($tray->hasClass('toolbar-tray-vertical'), 'After toggling the orientation the toolbar tray is now displayed vertically.');
46
47     $page->pressButton('Horizontal orientation');
48     $this->assertTrue($tray->hasClass('toolbar-tray-horizontal'), 'After toggling the orientation a second time the toolbar tray is displayed horizontally again.');
49   }
50
51 }