You are here

function RestfulTokenAuthenticationTestCase::testTokenInvalidating in RESTful 7.2

Same name and namespace in other branches
  1. 7 modules/restful_token_auth/tests/RestfulTokenAuthenticationTestCase.test \RestfulTokenAuthenticationTestCase::testTokenInvalidating()

Testing the user's access token will be invalidate one the user is blocked.

File

modules/restful_token_auth/tests/RestfulTokenAuthenticationTestCase.test, line 37
Contains RestfulTokenAuthenticationTestCase.

Class

RestfulTokenAuthenticationTestCase

Code

function testTokenInvalidating() {
  $this
    ->drupalLogin($this->user);
  $resource_manager = restful()
    ->getResourceManager();
  $handler = $resource_manager
    ->getPlugin('access_token:1.0');

  // Generating token.
  $handler
    ->doGet();

  // Blocking the user.
  user_save($this->user, array(
    'status' => FALSE,
  ));

  // Verify the token removed.
  $query = new EntityFieldQuery();
  $result = $query
    ->entityCondition('entity_type', 'restful_token_auth')
    ->propertyCondition('uid', $this->user->uid)
    ->execute();
  $this
    ->assertTrue(empty($result), 'The access tokens invalidated when blocking the user.');
}