function CKEditor5PluginManagerTest::providerTestInvalidPluginDefinitions

Same name in other branches
  1. 10 core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php \Drupal\Tests\ckeditor5\Kernel\CKEditor5PluginManagerTest::providerTestInvalidPluginDefinitions()
  2. 11.x core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php \Drupal\Tests\ckeditor5\Kernel\CKEditor5PluginManagerTest::providerTestInvalidPluginDefinitions()

Data provider.

Return value

\Generator Test scenarios.

File

core/modules/ckeditor5/tests/src/Kernel/CKEditor5PluginManagerTest.php, line 193

Class

CKEditor5PluginManagerTest
Tests different ways of enabling CKEditor 5 plugins.

Namespace

Drupal\Tests\ckeditor5\Kernel

Code

public function providerTestInvalidPluginDefinitions() : \Generator {
    (yield 'invalid plugin ID with everything else okay' => [
        <<<YAML
foo_bar:
  ckeditor5:
    plugins: []
  drupal:
    label: TEST
    elements: false
YAML
,
        'The "foo_bar" CKEditor 5 plugin definition must have a plugin ID that starts with "ckeditor5_invalid_plugin_".',
    ]);
    // Now let's show the progressive exceptions that should steer the plugin
    // developer in the right direction.
    (yield 'only plugin ID, nothing else' => [
        <<<YAML
foo_bar: {}
YAML
,
        'The "foo_bar" CKEditor 5 plugin definition must have a plugin ID that starts with "ckeditor5_invalid_plugin_".',
    ]);
    (yield 'fixed plugin ID' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar: {}
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition must contain a "ckeditor5" key.',
    ]);
    (yield 'added ckeditor5' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5: {}
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition must contain a "ckeditor5.plugins" key.',
    ]);
    (yield 'added ckeditor5.plugins' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition must contain a "drupal" key.',
    ]);
    (yield 'added drupal' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal: {}
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition must contain a "drupal.label" key.',
    ]);
    (yield 'added drupal.label' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: {}
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition has a "drupal.label" value that is not a string nor a TranslatableMarkup instance.',
    ]);
    (yield 'fixed drupal.label' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition must contain a "drupal.elements" key.',
    ]);
    (yield 'added drupal.elements' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements: {}
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition has a "drupal.elements" value that is neither a list of HTML tags/attributes nor false.',
    ]);
    (yield 'wrongly fixed drupal.elements: no valid tags' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - foo
      - bar
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition has a value at "drupal.elements.0" that is not an HTML tag with optional attributes: "foo". Expected structure: "<tag allowedAttribute="allowedValue1 allowedValue2">".',
    ]);
    (yield 'wrongly fixed drupal.elements: multiple tags per entry' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo> <bar>
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition has a value at "drupal.elements.0": multiple tags listed, should be one: "<foo> <bar>".',
    ]);
    (yield 'fixed drupal.elements' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
YAML
,
        NULL,
    ]);
    (yield 'alternative fix for drupal.elements' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements: false
YAML
,
        NULL,
    ]);
    (yield 'added invalid optional metadata: drupal.admin_library' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/foo_bar
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition has a "drupal.admin_library" key whose asset library "ckeditor5/foo_bar" does not exist.',
    ]);
    (yield 'fixed drupal.admin_library' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
YAML
,
        NULL,
    ]);
    // Add conditions.
    (yield 'unsupported condition type' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
    conditions:
      foo: bar
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition has a "drupal.conditions" value that contains some unsupported condition types: "foo". Only the following conditions types are supported: "toolbarItem", "imageUploadStatus", "filter", "requiresConfiguration", "plugins".',
    ]);
    (yield 'invalid condition: toolbarItem' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
    conditions:
      toolbarItem: [bold, italic]
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition has an invalid "drupal.conditions" item. "toolbarItem" is set to an invalid value. A string corresponding to a CKEditor 5 toolbar item must be specified.',
    ]);
    (yield 'valid condition: toolbarItem' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
    conditions:
      toolbarItem: bold
YAML
,
        NULL,
    ]);
    (yield 'invalid condition: filter' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
    conditions:
      toolbarItem: bold
      filter: true
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition has an invalid "drupal.conditions" item. "filter" is set to an invalid value. A string corresponding to a filter plugin ID must be specified.',
    ]);
    (yield 'valid condition: filter' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
    conditions:
      toolbarItem: bold
      filter: filter_caption
YAML
,
        NULL,
    ]);
    (yield 'invalid condition: imageUploadStatus' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
    conditions:
      toolbarItem: bold
      filter: filter_caption
      imageUploadStatus: 'true'
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition has an invalid "drupal.conditions" item. "imageUploadStatus" is set to an invalid value. A boolean indicating whether image uploads must be enabled (true) or not (false) must be specified.',
    ]);
    (yield 'valid condition: imageUploadStatus' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
    conditions:
      toolbarItem: bold
      filter: filter_caption
      imageUploadStatus: true
YAML
,
        NULL,
    ]);
    (yield 'invalid condition: plugins' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
    conditions:
      toolbarItem: bold
      filter: filter_caption
      imageUploadStatus: true
      plugins: ckeditor5_imageCaption
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition has an invalid "drupal.conditions" item. "plugins" is set to an invalid value. A list of strings, each corresponding to a CKEditor 5 plugin ID must be specified.',
    ]);
    (yield 'valid condition: plugins' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
    conditions:
      toolbarItem: bold
      filter: filter_caption
      imageUploadStatus: true
      plugins: [ckeditor5_imageCaption]
YAML
,
        NULL,
    ]);
    (yield 'unconditional: for plugins that should always loaded' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
    conditions: []
YAML
,
        NULL,
    ]);
    (yield 'explicitly unconditional' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
    conditions: false
YAML
,
        NULL,
    ]);
    // Add a plugin class; observe what additional requirements need to be met.
    (yield 'added plugin class' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    class: Drupal\\ckeditor5_invalid_plugin\\Plugin\\CKEditor5Plugin\\FooBar
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
YAML
,
        'The CKEditor 5 "ckeditor5_invalid_plugin_foo_bar" provides a plugin class: "Drupal\\ckeditor5_invalid_plugin\\Plugin\\CKEditor5Plugin\\FooBar", but it does not exist.',
    ]);
    (yield 'defined minimal (but not yet valid) plugin class' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    class: Drupal\\ckeditor5_invalid_plugin\\Plugin\\CKEditor5Plugin\\FooBar
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
YAML
,
        'CKEditor 5 plugins must implement \\Drupal\\ckeditor5\\Plugin\\CKEditor5PluginInterface. "ckeditor5_invalid_plugin_foo_bar" does not.',
        [
            'src' => [
                'Plugin' => [
                    'CKEditor5Plugin' => [
                        'FooBar.php' => <<<'PHP'
<?php
namespace Drupal\ckeditor5_invalid_plugin\Plugin\CKEditor5Plugin;
class FooBar {}
PHP
,
                    ],
                ],
            ],
        ],
    ]);
    (yield 'defined minimal and valid plugin class' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    class: Drupal\\ckeditor5_invalid_plugin\\Plugin\\CKEditor5Plugin\\FooBar
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
YAML
,
        NULL,
        [
            'src' => [
                'Plugin' => [
                    'CKEditor5Plugin' => [
                        'FooBar.php' => <<<'PHP'
<?php
namespace Drupal\ckeditor5_invalid_plugin\Plugin\CKEditor5Plugin;
use Drupal\ckeditor5\Plugin\CKEditor5PluginDefault;
class FooBar extends CKEditor5PluginDefault {}
PHP
,
                    ],
                ],
            ],
        ],
    ]);
    // Make the plugin configurable; observe what additional requirements need
    // to be met.
    (yield 'defined minimal and valid plugin class made configurable but not really anything configurable' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    class: Drupal\\ckeditor5_invalid_plugin\\Plugin\\CKEditor5Plugin\\FooBar
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
YAML
,
        NULL,
        [
            'src' => [
                'Plugin' => [
                    'CKEditor5Plugin' => [
                        'FooBar.php' => <<<'PHP'
<?php
namespace Drupal\ckeditor5_invalid_plugin\Plugin\CKEditor5Plugin;
use Drupal\ckeditor5\Plugin\CKEditor5PluginDefault;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableInterface;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableTrait;
use Drupal\Core\Form\FormStateInterface;
class FooBar extends CKEditor5PluginDefault implements CKEditor5PluginConfigurableInterface {
  use CKEditor5PluginConfigurableTrait;
  public function defaultConfiguration() { return []; }
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) { return []; }
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {}
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {}
}
PHP
,
                    ],
                ],
            ],
        ],
    ]);
    (yield 'defined minimal and valid plugin class made configurable: invalid if config schema is missing' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    class: Drupal\\ckeditor5_invalid_plugin\\Plugin\\CKEditor5Plugin\\FooBar
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition is configurable, has non-empty default configuration but has no config schema. Config schema is required for validation.',
        [
            'src' => [
                'Plugin' => [
                    'CKEditor5Plugin' => [
                        'FooBar.php' => <<<'PHP'
<?php
namespace Drupal\ckeditor5_invalid_plugin\Plugin\CKEditor5Plugin;
use Drupal\ckeditor5\Plugin\CKEditor5PluginDefault;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableInterface;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableTrait;
use Drupal\Core\Form\FormStateInterface;
class FooBar extends CKEditor5PluginDefault implements CKEditor5PluginConfigurableInterface {
  use CKEditor5PluginConfigurableTrait;
  public function defaultConfiguration() { return ['foo' => FALSE]; }
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) { return []; }
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {}
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {}
}
PHP
,
                    ],
                ],
            ],
        ],
    ]);
    (yield 'defined minimal and valid plugin class made configurable: valid if config schema is present' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    class: Drupal\\ckeditor5_invalid_plugin\\Plugin\\CKEditor5Plugin\\FooBar
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
YAML
,
        NULL,
        [
            'config' => [
                'schema' => [
                    'ckeditor5_invalid_plugin.schema.yml' => <<<YAML
ckeditor5.plugin.ckeditor5_invalid_plugin_foo_bar:
  type: mapping
  label: 'Foo Bar'
  mapping:
    foo:
      type: boolean
      label: 'Foo'
YAML
,
                ],
            ],
            'src' => [
                'Plugin' => [
                    'CKEditor5Plugin' => [
                        'FooBar.php' => <<<'PHP'
<?php
namespace Drupal\ckeditor5_invalid_plugin\Plugin\CKEditor5Plugin;
use Drupal\ckeditor5\Plugin\CKEditor5PluginDefault;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableInterface;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableTrait;
use Drupal\Core\Form\FormStateInterface;
class FooBar extends CKEditor5PluginDefault implements CKEditor5PluginConfigurableInterface {
  use CKEditor5PluginConfigurableTrait;
  public function defaultConfiguration() { return ['foo' => FALSE]; }
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) { return []; }
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {}
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {}
}
PHP
,
                    ],
                ],
            ],
        ],
    ]);
    (yield 'defined minimal and valid plugin class made configurable: invalid if config schema is present but incomplete' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    class: Drupal\\ckeditor5_invalid_plugin\\Plugin\\CKEditor5Plugin\\FooBar
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition is configurable, but its default configuration does not match its config schema. The following errors were found: [foo] The configuration property foo.bar doesn\'t exist, [baz] missing schema.',
        [
            'config' => [
                'schema' => [
                    'ckeditor5_invalid_plugin.schema.yml' => <<<YAML
ckeditor5.plugin.ckeditor5_invalid_plugin_foo_bar:
  type: mapping
  label: 'Foo Bar'
  mapping:
    foo:
      type: boolean
      label: 'Foo'
YAML
,
                ],
            ],
            'src' => [
                'Plugin' => [
                    'CKEditor5Plugin' => [
                        'FooBar.php' => <<<'PHP'
<?php
namespace Drupal\ckeditor5_invalid_plugin\Plugin\CKEditor5Plugin;
use Drupal\ckeditor5\Plugin\CKEditor5PluginDefault;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableInterface;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableTrait;
use Drupal\Core\Form\FormStateInterface;
class FooBar extends CKEditor5PluginDefault implements CKEditor5PluginConfigurableInterface {
  use CKEditor5PluginConfigurableTrait;
  public function defaultConfiguration() { return ['foo' => ['bar' => TRUE], 'baz' => FALSE]; }
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) { return []; }
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {}
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {}
}
PHP
,
                    ],
                ],
            ],
        ],
    ]);
    (yield 'defined minimal and valid plugin class made configurable: valid if config schema is present and complete' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    class: Drupal\\ckeditor5_invalid_plugin\\Plugin\\CKEditor5Plugin\\FooBar
    label: "Foo bar"
    elements:
      - <foo>
      - <bar>
    admin_library: ckeditor5/internal.admin.basic
YAML
,
        NULL,
        [
            'config' => [
                'schema' => [
                    'ckeditor5_invalid_plugin.schema.yml' => <<<YAML
ckeditor5.plugin.ckeditor5_invalid_plugin_foo_bar:
  type: mapping
  label: 'Foo Bar'
  mapping:
    foo:
      type: boolean
      label: 'Foo'
    bar:
      type: boolean
      label: 'Bar'
YAML
,
                ],
            ],
            'src' => [
                'Plugin' => [
                    'CKEditor5Plugin' => [
                        'FooBar.php' => <<<'PHP'
<?php
namespace Drupal\ckeditor5_invalid_plugin\Plugin\CKEditor5Plugin;
use Drupal\ckeditor5\Plugin\CKEditor5PluginDefault;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableInterface;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableTrait;
use Drupal\Core\Form\FormStateInterface;
class FooBar extends CKEditor5PluginDefault implements CKEditor5PluginConfigurableInterface {
  use CKEditor5PluginConfigurableTrait;
  public function defaultConfiguration() { return ['foo' => FALSE, 'bar' => FALSE]; }
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) { return []; }
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {}
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {}
}
PHP
,
                    ],
                ],
            ],
        ],
    ]);
    (yield 'invalid condition: requiresConfiguration not specifying a configuration array' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements: false
    conditions:
      requiresConfiguration: true
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition has an invalid "drupal.conditions" item. "requiresConfiguration" is set to an invalid value. An array structure matching the required configuration for this plugin must be specified.',
    ]);
    (yield 'invalid condition: requiresConfiguration without configurable plugin' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    label: "Foo bar"
    elements: false
    conditions:
      requiresConfiguration:
        allow_resize: true
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition has an invalid "drupal.conditions" item. "requiresConfiguration" is set to an invalid value. This condition type is only available for CKEditor 5 plugins implementing CKEditor5PluginConfigurableInterface.',
    ]);
    (yield 'invalid condition: requiresConfiguration with configurable plugin but required configuration does not match config schema' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    class: Drupal\\ckeditor5_invalid_plugin\\Plugin\\CKEditor5Plugin\\FooBar
    label: "Foo bar"
    elements: false
    conditions:
      requiresConfiguration:
        allow_resize: true
YAML
,
        'The "ckeditor5_invalid_plugin_foo_bar" CKEditor 5 plugin definition has an invalid "drupal.conditions" item. "requiresConfiguration" is set to an invalid value. The required configuration does not match its config schema. The following errors were found: [allow_resize] The configuration property allow_resize doesn\'t exist.',
        [
            'config' => [
                'schema' => [
                    'ckeditor5_invalid_plugin.schema.yml' => <<<YAML
ckeditor5.plugin.ckeditor5_invalid_plugin_foo_bar:
  type: mapping
  label: 'Foo Bar'
  mapping:
    foo:
      type: boolean
      label: 'Foo'
YAML
,
                ],
            ],
            'src' => [
                'Plugin' => [
                    'CKEditor5Plugin' => [
                        'FooBar.php' => <<<'PHP'
<?php
namespace Drupal\ckeditor5_invalid_plugin\Plugin\CKEditor5Plugin;
use Drupal\ckeditor5\Plugin\CKEditor5PluginDefault;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableInterface;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableTrait;
use Drupal\Core\Form\FormStateInterface;
class FooBar extends CKEditor5PluginDefault implements CKEditor5PluginConfigurableInterface {
  use CKEditor5PluginConfigurableTrait;
  public function defaultConfiguration() { return ['foo' => FALSE]; }
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) { return []; }
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {}
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {}
}
PHP
,
                    ],
                ],
            ],
        ],
    ]);
    (yield 'valid condition: requiresConfiguration' => [
        <<<YAML
ckeditor5_invalid_plugin_foo_bar:
  ckeditor5:
    plugins: {}
  drupal:
    class: Drupal\\ckeditor5_invalid_plugin\\Plugin\\CKEditor5Plugin\\FooBar
    label: "Foo bar"
    elements: false
    conditions:
      requiresConfiguration:
        foo: true
YAML
,
        NULL,
        [
            'config' => [
                'schema' => [
                    'ckeditor5_invalid_plugin.schema.yml' => <<<YAML
ckeditor5.plugin.ckeditor5_invalid_plugin_foo_bar:
  type: mapping
  label: 'Foo Bar'
  mapping:
    foo:
      type: boolean
      label: 'Foo'
YAML
,
                ],
            ],
            'src' => [
                'Plugin' => [
                    'CKEditor5Plugin' => [
                        'FooBar.php' => <<<'PHP'
<?php
namespace Drupal\ckeditor5_invalid_plugin\Plugin\CKEditor5Plugin;
use Drupal\ckeditor5\Plugin\CKEditor5PluginDefault;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableInterface;
use Drupal\ckeditor5\Plugin\CKEditor5PluginConfigurableTrait;
use Drupal\Core\Form\FormStateInterface;
class FooBar extends CKEditor5PluginDefault implements CKEditor5PluginConfigurableInterface {
  use CKEditor5PluginConfigurableTrait;
  public function defaultConfiguration() { return ['foo' => FALSE]; }
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) { return []; }
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {}
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {}
}
PHP
,
                    ],
                ],
            ],
        ],
    ]);
}

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