BlockRegionTest.php in Drupal 8
File
core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockRegionTest.php
View source
<?php
namespace Drupal\Tests\block\Unit\Plugin\migrate\process;
use Drupal\block\Plugin\migrate\process\BlockRegion;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
use Drupal\Tests\UnitTestCase;
class BlockRegionTest extends UnitTestCase {
protected function transform(array $value, Row $row = NULL) {
$executable = $this
->prophesize(MigrateExecutableInterface::class)
->reveal();
if (empty($row)) {
$row = $this
->prophesize(Row::class)
->reveal();
}
$configuration = [
'map' => [
'bartik' => [
'bartik' => [
'triptych_first' => 'triptych_first',
'triptych_middle' => 'triptych_second',
'triptych_last' => 'triptych_third',
],
],
],
'default_value' => 'content',
];
$plugin = new BlockRegion($configuration, 'block_region', [], $configuration['map']['bartik']['bartik']);
return $plugin
->transform($value, $executable, $row, 'foo');
}
public function testTransformSameThemeRegionExists() {
$this
->assertSame('triptych_second', $this
->transform([
'bartik',
'bartik',
'triptych_middle',
]));
}
public function testTransformSameThemeRegionNotExists() {
$this
->assertSame('content', $this
->transform([
'bartik',
'bartik',
'footer',
]));
}
}