You are here

protected function BlockContentTest::getExpectedDocument in Drupal 10

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

File

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

Class

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

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function getExpectedDocument() {
  $base_url = Url::fromUri('base:/jsonapi/block_content/basic/' . $this->entity
    ->uuid())
    ->setAbsolute();
  $self_url = clone $base_url;
  $version_identifier = 'id:' . $this->entity
    ->getRevisionId();
  $self_url = $self_url
    ->setOption('query', [
    'resourceVersion' => $version_identifier,
  ]);
  $version_query_string = '?resourceVersion=' . urlencode($version_identifier);
  return [
    'jsonapi' => [
      'meta' => [
        'links' => [
          'self' => [
            'href' => 'http://jsonapi.org/format/1.0/',
          ],
        ],
      ],
      'version' => '1.0',
    ],
    'links' => [
      'self' => [
        'href' => $base_url
          ->toString(),
      ],
    ],
    'data' => [
      'id' => $this->entity
        ->uuid(),
      'type' => 'block_content--basic',
      'links' => [
        'self' => [
          'href' => $self_url
            ->toString(),
        ],
      ],
      '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(),
            'meta' => [
              'drupal_internal__target_id' => 'basic',
            ],
            'type' => 'block_content_type--block_content_type',
          ],
          'links' => [
            'related' => [
              'href' => $base_url
                ->toString() . '/block_content_type' . $version_query_string,
            ],
            'self' => [
              'href' => $base_url
                ->toString() . '/relationships/block_content_type' . $version_query_string,
            ],
          ],
        ],
        'revision_user' => [
          'data' => NULL,
          'links' => [
            'related' => [
              'href' => $base_url
                ->toString() . '/revision_user' . $version_query_string,
            ],
            'self' => [
              'href' => $base_url
                ->toString() . '/relationships/revision_user' . $version_query_string,
            ],
          ],
        ],
      ],
    ],
  ];
}