@@ -20,93 +20,93 @@ |
||
20 | 20 | */ |
21 | 21 | class ReCaptchaV3Test extends TestCase { |
22 | 22 | |
23 | - protected $recaptcha_v3 = null; |
|
24 | - |
|
25 | - /** |
|
26 | - * @test |
|
27 | - */ |
|
28 | - public function testGetApiVersion() { |
|
29 | - |
|
30 | - $this->assertEquals($this->recaptcha_v3->getVersion(), 'v3'); |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * @test |
|
35 | - */ |
|
36 | - public function testHtmlScriptTagJsApiV3GetHtmlScriptTag() { |
|
37 | - |
|
38 | - $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(); |
|
39 | - $this->assertRegexp('/csrfToken/', $r); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @test |
|
44 | - */ |
|
45 | - public function testAction() { |
|
46 | - |
|
47 | - $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['action' => 'someAction']); |
|
48 | - $this->assertRegexp('/someAction/', $r); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * @test |
|
53 | - */ |
|
54 | - public function testFetchCallbackFunction() { |
|
55 | - |
|
56 | - $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['callback_then' => 'functionCallbackThen']); |
|
57 | - $this->assertRegexp('/functionCallbackThen\(response\)/', $r); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * @test |
|
62 | - */ |
|
63 | - public function testcCatchCallbackFunction() { |
|
64 | - |
|
65 | - $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['callback_catch' => 'functionCallbackCatch']); |
|
66 | - $this->assertRegexp('/functionCallbackCatch\(err\)/', $r); |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * @test |
|
71 | - */ |
|
72 | - public function testCustomValidationFunction() { |
|
73 | - |
|
74 | - $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['custom_validation' => 'functionCustomValidation']); |
|
75 | - $this->assertRegexp('/functionCustomValidation\(token\)/', $r); |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @test |
|
80 | - */ |
|
81 | - public function testValidateController() { |
|
82 | - |
|
83 | - $controller = App::make(ReCaptchaController::class); |
|
84 | - $return = $controller->validateV3(); |
|
85 | - |
|
86 | - $this->assertArrayHasKey("success", $return); |
|
87 | - $this->assertArrayHasKey("error-codes", $return); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Define environment setup. |
|
92 | - * |
|
93 | - * @param \Illuminate\Foundation\Application $app |
|
94 | - * |
|
95 | - * @return void |
|
96 | - */ |
|
97 | - protected function getEnvironmentSetUp($app) { |
|
98 | - |
|
99 | - $app['config']->set('recaptcha.version', 'v3'); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Setup the test environment. |
|
104 | - */ |
|
105 | - protected function setUp() { |
|
106 | - |
|
107 | - parent::setUp(); // TODO: Change the autogenerated stub |
|
108 | - |
|
109 | - $this->recaptcha_v3 = new ReCaptchaBuilderV3('api_site_key', 'api_secret_key'); |
|
110 | - |
|
111 | - } |
|
23 | + protected $recaptcha_v3 = null; |
|
24 | + |
|
25 | + /** |
|
26 | + * @test |
|
27 | + */ |
|
28 | + public function testGetApiVersion() { |
|
29 | + |
|
30 | + $this->assertEquals($this->recaptcha_v3->getVersion(), 'v3'); |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * @test |
|
35 | + */ |
|
36 | + public function testHtmlScriptTagJsApiV3GetHtmlScriptTag() { |
|
37 | + |
|
38 | + $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(); |
|
39 | + $this->assertRegexp('/csrfToken/', $r); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @test |
|
44 | + */ |
|
45 | + public function testAction() { |
|
46 | + |
|
47 | + $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['action' => 'someAction']); |
|
48 | + $this->assertRegexp('/someAction/', $r); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * @test |
|
53 | + */ |
|
54 | + public function testFetchCallbackFunction() { |
|
55 | + |
|
56 | + $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['callback_then' => 'functionCallbackThen']); |
|
57 | + $this->assertRegexp('/functionCallbackThen\(response\)/', $r); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * @test |
|
62 | + */ |
|
63 | + public function testcCatchCallbackFunction() { |
|
64 | + |
|
65 | + $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['callback_catch' => 'functionCallbackCatch']); |
|
66 | + $this->assertRegexp('/functionCallbackCatch\(err\)/', $r); |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * @test |
|
71 | + */ |
|
72 | + public function testCustomValidationFunction() { |
|
73 | + |
|
74 | + $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['custom_validation' => 'functionCustomValidation']); |
|
75 | + $this->assertRegexp('/functionCustomValidation\(token\)/', $r); |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @test |
|
80 | + */ |
|
81 | + public function testValidateController() { |
|
82 | + |
|
83 | + $controller = App::make(ReCaptchaController::class); |
|
84 | + $return = $controller->validateV3(); |
|
85 | + |
|
86 | + $this->assertArrayHasKey("success", $return); |
|
87 | + $this->assertArrayHasKey("error-codes", $return); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Define environment setup. |
|
92 | + * |
|
93 | + * @param \Illuminate\Foundation\Application $app |
|
94 | + * |
|
95 | + * @return void |
|
96 | + */ |
|
97 | + protected function getEnvironmentSetUp($app) { |
|
98 | + |
|
99 | + $app['config']->set('recaptcha.version', 'v3'); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Setup the test environment. |
|
104 | + */ |
|
105 | + protected function setUp() { |
|
106 | + |
|
107 | + parent::setUp(); // TODO: Change the autogenerated stub |
|
108 | + |
|
109 | + $this->recaptcha_v3 = new ReCaptchaBuilderV3('api_site_key', 'api_secret_key'); |
|
110 | + |
|
111 | + } |
|
112 | 112 | } |
113 | 113 | \ No newline at end of file |