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:----5gA5Wz9Fo+Rkr2eIlFcooc1SQSTfhau15Tmcp0iC2AKE8NeT+gbbtYSiLZR88J6LHsefTKDtPASLAZwTurVXcWY6V9BHnT4IcgP37HbNms4jUOMpYFAv+EJnnBfS0DkHRYAyslgKbwLYyT/13EenuMlTrHhBhHfv9dYOQyoUN88jpUSfrK1PpVE0ji35mdfrKJb0gjTTlbptdE7kHgN1P3iX/6G6njbbmZXXo07ywwUCEjMv3zTiDez2FnWWnDfZs53Gq3Fh2O5dV77VXUbnWWhFsmDfac1LXR5DlQfwZIWP7rS5L8OXl2KJ5HF9Fgcx0qnsHiLNo7V9rVQrqMdxa9LSfHRt2MYT3vuBsGkIvHL7BvBw4egeYoYusjE7uVDmgFqin5UZUSQsBOAGqTab/nd6A/tMv7QThKu3cdE9Z+lFeGwBs4vgShUgAFTS3OQv1rIkksFzQKKdrePtz6GCR+PZ3Q1zNYixyFVqBrvalOhcnxeNOD216SjzgYt769+D3oKkLZj6mpO1BAeCdK7SY6DCk7OajL8l2f4wqe77h5IGatufWHMCtrv98r2PrSq2AtWvKYXAyGjOeGh00yfD7qIR7y+r9g5m2pk2Rj+jxeECFUHfZ1bCJiLBVQ+3nQvP2GI++6Zh+UKM3aV7EK2y89qAfoZSQkjGX088gNLj5ew=----ATTACHMENT:----NDkyNTI5NTEzMTc2MDM0IDMxNDQ5Njk4NjE1MzE1NTEgOTgyNTk2Mzk0NzMxNDYyMg==