Пример #1
0
 public function testSetAndGetPublicAndPrivateKeys()
 {
     $captcha = new Zend_Captcha_ReCaptcha();
     $pubKey = 'pubKey';
     $privKey = 'privKey';
     $captcha->setPubkey($pubKey)->setPrivkey($privKey);
     $this->assertSame($pubKey, $captcha->getPubkey());
     $this->assertSame($privKey, $captcha->getPrivkey());
     $this->assertSame($pubKey, $captcha->getService()->getPublicKey());
     $this->assertSame($privKey, $captcha->getService()->getPrivateKey());
 }
Пример #2
0
 public static function captchaValidation($property_info)
 {
     $captcha_type = SJB_Settings::getSettingByName('captcha_type');
     $validation = false;
     switch ($captcha_type) {
         case 'reCaptcha':
             $reCaptchaPubkey = SJB_Settings::getSettingByName('reCaptchaPubkey');
             $reCaptchaPrivkey = SJB_Settings::getSettingByName('reCaptchaPrivkey');
             $reCaptcha = new Zend_Captcha_ReCaptcha();
             $reCaptcha->setPubkey($reCaptchaPubkey);
             $reCaptcha->setPrivkey($reCaptchaPrivkey);
             $validation = $reCaptcha->isValid($property_info['value']);
             break;
         case 'customCaptcha':
             $customCaptcha = new SJB_CustomCaptcha();
             $validation = $customCaptcha->isValid($property_info['value']);
             break;
         case 'kCaptcha':
             $validation = $property_info;
             break;
     }
     return $validation;
 }
Пример #3
0
 /** @group ZF-10991 */
 public function testRenderWillUseElementNameWhenRenderingNoScriptFields()
 {
     $captcha = new Zend_Captcha_ReCaptcha();
     $pubKey = 'pubKey';
     $privKey = 'privKey';
     $captcha->setPubkey($pubKey)->setPrivkey($privKey);
     $element = new Zend_Form_Element_Captcha('captcha', array('captcha' => $captcha, 'belongsTo' => 'contact'));
     $view = new Zend_View();
     $html = $captcha->render($view, $element);
     $this->assertContains('contact[recaptcha_challenge_field]', $html);
     $this->assertContains('contact[recaptcha_response_field]', $html);
 }