diff --git a/lib/FilesHooksStatic.php b/lib/FilesHooksStatic.php index 25356ef50..81d8d81e1 100644 --- a/lib/FilesHooksStatic.php +++ b/lib/FilesHooksStatic.php @@ -12,11 +12,8 @@ * The class to handle the filesystem hooks */ class FilesHooksStatic { - /** - * @return FilesHooks - */ - protected static function getHooks() { - return \OC::$server->query(FilesHooks::class); + protected static function getHooks(): FilesHooks { + return \OCP\Server::get(FilesHooks::class); } /** diff --git a/playwright/e2e/sidebar.spec.ts b/playwright/e2e/sidebar.spec.ts index 56047f5b3..3abe11a74 100644 --- a/playwright/e2e/sidebar.spec.ts +++ b/playwright/e2e/sidebar.spec.ts @@ -6,7 +6,7 @@ import { test, expect } from '@playwright/test' import { createRandomUser, login } from '@nextcloud/e2e-test-server/playwright' import { createFolder, getFileListRow, moveFile, navigateToFolder, renameFile } from './filesUtils.ts' -import { addTag, closeToasts, createPublicShare, randHash, showActivityTab, toggleFavorite } from './sidebarUtils.ts' +import { addTag, createPublicShare, randHash, showActivityTab, toggleFavorite } from './sidebarUtils.ts' // Each test gets a fresh user so activity logs are clean and isolated. test.beforeEach(async ({ page }) => { @@ -51,7 +51,6 @@ test('Has rename activity', async ({ page }) => { test('Has move activity', async ({ page }) => { await createFolder(page, 'Test folder') await moveFile(page, 'welcome.txt', 'Test folder') - await closeToasts(page) await navigateToFolder(page, 'Test folder') await showActivityTab(page, 'welcome.txt') await expect(page.locator('.activity-entry').first()).toContainText('You moved') diff --git a/playwright/e2e/sidebarUtils.ts b/playwright/e2e/sidebarUtils.ts index 356758c58..c80aa06fb 100644 --- a/playwright/e2e/sidebarUtils.ts +++ b/playwright/e2e/sidebarUtils.ts @@ -20,12 +20,6 @@ export async function closeSidebar(page: Page) { await expect(page.locator('[data-cy-sidebar]')).not.toBeVisible() } -export async function closeToasts(page: Page) { - for (const btn of await page.locator('button.toast-close').all()) { - await btn.click() - } -} - export async function showActivityTab(page: Page, fileName: string) { const activitiesResponse = page.waitForResponse(/\/ocs\/v2\.php\/apps\/activity\/api\/v2\/activity\/filter/) @@ -41,7 +35,6 @@ export async function toggleFavorite(page: Page, fileName: string) { const tagResponse = page.waitForResponse(/\/index\.php\/apps\/files\/api\/v1\/files\//) await toggleMenuAction(page, fileName, 'favorite') await tagResponse - await page.locator('.toast-close').click() } export async function createPublicShare(page: Page, fileName: string) { diff --git a/tests/Controller/RemoteActivityControllerTest.php b/tests/Controller/RemoteActivityControllerTest.php index f32b38d6e..b75d123ff 100644 --- a/tests/Controller/RemoteActivityControllerTest.php +++ b/tests/Controller/RemoteActivityControllerTest.php @@ -27,6 +27,7 @@ use OCP\Files\Folder; use OCP\Files\InvalidPathException; use OCP\Files\IRootFolder; +use OCP\Files\IUserFolder; use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\IDBConnection; @@ -128,7 +129,7 @@ private function setupSuccessfulNode(string $path = '/SharedFolder/file.txt', in $node->method('getId')->willReturn($fileId); $node->method('getStorage')->willReturn($storage); - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $userFolder->method('get')->with($path)->willReturn($node); $this->rootFolder->method('getUserFolder')->willReturn($userFolder); @@ -453,7 +454,7 @@ public function testActorServerNormalization(string $actorServer, string $shareR ]); if ($shouldMatch) { - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $userFolder->method('get')->willThrowException(new NotFoundException()); $this->rootFolder->method('getUserFolder')->willReturn($userFolder); } @@ -532,7 +533,7 @@ public function testNodeNotFoundException(): void { $this->cloudIdManager->method('resolveCloudId')->willReturn($this->createCloudIdMock()); $this->setupDbQueryMock($this->validShare()); - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $userFolder->method('get')->willThrowException(new NotFoundException()); $this->rootFolder->method('getUserFolder')->willReturn($userFolder); @@ -553,7 +554,7 @@ public function testNodeInvalidPathException(): void { $this->cloudIdManager->method('resolveCloudId')->willReturn($this->createCloudIdMock()); $this->setupDbQueryMock($this->validShare()); - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $userFolder->method('get')->willThrowException(new InvalidPathException()); $this->rootFolder->method('getUserFolder')->willReturn($userFolder); @@ -684,7 +685,7 @@ public function testStorageNotExternalStorage(): void { $node = $this->createMock(Node::class); $node->method('getStorage')->willReturn($storage); - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $userFolder->method('get')->willReturn($node); $this->rootFolder->method('getUserFolder')->willReturn($userFolder); @@ -717,7 +718,7 @@ public function testStorageWrapperResolvesToNonExternalStorage(): void { $node = $this->createMock(Node::class); $node->method('getStorage')->willReturn($wrapperStorage); - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $userFolder->method('get')->willReturn($node); $this->rootFolder->method('getUserFolder')->willReturn($userFolder); @@ -745,7 +746,7 @@ public function testExternalStorageTokenMismatch(): void { $node = $this->createMock(Node::class); $node->method('getStorage')->willReturn($storage); - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $userFolder->method('get')->willReturn($node); $this->rootFolder->method('getUserFolder')->willReturn($userFolder); @@ -782,7 +783,7 @@ public function testSuccessfulMoveToAnotherFolder(): void { $node->method('getParent')->willReturn($parent); $node->method('getStorage')->willReturn($storage); - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $userFolder->method('get')->with($path)->willReturn($node); $this->rootFolder->method('getUserFolder')->willReturn($userFolder); diff --git a/tests/FilesHooksTest.php b/tests/FilesHooksTest.php index 6939974bc..a3eae3696 100644 --- a/tests/FilesHooksTest.php +++ b/tests/FilesHooksTest.php @@ -38,6 +38,7 @@ use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; +use OCP\Files\IUserFolder; use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\IConfig; @@ -933,7 +934,7 @@ public function testShareNotificationForOriginalOwners(bool $nodeFound, string $ if ($nodeFound) { $this->rootFolder->method('getUserFolder') ->willReturnCallback(function (string $userId) { - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $resolvedNode = $this->getNodeMock(42, "/$userId/files/source-path"); $userFolder->method('getById') ->with(42) @@ -977,7 +978,7 @@ public function testShareNotificationForOriginalOwnersUsesActualFileNotShareRoot // The owner's view of the subfolder (resolved by file ID 99) $ownerSubfolder = $this->getNodeMock(99, '/admin/files/ParentFolder/Subfolder', false); - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $userFolder->method('getById') ->with(99) ->willReturn([$ownerSubfolder]); @@ -1148,7 +1149,7 @@ public function testLeaveShare(): void { } public function testGetUserPathsFromPathFileNotFound(): void { - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $userFolder->method('get') ->with('/test/path') ->willThrowException(new NotFoundException()); @@ -1164,7 +1165,7 @@ public function testGetUserPathsFromPathFileNotFound(): void { } public function testGetUserPathsFromPathNotANode(): void { - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $userFolder->method('get') ->with('/test/path') ->willReturn(null); @@ -1184,7 +1185,7 @@ public function testGetUserPathsFromPathSuccess(): void { $node->method('getPath') ->willReturn('/owner/files/test/path'); - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $userFolder->method('get') ->with('/test/path') ->willReturn($node); @@ -1218,7 +1219,7 @@ private function getShareMock(string $nodeType, int $shareType, string $owner = private function mockNodeNotDeleted(string $owner, int $nodeId): void { $node = $this->createMock(File::class); - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $userFolder->method('getFirstNodeById')->with($nodeId)->willReturn($node); $this->rootFolder->method('getUserFolder')->with($owner)->willReturn($userFolder); } diff --git a/tests/ViewInfoCacheTest.php b/tests/ViewInfoCacheTest.php index e667dd0c4..41cb6652b 100644 --- a/tests/ViewInfoCacheTest.php +++ b/tests/ViewInfoCacheTest.php @@ -27,6 +27,7 @@ use OCP\Files\File; use OCP\Files\Folder; use OCP\Files\IRootFolder; +use OCP\Files\IUserFolder; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; @@ -230,7 +231,7 @@ public static function dataFindInfoById(): array { #[DataProvider('dataFindInfoById')] public function testFindInfoById(string $user, int $fileId, string $filename, ?string $path, ?string $pathTrash, string $isDirPath, bool $isDir, array $expected, array $expectedCache): void { - $userFolder = $this->createMock(Folder::class); + $userFolder = $this->createMock(IUserFolder::class); $this->rootFolder ->method('getUserFolder')