@@ -306,6 +306,31 @@ public function testParseTXTResponseMultiple()
306306 $ this ->assertSame (array ('hello ' , 'world ' ), $ response ->answers [0 ]->data );
307307 }
308308
309+ public function testParseMXResponse ()
310+ {
311+ $ data = "" ;
312+ $ data .= "04 69 67 6f 72 02 69 6f 00 " ; // answer: igor.io
313+ $ data .= "00 0f 00 01 " ; // answer: type MX, class IN
314+ $ data .= "00 01 51 80 " ; // answer: ttl 86400
315+ $ data .= "00 09 " ; // answer: rdlength 9
316+ $ data .= "00 0a 05 68 65 6c 6c 6f 00 " ; // answer: rdata priority 10: hello
317+
318+ $ data = $ this ->convertTcpDumpToBinary ($ data );
319+
320+ $ response = new Message ();
321+ $ response ->header ->set ('anCount ' , 1 );
322+ $ response ->data = $ data ;
323+
324+ $ this ->parser ->parseAnswer ($ response );
325+
326+ $ this ->assertCount (1 , $ response ->answers );
327+ $ this ->assertSame ('igor.io ' , $ response ->answers [0 ]->name );
328+ $ this ->assertSame (Message::TYPE_MX , $ response ->answers [0 ]->type );
329+ $ this ->assertSame (Message::CLASS_IN , $ response ->answers [0 ]->class );
330+ $ this ->assertSame (86400 , $ response ->answers [0 ]->ttl );
331+ $ this ->assertSame (array ('priority ' => 10 , 'target ' => 'hello ' ), $ response ->answers [0 ]->data );
332+ }
333+
309334 public function testParseResponseWithTwoAnswers ()
310335 {
311336 $ data = "" ;
0 commit comments