function WorkspaceResourceTestBase::getExpectedNormalizedEntity

Same name in this branch
  1. 10 core/modules/workspaces/tests/src/Functional/Rest/WorkspaceResourceTestBase.php \Drupal\Tests\workspaces\Functional\Rest\WorkspaceResourceTestBase::getExpectedNormalizedEntity()
Same name in other branches
  1. 9 core/modules/workspaces/tests/src/Functional/EntityResource/WorkspaceResourceTestBase.php \Drupal\Tests\workspaces\Functional\EntityResource\WorkspaceResourceTestBase::getExpectedNormalizedEntity()
  2. 8.9.x core/modules/workspaces/tests/src/Functional/EntityResource/WorkspaceResourceTestBase.php \Drupal\Tests\workspaces\Functional\EntityResource\WorkspaceResourceTestBase::getExpectedNormalizedEntity()
  3. 11.x core/modules/workspaces/tests/src/Functional/EntityResource/WorkspaceResourceTestBase.php \Drupal\Tests\workspaces\Functional\EntityResource\WorkspaceResourceTestBase::getExpectedNormalizedEntity()
  4. 11.x core/modules/workspaces/tests/src/Functional/Rest/WorkspaceResourceTestBase.php \Drupal\Tests\workspaces\Functional\Rest\WorkspaceResourceTestBase::getExpectedNormalizedEntity()

Overrides EntityResourceTestBase::getExpectedNormalizedEntity

File

core/modules/workspaces/tests/src/Functional/EntityResource/WorkspaceResourceTestBase.php, line 99

Class

WorkspaceResourceTestBase
Base class for workspace EntityResource tests.

Namespace

Drupal\Tests\workspaces\Functional\EntityResource

Code

protected function getExpectedNormalizedEntity() {
    $author = User::load($this->entity
        ->getOwnerId());
    return [
        'created' => [
            [
                'value' => (new \DateTime())->setTimestamp((int) $this->entity
                    ->getCreatedTime())
                    ->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,
            ],
        ],
        'id' => [
            [
                'value' => 'layla',
            ],
        ],
        'label' => [
            [
                'value' => 'Layla',
            ],
        ],
        'revision_id' => [
            [
                'value' => 2,
            ],
        ],
        'parent' => [],
        'uid' => [
            [
                'target_id' => (int) $author->id(),
                'target_type' => 'user',
                'target_uuid' => $author->uuid(),
                'url' => base_path() . 'user/' . $author->id(),
            ],
        ],
        'uuid' => [
            [
                'value' => $this->entity
                    ->uuid(),
            ],
        ],
    ];
}

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