function RelationshipNodeTermDataTest::assertQueriesTermAccessTag

Assert views queries have taxonomy_term_access tag.

@internal

Parameters

\Drupal\views\ViewExecutable $view: The View to check for the term access tag.

bool $hasTag: The expected existence of taxonomy_term_access tag.

1 call to RelationshipNodeTermDataTest::assertQueriesTermAccessTag()
RelationshipNodeTermDataTest::testTag in core/modules/taxonomy/tests/src/Kernel/Views/RelationshipNodeTermDataTest.php
Tests that the 'taxonomy_term_access' tag is added to the Views query.

File

core/modules/taxonomy/tests/src/Kernel/Views/RelationshipNodeTermDataTest.php, line 100

Class

RelationshipNodeTermDataTest
Tests the taxonomy term on node relationship handler.

Namespace

Drupal\Tests\taxonomy\Kernel\Views

Code

protected function assertQueriesTermAccessTag(ViewExecutable $view, bool $hasTag) : void {
  $main_query = $view->build_info['query'];
  $count_query = $view->build_info['count_query'];
  foreach ([
    $main_query,
    $count_query,
  ] as $query) {
    $tables = $query->getTables();
    foreach ($tables as $join_table) {
      if (is_object($join_table['table'])) {
        $this->assertSame($join_table['table']->hasTag('taxonomy_term_access'), $hasTag);
      }
    }
  }
}

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