function EntityResourceTestBase::getModifiedEntityForPostTesting
Same name in other branches
- 9 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getModifiedEntityForPostTesting()
- 8.9.x core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getModifiedEntityForPostTesting()
- 11.x core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getModifiedEntityForPostTesting()
Gets the normalized POST entity with random values for its unique fields.
Return value
array An array structure as returned by ::getNormalizedPostEntity().
See also
::testPost
::getNormalizedPostEntity
2 calls to EntityResourceTestBase::getModifiedEntityForPostTesting()
- EntityResourceTestBase::testPost in core/
modules/ rest/ tests/ src/ Functional/ EntityResource/ EntityResourceTestBase.php - Tests a POST request for an entity, plus edge cases to ensure good DX.
- WorkspaceResourceTestBase::getModifiedEntityForPostTesting in core/
modules/ workspaces/ tests/ src/ Functional/ Rest/ WorkspaceResourceTestBase.php - Gets the normalized POST entity with random values for its unique fields.
1 method overrides EntityResourceTestBase::getModifiedEntityForPostTesting()
- WorkspaceResourceTestBase::getModifiedEntityForPostTesting in core/
modules/ workspaces/ tests/ src/ Functional/ Rest/ WorkspaceResourceTestBase.php - Gets the normalized POST entity with random values for its unique fields.
File
-
core/
modules/ rest/ tests/ src/ Functional/ EntityResource/ EntityResourceTestBase.php, line 310
Class
- EntityResourceTestBase
- Defines a base class for testing all entity resources.
Namespace
Drupal\Tests\rest\Functional\EntityResourceCode
protected function getModifiedEntityForPostTesting() {
$normalized_entity = $this->getNormalizedPostEntity();
// Ensure that all the unique fields of the entity type get a new random
// value.
foreach (static::$uniqueFieldNames as $field_name) {
$field_definition = $this->entity
->getFieldDefinition($field_name);
$field_type_class = $field_definition->getItemDefinition()
->getClass();
$normalized_entity[$field_name] = $field_type_class::generateSampleValue($field_definition);
}
return $normalized_entity;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.