class ResponseTest in reCAPTCHA 6.2
Same name and namespace in other branches
- 7.2 recaptcha-php/tests/ReCaptcha/ResponseTest.php \ReCaptcha\ResponseTest
Hierarchy
- class \ReCaptcha\ResponseTest extends \ReCaptcha\PHPUnit_Framework_TestCase
Expanded class hierarchy of ResponseTest
File
- recaptcha-php/
tests/ ReCaptcha/ ResponseTest.php, line 29
Namespace
ReCaptchaView source
class ResponseTest extends \PHPUnit_Framework_TestCase {
/**
* @dataProvider provideJson
*/
public function testFromJson($json, $success, $errorCodes) {
$response = Response::fromJson($json);
$this
->assertEquals($success, $response
->isSuccess());
$this
->assertEquals($errorCodes, $response
->getErrorCodes());
}
public function provideJson() {
return array(
array(
'{"success": true}',
true,
array(),
),
array(
'{"success": false, "error-codes": ["test"]}',
false,
array(
'test',
),
),
array(
'{"success": true, "error-codes": ["test"]}',
true,
array(),
),
array(
'{"success": false}',
false,
array(),
),
array(
'BAD JSON',
false,
array(
'invalid-json',
),
),
);
}
public function testIsSuccess() {
$response = new Response(true);
$this
->assertTrue($response
->isSuccess());
$response = new Response(false);
$this
->assertFalse($response
->isSuccess());
}
public function testGetErrorCodes() {
$errorCodes = array(
'test',
);
$response = new Response(true, $errorCodes);
$this
->assertEquals($errorCodes, $response
->getErrorCodes());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ResponseTest:: |
public | function | ||
ResponseTest:: |
public | function | @dataProvider provideJson | |
ResponseTest:: |
public | function | ||
ResponseTest:: |
public | function |