diff options
author | tailor <cygnus@janrain.com> | 2007-09-20 18:44:45 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2007-09-20 18:44:45 +0000 |
commit | 8888843a23401dd3b7e3f90c7f79a4caca9281fb (patch) | |
tree | 7625d54ccd22b9f29a1fbb4b3162f48c46bfd56e /Tests/Auth/OpenID | |
parent | 773341140b8b9567543aef4899ef641d955a968c (diff) | |
download | php-openid-8888843a23401dd3b7e3f90c7f79a4caca9281fb.zip php-openid-8888843a23401dd3b7e3f90c7f79a4caca9281fb.tar.gz php-openid-8888843a23401dd3b7e3f90c7f79a4caca9281fb.tar.bz2 |
[project @ Removed sendSRegFields, added Auth_OpenID_Response.addExtension]
Diffstat (limited to 'Tests/Auth/OpenID')
-rw-r--r-- | Tests/Auth/OpenID/SReg.php | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/Tests/Auth/OpenID/SReg.php b/Tests/Auth/OpenID/SReg.php index 395daf1..5142b63 100644 --- a/Tests/Auth/OpenID/SReg.php +++ b/Tests/Auth/OpenID/SReg.php @@ -176,38 +176,59 @@ class GetNSTest extends PHPUnit_TestCase { } } -class SentinelFakeMessage { - var $args_sentinel = 'args_sentinel'; +global $__args_sentinel; +global $__ns_sentinel; +$__args_sentinel = 'args_sentinel'; +$__ns_sentinel = 'ns_sentinel'; +class SentinelFakeMessage { function SentinelFakeMessage(&$test_case) { $this->test_case =& $test_case; + $this->message = new Auth_OpenID_Message(); } function getArgs($ns_uri) { - $this->test_case->assertEquals($ns_sentinel, $ns_uri); - return $this->args_sentinel; + global $__ns_sentinel, $__args_sentinel; + $this->test_case->assertEquals($__ns_sentinel, $ns_uri); + return $__args_sentinel; } } -class TestingReq extends Auth_OpenID_SRegRequest { - var $ns_sentinel = 'ns_sentinel'; +// XXX Ugly hack. Thanks, PHP. +global $__TestingReq_TEST_CASE; +$__TestingReq_TEST_CASE = "FLUB"; - function fromOpenIDRequest($message, &$test_case) +function __setTestCase(&$thing) { + global $__TestingReq_TEST_CASE; + $__TestingReq_TEST_CASE = $thing; +} + +function &__getTestCase() { + global $__TestingReq_TEST_CASE; + return $__TestingReq_TEST_CASE; +} + +class TestingReq extends Auth_OpenID_SRegRequest { + function fromOpenIDRequest(&$thing, &$test_case) { - parent::fromOpenIDRequest($message); - $this->test_case =& $test_case; + __setTestCase($test_case); + $obj = parent::fromOpenIDRequest($thing, 'TestingReq'); + return $obj; } function _getSRegNS($unused) { - return $this->ns_sentinel; + global $__ns_sentinel; + return $__ns_sentinel; } function parseExtensionArgs($args) { - $this->test_case->assertEquals($args_sentinel, $args); + global $__args_sentinel; + $tc =& __getTestCase(); + $tc->assertEquals($__args_sentinel, $args); } } @@ -239,13 +260,16 @@ class SRegRequestTest extends PHPUnit_TestCase { $this->assertTrue(Auth_OpenID_SRegRequest::build(array('elvis')) === null); } - /* function test_fromOpenIDResponse() { + $openid_req = new Auth_OpenID_Request(); + $msg = new SentinelFakeMessage($this); - $req = TestingReq::fromOpenIDRequest($msg, $this); + $openid_req->message =& $msg; + + $req = TestingReq::fromOpenIDRequest($openid_req, $this); + $this->assertTrue(is_a($req, 'TestingReq')); } - */ function test_parseExtensionArgs_empty() { @@ -607,7 +631,8 @@ class SendFieldsTest extends PHPUnit_TestCase { 'language' => 'en-us'); // Put the requested data fields in the response message - Auth_OpenID_sendSRegFields($req, $data, $resp); + $sreg_resp = Auth_OpenID_SRegResponse::extractResponse($sreg_req, $data); + $resp->addExtension($sreg_resp); // <- send id_res response |