function ToolbarAdminMenuTest::assertDifferentHash

Same name and namespace in other branches
  1. 11.x 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

File

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

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.