2017-06-23 18:07:57 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp\Dns\Test;
|
|
|
|
|
|
|
|
use Amp\Dns\HostLoader;
|
|
|
|
use Amp\Dns\Record;
|
|
|
|
use Amp\Loop;
|
|
|
|
use Amp\PHPUnit\TestCase;
|
2018-01-29 02:35:57 +01:00
|
|
|
use DaveRandom\LibDNS\HostsFile\HostsFile;
|
2017-06-23 18:07:57 +02:00
|
|
|
|
|
|
|
class HostLoaderTest extends TestCase {
|
2018-01-29 02:35:57 +01:00
|
|
|
public function testReturnsHostsFileInstanceOnExistingFile() {
|
2017-06-23 18:07:57 +02:00
|
|
|
Loop::run(function () {
|
|
|
|
$loader = new HostLoader(__DIR__ . "/data/hosts");
|
2018-01-29 02:35:57 +01:00
|
|
|
$this->assertInstanceOf(HostsFile::class, yield $loader->loadHosts());
|
2017-06-23 18:07:57 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testReturnsEmptyErrorOnFileNotFound() {
|
|
|
|
Loop::run(function () {
|
|
|
|
$loader = new HostLoader(__DIR__ . "/data/hosts.not.found");
|
2018-01-29 02:35:57 +01:00
|
|
|
$this->assertSame(null, yield $loader->loadHosts());
|
2017-06-23 18:07:57 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|