protected function SectionFormAlterTest::setUp in Block Style Plugins 8.2
Create the setup for constants and configFactory stub.
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ SectionFormAlterTest.php, line 67
Class
- SectionFormAlterTest
- @coversDefaultClass \Drupal\block_style_plugins\SectionFormAlter @group block_style_plugins
Namespace
Drupal\Tests\block_style_plugins\UnitCode
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);
// Block plugin.
$this->section = $this
->prophesize(Section::class);
$this->section
->getLayoutId()
->willReturn('layout_onecol');
$configuration = [];
$plugin_id = 'block_style_plugins';
$plugin_definition['provider'] = 'block_style_plugins';
$plugin_definition['type'] = 'section';
$this->plugin = new MockBlockStyleBase($configuration, $plugin_id, $plugin_definition, $this->entityTypeManager
->reveal());
// Stub the Block Style Manager service.
$this->blockStyleManager = $this
->prophesize(BlockStyleManager::class);
$this->blockStyleManager
->getSectionDefinitions()
->willReturn([
$plugin_id => $plugin_definition,
]);
$this->blockStyleManager
->createInstance('block_style_plugins')
->willReturn($this->plugin);
$this->classInstance = new SectionFormAlter($this->blockStyleManager
->reveal());
// Create a translation stub for the t() method.
$translator = $this
->getStringTranslationStub();
$this->classInstance
->setStringTranslation($translator);
}