You are here

protected function BlockStyleTest::setUp in Block Style Plugins 8

Same name and namespace in other branches
  1. 8.2 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 50

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() {
  parent::setUp();

  // Stub the Iconset Finder Service.
  $this->entityRepository = $this
    ->prophesize(EntityRepositoryInterface::CLASS);

  // 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->entityRepository
    ->reveal(), $this->entityTypeManager
    ->reveal());

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