TaxonomyVocabularyArgumentTest.php in Drupal 9
File
core/modules/taxonomy/tests/src/Functional/Views/TaxonomyVocabularyArgumentTest.php
View source
<?php
namespace Drupal\Tests\taxonomy\Functional\Views;
use Drupal\taxonomy\Entity\Vocabulary;
class TaxonomyVocabularyArgumentTest extends TaxonomyTestBase {
protected static $modules = [
'taxonomy',
'taxonomy_test_views',
'views',
];
protected $defaultTheme = 'stark';
public static $testViews = [
'test_argument_taxonomy_vocabulary',
];
protected $terms = [];
protected $vocabularies;
protected function setUp($import_test_views = TRUE) : void {
parent::setUp($import_test_views);
$this->vocabularies[] = $this->vocabulary;
$vocabulary = Vocabulary::create([
'name' => 'Views testing category',
'vid' => 'views_testing_category',
]);
$vocabulary
->save();
$this->vocabularies[] = $vocabulary;
$this->terms[0] = $this
->createTerm([
'name' => 'First',
'vid' => $this->vocabularies[0]
->id(),
]);
$this->terms[1] = $this
->createTerm([
'name' => 'Second',
'vid' => $this->vocabularies[1]
->id(),
]);
}
public function testTermWithVocabularyArgument() {
$this
->drupalGet('test_argument_taxonomy_vocabulary/' . $this->vocabularies[0]
->id());
$this
->assertSession()
->pageTextContains($this->terms[0]
->label());
$this
->assertSession()
->pageTextNotContains($this->terms[1]
->label());
}
}