function PathautoUnitTestCase::testCleanString in Pathauto 7
Same name and namespace in other branches
- 6.2 pathauto.test \PathautoUnitTestCase::testCleanString()
- 6 pathauto.test \PathautoUnitTestCase::testCleanString()
Test pathauto_cleanstring().
File
- ./
pathauto.test, line 176 - Functionality tests for Pathauto.
Class
- PathautoUnitTestCase
- Unit tests for Pathauto functions.
Code
function testCleanString() {
$tests = array();
variable_set('pathauto_ignore_words', ', in, is,that, the , this, with, ');
variable_set('pathauto_max_component_length', 35);
// Test the 'ignored words' removal.
$tests['this'] = 'this';
$tests['this with that'] = 'this-with-that';
$tests['this thing with that thing'] = 'thing-thing';
// Test length truncation and duplicate separator removal.
$tests[' - Pathauto is the greatest - module ever in Drupal history - '] = 'pathauto-greatest-module-ever';
// Test that HTML tags are removed.
$tests['This <span class="text">text</span> has <br /><a href="http://example.com"><strong>HTML tags</strong></a>.'] = 'text-has-html-tags';
$tests[check_plain('This <span class="text">text</span> has <br /><a href="http://example.com"><strong>HTML tags</strong></a>.')] = 'text-has-html-tags';
foreach ($tests as $input => $expected) {
$output = pathauto_cleanstring($input);
$this
->assertEqual($output, $expected, t("pathauto_cleanstring('@input') expected '@expected', actual '@output'", array(
'@input' => $input,
'@expected' => $expected,
'@output' => $output,
)));
}
}