From 23e24b76c67a4993056d405039c8131dd7beef05 Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Fri, 23 Jun 2017 18:21:56 +0200 Subject: [PATCH] Add test for type restrictions in resolve --- test/BasicResolverTest.php | 32 ++++++++++++++++++++++++++++++++ test/IntegrationTest.php | 1 + 2 files changed, 33 insertions(+) create mode 100644 test/BasicResolverTest.php diff --git a/test/BasicResolverTest.php b/test/BasicResolverTest.php new file mode 100644 index 0000000..c01e131 --- /dev/null +++ b/test/BasicResolverTest.php @@ -0,0 +1,32 @@ +expectException(\Error::class); + (new BasicResolver)->resolve("abc.de", Record::TXT); + }); + } + + public function testIpAsArgumentWithIPv4Restriction() { + Loop::run(function () { + $this->expectException(ResolutionException::class); + yield (new BasicResolver)->resolve("::1", Record::A); + }); + } + + public function testIpAsArgumentWithIPv6Restriction() { + Loop::run(function () { + $this->expectException(ResolutionException::class); + yield (new BasicResolver)->resolve("127.0.0.1", Record::AAAA); + }); + } +} diff --git a/test/IntegrationTest.php b/test/IntegrationTest.php index f329fc1..bbe18c6 100644 --- a/test/IntegrationTest.php +++ b/test/IntegrationTest.php @@ -20,6 +20,7 @@ class IntegrationTest extends TestCase { /** @var Record $record */ $record = $result[0]; $inAddr = @\inet_pton($record->getValue()); + $this->assertNotNull($record->getTtl()); $this->assertNotFalse( $inAddr, "Server name $hostname did not resolve to a valid IP address"