class DesignTokenResourceTestBase

Resource test base for the design_token entity.

Hierarchy

Expanded class hierarchy of DesignTokenResourceTestBase

File

core/tests/Drupal/FunctionalTests/Rest/DesignTokenResourceTestBase.php, line 13

Namespace

Drupal\FunctionalTests\Rest
View source
abstract class DesignTokenResourceTestBase extends ConfigEntityResourceTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $entityTypeId = 'design_token';
  
  /**
   * @var \Drupal\Core\Theme\Entity\DesignTokenInterface
   */
  protected $entity;
  
  /**
   * {@inheritdoc}
   */
  protected function setUpAuthorization($method) : void {
    $this->grantPermissionsToTestedRole([
      'administer design tokens',
    ]);
  }
  
  /**
   * {@inheritdoc}
   */
  protected function createEntity() {
    $entity = DesignToken::create([
      'id' => 'my_token',
      'path' => 'my-token',
      'type' => 'fontWeight',
      'scopes' => [
        ':root' => 500,
      ],
    ]);
    $entity->save();
    return $entity;
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getExpectedNormalizedEntity() {
    return [
      'id' => 'my_token',
      'path' => 'my-token',
      'type' => 'fontWeight',
      'scopes' => [
        ':root' => 500,
      ],
      'langcode' => 'en',
      'status' => TRUE,
      'dependencies' => [],
      'uuid' => $this->entity
        ->uuid(),
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getNormalizedPostEntity() {
    // @todo Update in https://www.drupal.org/node/2300677.
    return [];
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getExpectedCacheContexts() {
    return [
      'user.permissions',
    ];
  }

}

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