"Fossies" - the Fresh Open Source Software Archive

Member "dav-4.0.3/tests/Sabre/DAV/Mount/PluginTest.php" (10 Jan 2020, 1777 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 "PluginTest.php": 4.0.2_vs_4.0.3.

    1 <?php
    2 
    3 declare(strict_types=1);
    4 
    5 namespace Sabre\DAV\Mount;
    6 
    7 use Sabre\DAV;
    8 use Sabre\HTTP;
    9 
   10 require_once 'Sabre/DAV/AbstractServer.php';
   11 
   12 class PluginTest extends DAV\AbstractServer
   13 {
   14     public function setUp()
   15     {
   16         parent::setUp();
   17         $this->server->addPlugin(new Plugin());
   18     }
   19 
   20     public function testPassThrough()
   21     {
   22         $serverVars = [
   23             'REQUEST_URI' => '/',
   24             'REQUEST_METHOD' => 'GET',
   25         ];
   26 
   27         $request = HTTP\Sapi::createFromServerArray($serverVars);
   28         $this->server->httpRequest = ($request);
   29         $this->server->exec();
   30 
   31         $this->assertEquals(501, $this->response->status, 'We expected GET to not be implemented for Directories. Response body: '.$this->response->getBodyAsString());
   32     }
   33 
   34     public function testMountResponse()
   35     {
   36         $serverVars = [
   37             'REQUEST_URI' => '/?mount',
   38             'REQUEST_METHOD' => 'GET',
   39             'QUERY_STRING' => 'mount',
   40             'HTTP_HOST' => 'example.org',
   41         ];
   42 
   43         $request = HTTP\Sapi::createFromServerArray($serverVars);
   44         $this->server->httpRequest = ($request);
   45         $this->server->exec();
   46 
   47         $this->assertEquals(200, $this->response->status);
   48 
   49         $xml = simplexml_load_string($this->response->getBodyAsString());
   50         $this->assertInstanceOf('SimpleXMLElement', $xml, 'Response was not a valid xml document. The list of errors:'.print_r(libxml_get_errors(), true).'. xml body: '.$this->response->getBodyAsString().'. What type we got: '.gettype($xml).' class, if object: '.get_class($xml));
   51 
   52         $xml->registerXPathNamespace('dm', 'http://purl.org/NET/webdav/mount');
   53         $url = $xml->xpath('//dm:url');
   54         $this->assertEquals('http://example.org/', (string) $url[0]);
   55     }
   56 }