aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php')
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php63
1 files changed, 23 insertions, 40 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
index 393f3c72c20..b07778e4fbd 100644
--- a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
@@ -1,5 +1,6 @@
<?php
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -27,7 +28,7 @@ use OCP\Files\Mount\IMountManager;
* @package OCA\DAV\Tests\Unit\Connector\Sabre
*/
class ObjectTreeTest extends \Test\TestCase {
- public function copyDataProvider() {
+ public static function copyDataProvider(): array {
return [
// copy into same dir
['a', 'b', ''],
@@ -38,10 +39,8 @@ class ObjectTreeTest extends \Test\TestCase {
];
}
- /**
- * @dataProvider copyDataProvider
- */
- public function testCopy($sourcePath, $targetPath, $targetParent): void {
+ #[\PHPUnit\Framework\Attributes\DataProvider('copyDataProvider')]
+ public function testCopy(string $sourcePath, string $targetPath, string $targetParent): void {
$view = $this->createMock(View::class);
$view->expects($this->once())
->method('verifyPath')
@@ -67,7 +66,7 @@ class ObjectTreeTest extends \Test\TestCase {
$rootDir = new Directory($view, $info);
$objectTree = $this->getMockBuilder(ObjectTree::class)
- ->setMethods(['nodeExists', 'getNodeForPath'])
+ ->onlyMethods(['nodeExists', 'getNodeForPath'])
->setConstructorArgs([$rootDir, $view])
->getMock();
@@ -82,9 +81,7 @@ class ObjectTreeTest extends \Test\TestCase {
$objectTree->copy($sourcePath, $targetPath);
}
- /**
- * @dataProvider copyDataProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('copyDataProvider')]
public function testCopyFailNotCreatable($sourcePath, $targetPath, $targetParent): void {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
@@ -110,7 +107,7 @@ class ObjectTreeTest extends \Test\TestCase {
$rootDir = new Directory($view, $info);
$objectTree = $this->getMockBuilder(ObjectTree::class)
- ->setMethods(['nodeExists', 'getNodeForPath'])
+ ->onlyMethods(['nodeExists', 'getNodeForPath'])
->setConstructorArgs([$rootDir, $view])
->getMock();
@@ -123,27 +120,17 @@ class ObjectTreeTest extends \Test\TestCase {
$objectTree->copy($sourcePath, $targetPath);
}
- /**
- * @dataProvider nodeForPathProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('nodeForPathProvider')]
public function testGetNodeForPath(
- $inputFileName,
- $fileInfoQueryPath,
- $outputFileName,
- $type,
+ string $inputFileName,
+ string $fileInfoQueryPath,
+ string $outputFileName,
+ string $type,
): void {
- $rootNode = $this->getMockBuilder(Directory::class)
- ->disableOriginalConstructor()
- ->getMock();
- $mountManager = $this->getMockBuilder(Manager::class)
- ->disableOriginalConstructor()
- ->getMock();
- $view = $this->getMockBuilder(View::class)
- ->disableOriginalConstructor()
- ->getMock();
- $fileInfo = $this->getMockBuilder(FileInfo::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $rootNode = $this->createMock(Directory::class);
+ $mountManager = $this->createMock(Manager::class);
+ $view = $this->createMock(View::class);
+ $fileInfo = $this->createMock(FileInfo::class);
$fileInfo->method('getType')
->willReturn($type);
$fileInfo->method('getName')
@@ -164,13 +151,13 @@ class ObjectTreeTest extends \Test\TestCase {
$this->assertEquals($outputFileName, $node->getName());
if ($type === 'file') {
- $this->assertTrue($node instanceof File);
+ $this->assertInstanceOf(File::class, $node);
} else {
- $this->assertTrue($node instanceof Directory);
+ $this->assertInstanceOf(Directory::class, $node);
}
}
- public function nodeForPathProvider() {
+ public static function nodeForPathProvider(): array {
return [
// regular file
[
@@ -213,7 +200,7 @@ class ObjectTreeTest extends \Test\TestCase {
$storage = new Temporary([]);
$view = $this->getMockBuilder(View::class)
- ->setMethods(['resolvePath'])
+ ->onlyMethods(['resolvePath'])
->getMock();
$view->expects($this->once())
->method('resolvePath')
@@ -221,9 +208,7 @@ class ObjectTreeTest extends \Test\TestCase {
return [$storage, ltrim($path, '/')];
});
- $rootNode = $this->getMockBuilder(Directory::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $rootNode = $this->createMock(Directory::class);
$mountManager = $this->createMock(IMountManager::class);
$tree = new ObjectTree();
@@ -239,7 +224,7 @@ class ObjectTreeTest extends \Test\TestCase {
$storage = new Temporary([]);
$view = $this->getMockBuilder(View::class)
- ->setMethods(['resolvePath'])
+ ->onlyMethods(['resolvePath'])
->getMock();
$view->expects($this->any())
->method('resolvePath')
@@ -247,9 +232,7 @@ class ObjectTreeTest extends \Test\TestCase {
return [$storage, ltrim($path, '/')];
});
- $rootNode = $this->getMockBuilder(Directory::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $rootNode = $this->createMock(Directory::class);
$mountManager = $this->createMock(IMountManager::class);
$tree = new ObjectTree();