DateFormatTest.php
Same filename in this branch
Same filename in other branches
- 9 core/modules/jsonapi/tests/src/Functional/DateFormatTest.php
- 9 core/modules/system/tests/src/FunctionalJavascript/System/DateFormatTest.php
- 10 core/modules/jsonapi/tests/src/Functional/DateFormatTest.php
- 10 core/modules/system/tests/src/FunctionalJavascript/System/DateFormatTest.php
- 11.x core/modules/jsonapi/tests/src/Functional/DateFormatTest.php
- 11.x core/modules/system/tests/src/FunctionalJavascript/System/DateFormatTest.php
Namespace
Drupal\Tests\jsonapi\FunctionalFile
-
core/
modules/ jsonapi/ tests/ src/ Functional/ DateFormatTest.php
View source
<?php
namespace Drupal\Tests\jsonapi\Functional;
use Drupal\Core\Datetime\Entity\DateFormat;
use Drupal\Core\Url;
/**
* JSON:API integration test for the "DateFormat" config entity type.
*
* @group jsonapi
*/
class DateFormatTest extends ResourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [];
/**
* {@inheritdoc}
*/
protected static $entityTypeId = 'date_format';
/**
* {@inheritdoc}
*/
protected static $resourceTypeName = 'date_format--date_format';
/**
* {@inheritdoc}
*/
protected static $anonymousUsersCanViewLabels = TRUE;
/**
* {@inheritdoc}
*
* @var \Drupal\Core\Datetime\DateFormatInterface
*/
protected $entity;
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUpAuthorization($method) {
$this->grantPermissionsToTestedRole([
'administer site configuration',
]);
}
/**
* {@inheritdoc}
*/
protected function createEntity() {
// Create a date format.
$date_format = DateFormat::create([
'id' => 'llama',
'label' => 'Llama',
'pattern' => 'F d, Y',
]);
$date_format->save();
return $date_format;
}
/**
* {@inheritdoc}
*/
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' => [
'href' => 'http://jsonapi.org/format/1.0/',
],
],
],
'version' => '1.0',
],
'links' => [
'self' => [
'href' => $self_url,
],
],
'data' => [
'id' => $this->entity
->uuid(),
'type' => 'date_format--date_format',
'links' => [
'self' => [
'href' => $self_url,
],
],
'attributes' => [
'dependencies' => [],
'label' => 'Llama',
'langcode' => 'en',
'locked' => FALSE,
'pattern' => 'F d, Y',
'status' => TRUE,
'drupal_internal__id' => 'llama',
],
],
];
}
/**
* {@inheritdoc}
*/
protected function getPostDocument() {
// @todo Update in https://www.drupal.org/node/2300677.
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
DateFormatTest | JSON:API integration test for the "DateFormat" config entity type. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.