diff options
author | Joseph Warner <hardolaf@hardolaf.com> | 2013-07-29 14:32:11 -0400 |
---|---|---|
committer | Joseph Warner <hardolaf@hardolaf.com> | 2013-07-29 14:32:29 -0400 |
commit | 17d774af8ed8895c0f9b77d57c218f0d01d761e3 (patch) | |
tree | a9386a8e56c71d320b644a87663131cd0606bfa5 /tests/auth/provider_oauth_token_storage_test.php | |
parent | 9eb4d55e8215d93256ae4ea241d40efa1d5b5854 (diff) | |
download | forums-17d774af8ed8895c0f9b77d57c218f0d01d761e3.tar forums-17d774af8ed8895c0f9b77d57c218f0d01d761e3.tar.gz forums-17d774af8ed8895c0f9b77d57c218f0d01d761e3.tar.bz2 forums-17d774af8ed8895c0f9b77d57c218f0d01d761e3.tar.xz forums-17d774af8ed8895c0f9b77d57c218f0d01d761e3.zip |
[feature/oauth] Add tests for the new token methods
PHPBB3-11673
Diffstat (limited to 'tests/auth/provider_oauth_token_storage_test.php')
-rw-r--r-- | tests/auth/provider_oauth_token_storage_test.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/auth/provider_oauth_token_storage_test.php b/tests/auth/provider_oauth_token_storage_test.php index 789b642ed5..a0a8a36f47 100644 --- a/tests/auth/provider_oauth_token_storage_test.php +++ b/tests/auth/provider_oauth_token_storage_test.php @@ -78,6 +78,32 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c $this->assertEquals($token, $stored_token); } + /** + * @dataProvider retrieveAccessToken_data + */ + public function test_retrieve_access_token_by_session($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->retrieve_access_token_by_session(); + $this->assertEquals($token, $stored_token); + } + + public function test_storeAccessToken() { $token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param') ); @@ -116,6 +142,20 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c $this->assertEquals($expected, $has_access_token); } + /** + * @dataProvider hasAccessToken_data + */ + public function test_has_access_token_by_session($token, $expected) + { + if ($token) + { + $this->token_storage->storeAccessToken($token); + } + + $has_access_token = $this->token_storage->has_access_token_by_session(); + $this->assertEquals($expected, $has_access_token); + } + public function test_clearToken() { $token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param') ); |