diff options
author | Joseph Warner <hardolaf@hardolaf.com> | 2013-08-14 23:42:50 -0400 |
---|---|---|
committer | Joseph Warner <hardolaf@hardolaf.com> | 2013-08-14 23:43:07 -0400 |
commit | 2bf97a01ce24d7e8fc789c4e29e8dd4d3b2780a2 (patch) | |
tree | f6fcc0aa4cf38be74e5ddff34d077ded8b092f84 /tests/auth | |
parent | [feature/oauth] Fix template not refreshing issue (diff) | |
download | phpbb-2bf97a01ce24d7e8fc789c4e29e8dd4d3b2780a2.tar.gz phpbb-2bf97a01ce24d7e8fc789c4e29e8dd4d3b2780a2.tar.bz2 phpbb-2bf97a01ce24d7e8fc789c4e29e8dd4d3b2780a2.zip |
[feature/oauth] Refactor test to provide for easier to read tests
PHPBB3-11673
Diffstat (limited to 'tests/auth')
-rw-r--r-- | tests/auth/provider_oauth_token_storage_test.php | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/tests/auth/provider_oauth_token_storage_test.php b/tests/auth/provider_oauth_token_storage_test.php index a0a8a36f47..f47f3652b6 100644 --- a/tests/auth/provider_oauth_token_storage_test.php +++ b/tests/auth/provider_oauth_token_storage_test.php @@ -47,25 +47,16 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c 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'), + array(new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')), null), + array(null, 'OAuth\Common\Storage\Exception\TokenNotFoundException'), ); } /** * @dataProvider retrieveAccessToken_data */ - public function test_retrieveAccessToken($cache_token, $db_token, $exception) + public function test_retrieveAccessToken($cache_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); @@ -78,6 +69,20 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c $this->assertEquals($token, $stored_token); } + public function test_retrieveAccessToken_from_db() + { + $expected_token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES); + + // Store a token in the database + $temp_storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $this->service_name, $this->token_storage_table); + $temp_storage->storeAccessToken($expected_token); + unset($temp_storage); + + // Test to see if the token can be retrieved + $stored_token = $this->token_storage->retrieveAccessToken(); + $this->assertEquals($expected_token, $stored_token); + } + /** * @dataProvider retrieveAccessToken_data */ |