function PathautoLocaleTestCase::testLanguageAliases in Pathauto 6
Same name and namespace in other branches
- 6.2 pathauto.test \PathautoLocaleTestCase::testLanguageAliases()
- 7 pathauto.test \PathautoLocaleTestCase::testLanguageAliases()
Test that when an English node is updated, its old English alias is updated and its newer French alias is left intact.
File
- ./
pathauto.test, line 624 - Functionality tests for Pathauto.
Class
Code
function testLanguageAliases() {
$node = array(
'title' => 'English node',
'language' => 'en',
'path' => 'english-node',
'pathauto_perform_alias' => FALSE,
);
$node = $this
->drupalCreateNode($node);
$english_alias = $this
->path_load(array(
'alias' => 'english-node',
));
$this
->assertTrue($english_alias, 'Alias created with proper language.');
// Also save a French alias that should not be left alone, even though
// it is the newer alias.
$this
->saveEntityAlias('node', $node, 'french-node', 'fr');
// Add an alias with the soon-to-be generated alias, causing the upcoming
// alias update to generate a unique alias with the '-0' suffix.
$this
->saveAlias('node/invalid', 'content/english-node', '');
// Update the node, triggering a change in the English alias.
$node->pathauto_perform_alias = TRUE;
pathauto_nodeapi($node, 'update');
// Check that the new English alias replaced the old one.
$this
->assertEntityAlias('node', $node, 'content/english-node-0', 'en');
$this
->assertEntityAlias('node', $node, 'french-node', 'fr');
$this
->assertAliasExists(array(
'pid' => $english_alias['pid'],
'alias' => 'content/english-node-0',
));
}