diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2018-06-12 16:20:53 +0200 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2018-07-02 11:29:30 +0200 |
commit | 9365fd2534eeff4cc0804a1ee794ed89b986bb1d (patch) | |
tree | 3285af34a7b992e4bc07b28738f1f247010a3e8e /apps | |
parent | 2e19213695d8bf9bc55eb57f4db9c7f04e8cc6fe (diff) | |
download | nextcloud-server-9365fd2534eeff4cc0804a1ee794ed89b986bb1d.tar.gz nextcloud-server-9365fd2534eeff4cc0804a1ee794ed89b986bb1d.zip |
fix external manager tests
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/tests/External/ManagerTest.php | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index 6756f91fb70..2cc88160a8c 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -32,6 +32,8 @@ use OC\Files\Storage\StorageFactory; use OCA\Files_Sharing\External\Manager; use OCA\Files_Sharing\External\MountProvider; use OCA\Files_Sharing\Tests\TestCase; +use OCP\Federation\ICloudFederationFactory; +use OCP\Federation\ICloudFederationProviderManager; use OCP\Http\Client\IClientService; use Test\Traits\UserTrait; @@ -45,7 +47,7 @@ use Test\Traits\UserTrait; class ManagerTest extends TestCase { use UserTrait; - /** @var Manager **/ + /** @var Manager|\PHPUnit_Framework_MockObject_MockObject **/ private $manager; /** @var \OC\Files\Mount\Manager */ @@ -54,6 +56,12 @@ class ManagerTest extends TestCase { /** @var IClientService|\PHPUnit_Framework_MockObject_MockObject */ private $clientService; + /** @var ICloudFederationProviderManager|\PHPUnit_Framework_MockObject_MockObject */ + private $cloudFederationProviderManager; + + /** @var ICloudFederationFactory|\PHPUnit_Framework_MockObject_MockObject */ + private $cloudFederationFactory; + private $uid; /** @@ -71,16 +79,24 @@ class ManagerTest extends TestCase { $this->mountManager = new \OC\Files\Mount\Manager(); $this->clientService = $this->getMockBuilder(IClientService::class) ->disableOriginalConstructor()->getMock(); + $this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class); + $this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class); + + $this->manager = $this->getMockBuilder(Manager::class) + ->setConstructorArgs( + [ + \OC::$server->getDatabaseConnection(), + $this->mountManager, + new StorageFactory(), + $this->clientService, + \OC::$server->getNotificationManager(), + \OC::$server->query(\OCP\OCS\IDiscoveryService::class), + $this->cloudFederationProviderManager, + $this->cloudFederationFactory, + $this->uid + ] + )->setMethods(['tryOCMEndPoint'])->getMock(); - $this->manager = new Manager( - \OC::$server->getDatabaseConnection(), - $this->mountManager, - new StorageFactory(), - $this->clientService, - \OC::$server->getNotificationManager(), - \OC::$server->query(\OCP\OCS\IDiscoveryService::class), - $this->uid - ); $this->testMountProvider = new MountProvider(\OC::$server->getDatabaseConnection(), function() { return $this->manager; }, new CloudIdManager()); @@ -109,6 +125,9 @@ class ManagerTest extends TestCase { $shareData3 = $shareData1; $shareData3['token'] = 'token3'; + $this->manager->expects($this->at(0))->method('tryOCMEndPoint')->with('http://localhost', 'token1', -1, 'accept')->willReturn(false); + $this->manager->expects($this->at(1))->method('tryOCMEndPoint')->with('http://localhost', 'token3', -1, 'decline')->willReturn(false); + // Add a share for "user" $this->assertSame(null, call_user_func_array([$this->manager, 'addShare'], $shareData1)); $openShares = $this->manager->getOpenShares(); |