|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Class TwoCaptchaTest. |
|
5
|
|
|
*/ |
|
6
|
|
|
class TwoCaptchaTest extends PHPUnit_Framework_TestCase |
|
|
|
|
|
|
7
|
|
|
{ |
|
8
|
|
|
/** |
|
9
|
|
|
* @expectedException \jumper423\decaptcha\core\DeCaptchaErrors |
|
10
|
|
|
* @expectedExceptionMessage Нулевой либо отрицательный баланс |
|
11
|
|
|
* @expectedExceptionCode 3 |
|
12
|
|
|
*/ |
|
13
|
|
|
public function testRecognizeBalanceError1() |
|
14
|
|
|
{ |
|
15
|
|
|
$captcha = new \jumper423\decaptcha\services\TwoCaptcha([ |
|
16
|
|
|
\jumper423\decaptcha\services\TwoCaptcha::PARAM_SPEC_API_KEY => '200a1ed2b6ca001d8171c655658086ed', |
|
17
|
|
|
]); |
|
18
|
|
|
$captcha->setErrorLang(\jumper423\decaptcha\core\DeCaptchaErrors::LANG_RU); |
|
19
|
|
|
$captcha->setCauseAnError(true); |
|
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
|
|
View Code Duplication |
public function testGetBalance() |
|
|
|
|
|
|
37
|
|
|
{ |
|
38
|
|
|
$captcha = new \jumper423\decaptcha\services\TwoCaptcha([ |
|
39
|
|
|
\jumper423\decaptcha\services\TwoCaptcha::PARAM_SPEC_API_KEY => '200a1ed2b6ca001d8171c655658086ed', |
|
40
|
|
|
]); |
|
41
|
|
|
$captcha->setErrorLang(\jumper423\decaptcha\core\DeCaptchaErrors::LANG_RU); |
|
42
|
|
|
$this->assertEquals(0, (int) $captcha->getBalance()); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
View Code Duplication |
public function testNotTrue() |
|
|
|
|
|
|
46
|
|
|
{ |
|
47
|
|
|
$captcha = new \jumper423\decaptcha\services\TwoCaptcha([ |
|
48
|
|
|
\jumper423\decaptcha\services\TwoCaptcha::PARAM_SPEC_API_KEY => '200a1ed2b6ca001d8171c655658086ed', |
|
49
|
|
|
]); |
|
50
|
|
|
$captcha->setErrorLang(\jumper423\decaptcha\core\DeCaptchaErrors::LANG_RU); |
|
51
|
|
|
$this->assertEquals(false, $captcha->notTrue()); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.