You are here

protected function BlockContentTest::getExpectedDocument in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/BlockContentTest.php \Drupal\Tests\jsonapi\Functional\BlockContentTest::getExpectedDocument()

Returns the expected JSON:API document for the entity.

Return value

array A JSON:API response document.

Overrides ResourceTestBase::getExpectedDocument

See also

::createEntity()

File

core/modules/jsonapi/tests/src/Functional/BlockContentTest.php, line 92

Class

BlockContentTest
JSON:API integration test for the "BlockContent" content entity type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function getExpectedDocument() {
  $self_url = Url::fromUri('base:/jsonapi/block_content/basic/' . $this->entity
    ->uuid())
    ->setAbsolute()
    ->toString(TRUE)
    ->getGeneratedUrl();
  return [
    'jsonapi' => [
      'meta' => [
        'links' => [
          'self' => [
            'href' => 'http://jsonapi.org/format/1.0/',
          ],
        ],
      ],
      'version' => '1.0',
    ],
    'links' => [
      'self' => [
        'href' => $self_url,
      ],
    ],
    'data' => [
      'id' => $this->entity
        ->uuid(),
      'type' => 'block_content--basic',
      'links' => [
        'self' => [
          'href' => $self_url,
        ],
      ],
      'attributes' => [
        'body' => [
          'value' => 'The name "llama" was adopted by European settlers from native Peruvians.',
          'format' => 'plain_text',
          'summary' => NULL,
          'processed' => "<p>The name &quot;llama&quot; was adopted by European settlers from native Peruvians.</p>\n",
        ],
        'changed' => (new \DateTime())
          ->setTimestamp($this->entity
          ->getChangedTime())
          ->setTimezone(new \DateTimeZone('UTC'))
          ->format(\DateTime::RFC3339),
        'info' => 'Llama',
        'revision_log' => NULL,
        'revision_created' => (new \DateTime())
          ->setTimestamp($this->entity
          ->getRevisionCreationTime())
          ->setTimezone(new \DateTimeZone('UTC'))
          ->format(\DateTime::RFC3339),
        'revision_translation_affected' => TRUE,
        'status' => FALSE,
        'langcode' => 'en',
        'default_langcode' => TRUE,
        'drupal_internal__id' => 1,
        'drupal_internal__revision_id' => 1,
        'reusable' => TRUE,
      ],
      'relationships' => [
        'block_content_type' => [
          'data' => [
            'id' => BlockContentType::load('basic')
              ->uuid(),
            'type' => 'block_content_type--block_content_type',
          ],
          'links' => [
            'related' => [
              'href' => $self_url . '/block_content_type',
            ],
            'self' => [
              'href' => $self_url . '/relationships/block_content_type',
            ],
          ],
        ],
        'revision_user' => [
          'data' => NULL,
          'links' => [
            'related' => [
              'href' => $self_url . '/revision_user',
            ],
            'self' => [
              'href' => $self_url . '/relationships/revision_user',
            ],
          ],
        ],
      ],
    ],
  ];
}