You are here

public function BlockStyleTest::testBuildConfigurationForm in Block Style Plugins 8.2

Same name and namespace in other branches
  1. 8 tests/src/Unit/Plugin/BlockStyleTest.php \Drupal\Tests\block_style_plugins\Unit\Plugin\BlockStyleTest::testBuildConfigurationForm()

Tests the buildConfigurationForm method.

See also

::buildConfigurationForm()

File

tests/src/Unit/Plugin/BlockStyleTest.php, line 105

Class

BlockStyleTest
@coversDefaultClass \Drupal\block_style_plugins\Plugin\BlockStyle @group block_style_plugins

Namespace

Drupal\Tests\block_style_plugins\Unit\Plugin

Code

public function testBuildConfigurationForm() {
  $expected = [
    'test_field' => [
      '#type' => 'textfield',
      '#title' => 'this is a title',
      '#default_value' => 'default text',
    ],
    'second_field' => [
      '#type' => 'checkbox',
      '#title' => 'Checkbox title',
      '#default_value' => 1,
    ],
    'third_field' => [
      '#type' => 'textfield',
      '#title' => 'Third Box',
      '#default_value' => 'user set value',
    ],
  ];

  // Use reflection to alter the protected $this->plugin->styles.
  $reflectionObject = new \ReflectionObject($this->plugin);
  $property = $reflectionObject
    ->getProperty('configuration');
  $property
    ->setAccessible(TRUE);
  $property
    ->setValue($this->plugin, [
    'third_field' => 'user set value',
  ]);
  $form = [];
  $return = $this->plugin
    ->buildConfigurationForm($form, $this->formState
    ->reveal());
  $this
    ->assertEquals($expected, $return);
}