function InternalEntitiesTest::setUp

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

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.