function CommentResourceTestBase::getExpectedNormalizedEntity

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

Overrides EntityResourceTestBase::getExpectedNormalizedEntity

File

core/modules/comment/tests/src/Functional/Rest/CommentResourceTestBase.php, line 138

Class

CommentResourceTestBase

Namespace

Drupal\Tests\comment\Functional\Rest

Code

protected function getExpectedNormalizedEntity() {
    $author = User::load($this->entity
        ->getOwnerId());
    return [
        'cid' => [
            [
                'value' => 1,
            ],
        ],
        'uuid' => [
            [
                'value' => $this->entity
                    ->uuid(),
            ],
        ],
        'langcode' => [
            [
                'value' => 'en',
            ],
        ],
        'comment_type' => [
            [
                'target_id' => 'comment',
                'target_type' => 'comment_type',
                'target_uuid' => CommentType::load('comment')->uuid(),
            ],
        ],
        'subject' => [
            [
                '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((int) $this->entity
                    ->getChangedTime())
                    ->setTimezone(new \DateTimeZone('UTC'))
                    ->format(\DateTime::RFC3339),
                'format' => \DateTime::RFC3339,
            ],
        ],
        'default_langcode' => [
            [
                'value' => TRUE,
            ],
        ],
        'uid' => [
            [
                'target_id' => (int) $author->id(),
                'target_type' => 'user',
                'target_uuid' => $author->uuid(),
                'url' => base_path() . 'user/' . $author->id(),
            ],
        ],
        'pid' => [],
        'entity_type' => [
            [
                'value' => 'entity_test',
            ],
        ],
        'entity_id' => [
            [
                'target_id' => 1,
                'target_type' => 'entity_test',
                'target_uuid' => EntityTest::load(1)->uuid(),
                'url' => base_path() . 'entity_test/1',
            ],
        ],
        'field_name' => [
            [
                'value' => 'comment',
            ],
        ],
        'name' => [],
        'homepage' => [],
        'thread' => [
            [
                'value' => '01/',
            ],
        ],
        'comment_body' => [
            [
                'value' => 'The name "llama" was adopted by European settlers from native Peruvians.',
                'format' => 'plain_text',
                'processed' => '<p>The name &quot;llama&quot; was adopted by European settlers from native Peruvians.</p>' . "\n",
            ],
        ],
    ];
}

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