FilterFormatResourceTestBase.php

Same filename and directory in other branches
  1. 8.9.x core/modules/filter/tests/src/Functional/Rest/FilterFormatResourceTestBase.php
  2. 8.9.x core/modules/rest/tests/src/Functional/EntityResource/FilterFormat/FilterFormatResourceTestBase.php
  3. 10 core/modules/filter/tests/src/Functional/Rest/FilterFormatResourceTestBase.php
  4. 11.x core/modules/filter/tests/src/Functional/Rest/FilterFormatResourceTestBase.php

Namespace

Drupal\Tests\filter\Functional\Rest

File

core/modules/filter/tests/src/Functional/Rest/FilterFormatResourceTestBase.php

View source
<?php

namespace Drupal\Tests\filter\Functional\Rest;

use Drupal\filter\Entity\FilterFormat;
use Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase;
abstract class FilterFormatResourceTestBase extends ConfigEntityResourceTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected static $modules = [];
    
    /**
     * {@inheritdoc}
     */
    protected static $entityTypeId = 'filter_format';
    
    /**
     * @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 getExpectedNormalizedEntity() {
        return [
            '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,
                    ],
                ],
            ],
            'format' => 'pablo',
            'langcode' => 'es',
            'name' => 'Pablo Picasso',
            'status' => TRUE,
            'uuid' => $this->entity
                ->uuid(),
            'weight' => 0,
        ];
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getNormalizedPostEntity() {
        // @todo Update in https://www.drupal.org/node/2300677.
        return [];
    }

}

Classes

Title Deprecated Summary
FilterFormatResourceTestBase

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