summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-07-20 14:08:45 +0200
committerLukas Reschke <lukas@statuscode.ch>2016-09-26 11:55:38 +0200
commit77216e7ca97e763ab12d30c471d0a73b44faeeba (patch)
treeaea85e1073c10cfc010ae8fa105ef690990bb86d /apps
parentd0ec6b9c15bcae0226fb46ab99d70897b0b96c4b (diff)
downloadnextcloud-server-77216e7ca97e763ab12d30c471d0a73b44faeeba.tar.gz
nextcloud-server-77216e7ca97e763ab12d30c471d0a73b44faeeba.zip
a few tests
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/tests/unit/CalDAV/CalDavBackendTest.php18
-rw-r--r--apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php71
2 files changed, 89 insertions, 0 deletions
diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
index 1a5673161de..a597b476336 100644
--- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
+++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
@@ -334,6 +334,24 @@ EOD;
$this->assertEquals($event, $changes['added'][0]);
}
+ public function testPublications() {
+ $this->backend->createCalendar(self::UNIT_TEST_USER, 'Example', []);
+
+ $calendarInfo = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER)[0];
+
+ $l10n = $this->getMockBuilder('\OCP\IL10N')
+ ->disableOriginalConstructor()->getMock();
+
+ $calendar = new Calendar($this->backend, $calendarInfo, $l10n);
+ $this->backend->setPublishStatus(true, $calendar);
+ $this->assertEquals(true, $this->backend->getPublishStatus($calendar));
+
+ $publicCalendars = $this->backend->getPublicCalendars();
+ $this->assertEquals(1, count($publicCalendars));
+ $this->assertEquals(true, $publicCalendars[0]['{http://owncloud.org/ns}public']);
+
+ }
+
public function testSubscriptions() {
$id = $this->backend->createSubscription(self::UNIT_TEST_USER, 'Subscription', [
'{http://calendarserver.org/ns/}source' => new Href('test-source'),
diff --git a/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php b/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php
new file mode 100644
index 00000000000..00e4f049307
--- /dev/null
+++ b/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php
@@ -0,0 +1,71 @@
+<?php
+
+namespace OCA\DAV\Tests\unit\CalDAV\Publishing;
+
+use OCA\DAV\CalDAV\Calendar;
+use OCA\DAV\CalDAV\Publishing\PublishPlugin;
+use OCA\DAV\Connector\Sabre\Auth;
+use OCP\IRequest;
+use Sabre\DAV\Server;
+use Sabre\DAV\SimpleCollection;
+use Sabre\HTTP\Request;
+use Sabre\HTTP\Response;
+use Test\TestCase;
+
+class PluginTest extends TestCase {
+
+ /** @var Plugin */
+ private $plugin;
+ /** @var Server */
+ private $server;
+ /** @var Calendar | \PHPUnit_Framework_MockObject_MockObject */
+ private $book;
+
+ public function setUp() {
+ parent::setUp();
+
+ /** @var Auth | \PHPUnit_Framework_MockObject_MockObject $authBackend */
+ $authBackend = $this->getMockBuilder('OCA\DAV\DAV\PublicAuth')->disableOriginalConstructor()->getMock();
+ $authBackend->method('isDavAuthenticated')->willReturn(true);
+
+ /** @var IRequest $request */
+ $request = $this->getMockBuilder('OCP\IRequest')->disableOriginalConstructor()->getMock();
+ $this->plugin = new PublishPlugin($authBackend, $request);
+
+ $root = new SimpleCollection('calendars');
+ $this->server = new Server($root);
+ /** @var SimpleCollection $node */
+ $this->book = $this->getMockBuilder('OCA\DAV\CalDAV\Calendar')->
+ disableOriginalConstructor()->
+ getMock();
+ $this->book->method('getName')->willReturn('cal1');
+ $root->addChild($this->book);
+ $this->plugin->initialize($this->server);
+ }
+
+ public function testPublishing() {
+
+ $this->book->expects($this->once())->method('setPublishStatus')->with(true);
+
+ // setup request
+ $request = new Request();
+ $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);
+ }
+
+ public function testUnPublishing() {
+
+ $this->book->expects($this->once())->method('setPublishStatus')->with(true);
+
+ // setup request
+ $request = new Request();
+ $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);
+ }
+}