1
0
mirror of https://github.com/danog/dns.git synced 2024-11-30 04:29:06 +01:00
dns/test/HostLoaderTest.php
2017-06-23 18:07:57 +02:00

40 lines
1.1 KiB
PHP

<?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());
});
}
}