Same name in this branch
  1. 10 core/modules/jsonapi/tests/src/Functional/FilterFormatTest.php \Drupal\Tests\jsonapi\Functional\FilterFormatTest
  2. 10 core/modules/filter/tests/src/Kernel/Plugin/migrate/source/d6/FilterFormatTest.php \Drupal\Tests\filter\Kernel\Plugin\migrate\source\d6\FilterFormatTest
  3. 10 core/modules/filter/tests/src/Kernel/Plugin/migrate/source/d7/FilterFormatTest.php \Drupal\Tests\filter\Kernel\Plugin\migrate\source\d7\FilterFormatTest
Same name and namespace in other branches
  1. 8.9.x core/modules/jsonapi/tests/src/Functional/FilterFormatTest.php \Drupal\Tests\jsonapi\Functional\FilterFormatTest
  2. 9 core/modules/jsonapi/tests/src/Functional/FilterFormatTest.php \Drupal\Tests\jsonapi\Functional\FilterFormatTest

JSON:API integration test for the "FilterFormat" config entity type.

@group jsonapi @group #slow

Hierarchy

Expanded class hierarchy of FilterFormatTest

File

core/modules/jsonapi/tests/src/Functional/FilterFormatTest.php, line 16

Namespace

Drupal\Tests\jsonapi\Functional
View source
class FilterFormatTest extends ConfigEntityResourceTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'filter',
  ];

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * {@inheritdoc}
   */
  protected static $entityTypeId = 'filter_format';

  /**
   * {@inheritdoc}
   */
  protected static $resourceTypeName = 'filter_format--filter_format';

  /**
   * {@inheritdoc}
   *
   * @var \Drupal\filter\FilterFormatInterface
   */
  protected $entity;

  /**
   * {@inheritdoc}
   */
  protected function setUpAuthorization($method) {
    $this
      ->grantPermissionsToTestedRole([
      'administer filters',
    ]);
  }

  /**
   * {@inheritdoc}
   */
  protected function createEntity() {
    $pablo_format = FilterFormat::create([
      'name' => 'Pablo Picasso',
      'format' => 'pablo',
      'langcode' => 'es',
      'filters' => [
        'filter_html' => [
          'status' => TRUE,
          'settings' => [
            'allowed_html' => '<p> <a> <b> <lo>',
          ],
        ],
      ],
    ]);
    $pablo_format
      ->save();
    return $pablo_format;
  }

  /**
   * {@inheritdoc}
   */
  protected function getExpectedDocument() {
    $self_url = Url::fromUri('base:/jsonapi/filter_format/filter_format/' . $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' => 'filter_format--filter_format',
        'links' => [
          'self' => [
            'href' => $self_url,
          ],
        ],
        'attributes' => [
          'dependencies' => [],
          'filters' => [
            'filter_html' => [
              'id' => 'filter_html',
              'provider' => 'filter',
              'status' => TRUE,
              'weight' => -10,
              'settings' => [
                'allowed_html' => '<p> <a> <b> <lo>',
                'filter_html_help' => TRUE,
                'filter_html_nofollow' => FALSE,
              ],
            ],
          ],
          'langcode' => 'es',
          'name' => 'Pablo Picasso',
          'status' => TRUE,
          'weight' => 0,
          'drupal_internal__format' => 'pablo',
        ],
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  protected function getPostDocument() {

    // @todo Update in https://www.drupal.org/node/2300677.
    return [];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigEntityResourceTestBase::setUp public function
ConfigEntityResourceTestBase::SKIP_METHODS constant A list of test methods to skip.
FilterFormatTest::$defaultTheme protected property
FilterFormatTest::$entity protected property
FilterFormatTest::$entityTypeId protected static property
FilterFormatTest::$modules protected static property
FilterFormatTest::$resourceTypeName protected static property
FilterFormatTest::createEntity protected function
FilterFormatTest::getExpectedDocument protected function
FilterFormatTest::getPostDocument protected function
FilterFormatTest::setUpAuthorization protected function