public function PatternsPathautoTestCase::testPathauto in Patterns 7
Same name and namespace in other branches
- 7.2 tests/pathauto/pathauto.test \PatternsPathautoTestCase::testPathauto()
File
- tests/
pathauto/ pathauto.test, line 80 - SimpleTests for the Field component of Patterns.
Class
- PatternsPathautoTestCase
- @file SimpleTests for the Field component of Patterns.
Code
public function testPathauto() {
if (!patterns_utils_is_module_enabled('pathauto')) {
$this
->fail('Pathauto module not found. Skipping all related tests');
return;
}
// Make sure that matches the theme in the pattern file
//module_enable(array('pathauto'));
parent::runFile('path_auto.yaml', 'pathauto setting', $this->pathauto_tests_dir);
//test pathauto setting
$case = variable_get('pathauto_case');
$Clength = variable_get('pathauto_max_component_length');
$length = variable_get('pathauto_max_length');
$punctuation_ampersand = variable_get('pathauto_punctuation_ampersand');
$reduce_ascii = variable_get('pathauto_reduce_ascii');
$separator = variable_get('pathauto_separator');
$update_action = variable_get('pathauto_update_action');
$verbose = variable_get('pathauto_verbose');
$this
->assertEqual($case, 1, t('Character case set correctly.'));
$this
->assertEqual($Clength, 50, t('Maximum component length set correctly.'));
$this
->assertEqual($length, 50, t('Maximum alias length set correctly.'));
$this
->assertEqual($punctuation_ampersand, 1, t('Punctuation ampersand set correctly.'));
$this
->assertEqual($reduce_ascii, 1, t('Reduce strings to letters and numbers set correctly.'));
$this
->assertEqual($separator, '-', t('Separator set correctly.'));
$this
->assertEqual($update_action, 2, t('Update action set correctly.'));
$this
->assertEqual($verbose, 1, t('Verbose set correctly.'));
// Test pattens settings
$tests = array(
array(
'entity' => 'node',
'bundle' => 'page',
'language' => LANGUAGE_NONE,
'expected' => 'contentnode/[node:title]',
),
array(
'entity' => 'user',
'bundle' => 'user',
'language' => 'en',
'expected' => 'users/[user:name]',
),
array(
'entity' => 'user',
'bundle' => 'user',
'language' => LANGUAGE_NONE,
'expected' => 'users/[user:name]',
),
array(
'entity' => 'invalid-entity',
'bundle' => '',
'language' => LANGUAGE_NONE,
'expected' => '',
),
);
foreach ($tests as $test) {
$actual = pathauto_pattern_load_by_entity($test['entity'], $test['bundle'], $test['language']);
$this
->assertIdentical($actual, $test['expected'], t("pathauto_pattern_load_by_entity('@entity', '@bundle', '@language') returned '@actual', expected '@expected'", array(
'@entity' => $test['entity'],
'@bundle' => $test['bundle'],
'@language' => $test['language'],
'@actual' => $actual,
'@expected' => $test['expected'],
)));
}
}