]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/DAV/AbstractServer.php
Merge branch 'master' of git://github.com/friendica/friendica-addons
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / DAV / AbstractServer.php
1 <?php
2
3 require_once 'Sabre/HTTP/ResponseMock.php';
4
5 abstract class Sabre_DAV_AbstractServer extends PHPUnit_Framework_TestCase {
6
7     /**
8      * @var Sabre_HTTP_ResponseMock
9      */
10     protected $response;
11     protected $request;
12     /**
13      * @var Sabre_DAV_Server
14      */
15     protected $server;
16     protected $tempDir = SABRE_TEMPDIR;
17
18     function setUp() {
19
20         $this->response = new Sabre_HTTP_ResponseMock();
21         $this->server = new Sabre_DAV_Server($this->getRootNode());
22         $this->server->httpResponse = $this->response;
23         $this->server->debugExceptions = true;
24         file_put_contents(SABRE_TEMPDIR . '/test.txt', 'Test contents');
25         mkdir(SABRE_TEMPDIR . '/dir');
26         file_put_contents(SABRE_TEMPDIR . '/dir/child.txt', 'Child contents');
27
28
29     }
30
31     function tearDown() {
32
33         $this->deleteTree(SABRE_TEMPDIR,false);
34
35     }
36
37     protected function getRootNode() {
38
39         return new Sabre_DAV_FS_Directory(SABRE_TEMPDIR);
40
41     }
42
43     private function deleteTree($path,$deleteRoot = true) {
44
45         foreach(scandir($path) as $node) {
46
47             if ($node=='.' || $node=='.svn' || $node=='..') continue;
48             $myPath = $path.'/'. $node;
49             if (is_file($myPath)) {
50                 unlink($myPath);
51             } else {
52                 $this->deleteTree($myPath);
53             }
54
55         }
56         if ($deleteRoot) rmdir($path);
57
58     }
59
60 }