protected function EntityTestTest::createEntity in JSON:API 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/EntityTestTest.php \Drupal\Tests\jsonapi\Functional\EntityTestTest::createEntity()
Creates the entity to be tested.
Return value
\Drupal\Core\Entity\EntityInterface The entity to be tested.
Overrides ResourceTestBase::createEntity
File
- tests/
src/ Functional/ EntityTestTest.php, line 70
Class
- EntityTestTest
- JSON API integration test for the "EntityTest" content entity type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
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);
\Drupal::entityDefinitionUpdateManager()
->applyUpdates();
$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;
}