You are here

protected function EntityTestResourceTestBase::createEntity in Drupal 8

Same name and namespace 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()

Creates the entity to be tested.

Return value

\Drupal\Core\Entity\EntityInterface The entity to be tested.

Overrides EntityResourceTestBase::createEntity

3 calls to EntityTestResourceTestBase::createEntity()
EntityTestHalJsonInternalPropertyNormalizerTest::createEntity in core/modules/system/tests/modules/entity_test/tests/src/Functional/Hal/EntityTestHalJsonInternalPropertyNormalizerTest.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.
6 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.
EntityTestHalJsonInternalPropertyNormalizerTest::createEntity in core/modules/system/tests/modules/entity_test/tests/src/Functional/Hal/EntityTestHalJsonInternalPropertyNormalizerTest.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.

... See full list

File

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

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 = EntityTest::create([
    'name' => 'Llama',
    'type' => 'entity_test',
    // 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;
}