示例#1
0
 /**
  * testing check
  */
 public function testCheck()
 {
     $this->expectOutputRegex('/.*/');
     // Hide stdout from the component when the test run
     $expiresIn = time() + 600;
     $_SERVER['SCRIPT_URI'] = "http://www.zf-test.com/test.php";
     $storage = new Storage\File(__DIR__ . "/_files/consumer");
     $storage->delDiscoveryInfo(self::ID);
     $this->assertTrue($storage->addDiscoveryInfo(self::ID, self::REAL_ID, self::SERVER, 1.1, $expiresIn));
     $storage->delAssociation(self::SERVER);
     $this->assertTrue($storage->addAssociation(self::SERVER, self::HANDLE, self::MAC_FUNC, self::SECRET, $expiresIn));
     $response = new ResponseHelper(true);
     $consumer = new Consumer($storage);
     $this->assertTrue($consumer->check(self::ID, null, null, null, $response));
     $headers = $response->getHeaders();
     $this->assertTrue(1 <= count($headers));
     $this->assertTrue($headers->has('Location'));
     $location = $headers->get('Location');
     $url = $location->getFieldValue();
     $url = parse_url($url);
     $this->assertSame("http", $url['scheme']);
     $this->assertSame("www.myopenid.com", $url['host']);
     $this->assertSame("/", $url['path']);
     $q = explode("&", $url['query']);
     $query = array();
     foreach ($q as $var) {
         if (list($key, $val) = explode("=", $var, 2)) {
             $query[$key] = $val;
         }
     }
     $this->assertTrue(is_array($query));
     $this->assertSame(6, count($query));
     $this->assertSame('checkid_immediate', $query['openid.mode']);
     $this->assertSame('http%3A%2F%2Freal_id.myopenid.com%2F', $query['openid.identity']);
     $this->assertSame('http%3A%2F%2Fid.myopenid.com%2F', $query['openid.claimed_id']);
     $this->assertSame(self::HANDLE, $query['openid.assoc_handle']);
     $this->assertSame('http%3A%2F%2Fwww.zf-test.com%2Ftest.php', $query['openid.return_to']);
     $this->assertSame('http%3A%2F%2Fwww.zf-test.com', $query['openid.trust_root']);
     $storage->delDiscoveryInfo(self::ID);
     $storage->delAssociation(self::SERVER);
 }
 public function __construct(Storage\AbstractStorage $storage = null, $dumbMode = false)
 {
     $container = new SessionContainer('Default', new SessionManager());
     $this->setSession($container);
     parent::__construct($storage, $dumbMode);
 }