1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright (c) 2017 - present |
5
|
|
|
* LaravelGoogleRecaptcha - ReCaptchaCustomApiDomainTest.php |
6
|
|
|
* author: Roberto Belotti - [email protected] |
7
|
|
|
* web : robertobelotti.com, github.com/biscolab |
8
|
|
|
* Initial version created on: 13/9/2020 |
9
|
|
|
* MIT license: https://github.com/biscolab/laravel-recaptcha/blob/master/LICENSE |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Biscolab\ReCaptcha\Tests; |
13
|
|
|
|
14
|
|
|
use Biscolab\ReCaptcha\ReCaptchaBuilderInvisible; |
15
|
|
|
use Biscolab\ReCaptcha\ReCaptchaBuilderV2; |
16
|
|
|
use Biscolab\ReCaptcha\ReCaptchaBuilderV3; |
17
|
|
|
|
18
|
|
|
class ReCaptchaCustomApiDomainTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var ReCaptchaBuilderInvisible |
23
|
|
|
*/ |
24
|
|
|
protected $recaptcha_invisible; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var ReCaptchaBuilderV2 |
28
|
|
|
*/ |
29
|
|
|
protected $recaptcha_v2; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var ReCaptchaBuilderV3 |
33
|
|
|
*/ |
34
|
|
|
protected $recaptcha_v3; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @test |
38
|
|
|
*/ |
39
|
|
|
public function testRecaptchaApiDomainChangesByConfig() |
40
|
|
|
{ |
41
|
|
|
$this->app['config']->set('recaptcha.api_domain', 'www.recaptcha.net'); |
42
|
|
|
$this->assertEquals("www.recaptcha.net", $this->recaptcha_v2->getApiDomain()); |
43
|
|
|
$this->assertEquals("www.recaptcha.net", $this->recaptcha_invisible->getApiDomain()); |
44
|
|
|
$this->assertEquals("www.recaptcha.net", $this->recaptcha_v3->getApiDomain()); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @test |
49
|
|
|
*/ |
50
|
|
|
public function testRecaptchaApiDomainChangesByConfigInHtmlScriptTagJsApi() |
51
|
|
|
{ |
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()); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Define environment setup. |
59
|
|
|
* |
60
|
|
|
* @param \Illuminate\Foundation\Application $app |
61
|
|
|
* |
62
|
|
|
* @return void |
63
|
|
|
*/ |
64
|
|
|
protected function getEnvironmentSetUp($app) |
65
|
|
|
{ |
66
|
|
|
|
67
|
|
|
$app['config']->set('recaptcha.api_domain', 'www.recaptcha.net'); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @inheritdoc |
72
|
|
|
*/ |
73
|
|
|
protected function setUp(): void |
74
|
|
|
{ |
75
|
|
|
|
76
|
|
|
parent::setUp(); // TODO: Change the autogenerated stub |
77
|
|
|
$this->recaptcha_invisible = new ReCaptchaBuilderInvisible('api_site_key', 'api_secret_key'); |
78
|
|
|
$this->recaptcha_v2 = new ReCaptchaBuilderV2('api_site_key', 'api_secret_key'); |
79
|
|
|
$this->recaptcha_v3 = new ReCaptchaBuilderV3('api_site_key', 'api_secret_key'); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|