You are here

public function InternalEntitiesTest::setUp in JSON:API 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/InternalEntitiesTest.php \Drupal\Tests\jsonapi\Functional\InternalEntitiesTest::setUp()

Overrides BrowserTestBase::setUp

File

tests/src/Functional/InternalEntitiesTest.php, line 57

Class

InternalEntitiesTest
Makes assertions about the JSON API behavior for internal entities.

Namespace

Drupal\Tests\jsonapi\Functional

Code

public function setUp() {
  parent::setUp();
  $this->testUser = $this
    ->drupalCreateUser([
    'access jsonapi resource list',
    'view test entity',
    'administer entity_test_with_bundle content',
  ], $this
    ->randomString(), TRUE);
  EntityTestBundle::create([
    'id' => 'internal_referencer',
    'label' => 'Entity Test Internal Referencer',
  ])
    ->save();
  $this
    ->createEntityReferenceField('entity_test_with_bundle', 'internal_referencer', 'field_internal', 'Internal Entities', 'entity_test_no_label');
  $this->internalEntity = EntityTestNoLabel::create([]);
  $this->internalEntity
    ->save();
  $this->referencingEntity = EntityTestWithBundle::create([
    'type' => 'internal_referencer',
    'field_internal' => $this->internalEntity
      ->id(),
  ]);
  $this->referencingEntity
    ->save();
  drupal_flush_all_caches();
}