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