View source
<?php
namespace Drupal\Tests\jsonapi\Functional;
use Drupal\Core\Entity\Entity\EntityViewMode;
use Drupal\Core\Url;
class EntityViewModeTest extends ResourceTestBase {
protected static $modules = [
'user',
'field_ui',
];
protected $defaultTheme = 'stark';
protected static $entityTypeId = 'entity_view_mode';
protected static $resourceTypeName = 'entity_view_mode--entity_view_mode';
protected $entity;
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer display modes',
]);
}
protected function createEntity() {
$entity_view_mode = EntityViewMode::create([
'id' => 'user.test',
'label' => 'Test',
'targetEntityType' => 'user',
]);
$entity_view_mode
->save();
return $entity_view_mode;
}
protected function getExpectedDocument() {
$self_url = Url::fromUri('base:/jsonapi/entity_view_mode/entity_view_mode/' . $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' => 'entity_view_mode--entity_view_mode',
'links' => [
'self' => [
'href' => $self_url,
],
],
'attributes' => [
'cache' => TRUE,
'dependencies' => [
'module' => [
'user',
],
],
'label' => 'Test',
'langcode' => 'en',
'status' => TRUE,
'targetEntityType' => 'user',
'drupal_internal__id' => 'user.test',
],
],
];
}
protected function getPostDocument() {
}
}