You are here

protected function EntityHierarchyWorkbenchAccessTest::setUp in Entity Reference Hierarchy 3.x

Same name and namespace in other branches
  1. 8.2 modules/entity_hierarchy_workbench_access/tests/src/Kernel/EntityHierarchyWorkbenchAccessTest.php \Drupal\Tests\entity_hierarchy_workbench_access\Kernel\EntityHierarchyWorkbenchAccessTest::setUp()

Overrides EntityHierarchyKernelTestBase::setUp

File

modules/entity_hierarchy_workbench_access/tests/src/Kernel/EntityHierarchyWorkbenchAccessTest.php, line 70

Class

EntityHierarchyWorkbenchAccessTest
Tests interaction between entity_hierarchy and workbench_access.

Namespace

Drupal\Tests\entity_hierarchy_workbench_access\Kernel

Code

protected function setUp() {
  EntityKernelTestBase::setUp();
  $this
    ->installEntitySchema(static::ENTITY_TYPE);
  $this
    ->installEntitySchema('section_association');
  $this
    ->installConfig([
    'node',
    'workbench_access',
  ]);
  $this
    ->installSchema('node', [
    'node_access',
  ]);
  $this->parentNodeType = $this
    ->createContentType([
    'type' => 'section',
  ]);
  $this->childNodeType = $this
    ->createContentType([
    'type' => 'children',
  ]);

  // Only the child has the field.
  $this
    ->setupEntityHierarchyField(static::ENTITY_TYPE, $this->childNodeType
    ->id(), static::FIELD_NAME);
  $this->scheme = AccessScheme::create([
    'id' => 'eh',
    'label' => 'EH',
    'plural_label' => 'EHs',
    'scheme' => 'entity_hierarchy:node__parents',
    'scheme_settings' => [
      'boolean_fields' => [
        static::BOOLEAN_FIELD,
      ],
      'bundles' => [
        'section',
        'children',
      ],
    ],
  ]);
  $this->scheme
    ->save();
  $this->treeStorage = $this->container
    ->get('entity_hierarchy.nested_set_storage_factory')
    ->get(static::FIELD_NAME, static::ENTITY_TYPE);
  $this->nodeFactory = $this->container
    ->get('entity_hierarchy.nested_set_node_factory');

  // Setup a boolean field on both node types.
  $this
    ->setupBooleanEditorialField(static::ENTITY_TYPE, $this->childNodeType
    ->id(), self::BOOLEAN_FIELD);
  $this
    ->setupBooleanEditorialField(static::ENTITY_TYPE, $this->parentNodeType
    ->id(), self::BOOLEAN_FIELD, FALSE);
}