LegacyBlockPluginIdTest.php in Drupal 8
File
core/modules/block/tests/src/Unit/Plugin/migrate/process/LegacyBlockPluginIdTest.php
View source
<?php
namespace Drupal\Tests\block\Unit\Plugin\migrate\process;
use Drupal\block\Plugin\migrate\process\BlockPluginId;
use Drupal\block_content\Entity\BlockContent;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\migrate\MigrateLookupInterface;
use Drupal\migrate\Plugin\MigrateProcessInterface;
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
class LegacyBlockPluginIdTest extends MigrateProcessTestCase {
public function setUp() {
parent::setUp();
$migrate_lookup = $this
->prophesize(MigrateLookupInterface::class);
$container = new ContainerBuilder();
$container
->set('migrate.lookup', $migrate_lookup
->reveal());
\Drupal::setContainer($container);
}
public function testConstruct() {
$process_plugin = $this
->prophesize(MigrateProcessInterface::class);
$process_plugin
->transform(1, $this->migrateExecutable, $this->row, 'destination_property')
->willReturn(3);
$block = $this
->prophesize(BlockContent::class);
$block
->uuid()
->willReturn('123456789');
$storage = $this
->prophesize(EntityStorageInterface::class);
$storage
->load(3)
->willReturn($block
->reveal());
$plugin = new BlockPluginId([], '', [], $storage
->reveal(), $process_plugin
->reveal());
$this
->assertSame('block_content:123456789', $plugin
->transform([
'block',
1,
], $this->migrateExecutable, $this->row, 'destination_property'));
}
}