You are here

public function InternalEntitiesTest::setUp in Drupal 9

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

Overrides BrowserTestBase::setUp

File

core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php, line 62

Class

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

Namespace

Drupal\Tests\jsonapi\Functional

Code

public function setUp() : void {
  parent::setUp();
  $this->testUser = $this
    ->drupalCreateUser([
    '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::service('router.builder')
    ->rebuild();
}