function BlockSettingsTest::testTransform

Same name and namespace in other branches
  1. 9 core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockSettingsTest.php \Drupal\Tests\block\Unit\Plugin\migrate\process\BlockSettingsTest::testTransform()
  2. 10 core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockSettingsTest.php \Drupal\Tests\block\Unit\Plugin\migrate\process\BlockSettingsTest::testTransform()

Tests the blocks settings process plugin.

@covers ::transform

@dataProvider providerTestTransform

Parameters

array $value: The source value for the plugin.

array $expected: The expected result.

File

core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockSettingsTest.php, line 33

Class

BlockSettingsTest
@coversDefaultClass \Drupal\block\Plugin\migrate\process\BlockSettings[[api-linebreak]] @group block

Namespace

Drupal\Tests\block\Unit\Plugin\migrate\process

Code

public function testTransform($value, $expected) : void {
  $executable = $this->prophesize(MigrateExecutableInterface::class)
    ->reveal();
  $row = $this->prophesize(Row::class)
    ->reveal();
  // The block plugin should be asked to provide default configuration.
  $expected['default'] = 'value';
  $mock_plugin = $this->prophesize(BlockPluginInterface::class);
  $mock_plugin->getConfiguration()
    ->shouldBeCalled()
    ->willReturn($expected);
  $block_manager = $this->prophesize(BlockManagerInterface::class);
  $block_manager->createInstance($value[0], Argument::type('array'))
    ->shouldBeCalled()
    ->willReturn($mock_plugin->reveal());
  $plugin = new BlockSettings([], 'block_settings', [], $block_manager->reveal());
  $actual = $plugin->transform($value, $executable, $row, 'foo');
  $this->assertSame($expected, $actual);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.