function TokenCurrentPageTestCase::testCurrentPageTokens in Token 7
Same name and namespace in other branches
- 6 token.test \TokenCurrentPageTestCase::testCurrentPageTokens()
File
- ./
token.test, line 869 - Test integration for the token module.
Class
- TokenCurrentPageTestCase
- Test the current page tokens.
Code
function testCurrentPageTokens() {
$tokens = array(
'[current-page:title]' => t('Welcome to @site-name', array(
'@site-name' => variable_get('site_name', 'Drupal'),
)),
'[current-page:url]' => url('node', array(
'absolute' => TRUE,
)),
'[current-page:url:absolute]' => url('node', array(
'absolute' => TRUE,
)),
'[current-page:url:relative]' => url('node', array(
'absolute' => FALSE,
)),
'[current-page:url:path]' => 'node',
'[current-page:url:args:value:0]' => 'node',
'[current-page:url:args:value:1]' => NULL,
'[current-page:url:unaliased]' => url('node', array(
'absolute' => TRUE,
'alias' => TRUE,
)),
'[current-page:page-number]' => 1,
'[current-page:query:foo]' => NULL,
'[current-page:query:bar]' => NULL,
'[current-page:query:q]' => 'node',
// Deprecated tokens
'[current-page:arg:0]' => 'node',
'[current-page:arg:1]' => NULL,
);
$this
->assertPageTokens('', $tokens);
$node = $this
->drupalCreateNode(array(
'title' => 'Node title',
'path' => array(
'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/1',
// Deprecated tokens
'[current-page:arg:0]' => 'node',
'[current-page:arg:1]' => 1,
'[current-page:arg:2]' => NULL,
);
$this
->assertPageTokens("node/{$node->nid}", $tokens, array(), array(
'url_options' => array(
'query' => array(
'foo' => 'bar',
),
),
));
}