Commit 477fbfd2 authored by catch's avatar catch

Issue #2863597 by Lendude, Jo Fitzgerald, michielnugter, nlisgo, dawehner:...

Issue #2863597 by Lendude, Jo Fitzgerald, michielnugter, nlisgo, dawehner: Convert web tests to browser tests for toolbar module
parent 9e7f7cd4
<?php <?php
namespace Drupal\toolbar\Tests; namespace Drupal\Tests\toolbar\Functional;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\language\Entity\ConfigurableLanguage; use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\simpletest\WebTestBase; use Drupal\Tests\BrowserTestBase;
use Drupal\user\RoleInterface; use Drupal\user\RoleInterface;
/** /**
...@@ -25,7 +26,7 @@ ...@@ -25,7 +26,7 @@
* *
* @group toolbar * @group toolbar
*/ */
class ToolbarAdminMenuTest extends WebTestBase { class ToolbarAdminMenuTest extends BrowserTestBase {
/** /**
* A user with permission to access the administrative toolbar. * A user with permission to access the administrative toolbar.
...@@ -297,7 +298,7 @@ public function testLocaleTranslationSubtreesHashCacheClear() { ...@@ -297,7 +298,7 @@ public function testLocaleTranslationSubtreesHashCacheClear() {
// Assume this is the only result. // Assume this is the only result.
// Translate the string to a random string. // Translate the string to a random string.
$textarea = current($this->xpath('//textarea')); $textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name']; $lid = (string) $textarea->getAttribute('name');
$edit = [ $edit = [
$lid => $translation, $lid => $translation,
]; ];
...@@ -330,8 +331,8 @@ public function testSubtreesJsonRequest() { ...@@ -330,8 +331,8 @@ public function testSubtreesJsonRequest() {
// Request a new page to refresh the drupalSettings object. // Request a new page to refresh the drupalSettings object.
$subtrees_hash = $this->getSubtreesHash(); $subtrees_hash = $this->getSubtreesHash();
$ajax_result = $this->drupalGetAjax('toolbar/subtrees/' . $subtrees_hash); $this->drupalGet('toolbar/subtrees/' . $subtrees_hash, ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']], ['X-Requested-With: XMLHttpRequest']);
$this->assertResponse('200'); $ajax_result = json_decode($this->getSession()->getPage()->getContent(), TRUE);
$this->assertEqual($ajax_result[0]['command'], 'setToolbarSubtrees', 'Subtrees response uses the correct command.'); $this->assertEqual($ajax_result[0]['command'], 'setToolbarSubtrees', 'Subtrees response uses the correct command.');
$this->assertEqual(array_keys($ajax_result[0]['subtrees']), ['system-admin_content', 'system-admin_structure', 'system-themes_page', 'system-modules_list', 'system-admin_config', 'entity-user-collection', 'front'], 'Correct subtrees returned.'); $this->assertEqual(array_keys($ajax_result[0]['subtrees']), ['system-admin_content', 'system-admin_structure', 'system-themes_page', 'system-modules_list', 'system-admin_config', 'entity-user-collection', 'front'], 'Correct subtrees returned.');
} }
......
<?php <?php
namespace Drupal\toolbar\Tests; namespace Drupal\Tests\toolbar\Functional;
use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\Cache;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber; use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
use Drupal\simpletest\WebTestBase;
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait; use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
use Drupal\Tests\BrowserTestBase;
/** /**
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* *
* @group toolbar * @group toolbar
*/ */
class ToolbarCacheContextsTest extends WebTestBase { class ToolbarCacheContextsTest extends BrowserTestBase {
use AssertPageCacheContextsAndTagsTrait; use AssertPageCacheContextsAndTagsTrait;
......
<?php <?php
namespace Drupal\toolbar\Tests; namespace Drupal\Tests\toolbar\Functional;
use Drupal\simpletest\WebTestBase; use Drupal\Tests\BrowserTestBase;
/** /**
* Tests that the toolbar icon class remains for translated menu items. * Tests that the toolbar icon class remains for translated menu items.
* *
* @group toolbar * @group toolbar
*/ */
class ToolbarMenuTranslationTest extends WebTestBase { class ToolbarMenuTranslationTest extends BrowserTestBase {
/** /**
* A user with permission to access the administrative toolbar. * A user with permission to access the administrative toolbar.
...@@ -66,7 +66,7 @@ public function testToolbarClasses() { ...@@ -66,7 +66,7 @@ public function testToolbarClasses() {
// Translate the menu item. // Translate the menu item.
$menu_item_translated = $this->randomMachineName(); $menu_item_translated = $this->randomMachineName();
$textarea = current($this->xpath('//textarea')); $textarea = current($this->xpath('//textarea'));
$lid = (string) $textarea[0]['name']; $lid = (string) $textarea->getAttribute('name');
$edit = [ $edit = [
$lid => $menu_item_translated, $lid => $menu_item_translated,
]; ];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment