function ResourceTestBase::getEntityDuplicate
Same name in other branches
- 9 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getEntityDuplicate()
- 10 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getEntityDuplicate()
- 11.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getEntityDuplicate()
4 calls to ResourceTestBase::getEntityDuplicate()
- FeedTest::createAnotherEntity in core/
modules/ jsonapi/ tests/ src/ Functional/ FeedTest.php - Creates another entity to be tested.
- ItemTest::createAnotherEntity in core/
modules/ jsonapi/ tests/ src/ Functional/ ItemTest.php - Creates another entity to be tested.
- ResourceTestBase::createAnotherEntity in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php - Creates another entity to be tested.
- UserTest::createAnotherEntity in core/
modules/ jsonapi/ tests/ src/ Functional/ UserTest.php - Creates another entity to be tested.
File
-
core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php, line 421
Class
- ResourceTestBase
- Subclass this for every JSON:API resource type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected function getEntityDuplicate(EntityInterface $original, $key) {
$duplicate = $original->createDuplicate();
if ($label_key = $original->getEntityType()
->getKey('label')) {
$duplicate->set($label_key, $original->label() . '_' . $key);
}
if ($duplicate instanceof ConfigEntityInterface && ($id_key = $duplicate->getEntityType()
->getKey('id'))) {
$id = $original->id();
$id_key = $duplicate->getEntityType()
->getKey('id');
$duplicate->set($id_key, $id . '_' . $key);
}
return $duplicate;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.