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. 10 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

1 call to CommentResourceTestBase::getExpectedNormalizedEntity()
CommentHalJsonTestBase::getExpectedNormalizedEntity in core/modules/comment/tests/src/Functional/Hal/CommentHalJsonTestBase.php
Returns the expected normalization of the entity.
1 method overrides CommentResourceTestBase::getExpectedNormalizedEntity()
CommentHalJsonTestBase::getExpectedNormalizedEntity in core/modules/comment/tests/src/Functional/Hal/CommentHalJsonTestBase.php
Returns the expected normalization of the entity.

File

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

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' => [
            $this->formatExpectedTimestampItemValues(123456789),
        ],
        'changed' => [
            $this->formatExpectedTimestampItemValues($this->entity
                ->getChangedTime()),
        ],
        '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.