diff options
author | Robin Appelman <robin@icewind.nl> | 2024-02-09 09:54:52 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2024-03-04 13:57:31 +0100 |
commit | e7a7b4a40184dc3da2c83e858c820625f660e48e (patch) | |
tree | 367bda0ac814376e7c771fbe4b1c40cf7f33df53 /apps/dav/tests | |
parent | 4d110c1dd6ae384c00c93b4e266118004b71e498 (diff) | |
download | nextcloud-server-e7a7b4a40184dc3da2c83e858c820625f660e48e.tar.gz nextcloud-server-e7a7b4a40184dc3da2c83e858c820625f660e48e.zip |
perf: switch places that always use the first getById result to getFirstNodeById
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/dav/tests')
4 files changed, 28 insertions, 28 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php index c636d16358d..d60d1123de9 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php @@ -320,14 +320,14 @@ class FilesReportPluginTest extends \Test\TestCase { ->willReturn('/'); $this->userFolder->expects($this->exactly(2)) - ->method('getById') + ->method('getFirstNodeById') ->withConsecutive( ['111'], ['222'], ) ->willReturnOnConsecutiveCalls( - [$filesNode1], - [$filesNode2], + $filesNode1, + $filesNode2, ); /** @var \OCA\DAV\Connector\Sabre\Directory|MockObject $reportTargetNode */ @@ -373,14 +373,14 @@ class FilesReportPluginTest extends \Test\TestCase { ->willReturn($subNode); $subNode->expects($this->exactly(2)) - ->method('getById') + ->method('getFirstNodeById') ->withConsecutive( ['111'], ['222'], ) ->willReturnOnConsecutiveCalls( - [$filesNode1], - [$filesNode2], + $filesNode1, + $filesNode2, ); /** @var \OCA\DAV\Connector\Sabre\Directory|MockObject $reportTargetNode */ diff --git a/apps/dav/tests/unit/Controller/DirectControllerTest.php b/apps/dav/tests/unit/Controller/DirectControllerTest.php index fe6d4ea8f24..181b02bda2c 100644 --- a/apps/dav/tests/unit/Controller/DirectControllerTest.php +++ b/apps/dav/tests/unit/Controller/DirectControllerTest.php @@ -110,9 +110,9 @@ class DirectControllerTest extends TestCase { $folder = $this->createMock(Folder::class); - $userFolder->method('getById') + $userFolder->method('getFirstNodeById') ->with(101) - ->willReturn([$folder]); + ->willReturn($folder); $this->expectException(OCSBadRequestException::class); $this->controller->getUrl(101); @@ -129,9 +129,9 @@ class DirectControllerTest extends TestCase { $this->timeFactory->method('getTime') ->willReturn(42); - $userFolder->method('getById') + $userFolder->method('getFirstNodeById') ->with(101) - ->willReturn([$file]); + ->willReturn($file); $userFolder->method('getRelativePath') ->willReturn('/path'); diff --git a/apps/dav/tests/unit/Direct/DirectFileTest.php b/apps/dav/tests/unit/Direct/DirectFileTest.php index fdf7fa54923..bc8b3822532 100644 --- a/apps/dav/tests/unit/Direct/DirectFileTest.php +++ b/apps/dav/tests/unit/Direct/DirectFileTest.php @@ -73,9 +73,9 @@ class DirectFileTest extends TestCase { ->willReturn($this->userFolder); $this->file = $this->createMock(File::class); - $this->userFolder->method('getById') + $this->userFolder->method('getFirstNodeById') ->with(42) - ->willReturn([$this->file]); + ->willReturn($this->file); $this->eventDispatcher = $this->createMock(IEventDispatcher::class); diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php index 4dd81615c01..143d598fd2d 100644 --- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php +++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php @@ -84,8 +84,8 @@ class SystemTagsObjectTypeCollectionTest extends \Test\TestCase { $userFolder = $this->userFolder; $closure = function ($name) use ($userFolder) { - $nodes = $userFolder->getById(intval($name)); - return !empty($nodes); + $node = $userFolder->getFirstNodeById(intval($name)); + return $node !== null; }; $this->node = new \OCA\DAV\SystemTag\SystemTagsObjectTypeCollection( @@ -98,14 +98,14 @@ class SystemTagsObjectTypeCollectionTest extends \Test\TestCase { ); } - + public function testForbiddenCreateFile(): void { $this->expectException(\Sabre\DAV\Exception\Forbidden::class); $this->node->createFile('555'); } - + public function testForbiddenCreateDirectory(): void { $this->expectException(\Sabre\DAV\Exception\Forbidden::class); @@ -114,27 +114,27 @@ class SystemTagsObjectTypeCollectionTest extends \Test\TestCase { public function testGetChild(): void { $this->userFolder->expects($this->once()) - ->method('getById') + ->method('getFirstNodeById') ->with('555') - ->willReturn([true]); + ->willReturn($this->createMock(\OCP\Files\Node::class)); $childNode = $this->node->getChild('555'); $this->assertInstanceOf('\OCA\DAV\SystemTag\SystemTagsObjectMappingCollection', $childNode); $this->assertEquals('555', $childNode->getName()); } - + public function testGetChildWithoutAccess(): void { $this->expectException(\Sabre\DAV\Exception\NotFound::class); $this->userFolder->expects($this->once()) - ->method('getById') + ->method('getFirstNodeById') ->with('555') - ->willReturn([]); + ->willReturn(null); $this->node->getChild('555'); } - + public function testGetChildren(): void { $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); @@ -143,28 +143,28 @@ class SystemTagsObjectTypeCollectionTest extends \Test\TestCase { public function testChildExists(): void { $this->userFolder->expects($this->once()) - ->method('getById') + ->method('getFirstNodeById') ->with('123') - ->willReturn([true]); + ->willReturn($this->createMock(\OCP\Files\Node::class)); $this->assertTrue($this->node->childExists('123')); } public function testChildExistsWithoutAccess(): void { $this->userFolder->expects($this->once()) - ->method('getById') + ->method('getFirstNodeById') ->with('555') - ->willReturn([]); + ->willReturn(null); $this->assertFalse($this->node->childExists('555')); } - + public function testDelete(): void { $this->expectException(\Sabre\DAV\Exception\Forbidden::class); $this->node->delete(); } - + public function testSetName(): void { $this->expectException(\Sabre\DAV\Exception\Forbidden::class); |