diff --git a/test/RecordTest.php b/test/RecordTest.php new file mode 100644 index 0000000..479de71 --- /dev/null +++ b/test/RecordTest.php @@ -0,0 +1,23 @@ +assertSame("A", Record::getName(Record::A)); + } + + public function testGetNameOnInvalidRecordType() { + $this->expectException(\Error::class); + $this->expectExceptionMessage("65536 does not correspond to a valid record type (must be between 0 and 65535)."); + + Record::getName(65536); + } + + public function testGetNameOnUnknownRecordType() { + $this->assertSame("unknown (1000)", Record::getName(1000)); + } +} diff --git a/test/SocketTest.php b/test/SocketTest.php index 07f907a..ba0d65e 100644 --- a/test/SocketTest.php +++ b/test/SocketTest.php @@ -28,4 +28,16 @@ abstract class SocketTest extends TestCase { $this->assertSame(MessageTypes::RESPONSE, $result->getType()); }); } + + public function testGetLastActivity() { + Loop::run(function () { + $question = (new QuestionFactory)->create(Dns\Record::A); + $question->setName("google.com"); + + /** @var Dns\Internal\Socket $socket */ + $socket = yield $this->connect(); + + $this->assertTrue($socket->getLastActivity() < time() + 1); + }); + } }