function MachineNameTest::testMachineNames
Same name in other branches
- 9 core/modules/migrate/tests/src/Unit/process/MachineNameTest.php \Drupal\Tests\migrate\Unit\process\MachineNameTest::testMachineNames()
- 8.9.x core/modules/migrate/tests/src/Unit/process/MachineNameTest.php \Drupal\Tests\migrate\Unit\process\MachineNameTest::testMachineNames()
- 11.x core/modules/migrate/tests/src/Unit/process/MachineNameTest.php \Drupal\Tests\migrate\Unit\process\MachineNameTest::testMachineNames()
Tests machine name transformation of non-alphanumeric characters.
@dataProvider providerTestMachineNames
Parameters
string $human_name: The human-readable name that will be converted in the test.
array $configuration: The plugin configuration.
string $expected_result: The expected result of the transformation.
File
-
core/
modules/ migrate/ tests/ src/ Unit/ process/ MachineNameTest.php, line 52
Class
- MachineNameTest
- Tests the machine name process plugin.
Namespace
Drupal\Tests\migrate\Unit\processCode
public function testMachineNames(string $human_name, array $configuration, string $expected_result) : void {
// Test for calling transliterate on mock object.
$this->transliteration
->expects($this->once())
->method('transliterate')
->with($human_name)
->willReturnCallback(function (string $string) : string {
return str_replace([
'á',
'é',
'ő',
], [
'a',
'e',
'o',
], $string);
});
$plugin = new MachineName($configuration, 'machine_name', [], $this->transliteration);
$value = $plugin->transform($human_name, $this->migrateExecutable, $this->row, 'destination_property');
$this->assertEquals($expected_result, $value);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.