/** * sreg_form * * @param Zend_OpenId_Extension_Sreg $sreg * @return string */ function sreg_form(Zend_OpenId_Extension_Sreg $sreg) { $s = ""; $props = $sreg->getProperties(); if (is_array($props) && count($props) > 0) { $s = 'It also requests additinal information about you'; $s .= ' (fields marked by <u>*</u> are required)<br>'; $s .= '<table border="0" cellspacing="2" cellpadding="2">'; foreach ($props as $prop => $val) { if ($val) { $s .= '<tr><td><u>' . $prop . ':*</u></td>'; } else { $s .= '<tr><td>' . $prop . ':</u></td>'; } $value = ""; $s .= '<td><input type="text" name="openid.sreg.' . $prop . '" value="' . $value . '"></td></tr>'; } $s .= '</table><br>'; $policy = $sreg->getPolicyUrl(); if (!empty($policy)) { $s .= 'The private policy can be found at <a href="' . $policy . '">' . $policy . '</a>.<br>'; } } return $s; }
/** * testing parseResponse * */ public function testParseResponse() { $ext = new Zend_OpenId_Extension_Sreg(); $this->assertTrue($ext->parseResponse(array())); $this->assertSame(array(), $ext->getProperties()); $this->assertSame(null, $ext->getPolicyUrl()); $this->assertSame(1.0, $ext->getVersion()); $this->assertTrue($ext->parseResponse(array('openid_sreg_nickname' => self::USER, 'openid_sreg_email' => self::EMAIL))); $this->assertSame(array('nickname' => self::USER, 'email' => self::EMAIL), $ext->getProperties()); $this->assertSame(null, $ext->getPolicyUrl()); $this->assertSame(1.0, $ext->getVersion()); $this->assertTrue($ext->parseResponse(array('openid_sreg_nickname' => self::USER, 'openid_sreg_email' => self::EMAIL, 'openid_sreg_policy_url' => self::POLICY))); $this->assertSame(array('nickname' => self::USER, 'email' => self::EMAIL), $ext->getProperties()); $this->assertSame(null, $ext->getPolicyUrl()); $this->assertSame(1.0, $ext->getVersion()); $this->assertTrue($ext->parseResponse(array('openid_ns_sreg' => "http://openid.net/extensions/sreg/1.1", 'openid_sreg_nickname' => self::USER, 'openid_sreg_email' => self::EMAIL))); $this->assertSame(array('nickname' => self::USER, 'email' => self::EMAIL), $ext->getProperties()); $this->assertSame(null, $ext->getPolicyUrl()); $this->assertSame(1.1, $ext->getVersion()); }