function InternalEntitiesTest::setUp

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

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

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