You are here

protected function EntityTestResourceTestBase::getExpectedNormalizedEntity in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestResourceTestBase.php \Drupal\Tests\entity_test\Functional\Rest\EntityTestResourceTestBase::getExpectedNormalizedEntity()

Returns the expected normalization of the entity.

Return value

array

Overrides EntityResourceTestBase::getExpectedNormalizedEntity

See also

::createEntity()

7 calls to EntityTestResourceTestBase::getExpectedNormalizedEntity()
EntityTestComputedFieldNormalizerTest::getExpectedNormalizedEntity in core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestComputedFieldNormalizerTest.php
Returns the expected normalization of the entity.
EntityTestDateonlyTest::getExpectedNormalizedEntity in core/modules/datetime/tests/src/Functional/EntityResource/EntityTest/EntityTestDateonlyTest.php
Returns the expected normalization of the entity.
EntityTestDateRangeTest::getExpectedNormalizedEntity in core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDateRangeTest.php
Returns the expected normalization of the entity.
EntityTestDatetimeTest::getExpectedNormalizedEntity in core/modules/datetime/tests/src/Functional/EntityResource/EntityTest/EntityTestDatetimeTest.php
Returns the expected normalization of the entity.
EntityTestHalJsonAnonTest::getExpectedNormalizedEntity in core/modules/system/tests/modules/entity_test/tests/src/Functional/Hal/EntityTestHalJsonAnonTest.php
Returns the expected normalization of the entity.

... See full list

7 methods override EntityTestResourceTestBase::getExpectedNormalizedEntity()
EntityTestComputedFieldNormalizerTest::getExpectedNormalizedEntity in core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestComputedFieldNormalizerTest.php
Returns the expected normalization of the entity.
EntityTestDateonlyTest::getExpectedNormalizedEntity in core/modules/datetime/tests/src/Functional/EntityResource/EntityTest/EntityTestDateonlyTest.php
Returns the expected normalization of the entity.
EntityTestDateRangeTest::getExpectedNormalizedEntity in core/modules/datetime_range/tests/src/Functional/EntityResource/EntityTest/EntityTestDateRangeTest.php
Returns the expected normalization of the entity.
EntityTestDatetimeTest::getExpectedNormalizedEntity in core/modules/datetime/tests/src/Functional/EntityResource/EntityTest/EntityTestDatetimeTest.php
Returns the expected normalization of the entity.
EntityTestHalJsonAnonTest::getExpectedNormalizedEntity in core/modules/system/tests/modules/entity_test/tests/src/Functional/Hal/EntityTestHalJsonAnonTest.php
Returns the expected normalization of the entity.

... See full list

File

core/modules/system/tests/modules/entity_test/tests/src/Functional/Rest/EntityTestResourceTestBase.php, line 83

Class

EntityTestResourceTestBase

Namespace

Drupal\Tests\entity_test\Functional\Rest

Code

protected function getExpectedNormalizedEntity() {
  $author = User::load(0);
  $normalization = [
    'uuid' => [
      [
        'value' => $this->entity
          ->uuid(),
      ],
    ],
    'id' => [
      [
        'value' => 1,
      ],
    ],
    'langcode' => [
      [
        'value' => 'en',
      ],
    ],
    'type' => [
      [
        'value' => static::$entityTypeId,
      ],
    ],
    'name' => [
      [
        'value' => 'Llama',
      ],
    ],
    'created' => [
      [
        'value' => (new \DateTime())
          ->setTimestamp((int) $this->entity
          ->get('created')->value)
          ->setTimezone(new \DateTimeZone('UTC'))
          ->format(\DateTime::RFC3339),
        'format' => \DateTime::RFC3339,
      ],
    ],
    'user_id' => [
      [
        'target_id' => (int) $author
          ->id(),
        'target_type' => 'user',
        'target_uuid' => $author
          ->uuid(),
        'url' => $author
          ->toUrl()
          ->toString(),
      ],
    ],
    'field_test_text' => [],
  ];
  return $normalization;
}