3 namespace Drupal\Tests\views\Functional\Entity;
5 use Drupal\entity_test\Entity\EntityTest;
6 use Drupal\Tests\views\Functional\ViewTestBase;
7 use Drupal\views\Tests\ViewTestData;
10 * Tests views base field access.
14 class BaseFieldAccessTest extends ViewTestBase {
17 * Views used by this test.
21 public static $testViews = ['test_entity_test_protected_access'];
28 public static $modules = [
29 'views', 'views_test_config', 'entity_test', 'node', 'views_entity_test',
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', [
44 'test_text_access' => [
51 $entity_1 = EntityTest::create([
52 'test_text_access' => 'no access value',
55 $entity_2 = EntityTest::create([
56 'test_text_access' => 'ok to see this one',
59 $this->drupalLogin($this->drupalCreateUser(['access content']));
63 * Test access to protected base fields.
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');