File: SqlTest.php

package info (click to toggle)
php-horde-passwd 5.0.7-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 3,412 kB
  • sloc: php: 2,017; xml: 1,136; javascript: 29; makefile: 18; sh: 3
file content (52 lines) | stat: -rw-r--r-- 1,451 bytes parent folder | download | duplicates (2)
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
<?php
/**
 * Test the Sql backend driver.
 *
 * @author     Ralf Lang <lang@b1-systems.de>
 * @category   Horde
 * @copyright  2013 Horde LLC
 * @internal
 * @package    Passwd
 * @subpackage UnitTests
 */
class Passwd_Unit_Driver_SqlTest extends Passwd_TestCase
{
    private $driver;

    public static function setUpBeforeClass(): void
    {
        self::createBasicPasswdSetup(new Horde_Test_Setup());
        parent::setUpBeforeClass();
    }

    public function setUp(): void
    {
        $GLOBALS['injector'] = $this->getInjector();
        $factory = new Passwd_Factory_Driver($this->getInjector());
        $factory->backends = array();

        // Get a Horde_Db_Adapter to prevent usage of Horde_Core_Factory_Db.
        $db = new Horde_Db_Adapter_Pdo_Sqlite(array('dbname' => ':memory:'));
        $db->execute("CREATE TABLE horde_users (
            user_uid VARCHAR(255) PRIMARY KEY NOT NULL,
            user_pass VARCHAR(255) NOT NULL,
            user_soft_expiration_date INTEGER,
            user_hard_expiration_date INTEGER
        );");

        $this->driver = new Passwd_Driver_Sql(array('db' => $db));
    }

    public function testSetup()
    {
        $this->assertInstanceOf('Passwd_Driver', $this->driver);
    }

    public function testChangePasswordFailsForNonexistingUser()
    {
        $this->expectException('Passwd_Exception');

        $res = $this->driver->changePassword('Patricia', 'alt', 'neu');
    }

}