function ResourceTestBase::createAnotherEntity
Same name in other branches
- 9 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::createAnotherEntity()
- 8.9.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::createAnotherEntity()
- 10 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::createAnotherEntity()
Creates another entity to be tested.
Parameters
mixed $key: A unique key to be used for the ID and/or label of the duplicated entity.
Return value
\Drupal\Core\Entity\EntityInterface Another entity based on $this->entity.
Throws
\Drupal\Core\Entity\EntityStorageException
4 calls to ResourceTestBase::createAnotherEntity()
- FileTest::createAnotherEntity in core/
modules/ jsonapi/ tests/ src/ Functional/ FileTest.php - Creates another entity to be tested.
- ResourceTestBase::doTestPatchIndividual in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php - Tests PATCHing an individual resource, plus edge cases to ensure good DX.
- ResourceTestBase::doTestRelationshipMutation in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php - Performs one round of relationship POST, PATCH and DELETE route testing.
- ResourceTestBase::getData in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php - Sets up a collection of entities of the same type for testing.
8 methods override ResourceTestBase::createAnotherEntity()
- BaseFieldOverrideTest::createAnotherEntity in core/
modules/ jsonapi/ tests/ src/ Functional/ BaseFieldOverrideTest.php - Creates another entity to be tested.
- ContentLanguageSettingsTest::createAnotherEntity in core/
modules/ jsonapi/ tests/ src/ Functional/ ContentLanguageSettingsTest.php - Creates another entity to be tested.
- EditorTest::createAnotherEntity in core/
modules/ jsonapi/ tests/ src/ Functional/ EditorTest.php - Creates another entity to be tested.
- EntityFormDisplayTest::createAnotherEntity in core/
modules/ jsonapi/ tests/ src/ Functional/ EntityFormDisplayTest.php - Creates another entity to be tested.
- EntityViewDisplayTest::createAnotherEntity in core/
modules/ jsonapi/ tests/ src/ Functional/ EntityViewDisplayTest.php - Creates another entity to be tested.
File
-
core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php, line 408
Class
- ResourceTestBase
- Subclass this for every JSON:API resource type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected function createAnotherEntity($key) {
$duplicate = $this->getEntityDuplicate($this->entity, $key);
// Some entity types are not stored, hence they cannot be reloaded.
if (get_class($this->entityStorage) !== ContentEntityNullStorage::class) {
$duplicate->set('field_rest_test', 'Second collection entity');
}
$duplicate->save();
return $duplicate;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.