function EntityResourceTestBase::createAnotherEntity
Same name in other branches
- 9 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::createAnotherEntity()
- 8.9.x core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::createAnotherEntity()
- 11.x core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::createAnotherEntity()
Creates another entity to be tested.
Return value
\Drupal\Core\Entity\EntityInterface Another entity based on $this->entity.
1 call to EntityResourceTestBase::createAnotherEntity()
- EntityResourceTestBase::testPatch in core/
modules/ rest/ tests/ src/ Functional/ EntityResource/ EntityResourceTestBase.php - Tests a PATCH request for an entity, plus edge cases to ensure good DX.
3 methods override EntityResourceTestBase::createAnotherEntity()
- UserResourceTestBase::createAnotherEntity in core/
modules/ user/ tests/ src/ Functional/ Rest/ UserResourceTestBase.php - Creates another entity to be tested.
- WorkspaceResourceTestBase::createAnotherEntity in core/
modules/ workspaces/ tests/ src/ Functional/ EntityResource/ WorkspaceResourceTestBase.php - Creates another entity to be tested.
- WorkspaceResourceTestBase::createAnotherEntity in core/
modules/ workspaces/ tests/ src/ Functional/ Rest/ WorkspaceResourceTestBase.php - Creates another entity to be tested.
File
-
core/
modules/ rest/ tests/ src/ Functional/ EntityResource/ EntityResourceTestBase.php, line 259
Class
- EntityResourceTestBase
- Defines a base class for testing all entity resources.
Namespace
Drupal\Tests\rest\Functional\EntityResourceCode
protected function createAnotherEntity() {
$entity = $this->entity
->createDuplicate();
$label_key = $entity->getEntityType()
->getKey('label');
if ($label_key) {
$entity->set($label_key, $entity->label() . '_dupe');
}
$entity->save();
return $entity;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.