X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ftext%2Ftests%2Fsrc%2FUnit%2FMigrate%2Fd6%2FTextFieldTest.php;h=807b9f16e5ec7d9d1231496f8e2a27f45756b7c4;hp=8bf5d2a2d07d5d1352d55f6f40335c90ab0f553a;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php b/web/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php index 8bf5d2a2d..807b9f16e 100644 --- a/web/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php +++ b/web/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php @@ -33,7 +33,7 @@ class TextFieldTest extends UnitTestCase { $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 @@ class TextFieldTest extends UnitTestCase { } /** + * Calls the deprecated processFieldValues() method to test BC. + * * @covers ::processFieldValues + * + * @depends testFilteredTextValueProcessPipeline */ public function testProcessFilteredTextFieldValues() { $field_info = [ @@ -69,14 +73,41 @@ class TextFieldTest extends UnitTestCase { } /** + * @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); @@ -94,14 +125,43 @@ class TextFieldTest extends UnitTestCase { } /** + * @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); @@ -118,6 +178,31 @@ class TextFieldTest extends UnitTestCase { $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(). */