View source
<?php
namespace Drupal\Tests\jsonapi\Functional;
use Drupal\Core\Datetime\Entity\DateFormat;
use Drupal\Core\Url;
class DateFormatTest extends ResourceTestBase {
public static $modules = [];
protected static $entityTypeId = 'date_format';
protected static $resourceTypeName = 'date_format--date_format';
protected $entity;
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer site configuration',
]);
}
protected function createEntity() {
$date_format = DateFormat::create([
'id' => 'llama',
'label' => 'Llama',
'pattern' => 'F d, Y',
]);
$date_format
->save();
return $date_format;
}
protected function getExpectedDocument() {
$self_url = Url::fromUri('base:/jsonapi/date_format/date_format/' . $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' => 'date_format--date_format',
'links' => [
'self' => $self_url,
],
'attributes' => [
'dependencies' => [],
'id' => 'llama',
'label' => 'Llama',
'langcode' => 'en',
'locked' => FALSE,
'pattern' => 'F d, Y',
'status' => TRUE,
'uuid' => $this->entity
->uuid(),
],
],
];
}
protected function getPostDocument() {
}
}