public function SystemValidTokenTest::testTokenValidation

7.x system.test public SystemValidTokenTest::testTokenValidation()

Tests invalid invocations of drupal_valid_token() that must return FALSE.

File

drupal-7.x/modules/system/system.test, line 2738
Tests for system.module.

Class

SystemValidTokenTest
Test case for drupal_valid_token().

Code

public function testTokenValidation() {
  // The following checks will throw PHP notices, so we disable error
  // assertions.
  $this->assertErrors = FALSE;
  $this->assertFalse(drupal_valid_token(NULL, new stdClass()), 'Token NULL, value object returns FALSE.');
  $this->assertFalse(drupal_valid_token(0, array()), 'Token 0, value array returns FALSE.');
  $this->assertFalse(drupal_valid_token('', array()), "Token '', value array returns FALSE.");
  $this->assertFalse('' === drupal_get_token(array()), 'Token generation does not return an empty string on invalid parameters.');
  $this->assertErrors = TRUE;

  $this->assertFalse(drupal_valid_token(TRUE, 'foo'), 'Token TRUE, value foo returns FALSE.');
  $this->assertFalse(drupal_valid_token(0, 'foo'), 'Token 0, value foo returns FALSE.');
}