1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
<?php
require_once __DIR__.'/../../Base.php';
use Kanboard\Core\Ldap\Entry;
class EntryTest extends Base
{
private $entry = array(
'count' => 2,
'dn' => 'uid=my_user,ou=People,dc=kanboard,dc=local',
'displayname' => array(
'count' => 1,
0 => 'My LDAP user',
),
'broken' => array(
),
'mail' => array(
'count' => 2,
0 => 'user1@localhost',
1 => 'user2@localhost',
),
'samaccountname' => array(
'count' => 1,
0 => 'my_ldap_user',
),
0 => 'displayname',
1 => 'mail',
2 => 'samaccountname',
);
public function testGetAll()
{
$expected = array(
'user1@localhost',
'user2@localhost',
);
$entry = new Entry($this->entry);
$this->assertEquals($expected, $entry->getAll('mail'));
$this->assertEmpty($entry->getAll('not found'));
$this->assertEmpty($entry->getAll('broken'));
}
public function testGetFirst()
{
$entry = new Entry($this->entry);
$this->assertEquals('user1@localhost', $entry->getFirstValue('mail'));
$this->assertEquals('', $entry->getFirstValue('not found'));
$this->assertEquals('default', $entry->getFirstValue('not found', 'default'));
$this->assertEquals('default', $entry->getFirstValue('broken', 'default'));
}
public function testGetDn()
{
$entry = new Entry($this->entry);
$this->assertEquals('uid=my_user,ou=People,dc=kanboard,dc=local', $entry->getDn());
$entry = new Entry(array());
$this->assertEquals('', $entry->getDn());
}
public function testHasValue()
{
$entry = new Entry($this->entry);
$this->assertTrue($entry->hasValue('mail', 'user2@localhost'));
$this->assertFalse($entry->hasValue('mail', 'user3@localhost'));
$this->assertTrue($entry->hasValue('displayname', 'My LDAP user'));
$this->assertFalse($entry->hasValue('displayname', 'Something else'));
}
}
|