function FilterCrudTest::verifyTextFormat

Same name in other branches
  1. 9 core/modules/filter/tests/src/Kernel/FilterCrudTest.php \Drupal\Tests\filter\Kernel\FilterCrudTest::verifyTextFormat()
  2. 8.9.x core/modules/filter/tests/src/Kernel/FilterCrudTest.php \Drupal\Tests\filter\Kernel\FilterCrudTest::verifyTextFormat()
  3. 10 core/modules/filter/tests/src/Kernel/FilterCrudTest.php \Drupal\Tests\filter\Kernel\FilterCrudTest::verifyTextFormat()

Verifies that a text format is properly stored.

1 call to FilterCrudTest::verifyTextFormat()
FilterCrudTest::testTextFormatCrud in core/modules/filter/tests/src/Kernel/FilterCrudTest.php
Tests CRUD operations for text formats and filters.

File

core/modules/filter/tests/src/Kernel/FilterCrudTest.php, line 91

Class

FilterCrudTest
Tests creation, loading, updating, deleting of text formats and filters.

Namespace

Drupal\Tests\filter\Kernel

Code

public function verifyTextFormat($format) {
    $default_langcode = \Drupal::languageManager()->getDefaultLanguage()
        ->getId();
    // Verify the loaded filter has all properties.
    $filter_format = FilterFormat::load($format->id());
    $format_label = $format->label();
    $this->assertEquals($format->id(), $filter_format->id(), "filter_format_load: Proper format id for text format {$format_label}.");
    $this->assertEquals($format->label(), $filter_format->label(), "filter_format_load: Proper title for text format {$format_label}.");
    $this->assertEquals($format->get('weight'), $filter_format->get('weight'), "filter_format_load: Proper weight for text format {$format_label}.");
    // Check that the filter was created in site default language.
    $this->assertEquals($default_langcode, $format->language()
        ->getId(), "filter_format_load: Proper language code for text format {$format_label}.");
    // Verify the permission exists and has the correct dependencies.
    $permissions = \Drupal::service('user.permissions')->getPermissions();
    $this->assertTrue(isset($permissions[$format->getPermissionName()]));
    $this->assertEquals([
        'config' => [
            $format->getConfigDependencyName(),
        ],
    ], $permissions[$format->getPermissionName()]['dependencies']);
}

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