_response = new Zend_Service_ReCaptcha_Response(); } public function testSetAndGet() { /* Set and get status */ $status = 'true'; $this->_response->setStatus($status); $this->assertSame(true, $this->_response->getStatus()); $status = 'false'; $this->_response->setStatus($status); $this->assertSame(false, $this->_response->getStatus()); /* Set and get the error code */ $errorCode = 'foobar'; $this->_response->setErrorCode($errorCode); $this->assertSame($errorCode, $this->_response->getErrorCode()); } public function testIsValid() { $this->_response->setStatus('true'); $this->assertSame(true, $this->_response->isValid()); } public function testIsInvalid() { $this->_response->setStatus('false'); $this->assertSame(false, $this->_response->isValid()); } public function testSetFromHttpResponse() { $status = 'false'; $errorCode = 'foobar'; $responseBody = $status . "\n" . $errorCode; $httpResponse = new Zend_Http_Response(200, array('Content-Type' => 'text/html'), $responseBody); $this->_response->setFromHttpResponse($httpResponse); $this->assertSame(false, $this->_response->getStatus()); $this->assertSame($errorCode, $this->_response->getErrorCode()); } public function testConstructor() { $status = 'true'; $errorCode = 'ok'; $response = new Zend_Service_ReCaptcha_Response($status, $errorCode); $this->assertSame(true, $response->getStatus()); $this->assertSame($errorCode, $response->getErrorCode()); } public function testConstructorWithHttpResponse() { $status = 'false'; $errorCode = 'foobar'; $responseBody = $status . "\n" . $errorCode; $httpResponse = new Zend_Http_Response(200, array('Content-Type' => 'text/html'), $responseBody); $response = new Zend_Service_ReCaptcha_Response(null, null, $httpResponse); $this->assertSame(false, $response->getStatus()); $this->assertSame($errorCode, $response->getErrorCode()); } }