You are here

function PathautoTaxonomyTokenTestCase::testCatTokens in Pathauto 6

Same name and namespace in other branches
  1. 6.2 pathauto.test \PathautoTaxonomyTokenTestCase::testCatTokens()

Test the [catpath] and [catalias] tokens.

File

./pathauto.test, line 769
Functionality tests for Pathauto.

Class

PathautoTaxonomyTokenTestCase

Code

function testCatTokens() {
  $term1 = $this
    ->addTerm($this->vocab);
  $tokens = array(
    'catpath' => $term1->name,
    'catalias' => "category/{$this->vocab->name}/{$term1->name}",
  );
  $this
    ->assertTokens('taxonomy', $term1, $tokens);

  // Change the term name to check that the alias is also changed.
  // Regression test for http://drupal.org/node/822174.
  $term1->oldname = $term1->name;
  $term1->name = drupal_strtolower($this
    ->randomName());
  $form_values = (array) $term1;
  taxonomy_save_term($form_values);
  $tokens = array(
    'catpath' => $term1->name,
  );
  $this
    ->assertTokens('taxonomy', $term1, $tokens);
  $term2 = $this
    ->addTerm($this->vocab, array(
    'parent' => $term1->tid,
  ));
  $tokens = array(
    'catpath' => "{$term1->name}/{$term2->name}",
    'catalias' => "category/{$this->vocab->name}/{$term2->name}",
  );
  $this
    ->assertTokens('taxonomy', $term2, $tokens);
  $term3 = $this
    ->addTerm($this->vocab, array(
    'parent' => $term2->tid,
    'name' => ' foo/bar fer|zle ',
  ));
  $tokens = array(
    'catpath' => "{$term1->name}/{$term2->name}/foobar-ferzle",
    'catalias' => "category/{$this->vocab->name}/foobar-ferzle",
  );
  $this
    ->assertTokens('taxonomy', $term3, $tokens);
}