You are here

protected function EntityTestAccessTest::setUp in Workbench Access 8

Overrides KernelTestBase::setUp

File

tests/src/Kernel/EntityTestAccessTest.php, line 69

Class

EntityTestAccessTest
Tests workbench_access integration with entity_test.

Namespace

Drupal\Tests\workbench_access\Kernel

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('entity_test');
  entity_test_create_bundle('access_controlled');
  entity_test_create_bundle('not_access_controlled');
  $this
    ->installConfig([
    'filter',
    'entity_test',
    'workbench_access',
  ]);
  $this
    ->installEntitySchema('access_scheme');
  $this->scheme = AccessScheme::create([
    'id' => 'editorial_section',
    'label' => 'Editorial section',
    'plural_label' => 'Editorial sections',
    'scheme' => 'taxonomy',
    'scheme_settings' => [
      'vocabularies' => [
        'workbench_access',
      ],
      'fields' => [
        [
          'entity_type' => 'entity_test',
          'bundle' => 'access_controlled',
          'field' => WorkbenchAccessManagerInterface::FIELD_NAME,
        ],
      ],
    ],
  ]);
  $this->scheme
    ->save();
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('taxonomy_term');
  $this
    ->installEntitySchema('section_association');
  $this
    ->installSchema('system', [
    'key_value',
    'sequences',
  ]);
  $this->vocabulary = $this
    ->setUpVocabulary();
  $this->accessHandler = $this->container
    ->get('entity_type.manager')
    ->getAccessControlHandler('entity_test');
  $this
    ->setUpTaxonomyFieldForEntityType('entity_test', 'access_controlled', $this->vocabulary
    ->id());
  $this->userStorage = \Drupal::service('workbench_access.user_section_storage');
}