blob: 5a4a7a3279e71c1134bcf30c7e73a1797824ca95 (
plain) (
blame)
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
53
54
|
<?php
namespace Sabre\CardDAV\Backend;
require_once 'Sabre/TestUtil.php';
class PDOSqliteTest extends AbstractPDOTest {
function tearDown() {
if (file_exists(SABRE_TEMPDIR . '/pdobackend')) unlink(SABRE_TEMPDIR . '/pdobackend');
if (file_exists(SABRE_TEMPDIR . '/pdobackend2')) unlink(SABRE_TEMPDIR . '/pdobackend2');
}
/**
* @return PDO
*/
function getPDO() {
return self::getSQLite();
}
/**
* @return PDO
*/
static function getSQLite() {
if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
$pdo = new \PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend');
$pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION);
$pdo->query("DROP TABLE IF EXISTS addressbooks");
$pdo->query("DROP TABLE IF EXISTS addressbookchanges");
$pdo->query("DROP TABLE IF EXISTS cards");
$queries = explode(
';',
file_get_contents(__DIR__ . '/../../../../examples/sql/sqlite.addressbooks.sql')
);
foreach($queries as $query) {
$query = trim($query," \r\n\t");
if ($query)
$pdo->exec($query);
}
return $pdo;
}
}
|