class VocabularyResourceTestBase

Same name and namespace in other branches
  1. 11.x core/modules/taxonomy/tests/src/Functional/Rest/VocabularyResourceTestBase.php \Drupal\Tests\taxonomy\Functional\Rest\VocabularyResourceTestBase
  2. 10 core/modules/taxonomy/tests/src/Functional/Rest/VocabularyResourceTestBase.php \Drupal\Tests\taxonomy\Functional\Rest\VocabularyResourceTestBase
  3. 8.9.x core/modules/rest/tests/src/Functional/EntityResource/Vocabulary/VocabularyResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\Vocabulary\VocabularyResourceTestBase
  4. 8.9.x core/modules/taxonomy/tests/src/Functional/Rest/VocabularyResourceTestBase.php \Drupal\Tests\taxonomy\Functional\Rest\VocabularyResourceTestBase

Hierarchy

Expanded class hierarchy of VocabularyResourceTestBase

3 files declare their use of VocabularyResourceTestBase
VocabularyHalJsonAnonTest.php in core/modules/hal/tests/src/Functional/taxonomy/VocabularyHalJsonAnonTest.php
VocabularyHalJsonBasicAuthTest.php in core/modules/hal/tests/src/Functional/taxonomy/VocabularyHalJsonBasicAuthTest.php
VocabularyHalJsonCookieTest.php in core/modules/hal/tests/src/Functional/taxonomy/VocabularyHalJsonCookieTest.php

File

core/modules/taxonomy/tests/src/Functional/Rest/VocabularyResourceTestBase.php, line 8

Namespace

Drupal\Tests\taxonomy\Functional\Rest
View source
abstract class VocabularyResourceTestBase extends ConfigEntityResourceTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'taxonomy',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected static $entityTypeId = 'taxonomy_vocabulary';
  
  /**
   * @var \Drupal\taxonomy\VocabularyInterface
   */
  protected $entity;
  
  /**
   * {@inheritdoc}
   */
  protected function setUpAuthorization($method) {
    $this->grantPermissionsToTestedRole([
      'administer taxonomy',
    ]);
  }
  
  /**
   * {@inheritdoc}
   */
  protected function createEntity() {
    $vocabulary = Vocabulary::create([
      'name' => 'Llama',
      'vid' => 'llama',
    ]);
    $vocabulary->save();
    return $vocabulary;
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getExpectedNormalizedEntity() {
    return [
      'uuid' => $this->entity
        ->uuid(),
      'vid' => 'llama',
      'langcode' => 'en',
      'status' => TRUE,
      'dependencies' => [],
      'name' => 'Llama',
      'description' => NULL,
      'weight' => 0,
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getNormalizedPostEntity() {
    // @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);
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.