Esempio n. 1
0
 public function addCaptcha()
 {
     $captcha = new CaptchaWidget();
     $captcha->setPrivkey($this->options['captchaConfig']['private-key']);
     $captcha->setPubkey($this->options['captchaConfig']['public-key']);
     if ($this->options['showCaptcha']) {
         $this->add(['type' => 'Zend\\Form\\Element\\Captcha', 'name' => 'captcha', 'options' => ['label' => $this->translate('Please verify you are human'), 'captcha' => $captcha]]);
     }
 }
Esempio n. 2
0
 public function testSetAndGetPublicAndPrivateKeys()
 {
     $captcha = new 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());
 }
Esempio n. 3
0
 /** @group ZF-10991 */
 public function testRenderWillUseElementNameWhenRenderingNoScriptFields()
 {
     $captcha = new 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\PhpRenderer();
     $html = $captcha->render($view, $element);
     $this->assertContains('contact[recaptcha_challenge_field]', $html);
     $this->assertContains('contact[recaptcha_response_field]', $html);
 }