function PathautoFunctionalTestCase::testTermEditing in Pathauto 7
Basic functional testing of Pathauto with taxonomy terms.
File
- ./
pathauto.test, line 652 - Functionality tests for Pathauto.
Class
- PathautoFunctionalTestCase
- Test basic pathauto functionality.
Code
function testTermEditing() {
$this
->drupalGet('admin/structure');
$this
->drupalGet('admin/structure/taxonomy');
// Create term for testing.
$name = ' Testing: term name [ ';
$automatic_alias = 'tags/testing-term-name';
$this
->drupalPost('admin/structure/taxonomy/tags/add', array(
'name' => $name,
), 'Save');
$name = trim($name);
$this
->assertText("Created new term {$name}.");
$term = $this
->drupalGetTermByName($name);
// Look for alias generated in the form.
$this
->drupalGet("taxonomy/term/{$term->tid}/edit");
$this
->assertFieldChecked('edit-path-pathauto');
$this
->assertFieldByName('path[alias]', $automatic_alias, 'Generated alias visible in the path alias field.');
// Check whether the alias actually works.
$this
->drupalGet($automatic_alias);
$this
->assertText($name, 'Term accessible through automatic alias.');
// Manually set the term's alias.
$manual_alias = 'tags/' . $term->tid;
$edit = array(
'path[pathauto]' => FALSE,
'path[alias]' => $manual_alias,
);
$this
->drupalPost("taxonomy/term/{$term->tid}/edit", $edit, t('Save'));
$this
->assertText("Updated term {$name}.");
// Check that the automatic alias checkbox is now unchecked by default.
$this
->drupalGet("taxonomy/term/{$term->tid}/edit");
$this
->assertNoFieldChecked('edit-path-pathauto');
$this
->assertFieldByName('path[alias]', $manual_alias);
// Submit the term form with the default values.
$this
->drupalPost(NULL, array(), t('Save'));
$this
->assertText("Updated term {$name}.");
// Test that the old (automatic) alias has been deleted and only accessible
// through the new (manual) alias.
$this
->drupalGet($automatic_alias);
$this
->assertResponse(404, 'Term not accessible through automatic alias.');
$this
->drupalGet($manual_alias);
$this
->assertText($name, 'Term accessible through manual alias.');
}