function FileTest::getExpectedDocument
Same name in other branches
- 9 core/modules/jsonapi/tests/src/Functional/FileTest.php \Drupal\Tests\jsonapi\Functional\FileTest::getExpectedDocument()
- 10 core/modules/jsonapi/tests/src/Functional/FileTest.php \Drupal\Tests\jsonapi\Functional\FileTest::getExpectedDocument()
- 11.x core/modules/jsonapi/tests/src/Functional/FileTest.php \Drupal\Tests\jsonapi\Functional\FileTest::getExpectedDocument()
Overrides ResourceTestBase::getExpectedDocument
File
-
core/
modules/ jsonapi/ tests/ src/ Functional/ FileTest.php, line 132
Class
- FileTest
- JSON:API integration test for the "File" content entity type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected function getExpectedDocument() {
$self_url = Url::fromUri('base:/jsonapi/file/file/' . $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' => 'file--file',
'links' => [
'self' => [
'href' => $self_url,
],
],
'attributes' => [
'created' => (new \DateTime())->setTimestamp($this->entity
->getCreatedTime())
->setTimezone(new \DateTimeZone('UTC'))
->format(\DateTime::RFC3339),
'changed' => (new \DateTime())->setTimestamp($this->entity
->getChangedTime())
->setTimezone(new \DateTimeZone('UTC'))
->format(\DateTime::RFC3339),
'filemime' => 'text/plain',
'filename' => 'drupal.txt',
'filesize' => (int) $this->entity
->getSize(),
'langcode' => 'en',
'status' => TRUE,
'uri' => [
'url' => base_path() . $this->siteDirectory . '/files/drupal.txt',
'value' => 'public://drupal.txt',
],
'drupal_internal__fid' => 1,
],
'relationships' => [
'uid' => [
'data' => [
'id' => $this->author
->uuid(),
'type' => 'user--user',
],
'links' => [
'related' => [
'href' => $self_url . '/uid',
],
'self' => [
'href' => $self_url . '/relationships/uid',
],
],
],
],
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.