Skip to content

Commit 38b6bb4

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

3 files changed

Lines changed: 21 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
@@ -49,7 +49,8 @@ private function createController($allowCreateLocal = true) {
4949
$this->createMock(LoggerInterface::class),
5050
$session,
5151
$this->createMock(IGroupManager::class),
52-
$config
52+
$config,
53+
$this->backendService,
5354
);
5455
}
5556

apps/files_external/tests/Controller/StoragesControllerTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
use OCA\Files_External\Controller\GlobalStoragesController;
1010
use OCA\Files_External\Lib\Auth\AuthMechanism;
1111
use OCA\Files_External\Lib\Backend\Backend;
12+
use OCA\Files_External\Lib\Backend\Local;
13+
use OCA\Files_External\Lib\Backend\SMB;
1214
use OCA\Files_External\Lib\StorageConfig;
1315

1416
use OCA\Files_External\MountConfig;
1517
use OCA\Files_External\NotFoundException;
18+
use OCA\Files_External\Service\BackendService;
1619
use OCA\Files_External\Service\GlobalStoragesService;
1720
use OCA\Files_External\Service\UserStoragesService;
1821
use OCP\AppFramework\Http;
@@ -29,9 +32,23 @@ abstract class StoragesControllerTest extends \Test\TestCase {
2932
* @var GlobalStoragesService|UserStoragesService|MockObject
3033
*/
3134
protected $service;
35+
/**
36+
* @var BackendService|MockObject
37+
*/
38+
protected $backendService;
3239

3340
protected function setUp(): void {
3441
MountConfig::$skipTest = true;
42+
43+
$this->backendService = $this->createMock(BackendService::class);
44+
$this->backendService->method('getBackend')
45+
->willReturnCallback(function ($identifier) {
46+
if ($identifier === 'local') {
47+
return $this->createMock(Local::class);
48+
} else {
49+
return $this->createMock(Backend::class);
50+
}
51+
});
3552
}
3653

3754
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
@@ -56,7 +56,8 @@ private function createController($allowCreateLocal = true) {
5656
$this->createMock(LoggerInterface::class),
5757
$session,
5858
$this->createMock(IGroupManager::class),
59-
$config
59+
$config,
60+
$this->backendService,
6061
);
6162
}
6263

0 commit comments

Comments
 (0)