From f0421e1f75179a42e76973a4b11d8474ee571d08 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sun, 14 Aug 2016 19:08:01 +0200 Subject: add missing tests --- apps/dav/tests/unit/CalDAV/AbstractCalDavBackendTest.php | 6 +++++- apps/dav/tests/unit/CalDAV/CalDavBackendTest.php | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackendTest.php index ebdd4d9f940..ca5000f3f44 100644 --- a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackendTest.php @@ -28,6 +28,7 @@ use OCA\DAV\CalDAV\CalDavBackend; use OCA\DAV\CalDAV\Calendar; use OCA\DAV\Connector\Sabre\Principal; use OCP\IL10N; +use OCP\IConfig; use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet; use Sabre\DAV\PropPatch; use Sabre\DAV\Xml\Property\Href; @@ -51,6 +52,9 @@ abstract class AbstractCalDavBackendTest extends TestCase { /** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject */ protected $userManager; + + /** var OCP\IConfig */ + protected $config; const UNIT_TEST_USER = 'principals/users/caldav-unit-test'; const UNIT_TEST_USER1 = 'principals/users/caldav-unit-test1'; @@ -75,7 +79,7 @@ abstract class AbstractCalDavBackendTest extends TestCase { ->willReturn([self::UNIT_TEST_GROUP]); $db = \OC::$server->getDatabaseConnection(); - $config = \OC::$server->getConfig(); + $this->config = \OC::$server->getConfig(); $this->backend = new CalDavBackend($db, $this->principal, $this->userManager, $config); $this->tearDown(); diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index a597b476336..0c07ed7c292 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -343,13 +343,24 @@ EOD; ->disableOriginalConstructor()->getMock(); $calendar = new Calendar($this->backend, $calendarInfo, $l10n); - $this->backend->setPublishStatus(true, $calendar); - $this->assertEquals(true, $this->backend->getPublishStatus($calendar)); + $calendar->setPublishStatus(true); + $this->assertEquals(true, $calendar->getPublishStatus()); $publicCalendars = $this->backend->getPublicCalendars(); $this->assertEquals(1, count($publicCalendars)); $this->assertEquals(true, $publicCalendars[0]['{http://owncloud.org/ns}public']); + $publicCalendarURI = md5($this->config->getSystemValue('secret', '') . $calendar->getResourceId()); + $publicCalendar = $this->backend->getPublicCalendar($publicCalendarURI); + $this->assertEquals(true, $publicCalendar['{http://owncloud.org/ns}public']); + + $calendar->setPublishStatus(false); + $this->assertEquals(false, $calendar->getPublishStatus()); + + $publicCalendarURI = md5($this->config->getSystemValue('secret', '') . $calendar->getResourceId()); + $this->setExpectedException('Sabre\DAV\Exception\NotFound'); + $publicCalendar = $this->backend->getPublicCalendar($publicCalendarURI); + } public function testSubscriptions() { -- cgit v1.2.3