You are here

protected function NodeResourceTestBase::getExpectedNormalizedEntity in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/node/tests/src/Functional/Rest/NodeResourceTestBase.php \Drupal\Tests\node\Functional\Rest\NodeResourceTestBase::getExpectedNormalizedEntity()
  2. 9 core/modules/node/tests/src/Functional/Rest/NodeResourceTestBase.php \Drupal\Tests\node\Functional\Rest\NodeResourceTestBase::getExpectedNormalizedEntity()
1 method overrides NodeResourceTestBase::getExpectedNormalizedEntity()
ModeratedNodeResourceTestBase::getExpectedNormalizedEntity in core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeResourceTestBase.php
Returns the expected normalization of the entity.

File

core/modules/node/tests/src/Functional/Rest/NodeResourceTestBase.php, line 97

Class

NodeResourceTestBase

Namespace

Drupal\Tests\node\Functional\Rest

Code

protected function getExpectedNormalizedEntity() {
  $author = User::load($this->entity
    ->getOwnerId());
  return [
    'nid' => [
      [
        'value' => 1,
      ],
    ],
    'uuid' => [
      [
        'value' => $this->entity
          ->uuid(),
      ],
    ],
    'vid' => [
      [
        'value' => 1,
      ],
    ],
    'langcode' => [
      [
        'value' => 'en',
      ],
    ],
    'type' => [
      [
        'target_id' => 'camelids',
        'target_type' => 'node_type',
        'target_uuid' => NodeType::load('camelids')
          ->uuid(),
      ],
    ],
    'title' => [
      [
        'value' => 'Llama',
      ],
    ],
    'status' => [
      [
        'value' => TRUE,
      ],
    ],
    'created' => [
      [
        'value' => (new \DateTime())
          ->setTimestamp(123456789)
          ->setTimezone(new \DateTimeZone('UTC'))
          ->format(\DateTime::RFC3339),
        'format' => \DateTime::RFC3339,
      ],
    ],
    'changed' => [
      [
        'value' => (new \DateTime())
          ->setTimestamp($this->entity
          ->getChangedTime())
          ->setTimezone(new \DateTimeZone('UTC'))
          ->format(\DateTime::RFC3339),
        'format' => \DateTime::RFC3339,
      ],
    ],
    'promote' => [
      [
        'value' => TRUE,
      ],
    ],
    'sticky' => [
      [
        'value' => FALSE,
      ],
    ],
    'revision_timestamp' => [
      [
        'value' => (new \DateTime())
          ->setTimestamp(123456789)
          ->setTimezone(new \DateTimeZone('UTC'))
          ->format(\DateTime::RFC3339),
        'format' => \DateTime::RFC3339,
      ],
    ],
    'revision_translation_affected' => [
      [
        'value' => TRUE,
      ],
    ],
    'default_langcode' => [
      [
        'value' => TRUE,
      ],
    ],
    'uid' => [
      [
        'target_id' => (int) $author
          ->id(),
        'target_type' => 'user',
        'target_uuid' => $author
          ->uuid(),
        'url' => base_path() . 'user/' . $author
          ->id(),
      ],
    ],
    'revision_uid' => [
      [
        'target_id' => (int) $author
          ->id(),
        'target_type' => 'user',
        'target_uuid' => $author
          ->uuid(),
        'url' => base_path() . 'user/' . $author
          ->id(),
      ],
    ],
    'revision_log' => [],
    'path' => [
      [
        'alias' => '/llama',
        'pid' => 1,
        'langcode' => 'en',
      ],
    ],
  ];
}