|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright (c) 2017 - present |
|
5
|
|
|
* LaravelGoogleRecaptcha - ReCaptchaHelpersInvisibleTest.phpp |
|
6
|
|
|
* author: Roberto Belotti - [email protected] |
|
7
|
|
|
* web : robertobelotti.com, github.com/biscolab |
|
8
|
|
|
* Initial version created on: 8/8/2019 |
|
9
|
|
|
* MIT license: https://github.com/biscolab/laravel-recaptcha/blob/master/LICENSE |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Biscolab\ReCaptcha\Tests; |
|
13
|
|
|
|
|
14
|
|
|
use Biscolab\ReCaptcha\Facades\ReCaptcha; |
|
15
|
|
|
|
|
16
|
|
|
class ReCaptchaHelpersInvisibleTest extends TestCase |
|
17
|
|
|
{ |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @test |
|
21
|
|
|
*/ |
|
22
|
|
|
public function testHtmlScriptTagJsApiCalledByFacade() |
|
23
|
|
|
{ |
|
24
|
|
|
|
|
25
|
|
|
ReCaptcha::shouldReceive('htmlScriptTagJsApi') |
|
26
|
|
|
->once() |
|
27
|
|
|
->with(["form_id" => "test-form"]); |
|
28
|
|
|
|
|
29
|
|
|
htmlScriptTagJsApi(["form_id" => "test-form"]); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @test |
|
34
|
|
|
*/ |
|
35
|
|
|
public function testHtmlFormButtonCalledByFacade() |
|
36
|
|
|
{ |
|
37
|
|
|
|
|
38
|
|
|
ReCaptcha::shouldReceive('htmlFormButton') |
|
39
|
|
|
->once() |
|
40
|
|
|
->with("Inner text", ['id' => 'button_id']); |
|
41
|
|
|
|
|
42
|
|
|
htmlFormButton("Inner text", ['id' => 'button_id']); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @test |
|
47
|
|
|
*/ |
|
48
|
|
|
public function testGetFormIdCalledByFacade() |
|
49
|
|
|
{ |
|
50
|
|
|
|
|
51
|
|
|
ReCaptcha::shouldReceive('getFormId') |
|
52
|
|
|
->once(); |
|
53
|
|
|
|
|
54
|
|
|
getFormId(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function testHtmlFormButtonConfiguration() |
|
58
|
|
|
{ |
|
59
|
|
|
$button_html = htmlFormButton("Inner text", ['id' => 'button_id', 'class' => 'button_class', 'data-sitekey' => 'custom-data-sitekey', 'data-callback' => 'myCallback']); |
|
60
|
|
|
|
|
61
|
|
|
$this->assertEquals('<button class="button_class g-recaptcha" data-callback="biscolabLaravelReCaptcha" data-sitekey="api_site_key" id="button_id">Inner text</button>', $button_html); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @test |
|
66
|
|
|
* @expectedException \TypeError |
|
67
|
|
|
*/ |
|
68
|
|
|
public function testHtmlFormSnippetCalledByFacade() |
|
69
|
|
|
{ |
|
70
|
|
|
|
|
71
|
|
|
$this->expectException('\TypeError'); |
|
72
|
|
|
ReCaptcha::shouldReceive('htmlFormSnippet') |
|
73
|
|
|
->once(); |
|
74
|
|
|
|
|
75
|
|
|
htmlFormSnippet(); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function testGetFormIdReturnDefaultFormIdValue() |
|
79
|
|
|
{ |
|
80
|
|
|
$this->assertEquals('biscolab-recaptcha-invisible-form', getFormId()); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Define environment setup. |
|
85
|
|
|
* |
|
86
|
|
|
* @param \Illuminate\Foundation\Application $app |
|
87
|
|
|
* |
|
88
|
|
|
* @return void |
|
89
|
|
|
*/ |
|
90
|
|
|
protected function getEnvironmentSetUp($app) |
|
91
|
|
|
{ |
|
92
|
|
|
|
|
93
|
|
|
$app['config']->set('recaptcha.api_site_key', 'api_site_key'); |
|
94
|
|
|
$app['config']->set('recaptcha.api_site_key', 'api_site_key'); |
|
95
|
|
|
$app['config']->set('recaptcha.version', 'invisible'); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|