You are here

protected function InternalEntitiesTest::setUp in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php \Drupal\Tests\jsonapi\Functional\InternalEntitiesTest::setUp()
  2. 9 core/modules/jsonapi/tests/src/Functional/InternalEntitiesTest.php \Drupal\Tests\jsonapi\Functional\InternalEntitiesTest::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

protected 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();
}