diff options
Diffstat (limited to 'test/lib')
| -rw-r--r-- | test/lib/OAuth2/Storage/Bootstrap.php | 5 | ||||
| -rw-r--r-- | test/lib/OAuth2/Storage/MockRedisClient.php | 63 |
2 files changed, 68 insertions, 0 deletions
diff --git a/test/lib/OAuth2/Storage/Bootstrap.php b/test/lib/OAuth2/Storage/Bootstrap.php index 92ea4b6..be02a60 100644 --- a/test/lib/OAuth2/Storage/Bootstrap.php +++ b/test/lib/OAuth2/Storage/Bootstrap.php @@ -33,6 +33,11 @@ class OAuth2_Storage_Bootstrap return new OAuth2_Storage_Memory(json_decode(file_get_contents(dirname(__FILE__).'/../../../config/storage.json'), true)); } + public function getRedisStorage() + { + return new OAuth2_Storage_Redis(new OAuth2_Storage_MockRedisClient()); + } + public function getMysqlPdo() { if (!$this->mysql) { diff --git a/test/lib/OAuth2/Storage/MockRedisClient.php b/test/lib/OAuth2/Storage/MockRedisClient.php new file mode 100644 index 0000000..9ecaa20 --- /dev/null +++ b/test/lib/OAuth2/Storage/MockRedisClient.php @@ -0,0 +1,63 @@ +<?php +class OAuth2_Storage_MockRedisClient +{ + public function __construct() + { + $data = array( + 'oauth_clients:oauth_test_client' => array( + 'client_id' => 'oauth_test_client', + 'client_secret' => "testpass", + 'redirect_uri' => '', + ), + 'oauth_access_tokens:testtoken' => array( + 'access_token' => 'testtoken', + 'client_id' => "Some Client", + 'user_id' => '', + 'expires' => 0, + 'scope' => '' + ), + 'oauth_authorization_codes:testcode' => array( + 'client_id' => "Some Client", + 'authorization_code' => 'testcode', + 'user_id' => '', + 'redirect_uri' => '', + 'expires' => 0, + 'scope' => '' + ), + 'oauth_users:testuser' => array( + 'username' => 'testuser', + 'password' => "password", + 'first_name' => '', + 'last_name' => '' + ) + ); + foreach ( $data as $name => $val ) { + $data[$name] = json_encode($val); + } + $this->data = $data; + } + + function get($key) + { + return isset($this->data[$key]) ? $this->data[$key] : null; + } + + function set ($key, $value) + { + $this->data[$key] = $value; + return true; + } + + function setex($key, $expires, $value) + { + + $this->data[$key] = $value; + return true; + } + + function expire($key) + { + unset($this->data[$key]); + return true; + } +} |
