You are here

function RestfulTokenAuthenticationTestCase::testTokenInvalidating in RESTful 7

Same name and namespace in other branches
  1. 7.2 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 27
Contains RestfulTokenAuthenticationTestCase.

Class

RestfulTokenAuthenticationTestCase
@file Contains RestfulTokenAuthenticationTestCase.

Code

function testTokenInvalidating() {
  $this
    ->drupalLogin($this->user);
  $handler = restful_get_restful_handler('access_token');

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

  // 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.');
}