diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-03-25 22:21:27 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-03-25 22:21:27 +0100 |
commit | 2ee65f177e4f7e09ad2287f14d564e7068d322fb (patch) | |
tree | 39075e87ea7927e20e8956824cb7c49bf626b178 /tests/lib/AppFramework/Middleware | |
parent | 3cf321fdfc4235a87015a9af2f59c63220016c65 (diff) | |
download | nextcloud-server-2ee65f177e4f7e09ad2287f14d564e7068d322fb.tar.gz nextcloud-server-2ee65f177e4f7e09ad2287f14d564e7068d322fb.zip |
Use the shorter phpunit syntax for mocked return values
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests/lib/AppFramework/Middleware')
3 files changed, 18 insertions, 18 deletions
diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php index 965637cb4c4..4790e9baca7 100644 --- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php +++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php @@ -158,7 +158,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { ->getMock(); $m2->expects($this->once()) ->method('afterException') - ->will($this->returnValue($response)); + ->willReturn($response); $this->dispatcher->registerMiddleware($m1); $this->dispatcher->registerMiddleware($m2); @@ -282,7 +282,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { $m3->expects($this->never()) ->method('afterController'); $m3->method('beforeOutput') - ->will($this->returnArgument(2)); + ->willReturnArgument(2); $this->dispatcher->registerMiddleware($m3); diff --git a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php index 1c12a4aa153..691553a13d8 100644 --- a/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php @@ -140,7 +140,7 @@ class CORSMiddlewareTest extends \Test\TestCase { $this->session->expects($this->never()) ->method('logClientIn') ->with($this->equalTo('user'), $this->equalTo('pass')) - ->will($this->returnValue(true)); + ->willReturn(true); $this->reflector->reflect($this, __FUNCTION__); $middleware->beforeController($this->controller, __FUNCTION__); @@ -163,7 +163,7 @@ class CORSMiddlewareTest extends \Test\TestCase { $this->session->expects($this->once()) ->method('logClientIn') ->with($this->equalTo('user'), $this->equalTo('pass')) - ->will($this->returnValue(true)); + ->willReturn(true); $this->reflector->reflect($this, __FUNCTION__); $middleware = new CORSMiddleware($request, $this->reflector, $this->session, $this->throttler); @@ -215,7 +215,7 @@ class CORSMiddlewareTest extends \Test\TestCase { $this->session->expects($this->once()) ->method('logClientIn') ->with($this->equalTo('user'), $this->equalTo('pass')) - ->will($this->returnValue(false)); + ->willReturn(false); $this->reflector->reflect($this, __FUNCTION__); $middleware = new CORSMiddleware($request, $this->reflector, $this->session, $this->throttler); diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php index ae0e6ff484d..5a8260d7968 100644 --- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php @@ -218,7 +218,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { public function testNoChecks(){ $this->request->expects($this->never()) ->method('passesCSRFCheck') - ->will($this->returnValue(false)); + ->willReturn(false); $sec = $this->getMiddleware(false, false, false); @@ -262,10 +262,10 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->request->expects($this->once()) ->method('passesCSRFCheck') - ->will($this->returnValue(false)); + ->willReturn(false); $this->request->expects($this->once()) ->method('passesStrictCookieCheck') - ->will($this->returnValue(true)); + ->willReturn(true); $this->reader->reflect(__CLASS__, __FUNCTION__); $this->middleware->beforeController($this->controller, __FUNCTION__); } @@ -278,7 +278,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { public function testNoCsrfCheck(){ $this->request->expects($this->never()) ->method('passesCSRFCheck') - ->will($this->returnValue(false)); + ->willReturn(false); $this->reader->reflect(__CLASS__, __FUNCTION__); $this->middleware->beforeController($this->controller, __FUNCTION__); @@ -290,10 +290,10 @@ class SecurityMiddlewareTest extends \Test\TestCase { public function testPassesCsrfCheck(){ $this->request->expects($this->once()) ->method('passesCSRFCheck') - ->will($this->returnValue(true)); + ->willReturn(true); $this->request->expects($this->once()) ->method('passesStrictCookieCheck') - ->will($this->returnValue(true)); + ->willReturn(true); $this->reader->reflect(__CLASS__, __FUNCTION__); $this->middleware->beforeController($this->controller, __FUNCTION__); @@ -307,10 +307,10 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->request->expects($this->once()) ->method('passesCSRFCheck') - ->will($this->returnValue(false)); + ->willReturn(false); $this->request->expects($this->once()) ->method('passesStrictCookieCheck') - ->will($this->returnValue(true)); + ->willReturn(true); $this->reader->reflect(__CLASS__, __FUNCTION__); $this->middleware->beforeController($this->controller, __FUNCTION__); @@ -327,7 +327,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { ->method('passesCSRFCheck'); $this->request->expects($this->once()) ->method('passesStrictCookieCheck') - ->will($this->returnValue(false)); + ->willReturn(false); $this->reader->reflect(__CLASS__, __FUNCTION__); $this->middleware->beforeController($this->controller, __FUNCTION__); @@ -341,7 +341,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { public function testNoStrictCookieRequiredCheck() { $this->request->expects($this->never()) ->method('passesStrictCookieCheck') - ->will($this->returnValue(false)); + ->willReturn(false); $this->reader->reflect(__CLASS__, __FUNCTION__); $this->middleware->beforeController($this->controller, __FUNCTION__); @@ -393,7 +393,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { public function testCsrfOcsController(Controller $controller, bool $hasOcsApiHeader, bool $hasBearerAuth, bool $exception) { $this->request ->method('getHeader') - ->will(self::returnCallback(function ($header) use ($hasOcsApiHeader, $hasBearerAuth) { + ->willReturnCallback(function ($header) use ($hasOcsApiHeader, $hasBearerAuth) { if ($header === 'OCS-APIREQUEST' && $hasOcsApiHeader) { return 'true'; } @@ -401,7 +401,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { return 'Bearer TOKEN!'; } return ''; - })); + }); $this->request->expects($this->once()) ->method('passesStrictCookieCheck') ->willReturn(true); @@ -511,7 +511,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { 'redirect_url' => 'nextcloud/index.php/apps/specialapp', ] ) - ->will($this->returnValue('http://localhost/nextcloud/index.php/login?redirect_url=nextcloud/index.php/apps/specialapp')); + ->willReturn('http://localhost/nextcloud/index.php/login?redirect_url=nextcloud/index.php/apps/specialapp'); $this->logger ->expects($this->once()) ->method('logException'); |