Skip to content

Commit 41a95d7

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

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

apps/files_external/tests/Controller/GlobalStoragesControllerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ private function createController($allowCreateLocal = true) {
6868
$this->createMock(LoggerInterface::class),
6969
$session,
7070
$this->createMock(IGroupManager::class),
71-
$config
71+
$config,
72+
$this->backendService,
7273
);
7374
}
7475

apps/files_external/tests/Controller/StoragesControllerTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
use OCA\Files_External\Lib\Auth\AuthMechanism;
3232
use OCA\Files_External\Lib\Backend\Backend;
3333

34+
use OCA\Files_External\Lib\Backend\Local;
3435
use OCA\Files_External\Lib\StorageConfig;
3536
use OCA\Files_External\NotFoundException;
37+
use OCA\Files_External\Service\BackendService;
3638
use OCA\Files_External\Service\GlobalStoragesService;
3739
use OCA\Files_External\Service\UserStoragesService;
3840
use OCP\AppFramework\Http;
@@ -49,9 +51,23 @@ abstract class StoragesControllerTest extends \Test\TestCase {
4951
* @var GlobalStoragesService|UserStoragesService|MockObject
5052
*/
5153
protected $service;
54+
/**
55+
* @var BackendService|MockObject
56+
*/
57+
protected $backendService;
5258

5359
protected function setUp(): void {
5460
\OCA\Files_External\MountConfig::$skipTest = true;
61+
62+
$this->backendService = $this->createMock(BackendService::class);
63+
$this->backendService->method('getBackend')
64+
->willReturnCallback(function ($identifier) {
65+
if ($identifier === 'local') {
66+
return $this->createMock(Local::class);
67+
} else {
68+
return $this->createMock(Backend::class);
69+
}
70+
});
5571
}
5672

5773
protected function tearDown(): void {

apps/files_external/tests/Controller/UserStoragesControllerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ private function createController($allowCreateLocal = true) {
7676
$this->createMock(LoggerInterface::class),
7777
$session,
7878
$this->createMock(IGroupManager::class),
79-
$config
79+
$config,
80+
$this->backendService,
8081
);
8182
}
8283

0 commit comments

Comments
 (0)