public function testVerify() { $this->_reCaptcha->setPublicKey($this->_publicKey); $this->_reCaptcha->setPrivateKey($this->_privateKey); $this->_reCaptcha->setIp('127.0.0.1'); $adapter = new Zend_Http_Client_Adapter_Test(); $client = new Zend_Http_Client(null, array('adapter' => $adapter)); Zend_Service_ReCaptcha::setHttpClient($client); // Set a header that will be reset in the recaptcha class before sending the request $client->setHeaders('host', 'example.com'); $resp = $this->_reCaptcha->verify('challengeField', 'responseField'); $this->assertNotSame('example.com', $client->getHeader('host')); // See if we have a valid object and that the status is false $this->assertTrue($resp instanceof Zend_Service_ReCaptcha_Response); $this->assertFalse($resp->getStatus()); }
protected function _testVerifyOffline() { $adapter = new Zend_Http_Client_Adapter_Test(); $client = new Zend_Http_Client(null, array('adapter' => $adapter)); Zend_Service_ReCaptcha::setHttpClient($client); $resp = $this->_reCaptcha->verify('challengeField', 'responseField'); // See if we have a valid object and that the status is false $this->assertTrue($resp instanceof Zend_Service_ReCaptcha_Response); $this->assertFalse($resp->getStatus()); }