protected function ResourceTestBase::getModifiedEntityForPostTesting in Drupal 8
Same name and namespace in other branches
- 9 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::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
::testPostIndividual
::getPostDocument
2 calls to ResourceTestBase::getModifiedEntityForPostTesting()
- ResourceTestBase::testPostIndividual in core/modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php 
- Tests POSTing an individual resource, plus edge cases to ensure good DX.
- UserTest::getModifiedEntityForPostTesting in core/modules/ jsonapi/ tests/ src/ Functional/ UserTest.php 
- Gets the normalized POST entity with random values for its unique fields.
1 method overrides ResourceTestBase::getModifiedEntityForPostTesting()
- UserTest::getModifiedEntityForPostTesting in core/modules/ jsonapi/ tests/ src/ Functional/ UserTest.php 
- Gets the normalized POST entity with random values for its unique fields.
File
- core/modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php, line 2533 
Class
- ResourceTestBase
- Subclass this for every JSON:API resource type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected function getModifiedEntityForPostTesting() {
  $document = $this
    ->getPostDocument();
  // 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();
    $document['data']['attributes'][$field_name] = $field_type_class::generateSampleValue($field_definition);
  }
  return $document;
}