class ReCaptchaTest in reCAPTCHA 6.2
Same name and namespace in other branches
- 7.2 recaptcha-php/tests/ReCaptcha/ReCaptchaTest.php \ReCaptcha\ReCaptchaTest
Hierarchy
- class \ReCaptcha\ReCaptchaTest extends \ReCaptcha\PHPUnit_Framework_TestCase
Expanded class hierarchy of ReCaptchaTest
File
- recaptcha-php/
tests/ ReCaptcha/ ReCaptchaTest.php, line 29
Namespace
ReCaptchaView source
class ReCaptchaTest extends \PHPUnit_Framework_TestCase {
/**
* @expectedException \RuntimeException
* @dataProvider invalidSecretProvider
*/
public function testExceptionThrownOnInvalidSecret($invalid) {
$rc = new ReCaptcha($invalid);
}
public function invalidSecretProvider() {
return array(
array(
'',
),
array(
null,
),
array(
0,
),
array(
new \stdClass(),
),
array(
array(),
),
);
}
public function testVerifyReturnsErrorOnMissingResponse() {
$rc = new ReCaptcha('secret');
$response = $rc
->verify('');
$this
->assertFalse($response
->isSuccess());
$this
->assertEquals(array(
'missing-input-response',
), $response
->getErrorCodes());
}
public function testVerifyReturnsResponse() {
$method = $this
->getMock('\\ReCaptcha\\RequestMethod', array(
'submit',
));
$method
->expects($this
->once())
->method('submit')
->with($this
->callback(function ($params) {
return true;
}))
->will($this
->returnValue('{"success": true}'));
$rc = new ReCaptcha('secret', $method);
$response = $rc
->verify('response');
$this
->assertTrue($response
->isSuccess());
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ReCaptchaTest:: |
public | function | ||
ReCaptchaTest:: |
public | function | @expectedException \RuntimeException @dataProvider invalidSecretProvider | |
ReCaptchaTest:: |
public | function | ||
ReCaptchaTest:: |
public | function |