3 namespace Drupal\Tests\taxonomy\Kernel\Views;
5 use Drupal\taxonomy\Entity\Term;
6 use Drupal\taxonomy\Entity\Vocabulary;
7 use Drupal\Tests\views\Kernel\Handler\FieldFieldAccessTestBase;
10 * Tests base field access in Views for the taxonomy entity.
14 class TaxonomyViewsFieldAccessTest extends FieldFieldAccessTestBase {
19 public static $modules = ['taxonomy', 'text', 'entity_test'];
24 protected function setUp($import_test_views = TRUE) {
25 parent::setUp($import_test_views);
27 $this->installEntitySchema('taxonomy_term');
31 * Check access for taxonomy fields.
33 public function testTermFields() {
34 $vocab = Vocabulary::create([
36 'name' => 'Randomness',
39 $term1 = Term::create([
40 'name' => 'Semi random',
41 'vid' => $vocab->id(),
45 $term2 = Term::create([
46 'name' => 'Majorly random',
47 'vid' => $vocab->id(),
51 $term3 = Term::create([
52 'name' => 'Not really random',
53 'vid' => $vocab->id(),
57 $this->assertFieldAccess('taxonomy_term', 'name', 'Majorly random');
58 $this->assertFieldAccess('taxonomy_term', 'name', 'Semi random');
59 $this->assertFieldAccess('taxonomy_term', 'name', 'Not really random');
60 $this->assertFieldAccess('taxonomy_term', 'tid', $term1->id());
61 $this->assertFieldAccess('taxonomy_term', 'tid', $term2->id());
62 $this->assertFieldAccess('taxonomy_term', 'tid', $term3->id());
63 $this->assertFieldAccess('taxonomy_term', 'uuid', $term1->uuid());
64 $this->assertFieldAccess('taxonomy_term', 'uuid', $term2->uuid());
65 $this->assertFieldAccess('taxonomy_term', 'uuid', $term3->uuid());