[Pkg-owncloud-commits] [php-sabredav] 141/163: Everything is now tested
David Prévot
taffit at moszumanska.debian.org
Tue May 20 18:55:02 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag upstream/2.0.0_beta1
in repository php-sabredav.
commit f5dc36e0081a726e80036162423654850c22b42f
Author: Evert Pot <me at evertpot.com>
Date: Thu May 15 14:26:16 2014 -0400
Everything is now tested
---
examples/sql/mysql.propertystorage.sql | 8 +-
.../PropertyStorage/Backend/AbstractPDOTest.php | 96 ++++++++++++++++++++++
.../DAV/PropertyStorage/Backend/PDOMysqlTest.php | 31 +++++++
.../DAV/PropertyStorage/Backend/PDOSqliteTest.php | 37 +++++++++
tests/Sabre/TestUtil.php | 7 ++
5 files changed, 175 insertions(+), 4 deletions(-)
diff --git a/examples/sql/mysql.propertystorage.sql b/examples/sql/mysql.propertystorage.sql
index 1b069df..c81ab9b 100644
--- a/examples/sql/mysql.propertystorage.sql
+++ b/examples/sql/mysql.propertystorage.sql
@@ -1,7 +1,7 @@
CREATE TABLE propertystorage (
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
- path VARCHAR(1024) NOT NULL,
- name VARCHAR(100) NOT NULL,
- value MEDIUMTEXT,
+ path VARBINARY(1024) NOT NULL,
+ name VARBINARY(100) NOT NULL,
+ value MEDIUMBLOB
);
-CREATE UNIQUE INDEX path_property ON propertystorage (path, name);
+CREATE UNIQUE INDEX path_property ON propertystorage (path(600), name(100));
diff --git a/tests/Sabre/DAV/PropertyStorage/Backend/AbstractPDOTest.php b/tests/Sabre/DAV/PropertyStorage/Backend/AbstractPDOTest.php
new file mode 100644
index 0000000..cb96100
--- /dev/null
+++ b/tests/Sabre/DAV/PropertyStorage/Backend/AbstractPDOTest.php
@@ -0,0 +1,96 @@
+<?php
+
+namespace Sabre\DAV\PropertyStorage\Backend;
+
+use Sabre\DAV\PropFind;
+use Sabre\DAV\PropPatch;
+
+abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * Should return an instance of \PDO with the current tables initialized,
+ * and some test records.
+ */
+ abstract function getPDO();
+
+ function getBackend() {
+
+ return new PDO($this->getPDO());
+
+ }
+
+ function testPropFind() {
+
+ $backend = $this->getBackend();
+
+ $propFind = new PropFind('dir', ['{DAV:}displayname']);
+ $backend->propFind('dir', $propFind);
+
+ $this->assertEquals('Directory', $propFind->get('{DAV:}displayname'));
+
+ }
+
+ function testPropFindNothingToDo() {
+
+ $backend = $this->getBackend();
+
+ $propFind = new PropFind('dir', ['{DAV:}displayname']);
+ $propFind->set('{DAV:}displayname', 'foo');
+ $backend->propFind('dir', $propFind);
+
+ $this->assertEquals('foo', $propFind->get('{DAV:}displayname'));
+
+ }
+
+ /**
+ * @depends testPropFind
+ */
+ function testPropPatchUpdate() {
+
+ $backend = $this->getBackend();
+
+ $propPatch = new PropPatch(['{DAV:}displayname' => 'bar']);
+ $backend->propPatch('dir', $propPatch);
+ $propPatch->commit();
+
+ $propFind = new PropFind('dir', ['{DAV:}displayname']);
+ $backend->propFind('dir', $propFind);
+
+ $this->assertEquals('bar', $propFind->get('{DAV:}displayname'));
+
+ }
+
+ /**
+ * @depends testPropFind
+ */
+ function testPropPatchRemove() {
+
+ $backend = $this->getBackend();
+
+ $propPatch = new PropPatch(['{DAV:}displayname' => null]);
+ $backend->propPatch('dir', $propPatch);
+ $propPatch->commit();
+
+ $propFind = new PropFind('dir', ['{DAV:}displayname']);
+ $backend->propFind('dir', $propFind);
+
+ $this->assertEquals(null, $propFind->get('{DAV:}displayname'));
+
+ }
+
+ /**
+ * @depends testPropFind
+ */
+ function testDelete() {
+
+ $backend = $this->getBackend();
+ $backend->delete('dir');
+
+ $propFind = new PropFind('dir', ['{DAV:}displayname']);
+ $backend->propFind('dir', $propFind);
+
+ $this->assertEquals(null, $propFind->get('{DAV:}displayname'));
+
+ }
+
+}
diff --git a/tests/Sabre/DAV/PropertyStorage/Backend/PDOMysqlTest.php b/tests/Sabre/DAV/PropertyStorage/Backend/PDOMysqlTest.php
new file mode 100644
index 0000000..ff6db27
--- /dev/null
+++ b/tests/Sabre/DAV/PropertyStorage/Backend/PDOMysqlTest.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Sabre\DAV\PropertyStorage\Backend;
+
+class PDOMySqlTest extends AbstractPDOTest {
+
+ function getPDO() {
+
+ $pdo = \Sabre\TestUtil::getMySQLDB();
+ if (!$pdo) $this->markTestSkipped('MySQL is not enabled');
+
+ $setupSql = file_get_contents(__DIR__ . '/../../../../../examples/sql/mysql.propertystorage.sql');
+ // Sloppy multi-query, but it works
+ $setupSql = explode(';', $setupSql);
+
+ $pdo->exec('DROP TABLE IF EXISTS propertystorage');
+
+ foreach($setupSql as $sql) {
+
+ if (!trim($sql)) continue;
+ $pdo->exec($sql);
+
+ }
+ $pdo->exec('INSERT INTO propertystorage (path, name, value) VALUES ("dir", "{DAV:}displayname", "Directory")');
+
+ return $pdo;
+
+ }
+
+}
+
diff --git a/tests/Sabre/DAV/PropertyStorage/Backend/PDOSqliteTest.php b/tests/Sabre/DAV/PropertyStorage/Backend/PDOSqliteTest.php
new file mode 100644
index 0000000..a48cfeb
--- /dev/null
+++ b/tests/Sabre/DAV/PropertyStorage/Backend/PDOSqliteTest.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Sabre\DAV\PropertyStorage\Backend;
+
+class PDOSqliteTest extends AbstractPDOTest {
+
+ function getPDO() {
+
+ $pdo = \Sabre\TestUtil::getSqliteDB();
+ if (!$pdo) $this->markTestSkipped('Sqlite is not enabled');
+
+ $setupSql = file_get_contents(__DIR__ . '/../../../../../examples/sql/sqlite.propertystorage.sql');
+ // Sloppy multi-query, but it works
+ $setupSql = explode(';', $setupSql);
+
+ $pdo->exec('DROP TABLE IF EXISTS propertystorage');
+
+ foreach($setupSql as $sql) {
+
+ if (!trim($sql)) continue;
+ $pdo->exec($sql);
+
+ }
+ $pdo->exec('INSERT INTO propertystorage (path, name, value) VALUES ("dir", "{DAV:}displayname", "Directory")');
+
+ return $pdo;
+
+ }
+
+ function tearDown() {
+
+ \Sabre\TestUtil::clearTempDir();
+
+ }
+
+}
+
diff --git a/tests/Sabre/TestUtil.php b/tests/Sabre/TestUtil.php
index 5a90624..20bce1e 100644
--- a/tests/Sabre/TestUtil.php
+++ b/tests/Sabre/TestUtil.php
@@ -47,5 +47,12 @@ class TestUtil {
}
+ static function getSQLiteDB() {
+
+ $pdo = new \PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend');
+ $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION);
+ return $pdo;
+
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list