annotate core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php @ 0:4c8ae668cc8c

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