"Fossies" - the Fresh Open Source Software Archive

Member "dav-4.0.3/tests/Sabre/DAV/ServerPluginTest.php" (10 Jan 2020, 2629 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 "ServerPluginTest.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 require_once 'Sabre/DAV/AbstractServer.php';
   10 require_once 'Sabre/DAV/TestPlugin.php';
   11 
   12 class ServerPluginTest extends AbstractServer
   13 {
   14     /**
   15      * @var Sabre\DAV\TestPlugin
   16      */
   17     protected $testPlugin;
   18 
   19     public function setUp()
   20     {
   21         parent::setUp();
   22 
   23         $testPlugin = new TestPlugin();
   24         $this->server->addPlugin($testPlugin);
   25         $this->testPlugin = $testPlugin;
   26     }
   27 
   28     public function testBaseClass()
   29     {
   30         $p = new ServerPluginMock();
   31         $this->assertEquals([], $p->getFeatures());
   32         $this->assertEquals([], $p->getHTTPMethods(''));
   33         $this->assertEquals(
   34             [
   35                 'name' => 'Sabre\DAV\ServerPluginMock',
   36                 'description' => null,
   37                 'link' => null,
   38             ], $p->getPluginInfo()
   39         );
   40     }
   41 
   42     public function testOptions()
   43     {
   44         $serverVars = [
   45             'REQUEST_URI' => '/',
   46             'REQUEST_METHOD' => 'OPTIONS',
   47         ];
   48 
   49         $request = HTTP\Sapi::createFromServerArray($serverVars);
   50         $this->server->httpRequest = ($request);
   51         $this->server->exec();
   52 
   53         $this->assertEquals([
   54             'DAV' => ['1, 3, extended-mkcol, drinking'],
   55             'MS-Author-Via' => ['DAV'],
   56             'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, BEER, WINE'],
   57             'Accept-Ranges' => ['bytes'],
   58             'Content-Length' => ['0'],
   59             'X-Sabre-Version' => [Version::VERSION],
   60         ], $this->response->getHeaders());
   61 
   62         $this->assertEquals(200, $this->response->status);
   63         $this->assertEquals('', $this->response->getBodyAsString());
   64         $this->assertEquals('OPTIONS', $this->testPlugin->beforeMethod);
   65     }
   66 
   67     public function testGetPlugin()
   68     {
   69         $this->assertEquals($this->testPlugin, $this->server->getPlugin(get_class($this->testPlugin)));
   70     }
   71 
   72     public function testUnknownPlugin()
   73     {
   74         $this->assertNull($this->server->getPlugin('SomeRandomClassName'));
   75     }
   76 
   77     public function testGetSupportedReportSet()
   78     {
   79         $this->assertEquals([], $this->testPlugin->getSupportedReportSet('/'));
   80     }
   81 
   82     public function testGetPlugins()
   83     {
   84         $this->assertEquals(
   85             [
   86                 get_class($this->testPlugin) => $this->testPlugin,
   87                 'core' => $this->server->getPlugin('core'),
   88             ],
   89             $this->server->getPlugins()
   90         );
   91     }
   92 }
   93 
   94 class ServerPluginMock extends ServerPlugin
   95 {
   96     public function initialize(Server $s)
   97     {
   98     }
   99 }