diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2017-03-09 11:36:54 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-04-11 15:04:01 +0200 |
commit | 821e2878057343dcd6df9ce28b4885e3144ca318 (patch) | |
tree | a5ec63e57d387c40a2cda01ebe03957a9ac9647e /apps/federation/tests | |
parent | d5dec527c964fd08b91f9ab6ffeea228ca214ad6 (diff) | |
download | nextcloud-server-821e2878057343dcd6df9ce28b4885e3144ca318.tar.gz nextcloud-server-821e2878057343dcd6df9ce28b4885e3144ca318.zip |
adjust existing tests
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/federation/tests')
3 files changed, 38 insertions, 8 deletions
diff --git a/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php b/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php index fe7cc5cc337..6364ddaedff 100644 --- a/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php +++ b/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php @@ -36,6 +36,7 @@ use OCP\Http\Client\IClient; use OCP\Http\Client\IResponse; use OCP\ILogger; use OCP\IURLGenerator; +use OCP\OCS\IDiscoveryService; /** * Class GetSharedSecretTest @@ -67,6 +68,9 @@ class GetSharedSecretTest extends TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject | IResponse */ private $response; + /** @var \PHPUnit_Framework_MockObject_MockObject | IDiscoveryService */ + private $discoverService; + /** @var GetSharedSecret */ private $getSharedSecret; @@ -82,6 +86,9 @@ class GetSharedSecretTest extends TestCase { ->disableOriginalConstructor()->getMock(); $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); $this->response = $this->getMockBuilder(IResponse::class)->getMock(); + $this->discoverService = $this->getMockBuilder(IDiscoveryService::class)->getMock(); + + $this->discoverService->expects($this->any())->method('discover')->willReturn([]); $this->getSharedSecret = new GetSharedSecret( $this->httpClient, @@ -89,7 +96,8 @@ class GetSharedSecretTest extends TestCase { $this->jobList, $this->trustedServers, $this->logger, - $this->dbHandler + $this->dbHandler, + $this->discoverService ); } @@ -109,7 +117,8 @@ class GetSharedSecretTest extends TestCase { $this->jobList, $this->trustedServers, $this->logger, - $this->dbHandler + $this->dbHandler, + $this->discoverService ] )->setMethods(['parentExecute'])->getMock(); $this->invokePrivate($getSharedSecret, 'argument', [['url' => 'url']]); diff --git a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php index 3fa2ca2973e..06da29d17fc 100644 --- a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php +++ b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php @@ -33,6 +33,7 @@ use OCP\BackgroundJob\IJobList; use OCP\Http\Client\IClient; use OCP\Http\Client\IResponse; use OCP\IURLGenerator; +use OCP\OCS\IDiscoveryService; use Test\TestCase; class RequestSharedSecretTest extends TestCase { @@ -55,6 +56,9 @@ class RequestSharedSecretTest extends TestCase { /** @var \PHPUnit_Framework_MockObject_MockObject | IResponse */ private $response; + /** @var \PHPUnit_Framework_MockObject_MockObject | IDiscoveryService */ + private $discoveryService; + /** @var RequestSharedSecret */ private $requestSharedSecret; @@ -69,13 +73,17 @@ class RequestSharedSecretTest extends TestCase { $this->dbHandler = $this->getMockBuilder(DbHandler::class) ->disableOriginalConstructor()->getMock(); $this->response = $this->getMockBuilder(IResponse::class)->getMock(); + $this->discoveryService = $this->getMockBuilder(IDiscoveryService::class)->getMock(); + + $this->discoveryService->expects($this->any())->method('discover')->willReturn([]); $this->requestSharedSecret = new RequestSharedSecret( $this->httpClient, $this->urlGenerator, $this->jobList, $this->trustedServers, - $this->dbHandler + $this->dbHandler, + $this->discoveryService ); } @@ -94,7 +102,8 @@ class RequestSharedSecretTest extends TestCase { $this->urlGenerator, $this->jobList, $this->trustedServers, - $this->dbHandler + $this->dbHandler, + $this->discoveryService ] )->setMethods(['parentExecute'])->getMock(); $this->invokePrivate($requestSharedSecret, 'argument', [['url' => 'url']]); diff --git a/apps/federation/tests/SyncFederationAddressbooksTest.php b/apps/federation/tests/SyncFederationAddressbooksTest.php index 1a2dbf1bcae..9ce5efeb457 100644 --- a/apps/federation/tests/SyncFederationAddressbooksTest.php +++ b/apps/federation/tests/SyncFederationAddressbooksTest.php @@ -24,6 +24,7 @@ */ namespace OCA\Federation\Tests; +use OC\OCS\DiscoveryService; use OCA\Federation\DbHandler; use OCA\Federation\SyncFederationAddressBooks; @@ -32,7 +33,18 @@ class SyncFederationAddressbooksTest extends \Test\TestCase { /** @var array */ private $callBacks = []; - function testSync() { + /** @var \PHPUnit_Framework_MockObject_MockObject | DiscoveryService */ + private $discoveryService; + + public function setUp() { + parent::setUp(); + + $this->discoveryService = $this->getMockBuilder(DiscoveryService::class) + ->disableOriginalConstructor()->getMock(); + $this->discoveryService->expects($this->any())->method('discover')->willReturn([]); + } + + public function testSync() { /** @var DbHandler | \PHPUnit_Framework_MockObject_MockObject $dbHandler */ $dbHandler = $this->getMockBuilder('OCA\Federation\DbHandler')-> disableOriginalConstructor()-> @@ -55,14 +67,14 @@ class SyncFederationAddressbooksTest extends \Test\TestCase { ->willReturn(1); /** @var \OCA\DAV\CardDAV\SyncService $syncService */ - $s = new SyncFederationAddressBooks($dbHandler, $syncService); + $s = new SyncFederationAddressBooks($dbHandler, $syncService, $this->discoveryService); $s->syncThemAll(function($url, $ex) { $this->callBacks[] = [$url, $ex]; }); $this->assertEquals(1, count($this->callBacks)); } - function testException() { + public function testException() { /** @var DbHandler | \PHPUnit_Framework_MockObject_MockObject $dbHandler */ $dbHandler = $this->getMockBuilder('OCA\Federation\DbHandler')-> disableOriginalConstructor()-> @@ -83,7 +95,7 @@ class SyncFederationAddressbooksTest extends \Test\TestCase { ->willThrowException(new \Exception('something did not work out')); /** @var \OCA\DAV\CardDAV\SyncService $syncService */ - $s = new SyncFederationAddressBooks($dbHandler, $syncService); + $s = new SyncFederationAddressBooks($dbHandler, $syncService, $this->discoveryService); $s->syncThemAll(function($url, $ex) { $this->callBacks[] = [$url, $ex]; }); |