]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix phpunit-5.4 wargning
authorRoeland Jago Douma <roeland@famdouma.nl>
Sun, 10 Jul 2016 12:17:26 +0000 (14:17 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Mon, 11 Jul 2016 06:50:07 +0000 (08:50 +0200)
* getMock is deprecated.
* \PDOStatement mocking fails hard on phpunit 4.8

13 files changed:
tests/lib/AppFramework/Controller/ApiControllerTest.php
tests/lib/AppFramework/Controller/ControllerTest.php
tests/lib/AppFramework/Controller/OCSControllerTest.php
tests/lib/AppFramework/DependencyInjection/DIContainerTest.php
tests/lib/AppFramework/Http/DispatcherTest.php
tests/lib/AppFramework/Http/StreamResponseTest.php
tests/lib/AppFramework/Http/TemplateResponseTest.php
tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php
tests/lib/AppFramework/Middleware/MiddlewareTest.php
tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php
tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
tests/lib/AppFramework/Routing/RoutingTest.php

index 783eecf93e5caf04e6bcf63f597cbdb551bc4b36..74231b8d6acab001deb60751f59d96ce873141d8 100644 (file)
@@ -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']);
+       }
 
 }
index 521799a46cec32009a6627c82e5fdae718424038..63cc2873575644279bfbc11087c8ed46beb823e0 100644 (file)
@@ -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'));
index f69740d4496658fb43385f6fceb4985f30abf485..7dcbd189cd5852a16c8c1665ee4634ed9aae60ef 100644 (file)
@@ -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"}}}';
index 5aa000fa25aaeadd541afb655e6eee4ccb1a223e..0edf96dd5a4bd1647207c0a47b6b4f13e27eb24c 100644 (file)
@@ -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'];
index 6df6f7fa7fe5659924908f2ff82039e2f121560e..c2d73adfd7b68c9cc3d92fdaddddfa3092973e9a 100644 (file)
@@ -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,
index 1f761d6b89c2e7854d0d4f08cbaf5acf2a9378c9..c082b36e0ace5c17c89b7d07e5d1609e5a0a5892 100644 (file)
@@ -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(){
index 87fb6864f78c2901b6ae84f23bdfda57e802d2f2..4f779e8c69793377f26afc502039838d4b3d8113 100644 (file)
@@ -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'));
index f81aca106d6d625bc563e5f95496bc00e27bc880..2b7a79bae2f62ecf301bf6d07b19aa2623a96b6a 100644 (file)
@@ -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())
index 013403a9a4abb1b2860c8f6ce25521d58e763113..c5c812839b2ee204c15fd323106e61c3748ff8bb 100644 (file)
@@ -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();
        }
 
 
index 54d2831d25f6a6b0b70bdc9fe0a0c1208a9f6d43..a0dbcc6872a266129ab7adc6219a37113d032c14 100644 (file)
@@ -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'));
index 8cdba76d8356a460996061cc5a59dee653e57214..a4f203bacd77e5911cfe80ca5e7b87a32adeeddd 100644 (file)
@@ -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
index 17fcc1904c1bfbe3ebccb2e113f02efb67b682db..af2045cb7c1e60184b9b8a70ba9283eccf03c6bf 100644 (file)
@@ -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();
        }
index 326c156af980850d78a60ae31b386450dea8b837..ce0866f05117885b6a60782ac42878763c0d60df 100644 (file)
@@ -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')