| @@ 8-19 (lines=12) @@ | ||
| 5 | */ |
|
| 6 | class AnticaptchaTest extends PHPUnit_Framework_TestCase |
|
| 7 | { |
|
| 8 | public function testRecognize() |
|
| 9 | { |
|
| 10 | $captcha = new \jumper423\decaptcha\services\Anticaptcha([ |
|
| 11 | \jumper423\decaptcha\services\Anticaptcha::PARAM_SPEC_API_KEY => '5464654645646', |
|
| 12 | ]); |
|
| 13 | $captcha->setErrorLang(\jumper423\decaptcha\core\DeCaptchaErrors::LANG_RU); |
|
| 14 | if ($captcha->recognize(__DIR__.'/data/Captcha.jpg')) { |
|
| 15 | $this->assertEquals('11111111111111', $captcha->getCode()); |
|
| 16 | } else { |
|
| 17 | $this->assertEquals('Использован несуществующий key', $captcha->getError()); |
|
| 18 | } |
|
| 19 | } |
|
| 20 | ||
| 21 | public function testEnum() |
|
| 22 | { |
|
| @@ 21-33 (lines=13) @@ | ||
| 18 | } |
|
| 19 | } |
|
| 20 | ||
| 21 | public function testEnum() |
|
| 22 | { |
|
| 23 | $captcha = new \jumper423\decaptcha\services\Anticaptcha([ |
|
| 24 | \jumper423\decaptcha\services\Anticaptcha::PARAM_SPEC_API_KEY => '5464654645646', |
|
| 25 | \jumper423\decaptcha\services\Anticaptcha::ACTION_FIELD_LANGUAGE => 'ru', |
|
| 26 | ]); |
|
| 27 | $captcha->setErrorLang(\jumper423\decaptcha\core\DeCaptchaErrors::LANG_RU); |
|
| 28 | if ($captcha->recognize(__DIR__ . '/data/Captcha.jpg')) { |
|
| 29 | $this->assertEquals('11111111111111', $captcha->getCode()); |
|
| 30 | } else { |
|
| 31 | $this->assertEquals('Нет в допустимых значиниях поля: languagePool = ru', $captcha->getError()); |
|
| 32 | } |
|
| 33 | } |
|
| 34 | } |
|
| 35 | ||
| @@ 23-34 (lines=12) @@ | ||
| 20 | $captcha->recognize(__DIR__.'/data/Captcha.jpg'); |
|
| 21 | } |
|
| 22 | ||
| 23 | public function testRecognizeBalanceError2() |
|
| 24 | { |
|
| 25 | $captcha = new \jumper423\decaptcha\services\TwoCaptcha([ |
|
| 26 | \jumper423\decaptcha\services\TwoCaptcha::PARAM_SPEC_API_KEY => '200a1ed2b6ca001d8171c655658086ed', |
|
| 27 | ]); |
|
| 28 | $captcha->setErrorLang(\jumper423\decaptcha\core\DeCaptchaErrors::LANG_RU); |
|
| 29 | if ($captcha->recognize(__DIR__.'/data/Captcha.jpg')) { |
|
| 30 | $this->assertEquals('11111111111111', $captcha->getCode()); |
|
| 31 | } else { |
|
| 32 | $this->assertEquals('Нулевой либо отрицательный баланс', $captcha->getError()); |
|
| 33 | } |
|
| 34 | } |
|
| 35 | ||
| 36 | public function testGetBalance() |
|
| 37 | { |
|