3 require_once 'Sabre/HTTP/ResponseMock.php';
5 abstract class Sabre_DAV_AbstractServer extends PHPUnit_Framework_TestCase {
8 * @var Sabre_HTTP_ResponseMock
13 * @var Sabre_DAV_Server
16 protected $tempDir = SABRE_TEMPDIR;
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');
33 $this->deleteTree(SABRE_TEMPDIR,false);
37 protected function getRootNode() {
39 return new Sabre_DAV_FS_Directory(SABRE_TEMPDIR);
43 private function deleteTree($path,$deleteRoot = true) {
45 foreach(scandir($path) as $node) {
47 if ($node=='.' || $node=='.svn' || $node=='..') continue;
48 $myPath = $path.'/'. $node;
49 if (is_file($myPath)) {
52 $this->deleteTree($myPath);
56 if ($deleteRoot) rmdir($path);