Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / taxonomy / tests / src / Kernel / Views / TaxonomyViewsFieldAccessTest.php
1 <?php
2
3 namespace Drupal\Tests\taxonomy\Kernel\Views;
4
5 use Drupal\taxonomy\Entity\Term;
6 use Drupal\taxonomy\Entity\Vocabulary;
7 use Drupal\Tests\views\Kernel\Handler\FieldFieldAccessTestBase;
8
9 /**
10  * Tests base field access in Views for the taxonomy entity.
11  *
12  * @group taxonomy
13  */
14 class TaxonomyViewsFieldAccessTest extends FieldFieldAccessTestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public static $modules = ['taxonomy', 'text', 'entity_test'];
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setUp($import_test_views = TRUE) {
25     parent::setUp($import_test_views);
26
27     $this->installEntitySchema('taxonomy_term');
28   }
29
30   /**
31    * Check access for taxonomy fields.
32    */
33   public function testTermFields() {
34     $vocab = Vocabulary::create([
35       'vid' => 'random',
36       'name' => 'Randomness',
37     ]);
38     $vocab->save();
39     $term1 = Term::create([
40       'name' => 'Semi random',
41       'vid' => $vocab->id(),
42     ]);
43     $term1->save();
44
45     $term2 = Term::create([
46       'name' => 'Majorly random',
47       'vid' => $vocab->id(),
48     ]);
49     $term2->save();
50
51     $term3 = Term::create([
52       'name' => 'Not really random',
53       'vid' => $vocab->id(),
54     ]);
55     $term3->save();
56
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());
66   }
67
68 }