Loading tests/src/Kernel/Plugin/migrate/process/EntityLookupTest.php +38 −0 Changes for tests/src/Kernel/Plugin/migrate/process/EntityLookupTest.php: 38 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -19,6 +19,13 @@ class EntityLookupTest extends KernelTestBase { use UserCreationTrait; /** * The migrate executable mock object. * * @var \Drupal\migrate\MigrateExecutable|\PHPUnit\Framework\MockObject\MockObject */ protected $migrateExecutable; /** * {@inheritdoc} */ Loading @@ -27,6 +34,7 @@ class EntityLookupTest extends KernelTestBase { 'migrate', 'user', 'system', 'filter', ]; /** Loading @@ -36,6 +44,11 @@ class EntityLookupTest extends KernelTestBase { parent::setUp(); $this->installSchema('system', ['sequences']); $this->installEntitySchema('user'); $this->installConfig(['filter']); $this->migrateExecutable = $this->getMockBuilder('Drupal\migrate\MigrateExecutable') ->disableOriginalConstructor() ->getMock(); } /** Loading Loading @@ -73,4 +86,29 @@ class EntityLookupTest extends KernelTestBase { $this->assertNull($value); } /** * Tests a lookup of config entity. */ public function testConfigEntityLookup(): void { $migration = \Drupal::service('plugin.manager.migration') ->createStubMigration([ 'id' => 'test', 'source' => [], 'process' => [], 'destination' => [ 'plugin' => 'entity:node', ], ]); $configuration = [ 'entity_type' => 'filter_format', 'value_key' => 'name', ]; $plugin = \Drupal::service('plugin.manager.migrate.process') ->createInstance('entity_lookup', $configuration, $migration); $value = $plugin->transform('Plain text', $this->migrateExecutable, new Row(), 'destination_property'); $this->assertEquals('plain_text', $value); } } Loading
tests/src/Kernel/Plugin/migrate/process/EntityLookupTest.php +38 −0 Changes for tests/src/Kernel/Plugin/migrate/process/EntityLookupTest.php: 38 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -19,6 +19,13 @@ class EntityLookupTest extends KernelTestBase { use UserCreationTrait; /** * The migrate executable mock object. * * @var \Drupal\migrate\MigrateExecutable|\PHPUnit\Framework\MockObject\MockObject */ protected $migrateExecutable; /** * {@inheritdoc} */ Loading @@ -27,6 +34,7 @@ class EntityLookupTest extends KernelTestBase { 'migrate', 'user', 'system', 'filter', ]; /** Loading @@ -36,6 +44,11 @@ class EntityLookupTest extends KernelTestBase { parent::setUp(); $this->installSchema('system', ['sequences']); $this->installEntitySchema('user'); $this->installConfig(['filter']); $this->migrateExecutable = $this->getMockBuilder('Drupal\migrate\MigrateExecutable') ->disableOriginalConstructor() ->getMock(); } /** Loading Loading @@ -73,4 +86,29 @@ class EntityLookupTest extends KernelTestBase { $this->assertNull($value); } /** * Tests a lookup of config entity. */ public function testConfigEntityLookup(): void { $migration = \Drupal::service('plugin.manager.migration') ->createStubMigration([ 'id' => 'test', 'source' => [], 'process' => [], 'destination' => [ 'plugin' => 'entity:node', ], ]); $configuration = [ 'entity_type' => 'filter_format', 'value_key' => 'name', ]; $plugin = \Drupal::service('plugin.manager.migrate.process') ->createInstance('entity_lookup', $configuration, $migration); $value = $plugin->transform('Plain text', $this->migrateExecutable, new Row(), 'destination_property'); $this->assertEquals('plain_text', $value); } }