Completed
Push — master ( 7b9b82...f4954a )
by Roberto
07:53 queued 11s
created
tests/ReCaptchaConfigurationTest.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -20,67 +20,67 @@
 block discarded – undo
20 20
 class ReCaptchaConfigurationTest extends TestCase
21 21
 {
22 22
 
23
-	/**
24
-	 * @var ReCaptchaBuilder
25
-	 */
26
-	protected $recaptcha;
23
+    /**
24
+     * @var ReCaptchaBuilder
25
+     */
26
+    protected $recaptcha;
27 27
 
28
-	/**
29
-	 * @test
30
-	 */
31
-	public function testGetApiSiteKey() {
32
-		$this->assertEquals("api_site_key", $this->recaptcha->getApiSiteKey());
33
-	}
28
+    /**
29
+     * @test
30
+     */
31
+    public function testGetApiSiteKey() {
32
+        $this->assertEquals("api_site_key", $this->recaptcha->getApiSiteKey());
33
+    }
34 34
 
35
-	/**
36
-	 * @test
37
-	 */
38
-	public function testGetApiSecretKey() {
39
-		$this->assertEquals("api_secret_key", $this->recaptcha->getApiSecretKey());
40
-	}
35
+    /**
36
+     * @test
37
+     */
38
+    public function testGetApiSecretKey() {
39
+        $this->assertEquals("api_secret_key", $this->recaptcha->getApiSecretKey());
40
+    }
41 41
 
42
-	/**
43
-	 * @test
44
-	 */
45
-	public function testSkipIpWhiteListIsArray()
46
-	{
42
+    /**
43
+     * @test
44
+     */
45
+    public function testSkipIpWhiteListIsArray()
46
+    {
47 47
 
48
-		$ip_whitelist = $this->recaptcha->getIpWhitelist();
49
-		$this->assertTrue(is_array($ip_whitelist));
50
-		$this->assertCount(2, $ip_whitelist);
51
-	}
48
+        $ip_whitelist = $this->recaptcha->getIpWhitelist();
49
+        $this->assertTrue(is_array($ip_whitelist));
50
+        $this->assertCount(2, $ip_whitelist);
51
+    }
52 52
 
53
-	/**
54
-	 * @test
55
-	 */
56
-	public function testCurlTimeoutIsSet()
57
-	{
53
+    /**
54
+     * @test
55
+     */
56
+    public function testCurlTimeoutIsSet()
57
+    {
58 58
 
59
-		$this->assertEquals(3, $this->recaptcha->getCurlTimeout());
60
-	}
59
+        $this->assertEquals(3, $this->recaptcha->getCurlTimeout());
60
+    }
61 61
 
62
-	/**
63
-	 * Define environment setup.
64
-	 *
65
-	 * @param  \Illuminate\Foundation\Application $app
66
-	 *
67
-	 * @return void
68
-	 */
69
-	protected function getEnvironmentSetUp($app)
70
-	{
62
+    /**
63
+     * Define environment setup.
64
+     *
65
+     * @param  \Illuminate\Foundation\Application $app
66
+     *
67
+     * @return void
68
+     */
69
+    protected function getEnvironmentSetUp($app)
70
+    {
71 71
 
72
-		$app['config']->set('recaptcha.skip_ip', '10.0.0.1,10.0.0.2');
73
-		$app['config']->set('recaptcha.curl_timeout', 3);
74
-	}
72
+        $app['config']->set('recaptcha.skip_ip', '10.0.0.1,10.0.0.2');
73
+        $app['config']->set('recaptcha.curl_timeout', 3);
74
+    }
75 75
 
76
-	/**
77
-	 * Setup the test environment.
78
-	 */
79
-	protected function setUp(): void
80
-	{
76
+    /**
77
+     * Setup the test environment.
78
+     */
79
+    protected function setUp(): void
80
+    {
81 81
 
82
-		parent::setUp(); // TODO: Change the autogenerated stub
82
+        parent::setUp(); // TODO: Change the autogenerated stub
83 83
 
84
-		$this->recaptcha = new ReCaptchaBuilderV2('api_site_key', 'api_secret_key');
85
-	}
84
+        $this->recaptcha = new ReCaptchaBuilderV2('api_site_key', 'api_secret_key');
85
+    }
86 86
 }
