IPTest.php
1<?php
2
3namespace tests\Udger\Helper;
4
6
11class ParserFactoryTest extends \Codeception\TestCase\Test {
12
16 protected $guy;
17
22 protected $object;
23
24 protected function _before()
25 {
26 $this->object = new IP();
27 }
28
29 public function testInterface()
30 {
31 $this->assertInstanceOf("Udger\Helper\IPInterface", $this->object);
32 }
33
34 public function testGetInvalidIpVerison()
35 {
36 $this->assertFalse($this->object->getIpVersion("banana"));
37 }
38
39 public function testGetEmptyIpVerison()
40 {
41 $this->assertFalse($this->object->getIpVersion(""));
42 }
43
44 public function testGetValidIpVerison()
45 {
46 $this->assertEquals(4, $this->object->getIpVersion("0.0.0.0"));
47 $this->assertEquals(4, $this->object->getIpVersion("127.0.0.1"));
48 }
49
50 public function testGetValidIp6LoopbackVerison()
51 {
52 $this->assertEquals(6, $this->object->getIpVersion("::1"));
53 }
54
55 public function testGetValidIp6Verison()
56 {
57 $this->assertEquals(6, $this->object->getIpVersion("FE80:CD00:0000:0CDE:1257:0000:211E:729C"));
58 $this->assertEquals(6, $this->object->getIpVersion("FE80:CD00:0:CDE:1257:0:211E:729C"));
59 }
60
61 public function testGetIpLong()
62 {
63 $this->assertEquals(0, $this->object->getIpLong("0.0.0.0"));
64 }
65}