diff --git a/core/lib/Drupal/Core/Field/Plugin/migrate/field/Email.php b/core/lib/Drupal/Core/Field/Plugin/migrate/field/Email.php index 11226fa649bd2adfdb22ecec24cec89b74e333e9..f56a6f844b0ff2e4651ad316d74d38268cc6520d 100644 --- a/core/lib/Drupal/Core/Field/Plugin/migrate/field/Email.php +++ b/core/lib/Drupal/Core/Field/Plugin/migrate/field/Email.php @@ -46,7 +46,7 @@ public function getFieldFormatterMap() { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'sub_process', 'source' => $field_name, diff --git a/core/modules/comment/src/Plugin/migrate/D7Comment.php b/core/modules/comment/src/Plugin/migrate/D7Comment.php index 77a7dca61fed65bcd30ec5ca470bd3387850ecbd..9a509f4b23135ffb1a851468626abe87ee8acc42 100644 --- a/core/modules/comment/src/Plugin/migrate/D7Comment.php +++ b/core/modules/comment/src/Plugin/migrate/D7Comment.php @@ -35,7 +35,7 @@ public function getProcess() { $this->fieldPluginCache[$field_type] = $this->fieldPluginManager->createInstance($field_type, [], $this); } $info = $row->getSource(); - $this->fieldPluginCache[$field_type]->processFieldValues($this, $field_name, $info); + $this->fieldPluginCache[$field_type]->defineValueProcessPipeline($this, $field_name, $info); } else { $this->setProcessOfProperty($field_name, $field_name); diff --git a/core/modules/datetime/src/Plugin/migrate/field/DateField.php b/core/modules/datetime/src/Plugin/migrate/field/DateField.php index 446076232f73a7f31b4277f752eeceb9cb3a26b0..876c9da09b636bb4e30f91830aa5878d4150bcee 100644 --- a/core/modules/datetime/src/Plugin/migrate/field/DateField.php +++ b/core/modules/datetime/src/Plugin/migrate/field/DateField.php @@ -44,7 +44,7 @@ public function getFieldWidgetMap() { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { switch ($data['type']) { case 'date': $from_format = 'Y-m-d\TH:i:s'; diff --git a/core/modules/datetime/src/Plugin/migrate/field/d6/DateField.php b/core/modules/datetime/src/Plugin/migrate/field/d6/DateField.php index 4e7cd881d30cdffee764b105dc9db8b630e47ab8..7ea04b9de6a3f090649351d9d531d040e066e912 100644 --- a/core/modules/datetime/src/Plugin/migrate/field/d6/DateField.php +++ b/core/modules/datetime/src/Plugin/migrate/field/d6/DateField.php @@ -40,7 +40,7 @@ public function getFieldWidgetMap() { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { switch ($data['type']) { case 'date': $from_format = 'Y-m-d\TH:i:s'; diff --git a/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldLegacyTest.php b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldLegacyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..fb51066196c12a55c7f17adec0b03bd04564e93d --- /dev/null +++ b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldLegacyTest.php @@ -0,0 +1,18 @@ +migration = $this->prophesize('Drupal\migrate\Plugin\MigrationInterface')->reveal(); - $this->plugin = new DateField([], '', []); + public function testUnknownDateType($method = 'defineValueProcessPipeline') { + $migration = $this->prophesize('Drupal\migrate\Plugin\MigrationInterface')->reveal(); + $plugin = new DateField([], '', []); $this->setExpectedException(MigrateException::class, "Field field_date of type 'timestamp' is an unknown date field type."); - $this->plugin->processFieldValues($this->migration, 'field_date', ['type' => 'timestamp']); + $plugin->$method($migration, 'field_date', ['type' => 'timestamp']); } } diff --git a/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/d6/DateFieldLegacyTest.php b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/d6/DateFieldLegacyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..00e6e8c6ea679a906f80f0806fcab023be6b3ab1 --- /dev/null +++ b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/d6/DateFieldLegacyTest.php @@ -0,0 +1,18 @@ +migration = $this->prophesize(MigrationInterface::class)->reveal(); + } /** * Tests an Exception is thrown when the field type is not a known date type. * * @expectedDeprecation DateField is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\datetime\Plugin\migrate\field\DateField instead. */ - public function testUnknownDateType() { - $this->migration = $this->prophesize('Drupal\migrate\Plugin\MigrationInterface')->reveal(); - $this->plugin = new DateField([], '', []); + public function testUnknownDateType($method = 'defineValueProcessPipeline') { + $plugin = new DateField([], '', []); $this->setExpectedException(MigrateException::class, "Field field_date of type 'timestamp' is an unknown date field type."); - $this->plugin->processFieldValues($this->migration, 'field_date', ['type' => 'timestamp']); + $plugin->$method($this->migration, 'field_date', ['type' => 'timestamp']); } } diff --git a/core/modules/field/migrations/d6_field.yml b/core/modules/field/migrations/d6_field.yml index ab8313ace7c558b04aacfe2514580849da88aaf9..e25d7ae0c236aebf1704d24e541f1caaf19b7547 100644 --- a/core/modules/field/migrations/d6_field.yml +++ b/core/modules/field/migrations/d6_field.yml @@ -4,7 +4,7 @@ migration_tags: - Drupal 6 - Configuration class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processField +field_plugin_method: alterFieldMigration source: plugin: d6_field constants: diff --git a/core/modules/field/migrations/d6_field_formatter_settings.yml b/core/modules/field/migrations/d6_field_formatter_settings.yml index 772f36400b0d98cfdda8c507bd3cf217275b9070..23ea2bd0e0e6f442ee4d16358733ed44c9346ec9 100644 --- a/core/modules/field/migrations/d6_field_formatter_settings.yml +++ b/core/modules/field/migrations/d6_field_formatter_settings.yml @@ -4,7 +4,7 @@ migration_tags: - Drupal 6 - Configuration class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processFieldFormatter +field_plugin_method: alterFieldFormatterMigration source: plugin: d6_field_instance_per_view_mode constants: diff --git a/core/modules/field/migrations/d6_field_instance.yml b/core/modules/field/migrations/d6_field_instance.yml index 7c2305559001f4722bedd5808a9c1a56443b8d7f..45941165a3d848ddab0c79e8ded3d988851454b2 100644 --- a/core/modules/field/migrations/d6_field_instance.yml +++ b/core/modules/field/migrations/d6_field_instance.yml @@ -4,7 +4,7 @@ migration_tags: - Drupal 6 - Configuration class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processFieldInstance +field_plugin_method: alterFieldInstanceMigration source: plugin: d6_field_instance constants: diff --git a/core/modules/field/migrations/d6_field_instance_widget_settings.yml b/core/modules/field/migrations/d6_field_instance_widget_settings.yml index 4c2f4fd8e3fc319de45cc09278f9ae76fb6a86ae..9faac2f36bd2add4b73b182206b308a37fcaec5b 100644 --- a/core/modules/field/migrations/d6_field_instance_widget_settings.yml +++ b/core/modules/field/migrations/d6_field_instance_widget_settings.yml @@ -4,7 +4,7 @@ migration_tags: - Drupal 6 - Configuration class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processFieldWidget +field_plugin_method: alterFieldWidgetMigration source: plugin: d6_field_instance_per_form_display constants: diff --git a/core/modules/field/migrations/d7_field.yml b/core/modules/field/migrations/d7_field.yml index aba5c9f917abc2afe15ecd44c61e560ec2b0cc67..96bf5caac23d1fc0948b0de98da5937ce02d8643 100644 --- a/core/modules/field/migrations/d7_field.yml +++ b/core/modules/field/migrations/d7_field.yml @@ -4,7 +4,7 @@ migration_tags: - Drupal 7 - Configuration class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processField +field_plugin_method: alterFieldMigration source: plugin: d7_field constants: diff --git a/core/modules/field/migrations/d7_field_formatter_settings.yml b/core/modules/field/migrations/d7_field_formatter_settings.yml index 59783327457081b8c4ef4aa633112e64880166ce..b4580a235603b283f7fc86654549606dfb6cb995 100644 --- a/core/modules/field/migrations/d7_field_formatter_settings.yml +++ b/core/modules/field/migrations/d7_field_formatter_settings.yml @@ -4,7 +4,7 @@ migration_tags: - Drupal 7 - Configuration class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processFieldFormatter +field_plugin_method: alterFieldFormatterMigration source: plugin: d7_field_instance_per_view_mode constants: diff --git a/core/modules/field/migrations/d7_field_instance.yml b/core/modules/field/migrations/d7_field_instance.yml index de5f3467f8cc959c67404b80075091f97441aa13..c824c00971e63b7ce38054a12efd82cfa92b6c47 100644 --- a/core/modules/field/migrations/d7_field_instance.yml +++ b/core/modules/field/migrations/d7_field_instance.yml @@ -4,7 +4,7 @@ migration_tags: - Drupal 7 - Configuration class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processFieldInstance +field_plugin_method: alterFieldInstanceMigration source: plugin: d7_field_instance constants: diff --git a/core/modules/field/migrations/d7_field_instance_widget_settings.yml b/core/modules/field/migrations/d7_field_instance_widget_settings.yml index 14c1a8c6d52d3cfb4c51c4283eeab59eebc47588..eaa7831d69fa202f9fe22b74c8af785e6de4182d 100644 --- a/core/modules/field/migrations/d7_field_instance_widget_settings.yml +++ b/core/modules/field/migrations/d7_field_instance_widget_settings.yml @@ -4,7 +4,7 @@ migration_tags: - Drupal 7 - Configuration class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processFieldWidget +field_plugin_method: alterFieldWidgetMigration source: plugin: d7_field_instance_per_form_display constants: diff --git a/core/modules/file/src/Plugin/migrate/field/d6/FileField.php b/core/modules/file/src/Plugin/migrate/field/d6/FileField.php index 87c3bfe7acb249502dafdd5995f9d963df10d960..d532ccbe2bec687c1acf502c6320d3ed180e2522 100644 --- a/core/modules/file/src/Plugin/migrate/field/d6/FileField.php +++ b/core/modules/file/src/Plugin/migrate/field/d6/FileField.php @@ -42,7 +42,7 @@ public function getFieldFormatterMap() { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'd6_field_file', 'source' => $field_name, diff --git a/core/modules/file/src/Plugin/migrate/field/d7/FileField.php b/core/modules/file/src/Plugin/migrate/field/d7/FileField.php index 8157def995ac8379e44bfcb24ef0758cf8b7dabd..8ca9450742d6fd55e25f7d60c22669da0af184c0 100644 --- a/core/modules/file/src/Plugin/migrate/field/d7/FileField.php +++ b/core/modules/file/src/Plugin/migrate/field/d7/FileField.php @@ -18,7 +18,7 @@ class FileField extends D6FileField { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'sub_process', 'source' => $field_name, diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d6/FileCckTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d6/FileCckTest.php index 0581c27396848fe7e3f78403d070e8e0cab5097a..43d7959ec2ff6f5f9057f0df3ceb28491d66415c 100644 --- a/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d6/FileCckTest.php +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d6/FileCckTest.php @@ -33,7 +33,7 @@ protected function setUp() { $migration = $this->prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/FileCckTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/FileCckTest.php index 01db93ea9b08e21da8749d7cae15df820564a580..e47a5a93164d9d63ce79fabf4ace9995ebfac0dc 100644 --- a/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/FileCckTest.php +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/FileCckTest.php @@ -33,7 +33,7 @@ protected function setUp() { $migration = $this->prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/ImageCckTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/ImageCckTest.php index 2175c64215d3bc64c2d53c9f12dc8265c4d23a69..b20d3d0f41c9775600ce03c2118a1203e0f47e35 100644 --- a/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/ImageCckTest.php +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/ImageCckTest.php @@ -32,7 +32,7 @@ protected function setUp() { $migration = $this->prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/field/d6/FileFieldLegacyTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d6/FileFieldLegacyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..15cfb630abc406bd8436d1c2d2a032d4742f5366 --- /dev/null +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d6/FileFieldLegacyTest.php @@ -0,0 +1,19 @@ +prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). @@ -44,10 +44,10 @@ protected function setUp() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessFieldValues() { - $this->plugin->processFieldValues($this->migration, 'somefieldname', []); + public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') { + $this->plugin->$method($this->migration, 'somefieldname', []); $expected = [ 'plugin' => 'd6_field_file', diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/FileFieldLegacyTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/FileFieldLegacyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..72c2fca6a23e4a52c9633c5cfc54a93174372623 --- /dev/null +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/FileFieldLegacyTest.php @@ -0,0 +1,19 @@ +prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). @@ -44,10 +44,10 @@ protected function setUp() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessFieldValues() { - $this->plugin->processFieldValues($this->migration, 'somefieldname', []); + public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') { + $this->plugin->$method($this->migration, 'somefieldname', []); $expected = [ 'plugin' => 'sub_process', diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldLegacyTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldLegacyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..65655e630dfbd7a7dadb065510b05551c809f793 --- /dev/null +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldLegacyTest.php @@ -0,0 +1,18 @@ +prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). @@ -44,11 +44,11 @@ protected function setUp() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline * @expectedDeprecation ImageField is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.x. Use \Drupal\image\Plugin\migrate\field\d7\ImageField instead. See https://www.drupal.org/node/2936061. */ - public function testProcessFieldValues() { - $this->plugin->processFieldValues($this->migration, 'somefieldname', []); + public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') { + $this->plugin->$method($this->migration, 'somefieldname', []); $expected = [ 'plugin' => 'sub_process', diff --git a/core/modules/image/src/Plugin/migrate/field/d7/ImageField.php b/core/modules/image/src/Plugin/migrate/field/d7/ImageField.php index 4336c15d3c8cf9b3639815863130342735009405..1d829257182f130f9bca6b56b262154d411e1e4f 100644 --- a/core/modules/image/src/Plugin/migrate/field/d7/ImageField.php +++ b/core/modules/image/src/Plugin/migrate/field/d7/ImageField.php @@ -18,7 +18,7 @@ class ImageField extends FieldPluginBase { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'sub_process', 'source' => $field_name, diff --git a/core/modules/image/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldTest.php b/core/modules/image/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldTest.php index 198aa9ddfb7b66d69ee6d7b74dbbc26ea17bb03b..638c4eda73fd4d4b1965d416c10adafc62cb91b4 100644 --- a/core/modules/image/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldTest.php +++ b/core/modules/image/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldTest.php @@ -10,6 +10,7 @@ /** * @coversDefaultClass \Drupal\image\Plugin\migrate\field\d7\ImageField * @group image + * @group legacy */ class ImageFieldTest extends UnitTestCase { @@ -44,6 +45,7 @@ protected function setUp() { /** * @covers ::processFieldValues + * @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598. */ public function testProcessFieldValues() { $this->plugin->processFieldValues($this->migration, 'somefieldname', []); diff --git a/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php b/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php index f902987c6784556c9e68f261058a3987c00be056..1a823f550674ae1a415dd2c8669a63ff219d3b27 100644 --- a/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php @@ -29,8 +29,8 @@ class LinkField extends CckFieldPluginBase { * {@inheritdoc} */ public function getFieldFormatterMap() { - // See d6_field_formatter_settings.yml and CckFieldPluginBase - // processFieldFormatter(). + // See d6_field_formatter_settings.yml and FieldPluginBase + // alterFieldFormatterMigration(). return [ 'default' => 'link', 'plain' => 'link', diff --git a/core/modules/link/src/Plugin/migrate/cckfield/d7/LinkField.php b/core/modules/link/src/Plugin/migrate/cckfield/d7/LinkField.php index c4f09f25e598b03a23a1337ccd1c1b4f219a0684..a796409662f30921f167deaa5977d455c3b3aaaa 100644 --- a/core/modules/link/src/Plugin/migrate/cckfield/d7/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/cckfield/d7/LinkField.php @@ -38,9 +38,9 @@ public function getFieldWidgetMap() { } /** - * {@inheritdoc} + * @inheritdoc} */ - public function processFieldInstance(MigrationInterface $migration) { + public function alterFieldInstanceMigration(MigrationInterface $migration) { $process = [ 'plugin' => 'static_map', 'source' => 'settings/title', diff --git a/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php b/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php index 547e49201f0f404cbb1b6b29285465970d547d02..7c6fe3b600e50e146a844f587433bf5d6ba0bc35 100644 --- a/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php @@ -23,7 +23,7 @@ class LinkField extends FieldPluginBase { */ public function getFieldFormatterMap() { // See d6_field_formatter_settings.yml and FieldPluginBase - // processFieldFormatter(). + // alterFieldFormatterMigration(). return [ 'default' => 'link', 'plain' => 'link', @@ -39,7 +39,7 @@ public function getFieldFormatterMap() { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'field_link', 'source' => $field_name, diff --git a/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php b/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php index c9c7f9f188928eda47704df57363b9107bfa8cf5..20bf629b6538aa33b8d1b282934c65e3bcaa2035 100644 --- a/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php @@ -42,7 +42,7 @@ public function getFieldWidgetMap() { /** * {@inheritdoc} */ - public function processFieldInstance(MigrationInterface $migration) { + public function alterFieldInstanceMigration(MigrationInterface $migration) { $process = [ 'plugin' => 'static_map', 'source' => 'settings/title', diff --git a/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckDeprecationTest.php b/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckDeprecationTest.php new file mode 100644 index 0000000000000000000000000000000000000000..97a3892ba8b68947f20fd7c57279a72199b6f024 --- /dev/null +++ b/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckDeprecationTest.php @@ -0,0 +1,18 @@ +prophesize(MigrationInterface::class); - // The plugin's processFieldInstance() method will call + // The plugin's alterFieldInstanceMigration() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). @@ -52,12 +52,10 @@ protected function setUp() { } /** - * @covers ::processCckFieldValues - * @expectedDeprecation CckFieldPluginBase is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead. - * @expectedDeprecation MigrateCckFieldInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead. + * @covers ::alterFieldInstanceMigration */ - public function testProcessCckFieldValues() { - $this->plugin->processFieldInstance($this->migration); + public function testAlterFieldInstanceMigration($method = 'alterFieldInstanceMigration') { + $this->plugin->$method($this->migration); $expected = [ 'plugin' => 'static_map', diff --git a/core/modules/link/tests/src/Kernel/Plugin/migrate/field/d7/LinkFieldLegacyTest.php b/core/modules/link/tests/src/Kernel/Plugin/migrate/field/d7/LinkFieldLegacyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..149442edafb0596e07bb920dddb1dc4d6a7883bf --- /dev/null +++ b/core/modules/link/tests/src/Kernel/Plugin/migrate/field/d7/LinkFieldLegacyTest.php @@ -0,0 +1,18 @@ +prophesize(MigrationInterface::class); - // The plugin's ProcessFieldInstance() method will call + // The plugin's alterFieldInstanceMigration() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). @@ -51,10 +51,10 @@ protected function setUp() { } /** - * @covers ::processFieldInstance + * @covers ::alterFieldInstanceMigration */ - public function testProcessFieldInstance() { - $this->plugin->processFieldInstance($this->migration); + public function testAlterFieldInstanceMigration($method = 'alterFieldInstanceMigration') { + $this->plugin->$method($this->migration); $expected = [ 'plugin' => 'static_map', diff --git a/core/modules/link/tests/src/Unit/Plugin/migrate/field/d6/LinkFieldLegacyTest.php b/core/modules/link/tests/src/Unit/Plugin/migrate/field/d6/LinkFieldLegacyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7e7be8e10cac7a93361a788ae5d4e8362e2e8a3e --- /dev/null +++ b/core/modules/link/tests/src/Unit/Plugin/migrate/field/d6/LinkFieldLegacyTest.php @@ -0,0 +1,18 @@ +prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). @@ -44,10 +44,10 @@ protected function setUp() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessFieldValues() { - $this->plugin->processFieldValues($this->migration, 'somefieldname', []); + public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') { + $this->plugin->$method($this->migration, 'somefieldname', []); $expected = [ 'plugin' => 'field_link', diff --git a/core/modules/migrate_drupal/src/Plugin/MigrateFieldInterface.php b/core/modules/migrate_drupal/src/Plugin/MigrateFieldInterface.php index 2aac5d18eb36a81c0acaa5c095725d722d77b76f..96ed53e5c4155717380314a406fd62d0b98b2d68 100644 --- a/core/modules/migrate_drupal/src/Plugin/MigrateFieldInterface.php +++ b/core/modules/migrate_drupal/src/Plugin/MigrateFieldInterface.php @@ -17,7 +17,7 @@ interface MigrateFieldInterface extends PluginInspectionInterface { * @param \Drupal\migrate\Plugin\MigrationInterface $migration * The migration entity. */ - public function processField(MigrationInterface $migration); + public function alterFieldMigration(MigrationInterface $migration); /** * Apply any custom processing to the field instance migration. @@ -25,7 +25,7 @@ public function processField(MigrationInterface $migration); * @param \Drupal\migrate\Plugin\MigrationInterface $migration * The migration entity. */ - public function processFieldInstance(MigrationInterface $migration); + public function alterFieldInstanceMigration(MigrationInterface $migration); /** * Apply any custom processing to the field widget migration. @@ -33,7 +33,7 @@ public function processFieldInstance(MigrationInterface $migration); * @param \Drupal\migrate\Plugin\MigrationInterface $migration * The migration entity. */ - public function processFieldWidget(MigrationInterface $migration); + public function alterFieldWidgetMigration(MigrationInterface $migration); /** * Apply any custom processing to the field formatter migration. @@ -41,7 +41,7 @@ public function processFieldWidget(MigrationInterface $migration); * @param \Drupal\migrate\Plugin\MigrationInterface $migration * The migration entity. */ - public function processFieldFormatter(MigrationInterface $migration); + public function alterFieldFormatterMigration(MigrationInterface $migration); /** * Get the field formatter type from the source. @@ -57,7 +57,7 @@ public function getFieldFormatterType(Row $row); /** * Get a map between D6 formatters and D8 formatters for this field type. * - * This is used by static::processFieldFormatter() in the base class. + * This is used by static::alterFieldFormatterMigration() in the base class. * * @return array * The keys are D6 formatters and the values are D8 formatters. @@ -93,7 +93,7 @@ public function getFieldWidgetMap(); * @param array $data * The array of field data from FieldValues::fieldData(). */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data); + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data); /** * Computes the destination type of a migrated field. diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php b/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php index 220c8bbd6c44fb791334fb80a589becb7098cf0f..80ad6fa50763f7db8846572d0217c08c917e0870 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php @@ -21,16 +21,9 @@ abstract class CckFieldPluginBase extends FieldPluginBase implements MigrateCckFieldInterface { /** - * Apply any custom processing to the field bundle migrations. - * - * @param \Drupal\migrate\Plugin\MigrationInterface $migration - * The migration entity. - * @param string $field_name - * The field name we're processing the value for. - * @param array $data - * The array of field data from FieldValues::fieldData(). + * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { // Provide a bridge to the old method declared on the interface and now an // abstract method in this class. return $this->processCckFieldValues($migration, $field_name, $data); diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/field/FieldPluginBase.php b/core/modules/migrate_drupal/src/Plugin/migrate/field/FieldPluginBase.php index dc115abc99f6dd87dd8974e489f95ffa5dbc2b50..78274704d16371b17fb36c0d0d5a31e48a716411 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/field/FieldPluginBase.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/field/FieldPluginBase.php @@ -20,24 +20,66 @@ abstract class FieldPluginBase extends PluginBase implements MigrateFieldInterface { /** - * {@inheritdoc} + * Alters the migration for field definitions. + * + * @deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use + * alterFieldMigration() instead. + * + * @see https://www.drupal.org/node/2944598 + * @see ::alterFieldMigration() */ public function processField(MigrationInterface $migration) { + @trigger_error('Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use alterFieldMigration() instead. See https://www.drupal.org/node/2944598.', E_USER_DEPRECATED); + $this->alterFieldMigration($migration); + } + + /** + * {@inheritdoc} + */ + public function alterFieldMigration(MigrationInterface $migration) { $process[0]['map'][$this->pluginId][$this->pluginId] = $this->pluginId; $migration->mergeProcessOfProperty('type', $process); } /** - * {@inheritdoc} + * Alert field instance migration. + * + * @deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use + * alterFieldInstanceMigration() instead. + * + * @see https://www.drupal.org/node/2944598 + * @see ::alterFieldInstanceMigration() */ public function processFieldInstance(MigrationInterface $migration) { - // Nothing to do by default with field instances. + @trigger_error('Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use alterFieldInstanceMigration() instead. See https://www.drupal.org/node/2944598.', E_USER_DEPRECATED); + $this->alterFieldInstanceMigration($migration); } /** * {@inheritdoc} */ + public function alterFieldInstanceMigration(MigrationInterface $migration) { + // Nothing to do by default with field instances. + } + + /** + * Alter field widget migration. + * + * @deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use + * alterFieldWidgetMigration() instead. + * + * @see https://www.drupal.org/node/2944598 + * @see ::alterFieldWidgetMigration() + */ public function processFieldWidget(MigrationInterface $migration) { + @trigger_error('Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use alterFieldWidgetMigration() instead. See https://www.drupal.org/node/2944598.', E_USER_DEPRECATED); + $this->alterFieldWidgetMigration($migration); + } + + /** + * {@inheritdoc} + */ + public function alterFieldWidgetMigration(MigrationInterface $migration) { $process = []; foreach ($this->getFieldWidgetMap() as $source_widget => $destination_widget) { $process['type']['map'][$source_widget] = $destination_widget; @@ -77,11 +119,24 @@ public function getFieldWidgetMap() { } /** - * {@inheritdoc} + * Alter field formatter migration. + * + * @deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use + * alterFieldFormatterMigration() instead. + * + * @see https://www.drupal.org/node/2944598 + * @see ::processFieldFormatter() */ public function processFieldFormatter(MigrationInterface $migration) { - $process = []; + @trigger_error('Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use alterFieldFormatterMigration() instead. See https://www.drupal.org/node/2944598.', E_USER_DEPRECATED); + $this->alterFieldFormatterMigration($migration); + } + /** + * {@inheritdoc} + */ + public function alterFieldFormatterMigration(MigrationInterface $migration) { + $process = []; // Some migrate field plugin IDs are prefixed with 'd6_' or 'd7_'. Since the // plugin ID is used in the static map as the module name, we have to remove // this prefix from the plugin ID. @@ -93,9 +148,23 @@ public function processFieldFormatter(MigrationInterface $migration) { } /** - * {@inheritdoc} + * Defines the process pipeline for field values. + * + * @deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use + * defineValueProcessPipeline() instead. + * + * @see https://www.drupal.org/node/2944598 + * @see ::defineValueProcessPipeline() */ public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + @trigger_error('Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598.', E_USER_DEPRECATED); + return $this->defineValueProcessPipeline($migration, $field_name, $data); + } + + /** + * {@inheritdoc} + */ + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'get', 'source' => $field_name, diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php b/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php index d8b756b916bad879e62a4b5961214d311920e607..de8c4f50950e11257692228aa8ba5a79d550ba51 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php @@ -20,7 +20,7 @@ class NodeReference extends FieldPluginBase { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'sub_process', 'source' => $field_name, diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php b/core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php index b42d94cba326cee1a8949ff0f6992a0d8d8827f1..4a60f450de5b02c801cd087daa59fff9de7b8eaf 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php @@ -20,7 +20,7 @@ class UserReference extends FieldPluginBase { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'sub_process', 'source' => $field_name, diff --git a/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php index 536303e95648f962b52678e0c0f7cca7aea3b725..94c759bea45bd99f65a494f3728ea016e71a58be 100644 --- a/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php +++ b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php @@ -165,7 +165,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->fieldPluginCache[$field_type] = $this->fieldPluginManager->createInstance($plugin_id, ['core' => 6], $migration); } $this->fieldPluginCache[$field_type] - ->processFieldValues($migration, $field_name, $info); + ->defineValueProcessPipeline($migration, $field_name, $info); } catch (PluginNotFoundException $ex) { try { diff --git a/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php b/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php index 28c61b834091e48d263a33d95f0df7cf76f8f355..25099cf178db81fa34887578473c02bbe3473d9a 100644 --- a/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php +++ b/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php @@ -168,7 +168,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->fieldPluginCache[$field_type] = $this->fieldPluginManager->createInstance($plugin_id, ['core' => 7], $migration); } $this->fieldPluginCache[$field_type] - ->processFieldValues($migration, $field_name, $info); + ->defineValueProcessPipeline($migration, $field_name, $info); } catch (PluginNotFoundException $ex) { try { diff --git a/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php b/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php index 561a9afe8035e40e25aa06c4b2dbdf0f843a316e..566cf3b3da224614aaf2ec5477ae62076b37119e 100644 --- a/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php +++ b/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php @@ -137,7 +137,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->fieldPluginCache[$field_type] = $this->fieldPluginManager->createInstance($plugin_id, ['core' => 7], $migration); } $this->fieldPluginCache[$field_type] - ->processFieldValues($migration, $field_name, $info); + ->defineValueProcessPipeline($migration, $field_name, $info); } catch (PluginNotFoundException $ex) { try { diff --git a/core/modules/taxonomy/src/Plugin/migrate/field/TaxonomyTermReference.php b/core/modules/taxonomy/src/Plugin/migrate/field/TaxonomyTermReference.php index bea9a3f95f0b259f0dcf71c73a4d526184d9a836..1fa80d2cd59d5404fc7b8ce471f277e8f9d4a5c4 100644 --- a/core/modules/taxonomy/src/Plugin/migrate/field/TaxonomyTermReference.php +++ b/core/modules/taxonomy/src/Plugin/migrate/field/TaxonomyTermReference.php @@ -30,7 +30,7 @@ public function getFieldFormatterMap() { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'sub_process', 'source' => $field_name, diff --git a/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/cckfield/TaxonomyTermReferenceCckLegacyTest.php b/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/cckfield/TaxonomyTermReferenceCckLegacyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..003185adbf352d2155d4afc1dff3004433f4869c --- /dev/null +++ b/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/cckfield/TaxonomyTermReferenceCckLegacyTest.php @@ -0,0 +1,18 @@ +migration = $migration->reveal(); } + public function testProcessCckFieldValues() { + $this->testDefineValueProcessPipeline('processCckFieldValues'); + } + /** - * @covers ::processCckFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessCckFieldValues() { - $this->plugin->processFieldValues($this->migration, 'somefieldname', []); + public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') { + $this->plugin->$method($this->migration, 'somefieldname', []); $expected = [ 'plugin' => 'sub_process', diff --git a/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/field/TaxonomyTermReferenceFieldLegacyTest.php b/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/field/TaxonomyTermReferenceFieldLegacyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..60b1cab00c5f63278b140e978acff25b6b3ba1da --- /dev/null +++ b/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/field/TaxonomyTermReferenceFieldLegacyTest.php @@ -0,0 +1,18 @@ +prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // setProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to setProcessOfProperty(). @@ -44,10 +44,10 @@ protected function setUp() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessFieldValues() { - $this->plugin->processFieldValues($this->migration, 'somefieldname', []); + public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') { + $this->plugin->$method($this->migration, 'somefieldname', []); $expected = [ 'plugin' => 'sub_process', diff --git a/core/modules/text/src/Plugin/migrate/field/d6/TextField.php b/core/modules/text/src/Plugin/migrate/field/d6/TextField.php index aa324b6f77d1fcae570a12b8a4796a5b42cbbdea..dba6398a06448eeb435ea265ef06db88a250e85a 100644 --- a/core/modules/text/src/Plugin/migrate/field/d6/TextField.php +++ b/core/modules/text/src/Plugin/migrate/field/d6/TextField.php @@ -44,7 +44,7 @@ public function getFieldFormatterMap() { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $field_info) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $field_info) { $widget_type = isset($field_info['widget_type']) ? $field_info['widget_type'] : $field_info['widget']['type']; if ($widget_type == 'optionwidgets_onoff') { diff --git a/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php b/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php index e17404e0488dbf4f9985b0fa5a78fc73fd5c5f6c..807b9f16e5ec7d9d1231496f8e2a27f45756b7c4 100644 --- a/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php +++ b/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php @@ -33,7 +33,7 @@ protected function setUp() { $migration = $this->prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // setProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to setProcessOfProperty(). @@ -46,7 +46,11 @@ protected function setUp() { } /** + * Calls the deprecated processFieldValues() method to test BC. + * * @covers ::processFieldValues + * + * @depends testFilteredTextValueProcessPipeline */ public function testProcessFilteredTextFieldValues() { $field_info = [ @@ -69,7 +73,34 @@ public function testProcessFilteredTextFieldValues() { } /** + * @covers ::defineValueProcessPipeline + */ + public function testFilteredTextValueProcessPipeline() { + $field_info = [ + 'widget_type' => 'text_textfield', + ]; + $this->plugin->defineValueProcessPipeline($this->migration, 'body', $field_info); + + $process = $this->migration->getProcess(); + $this->assertSame('sub_process', $process['plugin']); + $this->assertSame('body', $process['source']); + $this->assertSame('value', $process['process']['value']); + + // Ensure that filter format IDs will be looked up in the filter format + // migrations. + $lookup = $process['process']['format'][2]; + $this->assertSame('migration', $lookup['plugin']); + $this->assertContains('d6_filter_format', $lookup['migration']); + $this->assertContains('d7_filter_format', $lookup['migration']); + $this->assertSame('format', $lookup['source']); + } + + /** + * Calls the deprecated processFieldValues() method to test BC. + * * @covers ::processFieldValues + * + * @depends testBooleanTextImplicitValueProcessPipeline */ public function testProcessBooleanTextImplicitValues() { $info = [ @@ -94,7 +125,36 @@ public function testProcessBooleanTextImplicitValues() { } /** + * @covers ::defineValueProcessPipeline + */ + public function testBooleanTextImplicitValueProcessPipeline() { + $info = [ + 'widget_type' => 'optionwidgets_onoff', + 'global_settings' => [ + 'allowed_values' => "foo\nbar", + ], + ]; + $this->plugin->defineValueProcessPipeline($this->migration, 'field', $info); + + $expected = [ + 'value' => [ + 'plugin' => 'static_map', + 'source' => 'value', + 'default_value' => 0, + 'map' => [ + 'bar' => 1, + ], + ], + ]; + $this->assertSame($expected, $this->migration->getProcess()['process']); + } + + /** + * Calls the deprecated processFieldValues() method to test BC. + * * @covers ::processFieldValues + * + * @depends testBooleanTextExplicitValueProcessPipeline */ public function testProcessBooleanTextExplicitValues() { $info = [ @@ -118,6 +178,31 @@ public function testProcessBooleanTextExplicitValues() { $this->assertSame($expected, $this->migration->getProcess()['process']); } + /** + * @covers ::defineValueProcessPipeline + */ + public function testBooleanTextExplicitValueProcessPipeline() { + $info = [ + 'widget_type' => 'optionwidgets_onoff', + 'global_settings' => [ + 'allowed_values' => "foo|Foo\nbaz|Baz", + ], + ]; + $this->plugin->defineValueProcessPipeline($this->migration, 'field', $info); + + $expected = [ + 'value' => [ + 'plugin' => 'static_map', + 'source' => 'value', + 'default_value' => 0, + 'map' => [ + 'baz' => 1, + ], + ], + ]; + $this->assertSame($expected, $this->migration->getProcess()['process']); + } + /** * Data provider for testGetFieldType(). */ diff --git a/core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldLegacyTest.php b/core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldLegacyTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d30844bf0ba6e60dfa907e53dbfa2eed6a8b7642 --- /dev/null +++ b/core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldLegacyTest.php @@ -0,0 +1,36 @@ +prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // setProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to setProcessOfProperty(). @@ -45,13 +45,13 @@ protected function setUp() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessFilteredTextFieldValues() { + public function testProcessFilteredTextFieldValues($method = 'defineValueProcessPipeline') { $field_info = [ 'widget_type' => 'text_textfield', ]; - $this->plugin->processFieldValues($this->migration, 'body', $field_info); + $this->plugin->$method($this->migration, 'body', $field_info); $process = $this->migration->getProcess(); $this->assertSame('sub_process', $process['plugin']); @@ -68,16 +68,16 @@ public function testProcessFilteredTextFieldValues() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessBooleanTextImplicitValues() { + public function testProcessBooleanTextImplicitValues($method = 'defineValueProcessPipeline') { $info = [ 'widget_type' => 'optionwidgets_onoff', 'global_settings' => [ 'allowed_values' => "foo\nbar", ], ]; - $this->plugin->processFieldValues($this->migration, 'field', $info); + $this->plugin->$method($this->migration, 'field', $info); $expected = [ 'value' => [ @@ -93,16 +93,16 @@ public function testProcessBooleanTextImplicitValues() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessBooleanTextExplicitValues() { + public function testProcessBooleanTextExplicitValues($method = 'defineValueProcessPipeline') { $info = [ 'widget_type' => 'optionwidgets_onoff', 'global_settings' => [ 'allowed_values' => "foo|Foo\nbaz|Baz", ], ]; - $this->plugin->processFieldValues($this->migration, 'field', $info); + $this->plugin->$method($this->migration, 'field', $info); $expected = [ 'value' => [ diff --git a/core/modules/user/src/Plugin/migrate/User.php b/core/modules/user/src/Plugin/migrate/User.php index 5316259abd3c78ffe98459f2f2d647a615e0a76c..d918932ddcfce9624c6e73cd67960c88aa8f15d6 100644 --- a/core/modules/user/src/Plugin/migrate/User.php +++ b/core/modules/user/src/Plugin/migrate/User.php @@ -37,7 +37,7 @@ public function getProcess() { } $info = $row->getSource(); $this->fieldPluginCache[$field_type] - ->processFieldValues($this, $field_name, $info); + ->defineValueProcessPipeline($this, $field_name, $info); } else { if ($this->cckPluginManager->hasDefinition($field_type)) {