Skip to content

Commit 51a7f0e

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

3 files changed

Lines changed: 22 additions & 3 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: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
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;
15+
use OCA\Files_External\Lib\Backend\SMB;
1416
use OCA\Files_External\Lib\StorageConfig;
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 {
34-
\OCA\Files_External\MountConfig::$skipTest = true;
41+
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
@@ -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)