Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-09-12 18:09:46 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2016-10-19 12:06:29 +0300
commit361f008c705009eee8d7435f46095760ac706456 (patch)
tree95e7033befa4ff0fc20e60f5df2a4b249575d636 /apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
parent5e48ce98c70fa511ea2c1caeb332594912c9d96a (diff)
Make it possible to filter by tags with REPORT method
Enhanced the REPORT method on the Webdav endpoint and added a "oc:favorite" filter rule. When set, it will return a flat list of results filtered with only favorite files. The web UI was also adjusted to use this REPORT method instead of the private API endpoint. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php')
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php39
1 files changed, 29 insertions, 10 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
index 336a33058bf..2097777c8fd 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
@@ -26,12 +26,15 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre;
use OCA\DAV\Connector\Sabre\FilesReportPlugin as FilesReportPluginImplementation;
use OCP\IPreview;
+use OCP\ITagManager;
+use OCP\IUserSession;
use Sabre\DAV\Exception\NotFound;
use OCP\SystemTag\ISystemTagObjectMapper;
use OC\Files\View;
use OCP\Files\Folder;
use OCP\IGroupManager;
use OCP\SystemTag\ISystemTagManager;
+use OCP\ITags;
class FilesReportPluginTest extends \Test\TestCase {
/** @var \Sabre\DAV\Server|\PHPUnit_Framework_MockObject_MockObject */
@@ -46,6 +49,9 @@ class FilesReportPluginTest extends \Test\TestCase {
/** @var ISystemTagManager|\PHPUnit_Framework_MockObject_MockObject */
private $tagManager;
+ /** @var ITags|\PHPUnit_Framework_MockObject_MockObject */
+ private $privateTags;
+
/** @var \OCP\IUserSession */
private $userSession;
@@ -87,20 +93,20 @@ class FilesReportPluginTest extends \Test\TestCase {
->disableOriginalConstructor()
->getMock();
- $this->tagManager = $this->getMockBuilder('\OCP\SystemTag\ISystemTagManager')
- ->disableOriginalConstructor()
- ->getMock();
- $this->tagMapper = $this->getMockBuilder('\OCP\SystemTag\ISystemTagObjectMapper')
- ->disableOriginalConstructor()
- ->getMock();
- $this->userSession = $this->getMockBuilder('\OCP\IUserSession')
- ->disableOriginalConstructor()
- ->getMock();
-
$this->previewManager = $this->getMockBuilder('\OCP\IPreview')
->disableOriginalConstructor()
->getMock();
+ $this->tagManager = $this->createMock(ISystemTagManager::class);
+ $this->tagMapper = $this->createMock(ISystemTagObjectMapper::class);
+ $this->userSession = $this->createMock(IUserSession::class);
+ $this->privateTags = $this->createMock(ITags::class);
+ $privateTagManager = $this->createMock(ITagManager::class);
+ $privateTagManager->expects($this->any())
+ ->method('load')
+ ->with('files')
+ ->will($this->returnValue($this->privateTags));
+
$user = $this->getMockBuilder('\OCP\IUser')
->disableOriginalConstructor()
->getMock();
@@ -116,6 +122,7 @@ class FilesReportPluginTest extends \Test\TestCase {
$this->view,
$this->tagManager,
$this->tagMapper,
+ $privateTagManager,
$this->userSession,
$this->groupManager,
$this->userFolder
@@ -652,4 +659,16 @@ class FilesReportPluginTest extends \Test\TestCase {
$this->assertEquals(['222'], array_values($this->invokePrivate($this->plugin, 'processFilterRules', [$rules])));
}
+
+ public function testProcessFavoriteFilter() {
+ $rules = [
+ ['name' => '{http://owncloud.org/ns}favorite', 'value' => '1'],
+ ];
+
+ $this->privateTags->expects($this->once())
+ ->method('getFavorites')
+ ->will($this->returnValue(['456', '789']));
+
+ $this->assertEquals(['456', '789'], array_values($this->invokePrivate($this->plugin, 'processFilterRules', [$rules])));
+ }
}