1
0
mirror of https://github.com/danog/dns.git synced 2024-11-26 20:14:51 +01:00

Add test for type restrictions in resolve

This commit is contained in:
Niklas Keller 2017-06-23 18:21:56 +02:00
parent 7ea775f741
commit 23e24b76c6
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,32 @@
<?php
namespace Amp\Dns\Test;
use Amp\Dns\BasicResolver;
use Amp\Dns\Record;
use Amp\Dns\ResolutionException;
use Amp\Loop;
use Amp\PHPUnit\TestCase;
class BasicResolverTest extends TestCase {
public function testResolveSecondParameterAcceptedValues() {
Loop::run(function () {
$this->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);
});
}
}

View File

@ -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"