Index: token.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/token.test,v
retrieving revision 1.25
diff -u -p -r1.25 token.test
--- token.test	16 Nov 2010 00:08:50 -0000	1.25
+++ token.test	16 Nov 2010 02:27:45 -0000
@@ -483,3 +483,62 @@ class TokenProfileTestCase extends Token
     return $saved_field;
   }
 }
+
+/**
+ * Test the current page tokens.
+ */
+class TokenCurrentPageTestCase extends TokenTestHelper {
+  private $account;
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Current page token tests',
+      'description' => 'Test the [current-page:*] tokens.',
+      'group' => 'Token',
+    );
+  }
+
+  function setUp() {
+    parent::setUp(array('token_test'));
+  }
+
+  function assertPageTokens($url, array $tokens, array $data = array(), array $options = array()) {
+    if (empty($tokens)) {
+      return TRUE;
+    }
+
+    $token_page_tokens = array(
+      'tokens' => $tokens,
+      'data' => $data,
+      'options' => $options,
+    );
+    variable_set('token_page_tokens', $token_page_tokens);
+
+    $this->drupalGet($url, $options);
+    $this->refreshVariables();
+    $result = variable_get('token_page_tokens');
+
+    if (!isset($result['values']) || !is_array($result['values'])) {
+      return $this->fail('Failed to generate tokens.');
+    }
+
+    foreach ($tokens as $token => $expected) {
+      if (isset($expected)) {
+        $this->assertIdentical($result['values'][$token], (string) $expected, t("Token value for @token was '@actual', expected value '@expected'.", array('@token' => $token, '@actual' => $result['values'][$token], '@expected' => $expected)));
+      }
+      else {
+        $this->assertTrue(!isset($result['values'][$token]), t("Token value for @token was not generated.", array('@token' => $token)));
+      }
+    }
+  }
+
+  function testCurrentPageTokens() {
+    $tokens =  array(
+      '[current-page:title]' => 'Welcome to Drupal',
+      '[current-page:path]' => 'node',
+      '[current-page:url]' => url('node', array('absolute' => TRUE)),
+      '[current-page:page-number]' => 1,
+    );
+    $this->assertPageTokens('node', $tokens);
+  }
+}
Index: tests/token_test.info
===================================================================
RCS file: tests/token_test.info
diff -N tests/token_test.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/token_test.info	16 Nov 2010 02:27:45 -0000
@@ -0,0 +1,6 @@
+name = Token Test
+description = Testing module for token functionality.
+core = 7.x
+package = Testing
+hidden = TRUE
+files[] = token_test.module
Index: tests/token_test.module
===================================================================
RCS file: tests/token_test.module
diff -N tests/token_test.module
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/token_test.module	16 Nov 2010 02:27:45 -0000
@@ -0,0 +1,14 @@
+<?php
+
+/**
+ * Implements hook_exit().
+ */
+function token_test_exit() {
+  if ($debug = variable_get('token_page_tokens', array())) {
+    $debug += array('tokens' => array(), 'data' => array(), 'options' => array());
+    foreach (array_keys($debug['tokens']) as $token) {
+      $debug['values'][$token] = token_replace($token, $debug['data'], $debug['options']);
+    }
+    variable_set('token_page_tokens', $debug);
+  }
+}
