forked from RyanDaDeng/laravel-google-recaptcha-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestTest.php
More file actions
69 lines (55 loc) · 2.19 KB
/
RequestTest.php
File metadata and controls
69 lines (55 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace TimeHunter\Tests;
use PHPUnit\Framework\TestCase;
use TimeHunter\LaravelGoogleReCaptchaV3\Core\CurlRequestClient;
use TimeHunter\LaravelGoogleReCaptchaV3\Core\GoogleReCaptchaV3Response;
use TimeHunter\LaravelGoogleReCaptchaV3\Core\GuzzleRequestClient;
class RequestTest extends TestCase
{
public function testCurlRequest()
{
$client = new CurlRequestClient();
$response = $client->post('https://www.google.com/recaptcha/api/siteverify', [
'secret' => 'test',
'remoteip' => null,
'response' => 'test',
]);
$response = new GoogleReCaptchaV3Response(json_decode($response, 1), null, '');
$this->assertEquals(false, $response->isSuccess());
$this->assertEquals(1, count($response->getErrorCodes()));
}
public function testCurlRequest2()
{
$client = new CurlRequestClient();
$response = $client->post('https://www.google.com/recaptcha/api/siteve11rify', [
'secret' => 'test',
'remoteip' => null,
'response' => 'test',
]);
$response = new GoogleReCaptchaV3Response(json_decode($response, 1), null, '');
$this->assertEquals(false, $response->isSuccess());
}
public function testGuzzleRequest()
{
$client = new GuzzleRequestClient();
$response = $client->post('https://www.google.com/recaptcha/api/siteverify', [
'secret' => 'test',
'remoteip' => null,
'response' => 'test',
]);
$response = new GoogleReCaptchaV3Response(json_decode($response, 1), null, '');
$this->assertEquals(false, $response->toArray()['success']);
$this->assertEquals(1, count($response->getErrorCodes()));
}
public function testGuzzleRequest2()
{
$client = new GuzzleRequestClient();
$response = $client->post('https://www.google.com/recaptcha/api/sitev111erify', [
'secret' => 'test',
'remoteip' => null,
'response' => 'test',
]);
$response = new GoogleReCaptchaV3Response(json_decode($response, 1), null, '');
$this->assertEquals(false, $response->toArray()['success']);
}
}