function it_should_lookup_servers_via_dns_if_no_servers_are_defined(TcpSocket $tcp, Dns $dns)
{
$tcp->connect('bar.example.com', 389, 1)->shouldBeCalled()->willReturn(false);
$tcp->connect('test.example.com', 389, 1)->shouldBeCalled()->willReturn(false);
$tcp->connect('foo.example.com', 389, 1)->shouldBeCalled()->willReturn(true);
$tcp->close()->willReturn(null);
$srvRecords = [['host' => '_ldap._tcp.example.com', 'class' => 'IN', 'ttl' => 600, 'type' => 'SRV', 'pri' => 1, 'weight' => 101, 'port' => 389, 'target' => 'foo.example.com'], ['host' => '_ldap._tcp.example.com', 'class' => 'IN', 'ttl' => 600, 'type' => 'SRV', 'pri' => 0, 'weight' => 100, 'port' => 389, 'target' => 'test.example.com'], ['host' => '_ldap._tcp.example.com', 'class' => 'IN', 'ttl' => 600, 'type' => 'SRV', 'pri' => 0, 'weight' => 101, 'port' => 389, 'target' => 'bar.example.com']];
$dns->getRecord("_ldap._tcp.example.com", DNS_SRV)->willReturn($srvRecords);
$config = new DomainConfiguration('example.com');
$this->beConstructedWith($config, $tcp, $dns);
$this->getServer()->shouldBeEqualTo('foo.example.com');
}