Tests are now compliant with php-cs-fixer (CamelCase for method, phpdoc valid)
This commit is contained in:
@@ -1,255 +1,258 @@
|
||||
<?php
|
||||
|
||||
/** DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
/**
|
||||
* DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
* @license BSD
|
||||
*/
|
||||
|
||||
namespace Domframework\Tests;
|
||||
|
||||
use Domframework\Ipaddresses;
|
||||
|
||||
/** Test the Ipaddresses.php file */
|
||||
/**
|
||||
* Test the Ipaddresses.php file
|
||||
*/
|
||||
class IpaddressesTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_validIPAddress1()
|
||||
public function testValidIPAddress1()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPAddress("::");
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_validIPAddress2()
|
||||
public function testValidIPAddress2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPAddress("1::");
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_validIPAddress3()
|
||||
public function testValidIPAddress3()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPAddress("::1");
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_validIPAddress4()
|
||||
public function testValidIPAddress4()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPAddress("2001::1");
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_validIPAddress5()
|
||||
public function testValidIPAddress5()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPAddress("1.2.3.4");
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_validIPAddress6()
|
||||
public function testValidIPAddress6()
|
||||
{
|
||||
$this->setExpectedException("Exception");
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPAddress("");
|
||||
}
|
||||
public function test_validIPAddress7()
|
||||
public function testValidIPAddress7()
|
||||
{
|
||||
$this->setExpectedException("Exception");
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPAddress(array ());
|
||||
$res = $i->validIPAddress([]);
|
||||
}
|
||||
|
||||
public function test_validIPv4Address1()
|
||||
public function testValidIPv4Address1()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv4Address("::");
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
public function test_validIPv4Address2()
|
||||
public function testValidIPv4Address2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv4Address("1.2.3.4");
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
|
||||
public function test_validIPv6Address1()
|
||||
public function testValidIPv6Address1()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv6Address("1.2.3.4");
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
public function test_validIPv6Address2()
|
||||
public function testValidIPv6Address2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv6Address("::");
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_validIPv6Address3()
|
||||
public function testValidIPv6Address3()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv6Address("1::");
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_validIPv6Address4()
|
||||
public function testValidIPv6Address4()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv6Address("::1");
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_validIPv6Address5()
|
||||
public function testValidIPv6Address5()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv6Address("1::1");
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_validIPv6Address6()
|
||||
public function testValidIPv6Address6()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv6Address("1:1:1");
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
|
||||
public function test_validCIDR1()
|
||||
public function testValidCIDR1()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validCIDR(-1);
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
public function test_validCIDR2()
|
||||
public function testValidCIDR2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validCIDR(129);
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
public function test_validCIDR3()
|
||||
public function testValidCIDR3()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validCIDR(128);
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_validCIDR4()
|
||||
public function testValidCIDR4()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validCIDR(0);
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
|
||||
public function test_validIPv4CIDR1()
|
||||
public function testValidIPv4CIDR1()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv4CIDR(-1);
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
public function test_validIPv4CIDR2()
|
||||
public function testValidIPv4CIDR2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv4CIDR(33);
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
public function test_validIPv4CIDR3()
|
||||
public function testValidIPv4CIDR3()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv4CIDR(32);
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_validIPv4CIDR4()
|
||||
public function testValidIPv4CIDR4()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv4CIDR(0);
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
|
||||
public function test_validIPv6CIDR1()
|
||||
public function testValidIPv6CIDR1()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv6CIDR(-1);
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
public function test_validIPv6CIDR2()
|
||||
public function testValidIPv6CIDR2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv6CIDR(129);
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
public function test_validIPv6CIDR3()
|
||||
public function testValidIPv6CIDR3()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv6CIDR(128);
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_validIPv6CIDR4()
|
||||
public function testValidIPv6CIDR4()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->validIPv6CIDR(0);
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
|
||||
public function test_compressIP1()
|
||||
public function testCompressIP1()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->compressIP("::");
|
||||
$this->assertSame("::", $res);
|
||||
}
|
||||
public function test_compressIP2()
|
||||
public function testCompressIP2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->compressIP("::1");
|
||||
$this->assertSame("::1", $res);
|
||||
}
|
||||
public function test_compressIP3()
|
||||
public function testCompressIP3()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->compressIP("2::1");
|
||||
$this->assertSame("2::1", $res);
|
||||
}
|
||||
public function test_compressIP4()
|
||||
public function testCompressIP4()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->compressIP("2::");
|
||||
$this->assertSame("2::", $res);
|
||||
}
|
||||
public function test_compressIP5()
|
||||
public function testCompressIP5()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->compressIP("2:1:0:3::0:1");
|
||||
$this->assertSame("2:1:0:3::1", $res);
|
||||
}
|
||||
public function test_compressIP6()
|
||||
public function testCompressIP6()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->compressIP("2:1:0:3:0000::1");
|
||||
$this->assertSame("2:1:0:3::1", $res);
|
||||
}
|
||||
|
||||
public function test_uncompressIPv6a()
|
||||
public function testUncompressIPv6a()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->uncompressIPv6("1::1");
|
||||
$this->assertSame("1:0:0:0:0:0:0:1", $res);
|
||||
}
|
||||
public function test_uncompressIPv6b()
|
||||
public function testUncompressIPv6b()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->uncompressIPv6("1::");
|
||||
$this->assertSame("1:0:0:0:0:0:0:0", $res);
|
||||
}
|
||||
public function test_uncompressIPv6c()
|
||||
public function testUncompressIPv6c()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->uncompressIPv6("::");
|
||||
$this->assertSame("0:0:0:0:0:0:0:0", $res);
|
||||
}
|
||||
public function test_uncompressIPv6d()
|
||||
public function testUncompressIPv6d()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->uncompressIPv6("1.2.3.4");
|
||||
$this->assertSame("1.2.3.4", $res);
|
||||
}
|
||||
|
||||
public function test_groupIPv6a()
|
||||
public function testGroupIPv6a()
|
||||
{
|
||||
$this->setExpectedException("Exception");
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->groupIPv6("1.2.3.4");
|
||||
}
|
||||
public function test_groupIPv6b()
|
||||
public function testGroupIPv6b()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->groupIPv6("0.1.2.3.4.5.6.7.8.9.a.b.c.d.e.f." .
|
||||
@@ -257,37 +260,37 @@ class IpaddressesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame("0123:4567:89ab:cdef:0123:4567:89ab:cdef", $res);
|
||||
}
|
||||
|
||||
public function test_completeAddressWithZero1()
|
||||
public function testCompleteAddressWithZero1()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->completeAddressWithZero("::");
|
||||
$this->assertSame("0000:0000:0000:0000:0000:0000:0000:0000", $res);
|
||||
}
|
||||
public function test_completeAddressWithZero2()
|
||||
public function testCompleteAddressWithZero2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->completeAddressWithZero("::1");
|
||||
$this->assertSame("0000:0000:0000:0000:0000:0000:0000:0001", $res);
|
||||
}
|
||||
public function test_completeAddressWithZero3()
|
||||
public function testCompleteAddressWithZero3()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->completeAddressWithZero("1::");
|
||||
$this->assertSame("0001:0000:0000:0000:0000:0000:0000:0000", $res);
|
||||
}
|
||||
public function test_completeAddressWithZero4()
|
||||
public function testCompleteAddressWithZero4()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->completeAddressWithZero("1::1");
|
||||
$this->assertSame("0001:0000:0000:0000:0000:0000:0000:0001", $res);
|
||||
}
|
||||
public function test_completeAddressWithZero5()
|
||||
public function testCompleteAddressWithZero5()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->completeAddressWithZero("1:222::1");
|
||||
$this->assertSame("0001:0222:0000:0000:0000:0000:0000:0001", $res);
|
||||
}
|
||||
public function test_completeAddressWithZero6()
|
||||
public function testCompleteAddressWithZero6()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->completeAddressWithZero("1.2.3.4");
|
||||
@@ -297,274 +300,274 @@ class IpaddressesTest extends \PHPUnit_Framework_TestCase
|
||||
// TODO : cidrToBin
|
||||
// TODO : str_base_convert
|
||||
|
||||
public function test_reverseIPAddress1()
|
||||
public function testReverseIPAddress1()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->reverseIPAddress("1.2.3.4");
|
||||
$this->assertSame("4.3.2.1", $res);
|
||||
}
|
||||
public function test_reverseIPAddress2()
|
||||
public function testReverseIPAddress2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->reverseIPAddress("::");
|
||||
$this->assertSame("0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0", $res);
|
||||
}
|
||||
public function test_reverseIPAddress3()
|
||||
public function testReverseIPAddress3()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->reverseIPAddress("::1");
|
||||
$this->assertSame("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0", $res);
|
||||
}
|
||||
public function test_reverseIPAddress4()
|
||||
public function testReverseIPAddress4()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->reverseIPAddress("2::1");
|
||||
$this->assertSame("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0", $res);
|
||||
}
|
||||
public function test_reverseIPAddress5()
|
||||
public function testReverseIPAddress5()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->reverseIPAddress("2::abcd:1");
|
||||
$this->assertSame("1.0.0.0.d.c.b.a.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.0", $res);
|
||||
}
|
||||
|
||||
public function test_netmask2cidr1()
|
||||
public function testNetmask2cidr1()
|
||||
{
|
||||
$this->setExpectedException("Exception");
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->netmask2cidr(0);
|
||||
}
|
||||
public function test_netmask2cidr2()
|
||||
public function testNetmask2cidr2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->netmask2cidr("255.255.255.0");
|
||||
$this->assertSame(24, $res);
|
||||
}
|
||||
public function test_netmask2cidr3()
|
||||
public function testNetmask2cidr3()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->netmask2cidr("255.255.255.255");
|
||||
$this->assertSame(32, $res);
|
||||
}
|
||||
public function test_netmask2cidr4()
|
||||
public function testNetmask2cidr4()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->netmask2cidr("255.255.255.255");
|
||||
$this->assertSame(32, $res);
|
||||
}
|
||||
public function test_netmask2cidr5()
|
||||
public function testNetmask2cidr5()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->netmask2cidr("255.0.0.0");
|
||||
$this->assertSame(8, $res);
|
||||
}
|
||||
public function test_netmask2cidr6()
|
||||
public function testNetmask2cidr6()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->netmask2cidr("127.0.0.0");
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
public function test_netmask2cidr7()
|
||||
public function testNetmask2cidr7()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->netmask2cidr("63.0.0.0");
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
public function test_netmask2cidr8()
|
||||
public function testNetmask2cidr8()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->netmask2cidr("155.0.0.0");
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
public function test_netmask2cidr9()
|
||||
public function testNetmask2cidr9()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->netmask2cidr("0.0.0.255");
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
|
||||
public function test_netmask2cidrWildcard_1()
|
||||
public function testNetmask2cidrWildcard1()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->netmask2cidr("255.255.255.0", false);
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
|
||||
public function test_netmask2cidrWildcard_2()
|
||||
public function testNetmask2cidrWildcard2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->netmask2cidr("0.0.0.0", false);
|
||||
$this->assertSame(32, $res);
|
||||
}
|
||||
public function test_netmask2cidrWildcard_3()
|
||||
public function testNetmask2cidrWildcard3()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->netmask2cidr("255.255.255.255", false);
|
||||
$this->assertSame(0, $res);
|
||||
}
|
||||
|
||||
public function test_cidr2netmask_1()
|
||||
public function testCidr2netmask1()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->cidr2netmask(0, true);
|
||||
$this->assertSame("0.0.0.0", $res);
|
||||
}
|
||||
|
||||
public function test_cidr2netmask_2()
|
||||
public function testCidr2netmask2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->cidr2netmask(24, true);
|
||||
$this->assertSame("255.255.255.0", $res);
|
||||
}
|
||||
|
||||
public function test_cidr2netmask_3()
|
||||
public function testCidr2netmask3()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->cidr2netmask(25, true);
|
||||
$this->assertSame("255.255.255.128", $res);
|
||||
}
|
||||
|
||||
public function test_cidr2netmask_4()
|
||||
public function testCidr2netmask4()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->cidr2netmask(32, true);
|
||||
$this->assertSame("255.255.255.255", $res);
|
||||
}
|
||||
public function test_cidr2netmask_5()
|
||||
public function testCidr2netmask5()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->cidr2netmask(1, true);
|
||||
$this->assertSame("128.0.0.0", $res);
|
||||
}
|
||||
|
||||
public function test_ipInNetwork1()
|
||||
public function testIpInNetwork1()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->ipInNetwork("127.0.0.1", "127.1.0.0", 8);
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_ipInNetwork2()
|
||||
public function testIpInNetwork2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->ipInNetwork("192.168.1.1", "127.1.0.0", 8);
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
public function test_ipInNetwork3()
|
||||
public function testIpInNetwork3()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->ipInNetwork("2001:660:530d:201::1", "2001:660:530d:201::", 64);
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_ipInNetwork4()
|
||||
public function testIpInNetwork4()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->ipInNetwork("2001:660:530d:203::1", "2001:660:530d:201::", 64);
|
||||
$this->assertSame(false, $res);
|
||||
}
|
||||
public function test_ipInNetwork5()
|
||||
public function testIpInNetwork5()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->ipInNetwork("2001:660:530d:203::1", "2001::", 0);
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
public function test_ipInNetwork6()
|
||||
public function testIpInNetwork6()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->ipInNetwork("192.168.1.1", "127.0.0.0", 0);
|
||||
$this->assertSame(true, $res);
|
||||
}
|
||||
|
||||
public function test_networkFirstIP1()
|
||||
public function testNetworkFirstIP1()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkFirstIP("192.168.1.21", 24);
|
||||
$this->assertSame($res, "192.168.1.0");
|
||||
}
|
||||
public function test_networkFirstIP2()
|
||||
public function testNetworkFirstIP2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkFirstIP("192.168.1.21", 0);
|
||||
$this->assertSame($res, "0.0.0.0");
|
||||
}
|
||||
public function test_networkFirstIP3()
|
||||
public function testNetworkFirstIP3()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkFirstIP("192.168.1.21", 32);
|
||||
$this->assertSame($res, "192.168.1.21");
|
||||
}
|
||||
public function test_networkFirstIP4()
|
||||
public function testNetworkFirstIP4()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkFirstIP("192.168.1.21", 31);
|
||||
$this->assertSame($res, "192.168.1.20");
|
||||
}
|
||||
public function test_networkFirstIP5()
|
||||
public function testNetworkFirstIP5()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkFirstIP("2001:660:530d:201::125", 64);
|
||||
$this->assertSame($res, "2001:660:530d:201::");
|
||||
}
|
||||
public function test_networkFirstIP6()
|
||||
public function testNetworkFirstIP6()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkFirstIP("2001:660:530d:201::125", 0);
|
||||
$this->assertSame($res, "::");
|
||||
}
|
||||
public function test_networkFirstIP7()
|
||||
public function testNetworkFirstIP7()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkFirstIP("2001:660:530d:201::125", 128);
|
||||
$this->assertSame($res, "2001:660:530d:201::125");
|
||||
}
|
||||
public function test_networkFirstIP8()
|
||||
public function testNetworkFirstIP8()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkFirstIP("2001:660:530d:201::125", 127);
|
||||
$this->assertSame($res, "2001:660:530d:201::124");
|
||||
}
|
||||
public function test_networkLastIP1()
|
||||
public function testNetworkLastIP1()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkLastIP("192.168.1.21", 24);
|
||||
$this->assertSame($res, "192.168.1.255");
|
||||
}
|
||||
public function test_networkLastIP2()
|
||||
public function testNetworkLastIP2()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkLastIP("192.168.1.21", 0);
|
||||
$this->assertSame($res, "255.255.255.255");
|
||||
}
|
||||
public function test_networkLastIP3()
|
||||
public function testNetworkLastIP3()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkLastIP("192.168.1.21", 32);
|
||||
$this->assertSame($res, "192.168.1.21");
|
||||
}
|
||||
public function test_networkLastIP4()
|
||||
public function testNetworkLastIP4()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkLastIP("192.168.1.21", 31);
|
||||
$this->assertSame($res, "192.168.1.21");
|
||||
}
|
||||
public function test_networkLastIP5()
|
||||
public function testNetworkLastIP5()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkLastIP("2001:660:530d:201::125", 64);
|
||||
$this->assertSame($res, "2001:660:530d:201:ffff:ffff:ffff:ffff");
|
||||
}
|
||||
public function test_networkLastIP6()
|
||||
public function testNetworkLastIP6()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkLastIP("2001:660:530d:201::125", 0);
|
||||
$this->assertSame($res, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
|
||||
}
|
||||
public function test_networkLastIP7()
|
||||
public function testNetworkLastIP7()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkLastIP("2001:660:530d:201::125", 128);
|
||||
$this->assertSame($res, "2001:660:530d:201::125");
|
||||
}
|
||||
public function test_networkLastIP8()
|
||||
public function testNetworkLastIP8()
|
||||
{
|
||||
$i = new Ipaddresses();
|
||||
$res = $i->networkLastIP("2001:660:530d:201::125", 127);
|
||||
|
||||
Reference in New Issue
Block a user