Mercurial > hg > isophonics-drupal-site
diff core/modules/jsonapi/tests/src/Functional/RoleTest.php @ 18:af1871eacc83
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:33:08 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/jsonapi/tests/src/Functional/RoleTest.php Thu May 09 15:33:08 2019 +0100 @@ -0,0 +1,102 @@ +<?php + +namespace Drupal\Tests\jsonapi\Functional; + +use Drupal\Core\Url; +use Drupal\user\Entity\Role; + +/** + * JSON:API integration test for the "Role" config entity type. + * + * @group jsonapi + */ +class RoleTest extends ResourceTestBase { + + + /** + * {@inheritdoc} + */ + public static $modules = ['user']; + + /** + * {@inheritdoc} + */ + protected static $entityTypeId = 'user_role'; + + /** + * {@inheritdoc} + */ + protected static $resourceTypeName = 'user_role--user_role'; + + /** + * {@inheritdoc} + * + * @var \Drupal\user\RoleInterface + */ + protected $entity; + + /** + * {@inheritdoc} + */ + protected function setUpAuthorization($method) { + $this->grantPermissionsToTestedRole(['administer permissions']); + } + + /** + * {@inheritdoc} + */ + protected function createEntity() { + $role = Role::create([ + 'id' => 'llama', + 'name' => $this->randomString(), + ]); + $role->save(); + + return $role; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedDocument() { + $self_url = Url::fromUri('base:/jsonapi/user_role/user_role/' . $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' => 'user_role--user_role', + 'links' => [ + 'self' => ['href' => $self_url], + ], + 'attributes' => [ + 'weight' => 2, + 'langcode' => 'en', + 'status' => TRUE, + 'dependencies' => [], + 'label' => NULL, + 'is_admin' => NULL, + 'permissions' => [], + 'drupal_internal__id' => 'llama', + ], + ], + ]; + } + + /** + * {@inheritdoc} + */ + protected function getPostDocument() { + // @todo Update in https://www.drupal.org/node/2300677. + } + +}