summaryrefslogtreecommitdiffstats
path: root/Tests/Auth/OpenID/TestUtil.php
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/Auth/OpenID/TestUtil.php')
-rw-r--r--Tests/Auth/OpenID/TestUtil.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/Tests/Auth/OpenID/TestUtil.php b/Tests/Auth/OpenID/TestUtil.php
index 8358160..54b110d 100644
--- a/Tests/Auth/OpenID/TestUtil.php
+++ b/Tests/Auth/OpenID/TestUtil.php
@@ -4,6 +4,8 @@
* Utilites for test functions
*/
+require_once 'PHPUnit.php';
+
function Tests_Auth_OpenID_datafile($name, $reader)
{
$path = dirname(realpath(__FILE__));
@@ -26,3 +28,35 @@ function Tests_Auth_OpenID_readlines($name)
{
return Tests_Auth_OpenID_datafile($name, 'file');
}
+
+class OpenIDTestMixin extends PHPUnit_TestCase {
+ function failUnlessOpenIDValueEquals($msg, $key, $expected, $ns=null)
+ {
+ if ($ns === null) {
+ $ns = Auth_OpenID_OPENID_NS;
+ }
+
+ $actual = $msg->getArg($ns, $key);
+ $error_format = 'Wrong value for openid.%s: expected=%s, actual=%s';
+ $error_message = sprintf($error_format,
+ $key, $expected, $actual);
+
+ $this->assertEquals($expected, $actual, $error_message);
+ }
+
+ function failIfOpenIDKeyExists($msg, $key, $ns=null)
+ {
+ if ($ns === null) {
+ $ns = Auth_OpenID_OPENID_NS;
+ }
+
+ $actual = $msg->getArg($ns, $key);
+ $error_message = sprintf('openid.%s unexpectedly present: %s',
+ $key, $actual);
+
+ $this->assertFalse($msg->hasKey($ns, $key),
+ $error_message);
+ }
+}
+
+?> \ No newline at end of file