Backup of db before drupal security update
[yaffs-website] / web / core / modules / taxonomy / src / Tests / Views / TaxonomyVocabularyArgumentTest.php
1 <?php
2
3 namespace Drupal\taxonomy\Tests\Views;
4
5 use Drupal\taxonomy\Entity\Vocabulary;
6
7 /**
8  * Tests the vocabulary argument.
9  *
10  * @group taxonomy
11  */
12 class TaxonomyVocabularyArgumentTest extends TaxonomyTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static $modules = ['taxonomy', 'taxonomy_test_views', 'views'];
18
19   /**
20    * {@inheritdoc}
21    */
22   public static $testViews = ['test_argument_taxonomy_vocabulary'];
23
24   /**
25    * @var \Drupal\taxonomy\TermInterface[]
26    */
27   protected $terms = [];
28
29   /**
30    * Vocabularies used for creating terms.
31    *
32    * @var \Drupal\taxonomy\VocabularyInterface[]
33    */
34   protected $vocabularies;
35
36   /**
37    * {@inheritdoc}
38    */
39   protected function setUp() {
40     parent::setUp();
41
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',
48     ]);
49     $vocabulary->save();
50     $this->vocabularies[] = $vocabulary;
51
52     // Create some terms.
53     $this->terms[0] = $this->createTerm([
54       'name' => 'First',
55       'vid' => $this->vocabularies[0]->id(),
56     ]);
57     $this->terms[1] = $this->createTerm([
58       'name' => 'Second',
59       'vid' => $this->vocabularies[1]->id(),
60     ]);
61   }
62
63   /**
64    * Tests the vocabulary argument handler.
65    *
66    * @see Drupal\taxonomy\Plugin\views\argument\VocabularyVid
67    */
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());
74   }
75
76 }