Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / views / tests / src / Functional / Entity / BaseFieldAccessTest.php
1 <?php
2
3 namespace Drupal\Tests\views\Functional\Entity;
4
5 use Drupal\entity_test\Entity\EntityTest;
6 use Drupal\Tests\views\Functional\ViewTestBase;
7 use Drupal\views\Tests\ViewTestData;
8
9 /**
10  * Tests views base field access.
11  *
12  * @group views
13  */
14 class BaseFieldAccessTest extends ViewTestBase {
15
16   /**
17    * Views used by this test.
18    *
19    * @var array
20    */
21   public static $testViews = ['test_entity_test_protected_access'];
22
23   /**
24    * Modules to enable
25    *
26    * @var array
27    */
28   public static $modules = [
29     'views', 'views_test_config', 'entity_test', 'node', 'views_entity_test',
30   ];
31
32   /**
33    * {@inheritdoc}
34    */
35   protected function setUp($import_test_views = TRUE) {
36     parent::setUp($import_test_views);
37     /** @var \Drupal\Core\Entity\EntityDefinitionUpdateManager $update_manager */
38     $update_manager = $this->container->get('entity.definition_update_manager');
39     \Drupal::entityManager()->clearCachedDefinitions();
40     $update_manager->applyUpdates();
41     ViewTestData::createTestViews(get_class($this), ['comment_test_views']);
42     \Drupal::state()->set('entity_test.views_data', [
43       'entity_test' => [
44         'test_text_access' => [
45           'field' => [
46             'id' => 'standard',
47           ],
48         ],
49       ],
50     ]);
51     $entity_1 = EntityTest::create([
52       'test_text_access' => 'no access value',
53     ]);
54     $entity_1->save();
55     $entity_2 = EntityTest::create([
56       'test_text_access' => 'ok to see this one',
57     ]);
58     $entity_2->save();
59     $this->drupalLogin($this->drupalCreateUser(['access content']));
60   }
61
62   /**
63    * Test access to protected base fields.
64    */
65   public function testProtectedField() {
66     $this->drupalGet('test-entity-protected-access');
67     $this->assertText('ok to see this one');
68     $this->assertNoText('no access value');
69   }
70
71 }