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