diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-07-10 14:17:26 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-07-11 08:50:07 +0200 |
commit | 2fa9e672940012bfff5c3763d573158960416372 (patch) | |
tree | 558f3acefa54f5fc5303e3320795ac6855e2c0a7 /tests | |
parent | 67278d12e1f572d390722935f0eeb9aed34b708c (diff) | |
download | nextcloud-server-2fa9e672940012bfff5c3763d573158960416372.tar.gz nextcloud-server-2fa9e672940012bfff5c3763d573158960416372.zip |
Fix phpunit-5.4 wargning
* getMock is deprecated.
* \PDOStatement mocking fails hard on phpunit 4.8
Diffstat (limited to 'tests')
13 files changed, 185 insertions, 116 deletions
diff --git a/tests/lib/AppFramework/Controller/ApiControllerTest.php b/tests/lib/AppFramework/Controller/ApiControllerTest.php index 783eecf93e5..74231b8d6ac 100644 --- a/tests/lib/AppFramework/Controller/ApiControllerTest.php +++ b/tests/lib/AppFramework/Controller/ApiControllerTest.php @@ -32,27 +32,31 @@ class ChildApiController extends ApiController {}; class ApiControllerTest extends \Test\TestCase { - /** @var ChildApiController */ - protected $controller; - - public function testCors() { - $request = new Request( - ['server' => ['HTTP_ORIGIN' => 'test']], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') - ); - $this->controller = new ChildApiController('app', $request, 'verbs', - 'headers', 100); - - $response = $this->controller->preflightedCors(); - - $headers = $response->getHeaders(); - - $this->assertEquals('test', $headers['Access-Control-Allow-Origin']); - $this->assertEquals('verbs', $headers['Access-Control-Allow-Methods']); - $this->assertEquals('headers', $headers['Access-Control-Allow-Headers']); - $this->assertEquals('false', $headers['Access-Control-Allow-Credentials']); - $this->assertEquals(100, $headers['Access-Control-Max-Age']); - } + /** @var ChildApiController */ + protected $controller; + + public function testCors() { + $request = new Request( + ['server' => ['HTTP_ORIGIN' => 'test']], + $this->getMockBuilder('\OCP\Security\ISecureRandom') + ->disableOriginalConstructor() + ->getMock(), + $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock() + ); + $this->controller = new ChildApiController('app', $request, 'verbs', + 'headers', 100); + + $response = $this->controller->preflightedCors(); + + $headers = $response->getHeaders(); + + $this->assertEquals('test', $headers['Access-Control-Allow-Origin']); + $this->assertEquals('verbs', $headers['Access-Control-Allow-Methods']); + $this->assertEquals('headers', $headers['Access-Control-Allow-Headers']); + $this->assertEquals('false', $headers['Access-Control-Allow-Credentials']); + $this->assertEquals(100, $headers['Access-Control-Max-Age']); + } } diff --git a/tests/lib/AppFramework/Controller/ControllerTest.php b/tests/lib/AppFramework/Controller/ControllerTest.php index 521799a46ce..63cc2873575 100644 --- a/tests/lib/AppFramework/Controller/ControllerTest.php +++ b/tests/lib/AppFramework/Controller/ControllerTest.php @@ -76,12 +76,18 @@ class ControllerTest extends \Test\TestCase { 'session' => ['sezession' => 'kein'], 'method' => 'hi', ], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom') + ->disableOriginalConstructor() + ->getMock(), + $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock() ); - $this->app = $this->getMock('OC\AppFramework\DependencyInjection\DIContainer', - array('getAppName'), array('test')); + $this->app = $this->getMockBuilder('OC\AppFramework\DependencyInjection\DIContainer') + ->setMethods(['getAppName']) + ->setConstructorArgs(['test']) + ->getMock(); $this->app->expects($this->any()) ->method('getAppName') ->will($this->returnValue('apptemplate_advanced')); diff --git a/tests/lib/AppFramework/Controller/OCSControllerTest.php b/tests/lib/AppFramework/Controller/OCSControllerTest.php index f69740d4496..7dcbd189cd5 100644 --- a/tests/lib/AppFramework/Controller/OCSControllerTest.php +++ b/tests/lib/AppFramework/Controller/OCSControllerTest.php @@ -33,9 +33,6 @@ class ChildOCSController extends OCSController {} class OCSControllerTest extends \Test\TestCase { - - private $controller; - public function testCors() { $request = new Request( [ @@ -43,8 +40,12 @@ class OCSControllerTest extends \Test\TestCase { 'HTTP_ORIGIN' => 'test', ], ], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom') + ->disableOriginalConstructor() + ->getMock(), + $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock() ); $controller = new ChildOCSController('app', $request, 'verbs', 'headers', 100); @@ -64,8 +65,12 @@ class OCSControllerTest extends \Test\TestCase { public function testXML() { $controller = new ChildOCSController('app', new Request( [], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom') + ->disableOriginalConstructor() + ->getMock(), + $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock() )); $expected = "<?xml version=\"1.0\"?>\n" . "<ocs>\n" . @@ -96,8 +101,12 @@ class OCSControllerTest extends \Test\TestCase { public function testXMLDataResponse() { $controller = new ChildOCSController('app', new Request( [], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom') + ->disableOriginalConstructor() + ->getMock(), + $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock() )); $expected = "<?xml version=\"1.0\"?>\n" . "<ocs>\n" . @@ -128,8 +137,12 @@ class OCSControllerTest extends \Test\TestCase { public function testJSON() { $controller = new ChildOCSController('app', new Request( [], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom') + ->disableOriginalConstructor() + ->getMock(), + $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock() )); $expected = '{"ocs":{"meta":{"status":"failure","statuscode":400,"message":"OK",' . '"totalitems":"","itemsperpage":""},"data":{"test":"hi"}}}'; diff --git a/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php b/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php index 5aa000fa25a..0edf96dd5a4 100644 --- a/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php +++ b/tests/lib/AppFramework/DependencyInjection/DIContainerTest.php @@ -36,10 +36,13 @@ class DIContainerTest extends \Test\TestCase { protected function setUp(){ parent::setUp(); - $this->container = $this->getMock('OC\AppFramework\DependencyInjection\DIContainer', - ['isAdminUser'], ['name'] - ); - $this->api = $this->getMock('OC\AppFramework\Core\API', array(), array('hi')); + $this->container = $this->getMockBuilder('OC\AppFramework\DependencyInjection\DIContainer') + ->setMethods(['isAdminUser']) + ->setConstructorArgs(['name']) + ->getMock(); + $this->api = $this->getMockBuilder('OC\AppFramework\Core\API') + ->setConstructorArgs(['hi']) + ->getMock(); } public function testProvidesAPI(){ @@ -75,8 +78,12 @@ class DIContainerTest extends \Test\TestCase { public function testMiddlewareDispatcherIncludesSecurityMiddleware(){ $this->container['Request'] = new Request( ['method' => 'GET'], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom') + ->disableOriginalConstructor() + ->getMock(), + $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock() ); $security = $this->container['SecurityMiddleware']; $dispatcher = $this->container['MiddlewareDispatcher']; diff --git a/tests/lib/AppFramework/Http/DispatcherTest.php b/tests/lib/AppFramework/Http/DispatcherTest.php index 6df6f7fa7fe..c2d73adfd7b 100644 --- a/tests/lib/AppFramework/Http/DispatcherTest.php +++ b/tests/lib/AppFramework/Http/DispatcherTest.php @@ -105,9 +105,11 @@ class DispatcherTest extends \Test\TestCase { '\OC\AppFramework\Middleware\MiddlewareDispatcher') ->disableOriginalConstructor() ->getMock(); - $this->controller = $this->getMock( - '\OCP\AppFramework\Controller', - array($this->controllerMethod), array($app, $request)); + $this->controller = $this->getMockBuilder( + '\OCP\AppFramework\Controller') + ->setMethods([$this->controllerMethod]) + ->setConstructorArgs([$app, $request]) + ->getMock(); $this->request = $this->getMockBuilder( '\OC\AppFramework\Http\Request') @@ -296,8 +298,12 @@ class DispatcherTest extends \Test\TestCase { ], 'method' => 'POST' ], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom') + ->disableOriginalConstructor() + ->getMock(), + $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock() ); $this->dispatcher = new Dispatcher( $this->http, $this->middlewareDispatcher, $this->reflector, @@ -323,8 +329,12 @@ class DispatcherTest extends \Test\TestCase { ], 'method' => 'POST', ], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom') + ->disableOriginalConstructor() + ->getMock(), + $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock() ); $this->dispatcher = new Dispatcher( $this->http, $this->middlewareDispatcher, $this->reflector, @@ -353,8 +363,12 @@ class DispatcherTest extends \Test\TestCase { ], 'method' => 'GET' ], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom') + ->disableOriginalConstructor() + ->getMock(), + $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock() ); $this->dispatcher = new Dispatcher( $this->http, $this->middlewareDispatcher, $this->reflector, @@ -382,8 +396,12 @@ class DispatcherTest extends \Test\TestCase { ], 'method' => 'GET' ], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom') + ->disableOriginalConstructor() + ->getMock(), + $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock() ); $this->dispatcher = new Dispatcher( $this->http, $this->middlewareDispatcher, $this->reflector, @@ -412,8 +430,12 @@ class DispatcherTest extends \Test\TestCase { ], 'method' => 'PUT' ], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom') + ->disableOriginalConstructor() + ->getMock(), + $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock() ); $this->dispatcher = new Dispatcher( $this->http, $this->middlewareDispatcher, $this->reflector, @@ -444,8 +466,12 @@ class DispatcherTest extends \Test\TestCase { ], 'method' => 'POST' ], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom') + ->disableOriginalConstructor() + ->getMock(), + $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock() ); $this->dispatcher = new Dispatcher( $this->http, $this->middlewareDispatcher, $this->reflector, diff --git a/tests/lib/AppFramework/Http/StreamResponseTest.php b/tests/lib/AppFramework/Http/StreamResponseTest.php index 1f761d6b89c..c082b36e0ac 100644 --- a/tests/lib/AppFramework/Http/StreamResponseTest.php +++ b/tests/lib/AppFramework/Http/StreamResponseTest.php @@ -37,7 +37,9 @@ class StreamResponseTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->output = $this->getMock('OCP\\AppFramework\\Http\\IOutput'); + $this->output = $this->getMockBuilder('OCP\\AppFramework\\Http\\IOutput') + ->disableOriginalConstructor() + ->getMock(); } public function testOutputNotModified(){ diff --git a/tests/lib/AppFramework/Http/TemplateResponseTest.php b/tests/lib/AppFramework/Http/TemplateResponseTest.php index 87fb6864f78..4f779e8c697 100644 --- a/tests/lib/AppFramework/Http/TemplateResponseTest.php +++ b/tests/lib/AppFramework/Http/TemplateResponseTest.php @@ -43,8 +43,10 @@ class TemplateResponseTest extends \Test\TestCase { protected function setUp() { parent::setUp(); - $this->api = $this->getMock('OC\AppFramework\Core\API', - array('getAppName'), array('test')); + $this->api = $this->getMockBuilder('OC\AppFramework\Core\API') + ->setMethods(['getAppName']) + ->setConstructorArgs(['test']) + ->getMock(); $this->api->expects($this->any()) ->method('getAppName') ->will($this->returnValue('app')); diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php index f81aca106d6..2b7a79bae2f 100644 --- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php +++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php @@ -126,17 +126,15 @@ class MiddlewareDispatcherTest extends \Test\TestCase { private function getControllerMock(){ - return $this->getMock( - 'OCP\AppFramework\Controller', - ['method'], - ['app', + return $this->getMockBuilder('OCP\AppFramework\Controller') + ->setMethods(['method']) + ->setConstructorArgs(['app', new Request( ['method' => 'GET'], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ) - ] - ); + ])->getMock(); } @@ -149,13 +147,15 @@ class MiddlewareDispatcherTest extends \Test\TestCase { public function testAfterExceptionShouldReturnResponseOfMiddleware(){ $response = new Response(); - $m1 = $this->getMock('\OCP\AppFramework\Middleware', - array('afterException', 'beforeController')); + $m1 = $this->getMockBuilder('\OCP\AppFramework\Middleware') + ->setMethods(['afterException', 'beforeController']) + ->getMock(); $m1->expects($this->never()) ->method('afterException'); - $m2 = $this->getMock('OCP\AppFramework\Middleware', - array('afterException', 'beforeController')); + $m2 = $this->getMockBuilder('OCP\AppFramework\Middleware') + ->setMethods(['afterException', 'beforeController']) + ->getMock(); $m2->expects($this->once()) ->method('afterException') ->will($this->returnValue($response)); @@ -274,7 +274,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { public function testExceptionShouldRunAfterExceptionOfOnlyPreviouslyExecutedMiddlewares(){ $m1 = $this->getMiddleware(); $m2 = $this->getMiddleware(true); - $m3 = $this->getMock('\OCP\AppFramework\Middleware'); + $m3 = $this->getMockBuilder('\OCP\AppFramework\Middleware')->getMock(); $m3->expects($this->never()) ->method('afterException'); $m3->expects($this->never()) diff --git a/tests/lib/AppFramework/Middleware/MiddlewareTest.php b/tests/lib/AppFramework/Middleware/MiddlewareTest.php index 013403a9a4a..c5c812839b2 100644 --- a/tests/lib/AppFramework/Middleware/MiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/MiddlewareTest.php @@ -48,25 +48,22 @@ class MiddlewareTest extends \Test\TestCase { $this->middleware = new ChildMiddleware(); - $this->api = $this->getMockBuilder( - 'OC\AppFramework\DependencyInjection\DIContainer') + $this->api = $this->getMockBuilder('OC\AppFramework\DependencyInjection\DIContainer') ->disableOriginalConstructor() ->getMock(); - $this->controller = $this->getMock( - 'OCP\AppFramework\Controller', - [], - [ + $this->controller = $this->getMockBuilder('OCP\AppFramework\Controller') + ->setMethods([]) + ->setConstructorArgs([ $this->api, new Request( [], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ) - ] - ); + ])->getMock(); $this->exception = new \Exception(); - $this->response = $this->getMock('OCP\AppFramework\Http\Response'); + $this->response = $this->getMockBuilder('OCP\AppFramework\Http\Response')->getMock(); } diff --git a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php index 54d2831d25f..a0dbcc6872a 100644 --- a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php @@ -43,8 +43,8 @@ class CORSMiddlewareTest extends \Test\TestCase { 'HTTP_ORIGIN' => 'test' ] ], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ); $this->reflector->reflect($this, __FUNCTION__); $middleware = new CORSMiddleware($request, $this->reflector, $this->session); @@ -62,8 +62,8 @@ class CORSMiddlewareTest extends \Test\TestCase { 'HTTP_ORIGIN' => 'test' ] ], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ); $middleware = new CORSMiddleware($request, $this->reflector, $this->session); @@ -79,8 +79,8 @@ class CORSMiddlewareTest extends \Test\TestCase { public function testNoOriginHeaderNoCORSHEADER() { $request = new Request( [], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ); $this->reflector->reflect($this, __FUNCTION__); $middleware = new CORSMiddleware($request, $this->reflector, $this->session); @@ -102,8 +102,8 @@ class CORSMiddlewareTest extends \Test\TestCase { 'HTTP_ORIGIN' => 'test' ] ], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ); $this->reflector->reflect($this, __FUNCTION__); $middleware = new CORSMiddleware($request, $this->reflector, $this->session); @@ -120,8 +120,8 @@ class CORSMiddlewareTest extends \Test\TestCase { public function testNoCORSShouldAllowCookieAuth() { $request = new Request( [], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ); $this->reflector->reflect($this, __FUNCTION__); $middleware = new CORSMiddleware($request, $this->reflector, $this->session); @@ -145,8 +145,8 @@ class CORSMiddlewareTest extends \Test\TestCase { 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'pass' ]], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ); $this->session->expects($this->once()) ->method('logout'); @@ -170,8 +170,8 @@ class CORSMiddlewareTest extends \Test\TestCase { 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'pass' ]], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ); $this->session->expects($this->once()) ->method('logout'); @@ -195,8 +195,8 @@ class CORSMiddlewareTest extends \Test\TestCase { 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'pass' ]], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ); $this->session->expects($this->once()) ->method('logout'); @@ -216,8 +216,8 @@ class CORSMiddlewareTest extends \Test\TestCase { 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'pass' ]], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ); $middleware = new CORSMiddleware($request, $this->reflector, $this->session); $response = $middleware->afterException($this, __FUNCTION__, new SecurityException('A security exception')); @@ -232,8 +232,8 @@ class CORSMiddlewareTest extends \Test\TestCase { 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'pass' ]], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ); $middleware = new CORSMiddleware($request, $this->reflector, $this->session); $response = $middleware->afterException($this, __FUNCTION__, new SecurityException('A security exception', 501)); @@ -252,8 +252,8 @@ class CORSMiddlewareTest extends \Test\TestCase { 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'pass' ]], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ); $middleware = new CORSMiddleware($request, $this->reflector, $this->session); $middleware->afterException($this, __FUNCTION__, new \Exception('A regular exception')); diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php index 8cdba76d835..a4f203bacd7 100644 --- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php @@ -338,8 +338,8 @@ class SecurityMiddlewareTest extends \Test\TestCase { 'REQUEST_URI' => 'owncloud/index.php/apps/specialapp' ] ], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ); $this->middleware = $this->getMiddleware(false, false); $this->urlGenerator @@ -396,8 +396,8 @@ class SecurityMiddlewareTest extends \Test\TestCase { 'REQUEST_URI' => 'owncloud/index.php/apps/specialapp' ] ], - $this->getMock('\OCP\Security\ISecureRandom'), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), + $this->getMockBuilder('\OCP\IConfig')->getMock() ); $this->middleware = $this->getMiddleware(false, false); $this->logger diff --git a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php index 17fcc1904c1..af2045cb7c1 100644 --- a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php @@ -36,7 +36,7 @@ class SessionMiddlewareTest extends \Test\TestCase { $this->request = new Request( [], $this->getMockBuilder('\OCP\Security\ISecureRandom')->getMock(), - $this->getMock('\OCP\IConfig') + $this->getMockBuilder('\OCP\IConfig')->getMock() ); $this->reflector = new ControllerMethodReflector(); } diff --git a/tests/lib/AppFramework/Routing/RoutingTest.php b/tests/lib/AppFramework/Routing/RoutingTest.php index 326c156af98..ce0866f0511 100644 --- a/tests/lib/AppFramework/Routing/RoutingTest.php +++ b/tests/lib/AppFramework/Routing/RoutingTest.php @@ -74,7 +74,10 @@ class RoutingTest extends \Test\TestCase )); // router mock - $router = $this->getMock("\OC\Route\Router", array('create'), [\OC::$server->getLogger()]); + $router = $this->getMockBuilder('\OC\Route\Router') + ->setMethods(['create']) + ->setConstructorArgs([\OC::$server->getLogger()]) + ->getMock(); // load route configuration $container = new DIContainer('app1'); @@ -124,7 +127,10 @@ class RoutingTest extends \Test\TestCase $route = $this->mockRoute($container, $verb, $controllerName, $actionName, $requirements, $defaults); // router mock - $router = $this->getMock("\OC\Route\Router", array('create'), [\OC::$server->getLogger()]); + $router = $this->getMockBuilder('\OC\Route\Router') + ->setMethods(['create']) + ->setConstructorArgs([\OC::$server->getLogger()]) + ->getMock(); // we expect create to be called once: $router @@ -148,7 +154,10 @@ class RoutingTest extends \Test\TestCase private function assertResource($yaml, $resourceName, $url, $controllerName, $paramName) { // router mock - $router = $this->getMock("\OC\Route\Router", array('create'), [\OC::$server->getLogger()]); + $router = $this->getMockBuilder('\OC\Route\Router') + ->setMethods(['create']) + ->setConstructorArgs([\OC::$server->getLogger()]) + ->getMock(); // route mocks $container = new DIContainer('app1'); @@ -214,7 +223,10 @@ class RoutingTest extends \Test\TestCase array $requirements=array(), array $defaults=array() ) { - $route = $this->getMock("\OC\Route\Route", array('method', 'action', 'requirements', 'defaults'), array(), '', false); + $route = $this->getMockBuilder('\OC\Route\Route') + ->setMethods(['method', 'action', 'requirements', 'defaults']) + ->disableOriginalConstructor() + ->getMock(); $route ->expects($this->exactly(1)) ->method('method') |