aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auth/provider_oauth_token_storage_test.php
diff options
context:
space:
mode:
authorJoseph Warner <hardolaf@hardolaf.com>2013-07-24 15:46:08 -0400
committerJoseph Warner <hardolaf@hardolaf.com>2013-07-24 15:46:23 -0400
commita72951b79902d6512a1e769e23c394395e930870 (patch)
tree4946d425b0a6cfc88247602e2d722b3f9935ba4f /tests/auth/provider_oauth_token_storage_test.php
parent0055ab7ad05258b6739f505515aaa04dd630d1cb (diff)
downloadforums-a72951b79902d6512a1e769e23c394395e930870.tar
forums-a72951b79902d6512a1e769e23c394395e930870.tar.gz
forums-a72951b79902d6512a1e769e23c394395e930870.tar.bz2
forums-a72951b79902d6512a1e769e23c394395e930870.tar.xz
forums-a72951b79902d6512a1e769e23c394395e930870.zip
[feature/oauth] Token Storage retrieve access token test
PHPBB3-11673
Diffstat (limited to 'tests/auth/provider_oauth_token_storage_test.php')
-rw-r--r--tests/auth/provider_oauth_token_storage_test.php39
1 files changed, 35 insertions, 4 deletions
diff --git a/tests/auth/provider_oauth_token_storage_test.php b/tests/auth/provider_oauth_token_storage_test.php
index ba3a8a65f5..e86d1359d9 100644
--- a/tests/auth/provider_oauth_token_storage_test.php
+++ b/tests/auth/provider_oauth_token_storage_test.php
@@ -12,8 +12,10 @@ use OAuth\OAuth2\Token\StdOAuth2Token;
class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_case
{
protected $db;
+ protected $service_name;
protected $session_id;
protected $token_storage;
+ protected $token_storage_table;
protected $user;
protected function setup()
@@ -24,8 +26,8 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c
$this->db = $this->new_dbal();
$this->user = $this->getMock('phpbb_user');
- $service_name = 'auth.provider.oauth.service.testing';
- $token_storage_table = 'phpbb_oauth_tokens';
+ $this->service_name = 'auth.provider.oauth.service.testing';
+ $this->token_storage_table = 'phpbb_oauth_tokens';
// Give the user a session_id that we will remember
$this->session_id = '12345';
@@ -34,7 +36,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c
// Set the user id to anonymous
$this->user->data['user_id'] = ANONYMOUS;
- $this->token_storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $service_name, $token_storage_table);
+ $this->token_storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $this->service_name, $this->token_storage_table);
}
public function getDataSet()
@@ -42,9 +44,38 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/oauth_tokens.xml');
}
- public function test_retrieveAccessToken()
+ public static function retrieveAccessToken_data()
{
+ return array(
+ array(null, new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')), null),
+ array(new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param') ), null, null),
+ array(null, null, 'OAuth\Common\Storage\Exception\TokenNotFoundException'),
+ );
+ }
+ /**
+ * @dataProvider retrieveAccessToken_data
+ */
+ public function test_retrieveAccessToken($cache_token, $db_token, $exception)
+ {
+ if ($db_token)
+ {
+ $temp_storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $this->service_name, $this->token_storage_table);
+ $temp_storage->storeAccessToken($db_token);
+ unset($temp_storage);
+ $token = $db_token;
+ }
+
+ if ($cache_token)
+ {
+ $this->token_storage->storeAccessToken($cache_token);
+ $token = $cache_token;
+ }
+
+ $this->setExpectedException($exception);
+
+ $stored_token = $this->token_storage->retrieveAccessToken();
+ $this->assertEquals($token, $stored_token);
}
public function test_storeAccessToken()