1<?php
2
3namespace Sabre\DAVACL\PrincipalBackend;
4
5use Sabre\DAV;
6use Sabre\HTTP;
7
8
9require_once 'Sabre/TestUtil.php';
10
11class PDOMySQLTest extends AbstractPDOTest {
12
13    function getPDO() {
14
15        if (!SABRE_HASMYSQL) $this->markTestSkipped('MySQL driver is not available, or not properly configured');
16        $pdo = \Sabre\TestUtil::getMySQLDB();
17        if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database');
18        $pdo->query("DROP TABLE IF EXISTS principals");
19        $pdo->query("
20create table principals (
21	id integer unsigned not null primary key auto_increment,
22	uri varchar(50),
23    email varchar(80),
24    displayname VARCHAR(80),
25    vcardurl VARCHAR(80),
26	unique(uri)
27);");
28
29        $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/user','user@example.org','User')");
30        $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/group','group@example.org','Group')");
31        $pdo->query("DROP TABLE IF EXISTS groupmembers");
32        $pdo->query("CREATE TABLE groupmembers (
33                id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
34                    principal_id INTEGER UNSIGNED NOT NULL,
35                        member_id INTEGER UNSIGNED NOT NULL,
36                            UNIQUE(principal_id, member_id)
37                        );");
38
39        $pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (2,1)");
40
41        return $pdo;
42
43    }
44
45}
46