function ProcessFieldTest::testTransform
Same name in other branches
- 8.9.x core/modules/field/tests/src/Unit/Plugin/migrate/process/ProcessFieldTest.php \Drupal\Tests\field\Unit\Plugin\migrate\process\ProcessFieldTest::testTransform()
- 10 core/modules/field/tests/src/Unit/Plugin/migrate/process/ProcessFieldTest.php \Drupal\Tests\field\Unit\Plugin\migrate\process\ProcessFieldTest::testTransform()
- 11.x core/modules/field/tests/src/Unit/Plugin/migrate/process/ProcessFieldTest.php \Drupal\Tests\field\Unit\Plugin\migrate\process\ProcessFieldTest::testTransform()
Tests the transform method.
@covers ::transform @dataProvider providerTestTransform
Parameters
string $method: The method to call.
string $value: The value to process.
mixed $expected_value: The expected transformed value.
string $migrate_exception: The MigrateException message to expect.
bool $plugin_not_found: Whether the field plugin is not found.
File
-
core/
modules/ field/ tests/ src/ Unit/ Plugin/ migrate/ process/ ProcessFieldTest.php, line 81
Class
- ProcessFieldTest
- Tests the ProcessField migrate process plugin.
Namespace
Drupal\Tests\field\Unit\Plugin\migrate\processCode
public function testTransform($method, $value, $expected_value, $migrate_exception = '', $plugin_not_found = FALSE) {
if ($method) {
$this->fieldPlugin
->{$method}($this->row
->reveal())
->willReturn($expected_value);
}
$plugin = new ProcessField([
'method' => $method,
], $value, [], $this->fieldManager
->reveal(), $this->migration
->reveal());
if ($migrate_exception) {
$this->expectException(MigrateException::class);
$this->expectExceptionMessage($migrate_exception);
}
if ($plugin_not_found) {
$exception = new PluginNotFoundException('foo');
$this->fieldManager
->getPluginIdFromFieldType()
->willThrow($exception);
}
$transformed_value = $plugin->transform($value, $this->migrateExecutable
->reveal(), $this->row
->reveal(), 'foo');
$this->assertSame($transformed_value, $expected_value);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.