Passed
Push — master ( fa46b3...ce6672 )
by Ylva
05:16 queued 02:30
created

IpHandlerTest::testDomainNameInvalid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
nc 1
nop 0
dl 0
loc 6
c 1
b 0
f 0
cc 1
rs 10
1
<?php
2
3
namespace Ylvan\Models;
4
5
use Anax\DI\DIFactoryConfig;
0 ignored issues
show
Bug introduced by
The type Anax\DI\DIFactoryConfig was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use PHPUnit\Framework\TestCase;
7
8
/**
9
 * Test the helprt class IpHandler.
10
 */
11
class IpHandlerTest extends TestCase
12
{
13
14
    /**
15
     * Test get user IP
16
     */
17
    public function testGetUserIpContent()
18
    {
19
        $ipClass = new IpHandler();
20
        // $ipClass->ipv4();
21
        $res = $ipClass->getUserIp();
22
        $this->assertNotNull($res);
23
    }
24
25
26
    /**
27
     * Test get user IP
28
     */
29
    // public function testGetUserIp()
30
    // {
31
    //     $ipClass = new IpHandler();
32
    //     // $ipClass->ipv4();
33
    //     $res = $ipClass->getUserIp();
34
    //     $this->assertIsString($res);
35
    // }
36
37
38
    /**
39
     * Test the general validation method using ipv4.
40
     */
41
    public function testIpIsvalidIpv4()
42
    {
43
        $ipClass = new IpHandler();
44
        // $ipClass->ipv4();
45
        $res = $ipClass->ipIsValid("8.8.8.8");
46
        $this->assertContains("true", $res);
47
    }
48
49
50
    /**
51
     * Test the general validation method using ipv6.
52
     */
53
    public function testIpIsvalidIpv6()
54
    {
55
        $ipClass = new IpHandler();
56
        // $ipClass->ipv4();
57
        $res = $ipClass->ipIsValid("2001:4860:4860::8888");
58
        $this->assertContains("true", $res);
59
    }
60
61
62
    /**
63
     * Test the general validation method using ipv6.
64
     */
65
    public function testIpIsvalidFail()
66
    {
67
        $ipClass = new IpHandler();
68
        $res = $ipClass->ipIsValid("invalid");
69
        $this->assertContains("false", $res);
70
    }
71
72
73
    /**
74
     * Test the ipv4 validation method.
75
     */
76
    public function testIpv4Invalid()
77
    {
78
        $ipClass = new IpHandler();
79
        $res = $ipClass->ipv4("invalid");
80
        $this->assertContains("Validerar ej", $res);
81
    }
82
83
84
    /**
85
     * Test the ipv4 validation method.
86
     */
87
    public function testIpv4Valid()
88
    {
89
        $ipClass = new IpHandler();
90
        $res = $ipClass->ipv4("8.8.8.8");
91
        $this->assertContains("Validerar", $res);
92
    }
93
94
95
    /**
96
     * Test the ipv4 validation method.
97
     */
98
    // public function testIpv4Type()
99
    // {
100
    //     $ipClass = new IpHandler();
101
    //     // $ipClass->ipv4();
102
    //     $res = $ipClass->ipv4("8.8.8.8");
103
    //     $this->assertIsString($res);
104
    // }
105
106
107
    /**
108
     * Test the ipv6 validation method.
109
     */
110
    public function testIpv6Invalid()
111
    {
112
        $ipClass = new IpHandler();
113
        // $ipClass->ipv6();
114
        $res = $ipClass->ipv6("invalid");
115
        $this->assertContains("Validerar ej", $res);
116
    }
117
118
119
120
    /**
121
     * Test the ipv6 validation method.
122
     */
123
    public function testIpv6Valid()
124
    {
125
        $ipClass = new IpHandler();
126
        // $ipClass->ipv6();
127
        $res = $ipClass->ipv6("2001:4860:4860::8888");
128
        $this->assertContains("Validerar", $res);
129
    }
130
131
132
    /**
133
     * Test the ipv6 validation method.
134
     */
135
    // public function testIpv6Type()
136
    // {
137
    //     $ipClass = new IpHandler();
138
    //     // $ipClass->ipv6();
139
    //     $res = $ipClass->ipv6("2001:4860:4860::8888");
140
    //     $this->assertIsString($res);
141
    // }
142
143
144
    /**
145
     * Test the domain name checker method.
146
     */
147
    public function testDomainNameInvalid()
148
    {
149
        $ipClass = new IpHandler();
150
        // $ipClass->domainName();
151
        $res = $ipClass->domainName("invalid");
152
        $this->assertContains("ip ej validerad", $res);
153
    }
154
155
156
    /**
157
     * Test the domain name checker method.
158
     */
159
    public function testDomainNameValid()
160
    {
161
        $ipClass = new IpHandler();
162
        // $ipClass->domainName();
163
        $res = $ipClass->domainName("8.8.8.8");
164
        $this->assertContains("dns.google", $res);
165
    }
166
167
168
    /**
169
     * Test the domain name checker method.
170
     */
171
    // public function testDomainNameType()
172
    // {
173
    //     $ipClass = new IpHandler();
174
    //     // $ipClass->domainName();
175
    //     $res = $ipClass->domainName("8.8.8.8");
176
    //     $this->assertIsString($res);
177
    // }
178
}
179