diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-09-29 00:03:29 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-09-29 00:06:56 +0200 |
commit | bd70221d61b7467e2ab3eaf20243f114c0787989 (patch) | |
tree | 221a1a3b912b49696742adbcb71e56e43f2047a0 /apps/federatedfilesharing/tests | |
parent | 2eab2ffa22451851601d68bd73e0285a8803990e (diff) | |
download | nextcloud-server-bd70221d61b7467e2ab3eaf20243f114c0787989.tar.gz nextcloud-server-bd70221d61b7467e2ab3eaf20243f114c0787989.zip |
Mock HTTPClientService
These tests were not using any kind of mocks at all! This made the test execution time took 2 minutes instead of now less than 1 second… (because multiple HTTP requests were queued and timed-out then…)
See https://blackfire.io/profiles/compare/6d2611f2-ad08-47b6-973b-2b5f9c8b96d2/graph for reference
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'apps/federatedfilesharing/tests')
-rw-r--r-- | apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php index 8e1000fb500..18d698d398e 100644 --- a/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php +++ b/apps/federatedfilesharing/tests/Controller/RequestHandlerControllerTest.php @@ -31,6 +31,9 @@ use OC\Files\Filesystem; use OCA\FederatedFileSharing\DiscoveryManager; use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\FederatedFileSharing\Controller\RequestHandlerController; +use OCP\Http\Client\IClient; +use OCP\Http\Client\IClientService; +use OCP\Http\Client\IResponse; use OCP\IUserManager; use OCP\Share\IShare; @@ -242,15 +245,31 @@ class RequestHandlerControllerTest extends TestCase { function testDeleteUser($toDelete, $expected, $remainingUsers) { $this->createDummyS2SShares(); + $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); + $discoveryManager = new DiscoveryManager( \OC::$server->getMemCacheFactory(), - \OC::$server->getHTTPClientService() + $httpClientService ); $manager = new \OCA\Files_Sharing\External\Manager( \OC::$server->getDatabaseConnection(), Filesystem::getMountManager(), Filesystem::getLoader(), - \OC::$server->getHTTPClientService(), + $httpClientService, \OC::$server->getNotificationManager(), $discoveryManager, $toDelete |