|
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
|
|
|
/** |
|
21
|
|
|
* testCanBeUsedWithParts |
|
22
|
|
|
* @throws \kamerk22\IPFuscator\Exception\InvalidArgument |
|
23
|
|
|
*/ |
|
24
|
|
|
public function testCanBeUsedWithParts(): void |
|
25
|
|
|
{ |
|
26
|
|
|
$parts = Helper::getParts($this->ip); |
|
27
|
|
|
$this->assertEquals('127', $parts[0]); |
|
28
|
|
|
$this->assertEquals('0', $parts[1]); |
|
29
|
|
|
$this->assertEquals('1', $parts[3]); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* testCanBeUsedWithHexParts |
|
34
|
|
|
* @throws \kamerk22\IPFuscator\Exception\InvalidArgument |
|
35
|
|
|
*/ |
|
36
|
|
|
public function testCanBeUsedWithHexParts(): void |
|
37
|
|
|
{ |
|
38
|
|
|
$parts = Helper::getHexParts($this->ip); |
|
39
|
|
|
$this->assertEquals('0x7f', $parts[0]); |
|
40
|
|
|
$this->assertEquals('0x0', $parts[1]); |
|
41
|
|
|
$this->assertEquals('0x1', $parts[3]); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* testCanBeUsedWithOctParts |
|
46
|
|
|
* @throws \kamerk22\IPFuscator\Exception\InvalidArgument |
|
47
|
|
|
*/ |
|
48
|
|
|
public function testCanBeUsedWithOctParts(): void |
|
49
|
|
|
{ |
|
50
|
|
|
$parts = Helper::getOctalParts($this->ip); |
|
51
|
|
|
$this->assertEquals('0177', $parts[0]); |
|
52
|
|
|
$this->assertEquals('00', $parts[1]); |
|
53
|
|
|
$this->assertEquals('01', $parts[3]); |
|
54
|
|
|
} |
|
55
|
|
|
} |