87 87
\ No newline at end of file
Please login to merge, or discard this patch.
tests/ReCaptchaTest.php 1 patch
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -23,169 +23,169 @@
 block discarded – undo
23 23
 class ReCaptchaTest extends TestCase
24 24
 {
25 25
 
26
-	/**
27
-	 * @var ReCaptchaBuilderInvisible
28
-	 */
29
-	protected $recaptcha_invisible = null;
30
-
31
-	/**
32
-	 * @var ReCaptchaBuilderV2
33
-	 */
34
-	protected $recaptcha_v2 = null;
35
-
36
-	/**
37
-	 * @var ReCaptchaBuilderV3
38
-	 */
39
-	protected $recaptcha_v3 = null;
40
-
41
-	/**
42
-	 * @tests
43
-	 */
44
-	public function testHtmlScriptTagJsApiGetHtmlScriptTag()
45
-	{
46
-
47
-		$r = ReCaptcha::htmlScriptTagJsApi();
48
-		$this->assertEquals('<script src="https://www.google.com/recaptcha/api.js" async defer></script>', $r);
49
-	}
50
-
51
-	/**
52
-	 * @test
53
-	 */
54
-	public function testReCaptchaInvisibleHtmlFormButtonDefault()
55
-	{
56
-
57
-		$recaptcha = $this->recaptcha_invisible;
58
-		$html_button = $recaptcha->htmlFormButton();
59
-		$this->assertEquals('<button class="g-recaptcha" data-sitekey="api_site_key" data-callback="biscolabLaravelReCaptcha">Submit</button>',
60
-			$html_button);
61
-	}
62
-
63
-	/**
64
-	 * @test
65
-	 */
66
-	public function testReCaptchaInvisibleHtmlFormButtonCustom()
67
-	{
68
-
69
-		$recaptcha = $this->recaptcha_invisible;
70
-		$html_button = $recaptcha->htmlFormButton('Custom Text');
71
-		$this->assertEquals('<button class="g-recaptcha" data-sitekey="api_site_key" data-callback="biscolabLaravelReCaptcha">Custom Text</button>',
72
-			$html_button);
73
-	}
74
-
75
-	/**
76
-	 * @test
77
-	 */
78
-	public function testReCaptchaV2HtmlFormSnippet()
79
-	{
80
-
81
-		$recaptcha = $this->recaptcha_v2;
82
-		$html_snippet = $recaptcha->htmlFormSnippet();
83
-		$this->assertEquals('<div class="g-recaptcha" data-sitekey="api_site_key"></div>', $html_snippet);
84
-	}
85
-
86
-	/**
87
-	 * @test
88
-	 * @expectedException     \Error
89
-	 */
90
-	public function testReCaptchaInvisibleHtmlFormSnippetShouldThrowError()
91
-	{
92
-
93
-		$this->recaptcha_invisible->htmlFormSnippet();
94
-	}
95
-
96
-	/**
97
-	 * @test
98
-	 */
99
-	public function testSkipByIpAndReturnArrayReturnsDefaultArray()
100
-	{
101
-
102
-		$mock = $this->getMockBuilder(ReCaptchaBuilder::class)
103
-			->setConstructorArgs([
104
-				"api_site_key",
105
-				"api_secret_key"
106
-			])
107
-			->setMethods([
108
-				'returnArray'
109
-			])
110
-			->getMock();
111
-
112
-		$mock->method('returnArray')
113
-			->willReturn(true);
114
-
115
-		$this->setSkipByIp($this->recaptcha_v3, true);
116
-
117
-		$validate = $this->recaptcha_v3->validate("");
118
-
119
-		$this->assertEquals([
120
-			"skip_by_ip" => true,
121
-			"score"      => 0.9,
122
-			"success"    => true
123
-		], $validate);
124
-	}
125
-
126
-	/**
127
-	 * @test
128
-	 */
129
-	public function testSlipByIpReturnsValidResponse()
130
-	{
131
-
132
-		$this->setSkipByIp($this->recaptcha_invisible, true);
133
-		$validate = $this->recaptcha_invisible->validate("");
134
-
135
-		$this->assertTrue($validate);
136
-	}
137
-
138
-	/**
139
-	 * @test
140
-	 * @expectedException     \Exception
141
-	 */
142
-	public function testReCaptchaInvisibleHtmlScriptTagJsApiShouldThrowError()
143
-	{
144
-
145
-		$this->recaptcha_invisible->htmlScriptTagJsApi();
146
-	}
147
-
148
-	/**
149
-	 * @test
150
-	 */
151
-	public function testDefaultCurlTimeout()
152
-	{
153
-
154
-		$this->assertEquals($this->recaptcha_invisible->getCurlTimeout(), ReCaptchaBuilder::DEFAULT_CURL_TIMEOUT);
155
-		$this->assertEquals($this->recaptcha_v2->getCurlTimeout(), ReCaptchaBuilder::DEFAULT_CURL_TIMEOUT);
156
-		$this->assertEquals($this->recaptcha_v3->getCurlTimeout(), ReCaptchaBuilder::DEFAULT_CURL_TIMEOUT);
157
-	}
158
-
159
-	/**
160
-	 * @test
161
-	 * @expectedException     \Error
162
-	 */
163
-	public function testReCaptchaV2htmlFormButtonShouldThrowError()
164
-	{
165
-
166
-		$this->recaptcha_v2->htmlFormButton();
167
-	}
168
-
169
-	protected function setSkipByIp(ReCaptchaBuilder $builder, bool $value)
170
-	{
171
-
172
-		$reflection = new \ReflectionClass($builder);
173
-		$reflection_property = $reflection->getProperty('skip_by_ip');
174
-		$reflection_property->setAccessible(true);
175
-		$reflection_property->setValue($builder, $value);
176
-	}
177
-
178
-	/**
179
-	 * @inheritdoc
180
-	 */
181
-	protected function setUp(): void
182
-	{
183
-
184
-		parent::setUp(); // TODO: Change the autogenerated stub
185
-
186
-		$this->recaptcha_invisible = new ReCaptchaBuilderInvisible('api_site_key', 'api_secret_key');
187
-		$this->recaptcha_v2 = new ReCaptchaBuilderV2('api_site_key', 'api_secret_key');
188
-		$this->recaptcha_v3 = new ReCaptchaBuilderV3('api_site_key', 'api_secret_key');
189
-
190
-	}
26
+    /**
27
+     * @var ReCaptchaBuilderInvisible
28
+     */
29
+    protected $recaptcha_invisible = null;
30
+
31
+    /**
32
+     * @var ReCaptchaBuilderV2
33
+     */
34
+    protected $recaptcha_v2 = null;
35
+
36
+    /**
37
+     * @var ReCaptchaBuilderV3
38
+     */
39
+    protected $recaptcha_v3 = null;
40
+
41
+    /**
42
+     * @tests
43
+     */
44
+    public function testHtmlScriptTagJsApiGetHtmlScriptTag()
45
+    {
46
+
47
+        $r = ReCaptcha::htmlScriptTagJsApi();
48
+        $this->assertEquals('<script src="https://www.google.com/recaptcha/api.js" async defer></script>', $r);
49
+    }
50
+
51
+    /**
52
+     * @test
53
+     */
54
+    public function testReCaptchaInvisibleHtmlFormButtonDefault()
55
+    {
56
+
57
+        $recaptcha = $this->recaptcha_invisible;
58
+        $html_button = $recaptcha->htmlFormButton();
59
+        $this->assertEquals('<button class="g-recaptcha" data-sitekey="api_site_key" data-callback="biscolabLaravelReCaptcha">Submit</button>',
60
+            $html_button);
61
+    }
62
+
63
+    /**
64
+     * @test
65
+     */
66
+    public function testReCaptchaInvisibleHtmlFormButtonCustom()
67
+    {
68
+
69
+        $recaptcha = $this->recaptcha_invisible;
70
+        $html_button = $recaptcha->htmlFormButton('Custom Text');
71
+        $this->assertEquals('<button class="g-recaptcha" data-sitekey="api_site_key" data-callback="biscolabLaravelReCaptcha">Custom Text</button>',
72
+            $html_button);
73
+    }
74
+
75
+    /**
76
+     * @test
77
+     */
78
+    public function testReCaptchaV2HtmlFormSnippet()
79
+    {
80
+
81
+        $recaptcha = $this->recaptcha_v2;
82
+        $html_snippet = $recaptcha->htmlFormSnippet();
83
+        $this->assertEquals('<div class="g-recaptcha" data-sitekey="api_site_key"></div>', $html_snippet);
84
+    }
85
+
86
+    /**
87
+     * @test
88
+     * @expectedException     \Error
89
+     */
90
+    public function testReCaptchaInvisibleHtmlFormSnippetShouldThrowError()
91
+    {
92
+
93
+        $this->recaptcha_invisible->htmlFormSnippet();
94
+    }
95
+
96
+    /**
97
+     * @test
98
+     */
99
+    public function testSkipByIpAndReturnArrayReturnsDefaultArray()
100
+    {
101
+
102
+        $mock = $this->getMockBuilder(ReCaptchaBuilder::class)
103
+            ->setConstructorArgs([
104
+                "api_site_key",
105
+                "api_secret_key"
106
+            ])
107
+            ->setMethods([
108
+                'returnArray'
109
+            ])
110
+            ->getMock();
111
+
112
+        $mock->method('returnArray')
113
+            ->willReturn(true);
114
+
115
+        $this->setSkipByIp($this->recaptcha_v3, true);
116
+
117
+        $validate = $this->recaptcha_v3->validate("");
118
+
119
+        $this->assertEquals([
120
+            "skip_by_ip" => true,
121
+            "score"      => 0.9,
122
+            "success"    => true
123
+        ], $validate);
124
+    }
125
+
126
+    /**
127
+     * @test
128
+     */
129
+    public function testSlipByIpReturnsValidResponse()
130
+    {
131
+
132
+        $this->setSkipByIp($this->recaptcha_invisible, true);
133
+        $validate = $this->recaptcha_invisible->validate("");
134
+
135
+        $this->assertTrue($validate);
136
+    }
137
+
138
+    /**
139
+     * @test
140
+     * @expectedException     \Exception
141
+     */
142
+    public function testReCaptchaInvisibleHtmlScriptTagJsApiShouldThrowError()
143
+    {
144
+
145
+        $this->recaptcha_invisible->htmlScriptTagJsApi();
146
+    }
147
+
148
+    /**
149
+     * @test
150
+     */
151
+    public function testDefaultCurlTimeout()
152
+    {
153
+
154
+        $this->assertEquals($this->recaptcha_invisible->getCurlTimeout(), ReCaptchaBuilder::DEFAULT_CURL_TIMEOUT);
155
+        $this->assertEquals($this->recaptcha_v2->getCurlTimeout(), ReCaptchaBuilder::DEFAULT_CURL_TIMEOUT);
156
+        $this->assertEquals($this->recaptcha_v3->getCurlTimeout(), ReCaptchaBuilder::DEFAULT_CURL_TIMEOUT);
157
+    }
158
+
159
+    /**
160
+     * @test
161
+     * @expectedException     \Error
162
+     */
163
+    public function testReCaptchaV2htmlFormButtonShouldThrowError()
164
+    {
165
+
166
+        $this->recaptcha_v2->htmlFormButton();
167
+    }
168
+
169
+    protected function setSkipByIp(ReCaptchaBuilder $builder, bool $value)
170
+    {
171
+
172
+        $reflection = new \ReflectionClass($builder);
173
+        $reflection_property = $reflection->getProperty('skip_by_ip');
174
+        $reflection_property->setAccessible(true);
175
+        $reflection_property->setValue($builder, $value);
176
+    }
177
+
178
+    /**
179
+     * @inheritdoc
180
+     */
181
+    protected function setUp(): void
182
+    {
183
+
184
+        parent::setUp(); // TODO: Change the autogenerated stub
185
+
186
+        $this->recaptcha_invisible = new ReCaptchaBuilderInvisible('api_site_key', 'api_secret_key');
187
+        $this->recaptcha_v2 = new ReCaptchaBuilderV2('api_site_key', 'api_secret_key');
188
+        $this->recaptcha_v3 = new ReCaptchaBuilderV3('api_site_key', 'api_secret_key');
189
+
190
+    }
191 191
 }
192 192
\ No newline at end of file
Please login to merge, or discard this patch.
tests/TestCase.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -21,31 +21,31 @@
 block discarded – undo
21 21
 class TestCase extends OrchestraTestCase
22 22
 {
23 23
 
24
-	/**
25
-	 * Load package alias
26
-	 *
27
-	 * @param  \Illuminate\Foundation\Application $app
28
-	 *
29
-	 * @return array
30
-	 */
31
-	protected function getPackageAliases($app)
32
-	{
24
+    /**
25
+     * Load package alias
26
+     *
27
+     * @param  \Illuminate\Foundation\Application $app
28
+     *
29
+     * @return array
30
+     */
31
+    protected function getPackageAliases($app)
32
+    {
33 33
 
34
-		return [
35
-			'ReCaptcha' => ReCaptcha::class,
36
-		];
37
-	}
34
+        return [
35
+            'ReCaptcha' => ReCaptcha::class,
36
+        ];
37
+    }
38 38
 
39
-	/**
40
-	 * Load package service provider
41
-	 *
42
-	 * @param \Illuminate\Foundation\Application $app
43
-	 *
44
-	 * @return array
45
-	 */
46
-	protected function getPackageProviders($app)
47
-	{
39
+    /**
40
+     * Load package service provider
41
+     *
42
+     * @param \Illuminate\Foundation\Application $app
43
+     *
44
+     * @return array
45
+     */
46
+    protected function getPackageProviders($app)
47
+    {
48 48
 
49
-		return [ReCaptchaServiceProvider::class];
50
-	}
49
+        return [ReCaptchaServiceProvider::class];
50
+    }
51 51
 }
Please login to merge, or discard this patch.
tests/ReCaptchaHelpersInvisibleTest.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -17,71 +17,71 @@
 block discarded – undo
17 17
 class ReCaptchaHelpersInvisibleTest extends TestCase
18 18
 {
19 19
 
20
-	/**
21
-	 * @test
22
-	 */
23
-	public function testHtmlScriptTagJsApiCalledByFacade()
24
-	{
25
-		ReCaptcha::shouldReceive('htmlScriptTagJsApi')
26
-			->once()
27
-			->with("key");
28
-
29
-		htmlScriptTagJsApi("key");
30
-
31
-	}
32
-
33
-	/**
34
-	 * @test
35
-	 */
36
-	public function testHtmlScriptTagJsApiV3CalledByFacade()
37
-	{
38
-		ReCaptcha::shouldReceive('htmlScriptTagJsApiV3')
39
-			->once()
40
-			->with([]);
41
-
42
-		htmlScriptTagJsApiV3([]);
43
-
44
-	}
45
-
46
-	/**
47
-	 * @test
48
-	 */
49
-	public function testHtmlFormButtonCalledByFacade()
50
-	{
51
-		ReCaptcha::shouldReceive('htmlFormButton')
52
-			->once()
53
-			->with("key");
54
-
55
-		htmlFormButton("key");
56
-
57
-	}
58
-
59
-	/**
60
-	 * @test
61
-	 * @expectedException \TypeError
62
-	 */
63
-	public function testHtmlFormSnippetCalledByFacade()
64
-	{
65
-		ReCaptcha::shouldReceive('htmlFormSnippet')
66
-			->once();
67
-
68
-		htmlFormSnippet();
69
-
70
-	}
71
-
72
-
73
-	/**
74
-	 * Define environment setup.
75
-	 *
76
-	 * @param  \Illuminate\Foundation\Application $app
77
-	 *
78
-	 * @return void
79
-	 */
80
-	protected function getEnvironmentSetUp($app)
81
-	{
82
-
83
-		$app['config']->set('recaptcha.api_site_key', 'api_site_key');
84
-		$app['config']->set('recaptcha.api_site_key', 'api_site_key');
85
-		$app['config']->set('recaptcha.version', 'invisible');
86
-	}
20
+    /**
21
+     * @test
22
+     */
23
+    public function testHtmlScriptTagJsApiCalledByFacade()
24
+    {
25
+        ReCaptcha::shouldReceive('htmlScriptTagJsApi')
26
+            ->once()
27
+            ->with("key");
28
+
29
+        htmlScriptTagJsApi("key");
30
+
31
+    }
32
+
33
+    /**
34
+     * @test
35
+     */
36
+    public function testHtmlScriptTagJsApiV3CalledByFacade()
37
+    {
38
+        ReCaptcha::shouldReceive('htmlScriptTagJsApiV3')
39
+            ->once()
40
+            ->with([]);
41
+
42
+        htmlScriptTagJsApiV3([]);
43
+
44
+    }
45
+
46
+    /**
47
+     * @test
48
+     */
49
+    public function testHtmlFormButtonCalledByFacade()
50
+    {
51
+        ReCaptcha::shouldReceive('htmlFormButton')
52
+            ->once()
53
+            ->with("key");
54
+
55
+        htmlFormButton("key");
56
+
57
+    }
58
+
59
+    /**
60
+     * @test
61
+     * @expectedException \TypeError
62
+     */
63
+    public function testHtmlFormSnippetCalledByFacade()
64
+    {
65
+        ReCaptcha::shouldReceive('htmlFormSnippet')
66
+            ->once();
67
+
68
+        htmlFormSnippet();
69
+
70
+    }
71
+
72
+
73
+    /**
74
+     * Define environment setup.
75
+     *
76
+     * @param  \Illuminate\Foundation\Application $app
77
+     *
78
+     * @return void
79
+     */
80
+    protected function getEnvironmentSetUp($app)
81
+    {
82
+
83
+        $app['config']->set('recaptcha.api_site_key', 'api_site_key');
84
+        $app['config']->set('recaptcha.api_site_key', 'api_site_key');
85
+        $app['config']->set('recaptcha.version', 'invisible');
86
+    }
87 87
 }
