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:
parent
7ea775f741
commit
23e24b76c6
32
test/BasicResolverTest.php
Normal file
32
test/BasicResolverTest.php
Normal 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);
|
||||
});
|
||||
}
|
||||
}
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user