3 namespace Drupal\Tests\block\Unit\Plugin\migrate\process;
5 use Drupal\block\Plugin\migrate\process\BlockRegion;
6 use Drupal\migrate\MigrateExecutableInterface;
7 use Drupal\migrate\Row;
8 use Drupal\Tests\UnitTestCase;
11 * @coversDefaultClass \Drupal\block\Plugin\migrate\process\BlockRegion
14 class BlockRegionTest extends UnitTestCase {
17 * Transforms a value through the block_region plugin.
20 * The value to transform.
21 * @param \Drupal\migrate\Row|null $row
22 * (optional) The mocked row.
24 * @return array|string
25 * The transformed value.
27 protected function transform(array $value, Row $row = NULL) {
28 $executable = $this->prophesize(MigrateExecutableInterface::class)->reveal();
30 $row = $this->prophesize(Row::class)->reveal();
37 'triptych_first' => 'triptych_first',
38 'triptych_middle' => 'triptych_second',
39 'triptych_last' => 'triptych_third',
43 'default_value' => 'content',
46 $plugin = new BlockRegion($configuration, 'block_region', [], $configuration['map']['bartik']['bartik']);
47 return $plugin->transform($value, $executable, $row, 'foo');
51 * If the source and destination themes are identical, the region should only
52 * be passed through if it actually exists in the destination theme.
56 public function testTransformSameThemeRegionExists() {
57 $this->assertSame('triptych_second', $this->transform(['bartik', 'bartik', 'triptych_middle']));
61 * If the source and destination themes are identical, the region should be
62 * changed to 'content' if it doesn't exist in the destination theme.
66 public function testTransformSameThemeRegionNotExists() {
67 $this->assertSame('content', $this->transform(['bartik', 'bartik', 'footer']));