function 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/ hal/ tests/ src/ Functional/ entity_test/ 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/ hal/ tests/ src/ Functional/ entity_test/ 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.
File
- 
              core/modules/ system/ tests/ modules/ entity_test/ tests/ src/ Functional/ Rest/ EntityTestResourceTestBase.php, line 70 
Class
Namespace
Drupal\Tests\entity_test\Functional\RestCode
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.
