summaryrefslogtreecommitdiff
path: root/tests/units/Core/Ldap/EntriesTest.php
blob: 65025b6ee72e55a1b4e2dff5e3086701429b06be (plain)
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
<?php

require_once __DIR__.'/../../Base.php';

use Kanboard\Core\Ldap\Entries;

class EntriesTest extends Base
{
    private $entries = array(
        'count' => 2,
        0 => array(
            'cn' => array(
                'count' => 1,
                0 => 'Kanboard Other Group',
            ),
            0 => 'cn',
            'count' => 1,
            'dn' => 'CN=Kanboard Other Group,CN=Users,DC=kanboard,DC=local',
        ),
        1 => array(
            'cn' => array(
                'count' => 1,
                0 => 'Kanboard Users',
            ),
            0 => 'cn',
            'count' => 1,
            'dn' => 'CN=Kanboard Users,CN=Users,DC=kanboard,DC=local',
        ),
    );

    public function testGetAll()
    {
        $entries = new Entries(array());
        $this->assertEmpty($entries->getAll());

        $entries = new Entries($this->entries);
        $result = $entries->getAll();
        $this->assertCount(2, $result);
        $this->assertInstanceOf('Kanboard\Core\Ldap\Entry', $result[0]);
        $this->assertEquals('CN=Kanboard Users,CN=Users,DC=kanboard,DC=local', $result[1]->getDn());
        $this->assertEquals('Kanboard Users', $result[1]->getFirstValue('cn'));
    }

    public function testGetFirst()
    {
        $entries = new Entries(array());
        $this->assertEquals('', $entries->getFirstEntry()->getDn());

        $entries = new Entries($this->entries);
        $result = $entries->getFirstEntry();
        $this->assertInstanceOf('Kanboard\Core\Ldap\Entry', $result);
        $this->assertEquals('CN=Kanboard Other Group,CN=Users,DC=kanboard,DC=local', $result->getDn());
        $this->assertEquals('Kanboard Other Group', $result->getFirstValue('cn'));
    }
}