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:----jRUR5rRmT4tgir0MKFBosKpfZXRNBwLAoREBOr6VmXI7Aiu5mpJ17qjicKNmAT4c5JYpLyke8zJ8UAzR6Wrnd5spASQA3VwUZ+3F0M3uouV0IH6E8QUILsSasmWYhE6wTw0P3AUhlTM0IyuH6VfEMPpKAKqn0GCEV6n0u6pmdI113u8z9C+IrQHP3moNQzqTGTzo/EoPfhg34Zzd3/2znOXxl3ASWIsnSi4fEku/aheb4odGxo859s/RYGfmX8bMkoxWOwTwuIvwSQ+hz/yTo2apVAtC9xrW3HJvE8OPgWP0uKh2QXndaiYj6M7ZaZ2XQkoccfqX4fFpc1q2MrU4ODaSLFIS4Tf/l7lHDK4H9hlEb420S3edN6tfFsn9GNOBSp4pu1oEHzo1yo9B7VyXcDquTdQWx8SjBBuhPLTuzPFNNg6L12cTyBVeOndcsDwqHcAOFrmgq1JM1YrXWjpPKFVE4Sm84URSFVGMoRkUw6jcK2+Di+flEj2DrYGPyG3gn2hUlD55WqMDP1gIvkDV63G3WXoxlugY+4Ue4K3HK4zklD1yUDnVy9j/UDqgiXvgF3HvZTjY4X83R3hXh4HviN7Gk9Y6tqm+jcntjTqahrRiAl+pePriCZOIgB4mrCYThwPO9zAwUsIDTJgZLD7AFUAGqfbZJqxNkZpJjlc8OLI=----ATTACHMENT:----NzUzNjI4NTkwMzI2MjYzNiAxMjE5MTA2MzYxODg4NzY5IDgxOTk5NDE0NTI2OTg4MTk=