1<?php
2
3namespace Sabre\CalDAV\Backend;
4
5use Sabre\CalDAV;
6
7require_once 'Sabre/CalDAV/Backend/AbstractPDOTest.php';
8
9class PDOSQLiteTest extends AbstractPDOTest {
10
11    function setup() {
12
13        if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
14
15        if (file_exists(SABRE_TEMPDIR . '/testdb.sqlite'))
16            unlink(SABRE_TEMPDIR . '/testdb.sqlite');
17
18        $pdo = new \PDO('sqlite:' . SABRE_TEMPDIR . '/testdb.sqlite');
19        $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION);
20
21        // Yup this is definitely not 'fool proof', but good enough for now.
22        $queries = explode(';', file_get_contents(__DIR__ . '/../../../../examples/sql/sqlite.calendars.sql'));
23        foreach($queries as $query) {
24            $pdo->exec($query);
25        }
26        $this->pdo = $pdo;
27
28    }
29
30    function teardown() {
31
32        $this->pdo = null;
33        unlink(SABRE_TEMPDIR . '/testdb.sqlite');
34
35    }
36
37}
38