ModuleOptionsTest.php 1.7 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
52
53
54
55
56
<?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;
    
    /**
     * 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();
    }
    
    public function testSuperClass()
    {
        $this->assertInstanceOf('ZfcUser\Options\ModuleOptions', $this->options);
    }
    
    public function testOptionsDefaultValues()
    {
        $options = new ModuleOptions();
        
        $this->assertInternalType('array', $array = $options->getUsurpationAllowedUsernames());
        $this->assertEmpty($array);
        
        $this->assertInternalType('array', $array = $options->getCas());
        $this->assertEmpty($array);
        
        $this->assertFalse($this->options->getSaveLdapUserInDatabase());
    }
    
    public function testConstructorSetsOptions()
    {
        $options = array(
            'usurpation_allowed_usernames' => array('bob'),
            'save_ldap_user_in_database'  => true,
            'cas'                         => array('Cas config'),
        );
        $moduleOptions = new ModuleOptions($options);
        
        $this->assertEquals(array_shift($options), $moduleOptions->getUsurpationAllowedUsernames());
        $this->assertEquals(array_shift($options), $moduleOptions->getSaveLdapUserInDatabase());
        $this->assertEquals(array_shift($options), $moduleOptions->getCas());
    }
}