示例#1
0
文件: IPTest.php 项目: darsyn/ip
 /**
  * Test: Protocol to Number (Protocol Inputs)
  *
  * @test
  * @access public
  * @return void
  */
 public function pton()
 {
     $ipv4 = new IP('12.34.56.78');
     $this->assertSame(16, strlen($ipv4->getBinary()));
     $this->assertSame(pack('H*', '0000000000000000000000000c22384e'), $ipv4->getBinary());
     $ipv6 = new IP('2001:db8::a60:8a2e:370:7334');
     $this->assertSame(16, strlen($ipv6->getBinary()));
     $this->assertSame(pack('H*', '20010db8000000000a608a2e03707334'), $ipv6->getBinary());
     // Test input that has already been converted to binary notation.
     $ip = new IP($ipv6->getBinary());
     $this->assertSame(16, strlen($ip->getBinary()));
     $this->assertSame(pack('H*', '20010db8000000000a608a2e03707334'), $ip->getBinary());
 }
示例#2
0
文件: IpTypeTest.php 项目: darsyn/ip
 /**
  * IP Converts to PHP Value
  *
  * @test
  * @covers \Darsyn\IP\Doctrine\IpType::convertToPHPValue
  * @access public
  * @return void
  */
 public function ipConvertsToPHPValue()
 {
     $ip = new IP('12.34.56.78');
     $dbIp = $this->type->convertToPHPValue($ip->getBinary(), $this->platform);
     $this->assertInstanceOf('Darsyn\\IP\\IP', $dbIp);
     $this->assertEquals('12.34.56.78', $dbIp->getShortAddress());
 }