diff options
Diffstat (limited to 'apps/dav/tests')
9 files changed, 32 insertions, 29 deletions
diff --git a/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php b/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php index cf62b6eb05d..f7972d37d43 100644 --- a/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php +++ b/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php @@ -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); diff --git a/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php b/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php index e38bd1810a8..0bb4a8c4a34 100644 --- a/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php +++ b/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php @@ -91,6 +91,7 @@ class BirthdayServiceTest extends TestCase { $this->assertNull($cal); } else { $this->assertInstanceOf('Sabre\VObject\Component\VCalendar', $cal); + $this->assertEquals('-//IDN nextcloud.com//Birthday calendar//EN', $cal->PRODID->getValue()); $this->assertTrue(isset($cal->VEVENT)); $this->assertEquals('FREQ=YEARLY', $cal->VEVENT->RRULE->getValue()); $this->assertEquals($expectedSummary, $cal->VEVENT->SUMMARY->getValue()); @@ -259,21 +260,27 @@ class BirthdayServiceTest extends TestCase { ); } if ($expectedOp === 'create') { - $service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn(new VCalendar()); + $vCal = new VCalendar(); + $vCal->PRODID = '-//Nextcloud testing//mocked object//'; + + $service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn($vCal); $this->calDav->expects($this->exactly(3))->method('createCalendarObject')->withConsecutive( - [1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"], - [1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"], - [1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"] + [1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"], + [1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"], + [1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"] ); } if ($expectedOp === 'update') { - $service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn(new VCalendar()); + $vCal = new VCalendar(); + $vCal->PRODID = '-//Nextcloud testing//mocked object//'; + + $service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn($vCal); $service->expects($this->exactly(3))->method('birthdayEvenChanged')->willReturn(true); $this->calDav->expects($this->exactly(3))->method('getCalendarObject')->willReturn(['calendardata' => '']); $this->calDav->expects($this->exactly(3))->method('updateCalendarObject')->withConsecutive( - [1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"], - [1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"], - [1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"] + [1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"], + [1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"], + [1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"] ); } diff --git a/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php b/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php index 742f231287e..b8cdb70b7f9 100644 --- a/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php +++ b/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php @@ -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); diff --git a/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php index f2012a87a3d..29b549f3b4a 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php @@ -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); diff --git a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php index 473c0164d06..d24b4dfe962 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php @@ -172,7 +172,7 @@ class FakeLockerPluginTest extends TestCase { $this->assertSame(false, $this->fakeLockerPlugin->fakeLockProvider($request, $response)); - $expectedXml = '<?xml version="1.0" encoding="utf-8"?><d:prop xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"><d:lockdiscovery><d:activelock><d:lockscope><d:exclusive/></d:lockscope><d:locktype><d:write/></d:locktype><d:lockroot><d:href>MyPath</d:href></d:lockroot><d:depth>infinity</d:depth><d:timeout>Second-1800</d:timeout><d:locktoken><d:href>opaquelocktoken:fe4f7f2437b151fbcb4e9f5c8118c6b1</d:href></d:locktoken><d:owner/></d:activelock></d:lockdiscovery></d:prop>'; + $expectedXml = '<?xml version="1.0" encoding="utf-8"?><d:prop xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"><d:lockdiscovery><d:activelock><d:lockscope><d:exclusive/></d:lockscope><d:locktype><d:write/></d:locktype><d:lockroot><d:href>MyPath</d:href></d:lockroot><d:depth>infinity</d:depth><d:timeout>Second-1800</d:timeout><d:locktoken><d:href>opaquelocktoken:fe4f7f2437b151fbcb4e9f5c8118c6b1</d:href></d:locktoken></d:activelock></d:lockdiscovery></d:prop>'; $this->assertXmlStringEqualsXmlString($expectedXml, $response->getBody()); } diff --git a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php index 3af82f31f50..5ff1316752e 100644 --- a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php @@ -62,7 +62,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); } @@ -75,7 +75,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); } @@ -90,7 +90,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(''); } @@ -102,7 +102,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); } @@ -187,7 +187,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); } @@ -224,7 +224,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'); } diff --git a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php index 771d73dec5f..3624a9cc30e 100644 --- a/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php +++ b/apps/dav/tests/unit/Connector/Sabre/RequestTest/RequestTestCase.php @@ -92,7 +92,7 @@ abstract class RequestTestCase extends TestCase { * @return \Sabre\HTTP\Response * @throws \Exception */ - protected function request($view, $user, $password, $method, $url, $body = null, $headers = null) { + protected function request($view, $user, $password, $method, $url, $body = null, $headers = []) { if (is_string($body)) { $body = $this->getStream($body); } diff --git a/apps/dav/tests/unit/DAV/Sharing/PluginTest.php b/apps/dav/tests/unit/DAV/Sharing/PluginTest.php index 9eeaccc29d7..9776d17642c 100644 --- a/apps/dav/tests/unit/DAV/Sharing/PluginTest.php +++ b/apps/dav/tests/unit/DAV/Sharing/PluginTest.php @@ -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); diff --git a/apps/dav/tests/unit/Files/Sharing/FilesDropPluginTest.php b/apps/dav/tests/unit/Files/Sharing/FilesDropPluginTest.php index 77646b2c9d1..82a4515c7e3 100644 --- a/apps/dav/tests/unit/Files/Sharing/FilesDropPluginTest.php +++ b/apps/dav/tests/unit/Files/Sharing/FilesDropPluginTest.php @@ -66,7 +66,7 @@ class FilesDropPluginTest extends TestCase { $this->server->expects($this->once()) ->method('on') ->with( - $this->equalTo('beforeMethod'), + $this->equalTo('beforeMethod:*'), $this->equalTo([$this->plugin, 'beforeMethod']), $this->equalTo(999) ); |