aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2021-03-12 11:20:04 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-05-31 07:49:19 +0200
commitd6d8e9215c69a9e8d4bfa2035c657b0a037f3a2f (patch)
tree942254503672d6ab3e0b6c8fca0bd4053db352b9 /apps/dav/tests
parent9e596dd0cf455dc1639141c695f89c7d936f4c0c (diff)
downloadnextcloud-server-d6d8e9215c69a9e8d4bfa2035c657b0a037f3a2f.tar.gz
nextcloud-server-d6d8e9215c69a9e8d4bfa2035c657b0a037f3a2f.zip
Add a trashbin for calendars and calendar objects
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/tests')
-rw-r--r--apps/dav/tests/travis/caldav/install.sh6
-rw-r--r--apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php15
-rw-r--r--apps/dav/tests/unit/CalDAV/CalDavBackendTest.php4
-rw-r--r--apps/dav/tests/unit/CalDAV/CalendarHomeTest.php12
-rw-r--r--apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php6
5 files changed, 31 insertions, 12 deletions
diff --git a/apps/dav/tests/travis/caldav/install.sh b/apps/dav/tests/travis/caldav/install.sh
index e0ac30c9e46..d6064fb7a38 100644
--- a/apps/dav/tests/travis/caldav/install.sh
+++ b/apps/dav/tests/travis/caldav/install.sh
@@ -11,8 +11,12 @@ if [ ! -f pycalendar/setup.py ]; then
git clone https://github.com/apple/ccs-pycalendar.git pycalendar
fi
-# create test user
cd "$SCRIPTPATH/../../../../../"
+
+# disable the trashbin, so recurrent deletion of the same object works
+php occ config:app:set dav calendarRetentionObligation --value=0
+
+# create test user
OC_PASS=user01 php occ user:add --password-from-env user01
php occ dav:create-calendar user01 calendar
php occ dav:create-calendar user01 shared
diff --git a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php
index 1264342e27c..eb0530a8b3d 100644
--- a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php
+++ b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php
@@ -113,7 +113,18 @@ abstract class AbstractCalDavBackend extends TestCase {
$db = \OC::$server->getDatabaseConnection();
$this->random = \OC::$server->getSecureRandom();
$this->logger = $this->createMock(ILogger::class);
- $this->backend = new CalDavBackend($db, $this->principal, $this->userManager, $this->groupManager, $this->random, $this->logger, $this->dispatcher, $this->legacyDispatcher);
+ $this->config = $this->createMock(IConfig::class);
+ $this->backend = new CalDavBackend(
+ $db,
+ $this->principal,
+ $this->userManager,
+ $this->groupManager,
+ $this->random,
+ $this->logger,
+ $this->dispatcher,
+ $this->legacyDispatcher,
+ $this->config
+ );
$this->cleanUpBackend();
}
@@ -142,7 +153,7 @@ abstract class AbstractCalDavBackend extends TestCase {
return $event instanceof CalendarDeletedEvent;
}));
foreach ($calendars as $calendar) {
- $this->backend->deleteCalendar($calendar['id']);
+ $this->backend->deleteCalendar($calendar['id'], true);
}
$subscriptions = $this->backend->getSubscriptionsForUser($principal);
foreach ($subscriptions as $subscription) {
diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
index 2ac333b1526..03abd554e2b 100644
--- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
+++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php
@@ -83,7 +83,7 @@ class CalDavBackendTest extends AbstractCalDavBackend {
->with(self::callback(function ($event) {
return $event instanceof CalendarDeletedEvent;
}));
- $this->backend->deleteCalendar($calendars[0]['id']);
+ $this->backend->deleteCalendar($calendars[0]['id'], true);
$calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
self::assertEmpty($calendars);
}
@@ -212,7 +212,7 @@ EOD;
->with(self::callback(function ($event) {
return $event instanceof CalendarDeletedEvent;
}));
- $this->backend->deleteCalendar($calendars[0]['id']);
+ $this->backend->deleteCalendar($calendars[0]['id'], true);
$calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
self::assertEmpty($calendars);
}
diff --git a/apps/dav/tests/unit/CalDAV/CalendarHomeTest.php b/apps/dav/tests/unit/CalDAV/CalendarHomeTest.php
index a1df2d6254f..c9ef312df03 100644
--- a/apps/dav/tests/unit/CalDAV/CalendarHomeTest.php
+++ b/apps/dav/tests/unit/CalDAV/CalendarHomeTest.php
@@ -32,6 +32,7 @@ use OCA\DAV\CalDAV\CalendarHome;
use OCA\DAV\CalDAV\Integration\ExternalCalendar;
use OCA\DAV\CalDAV\Integration\ICalendarProvider;
use OCA\DAV\CalDAV\Outbox;
+use OCA\DAV\CalDAV\Trashbin\TrashbinHome;
use Sabre\CalDAV\Schedule\Inbox;
use Sabre\DAV\MkCol;
use Test\TestCase;
@@ -141,13 +142,14 @@ class CalendarHomeTest extends TestCase {
$actual = $this->calendarHome->getChildren();
- $this->assertCount(6, $actual);
+ $this->assertCount(7, $actual);
$this->assertInstanceOf(Inbox::class, $actual[0]);
$this->assertInstanceOf(Outbox::class, $actual[1]);
- $this->assertEquals('plugin1calendar1', $actual[2]);
- $this->assertEquals('plugin1calendar2', $actual[3]);
- $this->assertEquals('plugin2calendar1', $actual[4]);
- $this->assertEquals('plugin2calendar2', $actual[5]);
+ $this->assertInstanceOf(TrashbinHome::class, $actual[2]);
+ $this->assertEquals('plugin1calendar1', $actual[3]);
+ $this->assertEquals('plugin1calendar2', $actual[4]);
+ $this->assertEquals('plugin2calendar1', $actual[5]);
+ $this->assertEquals('plugin2calendar2', $actual[6]);
}
public function testGetChildNonAppGenerated():void {
diff --git a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
index 5200d201f50..94e224e5952 100644
--- a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
+++ b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php
@@ -86,6 +86,7 @@ class PublicCalendarRootTest extends TestCase {
$this->logger = $this->createMock(ILogger::class);
$dispatcher = $this->createMock(IEventDispatcher::class);
$legacyDispatcher = $this->createMock(EventDispatcherInterface::class);
+ $config = $this->createMock(IConfig::class);
$this->principal->expects($this->any())->method('getGroupMembership')
->withAnyParameters()
@@ -103,7 +104,8 @@ class PublicCalendarRootTest extends TestCase {
$this->random,
$this->logger,
$dispatcher,
- $legacyDispatcher
+ $legacyDispatcher,
+ $config
);
$this->l10n = $this->getMockBuilder(IL10N::class)
->disableOriginalConstructor()->getMock();
@@ -129,7 +131,7 @@ class PublicCalendarRootTest extends TestCase {
$books = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER);
foreach ($books as $book) {
- $this->backend->deleteCalendar($book['id']);
+ $this->backend->deleteCalendar($book['id'], true);
}
}