Skip to content
Snippets Groups Projects
Commit 7aab1f5c authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2711963 by jibran: Modernized ToolbarIntegrationTest

parent 526501d0
No related branches found
No related tags found
No related merge requests found
...@@ -23,30 +23,29 @@ public function testToolbarToggling() { ...@@ -23,30 +23,29 @@ public function testToolbarToggling() {
$admin_user = $this->drupalCreateUser([ $admin_user = $this->drupalCreateUser([
'access toolbar', 'access toolbar',
'administer site configuration', 'administer site configuration',
'access content overview' 'access content overview',
]); ]);
$this->drupalLogin($admin_user); $this->drupalLogin($admin_user);
$this->drupalGet('<front>'); $this->drupalGet('<front>');
$page = $this->getSession()->getPage();
// Test that it is possible to toggle the toolbar tray. // Test that it is possible to toggle the toolbar tray.
$this->assertElementVisible('#toolbar-link-system-admin_content', 'Toolbar tray is open by default.'); $content = $page->findLink('Content');
$this->click('#toolbar-item-administration'); $this->assertTrue($content->isVisible(), 'Toolbar tray is open by default.');
$this->assertElementNotVisible('#toolbar-link-system-admin_content', 'Toolbar tray is closed after clicking the "Manage" button.'); $page->clickLink('Manage');
$this->click('#toolbar-item-administration'); $this->assertFalse($content->isVisible(), 'Toolbar tray is closed after clicking the "Manage" link.');
$this->assertElementVisible('#toolbar-link-system-admin_content', 'Toolbar tray is visible again after clicking the "Manage" button a second time.'); $page->clickLink('Manage');
$this->assertTrue($content->isVisible(), 'Toolbar tray is visible again after clicking the "Manage" button a second time.');
// Test toggling the toolbar tray between horizontal and vertical. // Test toggling the toolbar tray between horizontal and vertical.
$this->assertElementVisible('#toolbar-item-administration-tray.toolbar-tray-horizontal', 'Toolbar tray is horizontally oriented by default.'); $tray = $page->findById('toolbar-item-administration-tray');
$this->assertElementNotPresent('#toolbar-item-administration-tray.toolbar-tray-vertical', 'Toolbar tray is not vertically oriented by default.'); $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.');
$this->click('#toolbar-item-administration-tray button.toolbar-icon-toggle-vertical'); $page->pressButton('Horizontal orientation');
$this->assertJsCondition('jQuery("#toolbar-item-administration-tray").hasClass("toolbar-tray-vertical")'); $this->assertTrue($tray->hasClass('toolbar-tray-horizontal'), 'After toggling the orientation a second time the toolbar tray is displayed horizontally again.');
$this->assertElementVisible('#toolbar-item-administration-tray.toolbar-tray-vertical', 'After toggling the orientation the toolbar tray is now displayed vertically.');
$this->click('#toolbar-item-administration-tray button.toolbar-icon-toggle-horizontal');
$this->assertJsCondition('jQuery("#toolbar-item-administration-tray").hasClass("toolbar-tray-horizontal")');
$this->assertElementVisible('#toolbar-item-administration-tray.toolbar-tray-horizontal', 'After toggling the orientation a second time the toolbar tray is displayed horizontally again.');
} }
} }
...@@ -41,6 +41,9 @@ protected function initMink() { ...@@ -41,6 +41,9 @@ protected function initMink() {
* The CSS selector identifying the element to check. * The CSS selector identifying the element to check.
* @param string $message * @param string $message
* Optional message to show alongside the assertion. * Optional message to show alongside the assertion.
*
* @deprecated in Drupal 8.1.x, will be removed before Drupal 8.3.x. Use
* \Behat\Mink\Element\NodeElement::isVisible() instead.
*/ */
protected function assertElementVisible($css_selector, $message = '') { protected function assertElementVisible($css_selector, $message = '') {
$this->assertTrue($this->getSession()->getDriver()->isVisible(CssSelector::toXPath($css_selector)), $message); $this->assertTrue($this->getSession()->getDriver()->isVisible(CssSelector::toXPath($css_selector)), $message);
...@@ -53,6 +56,9 @@ protected function assertElementVisible($css_selector, $message = '') { ...@@ -53,6 +56,9 @@ protected function assertElementVisible($css_selector, $message = '') {
* The CSS selector identifying the element to check. * The CSS selector identifying the element to check.
* @param string $message * @param string $message
* Optional message to show alongside the assertion. * Optional message to show alongside the assertion.
*
* @deprecated in Drupal 8.1.x, will be removed before Drupal 8.3.x. Use
* \Behat\Mink\Element\NodeElement::isVisible() instead.
*/ */
protected function assertElementNotVisible($css_selector, $message = '') { protected function assertElementNotVisible($css_selector, $message = '') {
$this->assertFalse($this->getSession()->getDriver()->isVisible(CssSelector::toXPath($css_selector)), $message); $this->assertFalse($this->getSession()->getDriver()->isVisible(CssSelector::toXPath($css_selector)), $message);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment