Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit c405eec

Browse files
committed
Tests fixed due to dependencies compatibility
1 parent e3e7eec commit c405eec

File tree

5 files changed

+17
-19
lines changed

5 files changed

+17
-19
lines changed

tests/ReCaptchaCustomApiDomainTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public function testRecaptchaApiDomainChangesByConfig()
4949
*/
5050
public function testRecaptchaApiDomainChangesByConfigInHtmlScriptTagJsApi()
5151
{
52-
$this->assertContains("https://www.recaptcha.net/recaptcha/api.js", $this->recaptcha_v2->htmlScriptTagJsApi());
53-
$this->assertContains("https://www.recaptcha.net/recaptcha/api.js", $this->recaptcha_invisible->htmlScriptTagJsApi());
54-
$this->assertContains("https://www.recaptcha.net/recaptcha/api.js", $this->recaptcha_v3->htmlScriptTagJsApi());
52+
$this->assertStringContainsString("https://www.recaptcha.net/recaptcha/api.js", $this->recaptcha_v2->htmlScriptTagJsApi());
53+
$this->assertStringContainsString("https://www.recaptcha.net/recaptcha/api.js", $this->recaptcha_invisible->htmlScriptTagJsApi());
54+
$this->assertStringContainsString("https://www.recaptcha.net/recaptcha/api.js", $this->recaptcha_v3->htmlScriptTagJsApi());
5555
}
5656

5757
/**

tests/ReCaptchaHelpersInvisibleTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright (c) 2017 - present
45
* LaravelGoogleRecaptcha - ReCaptchaHelpersInvisibleTest.phpp
@@ -26,7 +27,6 @@ public function testHtmlScriptTagJsApiCalledByFacade()
2627
->with(["form_id" => "test-form"]);
2728

2829
htmlScriptTagJsApi(["form_id" => "test-form"]);
29-
3030
}
3131

3232
/**
@@ -40,7 +40,6 @@ public function testHtmlFormButtonCalledByFacade()
4040
->with("Inner text", ['id' => 'button_id']);
4141

4242
htmlFormButton("Inner text", ['id' => 'button_id']);
43-
4443
}
4544

4645
/**
@@ -53,10 +52,10 @@ public function testGetFormIdCalledByFacade()
5352
->once();
5453

5554
getFormId();
56-
5755
}
5856

59-
public function testHtmlFormButtonConfiguration() {
57+
public function testHtmlFormButtonConfiguration()
58+
{
6059
$button_html = htmlFormButton("Inner text", ['id' => 'button_id', 'class' => 'button_class', 'data-sitekey' => 'custom-data-sitekey', 'data-callback' => 'myCallback']);
6160

6261
$this->assertEquals('<button class="button_class g-recaptcha" data-callback="biscolabLaravelReCaptcha" data-sitekey="api_site_key" id="button_id">Inner text</button>', $button_html);
@@ -69,11 +68,11 @@ public function testHtmlFormButtonConfiguration() {
6968
public function testHtmlFormSnippetCalledByFacade()
7069
{
7170

71+
$this->expectException('\TypeError');
7272
ReCaptcha::shouldReceive('htmlFormSnippet')
7373
->once();
7474

7575
htmlFormSnippet();
76-
7776
}
7877

7978
public function testGetFormIdReturnDefaultFormIdValue()
@@ -95,4 +94,4 @@ protected function getEnvironmentSetUp($app)
9594
$app['config']->set('recaptcha.api_site_key', 'api_site_key');
9695
$app['config']->set('recaptcha.version', 'invisible');
9796
}
98-
}
97+
}

tests/ReCaptchaHelpersV2Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function testExpectReCaptchaInstanceOfReCaptchaBuilderV2()
8383
*/
8484
public function testExpectExceptionWhenGetFormIdFunctionIsCalled()
8585
{
86-
86+
$this->expectException('\Error');
8787
getFormId();
8888
}
8989

tests/ReCaptchaTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function testReCaptchaV2HtmlFormSnippet()
9494
*/
9595
public function testReCaptchaInvisibleHtmlFormSnippetShouldThrowError()
9696
{
97-
97+
$this->expectException('\Error');
9898
$this->recaptcha_invisible->htmlFormSnippet();
9999
}
100100

@@ -157,7 +157,7 @@ public function testDefaultCurlTimeout()
157157
*/
158158
public function testReCaptchaV2htmlFormButtonShouldThrowError()
159159
{
160-
160+
$this->expectException('\Error');
161161
$this->recaptcha_v2->htmlFormButton();
162162
}
163163

tests/ReCaptchaV3Test.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright (c) 2017 - present
45
* LaravelGoogleRecaptcha - ReCaptchaV3Test.php
@@ -40,7 +41,7 @@ public function testAction()
4041
{
4142

4243
$r = $this->recaptcha_v3->htmlScriptTagJsApi(['action' => 'someAction']);
43-
$this->assertRegexp('/someAction/', $r);
44+
$this->assertMatchesRegularExpression('/someAction/', $r);
4445
}
4546

4647
/**
@@ -50,7 +51,7 @@ public function testFetchCallbackFunction()
5051
{
5152

5253
$r = $this->recaptcha_v3->htmlScriptTagJsApi(['callback_then' => 'functionCallbackThen']);
53-
$this->assertRegexp('/functionCallbackThen\(response\)/', $r);
54+
$this->assertMatchesRegularExpression('/functionCallbackThen\(response\)/', $r);
5455
}
5556

5657
/**
@@ -60,7 +61,7 @@ public function testcCatchCallbackFunction()
6061
{
6162

6263
$r = $this->recaptcha_v3->htmlScriptTagJsApi(['callback_catch' => 'functionCallbackCatch']);
63-
$this->assertRegexp('/functionCallbackCatch\(err\)/', $r);
64+
$this->assertMatchesRegularExpression('/functionCallbackCatch\(err\)/', $r);
6465
}
6566

6667
/**
@@ -70,7 +71,7 @@ public function testCustomValidationFunction()
7071
{
7172

7273
$r = $this->recaptcha_v3->htmlScriptTagJsApi(['custom_validation' => 'functionCustomValidation']);
73-
$this->assertRegexp('/functionCustomValidation\(token\)/', $r);
74+
$this->assertMatchesRegularExpression('/functionCustomValidation\(token\)/', $r);
7475
}
7576

7677
/**
@@ -106,7 +107,6 @@ public function testHtmlScriptTagJsApiCalledByFacade()
106107
->with([]);
107108

108109
htmlScriptTagJsApi([]);
109-
110110
}
111111

112112
/**
@@ -132,6 +132,5 @@ protected function setUp(): void
132132
parent::setUp(); // TODO: Change the autogenerated stub
133133

134134
$this->recaptcha_v3 = new ReCaptchaBuilderV3('api_site_key', 'api_secret_key');
135-
136135
}
137-
}
136+
}

0 commit comments

Comments
 (0)