function FilterIdTest::testTransform
Same name in other branches
- 9 core/modules/filter/tests/src/Kernel/Plugin/migrate/process/FilterIdTest.php \Drupal\Tests\filter\Kernel\Plugin\migrate\process\FilterIdTest::testTransform()
- 8.9.x core/modules/filter/tests/src/Kernel/Plugin/migrate/process/FilterIdTest.php \Drupal\Tests\filter\Kernel\Plugin\migrate\process\FilterIdTest::testTransform()
- 10 core/modules/filter/tests/src/Kernel/Plugin/migrate/process/FilterIdTest.php \Drupal\Tests\filter\Kernel\Plugin\migrate\process\FilterIdTest::testTransform()
Tests transformation of filter_id plugin.
@dataProvider provideFilters
@covers ::transform
Parameters
mixed $value: The input value to the plugin.
string $expected_value: The output value expected from the plugin.
string $invalid_id: (optional) The invalid plugin ID which is expected to be logged by the MigrateExecutable object.
bool $stop_pipeline: (optional) Set to TRUE if we expect the filter to be skipped because it is a transformation-only filter.
File
-
core/
modules/ filter/ tests/ src/ Kernel/ Plugin/ migrate/ process/ FilterIdTest.php, line 59
Class
- FilterIdTest
- Unit tests of the filter_id plugin.
Namespace
Drupal\Tests\filter\Kernel\Plugin\migrate\processCode
public function testTransform($value, $expected_value, $invalid_id = NULL, $stop_pipeline = FALSE) : void {
$configuration = [
'bypass' => TRUE,
'map' => [
'foo' => 'filter_html',
'baz' => 'php_code',
],
];
$plugin = FilterID::create($this->container, $configuration, 'filter_id', []);
if ($stop_pipeline) {
$this->executable
->expects($this->exactly(1))
->method('saveMessage')
->with(sprintf('Filter %s could not be mapped to an existing filter plugin; omitted since it is a transformation-only filter. Install and configure a successor after the migration.', $value), MigrationInterface::MESSAGE_INFORMATIONAL);
}
if (isset($invalid_id)) {
$this->executable
->expects($this->exactly(1))
->method('saveMessage')
->with(sprintf('Filter %s could not be mapped to an existing filter plugin; defaulting to %s and dropping all settings. Either redo the migration with the module installed that provides an equivalent filter, or modify the text format after the migration to remove this filter if it is no longer necessary.', $invalid_id, $expected_value), MigrationInterface::MESSAGE_WARNING);
}
$row = new Row();
$output_value = $plugin->transform($value, $this->executable, $row, 'foo');
$this->assertSame($expected_value, $output_value);
$this->assertSame($stop_pipeline, $plugin->isPipelineStopped());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.