function 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
1 call 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.
File
- 
              core/modules/ rest/ tests/ src/ Functional/ EntityResource/ EntityResourceTestBase.php, line 309 
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.
