You are here

protected function RelatedResourceTypesTest::setUp in JSON:API 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/ResourceType/RelatedResourceTypesTest.php \Drupal\Tests\jsonapi\Kernel\ResourceType\RelatedResourceTypesTest::setUp()

Overrides KernelTestBase::setUp

File

tests/src/Kernel/ResourceType/RelatedResourceTypesTest.php, line 53

Class

RelatedResourceTypesTest
@coversDefaultClass \Drupal\jsonapi\ResourceType\ResourceType @coversClass \Drupal\jsonapi\ResourceType\ResourceTypeRepository @group jsonapi

Namespace

Drupal\Tests\jsonapi\Kernel\ResourceType

Code

protected function setUp() {
  parent::setUp();

  // Add the entity schemas.
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('user');

  // Add the additional table schemas.
  $this
    ->installSchema('system', [
    'sequences',
  ]);
  $this
    ->installSchema('node', [
    'node_access',
  ]);
  $this
    ->installSchema('user', [
    'users_data',
  ]);
  NodeType::create([
    'type' => 'foo',
  ])
    ->save();
  NodeType::create([
    'type' => 'bar',
  ])
    ->save();
  $this
    ->createEntityReferenceField('node', 'foo', 'field_ref_bar', 'Bar Reference', 'node', 'default', [
    'target_bundles' => [
      'bar',
    ],
  ]);
  $this
    ->createEntityReferenceField('node', 'foo', 'field_ref_foo', 'Foo Reference', 'node', 'default', [
    'target_bundles' => [
      'foo',
    ],
  ]);
  $this
    ->createEntityReferenceField('node', 'foo', 'field_ref_any', 'Any Bundle Reference', 'node', 'default', [
    'target_bundles' => NULL,
  ]);
  $this->resourceTypeRepository = $this->container
    ->get('jsonapi.resource_type.repository');
}