From 62485ed08f2ae12c1c6dc92d1b9be020c67001ca Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 31 Aug 2016 20:54:17 +0200 Subject: [PATCH] Fix deprecated getMock call in Federation app --- .../BackgroundJob/GetSharedSecretTest.php | 14 +++++++------- .../BackgroundJob/RequestSharedSecretTest.php | 12 ++++++------ .../Controller/SettingsControllerTest.php | 9 ++++++--- apps/federation/tests/DbHandlerTest.php | 2 +- .../Middleware/AddServerMiddlewareTest.php | 7 ++++--- apps/federation/tests/TrustedServersTest.php | 18 +++++++++--------- 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php b/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php index 0746c517fa7af..fe7cc5cc3372f 100644 --- a/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php +++ b/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php @@ -73,15 +73,15 @@ class GetSharedSecretTest extends TestCase { public function setUp() { parent::setUp(); - $this->httpClient = $this->getMock('OCP\Http\Client\IClient'); - $this->jobList = $this->getMock('OCP\BackgroundJob\IJobList'); - $this->urlGenerator = $this->getMock('OCP\IURLGenerator'); - $this->trustedServers = $this->getMockBuilder('OCA\Federation\TrustedServers') + $this->httpClient = $this->getMockBuilder(IClient::class)->getMock(); + $this->jobList = $this->getMockBuilder(IJobList::class)->getMock(); + $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->getMock(); + $this->trustedServers = $this->getMockBuilder(TrustedServers::class) ->disableOriginalConstructor()->getMock(); - $this->dbHandler = $this->getMockBuilder('OCA\Federation\DbHandler') + $this->dbHandler = $this->getMockBuilder(DbHandler::class) ->disableOriginalConstructor()->getMock(); - $this->logger = $this->getMock('OCP\ILogger'); - $this->response = $this->getMock('OCP\Http\Client\IResponse'); + $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); + $this->response = $this->getMockBuilder(IResponse::class)->getMock(); $this->getSharedSecret = new GetSharedSecret( $this->httpClient, diff --git a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php index 339a2cbad006e..3fa2ca2973ec2 100644 --- a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php +++ b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php @@ -61,14 +61,14 @@ class RequestSharedSecretTest extends TestCase { public function setUp() { parent::setUp(); - $this->httpClient = $this->getMock('OCP\Http\Client\IClient'); - $this->jobList = $this->getMock('OCP\BackgroundJob\IJobList'); - $this->urlGenerator = $this->getMock('OCP\IURLGenerator'); - $this->trustedServers = $this->getMockBuilder('OCA\Federation\TrustedServers') + $this->httpClient = $this->getMockBuilder(IClient::class)->getMock(); + $this->jobList = $this->getMockBuilder(IJobList::class)->getMock(); + $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->getMock(); + $this->trustedServers = $this->getMockBuilder(TrustedServers::class) ->disableOriginalConstructor()->getMock(); - $this->dbHandler = $this->getMockBuilder('OCA\Federation\DbHandler') + $this->dbHandler = $this->getMockBuilder(DbHandler::class) ->disableOriginalConstructor()->getMock(); - $this->response = $this->getMock('OCP\Http\Client\IResponse'); + $this->response = $this->getMockBuilder(IResponse::class)->getMock(); $this->requestSharedSecret = new RequestSharedSecret( $this->httpClient, diff --git a/apps/federation/tests/Controller/SettingsControllerTest.php b/apps/federation/tests/Controller/SettingsControllerTest.php index e73d1f47cdd52..2f93ebfeaa13e 100644 --- a/apps/federation/tests/Controller/SettingsControllerTest.php +++ b/apps/federation/tests/Controller/SettingsControllerTest.php @@ -25,7 +25,10 @@ use OCA\Federation\Controller\SettingsController; +use OCA\Federation\TrustedServers; use OCP\AppFramework\Http\DataResponse; +use OCP\IL10N; +use OCP\IRequest; use Test\TestCase; class SettingsControllerTest extends TestCase { @@ -45,9 +48,9 @@ class SettingsControllerTest extends TestCase { public function setUp() { parent::setUp(); - $this->request = $this->getMock('OCP\IRequest'); - $this->l10n = $this->getMock('OCP\IL10N'); - $this->trustedServers = $this->getMockBuilder('OCA\Federation\TrustedServers') + $this->request = $this->getMockBuilder(IRequest::class)->getMock(); + $this->l10n = $this->getMockBuilder(IL10N::class)->getMock(); + $this->trustedServers = $this->getMockBuilder(TrustedServers::class) ->disableOriginalConstructor()->getMock(); $this->controller = new SettingsController( diff --git a/apps/federation/tests/DbHandlerTest.php b/apps/federation/tests/DbHandlerTest.php index f27317cfad9e1..d9f9cf162b665 100644 --- a/apps/federation/tests/DbHandlerTest.php +++ b/apps/federation/tests/DbHandlerTest.php @@ -53,7 +53,7 @@ public function setUp() { parent::setUp(); $this->connection = \OC::$server->getDatabaseConnection(); - $this->il10n = $this->getMock('OCP\IL10N'); + $this->il10n = $this->getMockBuilder(IL10N::class)->getMock(); $this->dbHandler = new DbHandler( $this->connection, diff --git a/apps/federation/tests/Middleware/AddServerMiddlewareTest.php b/apps/federation/tests/Middleware/AddServerMiddlewareTest.php index 9eed79b0db00f..b2096cb373044 100644 --- a/apps/federation/tests/Middleware/AddServerMiddlewareTest.php +++ b/apps/federation/tests/Middleware/AddServerMiddlewareTest.php @@ -29,6 +29,7 @@ use OCA\Federation\Middleware\AddServerMiddleware; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; +use OCP\IL10N; use OCP\ILogger; use Test\TestCase; @@ -49,9 +50,9 @@ class AddServerMiddlewareTest extends TestCase { public function setUp() { parent::setUp(); - $this->logger = $this->getMock('OCP\ILogger'); - $this->l10n = $this->getMock('OCP\IL10N'); - $this->controller = $this->getMockBuilder('OCP\AppFramework\Controller') + $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); + $this->l10n = $this->getMockBuilder(IL10N::class)->getMock(); + $this->controller = $this->getMockBuilder(Controller::class) ->disableOriginalConstructor()->getMock(); $this->middleware = new AddServerMiddleware( diff --git a/apps/federation/tests/TrustedServersTest.php b/apps/federation/tests/TrustedServersTest.php index 1bf1475aef225..d16c0908dd4ff 100644 --- a/apps/federation/tests/TrustedServersTest.php +++ b/apps/federation/tests/TrustedServersTest.php @@ -74,17 +74,17 @@ class TrustedServersTest extends TestCase { public function setUp() { parent::setUp(); - $this->dbHandler = $this->getMockBuilder('\OCA\Federation\DbHandler') + $this->dbHandler = $this->getMockBuilder(DbHandler::class) ->disableOriginalConstructor()->getMock(); - $this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface') + $this->dispatcher = $this->getMockBuilder(EventDispatcherInterface::class) ->disableOriginalConstructor()->getMock(); - $this->httpClientService = $this->getMock('OCP\Http\Client\IClientService'); - $this->httpClient = $this->getMock('OCP\Http\Client\IClient'); - $this->response = $this->getMock('OCP\Http\Client\IResponse'); - $this->logger = $this->getMock('OCP\ILogger'); - $this->jobList = $this->getMock('OCP\BackgroundJob\IJobList'); - $this->secureRandom = $this->getMock('OCP\Security\ISecureRandom'); - $this->config = $this->getMock('OCP\IConfig'); + $this->httpClientService = $this->getMockBuilder(IClientService::class)->getMock(); + $this->httpClient = $this->getMockBuilder(IClient::class)->getMock(); + $this->response = $this->getMockBuilder(IResponse::class)->getMock(); + $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); + $this->jobList = $this->getMockBuilder(IJobList::class)->getMock(); + $this->secureRandom = $this->getMockBuilder(ISecureRandom::class)->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->trustedServers = new TrustedServers( $this->dbHandler,