function EditorValidationTest::testInvalidDependencies

Same name in other branches
  1. 11.x core/modules/editor/tests/src/Kernel/EditorValidationTest.php \Drupal\Tests\editor\Kernel\EditorValidationTest::testInvalidDependencies()

Tests that validation fails if config dependencies are invalid.

File

core/modules/editor/tests/src/Kernel/EditorValidationTest.php, line 81

Class

EditorValidationTest
Tests validation of editor entities.

Namespace

Drupal\Tests\editor\Kernel

Code

public function testInvalidDependencies() : void {
    // Remove the config dependencies from the editor entity.
    $dependencies = $this->entity
        ->getDependencies();
    $dependencies['config'] = [];
    $this->entity
        ->set('dependencies', $dependencies);
    $this->assertValidationErrors([
        '' => 'This text editor requires a text format.',
    ]);
    // Things look sort-of like `filter.format.*` should fail validation
    // because they don't exist.
    $dependencies['config'] = [
        'filter.format',
        'filter.format.',
    ];
    $this->entity
        ->set('dependencies', $dependencies);
    $this->assertValidationErrors([
        '' => 'This text editor requires a text format.',
        'dependencies.config.0' => "The 'filter.format' config does not exist.",
        'dependencies.config.1' => "The 'filter.format.' config does not exist.",
    ]);
}

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