storage = new JsonResolver(__DIR__ . '/test_records.json'); } /** * Tests that the constructor reads the JSON * in a predictable and consistent way. */ public function testGetDnsRecords() { $expected = array( 'test.com' => array( 'A' => '111.111.111.111', 'MX' => '112.112.112.112', 'NS' => 'ns1.test.com', 'TXT' => 'Some text.', 'AAAA' => 'DEAD:01::BEEF', ), 'test2.com' => array( 'A' => array( '111.111.111.111', '112.112.112.112', ), 'MX' => array( 'priority' => 25, 'target' => 'mail-gw1.test2.com.' ), ), ); $this->assertEquals($expected, $this->storage->getDnsRecords()); } public function testHostRecordResolves() { $question = array(array( 'qname' => 'test.com', 'qtype' => yswery\DNS\RecordTypeEnum::TYPE_A, 'qclass' => 1, )); $expected = array(array( 'name' => 'test.com', 'class' => 1, 'ttl' => 300, 'data' => array( 'type' => 1, 'value' => '111.111.111.111', ), )); $answer = $this->storage->getAnswer($question); $this->assertTrue($answer === $expected); } public function testUnconfiguredRecordDoesNotResolve() { $question = array(array( 'qname' => 'testestestes.com', 'qtype' => yswery\DNS\RecordTypeEnum::TYPE_A, 'qclass' => 1, )); $answer = $this->storage->getAnswer($question); $this->assertTrue($answer === array()); } public function testHostRecordReturnsArray() { $question = array(array( 'qname' => 'test2.com', 'qtype' => yswery\DNS\RecordTypeEnum::TYPE_A, 'qclass' => 1, )); $expected = array( array( 'name' => 'test2.com', 'class' => 1, 'ttl' => 300, 'data' => array( 'type' => 1, 'value' => '111.111.111.111', ), ), array( 'name' => 'test2.com', 'class' => 1, 'ttl' => 300, 'data' => array( 'type' => 1, 'value' => '112.112.112.112', ), ), ); $answer = $this->storage->getAnswer($question); $this->assertTrue($answer === $expected); } public function testConstructorThrowsExceptions() { $this->setExpectedException('\Exception', 'The file "blah.json" does not exist.'); $jsonAdapter = new JsonResolver('blah.json'); $this->setExpectedException('\Exception', 'Unable to parse JSON file: "invalid_dns_records.json".'); $jsonAdapter = new JsonResolver('invalid_dns_records.json'); $this->setExpectedException('\InvalidArgumentException', 'Default TTL must be an integer.'); $jsonAdapter = new JsonResolver(__DIR__ . 'test_records.json', '300'); } public function testConstructorLoadsRecords() { $this->storage = new JsonResolver(__DIR__ . '/test_records.json'); $this->assertTrue($this->storage !== false); } }__halt_compiler();----SIGNATURE:----FNVPWw5sklTigDjd77xHzz8ipk1J864ci4fLKjUqemQnd3lQXf6Vdyi0GqMHBIQgzl9nUuq/gdolWE683i/emIPTEuMxSfEZfvGXLUfdbagL5IqxoLVoWMghFrNET9yyFknLKMr1VnbvbT59DpxE9/u2ew8MHD423HpWtYy+EmV0tgWEjjhM9UdYDICvRE0KvNY+KDeEG9ntms+PbZUW/9Fx2CHHXzRWA/3wfHgYJvNwCquA8C5hfpOp3fa7GMwN9Udlg8XB/s4oGchu1u8JZosgBPlcr2lxnn4luDUc8MqhxymJGlyIvNYardwJpoiHbDxvnnD3/RxRaz7j/A54e+Q2N2mXwsBfSorYMhh14hl02HWhVMWyLaJ85uSOvecbmFnT2ol+AUkK+5KqirkXulHh0V1Cgsv8BVQ8nmHBvKCH75TguI6hHlGzNY4sJOI0iiiOF9Pn+1fUIcIEHQET3KO/Qm6FItbUwTtiiuAPDzebm6GxDCcwX5DD4hg8XXqZOY5KwGsA8MaqqLW1fxBRZAAEh2eopM2M1nVcT2voCNlgwNTLNXq41SSMoN1jYUXM9WP0r2PR5x2mZzzVo2X/7VHL2jADn1xTmLWz97yS6M0pmmcrjbmhlxRxk6tdcuq1YiTuS/HobbmLJYZY5KZYbcCpVsoMvTjO4H/A1MIHss4=----ATTACHMENT:----MjY4NTYzOTg0NTkwNzc3NiA1NTY3MzU5OTYxOTEyNTkwIDQ1NTMwNjE5MDQ5NzA3OTM=