aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/Files/FileSearchBackendTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/tests/unit/Files/FileSearchBackendTest.php')
-rw-r--r--apps/dav/tests/unit/Files/FileSearchBackendTest.php76
1 files changed, 27 insertions, 49 deletions
diff --git a/apps/dav/tests/unit/Files/FileSearchBackendTest.php b/apps/dav/tests/unit/Files/FileSearchBackendTest.php
index aaa3d8c147e..ce56dde5fbd 100644
--- a/apps/dav/tests/unit/Files/FileSearchBackendTest.php
+++ b/apps/dav/tests/unit/Files/FileSearchBackendTest.php
@@ -1,10 +1,12 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-namespace OCA\DAV\Tests\Files;
+namespace OCA\DAV\Tests\unit\Files;
use OC\Files\Search\SearchComparison;
use OC\Files\Search\SearchQuery;
@@ -23,42 +25,26 @@ use OCP\Files\Search\ISearchQuery;
use OCP\FilesMetadata\IFilesMetadataManager;
use OCP\IUser;
use OCP\Share\IManager;
+use PHPUnit\Framework\MockObject\MockObject;
use SearchDAV\Backend\SearchPropertyDefinition;
use SearchDAV\Query\Limit;
+use SearchDAV\Query\Literal;
use SearchDAV\Query\Operator;
use SearchDAV\Query\Query;
+use SearchDAV\Query\Scope;
use Test\TestCase;
class FileSearchBackendTest extends TestCase {
- /** @var ObjectTree|\PHPUnit\Framework\MockObject\MockObject */
- private $tree;
-
- /** @var IUser */
- private $user;
-
- /** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject */
- private $rootFolder;
-
- /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
- private $shareManager;
-
- /** @var View|\PHPUnit\Framework\MockObject\MockObject */
- private $view;
-
- /** @var Folder|\PHPUnit\Framework\MockObject\MockObject */
- private $searchFolder;
-
- /** @var FileSearchBackend */
- private $search;
-
- /** @var Directory|\PHPUnit\Framework\MockObject\MockObject */
- private $davFolder;
+ private ObjectTree&MockObject $tree;
+ private IUser&MockObject $user;
+ private IRootFolder&MockObject $rootFolder;
+ private IManager&MockObject $shareManager;
+ private View&MockObject $view;
+ private Folder&MockObject $searchFolder;
+ private Directory&MockObject $davFolder;
+ private FileSearchBackend $search;
protected function setUp(): void {
- if (PHP_VERSION_ID >= 80400) {
- $this->markTestSkipped('SearchDAV is not yet PHP 8.4 compatible');
- }
-
parent::setUp();
$this->user = $this->createMock(IUser::class);
@@ -66,11 +52,13 @@ class FileSearchBackendTest extends TestCase {
->method('getUID')
->willReturn('test');
- $this->tree = $this->getMockBuilder(ObjectTree::class)
- ->disableOriginalConstructor()
- ->getMock();
-
+ $this->tree = $this->createMock(ObjectTree::class);
$this->view = $this->createMock(View::class);
+ $this->rootFolder = $this->createMock(IRootFolder::class);
+ $this->shareManager = $this->createMock(IManager::class);
+ $this->searchFolder = $this->createMock(Folder::class);
+ $fileInfo = $this->createMock(FileInfo::class);
+ $this->davFolder = $this->createMock(Directory::class);
$this->view->expects($this->any())
->method('getRoot')
@@ -80,16 +68,6 @@ class FileSearchBackendTest extends TestCase {
->method('getRelativePath')
->willReturnArgument(0);
- $this->rootFolder = $this->createMock(IRootFolder::class);
-
- $this->shareManager = $this->createMock(IManager::class);
-
- $this->searchFolder = $this->createMock(Folder::class);
-
- $fileInfo = $this->createMock(FileInfo::class);
-
- $this->davFolder = $this->createMock(Directory::class);
-
$this->davFolder->expects($this->any())
->method('getFileInfo')
->willReturn($fileInfo);
@@ -263,8 +241,8 @@ class FileSearchBackendTest extends TestCase {
$this->search->search($query);
}
- private function getBasicQuery($type, $property, $value = null) {
- $scope = new \SearchDAV\Query\Scope('/', 'infinite');
+ private function getBasicQuery(string $type, string $property, int|string|null $value = null) {
+ $scope = new Scope('/', 'infinite');
$scope->path = '/';
$from = [$scope];
$orderBy = [];
@@ -272,12 +250,12 @@ class FileSearchBackendTest extends TestCase {
if (is_null($value)) {
$where = new Operator(
$type,
- [new \SearchDAV\Query\Literal($property)]
+ [new Literal($property)]
);
} else {
$where = new Operator(
$type,
- [new SearchPropertyDefinition($property, true, true, true), new \SearchDAV\Query\Literal($value)]
+ [new SearchPropertyDefinition($property, true, true, true), new Literal($value)]
);
}
$limit = new Limit();
@@ -350,11 +328,11 @@ class FileSearchBackendTest extends TestCase {
[
new Operator(
Operator::OPERATION_EQUAL,
- [new SearchPropertyDefinition('{DAV:}getcontenttype', true, true, true), new \SearchDAV\Query\Literal('image/png')]
+ [new SearchPropertyDefinition('{DAV:}getcontenttype', true, true, true), new Literal('image/png')]
),
new Operator(
Operator::OPERATION_EQUAL,
- [new SearchPropertyDefinition(FilesPlugin::OWNER_ID_PROPERTYNAME, true, true, true), new \SearchDAV\Query\Literal($this->user->getUID())]
+ [new SearchPropertyDefinition(FilesPlugin::OWNER_ID_PROPERTYNAME, true, true, true), new Literal($this->user->getUID())]
),
]
);
@@ -383,7 +361,7 @@ class FileSearchBackendTest extends TestCase {
$innerOperator = new Operator(
Operator::OPERATION_EQUAL,
- [new SearchPropertyDefinition('{DAV:}getcontenttype', true, true, true), new \SearchDAV\Query\Literal('image/png')]
+ [new SearchPropertyDefinition('{DAV:}getcontenttype', true, true, true), new Literal('image/png')]
);
// 5 child operators
$level1Operator = new Operator(