Skip to content

Commit 19cac44

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

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
@@ -50,7 +50,8 @@ private function createController($allowCreateLocal = true) {
5050
$this->createMock(LoggerInterface::class),
5151
$session,
5252
$this->createMock(IGroupManager::class),
53-
$config
53+
$config,
54+
$this->backendService,
5455
);
5556
}
5657

apps/files_external/tests/Controller/StoragesControllerTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
use OCA\Files_External\Lib\Auth\AuthMechanism;
1212
use OCA\Files_External\Lib\Backend\Backend;
1313

14+
use OCA\Files_External\Lib\Backend\Local;
1415
use OCA\Files_External\Lib\StorageConfig;
1516
use OCA\Files_External\NotFoundException;
17+
use OCA\Files_External\Service\BackendService;
1618
use OCA\Files_External\Service\GlobalStoragesService;
1719
use OCA\Files_External\Service\UserStoragesService;
1820
use OCP\AppFramework\Http;
@@ -29,9 +31,23 @@ abstract class StoragesControllerTest extends \Test\TestCase {
2931
* @var GlobalStoragesService|UserStoragesService|MockObject
3032
*/
3133
protected $service;
34+
/**
35+
* @var BackendService|MockObject
36+
*/
37+
protected $backendService;
3238

3339
protected function setUp(): void {
3440
\OCA\Files_External\MountConfig::$skipTest = true;
41+
42+
$this->backendService = $this->createMock(BackendService::class);
43+
$this->backendService->method('getBackend')
44+
->willReturnCallback(function ($identifier) {
45+
if ($identifier === 'local') {
46+
return $this->createMock(Local::class);
47+
} else {
48+
return $this->createMock(Backend::class);
49+
}
50+
});
3551
}
3652

3753
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
@@ -57,7 +57,8 @@ private function createController($allowCreateLocal = true) {
5757
$this->createMock(LoggerInterface::class),
5858
$session,
5959
$this->createMock(IGroupManager::class),
60-
$config
60+
$config,
61+
$this->backendService,
6162
);
6263
}
6364

0 commit comments

Comments
 (0)