Inject IHTTPClientService
Otherwise the unit test execution will do a ton of external HTTP requests which fail and then timeout… See https://blackfire.io/profiles/compare/3c67acfa-a11e-4aec-bcd4-c945b006f01e/graph for reference Pretty similar to https://github.com/nextcloud/server/pull/1565 Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
This commit is contained in:
parent
2eab2ffa22
commit
498b7399c1
|
@ -56,6 +56,7 @@ class MountProvider implements IMountProvider {
|
||||||
$mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/');
|
$mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/');
|
||||||
$data['mountpoint'] = $mountPoint;
|
$data['mountpoint'] = $mountPoint;
|
||||||
$data['certificateManager'] = \OC::$server->getCertificateManager($user->getUID());
|
$data['certificateManager'] = \OC::$server->getCertificateManager($user->getUID());
|
||||||
|
$data['HttpClientService'] = \OC::$server->getHTTPClientService();
|
||||||
return new Mount(self::STORAGE, $mountPoint, $data, $manager, $storageFactory);
|
return new Mount(self::STORAGE, $mountPoint, $data, $manager, $storageFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,10 +64,10 @@ class Storage extends DAV implements ISharedStorage {
|
||||||
|
|
||||||
public function __construct($options) {
|
public function __construct($options) {
|
||||||
$this->memcacheFactory = \OC::$server->getMemCacheFactory();
|
$this->memcacheFactory = \OC::$server->getMemCacheFactory();
|
||||||
$this->httpClient = \OC::$server->getHTTPClientService();
|
$this->httpClient = $options['HttpClientService'];
|
||||||
$discoveryManager = new DiscoveryManager(
|
$discoveryManager = new DiscoveryManager(
|
||||||
$this->memcacheFactory,
|
$this->memcacheFactory,
|
||||||
\OC::$server->getHTTPClientService()
|
$this->httpClient
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->manager = $options['manager'];
|
$this->manager = $options['manager'];
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace OCA\Files_Sharing\Tests;
|
namespace OCA\Files_Sharing\Tests;
|
||||||
|
use OCP\Http\Client\IClient;
|
||||||
|
use OCP\Http\Client\IClientService;
|
||||||
|
use OCP\Http\Client\IResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the external Storage class for remote shares.
|
* Tests for the external Storage class for remote shares.
|
||||||
|
@ -69,6 +72,22 @@ class ExternalStorageTest extends \Test\TestCase {
|
||||||
|
|
||||||
private function getTestStorage($uri) {
|
private function getTestStorage($uri) {
|
||||||
$certificateManager = \OC::$server->getCertificateManager();
|
$certificateManager = \OC::$server->getCertificateManager();
|
||||||
|
$httpClientService = $this->createMock(IClientService::class);
|
||||||
|
$client = $this->createMock(IClient::class);
|
||||||
|
$response = $this->createMock(IResponse::class);
|
||||||
|
$client
|
||||||
|
->expects($this->any())
|
||||||
|
->method('get')
|
||||||
|
->willReturn($response);
|
||||||
|
$client
|
||||||
|
->expects($this->any())
|
||||||
|
->method('post')
|
||||||
|
->willReturn($response);
|
||||||
|
$httpClientService
|
||||||
|
->expects($this->any())
|
||||||
|
->method('newClient')
|
||||||
|
->willReturn($client);
|
||||||
|
|
||||||
return new TestSharingExternalStorage(
|
return new TestSharingExternalStorage(
|
||||||
array(
|
array(
|
||||||
'remote' => $uri,
|
'remote' => $uri,
|
||||||
|
@ -77,7 +96,8 @@ class ExternalStorageTest extends \Test\TestCase {
|
||||||
'token' => 'abcdef',
|
'token' => 'abcdef',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
'manager' => null,
|
'manager' => null,
|
||||||
'certificateManager' => $certificateManager
|
'certificateManager' => $certificateManager,
|
||||||
|
'HttpClientService' => $httpClientService,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue