Passed
Push — master ( 26f295...e4804f )
by Roberto
02:49
created

testHtmlScriptTagJsApiV3GetHtmlScriptTag()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright (c) 2017 - present
4
 * LaravelGoogleRecaptcha - ReCaptchaV3Test.php
5
 * author: Roberto Belotti - [email protected]
6
 * web : robertobelotti.com, github.com/biscolab
7
 * Initial version created on: 22/1/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\ReCaptchaBuilderV3;
14
15
/**
16
 * Class ReCaptchaV3Test
17
 * @package Biscolab\ReCaptcha\Tests
18
 */
19
class ReCaptchaV3Test extends TestCase {
20
21
    protected $recaptcha_v3        = null;
22
23
    /**
24
     * @test
25
     */
26
    public function testGetApiVersion() {
27
        $this->assertEquals($this->recaptcha_v3->getVersion(), 'v3');
28
    }
29
30
    /**
31
     * @test
32
     */
33
    public function testHtmlScriptTagJsApiV3GetHtmlScriptTag() {
34
35
        $r = $this->recaptcha_v3->htmlScriptTagJsApiV3();
36
        $this->assertRegexp('/csrfToken/', $r);
37
    }
38
39
    /**
40
     * @test
41
     */
42
    public function testAction() {
43
44
        $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['action' => 'someAction']);
45
        $this->assertRegexp('/someAction/', $r);
46
    }
47
48
    /**
49
     * @test
50
     */
51
    public function testFetchCallbackFunction() {
52
53
        $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['callback_then' => 'functionCallbackThen']);
54
        $this->assertRegexp('/functionCallbackThen\(response\)/', $r);
55
    }
56
57
    /**
58
     * @test
59
     */
60
    public function testcCatchCallbackFunction() {
61
62
        $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['callback_catch' => 'functionCallbackCatch']);
63
        $this->assertRegexp('/functionCallbackCatch\(err\)/', $r);
64
    }
65
66
    /**
67
     * @test
68
     */
69
    public function testCustomValidationFunction() {
70
71
        $r = $this->recaptcha_v3->htmlScriptTagJsApiV3(['custom_validation' => 'functionCustomValidation']);
72
        $this->assertRegexp('/functionCustomValidation\(token\)/', $r);
73
    }
74
75
    protected function setUp() {
76
77
        parent::setUp(); // TODO: Change the autogenerated stub
78
79
        $this->recaptcha_v3 = new ReCaptchaBuilderV3('api_site_key', 'api_secret_key');
80
81
    }
82
}