public function PathautoKernelTest::testCleanAlias in Pathauto 8
Test pathauto_clean_alias().
File
- tests/
src/ Kernel/ PathautoKernelTest.php, line 239
Class
- PathautoKernelTest
- Unit tests for Pathauto functions.
Namespace
Drupal\Tests\pathauto\KernelCode
public function testCleanAlias() {
$tests = [];
$tests['one/two/three'] = '/one/two/three';
$tests['/one/two/three/'] = '/one/two/three';
$tests['one//two///three'] = '/one/two/three';
$tests['one/two--three/-/--/-/--/four---five'] = '/one/two-three/four-five';
$tests['one/-//three--/four'] = '/one/three/four';
foreach ($tests as $input => $expected) {
$output = \Drupal::service('pathauto.alias_cleaner')
->cleanAlias($input);
$this
->assertEquals($expected, $output, t("Drupal::service('pathauto.generator')->cleanAlias('@input') expected '@expected', actual '@output'", [
'@input' => $input,
'@expected' => $expected,
'@output' => $output,
]));
}
}