You are here

protected function BlockStyleTest::setUp 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::setUp()

Create the setup for constants and configFactory stub.

Overrides UnitTestCase::setUp

File

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

Class

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

Namespace

Drupal\Tests\block_style_plugins\Unit\Plugin

Code

protected function setUp() : void {
  parent::setUp();

  // Stub the Entity Type Manager.
  $this->entityTypeManager = $this
    ->prophesize(EntityTypeManagerInterface::class);

  // Form state double.
  $this->formState = $this
    ->prophesize(FormStateInterface::class);
  $configuration = [];
  $plugin_id = 'block_style_plugins';
  $plugin_definition = [
    'provider' => 'block_style_plugins',
    'form' => [
      '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',
      ],
    ],
  ];
  $this->plugin = new BlockStyle($configuration, $plugin_id, $plugin_definition, $this->entityTypeManager
    ->reveal());

  // Create a translation stub for the t() method.
  $translator = $this
    ->getStringTranslationStub();
  $this->plugin
    ->setStringTranslation($translator);
}