Commit 14a769b7 authored by catch's avatar catch
Browse files

Issue #2631698 by Jo Fitzgerald, robpowell, phenaproxima, heddn, quietone: Fix...

Issue #2631698 by Jo Fitzgerald, robpowell, phenaproxima, heddn, quietone: Fix sub-optimal DX in MigrateFieldInterface
parent 163144a9
......@@ -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,
......
......@@ -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);
......
......@@ -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';
......
......@@ -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';
......
<?php
namespace Drupal\Tests\datetime\Unit\Plugin\migrate\field;
/**
* @group migrate
* @group legacy
*/
class DateFieldLegacyTest extends DateFieldTest {
/**
* @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 testUnknownDateType($method = 'processFieldValues') {
parent::testUnknownDateType($method);
}
}
......@@ -11,25 +11,15 @@
*/
class DateFieldTest extends UnitTestCase {
/**
* @var \Drupal\migrate_drupal\Plugin\MigrateFieldInterface
*/
protected $plugin;
/**
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
/**
* Tests an Exception is thrown when the field type is not a known date type.
*/
public function testUnknownDateType() {
$this->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']);
}
}
<?php
namespace Drupal\Tests\datetime\Unit\Plugin\migrate\field\d6;
/**
* @group migrate
* @group legacy
*/
class DateFieldLegacyTest extends DateFieldTest {
/**
* @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 testUnknownDateType($method = 'processFieldValues') {
parent::testUnknownDateType($method);
}
}
......@@ -4,6 +4,7 @@
use Drupal\datetime\Plugin\migrate\field\d6\DateField;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\Tests\UnitTestCase;
/**
......@@ -13,26 +14,28 @@
class DateFieldTest extends UnitTestCase {
/**
* @var \Drupal\migrate_drupal\Plugin\MigrateFieldInterface
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $plugin;
protected $migration;
/**
* @var \Drupal\migrate\Plugin\MigrationInterface
* {@inheritdoc}
*/
protected $migration;
protected function setUp() {
parent::setUp();
$this->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']);
}
}
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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,
......
......@@ -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,
......
......@@ -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().
......
......@@ -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().
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment