xref: /plugin/davcal/vendor/sabre/dav/tests/Sabre/CardDAV/Backend/PDOMySQLTest.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab)
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\CardDAV\Backend;
4*a1a3b679SAndreas Boehler
5*a1a3b679SAndreas Boehlerrequire_once 'Sabre/TestUtil.php';
6*a1a3b679SAndreas Boehler
7*a1a3b679SAndreas Boehlerclass PDOMySQLTest extends AbstractPDOTest {
8*a1a3b679SAndreas Boehler
9*a1a3b679SAndreas Boehler    /**
10*a1a3b679SAndreas Boehler     * @return PDO
11*a1a3b679SAndreas Boehler     */
12*a1a3b679SAndreas Boehler    public function getPDO() {
13*a1a3b679SAndreas Boehler
14*a1a3b679SAndreas Boehler        if (!SABRE_HASMYSQL) $this->markTestSkipped('MySQL driver is not available, or not properly configured');
15*a1a3b679SAndreas Boehler
16*a1a3b679SAndreas Boehler        $pdo = \Sabre\TestUtil::getMySQLDB();
17*a1a3b679SAndreas Boehler        if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database');
18*a1a3b679SAndreas Boehler
19*a1a3b679SAndreas Boehler        $pdo->query("DROP TABLE IF EXISTS addressbooks, cards, addressbookchanges");
20*a1a3b679SAndreas Boehler
21*a1a3b679SAndreas Boehler        $queries = explode(
22*a1a3b679SAndreas Boehler            ';',
23*a1a3b679SAndreas Boehler            file_get_contents(__DIR__ . '/../../../../examples/sql/mysql.addressbook.sql')
24*a1a3b679SAndreas Boehler        );
25*a1a3b679SAndreas Boehler
26*a1a3b679SAndreas Boehler        foreach($queries as $query) {
27*a1a3b679SAndreas Boehler            $query = trim($query," \r\n\t");
28*a1a3b679SAndreas Boehler            if ($query)
29*a1a3b679SAndreas Boehler                $pdo->exec($query);
30*a1a3b679SAndreas Boehler        }
31*a1a3b679SAndreas Boehler        return $pdo;
32*a1a3b679SAndreas Boehler
33*a1a3b679SAndreas Boehler    }
34*a1a3b679SAndreas Boehler
35*a1a3b679SAndreas Boehler}
36*a1a3b679SAndreas Boehler
37