You are here

public function LayoutClassesPluginDefinitionFormatTest::testDefinitionFormGeneration in Layout Section Classes 8

Test the plugin definition parsing into a form.

@covers ::buildConfigurationForm @dataProvider definitionFormGenerationTestCases

File

tests/src/Unit/LayoutClassesPluginDefinitionFormatTest.php, line 47

Class

LayoutClassesPluginDefinitionFormatTest
@coversDefaultClass \Drupal\layout_section_classes\ClassyLayout @group layout_section_classes

Namespace

Drupal\Tests\layout_section_classes\Unit

Code

public function testDefinitionFormGeneration($definition, $configuration, $expected_form) {
  $plugin = new ClassyLayout($configuration, 'foo_plugin', $definition);
  $plugin
    ->setStringTranslation($this
    ->prophesize(TranslationManager::class)
    ->reveal());
  $form = $plugin
    ->buildConfigurationForm([], new FormState());
  array_walk_recursive($form, function (&$value) {
    if ($value instanceof TranslatableMarkup) {
      $value = $value
        ->getUntranslatedString();
    }
  });
  unset($form['label']);
  $this
    ->assertEquals($expected_form, $form);
}