function ShortcutTest::getExpectedDocument

Same name in other branches
  1. 8.9.x core/modules/jsonapi/tests/src/Functional/ShortcutTest.php \Drupal\Tests\jsonapi\Functional\ShortcutTest::getExpectedDocument()
  2. 10 core/modules/jsonapi/tests/src/Functional/ShortcutTest.php \Drupal\Tests\jsonapi\Functional\ShortcutTest::getExpectedDocument()
  3. 11.x core/modules/jsonapi/tests/src/Functional/ShortcutTest.php \Drupal\Tests\jsonapi\Functional\ShortcutTest::getExpectedDocument()

Overrides ResourceTestBase::getExpectedDocument

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',
                        ],
                    ],
                ],
            ],
        ],
    ];
}

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