1
0
mirror of https://github.com/danog/dns.git synced 2024-12-03 09:57:56 +01:00
dns/test/SocketTest.php

29 lines
742 B
PHP
Raw Normal View History

2017-06-29 12:36:09 +02:00
<?php
namespace Amp\Dns\Test;
use Amp\Dns;
use Amp\Loop;
use Amp\PHPUnit\TestCase;
use Amp\Promise;
2018-01-29 02:35:57 +01:00
use DaveRandom\LibDNS\Protocol\Messages\Response;
use DaveRandom\LibDNS\Records\QuestionRecord;
use DaveRandom\Network\DomainName;
2017-06-29 12:36:09 +02:00
abstract class SocketTest extends TestCase {
abstract protected function connect(): Promise;
public function testAsk() {
Loop::run(function () {
2018-01-29 02:35:57 +01:00
$question = new QuestionRecord(DomainName::createFromString("google.com"), Dns\Record::A);
2017-06-29 12:36:09 +02:00
/** @var Dns\Internal\Socket $socket */
$socket = yield $this->connect();
$result = yield $socket->ask($question, 5000);
2018-01-29 02:35:57 +01:00
$this->assertInstanceOf(Response::class, $result);
2017-06-29 12:36:09 +02:00
});
}
}