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