3 namespace Drupal\Tests\taxonomy\Functional\Views;
5 use Drupal\taxonomy\Entity\Vocabulary;
8 * Tests the vocabulary argument.
12 class TaxonomyVocabularyArgumentTest extends TaxonomyTestBase {
17 public static $modules = ['taxonomy', 'taxonomy_test_views', 'views'];
22 public static $testViews = ['test_argument_taxonomy_vocabulary'];
25 * @var \Drupal\taxonomy\TermInterface[]
27 protected $terms = [];
30 * Vocabularies used for creating terms.
32 * @var \Drupal\taxonomy\VocabularyInterface[]
34 protected $vocabularies;
39 protected function setUp($import_test_views = TRUE) {
40 parent::setUp($import_test_views);
42 // Add default vocabulary to list of vocabularies.
43 $this->vocabularies[] = $this->vocabulary;
44 // Create additional vocabulary.
45 $vocabulary = Vocabulary::create([
46 'name' => 'Views testing category',
47 'vid' => 'views_testing_category',
50 $this->vocabularies[] = $vocabulary;
53 $this->terms[0] = $this->createTerm([
55 'vid' => $this->vocabularies[0]->id(),
57 $this->terms[1] = $this->createTerm([
59 'vid' => $this->vocabularies[1]->id(),
64 * Tests the vocabulary argument handler.
66 * @see Drupal\taxonomy\Plugin\views\argument\VocabularyVid
68 public function testTermWithVocabularyArgument() {
69 $this->drupalGet('test_argument_taxonomy_vocabulary/' . $this->vocabularies[0]->id());
70 // First term should be present.
71 $this->assertText($this->terms[0]->label());
72 // Second term should not be present.
73 $this->assertNoText($this->terms[1]->label());