public function PluginDiscoveryTest::testPluginDiscovery in Block Style Plugins 8.2
Same name and namespace in other branches
- 8 tests/src/Kernel/PluginDiscoveryTest.php \Drupal\Tests\block_style_plugins\Kernel\PluginDiscoveryTest::testPluginDiscovery()
Make sure that plugins are discovered.
File
- tests/
src/ Kernel/ PluginDiscoveryTest.php, line 22
Class
- PluginDiscoveryTest
- Test of the Block Style Plugins discovery integration.
Namespace
Drupal\Tests\block_style_plugins\KernelCode
public function testPluginDiscovery() {
$plugin_manager = $this->container
->get('plugin.manager.block_style.processor');
$style_plugins = $plugin_manager
->getDefinitions();
$expected = [
'simple_class' => [
'exclude' => [],
'include' => [],
'id' => 'simple_class',
'label' => 'Simple Class',
'class' => 'Drupal\\block_style_plugins_test\\Plugin\\BlockStyle\\SimpleClass',
'provider' => 'block_style_plugins_test',
'disable_auto_classes' => FALSE,
'layout_builder_embed_form' => FALSE,
'type' => 'block',
],
'dropdown_with_include' => [
'exclude' => [],
'include' => [
'system_powered_by_block',
'basic',
],
'id' => 'dropdown_with_include',
'label' => 'Dropdown with Include',
'class' => 'Drupal\\block_style_plugins_test\\Plugin\\BlockStyle\\DropdownWithInclude',
'provider' => 'block_style_plugins_test',
'disable_auto_classes' => FALSE,
'layout_builder_embed_form' => FALSE,
'type' => 'block',
],
'checkbox_with_exclude' => [
'exclude' => [
'system_powered_by_block',
'basic',
],
'id' => 'checkbox_with_exclude',
'label' => 'Checkbox with Exclude',
'class' => 'Drupal\\block_style_plugins_test\\Plugin\\BlockStyle\\CheckboxWithExclude',
'provider' => 'block_style_plugins_test',
],
'form_fields_created_with_yaml' => [
'include' => [
'system_powered_by_block',
],
'id' => 'form_fields_created_with_yaml',
'label' => 'Styles Created by Yaml',
'class' => 'Drupal\\block_style_plugins\\Plugin\\BlockStyle',
'provider' => 'block_style_plugins_test',
'form' => [
'test_field' => [
'#type' => 'textfield',
'#title' => 'Title Created by Yaml',
'#default_value' => 'text goes here',
],
'second_field' => [
'#type' => 'select',
'#title' => 'Choose a style',
'#options' => [
'style-1' => 'Style 1',
'style-2' => 'Style 2',
],
],
],
],
'template_set_with_yaml' => [
'id' => 'template_set_with_yaml',
'label' => 'Template Set by Yaml',
'class' => 'Drupal\\block_style_plugins\\Plugin\\BlockStyle',
'provider' => 'block_style_plugins_test',
'template' => 'block__test_custom',
'form' => [
'test_field' => [
'#type' => 'textfield',
'#title' => 'Template Title',
],
],
],
'embed_on_layout_builder' => [
'include' => [
'system_breadcrumb_block',
],
'id' => 'embed_on_layout_builder',
'label' => 'Embed on Layout Builder Form',
'class' => 'Drupal\\block_style_plugins\\Plugin\\BlockStyle',
'provider' => 'block_style_plugins_test',
'form' => [
'test_embedded_field' => [
'#type' => 'textfield',
'#title' => 'Embed on Layout Builder Form',
'#default_value' => 'text goes here',
],
],
'layout_builder_embed_form' => TRUE,
],
'section_class' => [
'id' => 'section_class',
'label' => 'Add a custom class to a Layout Builder section',
'class' => 'Drupal\\block_style_plugins\\Plugin\\BlockStyle',
'provider' => 'block_style_plugins_test',
'form' => [
'test_section_field' => [
'#type' => 'textfield',
'#title' => 'Add class on section',
'#default_value' => 'class goes here',
],
],
'type' => 'section',
],
];
$this
->assertEquals($expected, $style_plugins);
}