ModuleOptionsTest.php 1.64 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
namespace UnicaenAuthTest\Options;

use PHPUnit_Framework_TestCase;
use UnicaenAuth\Options\ModuleOptions;

/**
 * Description of ModuleOptionsTest
 *
 * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
 */
class ModuleOptionsTest extends PHPUnit_Framework_TestCase
{
    protected $options;
15

16
17
18
19
20
21
22
23
    /**
     * Sets up the fixture, for example, open a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
        $this->options = new ModuleOptions();
    }
24

25
26
27
28
    public function testSuperClass()
    {
        $this->assertInstanceOf('ZfcUser\Options\ModuleOptions', $this->options);
    }
29

30
31
32
    public function testOptionsDefaultValues()
    {
        $options = new ModuleOptions();
33

34
35
        $this->assertInternalType('array', $array = $options->getUsurpationAllowedUsernames());
        $this->assertEmpty($array);
36

37
38
        $this->assertInternalType('array', $array = $options->getCas());
        $this->assertEmpty($array);
39

40
41
        $this->assertFalse($this->options->getSaveLdapUserInDatabase());
    }
42

43
44
    public function testConstructorSetsOptions()
    {
45
46
        $options = [
            'usurpation_allowed_usernames' => ['bob'],
47
            'save_ldap_user_in_database'  => true,
48
49
            'cas'                         => ['Cas config'],
        ];
50
        $moduleOptions = new ModuleOptions($options);
51

52
53
54
55
56
        $this->assertEquals(array_shift($options), $moduleOptions->getUsurpationAllowedUsernames());
        $this->assertEquals(array_shift($options), $moduleOptions->getSaveLdapUserInDatabase());
        $this->assertEquals(array_shift($options), $moduleOptions->getCas());
    }
}