function EntityTestResourceTestBase::createEntity

Same name in other branches
  1. 9 core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestResourceTestBase.php \Drupal\Tests\entity_test\Functional\Rest\EntityTestResourceTestBase::createEntity()
  2. 8.9.x core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestResourceTestBase.php \Drupal\Tests\entity_test\Functional\Rest\EntityTestResourceTestBase::createEntity()
  3. 10 core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestResourceTestBase.php \Drupal\Tests\entity_test\Functional\Rest\EntityTestResourceTestBase::createEntity()

Overrides EntityResourceTestBase::createEntity

2 calls to EntityTestResourceTestBase::createEntity()
EntityTestJsonInternalPropertyNormalizerTest::createEntity in core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestJsonInternalPropertyNormalizerTest.php
Creates the entity to be tested.
EntityTestTextItemNormalizerTest::createEntity in core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.php
Creates the entity to be tested.
5 methods override EntityTestResourceTestBase::createEntity()
EntityTestDateOnlyTest::createEntity in core/modules/datetime/tests/src/Functional/EntityResource/EntityTest/EntityTestDateOnlyTest.php
Creates the entity to be tested.
EntityTestDateRangeTest::createEntity in core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDateRangeTest.php
Creates the entity to be tested.
EntityTestDatetimeTest::createEntity in core/modules/datetime/tests/src/Functional/EntityResource/EntityTest/EntityTestDatetimeTest.php
Creates the entity to be tested.
EntityTestJsonInternalPropertyNormalizerTest::createEntity in core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestJsonInternalPropertyNormalizerTest.php
Creates the entity to be tested.
EntityTestTextItemNormalizerTest::createEntity in core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestTextItemNormalizerTest.php
Creates the entity to be tested.

File

core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestResourceTestBase.php, line 74

Class

EntityTestResourceTestBase

Namespace

Drupal\Tests\entity_test\Functional\Rest

Code

protected function createEntity() {
    // Set flag so that internal field 'internal_string_field' is created.
    // @see entity_test_entity_base_field_info()
    $this->container
        ->get('state')
        ->set('entity_test.internal_field', TRUE);
    $this->applyEntityUpdates('entity_test');
    $entity_test = \Drupal::entityTypeManager()->getStorage(static::$entityTypeId)
        ->create([
        'name' => 'Llama',
        'type' => static::$entityTypeId,
        // Set a value for the internal field to confirm that it will not be
        // returned in normalization.
        // @see entity_test_entity_base_field_info().
'internal_string_field' => [
            'value' => 'This value shall not be internal!',
        ],
    ]);
    $entity_test->setOwnerId(0);
    $entity_test->save();
    return $entity_test;
}

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