mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 17:23:59 -04:00
chore(files_external): Fix BackendServiceTest
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
a77969d1c0
commit
a775fcfa5b
1 changed files with 11 additions and 8 deletions
|
|
@ -15,12 +15,15 @@ use OCA\Files_External\Lib\Config\IBackendProvider;
|
|||
use OCA\Files_External\Service\BackendService;
|
||||
use OCP\IAppConfig;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class BackendServiceTest extends \Test\TestCase {
|
||||
protected IAppConfig&MockObject $appConfig;
|
||||
protected LoggerInterface&MockObject $logger;
|
||||
|
||||
protected function setUp(): void {
|
||||
$this->appConfig = $this->createMock(IAppConfig::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -46,7 +49,7 @@ class BackendServiceTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testRegisterBackend(): void {
|
||||
$service = new BackendService($this->appConfig);
|
||||
$service = new BackendService($this->appConfig, $this->logger);
|
||||
|
||||
$backend = $this->getBackendMock('\Foo\Bar');
|
||||
|
||||
|
|
@ -72,7 +75,7 @@ class BackendServiceTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testBackendProvider(): void {
|
||||
$service = new BackendService($this->appConfig);
|
||||
$service = new BackendService($this->appConfig, $this->logger);
|
||||
|
||||
$backend1 = $this->getBackendMock('\Foo\Bar');
|
||||
$backend2 = $this->getBackendMock('\Bar\Foo');
|
||||
|
|
@ -91,7 +94,7 @@ class BackendServiceTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testAuthMechanismProvider(): void {
|
||||
$service = new BackendService($this->appConfig);
|
||||
$service = new BackendService($this->appConfig, $this->logger);
|
||||
|
||||
$backend1 = $this->getAuthMechanismMock('\Foo\Bar');
|
||||
$backend2 = $this->getAuthMechanismMock('\Bar\Foo');
|
||||
|
|
@ -110,7 +113,7 @@ class BackendServiceTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testMultipleBackendProviders(): void {
|
||||
$service = new BackendService($this->appConfig);
|
||||
$service = new BackendService($this->appConfig, $this->logger);
|
||||
|
||||
$backend1a = $this->getBackendMock('\Foo\Bar');
|
||||
$backend1b = $this->getBackendMock('\Bar\Foo');
|
||||
|
|
@ -147,7 +150,7 @@ class BackendServiceTest extends \Test\TestCase {
|
|||
->with('files_external', 'allow_user_mounting')
|
||||
->willReturn(true);
|
||||
|
||||
$service = new BackendService($this->appConfig);
|
||||
$service = new BackendService($this->appConfig, $this->logger);
|
||||
|
||||
$backendAllowed = $this->getBackendMock('\User\Mount\Allowed');
|
||||
$backendAllowed->expects($this->never())
|
||||
|
|
@ -171,7 +174,7 @@ class BackendServiceTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testGetAvailableBackends(): void {
|
||||
$service = new BackendService($this->appConfig);
|
||||
$service = new BackendService($this->appConfig, $this->logger);
|
||||
|
||||
$backendAvailable = $this->getBackendMock('\Backend\Available');
|
||||
$backendAvailable->expects($this->once())
|
||||
|
|
@ -212,7 +215,7 @@ class BackendServiceTest extends \Test\TestCase {
|
|||
public function testRegisterConfigHandlerInvalid(array $placeholders): void {
|
||||
$this->expectException(\RuntimeException::class);
|
||||
|
||||
$service = new BackendService($this->appConfig);
|
||||
$service = new BackendService($this->appConfig, $this->logger);
|
||||
$mock = $this->createMock(IConfigHandler::class);
|
||||
$cb = function () use ($mock) {
|
||||
return $mock;
|
||||
|
|
@ -223,7 +226,7 @@ class BackendServiceTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testConfigHandlers(): void {
|
||||
$service = new BackendService($this->appConfig);
|
||||
$service = new BackendService($this->appConfig, $this->logger);
|
||||
$mock = $this->createMock(IConfigHandler::class);
|
||||
$mock->expects($this->exactly(3))
|
||||
->method('handle');
|
||||
|
|
|
|||
Loading…
Reference in a new issue