Skip to content

Commit

Permalink
Add and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebauman committed Jul 26, 2024
1 parent 0ead806 commit 871d41d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions tests/Unit/Configuration/DomainConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function test_default_options()
$config = new DomainConfiguration();

$this->assertEquals(389, $config->get('port'));
$this->assertNull($config->get('protocol'));
$this->assertEmpty($config->get('hosts'));
$this->assertEquals(0, $config->get('follow_referrals'));
$this->assertEmpty($config->get('username'));
Expand All @@ -50,6 +51,7 @@ public function test_all_options()
{
$config = new DomainConfiguration([
'port' => 500,
'protocol' => 'foo://',
'base_dn' => 'dc=corp,dc=org',
'hosts' => ['dc1', 'dc2'],
'follow_referrals' => false,
Expand All @@ -67,6 +69,7 @@ public function test_all_options()
]);

$this->assertEquals(500, $config->get('port'));
$this->assertEquals('foo://', $config->get('protocol'));
$this->assertEquals('dc=corp,dc=org', $config->get('base_dn'));
$this->assertEquals(['dc1', 'dc2'], $config->get('hosts'));
$this->assertEquals('username', $config->get('username'));
Expand All @@ -92,6 +95,7 @@ public function test_get_all()
'timeout' => 5,
'version' => 3,
'port' => 389,
'protocol' => null,
'base_dn' => '',
'username' => '',
'password' => '',
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/FakeDirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function test_fake_connection_uses_real_connections_config()
'username' => 'user',
'password' => 'pass',
'port' => 389,
'protocol' => null,
'use_tls' => true,
'use_ssl' => false,
'use_sasl' => false,
Expand Down
9 changes: 5 additions & 4 deletions tests/Unit/LdapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace LdapRecord\Tests\Unit;

use LdapRecord\Ldap;
use LdapRecord\LdapInterface;
use LdapRecord\Testing\LdapFake;
use LdapRecord\Tests\TestCase;
use Mockery as m;
Expand All @@ -12,11 +13,11 @@ class LdapTest extends TestCase
public function test_construct_defaults()
{
$ldap = new Ldap();

$this->assertFalse($ldap->isUsingTLS());
$this->assertFalse($ldap->isUsingSSL());
$this->assertFalse($ldap->isBound());
$this->assertNull($ldap->getConnection());
$this->assertEquals($ldap->getProtocol(), LdapInterface::PROTOCOL);
}

public function test_host_arrays_are_properly_processed()
Expand All @@ -28,13 +29,13 @@ public function test_host_arrays_are_properly_processed()
$this->assertEquals('ldap://dc01:500 ldap://dc02:500', $ldap->getHost());
}

public function test_host_strings_are_properly_processed()
public function test_host_strings_are_properly_created()
{
$ldap = new LdapFake();

$ldap->connect('dc01', $port = 500);
$ldap->connect('dc01', $port = 500, 'foo://');

$this->assertEquals('ldap://dc01:500', $ldap->getHost());
$this->assertEquals('foo://dc01:500', $ldap->getHost());
}

public function test_get_default_protocol()
Expand Down

0 comments on commit 871d41d

Please sign in to comment.