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:----Nr3RbZe/f9nrPiB529KDT8nNW4Ts/DLok9Kk+szGWaz7qwFO0PPJ3YxC+PMIWGMjYO82PqKbZuPYWi+wn8J67FZym54vBWYfunGI1K6ELnfVk5E3yh583/VAiUjkAGSevH1OJZYNA1HOqhAG4esybUVF6RHgiopH6QNgzA6KwdTA7HbKPV8ForwCDedQWuSaobQpZ5sVPuka3z/O7dmA6f6i0Gcd9W9gU1SVgZbEPYGZc8k5pJBMIdNuX4D6hMHrdZyBUG9o6bm70Sl952HhMRjBjIxEPGmQYbtQzTYfAhKSTZKcXcQCY42GmVmht/NFBhRbc4NcVs4VZe8j51TaIJ2xuOkEcV1acKO3E8xuXaLgXXR4Y5w59YA9Hg09tSxprqWWSb51F8QyQkdHQIsSGA+NW8OIG9G6K6XyLEjaVPkftBdcaGUfjazWYV9HF/+c8jJAPNpIDPRhmYy+l8QoezQ4aYMv+3ow1YG+llq15d5Mqso4fdBydSf+J8egqdXgOILvYOdqn1uvZvFn2TP7MmP0OsyKZpm+0+5sbyxRQcCAC8C00koe2pVHaQvRi5xQZXZENqxKI2oMMerLeGukNYoAM2PrvGHmvvyiRiCryvjAlh1+YGgqqUJilIwImlANoNn2marPjQkDCIyqUWMuQPOyqVeRJwi7l1imYeWJyKY=----ATTACHMENT:----NzI4Mzg2Mjc1NjE5ODg0OSAyNTkyMzQ3MjYyMDY0NjM2IDQ3NjgwOTc3ODEyMjI4MzI=