summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2017-04-25 16:37:13 +0200
committerGeorg Ehrke <developer@georgehrke.com>2017-04-25 16:39:17 +0200
commitdd424fcb7b26745c6bebc323df282509c28bd563 (patch)
tree8d74d5ed393e5227fbbe774d8656334a88af9e9a /apps/dav/lib
parent40eec1e63c65c3a506ff88bdaf4cf611776ee034 (diff)
downloadnextcloud-server-dd424fcb7b26745c6bebc323df282509c28bd563.tar.gz
nextcloud-server-dd424fcb7b26745c6bebc323df282509c28bd563.zip
unit test CalDAV Search Plugin
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/CalDAV/Search/SearchPlugin.php6
-rw-r--r--apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php14
2 files changed, 10 insertions, 10 deletions
diff --git a/apps/dav/lib/CalDAV/Search/SearchPlugin.php b/apps/dav/lib/CalDAV/Search/SearchPlugin.php
index ad36f39e234..d658a50437d 100644
--- a/apps/dav/lib/CalDAV/Search/SearchPlugin.php
+++ b/apps/dav/lib/CalDAV/Search/SearchPlugin.php
@@ -86,9 +86,9 @@ class SearchPlugin extends ServerPlugin {
* @param mixed $path
* @return bool
*/
- function report($reportName, $report, $path) {
+ public function report($reportName, $report, $path) {
switch ($reportName) {
- case '{' . self::NS_Nextcloud . '}calendar-search' :
+ case '{' . self::NS_Nextcloud . '}calendar-search':
$this->server->transactionType = 'report-nc-calendar-search';
$this->calendarSearch($report);
return false;
@@ -127,7 +127,7 @@ class SearchPlugin extends ServerPlugin {
*/
private function calendarSearch($report) {
$node = $this->server->tree->getNodeForPath($this->server->getRequestUri());
- $depth = $this->server->getHTTPDepth(0);
+ $depth = $this->server->getHTTPDepth(2);
// The default result is an empty array
$result = [];
diff --git a/apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php b/apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php
index cda5d6dcc25..2c92a41e16b 100644
--- a/apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php
+++ b/apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php
@@ -20,7 +20,6 @@
*/
namespace OCA\DAV\CalDAV\Search\Xml\Request;
-use Sabre\CalDAV\Plugin;
use Sabre\DAV\Exception\BadRequest;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
@@ -107,24 +106,21 @@ class CalendarSearchReport implements XmlDeserializable {
switch ($elem['name']) {
case '{DAV:}prop':
$newProps['properties'] = array_keys($elem['value']);
- if (isset($elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data'])) {
- $newProps += $elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data'];
- }
break;
case '{' . SearchPlugin::NS_Nextcloud . '}filter':
foreach ($elem['value'] as $subElem) {
if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
- if (!is_array($newProps['filters']['comps'])) {
+ if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
$newProps['filters']['comps'] = [];
}
$newProps['filters']['comps'][] = $subElem['value'];
} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
- if (!is_array($newProps['filters']['props'])) {
+ if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
$newProps['filters']['props'] = [];
}
$newProps['filters']['props'][] = $subElem['value'];
} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
- if (!is_array($newProps['filters']['params'])) {
+ if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
$newProps['filters']['params'] = [];
}
$newProps['filters']['params'][] = $subElem['value'];
@@ -153,6 +149,10 @@ class CalendarSearchReport implements XmlDeserializable {
throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');
}
+ if (!isset($newProps['filters']['search-term'])) {
+ throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
+ }
+
$obj = new self();
foreach ($newProps as $key => $value) {