You are here

function ToolbarAdminMenuTest::testLanguageSwitching in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php \Drupal\toolbar\Tests\ToolbarAdminMenuTest::testLanguageSwitching()

Test that subtrees hashes vary by the language of the page.

File

core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php, line 347
Contains \Drupal\toolbar\Tests\ToolbarAdminMenuTest.

Class

ToolbarAdminMenuTest
Tests the caching of the admin menu subtree items.

Namespace

Drupal\toolbar\Tests

Code

function testLanguageSwitching() {

  // Create a new language with the langcode 'xx'.
  $langcode = 'xx';
  $language = ConfigurableLanguage::createFromLangcode($langcode);
  $language
    ->save();

  // The language path processor is just registered for more than one
  // configured language, so rebuild the container now that we are
  // multilingual.
  $this
    ->rebuildContainer();

  // Get a page with the new language langcode in the URL.
  $this
    ->drupalGet('test-page', array(
    'language' => $language,
  ));

  // Assert different hash.
  $new_subtree_hash = $this
    ->getSubtreesHash();

  // Assert that the old admin menu subtree hash and the new admin menu
  // subtree hash are different.
  $this
    ->assertTrue($new_subtree_hash, 'A valid hash value for the admin menu subtrees was created.');
  $this
    ->assertNotEqual($this->hash, $new_subtree_hash, 'The user-specific subtree menu hash has been updated.');
}