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