summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2006-01-05 00:08:33 +0000
committertailor <cygnus@janrain.com>2006-01-05 00:08:33 +0000
commitc99b2d4da247de92d8a3c3763b675dde03be1eb7 (patch)
tree208cfe8d9e4702e836843be5c28699a63a9c11e2
parent7019fdc4cb9fa51b8bcb6492f5886e7bbe069db3 (diff)
downloadphp-openid-c99b2d4da247de92d8a3c3763b675dde03be1eb7.zip
php-openid-c99b2d4da247de92d8a3c3763b675dde03be1eb7.tar.gz
php-openid-c99b2d4da247de92d8a3c3763b675dde03be1eb7.tar.bz2
[project @ Fixed brace style]
-rw-r--r--Tests/Net/OpenID/StoreTest.php69
1 files changed, 34 insertions, 35 deletions
diff --git a/Tests/Net/OpenID/StoreTest.php b/Tests/Net/OpenID/StoreTest.php
index 78253ac..e84826b 100644
--- a/Tests/Net/OpenID/StoreTest.php
+++ b/Tests/Net/OpenID/StoreTest.php
@@ -3,7 +3,8 @@
require_once('Net/OpenID/Association.php');
require_once('Net/OpenID/CryptUtil.php');
-function Net_OpenID_rmtree($dir) {
+function Net_OpenID_rmtree($dir)
+{
if ($dir[strlen($dir) - 1] != DIRECTORY_SEPARATOR) {
$dir .= DIRECTORY_SEPARATOR;
}
@@ -38,7 +39,8 @@ function Net_OpenID_rmtree($dir) {
class Tests_Net_OpenID_StoreTest extends PHPUnit_TestCase {
- function setUp() {
+ function setUp()
+ {
$this->letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$this->digits = "0123456789";
$this->punct = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
@@ -46,11 +48,13 @@ class Tests_Net_OpenID_StoreTest extends PHPUnit_TestCase {
$this->allowed_handle = $this->letters . $this->digits . $this->punct;
}
- function generateNonce() {
+ function generateNonce()
+ {
return Net_OpenID_CryptUtil::randomString(8, $this->allowed_nonce);
}
- function genAssoc($now, $issued = 0, $lifetime = 600) {
+ function genAssoc($now, $issued = 0, $lifetime = 600)
+ {
$sec = call_user_func(array('Net_OpenID_CryptUtil', 'randomString'),
20);
$hdl = Net_OpenID_CryptUtil::randomString(128, $this->allowed_handle);
@@ -66,7 +70,8 @@ class Tests_Net_OpenID_StoreTest extends PHPUnit_TestCase {
*
* OpenIDStore -> NoneType
*/
- function _testStore($store) {
+ function _testStore($store)
+ {
// Association functions
$now = time();
@@ -74,33 +79,25 @@ class Tests_Net_OpenID_StoreTest extends PHPUnit_TestCase {
$server_url = 'http://www.myopenid.com/openid';
function checkRetrieve(&$store, $url,
- $handle = null, $expected = null) {
- $retrieved_assoc = $store->getAssociation($url, $handle);
- if (($expected === null) || ($store->isDumb())) {
- assert($retrieved_assoc === null);
- } else {
- assert($retrieved_assoc == $expected);
- /**
- * The following test doesn't mean the same thing in
- * PHP that it does in Python.
-
- if ($retrieved_assoc === $expected) {
- print 'Unexpected: retrieved a reference to the expected ' .
- 'value instead of a new object\n';
+ $handle = null, $expected = null)
+ {
+ $retrieved_assoc = $store->getAssociation($url, $handle);
+ if (($expected === null) || ($store->isDumb())) {
+ assert($retrieved_assoc === null);
+ } else {
+ assert($retrieved_assoc == $expected);
+ assert($retrieved_assoc->handle == $expected->handle);
+ assert($retrieved_assoc->secret == $expected->secret);
}
-
- */
- assert($retrieved_assoc->handle == $expected->handle);
- assert($retrieved_assoc->secret == $expected->secret);
}
- }
- function checkRemove(&$store, $url, $handle, $expected) {
- $present = $store->removeAssociation($url, $handle);
- $expectedPresent = (!$store->isDumb() && $expected);
- assert((!$expectedPresent && !$present) ||
- ($expectedPresent && $present));
- }
+ function checkRemove(&$store, $url, $handle, $expected)
+ {
+ $present = $store->removeAssociation($url, $handle);
+ $expectedPresent = (!$store->isDumb() && $expected);
+ assert((!$expectedPresent && !$present) ||
+ ($expectedPresent && $present));
+ }
$assoc = $this->genAssoc($now);
@@ -187,11 +184,12 @@ class Tests_Net_OpenID_StoreTest extends PHPUnit_TestCase {
// Nonce functions
- function testUseNonce($store, $nonce, $expected) {
- $actual = $store->useNonce($nonce);
- $expected = $store->isDumb() || $expected;
- assert(($actual && $expected) || (!$actual && !$expected));
- }
+ function testUseNonce($store, $nonce, $expected)
+ {
+ $actual = $store->useNonce($nonce);
+ $expected = $store->isDumb() || $expected;
+ assert(($actual && $expected) || (!$actual && !$expected));
+ }
// Random nonce (not in store)
$nonce1 = $this->generateNonce();
@@ -223,7 +221,8 @@ class Tests_Net_OpenID_StoreTest extends PHPUnit_TestCase {
assert(strlen($key) == $store->AUTH_KEY_LEN);
}
- function test_filestore() {
+ function test_filestore()
+ {
require_once('Net/OpenID/Store/FileStore.php');
$temp_dir = Net_OpenID_mkdtemp('/tmp');