class DateFormatResourceTestBase

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

ResourceTestBase for DateFormat entity.

Hierarchy

Expanded class hierarchy of DateFormatResourceTestBase

3 files declare their use of DateFormatResourceTestBase
DateFormatHalJsonAnonTest.php in core/modules/hal/tests/src/Functional/Core/DateFormatHalJsonAnonTest.php
DateFormatHalJsonBasicAuthTest.php in core/modules/hal/tests/src/Functional/Core/DateFormatHalJsonBasicAuthTest.php
DateFormatHalJsonCookieTest.php in core/modules/hal/tests/src/Functional/Core/DateFormatHalJsonCookieTest.php

File

core/tests/Drupal/FunctionalTests/Rest/DateFormatResourceTestBase.php, line 11

Namespace

Drupal\FunctionalTests\Rest
View source
abstract class DateFormatResourceTestBase extends ConfigEntityResourceTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [];
  
  /**
   * {@inheritdoc}
   */
  protected static $entityTypeId = 'date_format';
  
  /**
   * The DateFormat entity.
   *
   * @var \Drupal\Core\Datetime\DateFormatInterface
   */
  protected $entity;
  
  /**
   * {@inheritdoc}
   */
  protected function setUpAuthorization($method) {
    $this->grantPermissionsToTestedRole([
      'administer site configuration',
    ]);
  }
  
  /**
   * {@inheritdoc}
   */
  protected function createEntity() {
    // Create a date format.
    $date_format = DateFormat::create([
      'id' => 'llama',
      'label' => 'Llama',
      'pattern' => 'F d, Y',
    ]);
    $date_format->save();
    return $date_format;
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getExpectedNormalizedEntity() {
    return [
      'dependencies' => [],
      'id' => 'llama',
      'label' => 'Llama',
      'langcode' => 'en',
      'locked' => FALSE,
      'pattern' => 'F d, Y',
      'status' => TRUE,
      'uuid' => $this->entity
        ->uuid(),
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getNormalizedPostEntity() {
    // @todo Update in https://www.drupal.org/node/2300677.
    return [];
  }

}

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