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/lib/AppFramework/Middleware | |
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/lib/AppFramework/Middleware')
5 files changed, 48 insertions, 51 deletions
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(); } |