diff options
author | tailor <me@arty.name> | 2008-02-02 19:47:09 +0000 |
---|---|---|
committer | tailor <me@arty.name> | 2008-02-02 19:47:09 +0000 |
commit | ae4e3f1cf0c475373faef7fc9df5cf2c865affcd (patch) | |
tree | 860e7ff1806c8a74410cb8ed100ebd8ad1e8afc0 /Tests/Auth/OpenID/StoreTest.php | |
parent | 20ab579497a3df8f81a0bfb2607238a31b0b2b1b (diff) | |
download | php-openid-ae4e3f1cf0c475373faef7fc9df5cf2c865affcd.zip php-openid-ae4e3f1cf0c475373faef7fc9df5cf2c865affcd.tar.gz php-openid-ae4e3f1cf0c475373faef7fc9df5cf2c865affcd.tar.bz2 |
[project @ Implementation of Memcached storage in PHP. This patch also includes supportsCleanup() function for OpenIDStore interface, as memcache doesn't allow ]
enumeration of all keys used (and cleans itself).
Also included test for memcached storage and support for supportsCleanup() in test functions.
Diffstat (limited to 'Tests/Auth/OpenID/StoreTest.php')
-rw-r--r-- | Tests/Auth/OpenID/StoreTest.php | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/Tests/Auth/OpenID/StoreTest.php b/Tests/Auth/OpenID/StoreTest.php index aabb3a0..0848c0b 100644 --- a/Tests/Auth/OpenID/StoreTest.php +++ b/Tests/Auth/OpenID/StoreTest.php @@ -47,6 +47,12 @@ global $_Auth_OpenID_db_test_host; $_Auth_OpenID_db_test_host = 'dbtest'; /** + * This is the host where the Memcache stores should save data + */ +global $_Auth_OpenID_memcache_test_host; +$_Auth_OpenID_memcache_test_host = 'localhost'; + +/** * Generate a sufficently unique database name so many hosts can run * SQL store tests on the server at the same time and not step on each * other. @@ -291,6 +297,10 @@ explicitly'); $assocExpired1 = $this->genAssoc($now, -7200, 3600); $assocExpired2 = $this->genAssoc($now, -7200, 3600); + if (!$store->supportsCleanup()) { + return; + } + $store->cleanupAssociations(); $store->storeAssociation($server_url . '1', $assocValid1); $store->storeAssociation($server_url . '1', $assocExpired1); @@ -337,8 +347,10 @@ explicitly'); } function _testNonceCleanup(&$store) { - global $Auth_OpenID_SKEW; - + if (!$store->supportsCleanup()) { + return; + } + $server_url = 'http://www.myopenid.com/openid'; $now = time(); @@ -419,6 +431,37 @@ explicitly'); $store->destroy(); } + function test_memcachedstore() + { + // If the memcache extension isn't loaded or loadable, succeed + // because we can't run the test. + if (!(extension_loaded('memcache') || + @dl('memcache.so') || + @dl('php_memcache.dll'))) { + print "Warning: not testing Memcache store"; + $this->pass(); + return; + } + + global $_Auth_OpenID_memcache_test_host; + + $memcached = new Memcache(); + if (!$memcached->connect($_Auth_OpenID_memcache_test_host)) { + $this->fail("Couldn't connect to Memcache server at '". + $_Auth_OpenID_memcache_test_host); + } + + require_once 'Auth/OpenID/MemcachedStore.php'; + + $store = new Auth_OpenID_MemcachedStore($memcached); + + $this->_testStore($store); + $this->_testNonce($store); + $this->_testNonceCleanup($store); + + $memcached->close(); + } + function test_postgresqlstore() { // If the postgres extension isn't loaded or loadable, succeed |