]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix usage of Sabre\HTTP\Request in unit tests
authorGeorg Ehrke <developer@georgehrke.com>
Tue, 10 Mar 2020 12:43:18 +0000 (13:43 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Fri, 27 Mar 2020 11:53:44 +0000 (12:53 +0100)
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php
apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php
apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php
apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
apps/dav/tests/unit/DAV/Sharing/PluginTest.php

index cf62b6eb05dbe42ff831314fcc16dc2ee563cc39..f7972d37d437a351dc2dfc98622d37f3ea60536e 100644 (file)
@@ -82,9 +82,8 @@ class PluginTest extends TestCase {
                $this->book->expects($this->once())->method('setPublishStatus')->with(true);
 
                // setup request
-               $request = new Request();
+               $request = new Request('POST', 'cal1');
                $request->addHeader('Content-Type', 'application/xml');
-               $request->setUrl('cal1');
                $request->setBody('<o:publish-calendar xmlns:o="http://calendarserver.org/ns/"/>');
                $response = new Response();
                $this->plugin->httpPost($request, $response);
@@ -95,9 +94,8 @@ class PluginTest extends TestCase {
                $this->book->expects($this->once())->method('setPublishStatus')->with(false);
 
                // setup request
-               $request = new Request();
+               $request = new Request('POST', 'cal1');
                $request->addHeader('Content-Type', 'application/xml');
-               $request->setUrl('cal1');
                $request->setBody('<o:unpublish-calendar xmlns:o="http://calendarserver.org/ns/"/>');
                $response = new Response();
                $this->plugin->httpPost($request, $response);
index 742f231287e7b3e6bb3a5ef1ebaa362b1587ec33..b8cdb70b7f9882b1f539d639f815c8f438d1cceb 100644 (file)
@@ -47,7 +47,7 @@ class PluginTest extends TestCase {
 
        protected function setUp(): void {
                parent::setUp();
-               
+
                /** @var Auth | \PHPUnit_Framework_MockObject_MockObject $authBackend */
                $authBackend = $this->getMockBuilder(Auth::class)->disableOriginalConstructor()->getMock();
                $authBackend->method('isDavAuthenticated')->willReturn(true);
@@ -75,9 +75,8 @@ class PluginTest extends TestCase {
                ]], ['mailto:wilfredo@example.com']);
 
                // setup request
-               $request = new Request();
+               $request = new Request('POST', 'addressbook1.vcf');
                $request->addHeader('Content-Type', 'application/xml');
-               $request->setUrl('addressbook1.vcf');
                $request->setBody('<?xml version="1.0" encoding="utf-8" ?><CS:share xmlns:D="DAV:" xmlns:CS="http://owncloud.org/ns"><CS:set><D:href>principal:principals/admin</D:href><CS:read-write/></CS:set> <CS:remove><D:href>mailto:wilfredo@example.com</D:href></CS:remove></CS:share>');
                $response = new Response();
                $this->plugin->httpPost($request, $response);
index f2012a87a3dc9fbbc81a30c64a63a4c98034b9fe..29b549f3b4a0bc33ed74a24ec9c016dc9cf62eae 100644 (file)
@@ -54,7 +54,7 @@ class CopyEtagHeaderPluginTest extends TestCase {
        }
 
        public function testCopyEtag() {
-               $request = new \Sabre\Http\Request();
+               $request = new \Sabre\Http\Request('GET', 'dummy.file');
                $response = new \Sabre\Http\Response();
                $response->setHeader('Etag', 'abcd');
 
@@ -64,7 +64,7 @@ class CopyEtagHeaderPluginTest extends TestCase {
        }
 
        public function testNoopWhenEmpty() {
-               $request = new \Sabre\Http\Request();
+               $request = new \Sabre\Http\Request('GET', 'dummy.file');
                $response = new \Sabre\Http\Response();
 
                $this->plugin->afterMethod($request, $response);
index d7554741fc07628c3c547fe41911c867d5cc6828..f604ee8a68520ff808c1e282d6232742f5469c39 100644 (file)
@@ -66,7 +66,7 @@ class QuotaPluginTest extends TestCase {
                $this->init(0);
                $this->plugin->expects($this->never())
                        ->method('getFileChunking');
-               $this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers);
+               $this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers);
                $length = $this->plugin->getLength();
                $this->assertEquals($expected, $length);
        }
@@ -79,7 +79,7 @@ class QuotaPluginTest extends TestCase {
                $this->plugin->expects($this->never())
                        ->method('getFileChunking');
 
-               $this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers);
+               $this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers);
                $result = $this->plugin->checkQuota('');
                $this->assertTrue($result);
        }
@@ -94,7 +94,7 @@ class QuotaPluginTest extends TestCase {
                $this->plugin->expects($this->never())
                        ->method('getFileChunking');
 
-               $this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers);
+               $this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers);
                $this->plugin->checkQuota('');
        }
 
@@ -106,7 +106,7 @@ class QuotaPluginTest extends TestCase {
                $this->plugin->expects($this->never())
                        ->method('getFileChunking');
 
-               $this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers);
+               $this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers);
                $result = $this->plugin->checkQuota('/sub/test.txt');
                $this->assertTrue($result);
        }
@@ -191,7 +191,7 @@ class QuotaPluginTest extends TestCase {
                        ->willReturn($mockChunking);
 
                $headers['OC-CHUNKED'] = 1;
-               $this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers);
+               $this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers);
                $result = $this->plugin->checkQuota('/sub/test.txt-chunking-12345-3-1');
                $this->assertTrue($result);
        }
@@ -228,7 +228,7 @@ class QuotaPluginTest extends TestCase {
                        ->willReturn($mockChunking);
 
                $headers['OC-CHUNKED'] = 1;
-               $this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers);
+               $this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers);
                $this->plugin->checkQuota('/sub/test.txt-chunking-12345-3-1');
        }
 
index 9eeaccc29d74cadf58e930d7124d7da14847bcf2..9776d17642c8e54491f7e5c7eae5d07ecd0972b5 100644 (file)
@@ -47,7 +47,7 @@ class PluginTest extends TestCase {
 
        protected function setUp(): void {
                parent::setUp();
-               
+
                /** @var Auth | \PHPUnit_Framework_MockObject_MockObject $authBackend */
                $authBackend = $this->getMockBuilder(Auth::class)->disableOriginalConstructor()->getMock();
                $authBackend->method('isDavAuthenticated')->willReturn(true);
@@ -77,9 +77,8 @@ class PluginTest extends TestCase {
                ]], ['mailto:wilfredo@example.com']);
 
                // setup request
-               $request = new Request();
+               $request = new Request('POST', 'addressbook1.vcf');
                $request->addHeader('Content-Type', 'application/xml');
-               $request->setUrl('addressbook1.vcf');
                $request->setBody('<?xml version="1.0" encoding="utf-8" ?><CS:share xmlns:D="DAV:" xmlns:CS="http://owncloud.org/ns"><CS:set><D:href>principal:principals/admin</D:href><CS:read-write/></CS:set> <CS:remove><D:href>mailto:wilfredo@example.com</D:href></CS:remove></CS:share>');
                $response = new Response();
                $this->plugin->httpPost($request, $response);