Passed
Push — master ( 6d4a3c...d9bd74 )
by Kashyap
01:15
created

HelpTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 14
c 0
b 0
f 0
dl 0
loc 26
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCanBeUsedWithHexParts() 0 6 1
A testCanBeUsedWithParts() 0 6 1
A testCanBeUsedWithOctParts() 0 6 1
1
<?php
2
/**
3
 *
4
 * Part of the IPFuscator package.
5
 * Author: Kashyap Merai <[email protected]>
6
 *
7
 */
8
9
10
namespace kamerk22\IPFuscator\Tests;
11
12
13
use kamerk22\IPFuscator\Helper\Helper;
14
use PHPUnit\Framework\TestCase;
15
16
class HelpTest extends TestCase
17
{
18
    public $ip = '127.0.0.1';
19
20
    public function testCanBeUsedWithParts(): void
21
    {
22
        $parts = Helper::getParts($this->ip);
23
        $this->assertEquals('127', $parts[0]);
24
        $this->assertEquals('0', $parts[1]);
25
        $this->assertEquals('1', $parts[3]);
26
    }
27
28
    public function testCanBeUsedWithHexParts(): void
29
    {
30
        $parts = Helper::getHexParts($this->ip);
31
        $this->assertEquals('0x7f', $parts[0]);
32
        $this->assertEquals('0x0', $parts[1]);
33
        $this->assertEquals('0x1', $parts[3]);
34
    }
35
36
    public function testCanBeUsedWithOctParts(): void
37
    {
38
        $parts = Helper::getOctalParts($this->ip);
39
        $this->assertEquals('0177', $parts[0]);
40
        $this->assertEquals('00', $parts[1]);
41
        $this->assertEquals('01', $parts[3]);
42
    }
43
}