예제 #1
0
파일: TestCase.php 프로젝트: surjit/DNS
 /**
  * @return Zone
  */
 protected function buildTestZone()
 {
     $soa = new ResourceRecord();
     $soa->setClass('IN');
     $soa->setName('@');
     $soa->setRdata(Factory::Soa('example.com.', 'postmaster.example.com.', 2015050801, 3600, 14400, 604800, 3600, false));
     $ns1 = new ResourceRecord();
     $ns1->setClass('IN');
     $ns1->setName('@');
     $ns1->setTtl(14400);
     $ns1->setRdata(Factory::Ns('ns1.example.net.au.'));
     $ns2 = new ResourceRecord();
     $ns2->setClass('IN');
     $ns2->setName('@');
     $ns2->setTtl(14400);
     $ns2->setRdata(Factory::Ns('ns2.example.net.au.'));
     $a_record = new ResourceRecord();
     $a_record->setName('subdomain.au');
     $a_record->setRdata(Factory::A('192.168.1.2'));
     $a_record->setComment('This is a local ip.');
     $cname = new ResourceRecord();
     $cname->setName('alias');
     $cname->setRdata(Factory::Cname('subdomain.au.example.com.'));
     $aaaa = new ResourceRecord('ipv6domain', Factory::Aaaa('::1'), 3600, Classes::INTERNET, 'This is an IPv6 domain.');
     $mx1 = new ResourceRecord();
     $mx1->setName('@');
     $mx1->setRdata(Factory::Mx(10, 'mail-gw1.example.net.'));
     $mx2 = new ResourceRecord();
     $mx2->setName('@');
     $mx2->setRdata(Factory::Mx(20, 'mail-gw2.example.net.'));
     $mx3 = new ResourceRecord();
     $mx3->setName('@');
     $mx3->setRdata(Factory::Mx(30, 'mail-gw3.example.net.'));
     $txt = new ResourceRecord();
     $txt->setName('example.net.');
     $txt->setRdata(Factory::txt('v=spf1 ip4:192.0.2.0/24 ip4:198.51.100.123 a -all'));
     $txt->setClass(Classes::INTERNET);
     $loc = new ResourceRecord();
     $loc->setName('canberra');
     $loc->setRdata(Factory::Loc(-35.3075, 149.1244, 500, 20.12, 200.3, 300.1));
     $loc->setComment('This is Canberra');
     $loc->setClass(Classes::INTERNET);
     $dname = new ResourceRecord();
     $dname->setName('bar.example.com.');
     $dname->setClass(Classes::INTERNET);
     $dname->setRdata(Factory::Dname('foo.example.com.'));
     $hinfo = new ResourceRecord();
     $hinfo->setName('@');
     $hinfo->setClass(Classes::INTERNET);
     $hinfo->setRdata(Factory::Hinfo('2.7GHz', 'Ubuntu 12.04'));
     return new Zone('example.com.', 3600, [$soa, $ns1, $ns2, $a_record, $aaaa, $loc, $dname, $mx3, $mx1, $mx2, $cname, $txt, $hinfo]);
 }
예제 #2
0
 public function testCompareResourceRecords()
 {
     $soa = new ResourceRecord();
     $soa->setClass('IN');
     $soa->setName('@');
     $soa->setRdata(Factory::Soa('example.com.', 'postmaster.example.com.', 2015050801, 3600, 14400, 604800, 3600));
     $ns1 = new ResourceRecord();
     $ns1->setClass(Classes::INTERNET);
     $ns1->setName('@');
     $ns1->setTtl(14400);
     $ns1->setRdata(Factory::Ns('ns1.example.net.au.'));
     $ns2 = new ResourceRecord();
     $ns2->setClass('IN');
     $ns2->setName('@');
     $ns2->setTtl(14400);
     $ns2->setRdata(Factory::Ns('ns2.example.net.au.'));
     $a = new ResourceRecord();
     $a->setName('subdomain.au');
     $a->setRdata(Factory::A('192.168.1.2'));
     $a->setComment('This is a local ip.');
     $cname = new ResourceRecord();
     $cname->setName('alias');
     $cname->setRdata(Factory::Cname('subdomain.au.example.com.'));
     $cname->setClass(Classes::INTERNET);
     $aaaa = new ResourceRecord('ipv6domain', Factory::Aaaa('::1'), 3600);
     $mx1 = new ResourceRecord();
     $mx1->setName('@');
     $mx1->setRdata(Factory::Mx(10, 'mailgw01.example.net.'));
     $mx2 = new ResourceRecord();
     $mx2->setName('@');
     $mx2->setRdata(Factory::Mx(20, 'mailgw02.example.net.'));
     $txt = new ResourceRecord();
     $txt->setName('example.net.');
     $txt->setRdata(Factory::txt('v=spf1 ip4:192.0.2.0/24 ip4:198.51.100.123 a -all'));
     $dummy = new ResourceRecord();
     $dummy->setName('example.com.');
     $dummy->setRdata(new DummyRdata());
     $this->assertTrue(AlignedBuilder::compareResourceRecords($soa, $ns1) < 0);
     $this->assertTrue(AlignedBuilder::compareResourceRecords($aaaa, $cname) < 0);
     $this->assertTrue(AlignedBuilder::compareResourceRecords($mx1, $mx2) < 0);
     $this->assertTrue(AlignedBuilder::compareResourceRecords($mx1, $mx2) < 0);
     $this->assertTrue(AlignedBuilder::compareResourceRecords($mx1, $dummy) < 0);
     $this->assertTrue(AlignedBuilder::compareResourceRecords($mx1, $a) > 0);
     $this->assertTrue(AlignedBuilder::compareResourceRecords($ns2, $ns1) > 0);
     $this->assertTrue(AlignedBuilder::compareResourceRecords($dummy, $txt) > 0);
 }