aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoseph Warner <hardolaf@hardolaf.com>2013-07-24 15:51:54 -0400
committerJoseph Warner <hardolaf@hardolaf.com>2013-07-24 15:52:24 -0400
commite2ea641cc4301d7fb591da88430b640cc41022c0 (patch)
treee985d8c47472ceeb8af174c265031516dbc4b3ea /tests
parent229d4f2fd6e067f95a5766c90e34578d1baaddb8 (diff)
downloadforums-e2ea641cc4301d7fb591da88430b640cc41022c0.tar
forums-e2ea641cc4301d7fb591da88430b640cc41022c0.tar.gz
forums-e2ea641cc4301d7fb591da88430b640cc41022c0.tar.bz2
forums-e2ea641cc4301d7fb591da88430b640cc41022c0.tar.xz
forums-e2ea641cc4301d7fb591da88430b640cc41022c0.zip
[feature/oauth] Token storage test set_user_id()
PHPBB3-11673
Diffstat (limited to 'tests')
-rw-r--r--tests/auth/provider_oauth_token_storage_test.php26
1 files changed, 20 insertions, 6 deletions
diff --git a/tests/auth/provider_oauth_token_storage_test.php b/tests/auth/provider_oauth_token_storage_test.php
index 2a161bb9cc..fc4a9af741 100644
--- a/tests/auth/provider_oauth_token_storage_test.php
+++ b/tests/auth/provider_oauth_token_storage_test.php
@@ -88,12 +88,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c
$this->assertEquals( 'param', $extraParams['extra'] );
$this->assertEquals( 'access', $this->token_storage->retrieveAccessToken()->getAccessToken() );
- // Test that the token is stored in the database
- $sql = 'SELECT oauth_token FROM phpbb_oauth_tokens
- WHERE session_id = \'' . $this->session_id . '\'';
- $result = $this->db->sql_query($sql);
- $row = $this->db->sql_fetchrow($result);
- $this->db->sql_freeresult($result);
+ $row = $this->get_token_row_by_session_id($this->session_id);
// The token is serialized before stored in the database
$this->assertEquals(serialize($token), $row['oauth_token']);
@@ -111,6 +106,25 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c
public function test_set_user_id()
{
+ $token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param') );
+ $this->token_storage->storeAccessToken($token);
+
+ $new_user_id = ANONYMOUS + 1;
+ $this->token_storage->set_user_id($new_user_id);
+
+ $row = $this->get_token_row_by_session_id($this->session_id);
+ $this->assertEquals($new_user_id, $row['user_id']);
+ }
+
+ protected function get_token_row_by_session_id($session_id)
+ {
+ // Test that the token is stored in the database
+ $sql = 'SELECT * FROM phpbb_oauth_tokens
+ WHERE session_id = \'' . $session_id . '\'';
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+ return $row;
}
} \ No newline at end of file