1 token.test | TokenTaxonomyTestCase::testTaxonomyTokens() |
Test the additional taxonomy term tokens.
File
- core/
modules/ simpletest/ tests/ token.test, line 645 - Test integration for the token module.
Class
Code
function testTaxonomyTokens() {
$root_term = $this->addTerm($this->vocab, array('name' => 'Root term', 'path' => array('alias' => 'root-term', 'auto' => FALSE)));
$tokens = array(
'url' => url("taxonomy/term/{$root_term->tid}", array('absolute' => TRUE)),
'url:absolute' => url("taxonomy/term/{$root_term->tid}", array('absolute' => TRUE)),
'url:relative' => url("taxonomy/term/{$root_term->tid}", array('absolute' => FALSE)),
'url:path' => 'root-term',
'url:unaliased:path' => "taxonomy/term/{$root_term->tid}",
'edit-url' => url("taxonomy/term/{$root_term->tid}/edit", array('absolute' => TRUE)),
'parents' => NULL,
'parents:count' => NULL,
'parents:keys' => NULL,
'root' => NULL,
// Deprecated tokens
'url:alias' => 'root-term',
);
$this->assertTokens('term', array('term' => $root_term), $tokens);
$parent_term = $this->addTerm($this->vocab, array('name' => 'Parent term', 'parent' => array($root_term->tid), 'path' => array('auto' => FALSE)));
$tokens = array(
'url' => url("taxonomy/term/{$parent_term->tid}", array('absolute' => TRUE)),
'url:absolute' => url("taxonomy/term/{$parent_term->tid}", array('absolute' => TRUE)),
'url:relative' => url("taxonomy/term/{$parent_term->tid}", array('absolute' => FALSE)),
'url:path' => "taxonomy/term/{$parent_term->tid}",
'url:unaliased:path' => "taxonomy/term/{$parent_term->tid}",
'edit-url' => url("taxonomy/term/{$parent_term->tid}/edit", array('absolute' => TRUE)),
'parents' => 'Root term',
'parents:count' => 1,
'parents:keys' => $root_term->tid,
'root' => check_plain($root_term->name),
'root:tid' => $root_term->tid,
// Deprecated tokens
'url:alias' => "taxonomy/term/{$parent_term->tid}",
);
$this->assertTokens('term', array('term' => $parent_term), $tokens);
$term = $this->addTerm($this->vocab, array('name' => 'Test term', 'parent' => array($parent_term->tid)));
$tokens = array(
'parents' => 'Root term, Parent term',
'parents:count' => 2,
'parents:keys' => implode(', ', array($root_term->tid, $parent_term->tid)),
);
$this->assertTokens('term', array('term' => $term), $tokens);
}