You are here

public function HierarchicalTaxonomyMenuCacheTest::testBlockCacheContextAuthenticated in Hierarchical Taxonomy Menu 8

Tests cache context for authenticated users.

File

tests/src/Functional/HierarchicalTaxonomyMenuCacheTest.php, line 112

Class

HierarchicalTaxonomyMenuCacheTest
Tests the Hierarchical Taxonomy Menu block caching.

Namespace

Drupal\Tests\hierarchical_taxonomy_menu\Functional

Code

public function testBlockCacheContextAuthenticated() {
  $this
    ->drupalLogin($this->user);
  $this
    ->drupalGet('<front>');
  $this
    ->assertCacheContext('url.path');
  $this
    ->drupalGet('taxonomy/term/1');
  $this
    ->assertCacheContext('url.path');
  $block_title_element = $this
    ->getSession()
    ->getPage()
    ->find('css', '#block-hierarchicaltaxonomymenu h2');
  $this
    ->assertEqual($block_title_element
    ->getText(), 'Term 1');
  $this
    ->drupalGet('taxonomy/term/2');
  $this
    ->assertCacheContext('url.path');
  $block_title_element = $this
    ->getSession()
    ->getPage()
    ->find('css', '#block-hierarchicaltaxonomymenu h2');
  $this
    ->assertEqual($block_title_element
    ->getText(), 'Term 2');
}