Passed
Branch master (00a87c)
by Kashyap
01:08
created

IPFuscatorTest::testCanBeUsedWithValidIp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 1
b 0
f 1
1
<?php
2
3
/**
4
 *
5
 * Part of the IPFuscator package.
6
 * Author: Kashyap Merai <[email protected]>
7
 *
8
 */
9
10
use kamerk22\IPFuscator\Exception\InvalidArgument;
11
use kamerk22\IPFuscator\IPFuscator;
12
use PHPUnit\Framework\TestCase;
13
14
class IPFuscatorTest extends TestCase
15
{
16
    public $ip = '127.0.0.1';
17
18
    public function testCanBeUsedWithValidIp()
19
    {
20
        $this->assertIsString(
21
            IPFuscator::class,
22
            IPFuscator::getDecimal($this->ip)
23
        );
24
    }
25
26
    public function testCanBeUsedWithInvalidIp()
27
    {
28
        $this->expectException(InvalidArgument::class);
29
        IPFuscator::getDecimal('in.va.lid.ip');
30
    }
31
32
    public function testCanBeValidDecimal()
33
    {
34
        $this->assertEquals(
35
            '2130706433',
36
            IPFuscator::getDecimal($this->ip)
37
        );
38
    }
39
40
    public function testCanBeValidHexadecimal()
41
    {
42
        $this->assertEquals(
43
            '0x7f000001',
44
            IPFuscator::getHexadecimal($this->ip)
45
        );
46
    }
47
48
    public function testCanBeValidOctal()
49
    {
50
        $this->assertEquals(
51
            '017700000001',
52
            IPFuscator::getOctal($this->ip)
53
        );
54
    }
55
56
    public function testCanBeValidFullHex()
57
    {
58
        $this->assertEquals(
59
            '0x7f.0x0.0x0.0x1',
60
            IPFuscator::getFullHex($this->ip)
61
        );
62
    }
63
64
    public function testCanBeValidFullOct()
65
    {
66
        $this->assertEquals(
67
            '0177.00.00.01',
68
            IPFuscator::getFullOct($this->ip)
69
        );
70
    }
71
}