$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().
}
/**
+ * Calls the deprecated processFieldValues() method to test BC.
+ *
* @covers ::processFieldValues
+ *
+ * @depends testFilteredTextValueProcessPipeline
*/
public function testProcessFilteredTextFieldValues() {
$field_info = [
}
/**
+ * @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 = [
'widget_type' => 'optionwidgets_onoff',
'global_settings' => [
'allowed_values' => "foo\nbar",
- ]
+ ],
];
$this->plugin->processFieldValues($this->migration, 'field', $info);
}
/**
+ * @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 = [
'widget_type' => 'optionwidgets_onoff',
'global_settings' => [
'allowed_values' => "foo|Foo\nbaz|Baz",
- ]
+ ],
];
$this->plugin->processFieldValues($this->migration, 'field', $info);
$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().
*/