1 token.test | TokenCurrentPageTestCase::testCurrentPageTokens() |
File
- core/
modules/ simpletest/ tests/ token.test, line 864 - Test integration for the token module.
Class
- TokenCurrentPageTestCase
- Test the current page tokens.
Code
function testCurrentPageTokens() {
$tokens = array(
'[current-page:title]' => t('Home', array('@site-name' => config_get('system.core', 'site_name'))),
'[current-page:url]' => url('home', array('absolute' => TRUE)),
'[current-page:url:absolute]' => url('home', array('absolute' => TRUE)),
'[current-page:url:relative]' => url('home', array('absolute' => FALSE)),
'[current-page:url:path]' => 'home',
'[current-page:url:args:value:0]' => 'home',
'[current-page:url:args:value:1]' => NULL,
'[current-page:url:unaliased]' => url('home', array('absolute' => TRUE, 'alias' => TRUE)),
'[current-page:page-number]' => 1,
'[current-page:query:foo]' => NULL,
'[current-page:query:bar]' => NULL,
'[current-page:query:q]' => 'home',
// Deprecated tokens
'[current-page:arg:0]' => 'home',
'[current-page:arg:1]' => NULL,
);
$this->assertPageTokens('', $tokens);
$node = $this->backdropCreateNode(array(
'title' => 'Node title',
'path' => array(
'auto' => FALSE,
'alias' => 'node-alias',
),
));
$tokens = array(
'[current-page:title]' => 'Node title',
'[current-page:url]' => url("node/{$node->nid}", array('absolute' => TRUE)),
'[current-page:url:absolute]' => url("node/{$node->nid}", array('absolute' => TRUE)),
'[current-page:url:relative]' => url("node/{$node->nid}", array('absolute' => FALSE)),
'[current-page:url:alias]' => 'node-alias',
'[current-page:url:args:value:0]' => 'node-alias',
'[current-page:url:args:value:1]' => NULL,
'[current-page:url:unaliased]' => url("node/{$node->nid}", array('absolute' => TRUE, 'alias' => TRUE)),
'[current-page:url:unaliased:args:value:0]' => 'node',
'[current-page:url:unaliased:args:value:1]' => $node->nid,
'[current-page:url:unaliased:args:value:2]' => NULL,
'[current-page:page-number]' => 1,
'[current-page:query:foo]' => 'bar',
'[current-page:query:bar]' => NULL,
'[current-page:query:q]' => 'node/' . $node->nid,
// Deprecated tokens
'[current-page:arg:0]' => 'node',
'[current-page:arg:1]' => $node->nid,
'[current-page:arg:2]' => NULL,
);
$this->assertPageTokens("node/{$node->nid}", $tokens, array(), array('url_options' => array('query' => array('foo' => 'bar'))));
}