diff options
author | tailor <cygnus@janrain.com> | 2007-10-01 19:46:30 +0000 |
---|---|---|
committer | tailor <cygnus@janrain.com> | 2007-10-01 19:46:30 +0000 |
commit | e198e7b3f3e2d0ec2c503a27f262fee54becf455 (patch) | |
tree | 8ecde35932a8c008fa74caa0b1f674b68db6f496 /Tests/Auth | |
parent | cbc83cb90c8485fed91b22de9b1ee309db173c7e (diff) | |
download | php-openid-e198e7b3f3e2d0ec2c503a27f262fee54becf455.zip php-openid-e198e7b3f3e2d0ec2c503a27f262fee54becf455.tar.gz php-openid-e198e7b3f3e2d0ec2c503a27f262fee54becf455.tar.bz2 |
[project @ Auth_OpenID_GenericConsumer::_httpResponseToMessage: split from _makeKVPost]
Diffstat (limited to 'Tests/Auth')
-rw-r--r-- | Tests/Auth/OpenID/Consumer.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Tests/Auth/OpenID/Consumer.php b/Tests/Auth/OpenID/Consumer.php index 192fbdf..1bfecb2 100644 --- a/Tests/Auth/OpenID/Consumer.php +++ b/Tests/Auth/OpenID/Consumer.php @@ -2104,6 +2104,45 @@ if (!defined('Auth_OpenID_NO_MATH_SUPPORT') && } } +class Tests_Auth_OpenID_KVPost extends PHPUnit_TestCase { + function setUp() + { + $this->server_url = 'http://unittest/bogus'; + } + + function test_200() + { + $response = new Auth_Yadis_HTTPResponse(); + $response->status = 200; + $response->body = "foo:bar\nbaz:quux\n"; + $r = Auth_OpenID_GenericConsumer::_httpResponseToMessage($response, $this->server_url); + $expected_msg = Auth_OpenID_Message::fromOpenIDArgs(array('foo' => 'bar', 'baz' => 'quux')); + $this->assertEquals($expected_msg, $r); + } + + function test_400() + { + $response = new Auth_Yadis_HTTPResponse(); + $response->status = 400; + $response->body = "error:bonk\nerror_code:7\n"; + $result = Auth_OpenID_GenericConsumer::_httpResponseToMessage($response, $this->server_url); + + $this->assertTrue(is_a($result, 'Auth_OpenID_ServerErrorContainer')); + $this->assertEquals($result->error_text, 'bonk'); + $this->assertEquals($result->error_code, '7'); + } + + function test_500() + { + // 500 as an example of any non-200, non-400 code. + $response = new Auth_Yadis_HTTPResponse(); + $response->status = 500; + $response->body = "foo:bar\nbaz:quux\n"; + $result = Auth_OpenID_GenericConsumer::_httpResponseToMessage($response, $this->server_url); + $this->assertTrue($result === null); + } +} + // Add other test cases to be run. global $Tests_Auth_OpenID_Consumer_other; $Tests_Auth_OpenID_Consumer_other = array( @@ -2123,6 +2162,7 @@ $Tests_Auth_OpenID_Consumer_other = array( new TestReturnToArgs(), new IDPDrivenTest(), new TestDiscoveryVerification(), + new Tests_Auth_OpenID_KVPost(), ); if (!defined('Auth_OpenID_NO_MATH_SUPPORT')) { |