[Pkg-owncloud-commits] [php-sabredav] 26/275: Fixed all unittests.
David Prévot
taffit at moszumanska.debian.org
Thu Sep 25 14:55:47 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit cb8cca835cee100278471058fd9d0079d181181d
Author: Evert Pot <evert at rooftopsolutions.nl>
Date: Tue Sep 24 13:11:22 2013 +0200
Fixed all unittests.
---
tests/Sabre/CalDAV/Backend/MockScheduling.php | 69 ++++++++++++++++++++++
.../Sabre/CalDAV/Schedule/FreeBusyRequestTest.php | 2 +-
.../CalDAV/UserCalendarsSharedCalendarsTest.php | 6 +-
.../CalDAV/UserCalendarsSubscriptionsTest.php | 4 +-
tests/Sabre/DAVServerTest.php | 6 +-
tests/bootstrap.php | 1 +
6 files changed, 79 insertions(+), 9 deletions(-)
diff --git a/tests/Sabre/CalDAV/Backend/MockScheduling.php b/tests/Sabre/CalDAV/Backend/MockScheduling.php
new file mode 100644
index 0000000..8b6c588
--- /dev/null
+++ b/tests/Sabre/CalDAV/Backend/MockScheduling.php
@@ -0,0 +1,69 @@
+<?php
+
+namespace Sabre\CalDAV\Backend;
+use Sabre\DAV;
+use Sabre\CalDAV;
+
+class MockScheduling extends Mock implements SchedulingSupport {
+
+ public $schedulingObjects = [];
+
+ /**
+ * Returns a single scheduling object.
+ *
+ * The returned array should contain the following elements:
+ * * uri - A unique basename for the object. This will be used to
+ * construct a full uri.
+ * * calendardata - The iCalendar object
+ * * lastmodified - The last modification date. Can be an int for a unix
+ * timestamp, or a PHP DateTime object.
+ * * etag - A unique token that must change if the object changed.
+ * * size - The size of the object, in bytes.
+ *
+ * @param string $principalUri
+ * @param string $objectUri
+ * @return array
+ */
+ public function getSchedulingObject($principalUri, $objectUri) {
+
+ if (isset($this->schedulingObjects[$principalUri][$objectUri])) {
+ return $this->schedulingObjects[$principalUri][$objectUri];
+ }
+
+ }
+
+ /**
+ * Returns all scheduling objects for the inbox collection.
+ *
+ * These objects should be returned as an array. Every item in the array
+ * should follow the same structure as returned from getSchedulingObject.
+ *
+ * The main difference is that 'calendardata' is optional.
+ *
+ * @param string $principalUri
+ * @return array
+ */
+ public function getSchedulingObjects($principalUri) {
+
+ if (isset($this->schedulingObjects[$principalUri])) {
+ return array_values($this->schedulingObjects[$principalUri]);
+ }
+
+ }
+
+ /**
+ * Deletes a scheduling object
+ *
+ * @param string $principalUri
+ * @param string $objectUri
+ * @return void
+ */
+ public function deleteSchedulingObject($principalUri, $objectUri) {
+
+ if (isset($this->schedulingObjects[$principalUri][$objectUri])) {
+ unset($this->schedulingObjects[$principalUri][$objectUri]);
+ }
+
+ }
+
+}
diff --git a/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php b/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
index 162705d..bce89b8 100644
--- a/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
+++ b/tests/Sabre/CalDAV/Schedule/FreeBusyRequestTest.php
@@ -40,7 +40,7 @@ END:VCALENDAR',
);
$principalBackend = new DAVACL\PrincipalBackend\Mock();
- $caldavBackend = new CalDAV\Backend\Mock($calendars, $calendarobjects);
+ $caldavBackend = new CalDAV\Backend\MockScheduling($calendars, $calendarobjects);
$tree = array(
new DAVACL\PrincipalCollection($principalBackend),
diff --git a/tests/Sabre/CalDAV/UserCalendarsSharedCalendarsTest.php b/tests/Sabre/CalDAV/UserCalendarsSharedCalendarsTest.php
index 7e76ad2..284c018 100644
--- a/tests/Sabre/CalDAV/UserCalendarsSharedCalendarsTest.php
+++ b/tests/Sabre/CalDAV/UserCalendarsSharedCalendarsTest.php
@@ -52,7 +52,7 @@ class UserCalendarsSharedCalendarsTest extends \PHPUnit_Framework_TestCase {
$instance = $this->getInstance();
$children = $instance->getChildren();
- $this->assertEquals(5, count($children));
+ $this->assertEquals(3, count($children));
// Testing if we got all the objects back.
$hasShareable = false;
@@ -68,9 +68,6 @@ class UserCalendarsSharedCalendarsTest extends \PHPUnit_Framework_TestCase {
if ($child instanceof ISharedCalendar) {
$hasShared = true;
}
- if ($child instanceof Schedule\IOutbox) {
- $hasOutbox = true;
- }
if ($child instanceof Notifications\ICollection) {
$hasNotifications = true;
}
@@ -78,7 +75,6 @@ class UserCalendarsSharedCalendarsTest extends \PHPUnit_Framework_TestCase {
}
if (!$hasShareable) $this->fail('Missing node!');
if (!$hasShared) $this->fail('Missing node!');
- if (!$hasOutbox) $this->fail('Missing node!');
if (!$hasNotifications) $this->fail('Missing node!');
}
diff --git a/tests/Sabre/CalDAV/UserCalendarsSubscriptionsTest.php b/tests/Sabre/CalDAV/UserCalendarsSubscriptionsTest.php
index 6ccd5de..a1eea2e 100644
--- a/tests/Sabre/CalDAV/UserCalendarsSubscriptionsTest.php
+++ b/tests/Sabre/CalDAV/UserCalendarsSubscriptionsTest.php
@@ -35,7 +35,7 @@ class UserCalendarsSubscriptionsTest extends \PHPUnit_Framework_TestCase {
$instance = $this->getInstance();
$children = $instance->getChildren();
- $this->assertEquals(4, count($children));
+ $this->assertEquals(2, count($children));
foreach($children as $child) {
if ($child instanceof Subscriptions\Subscription) {
return;
@@ -57,7 +57,7 @@ class UserCalendarsSubscriptionsTest extends \PHPUnit_Framework_TestCase {
$instance->createExtendedCollection('sub2', $rt, $props);
$children = $instance->getChildren();
- $this->assertEquals(5, count($children));
+ $this->assertEquals(3, count($children));
}
diff --git a/tests/Sabre/DAVServerTest.php b/tests/Sabre/DAVServerTest.php
index ae61a74..76b83ca 100644
--- a/tests/Sabre/DAVServerTest.php
+++ b/tests/Sabre/DAVServerTest.php
@@ -177,7 +177,11 @@ abstract class DAVServerTest extends \PHPUnit_Framework_TestCase {
function setUpBackends() {
if ($this->setupCalDAV && is_null($this->caldavBackend)) {
- $this->caldavBackend = new CalDAV\Backend\Mock($this->caldavCalendars, $this->caldavCalendarObjects);
+ if ($this->setupCalDAVScheduling) {
+ $this->caldavBackend = new CalDAV\Backend\MockScheduling($this->caldavCalendars, $this->caldavCalendarObjects);
+ } else {
+ $this->caldavBackend = new CalDAV\Backend\Mock($this->caldavCalendars, $this->caldavCalendarObjects);
+ }
}
if ($this->setupCardDAV && is_null($this->carddavBackend)) {
$this->carddavBackend = new CardDAV\Backend\Mock($this->carddavAddressBooks, $this->carddavCards);
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 919628c..c5439d3 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -9,6 +9,7 @@ include 'Sabre/CardDAV/Backend/AbstractPDOTest.php';
include 'Sabre/CardDAV/TestUtil.php';
include 'Sabre/DAV/ClientMock.php';
include 'Sabre/CalDAV/Schedule/IMip/Mock.php';
+include 'Sabre/CalDAV/Backend/MockScheduling.php';
date_default_timezone_set('GMT');
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list