expectException(InvalidArgumentException::class); $v0 = IPAddressRange::parse('12.4:424::1/128'); } public function testToString(): void { $v4 = IPAddressRange::parse('53.64.123.86/18'); $this->assertEquals('53.64.123.86/18', (string)$v4); $v6 = IPAddressRange::parse('abcd:1234::43:211a/86'); $this->assertEquals('abcd:1234::43:211a/86', (string)$v6); } public function testMatch(): void { $v41 = IPAddress::parse('53.64.123.86'); $v42 = IPAddress::parse('53.64.130.86'); $v61 = IPAddress::parse('abcd:1234::43:211a'); $v62 = IPAddress::parse('bbce:1535::73:212a'); $r4 = IPAddressRange::parse('53.64.123.0/22'); $r6 = IPAddressRange::parse('abcd:1234::43:211a/86'); $this->assertTrue($r4->match($v41)); $this->assertFalse($r4->match($v42)); $this->assertTrue($r6->match($v61)); $this->assertFalse($r6->match($v62)); } public function testSerializable(): void { $cidrs = [ '53.64.123.0/22', 'abcd:1234::43:211a/86', ]; foreach($cidrs as $cidr) { $obj = IPAddressRange::parse($cidr); $ser = serialize($obj); $unser = unserialize($ser); $this->assertTrue($obj->equals($unser)); } } }