]> git.mxchange.org Git - friendica-addons.git/blobdiff - dav/SabreDAV/tests/Sabre/TestUtil.php
Initial Release of the calendar plugin
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / TestUtil.php
diff --git a/dav/SabreDAV/tests/Sabre/TestUtil.php b/dav/SabreDAV/tests/Sabre/TestUtil.php
new file mode 100644 (file)
index 0000000..62ee1fb
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+
+class Sabre_TestUtil {
+
+    /**
+     * This function deletes all the contents of the temporary directory.
+     *
+     * @return void
+     */
+    static function clearTempDir() {
+
+        self::deleteTree(SABRE_TEMPDIR,false);
+
+    }
+
+
+    static private function deleteTree($path,$deleteRoot = true) {
+
+        foreach(scandir($path) as $node) {
+
+            if ($node=='.' || $node=='..') continue;
+            $myPath = $path.'/'. $node;
+            if (is_file($myPath)) {
+                unlink($myPath);
+            } else {
+                self::deleteTree($myPath);
+            }
+
+        }
+        if ($deleteRoot) {
+            rmdir($path);
+        }
+
+    }
+
+    static function getMySQLDB() {
+
+        try {
+            $pdo = new PDO(SABRE_MYSQLDSN,SABRE_MYSQLUSER,SABRE_MYSQLPASS);
+            $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
+            return $pdo;
+        } catch (PDOException $e) {
+            return null;
+        }
+
+    }
+
+
+}