function ToolbarAdminMenuTest::assertDifferentHash

Same name and namespace in other branches
  1. 9 core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php \Drupal\Tests\toolbar\Functional\ToolbarAdminMenuTest::assertDifferentHash()
  2. 8.9.x core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php \Drupal\Tests\toolbar\Functional\ToolbarAdminMenuTest::assertDifferentHash()
  3. 10 core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php \Drupal\Tests\toolbar\Functional\ToolbarAdminMenuTest::assertDifferentHash()

Checks the subtree hash of the current page with that of the previous page.

Asserts that the subtrees hash on a fresh page GET is different from the subtree hash from the previous page GET.

@internal

4 calls to ToolbarAdminMenuTest::assertDifferentHash()
ToolbarAdminMenuTest::testMenuLinkUpdateSubtreesHashCacheClear in core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php
Tests toolbar cache tags implementation.
ToolbarAdminMenuTest::testModuleStatusChangeSubtreesHashCacheClear in core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php
Tests Toolbar's responses to installing and uninstalling modules.
ToolbarAdminMenuTest::testNonCurrentUserAccountUpdates in core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php
Tests cache invalidation when one user modifies another user.
ToolbarAdminMenuTest::testUserRoleUpdateSubtreesHashCacheClear in core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php
Tests Toolbar's responses to user data updates.

File

core/modules/toolbar/tests/src/Functional/ToolbarAdminMenuTest.php, line 474

Class

ToolbarAdminMenuTest
Tests the caching of the admin menu subtree items.

Namespace

Drupal\Tests\toolbar\Functional

Code

private function assertDifferentHash() : void {
    // Request a new page to refresh the drupalSettings object.
    $this->drupalGet('test-page');
    $this->assertSession()
        ->statusCodeEquals(200);
    $new_subtree_hash = $this->getSubtreesHash();
    // Assert that the old admin menu subtree hash and the new admin menu
    // subtree hash are different.
    $this->assertNotEmpty($new_subtree_hash, 'A valid hash value for the admin menu subtrees was created.');
    $this->assertNotEquals($this->hash, $new_subtree_hash, 'The user-specific subtree menu hash has been updated.');
    // Save the new subtree hash as the original.
    $this->hash = $new_subtree_hash;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.