]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/TestUtil.php
Move friendica-specific parts into an own subdirectory
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / TestUtil.php
1 <?php
2
3 class Sabre_TestUtil {
4
5     /**
6      * This function deletes all the contents of the temporary directory.
7      *
8      * @return void
9      */
10     static function clearTempDir() {
11
12         self::deleteTree(SABRE_TEMPDIR,false);
13
14     }
15
16
17     static private function deleteTree($path,$deleteRoot = true) {
18
19         foreach(scandir($path) as $node) {
20
21             if ($node=='.' || $node=='..') continue;
22             $myPath = $path.'/'. $node;
23             if (is_file($myPath)) {
24                 unlink($myPath);
25             } else {
26                 self::deleteTree($myPath);
27             }
28
29         }
30         if ($deleteRoot) {
31             rmdir($path);
32         }
33
34     }
35
36     static function getMySQLDB() {
37
38         try {
39             $pdo = new PDO(SABRE_MYSQLDSN,SABRE_MYSQLUSER,SABRE_MYSQLPASS);
40             $pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
41             return $pdo;
42         } catch (PDOException $e) {
43             return null;
44         }
45
46     }
47
48
49 }