1<?php
2
3namespace Sabre\DAVACL\PrincipalBackend;
4
5use Sabre\DAV;
6use Sabre\HTTP;
7
8
9require_once 'Sabre/DAV/Auth/Backend/AbstractPDOTest.php';
10
11class PDOSQLiteTest extends AbstractPDOTest {
12
13    function tearDown() {
14
15        if (file_exists(SABRE_TEMPDIR . '/pdobackend')) unlink(SABRE_TEMPDIR . '/pdobackend');
16        if (file_exists(SABRE_TEMPDIR . '/pdobackend2')) unlink(SABRE_TEMPDIR . '/pdobackend2');
17
18    }
19
20    function getPDO() {
21
22        if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
23        $pdo = new \PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend');
24        $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION);
25        $pdo->query('CREATE TABLE principals (id INTEGER PRIMARY KEY ASC, uri TEXT, email VARCHAR(80), displayname VARCHAR(80))');
26        $pdo->query('INSERT INTO principals VALUES (1, "principals/user","user@example.org","User")');
27        $pdo->query('INSERT INTO principals VALUES (2, "principals/group","group@example.org","Group")');
28
29        $pdo->query("CREATE TABLE groupmembers (
30                id INTEGER PRIMARY KEY ASC,
31                principal_id INT,
32                member_id INT,
33                UNIQUE(principal_id, member_id)
34        );");
35
36        $pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (2,1)");
37
38        return $pdo;
39
40    }
41
42}
43