You are here

function PathautoTaxonomyTokenTestCase::testTermTokens in Pathauto 6

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

Test the [termpath] token.

File

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

Class

PathautoTaxonomyTokenTestCase

Code

function testTermTokens() {
  $term1 = $this
    ->addTerm($this->vocab, array(
    'weight' => 5,
  ));
  $term2 = $this
    ->addTerm($this->vocab, array(
    'weight' => -5,
  ));
  $term3 = $this
    ->addTerm($this->vocab, array(
    'weight' => 0,
  ));
  $node = $this
    ->drupalCreateNode(array(
    'type' => 'story',
    'taxonomy' => array(
      $term1->tid,
      $term2->tid,
      $term3->tid,
    ),
  ));
  $tokens = array(
    'termpath' => $term2->name,
    'termalias' => "category/{$this->vocab->name}/{$term2->name}",
  );
  $this
    ->assertTokens('node', $node, $tokens);
  $this
    ->assertToken('node', $node, 'termpath', $term2->name);
  $this
    ->assertToken('node', $node, 'termalias', "category/{$this->vocab->name}/{$term2->name}");
  $non_term_node = $this
    ->drupalCreateNode(array(
    'type' => 'story',
  ));
  $tokens = array(
    'termpath' => '',
    'termalias' => '',
  );
  $this
    ->assertTokens('node', $non_term_node, $tokens);
}