88 88
\ No newline at end of file
Please login to merge, or discard this patch.
tests/ReCaptchaV3Test.php 1 patch
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -21,112 +21,112 @@
 block discarded – undo
21 21
 class ReCaptchaV3Test extends TestCase
22 22
 {
23 23
 
24
-	protected $recaptcha_v3 = null;
25
-
26
-	/**
27
-	 * @test
28
-	 */
29
-	public function testGetApiVersion()
30
-	{
31
-
32
-		$this->assertEquals($this->recaptcha_v3->getVersion(), 'v3');
33
-	}
34
-
35
-	/**
36
-	 * @test
37
-	 */
38
-	public function testHtmlScriptTagJsApiV3GetHtmlScriptTag()
39
-	{
40
-
41
-		$r = $this->recaptcha_v3->htmlScriptTagJsApiV3();
42
-		$this->assertRegexp('/csrfToken/', $r);
43
-	}
44
-
45
-	/**
46
-	 * @test
47
-	 */
48
-	public function testAction()
49
-	{
50
-
51
-		$r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['action' => 'someAction']);
52
-		$this->assertRegexp('/someAction/', $r);
53
-	}
54
-
55
-	/**
56
-	 * @test
57
-	 */
58
-	public function testFetchCallbackFunction()
59
-	{
60
-
61
-		$r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['callback_then' => 'functionCallbackThen']);
62
-		$this->assertRegexp('/functionCallbackThen\(response\)/', $r);
63
-	}
64
-
65
-	/**
66
-	 * @test
67
-	 */
68
-	public function testcCatchCallbackFunction()
69
-	{
70
-
71
-		$r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['callback_catch' => 'functionCallbackCatch']);
72
-		$this->assertRegexp('/functionCallbackCatch\(err\)/', $r);
73
-	}
74
-
75
-	/**
76
-	 * @test
77
-	 */
78
-	public function testCustomValidationFunction()
79
-	{
80
-
81
-		$r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['custom_validation' => 'functionCustomValidation']);
82
-		$this->assertRegexp('/functionCustomValidation\(token\)/', $r);
83
-	}
84
-
85
-	/**
86
-	 * @test
87
-	 */
88
-	public function testValidateController()
89
-	{
90
-
91
-		$controller = App::make(ReCaptchaController::class);
92
-		$return = $controller->validateV3();
93
-
94
-		$this->assertArrayHasKey("success", $return);
95
-		$this->assertArrayHasKey("error-codes", $return);
96
-	}
97
-
98
-	/**
99
-	 * @test
100
-	 */
101
-	public function testCurlTimeoutIsSet()
102
-	{
103
-
104
-		$this->assertEquals($this->recaptcha_v3->getCurlTimeout(), 3);
105
-	}
106
-
107
-	/**
108
-	 * Define environment setup.
109
-	 *
110
-	 * @param  \Illuminate\Foundation\Application $app
111
-	 *
112
-	 * @return void
113
-	 */
114
-	protected function getEnvironmentSetUp($app)
115
-	{
116
-
117
-		$app['config']->set('recaptcha.version', 'v3');
118
-		$app['config']->set('recaptcha.curl_timeout', 3);
119
-	}
120
-
121
-	/**
122
-	 * Setup the test environment.
123
-	 */
124
-	protected function setUp(): void
125
-	{
126
-
127
-		parent::setUp(); // TODO: Change the autogenerated stub
128
-
129
-		$this->recaptcha_v3 = new ReCaptchaBuilderV3('api_site_key', 'api_secret_key');
130
-
131
-	}
24
+    protected $recaptcha_v3 = null;
25
+
26
+    /**
27
+     * @test
28
+     */
29
+    public function testGetApiVersion()
30
+    {
31
+
32
+        $this->assertEquals($this->recaptcha_v3->getVersion(), 'v3');
33
+    }
34
+
35
+    /**
36
+     * @test
37
+     */
38
+    public function testHtmlScriptTagJsApiV3GetHtmlScriptTag()
39
+    {
40
+
41
+        $r = $this->recaptcha_v3->htmlScriptTagJsApiV3();
42
+        $this->assertRegexp('/csrfToken/', $r);
43
+    }
44
+
45
+    /**
46
+     * @test
47
+     */
48
+    public function testAction()
49
+    {
50
+
51
+        $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['action' => 'someAction']);
52
+        $this->assertRegexp('/someAction/', $r);
53
+    }
54
+
55
+    /**
56
+     * @test
57
+     */
58
+    public function testFetchCallbackFunction()
59
+    {
60
+
61
+        $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['callback_then' => 'functionCallbackThen']);
62
+        $this->assertRegexp('/functionCallbackThen\(response\)/', $r);
63
+    }
64
+
65
+    /**
66
+     * @test
67
+     */
68
+    public function testcCatchCallbackFunction()
69
+    {
70
+
71
+        $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['callback_catch' => 'functionCallbackCatch']);
72
+        $this->assertRegexp('/functionCallbackCatch\(err\)/', $r);
73
+    }
74
+
75
+    /**
76
+     * @test
77
+     */
78
+    public function testCustomValidationFunction()
79
+    {
80
+
81
+        $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['custom_validation' => 'functionCustomValidation']);
82
+        $this->assertRegexp('/functionCustomValidation\(token\)/', $r);
83
+    }
84
+
85
+    /**
86
+     * @test
87
+     */
88
+    public function testValidateController()
89
+    {
90
+
91
+        $controller = App::make(ReCaptchaController::class);
92
+        $return = $controller->validateV3();
93
+
94
+        $this->assertArrayHasKey("success", $return);
95
+        $this->assertArrayHasKey("error-codes", $return);
96
+    }
97
+
98
+    /**
99
+     * @test
100
+     */
101
+    public function testCurlTimeoutIsSet()
102
+    {
103
+
104
+        $this->assertEquals($this->recaptcha_v3->getCurlTimeout(), 3);
105
+    }
106
+
107
+    /**
108
+     * Define environment setup.
109
+     *
110
+     * @param  \Illuminate\Foundation\Application $app
111
+     *
112
+     * @return void
113
+     */
114
+    protected function getEnvironmentSetUp($app)
115
+    {
116
+
117
+        $app['config']->set('recaptcha.version', 'v3');
118
+        $app['config']->set('recaptcha.curl_timeout', 3);
119
+    }
120
+
121
+    /**
122
+     * Setup the test environment.
123
+     */
124
+    protected function setUp(): void
125
+    {
126
+
127
+        parent::setUp(); // TODO: Change the autogenerated stub
128
+
129
+        $this->recaptcha_v3 = new ReCaptchaBuilderV3('api_site_key', 'api_secret_key');
130
+
131
+    }
132 132
 }
