ConfigTest.php 1.54 KB
Newer Older
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
<?php
namespace UnicaenAuthTest\Provider\Role;

use PHPUnit_Framework_TestCase;
use UnicaenAuth\Provider\Role\Config;

/**
 * Description of ConfigTest
 *
 * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
 */
class ConfigTest extends PHPUnit_Framework_TestCase
{
    protected $config;
    protected $options = array(
        'guest' => array(
            'name' => "Profil standard",
            'children' => array(
                'cn=support_info,ou=groups,dc=unicaen,dc=fr', // pas de nom pour celui-là
                'cn=dsi-infra,ou=groups,dc=unicaen,dc=fr' => array(
                    'name' => "DSI Infrastructure",
                ),
            ),
        ),
    );
    
    protected function setUp()
    {
        $this->config = new Config($this->options);
    }
    
    public function testLoadRolesFormConfigCreateNamedRoles()
    {
        $roles = $this->config->getRoles();
        $expected = array(
            $guest = new \UnicaenAuth\Acl\NamedRole(
                    'guest', 
                    null, 
                    "Profil standard"),
            new \UnicaenAuth\Acl\NamedRole(
                    'cn=support_info,ou=groups,dc=unicaen,dc=fr', 
                    $guest, 
                    "cn=support_info,ou=groups,dc=unicaen,dc=fr"), // le nom par défaut est l'id
            new \UnicaenAuth\Acl\NamedRole(
                    'cn=dsi-infra,ou=groups,dc=unicaen,dc=fr', 
                    $guest, 
                    "DSI Infrastructure"),
        );
        $this->assertEquals($expected, $roles);
    }
}