Skip to content

Commit 8e2ef53

Browse files
committed
test: adjust tests for updated local backend check
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 4166a20 commit 8e2ef53

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

apps/files_external/tests/Controller/GlobalStoragesControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private function createController(bool $allowCreateLocal = true): GlobalStorages
5050
$session,
5151
$this->createMock(IGroupManager::class),
5252
$config,
53-
$this->createMock(BackendService::class),
53+
$this->backendService,
5454
);
5555
}
5656

apps/files_external/tests/Controller/StoragesControllerTestCase.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
use OCA\Files_External\Lib\Auth\AuthMechanism;
1414
use OCA\Files_External\Lib\Auth\NullMechanism;
1515
use OCA\Files_External\Lib\Backend\Backend;
16+
use OCA\Files_External\Lib\Backend\Local;
1617
use OCA\Files_External\Lib\Backend\SMB;
1718
use OCA\Files_External\Lib\StorageConfig;
1819
use OCA\Files_External\NotFoundException;
20+
use OCA\Files_External\Service\BackendService;
1921
use OCA\Files_External\Service\GlobalStoragesService;
2022
use OCA\Files_External\Service\UserStoragesService;
2123
use OCP\AppFramework\Http;
@@ -24,9 +26,20 @@
2426
abstract class StoragesControllerTestCase extends \Test\TestCase {
2527
protected GlobalStoragesController|UserStoragesController $controller;
2628
protected GlobalStoragesService|UserStoragesService|MockObject $service;
29+
protected BackendService|MockObject $backendService;
2730

2831
protected function setUp(): void {
2932
parent::setUp();
33+
34+
$this->backendService = $this->createMock(BackendService::class);
35+
$this->backendService->method('getBackend')
36+
->willReturnCallback(function ($identifier) {
37+
if ($identifier === 'local') {
38+
return $this->createMock(Local::class);
39+
} else {
40+
return $this->createMock(Backend::class);
41+
}
42+
});
3043
}
3144

3245
protected function tearDown(): void {

apps/files_external/tests/Controller/UserStoragesControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private function createController(bool $allowCreateLocal = true) {
5959
$session,
6060
$this->createMock(IGroupManager::class),
6161
$config,
62-
$this->createMock(BackendService::class),
62+
$this->backendService,
6363
);
6464
}
6565

0 commit comments

Comments
 (0)