133 133
\ No newline at end of file
Please login to merge, or discard this patch.
tests/ReCaptchaHelpersV2Test.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -17,71 +17,71 @@
 block discarded – undo
17 17
 class ReCaptchaHelpersV2Test extends TestCase
18 18
 {
19 19
 
20
-	/**
21
-	 * @test
22
-	 */
23
-	public function testHtmlScriptTagJsApiCalledByFacade()
24
-	{
25
-		ReCaptcha::shouldReceive('htmlScriptTagJsApi')
26
-			->once()
27
-			->with("key");
28
-
29
-		htmlScriptTagJsApi("key");
30
-
31
-	}
32
-
33
-	/**
34
-	 * @test
35
-	 */
36
-	public function testHtmlScriptTagJsApiV3CalledByFacade()
37
-	{
38
-		ReCaptcha::shouldReceive('htmlScriptTagJsApiV3')
39
-			->once()
40
-			->with([]);
41
-
42
-		htmlScriptTagJsApiV3([]);
43
-
44
-	}
45
-
46
-	/**
47
-	 * @test
48
-	 * @expectedException \TypeError
49
-	 */
50
-	public function testHtmlFormButtonCalledByFacade()
51
-	{
52
-		ReCaptcha::shouldReceive('htmlFormButton')
53
-			->once()
54
-			->with("key");
55
-
56
-		htmlFormButton("key");
57
-
58
-	}
59
-
60
-	/**
61
-	 * @test
62
-	 */
63
-	public function testHtmlFormSnippetCalledByFacade()
64
-	{
65
-		ReCaptcha::shouldReceive('htmlFormSnippet')
66
-			->once();
67
-
68
-		htmlFormSnippet();