コード例 #1
0
 function Tests_Auth_Yadis_ParseHTML()
 {
     $test_data = Tests_Auth_Yadis_readdata('test1-parsehtml.txt');
     $test_cases = $this->parseTests($test_data);
     foreach ($test_cases as $case) {
         $this->addTest(new Tests_Auth_Yadis_ParseTest($case));
     }
 }
コード例 #2
0
function readTests($filename)
{
    $data = Tests_Auth_Yadis_readdata($filename);
    if ($data === null) {
        return null;
    }
    $tests = array();
    foreach (preg_split("/\f\n/", $data) as $case) {
        list($name, $content) = explode("\n", $case, 2);
        $tests[$name] = $content;
    }
    return $tests;
}
コード例 #3
0
ファイル: XRDS.php プロジェクト: Jobava/diacritice-meta-repo
 function test_services_filters()
 {
     // First, just be sure that service objects do the right
     // thing.
     $xml = Tests_Auth_Yadis_readdata("brian_priority.xrds");
     $xrds = Auth_Yadis_XRDS::parseXRDS($xml, array('openid' => 'http://openid.net/xmlns/1.0'));
     $this->assertTrue($xrds !== null);
     // Get list of service objects.
     $services = $xrds->services();
     $this->assertEquals(count($services), 2, "first service count");
     // Query the two service objecs.
     $s1 = $services[0];
     $this->assertEquals($s1->getPriority(), 1, "first priority check");
     $types = $s1->getTypes();
     $this->assertEquals(count($types), 1, "first type check");
     $s2 = $services[1];
     $this->assertEquals($s2->getPriority(), 2, "second priority check");
     $types = $s2->getTypes();
     $this->assertEquals(count($types), 1, "second type check");
     function _DelegateFilter(&$service)
     {
         if ($service->getElements('openid:Delegate')) {
             return true;
         }
         return false;
     }
     // Make sure that a filter which matches both DOES match both.
     $this->assertEquals(count($xrds->services(array("_DelegateFilter"))), 2, "_DelegateFilter check");
     // This filter should match all services in the document.
     function _HasTypeAndURI(&$service)
     {
         if ($service->getTypes() && $service->getURIs()) {
             return true;
         }
         return false;
     }
     // This filter should only match one.
     function _URIMatchesSchtuff(&$service)
     {
         $uris = $service->getURIs();
         foreach ($uris as $uri) {
             if (preg_match("|schtuff|", $uri)) {
                 return true;
             }
         }
         return false;
     }
     // This filter should only match one.
     function _URIMatchesMyOpenID(&$service)
     {
         $uris = $service->getURIs();
         foreach ($uris as $uri) {
             if (preg_match("|myopenid|", $uri)) {
                 return true;
             }
         }
         return false;
     }
     // Make sure a pair of filters in ALL mode only match one service.
     $this->assertEquals(count($xrds->services(array("_HasTypeAndURI", "_URIMatchesSchtuff"), SERVICES_YADIS_MATCH_ALL)), 1, "_HasTypeAndURI / _URIMatchesSchtuff check");
     // Make sure a pair of filters in ALL mode only match one service.
     $this->assertEquals(count($xrds->services(array("_HasTypeAndURI", "_URIMatchesMyOpenID"), SERVICES_YADIS_MATCH_ALL)), 1, "_HasTypeAndURI / _URIMatchesMyOpenID check");
     // Make sure a pair of filters in ANY mode matches both services.
     $this->assertEquals(count($xrds->services(array("_URIMatchesMyOpenID", "_URIMatchesSchtuff"))), 2, "_URIMatchesMyOpenID / _URIMatchesSchtuff check");
     // Make sure the order of the services returned (when using
     // filters) is correct.
     $s = $xrds->services(array("_URIMatchesMyOpenID", "_URIMatchesSchtuff"));
     $this->assertTrue($s[0]->getPriority() === 1, "s[0] priority check");
     $this->assertTrue($s[1]->getPriority() === 2, "s[1] priority check");
     // Make sure a bad filter mode gets us a null service list.
     $this->assertTrue($xrds->services(array("_URIMatchesMyOpenID", "_URIMatchesSchtuff"), "bogus") === null, "bogus filter check");
 }
コード例 #4
0
 function test_multisegment_xri()
 {
     $xml = Tests_Auth_Yadis_readdata('subsegments.xrds');
     $xmldoc = Auth_Yadis_XRDS::parseXRDS($xml);
     $result = Auth_Yadis_getCanonicalId('xri://=nishitani*masaki', $xmldoc);
     $this->assertEquals($result, "xri://=!E117.EF2F.454B.C707!0000.0000.3B9A.CA01");
 }