You are here

protected function ShortcutTest::getExpectedDocument in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/jsonapi/tests/src/Functional/ShortcutTest.php \Drupal\Tests\jsonapi\Functional\ShortcutTest::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/ShortcutTest.php, line 82

Class

ShortcutTest
JSON:API integration test for the "Shortcut" content entity type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function getExpectedDocument() {
  $self_url = Url::fromUri('base:/jsonapi/shortcut/default/' . $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' => 'shortcut--default',
      'links' => [
        'self' => [
          'href' => $self_url,
        ],
      ],
      'attributes' => [
        'title' => 'Comments',
        'link' => [
          'uri' => 'internal:/user/logout',
          'title' => NULL,
          'options' => [],
        ],
        'langcode' => 'en',
        'default_langcode' => TRUE,
        'weight' => -20,
        'drupal_internal__id' => (int) $this->entity
          ->id(),
      ],
      'relationships' => [
        'shortcut_set' => [
          'data' => [
            'type' => 'shortcut_set--shortcut_set',
            'meta' => [
              'drupal_internal__target_id' => 'default',
            ],
            'id' => ShortcutSet::load('default')
              ->uuid(),
          ],
          'links' => [
            'related' => [
              'href' => $self_url . '/shortcut_set',
            ],
            'self' => [
              'href' => $self_url . '/relationships/shortcut_set',
            ],
          ],
        ],
      ],
    ],
  ];
}