function NodeResourceTestBase::getExpectedNormalizedEntity

Same name in other branches
  1. 9 core/modules/node/tests/src/Functional/Rest/NodeResourceTestBase.php \Drupal\Tests\node\Functional\Rest\NodeResourceTestBase::getExpectedNormalizedEntity()
  2. 8.9.x core/modules/node/tests/src/Functional/Rest/NodeResourceTestBase.php \Drupal\Tests\node\Functional\Rest\NodeResourceTestBase::getExpectedNormalizedEntity()
  3. 10 core/modules/node/tests/src/Functional/Rest/NodeResourceTestBase.php \Drupal\Tests\node\Functional\Rest\NodeResourceTestBase::getExpectedNormalizedEntity()

Overrides EntityResourceTestBase::getExpectedNormalizedEntity

2 calls to NodeResourceTestBase::getExpectedNormalizedEntity()
ModeratedNodeResourceTestBase::getExpectedNormalizedEntity in core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeResourceTestBase.php
Returns the expected normalization of the entity.
NodeJsonBasicAuthTest::getExpectedNormalizedEntity in core/modules/node/tests/src/Functional/Rest/NodeJsonBasicAuthTest.php
Returns the expected normalization of the entity.
2 methods override NodeResourceTestBase::getExpectedNormalizedEntity()
ModeratedNodeResourceTestBase::getExpectedNormalizedEntity in core/modules/rest/tests/src/Functional/EntityResource/ModeratedNode/ModeratedNodeResourceTestBase.php
Returns the expected normalization of the entity.
NodeJsonBasicAuthTest::getExpectedNormalizedEntity in core/modules/node/tests/src/Functional/Rest/NodeJsonBasicAuthTest.php
Returns the expected normalization of the entity.

File

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

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(),
            ],
        ],
        'path' => [
            [
                'alias' => '/llama',
                'pid' => 1,
                'langcode' => 'en',
            ],
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.