summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authortailor <cygnus@janrain.com>2008-06-05 19:22:41 +0000
committertailor <cygnus@janrain.com>2008-06-05 19:22:41 +0000
commita40cb87199be578c1d3bc4ecaa1223c11569a459 (patch)
treedf71613ffeed397440706102011ec9818cc7e067 /Tests
parent160392b196414ce4a8d152b65c4aae75a8bc2aca (diff)
downloadphp-openid-a40cb87199be578c1d3bc4ecaa1223c11569a459.zip
php-openid-a40cb87199be578c1d3bc4ecaa1223c11569a459.tar.gz
php-openid-a40cb87199be578c1d3bc4ecaa1223c11569a459.tar.bz2
[project @ Fix Auth_OpenID_getAllowedReturnURLs, Auth_Yadis_DiscoveryResult::usedYadisLocation, add Auth_Yadis_getServiceEndpoints, tests]
Diffstat (limited to 'Tests')
-rw-r--r--Tests/Auth/Yadis/Discover_Yadis.php63
1 files changed, 63 insertions, 0 deletions
diff --git a/Tests/Auth/Yadis/Discover_Yadis.php b/Tests/Auth/Yadis/Discover_Yadis.php
index c5f67a7..8f308cf 100644
--- a/Tests/Auth/Yadis/Discover_Yadis.php
+++ b/Tests/Auth/Yadis/Discover_Yadis.php
@@ -58,6 +58,21 @@ class TestFetcher {
}
}
+class BlankContentTypeFetcher {
+ function get($url, $headers=null)
+ {
+ return new Auth_Yadis_HTTPResponse(
+ $url, 200, array("Content-Type" => ""), '');
+ }
+}
+
+class NoContentTypeFetcher {
+ function get($url, $headers=null)
+ {
+ return new Auth_Yadis_HTTPResponse($url, 200, array(), '');
+ }
+}
+
class MockFetcher {
function MockFetcher() {
$this->count = 0;
@@ -166,4 +181,52 @@ class Tests_Auth_Yadis_Discover_Yadis extends PHPUnit_TestSuite {
}
}
+class Tests_Auth_Yadis_Discover_Yadis_ContentTypes extends PHPUnit_TestCase {
+ function test_is_xrds_yadis_location()
+ {
+ $result = new Auth_Yadis_DiscoveryResult('http://request.uri/');
+ $result->normalized_uri = "http://normalized/";
+ $result->xrds_uri = "http://normalized/xrds";
+
+ $this->assertTrue($result->isXRDS());
+ }
+
+ function test_is_xrds_content_type()
+ {
+ $result = new Auth_Yadis_DiscoveryResult('http://request.uri/');
+ $result->normalized_uri = $result->xrds_uri = "http://normalized/";
+ $result->content_type = Auth_Yadis_CONTENT_TYPE;
+
+ $this->assertTrue($result->isXRDS());
+ }
+
+ function test_is_xrds_neither()
+ {
+ $result = new Auth_Yadis_DiscoveryResult('http://request.uri/');
+ $result->normalized_uri = $result->xrds_uri = "http://normalized/";
+ $result->content_type = "another/content-type";
+
+ $this->assertTrue(!$result->isXRDS());
+ }
+
+ function test_no_content_type()
+ {
+ $fetcher = new NoContentTypeFetcher();
+ $result = Auth_Yadis_Yadis::discover("http://bogus", $fetcher);
+ $this->assertEquals(null, $result->content_type);
+ }
+
+ function test_blank_content_type()
+ {
+ $fetcher = new BlankContentTypeFetcher();
+ $result = Auth_Yadis_Yadis::discover("http://bogus", $fetcher);
+ $this->assertEquals("", $result->content_type);
+ }
+}
+
+global $Tests_Auth_Yadis_Discover_Yadis_other;
+$Tests_Auth_Yadis_Discover_Yadis_other = array(
+ new Tests_Auth_Yadis_Discover_Yadis_ContentTypes()
+ );
+
?> \ No newline at end of file