Example #1
0
 static function getSQLiteDB()
 {
     if (file_exists(SABRE_TEMPDIR . '/testdb.sqlite')) {
         unlink(SABRE_TEMPDIR . '/testdb.sqlite');
     }
     $pdo = new PDO('sqlite:' . SABRE_TEMPDIR . '/testdb.sqlite');
     $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     // Yup this is definitely not 'fool proof', but good enough for now.
     $queries = explode(';', file_get_contents(__DIR__ . '/../../../examples/sql/sqlite.addressbooks.sql'));
     foreach ($queries as $query) {
         $pdo->exec($query);
     }
     // Inserting events through a backend class.
     $backend = new Sabre_CardDAV_Backend_PDO($pdo);
     $addressbookId = $backend->createAddressBook('principals/user1', 'UUID-123467', array('{DAV:}displayname' => 'user1 addressbook', '{urn:ietf:params:xml:ns:carddav}addressbook-description' => 'AddressBook description'));
     $backend->createAddressBook('principals/user1', 'UUID-123468', array('{DAV:}displayname' => 'user1 addressbook2', '{urn:ietf:params:xml:ns:carddav}addressbook-description' => 'AddressBook description'));
     $backend->createCard($addressbookId, 'UUID-2345', self::getTestCardData());
     return $pdo;
 }
 /**
  * @depends testGetCard
  */
 public function testDeleteCard()
 {
     $this->backend->deleteCard(1, 'card1');
     $result = $this->backend->getCard(1, 'card1');
     $this->assertFalse($result);
 }