1 path_pattern.test PathPatternFunctionalTestCase::testTermEditing()

Basic functional testing of Path automatic aliases with taxonomy terms.


core/modules/path/tests/path_pattern.test, line 633
Functionality tests for automatic path generation.


Test basic Path automatic URL alias functionality.


function testTermEditing() {

  // 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->assertFieldByName('path[alias]', $automatic_alias, 'Generated URL alias visible in the path URL alias field.');

  // Check whether the URL alias actually works.
  $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->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->assertResponse(404, 'Term not accessible through automatic alias.');
  $this->assertText($name, 'Term accessible through manual URL alias.');