grantPermissionsToTestedRole(['administer taxonomy']); } /** * {@inheritdoc} */ protected function createEntity() { $vocabulary = Vocabulary::create([ 'name' => 'Llama', 'vid' => 'llama', ]); $vocabulary->save(); return $vocabulary; } /** * {@inheritdoc} */ protected function getExpectedDocument(): array { $self_url = Url::fromUri('base:/jsonapi/taxonomy_vocabulary/taxonomy_vocabulary/' . $this->entity->uuid())->setAbsolute()->toString(TRUE)->getGeneratedUrl(); return [ 'jsonapi' => [ 'meta' => [ 'links' => [ 'self' => ['href' => JsonApiSpec::SUPPORTED_SPECIFICATION_PERMALINK], ], ], 'version' => JsonApiSpec::SUPPORTED_SPECIFICATION_VERSION, ], 'links' => [ 'self' => ['href' => $self_url], ], 'data' => [ 'id' => $this->entity->uuid(), 'type' => 'taxonomy_vocabulary--taxonomy_vocabulary', 'links' => [ 'self' => ['href' => $self_url], ], 'attributes' => [ 'langcode' => 'en', 'status' => TRUE, 'dependencies' => [], 'name' => 'Llama', 'new_revision' => FALSE, 'description' => NULL, 'weight' => 0, 'drupal_internal__vid' => 'llama', ], ], ]; } /** * {@inheritdoc} */ protected function getPostDocument(): array { // @todo Update in https://www.drupal.org/node/2300677. return []; } /** * {@inheritdoc} */ protected function getExpectedUnauthorizedAccessMessage($method) { if ($method === 'GET') { return "The following permissions are required: 'access taxonomy overview' OR 'administer taxonomy'."; } return parent::getExpectedUnauthorizedAccessMessage($method); } }