Loading src/Plugin/migrate/process/EntityValue.php +1 −1 Changes for src/Plugin/migrate/process/EntityValue.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -151,7 +151,7 @@ class EntityValue extends ProcessPluginBase implements ContainerFactoryPluginInt } else { if ($langcode) { throw new \InvalidArgumentException('Langcode can only be used with content entities currently.'); throw new MigrateException('Langcode can only be used with content entities currently.'); } } try { Loading tests/src/Kernel/Plugin/migrate/process/EntityValueTest.php +28 −1 Changes for tests/src/Kernel/Plugin/migrate/process/EntityValueTest.php: 28 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -3,10 +3,12 @@ namespace Drupal\Tests\migrate_plus\Kernel\Plugin\migrate\process; use Drupal\KernelTests\KernelTestBase; use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; use Drupal\node\Entity\Node; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\node\Entity\NodeType; /** * Tests the entity_value plugin. Loading Loading @@ -150,6 +152,31 @@ class EntityValueTest extends KernelTestBase { $this->assertTrue($this->plugin->multiple()); } /** * Test the EntityLoad plugin failure. * * @covers ::transform */ public function testEntityValueLangException() { $config_entity = NodeType::create(['type' => 'page', 'name' => 'page']); $config_entity->save(); $this->plugin = \Drupal::service('plugin.manager.migrate.process') ->createInstance('entity_value', [ 'entity_type' => 'node_type', 'langcode' => 'es', 'field_name' => 'type', ]); $executable = $this->prophesize(MigrateExecutableInterface::class) ->reveal(); $row = new Row(); // Ensure that the entity is returned if it really exists. $this->expectException(MigrateException::class); $this->expectExceptionMessage('Langcode can only be used with content entities currently.'); $this->plugin->transform([$config_entity->id()], $executable, $row, 'dummmy'); } /** * Test the EntityLoad plugin throwing. * Loading @@ -161,7 +188,7 @@ class EntityValueTest extends KernelTestBase { */ public function testEntityValueConfig($config) { $this->expectException(\InvalidArgumentException::class); $plugin = \Drupal::service('plugin.manager.migrate.process') \Drupal::service('plugin.manager.migrate.process') ->createInstance('entity_value', $config); } Loading Loading
src/Plugin/migrate/process/EntityValue.php +1 −1 Changes for src/Plugin/migrate/process/EntityValue.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -151,7 +151,7 @@ class EntityValue extends ProcessPluginBase implements ContainerFactoryPluginInt } else { if ($langcode) { throw new \InvalidArgumentException('Langcode can only be used with content entities currently.'); throw new MigrateException('Langcode can only be used with content entities currently.'); } } try { Loading
tests/src/Kernel/Plugin/migrate/process/EntityValueTest.php +28 −1 Changes for tests/src/Kernel/Plugin/migrate/process/EntityValueTest.php: 28 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -3,10 +3,12 @@ namespace Drupal\Tests\migrate_plus\Kernel\Plugin\migrate\process; use Drupal\KernelTests\KernelTestBase; use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Row; use Drupal\node\Entity\Node; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\node\Entity\NodeType; /** * Tests the entity_value plugin. Loading Loading @@ -150,6 +152,31 @@ class EntityValueTest extends KernelTestBase { $this->assertTrue($this->plugin->multiple()); } /** * Test the EntityLoad plugin failure. * * @covers ::transform */ public function testEntityValueLangException() { $config_entity = NodeType::create(['type' => 'page', 'name' => 'page']); $config_entity->save(); $this->plugin = \Drupal::service('plugin.manager.migrate.process') ->createInstance('entity_value', [ 'entity_type' => 'node_type', 'langcode' => 'es', 'field_name' => 'type', ]); $executable = $this->prophesize(MigrateExecutableInterface::class) ->reveal(); $row = new Row(); // Ensure that the entity is returned if it really exists. $this->expectException(MigrateException::class); $this->expectExceptionMessage('Langcode can only be used with content entities currently.'); $this->plugin->transform([$config_entity->id()], $executable, $row, 'dummmy'); } /** * Test the EntityLoad plugin throwing. * Loading @@ -161,7 +188,7 @@ class EntityValueTest extends KernelTestBase { */ public function testEntityValueConfig($config) { $this->expectException(\InvalidArgumentException::class); $plugin = \Drupal::service('plugin.manager.migrate.process') \Drupal::service('plugin.manager.migrate.process') ->createInstance('entity_value', $config); } Loading