container->get('entity.definition_update_manager'); \Drupal::entityManager()->clearCachedDefinitions(); $update_manager->applyUpdates(); ViewTestData::createTestViews(get_class($this), ['comment_test_views']); \Drupal::state()->set('entity_test.views_data', [ 'entity_test' => [ 'test_text_access' => [ 'field' => [ 'id' => 'standard', ], ], ], ]); $entity_1 = EntityTest::create([ 'test_text_access' => 'no access value', ]); $entity_1->save(); $entity_2 = EntityTest::create([ 'test_text_access' => 'ok to see this one', ]); $entity_2->save(); $this->drupalLogin($this->drupalCreateUser(['access content'])); } /** * Test access to protected base fields. */ public function testProtectedField() { $this->drupalGet('test-entity-protected-access'); $this->assertText('ok to see this one'); $this->assertNoText('no access value'); } }