mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 01:30:50 -04:00
test: mock ocm discovery in external share test
saves ~50s while running tests Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
e01a54c53a
commit
d47fd8d708
2 changed files with 13 additions and 1 deletions
2
apps/files_sharing/lib/External/Storage.php
vendored
2
apps/files_sharing/lib/External/Storage.php
vendored
|
|
@ -63,7 +63,7 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage,
|
|||
$this->manager = $options['manager'];
|
||||
$this->cloudId = $options['cloudId'];
|
||||
$this->logger = Server::get(LoggerInterface::class);
|
||||
$discoveryService = Server::get(IOCMDiscoveryService::class);
|
||||
$discoveryService = $options['discoveryService'] ?? Server::get(IOCMDiscoveryService::class);
|
||||
$this->config = Server::get(IConfig::class);
|
||||
$this->appConfig = Server::get(IAppConfig::class);
|
||||
$this->shareManager = Server::get(IShareManager::class);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ use OCP\Http\Client\IClient;
|
|||
use OCP\Http\Client\IClientService;
|
||||
use OCP\Http\Client\IResponse;
|
||||
use OCP\ICertificateManager;
|
||||
use OCP\OCM\IOCMDiscoveryService;
|
||||
use OCP\OCM\IOCMProvider;
|
||||
use OCP\Server;
|
||||
|
||||
/**
|
||||
|
|
@ -62,6 +64,9 @@ class ExternalStorageTest extends \Test\TestCase {
|
|||
$manager = $this->createMock(ExternalShareManager::class);
|
||||
$client = $this->createMock(IClient::class);
|
||||
$response = $this->createMock(IResponse::class);
|
||||
$discoveryService = $this->createMock(IOCMDiscoveryService::class);
|
||||
$ocmProvider = $this->createMock(IOCMProvider::class);
|
||||
|
||||
$client
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
|
|
@ -74,6 +79,12 @@ class ExternalStorageTest extends \Test\TestCase {
|
|||
->expects($this->any())
|
||||
->method('newClient')
|
||||
->willReturn($client);
|
||||
$discoveryService->method('discover')
|
||||
->willReturn($ocmProvider);
|
||||
$ocmProvider->method('extractProtocolEntry')
|
||||
->willReturn('/public.php/webdav');
|
||||
$ocmProvider->method('getEndPoint')
|
||||
->willReturn($uri);
|
||||
|
||||
return new TestSharingExternalStorage(
|
||||
[
|
||||
|
|
@ -86,6 +97,7 @@ class ExternalStorageTest extends \Test\TestCase {
|
|||
'manager' => $manager,
|
||||
'certificateManager' => $certificateManager,
|
||||
'HttpClientService' => $httpClientService,
|
||||
'discoveryService' => $discoveryService,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue