"Fossies" - the Fresh Open Source Software Archive

Member "dav-4.0.3/tests/Sabre/DAV/AbstractServer.php" (10 Jan 2020, 1564 Bytes) of package /linux/www/dav-4.0.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "AbstractServer.php": 4.0.2_vs_4.0.3.

    1 <?php
    2 
    3 declare(strict_types=1);
    4 
    5 namespace Sabre\DAV;
    6 
    7 use Sabre\HTTP;
    8 
    9 abstract class AbstractServer extends \PHPUnit\Framework\TestCase
   10 {
   11     /**
   12      * @var \Sabre\HTTP\ResponseMock
   13      */
   14     protected $response;
   15     protected $request;
   16     /**
   17      * @var Sabre\DAV\Server
   18      */
   19     protected $server;
   20     protected $tempDir = SABRE_TEMPDIR;
   21 
   22     public function setUp()
   23     {
   24         $this->response = new HTTP\ResponseMock();
   25         $this->server = new Server($this->getRootNode());
   26         $this->server->sapi = new HTTP\SapiMock();
   27         $this->server->httpResponse = $this->response;
   28         $this->server->debugExceptions = true;
   29         $this->deleteTree(SABRE_TEMPDIR, false);
   30         file_put_contents(SABRE_TEMPDIR.'/test.txt', 'Test contents');
   31         mkdir(SABRE_TEMPDIR.'/dir');
   32         file_put_contents(SABRE_TEMPDIR.'/dir/child.txt', 'Child contents');
   33     }
   34 
   35     public function tearDown()
   36     {
   37         $this->deleteTree(SABRE_TEMPDIR, false);
   38     }
   39 
   40     protected function getRootNode()
   41     {
   42         return new FS\Directory(SABRE_TEMPDIR);
   43     }
   44 
   45     private function deleteTree($path, $deleteRoot = true)
   46     {
   47         foreach (scandir($path) as $node) {
   48             if ('.' == $node || '.svn' == $node || '..' == $node) {
   49                 continue;
   50             }
   51             $myPath = $path.'/'.$node;
   52             if (is_file($myPath)) {
   53                 unlink($myPath);
   54             } else {
   55                 $this->deleteTree($myPath);
   56             }
   57         }
   58         if ($deleteRoot) {
   59             rmdir($path);
   60         }
   61     }
   62 }