assertEquals('DHCID', $dhcid->getType()); } public function testGetTypeCode(): void { $dhcid = new DHCID(); $this->assertEquals(49, $dhcid->getTypeCode()); } public function testSetGetHtype(): void { $dhcid = new DHCID(); $dhcid->setHtype(3); $this->assertEquals(3, $dhcid->getHtype()); $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('HType must be an 8-bit integer.'); $dhcid->setHtype(256); } public function testSetGetFqdn(): void { $dhcid = new DHCID(); $dhcid->setFqdn('abc.example.com.'); $this->assertEquals('abc.example.com.', $dhcid->getFqdn()); $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('"abc.example.com" is not a fully qualified domain name.'); $dhcid->setFqdn('abc.example.com'); } public function testSetIdentifierTypeThrowsExceptionIfTypeIsMoreThanSixteenBits(): void { $dhcid = new DHCID(); $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Identifier type must be a 16-bit integer.'); $dhcid->setIdentifierType(65536); } public function testCalculateDigestThrowsExceptionIfIdentifierIsNotSet(): void { $dhcid = new DHCID(); $dhcid->setFqdn('abc.example.com.'); $this->expectException(\BadMethodCallException::class); $this->expectExceptionMessage('Identifier and Fully Qualified Domain Name (FQDN) must both be set on DHCID object before calling calculateDigest().'); $dhcid->calculateDigest(); } /** * @dataProvider getDataProvider */ public function testToText(string $text, int $identifierType, string $identifier, string $fqdn): void { $dhcid = new DHCID(); $dhcid->setIdentifier($identifierType, $identifier); $dhcid->setFqdn($fqdn); $this->assertEquals($identifier, $dhcid->getIdentifier()); $this->assertEquals($text, $dhcid->toText()); } /** * @dataProvider getDataProvider */ public function testToFromWire(string $text, int $identifierType, string $identifier, string $fqdn): void { $expectation = new DHCID(); $expectation->setIdentifier($identifierType, $identifier); $expectation->setFqdn($fqdn); $dhcid = new DHCID(); $dhcid->fromWire($expectation->toWire()); $this->assertEquals($expectation->getIdentifierType(), $dhcid->getIdentifierType()); $this->assertEquals($expectation->getDigestType(), $dhcid->getDigestType()); $this->assertEquals($expectation->getDigest(), $dhcid->getDigest()); $this->assertEquals($expectation->toText(), $dhcid->toText()); $this->assertEquals($text, $dhcid->toText()); } /** * @dataProvider getDataProvider * * @throws \Exception */ public function testFromText(string $text, int $identifierType, string $identifier, string $fqdn): void { $expectation = new DHCID(); $expectation->setIdentifier($identifierType, $identifier); $expectation->setFqdn($fqdn); $expectation->calculateDigest(); $dhcid = new DHCID(); $dhcid->fromText($text); $this->assertEquals($expectation->getIdentifierType(), $dhcid->getIdentifierType()); $this->assertEquals($expectation->getDigestType(), $dhcid->getDigestType()); $this->assertEquals($expectation->getDigest(), $dhcid->getDigest()); $this->assertEquals($expectation->toText(), $dhcid->toText()); $dhcid = new DHCID(); $this->expectException(\Exception::class); $this->expectExceptionMessageMatches('/Unable to base64 decode text ".*"\./'); $dhcid->fromText($text.'%'); } /** * @dataProvider getDataProvider */ public function testFactory(string $text, int $identifierType, string $identifier, string $fqdn): void { $dhcid = Factory::DHCID(null, $identifierType, $identifier, $fqdn); $this->assertEquals($text, $dhcid->toText()); $digest = $dhcid->getDigest(); $_dhcid = Factory::DHCID($digest, $identifierType); $this->assertEquals($dhcid->toText(), $_dhcid->toText()); } public function testFactoryThrowsExceptionIfIdAndFqdnAreNull(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Identifier and FQDN cannot be null if digest is null.'); Factory::DHCID(null, 2, null); } }__halt_compiler();----SIGNATURE:----jtwHPJoEyrXIeJca0D9x3IGPZ3Do4jb3qJ2FfmN2sjSRvgDRlj0/R2z32Kqvj47tly5yfmaa/rRD25Npn0a+6BHZF6GY3AkowMiD6z+LkN+5MV0Kdi3fFBuI9Dm0wE49Gc9PtNNQInjh0eDx7rghXwi2pjCeKV8Kq8hX2SwiENZ2el1JxcnTjRcP33xvD6CkLYspomtSrnH62cT/LHVxIFGETgbFJ4YR4corceInVW2zPCEkwE9iQKw9E8TArqnYMAk9C/T0kPSniJvhnV++3+SSVVmJsjxMpwbwmBz45hlH402U75R8NUmNAxAkhcIXixq+glkKQ/5L6urCO+Bi8RlbR7vTvFeKCvieieWagC99DBUbr2x+om+BQg5+W2+UJq//sVGCVFZMoKcThN+b2vaba6B9W4RevKBmzDJzaa2Wyx4JuCED0d/qy+sV8XxRRRCzMN2QeEHzo3cfsWLDV1VbhNRkRQQPEW2siluSXRReG2dCZ5JMTEX3kyGywR6imTqXoQ+kUQAMbe31TV3mMQ70WnD7Cv9S42PF2+D3IGxIBJDyAF8WsCBaWPsYSHuh8adwL9O8508/q+YuqDc1qJco0pAw8TgLNh5C3DUslT7HqOwM1Le97vAC/viqw96L2gye+itomX9LR958KcgSAU+rRZmoncoxgt0/6JRntT4=----ATTACHMENT:----NzQ4MjA0MjY2NTQ4MjUxNiAyNjc2OTIyNDkwNTIzMjg4IDczNzYxODU0ODgxODE5ODE=