function RelationshipNodeTermDataTest::testTag

Same name and namespace in other branches
  1. 9 core/modules/taxonomy/tests/src/Functional/Views/RelationshipNodeTermDataTest.php \Drupal\Tests\taxonomy\Functional\Views\RelationshipNodeTermDataTest::testTag()
  2. 10 core/modules/taxonomy/tests/src/Kernel/Views/RelationshipNodeTermDataTest.php \Drupal\Tests\taxonomy\Kernel\Views\RelationshipNodeTermDataTest::testTag()
  3. 11.x core/modules/taxonomy/tests/src/Kernel/Views/RelationshipNodeTermDataTest.php \Drupal\Tests\taxonomy\Kernel\Views\RelationshipNodeTermDataTest::testTag()

Tests that the 'taxonomy_term_access' tag is added to the Views query.

File

core/modules/taxonomy/tests/src/Functional/Views/RelationshipNodeTermDataTest.php, line 67

Class

RelationshipNodeTermDataTest
Tests the taxonomy term on node relationship handler.

Namespace

Drupal\Tests\taxonomy\Functional\Views

Code

public function testTag() {
    // Change the view to test relation limited by vocabulary.
    $this->config('views.view.test_taxonomy_node_term_data')
        ->set('display.default.display_options.relationships.term_node_tid.vids', [
        'views_testing_tags',
    ])
        ->save();
    $view = Views::getView('test_taxonomy_node_term_data');
    $this->executeView($view, [
        $this->term1
            ->id(),
    ]);
    // By default, view has taxonomy_term_access tag.
    $this->assertQueriesTermAccessTag($view, TRUE);
    // The term_access tag is not set if disable_sql_rewrite is set.
    $view = Views::getView('test_taxonomy_node_term_data');
    $display = $view->getDisplay();
    $display_options = $display->getOption('query');
    $display_options['options']['disable_sql_rewrite'] = TRUE;
    $display->setOption('query', $display_options);
    $view->save();
    $this->executeView($view, [
        $this->term1
            ->id(),
    ]);
    $this->assertQueriesTermAccessTag($view, FALSE);
}

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