protected function UserTest::getExpectedDocument in JSON:API 8.2
Same name and namespace in other branches
- 8 tests/src/Functional/UserTest.php \Drupal\Tests\jsonapi\Functional\UserTest::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/ UserTest.php, line 120
Class
- UserTest
- JSON:API integration test for the "User" content entity type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected function getExpectedDocument() {
$self_url = Url::fromUri('base:/jsonapi/user/user/' . $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' => 'user--user',
'links' => [
'self' => [
'href' => $self_url,
],
],
'attributes' => [
'created' => '1973-11-29T21:33:09+00:00',
'changed' => (new \DateTime())
->setTimestamp($this->entity
->getChangedTime())
->setTimezone(new \DateTimeZone('UTC'))
->format(\DateTime::RFC3339),
'default_langcode' => TRUE,
'langcode' => 'en',
'name' => 'Llama',
'drupal_internal__uid' => 3,
],
],
];
}