File: DriverTest.php

package info (click to toggle)
php-horde-passwd 5.0.2-3%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 3,324 kB
  • ctags: 301
  • sloc: php: 2,014; xml: 1,054; makefile: 10; sh: 3
file content (68 lines) | stat: -rw-r--r-- 1,931 bytes parent folder | download | duplicates (6)
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
<?php
/**
 * Test the backend driver factory.
 *
 * @author     Ralf Lang <lang@b1-systems.de>
 * @category   Horde
 * @copyright  2013 Horde LLC
 * @internal
 * @license    http://www.horde.org/licenses/gpl GPL
 * @package    Passwd
 * @subpackage UnitTests
 */
class Passwd_Unit_Factory_DriverTest extends Passwd_TestCase
{
    protected $_backends = array();

    public function setUp()
    {
        $this->markTestIncomplete('Factories with configuration files don\'t work out of the box.');
        $this->_backends = array(
            'null' => array(
                'disabled' => false,
                'name' => 'Null',
                'driver' => 'Null',
                'policy' => array(
                    'minLength' => 6,
                    'minNumeric' => 1
                )
            )
        );
    }

    public function testGettingSubdriversWorks()
    {
        $factory = new Passwd_Factory_Driver($this->getInjector());
        $factory->backends = array();

        $driver = $factory->create('Null', array(
            'is_subdriver' => true,
            'driver' => 'Null'
        ));

        $this->assertInstanceOf('Passwd_Driver', $driver);
    }

    public function testGetBackendsReturnsResultOfSetBackends()
    {
        $GLOBALS['injector'] = $this->getInjector();
        $factory = new Passwd_Factory_Driver($this->getInjector());
        $factory->backends = $this->_backends;

        $this->assertArrayHasKey('null', $factory->backends);
    }

    // This test is currently blocked by a static call
    public function testGettingTheSameDriverTwiceWorks()
    {
        $GLOBALS['injector'] = $this->getInjector();
        $factory = new Passwd_Factory_Driver($this->getInjector());
        $factory->backends = $this->_backends;

        $driver1 = $factory->create('null');
        $driver2 = $factory->create('null');

        $this->assertEquals($driver1, $driver2);
    }

}