ReCaptchaConfigurationTest::testGetApiSiteKey()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
1
<?php
2
/**
3
 * Copyright (c) 2017 - present
4
 * LaravelGoogleRecaptcha - ReCaptchaConfigurationTest.php
5
 * author: Roberto Belotti - [email protected]
6
 * web : robertobelotti.com, github.com/biscolab
7
 * Initial version created on: 13/2/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\ReCaptchaBuilder;
14
use Biscolab\ReCaptcha\ReCaptchaBuilderV2;
15
16
/**
17
 * Class ReCaptchaConfigurationTest
18
 * @package Biscolab\ReCaptcha\Tests
19
 */
20
class ReCaptchaConfigurationTest extends TestCase
21
{
22
23
	/**
24
	 * @var ReCaptchaBuilder
25
	 */
26
	protected $recaptcha;
27
28
	/**
29
	 * @test
30
	 */
31
	public function testGetApiSiteKey() {
32
		$this->assertEquals("api_site_key", $this->recaptcha->getApiSiteKey());
33
	}
34
35
	/**
36
	 * @test
37
	 */
38
	public function testGetApiSecretKey() {
39
		$this->assertEquals("api_secret_key", $this->recaptcha->getApiSecretKey());
40
	}
41
42
	/**
43
	 * @test
44
	 */
45
	public function testSkipIpWhiteListIsArray()
46
	{
47
48
		$ip_whitelist = $this->recaptcha->getIpWhitelist();
49
		$this->assertTrue(is_array($ip_whitelist));
50
		$this->assertCount(2, $ip_whitelist);
51
52
		$this->assertEquals('10.0.0.1', $ip_whitelist[0]);
53
		$this->assertEquals('10.0.0.2', $ip_whitelist[1]);
54
	}
55
56
	/**
57
	 * @test
58
	 */
59
	public function testCurlTimeoutIsSet()
60
	{
61
62
		$this->assertEquals(3, $this->recaptcha->getCurlTimeout());
63
	}
64
65
	/**
66
	 * Define environment setup.
67
	 *
68
	 * @param  \Illuminate\Foundation\Application $app
69
	 *
70
	 * @return void
71
	 */
72
	protected function getEnvironmentSetUp($app)
73
	{
74
75
		$app['config']->set('recaptcha.api_site_key', 'api_site_key');
76
		$app['config']->set('recaptcha.api_secret_key', 'api_secret_key');
77
		$app['config']->set('recaptcha.skip_ip', '10.0.0.1,10.0.0.2');
78
		$app['config']->set('recaptcha.curl_timeout', 3);
79
	}
80
81
	/**
82
	 * Setup the test environment.
83
	 */
84
	protected function setUp(): void
85
	{
86
87
		parent::setUp(); // TODO: Change the autogenerated stub
88
89
		$this->recaptcha = recaptcha();
90
	}
91
}