diff -u b/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php /dev/null --- b/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php +++ /dev/null @@ -1,48 +0,0 @@ - 'link', - 'plain' => 'link', - 'absolute' => 'link', - 'title_plain' => 'link', - 'url' => 'link', - 'short' => 'link', - 'label' => 'link', - 'separate' => 'link_separate', - ]; - } - - /** - * {@inheritdoc} - */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { - $process = [ - 'plugin' => 'd6_field_link', - 'source' => $field_name, - ]; - $migration->mergeProcessOfProperty($field_name, $process); - } - -} diff -u b/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php b/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php --- b/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php @@ -12,0 +13,48 @@ + * "link_field" = "link" + * } + * ) + * + * This plugin provides the exact same functionality as the Drupal 6 "link" + * plugin with the exception that the plugin ID "link_field" is used in the + * field type map. + */ +class LinkField extends D6LinkField { + + /** + * {@inheritdoc} + */ + public function getFieldWidgetMap() { + // By default, use the plugin ID for the widget types. + return ['link_field' => 'link_default']; + } + + /** + * {@inheritdoc} + */ + public function processFieldInstance(MigrationInterface $migration) { + $process = [ + 'plugin' => 'static_map', + 'source' => 'instance_settings/title', + 'bypass' => TRUE, + 'map' => [ + 'disabled' => DRUPAL_DISABLED, + 'optional' => DRUPAL_OPTIONAL, + 'required' => DRUPAL_REQUIRED, + ], + ]; + $migration->mergeProcessOfProperty('settings/title', $process); + } + +} +getMock('\Drupal\migrate\Plugin\MigrationInterface')); - $transformed = $link_plugin->transform([ - 'url' => $url, - 'title' => '', - 'attributes' => serialize([]), - ], $this->getMock('\Drupal\migrate\MigrateExecutableInterface'), $this->getMockBuilder('\Drupal\migrate\Row')->disableOriginalConstructor()->getMock(), NULL); - $this->assertEquals($expected, $transformed['uri']); - } - - /** - * Data provider for testCanonicalizeUri. - */ - public function canonicalizeUriDataProvider() { - return [ - 'Simple front-page' => [ - '', - 'internal:/', - ], - 'Front page with query' => [ - '?query=1', - 'internal:/?query=1', - ], - 'No leading forward slash' => [ - 'node/10', - 'internal:/node/10', - ], - 'Leading forward slash' => [ - '/node/10', - 'internal:/node/10', - ], - 'Existing scheme' => [ - 'scheme:test', - 'scheme:test', - ], - ]; - } - -} diff -u b/core/modules/migrate_drupal/tests/src/Kernel/MigrateFieldPluginManagerTest.php b/core/modules/migrate_drupal/tests/src/Kernel/MigrateFieldPluginManagerTest.php --- b/core/modules/migrate_drupal/tests/src/Kernel/MigrateFieldPluginManagerTest.php +++ b/core/modules/migrate_drupal/tests/src/Kernel/MigrateFieldPluginManagerTest.php @@ -12,10 +12,11 @@ */ class MigrateFieldPluginManagerTest extends MigrateDrupalTestBase { + public static $modules = ['system', 'user', 'field', 'migrate_drupal', 'options', 'file', 'text', 'migrate_field_plugin_manager_test']; + /** * {@inheritdoc} */ - public static $modules = array('system', 'user', 'field', 'migrate_drupal', 'options', 'file', 'text', 'migrate_field_plugin_manager_test'); /** * Tests that the correct MigrateField plugins are used. only in patch2: unchanged: --- a/core/modules/link/src/Plugin/migrate/cckfield/d7/LinkField.php +++ /dev/null @@ -1,48 +0,0 @@ - 'link_default']; - } - - /** - * {@inheritdoc} - */ - public function processFieldInstance(MigrationInterface $migration) { - $process = [ - 'plugin' => 'static_map', - 'source' => 'instance_settings/title', - 'bypass' => TRUE, - 'map' => [ - 'disabled' => DRUPAL_DISABLED, - 'optional' => DRUPAL_OPTIONAL, - 'required' => DRUPAL_REQUIRED, - ], - ]; - $migration->mergeProcessOfProperty('settings/title', $process); - } - -} only in patch2: unchanged: --- /dev/null +++ b/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php @@ -0,0 +1,48 @@ + 'link', + 'plain' => 'link', + 'absolute' => 'link', + 'title_plain' => 'link', + 'url' => 'link', + 'short' => 'link', + 'label' => 'link', + 'separate' => 'link_separate', + ]; + } + + /** + * {@inheritdoc} + */ + public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + $process = [ + 'plugin' => 'd6_field_link', + 'source' => $field_name, + ]; + $migration->mergeProcessOfProperty($field_name, $process); + } + +} only in patch2: unchanged: --- /dev/null +++ b/core/modules/link/tests/src/Unit/Plugin/migrate/process/d6/FieldLinkTest.php @@ -0,0 +1,56 @@ +getMock('\Drupal\migrate\Plugin\MigrationInterface')); + $transformed = $link_plugin->transform([ + 'url' => $url, + 'title' => '', + 'attributes' => serialize([]), + ], $this->getMock('\Drupal\migrate\MigrateExecutableInterface'), $this->getMockBuilder('\Drupal\migrate\Row')->disableOriginalConstructor()->getMock(), NULL); + $this->assertEquals($expected, $transformed['uri']); + } + + /** + * Data provider for testCanonicalizeUri. + */ + public function canonicalizeUriDataProvider() { + return [ + 'Simple front-page' => [ + '', + 'internal:/', + ], + 'Front page with query' => [ + '?query=1', + 'internal:/?query=1', + ], + 'No leading forward slash' => [ + 'node/10', + 'internal:/node/10', + ], + 'Leading forward slash' => [ + '/node/10', + 'internal:/node/10', + ], + 'Existing scheme' => [ + 'scheme:test', + 'scheme:test', + ], + ]; + } + +} only in patch2: unchanged: --- /dev/null +++ b/core/modules/migrate/tests/src/Unit/process/SkipRowIfNotSetTest.php @@ -0,0 +1,45 @@ + 'some_key', + ]; + $process = new SkipRowIfNotSet($configuration, 'skip_row_if_not_set', []); + $this->setExpectedException(MigrateSkipRowException::class); + $process->transform('', $this->migrateExecutable, $this->row, 'destinationproperty'); + } + + /** + * Tests that a skip row exception with a message is raised. + * + * @covers ::transform + */ + public function testRowSkipWithMessage() { + $configuration = [ + 'index' => 'some_key', + 'message' => "The 'some_key' key is not set", + ]; + $process = new SkipRowIfNotSet($configuration, 'skip_row_if_not_set', []); + $this->setExpectedException(MigrateSkipRowException::class, "The 'some_key' key is not set"); + $process->transform('', $this->migrateExecutable, $this->row, 'destinationproperty'); + } + +}