public function OAuth2ServerStorageTestCase::testSetRefreshToken in OAuth2 Server 7
File
- tests/
oauth2_server.test, line 1011 - OAuth2 tests.
Class
Code
public function testSetRefreshToken() {
$user = $this
->drupalCreateUser(array(
'use oauth2 server',
));
$token = $this->storage
->getRefreshToken('refreshtoken');
$this
->assertFalse($token, 'Trying to load a nonexistent token is unsuccessful.');
$expires = time() + 20;
$success = $this->storage
->setRefreshToken('refreshtoken', $this->client_key, $user->uid, $expires);
$this
->assertTrue($success, 'A new refresh token has been successfully created.');
// Verify the return format of getRefreshToken().
$token = $this->storage
->getRefreshToken('refreshtoken');
$this
->assertTrue($token, 'A refresh token was successfully returned.');
$this
->assertTrue(array_key_exists('refresh_token', $token), 'The "refresh_token" value is present in the token array.');
$this
->assertTrue(array_key_exists('client_id', $token), 'The "client_id" value is present in the token array.');
$this
->assertTrue(array_key_exists('user_id', $token), 'The "user_id" value is present in the token array.');
$this
->assertTrue(array_key_exists('expires', $token), 'The "expires" value is present in the token array.');
$this
->assertEqual($token['refresh_token'], 'refreshtoken', 'The "refresh_token" key has the expected value.');
$this
->assertEqual($token['client_id'], $this->client_key, 'The "client_id" key has the expected value.');
$this
->assertEqual($token['user_id'], $user->uid, 'The "user_id" key has the expected value.');
$this
->assertEqual($token['expires'], $expires, 'The "expires" key has the expected value.');
}