You are here

class CurlPostTest in reCAPTCHA 6.2

Same name and namespace in other branches
  1. 7.2 recaptcha-php/tests/ReCaptcha/RequestMethod/CurlPostTest.php \ReCaptcha\RequestMethod\CurlPostTest

Hierarchy

  • class \ReCaptcha\RequestMethod\CurlPostTest extends \ReCaptcha\RequestMethod\PHPUnit_Framework_TestCase

Expanded class hierarchy of CurlPostTest

File

recaptcha-php/tests/ReCaptcha/RequestMethod/CurlPostTest.php, line 31

Namespace

ReCaptcha\RequestMethod
View source
class CurlPostTest extends \PHPUnit_Framework_TestCase {
  protected function setUp() {
    if (!extension_loaded('curl')) {
      $this
        ->markTestSkipped('The cURL extension is not available.');
    }
  }
  public function testSubmit() {
    $curl = $this
      ->getMock('\\ReCaptcha\\RequestMethod\\Curl', array(
      'init',
      'setoptArray',
      'exec',
      'close',
    ));
    $curl
      ->expects($this
      ->once())
      ->method('init')
      ->willReturn(new \stdClass());
    $curl
      ->expects($this
      ->once())
      ->method('setoptArray')
      ->willReturn(true);
    $curl
      ->expects($this
      ->once())
      ->method('exec')
      ->willReturn('RESPONSEBODY');
    $curl
      ->expects($this
      ->once())
      ->method('close');
    $pc = new CurlPost($curl);
    $response = $pc
      ->submit(new RequestParameters("secret", "response"));
    $this
      ->assertEquals('RESPONSEBODY', $response);
  }

}

Members