protected function ShortcutTest::getExpectedDocument in JSON:API 8
Same name and namespace in other branches
- 8.2 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
- tests/
src/ Functional/ ShortcutTest.php, line 77
Class
- ShortcutTest
- JSON API integration test for the "Shortcut" content entity type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected function getExpectedDocument() {
$self_url = Url::fromUri('base:/jsonapi/shortcut/default/' . $this->entity
->uuid())
->setAbsolute()
->toString(TRUE)
->getGeneratedUrl();
return [
'jsonapi' => [
'meta' => [
'links' => [
'self' => 'http://jsonapi.org/format/1.0/',
],
],
'version' => '1.0',
],
'links' => [
'self' => $self_url,
],
'data' => [
'id' => $this->entity
->uuid(),
'type' => 'shortcut--default',
'links' => [
'self' => $self_url,
],
'attributes' => [
'uuid' => $this->entity
->uuid(),
'id' => (int) $this->entity
->id(),
'title' => 'Comments',
'link' => [
'uri' => 'internal:/user/logout',
'title' => NULL,
'options' => [],
],
'langcode' => 'en',
'default_langcode' => TRUE,
'weight' => -20,
],
'relationships' => [
'shortcut_set' => [
'data' => [
'type' => 'shortcut_set--shortcut_set',
'id' => ShortcutSet::load('default')
->uuid(),
],
'links' => [
'related' => $self_url . '/shortcut_set',
'self' => $self_url . '/relationships/shortcut_set',
],
],
],
],
];
}