mirror of
https://github.com/danog/dns.git
synced 2024-11-26 20:14:51 +01:00
Add HostLoader test
This commit is contained in:
parent
9ed331ae3d
commit
7ea775f741
39
test/HostLoaderTest.php
Normal file
39
test/HostLoaderTest.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Dns\Test;
|
||||
|
||||
use Amp\Dns\HostLoader;
|
||||
use Amp\Dns\Record;
|
||||
use Amp\Loop;
|
||||
use Amp\PHPUnit\TestCase;
|
||||
|
||||
class HostLoaderTest extends TestCase {
|
||||
public function testIgnoresCommentsAndParsesBasicEntry() {
|
||||
Loop::run(function () {
|
||||
$loader = new HostLoader(__DIR__ . "/data/hosts");
|
||||
$this->assertSame([
|
||||
Record::A => [
|
||||
"localhost" => "127.0.0.1",
|
||||
],
|
||||
], yield $loader->loadHosts());
|
||||
});
|
||||
}
|
||||
|
||||
public function testReturnsEmptyErrorOnFileNotFound() {
|
||||
Loop::run(function () {
|
||||
$loader = new HostLoader(__DIR__ . "/data/hosts.not.found");
|
||||
$this->assertSame([], yield $loader->loadHosts());
|
||||
});
|
||||
}
|
||||
|
||||
public function testIgnoresInvalidNames() {
|
||||
Loop::run(function () {
|
||||
$loader = new HostLoader(__DIR__ . "/data/hosts.invalid.name");
|
||||
$this->assertSame([
|
||||
Record::A => [
|
||||
"localhost" => "127.0.0.1",
|
||||
],
|
||||
], yield $loader->loadHosts());
|
||||
});
|
||||
}
|
||||
}
|
2
test/data/hosts
Normal file
2
test/data/hosts
Normal file
@ -0,0 +1,2 @@
|
||||
# localhost
|
||||
127.0.0.1 localhost
|
2
test/data/hosts.invalid.name
Normal file
2
test/data/hosts.invalid.name
Normal file
@ -0,0 +1,2 @@
|
||||
# aaa...aa is too long
|
||||
127.0.0.1 localhost aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
Loading…
Reference in New Issue
Block a user