diff options
Diffstat (limited to 'tests/lib/AppFramework/Middleware')
3 files changed, 36 insertions, 36 deletions
diff --git a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php index 773e900545f..617ead473c0 100644 --- a/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/AdditionalScriptsMiddlewareTest.php @@ -82,7 +82,7 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase { public function testStandaloneTemplateResponse() { $this->dispatcher->expects($this->once()) ->method('dispatch') - ->willReturnCallback(function($eventName) { + ->willReturnCallback(function ($eventName) { if ($eventName === TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS) { return; } @@ -98,7 +98,7 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase { public function testTemplateResponseNotLoggedIn() { $this->dispatcher->expects($this->once()) ->method('dispatch') - ->willReturnCallback(function($eventName) { + ->willReturnCallback(function ($eventName) { if ($eventName === TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS) { return; } @@ -116,7 +116,7 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase { $this->dispatcher->expects($this->exactly(2)) ->method('dispatch') - ->willReturnCallback(function($eventName) use (&$events) { + ->willReturnCallback(function ($eventName) use (&$events) { if ($eventName === TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS || $eventName === TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN) { $events[] = $eventName; diff --git a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php index 69dd6d16226..5f0517016dd 100644 --- a/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php +++ b/tests/lib/AppFramework/Middleware/MiddlewareDispatcherTest.php @@ -60,7 +60,7 @@ class TestMiddleware extends Middleware { $this->beforeControllerThrowsEx = $beforeControllerThrowsEx; } - public function beforeController($controller, $methodName){ + public function beforeController($controller, $methodName) { self::$beforeControllerCalled++; $this->beforeControllerOrder = self::$beforeControllerCalled; $this->controller = $controller; @@ -70,7 +70,7 @@ class TestMiddleware extends Middleware { } } - public function afterException($controller, $methodName, \Exception $exception){ + public function afterException($controller, $methodName, \Exception $exception) { self::$afterExceptionCalled++; $this->afterExceptionOrder = self::$afterExceptionCalled; $this->controller = $controller; @@ -79,7 +79,7 @@ class TestMiddleware extends Middleware { parent::afterException($controller, $methodName, $exception); } - public function afterController($controller, $methodName, Response $response){ + public function afterController($controller, $methodName, Response $response) { self::$afterControllerCalled++; $this->afterControllerOrder = self::$afterControllerCalled; $this->controller = $controller; @@ -88,7 +88,7 @@ class TestMiddleware extends Middleware { return parent::afterController($controller, $methodName, $response); } - public function beforeOutput($controller, $methodName, $output){ + public function beforeOutput($controller, $methodName, $output) { self::$beforeOutputCalled++; $this->beforeOutputOrder = self::$beforeOutputCalled; $this->controller = $controller; @@ -124,7 +124,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - private function getControllerMock(){ + private function getControllerMock() { return $this->getMockBuilder('OCP\AppFramework\Controller') ->setMethods(['method']) ->setConstructorArgs(['app', @@ -137,14 +137,14 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - private function getMiddleware($beforeControllerThrowsEx=false){ + private function getMiddleware($beforeControllerThrowsEx=false) { $m1 = new TestMiddleware($beforeControllerThrowsEx); $this->dispatcher->registerMiddleware($m1); return $m1; } - public function testAfterExceptionShouldReturnResponseOfMiddleware(){ + public function testAfterExceptionShouldReturnResponseOfMiddleware() { $response = new Response(); $m1 = $this->getMockBuilder('\OCP\AppFramework\Middleware') ->setMethods(['afterException', 'beforeController']) @@ -167,7 +167,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testAfterExceptionShouldThrowAgainWhenNotHandled(){ + public function testAfterExceptionShouldThrowAgainWhenNotHandled() { $m1 = new TestMiddleware(false); $m2 = new TestMiddleware(true); @@ -180,7 +180,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testBeforeControllerCorrectArguments(){ + public function testBeforeControllerCorrectArguments() { $m1 = $this->getMiddleware(); $this->dispatcher->beforeController($this->controller, $this->method); @@ -189,7 +189,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testAfterControllerCorrectArguments(){ + public function testAfterControllerCorrectArguments() { $m1 = $this->getMiddleware(); $this->dispatcher->afterController($this->controller, $this->method, $this->response); @@ -200,7 +200,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testAfterExceptionCorrectArguments(){ + public function testAfterExceptionCorrectArguments() { $m1 = $this->getMiddleware(); $this->expectException(\Exception::class); @@ -214,7 +214,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testBeforeOutputCorrectArguments(){ + public function testBeforeOutputCorrectArguments() { $m1 = $this->getMiddleware(); $this->dispatcher->beforeOutput($this->controller, $this->method, $this->out); @@ -225,7 +225,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testBeforeControllerOrder(){ + public function testBeforeControllerOrder() { $m1 = $this->getMiddleware(); $m2 = $this->getMiddleware(); @@ -235,7 +235,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { $this->assertEquals(2, $m2->beforeControllerOrder); } - public function testAfterControllerOrder(){ + public function testAfterControllerOrder() { $m1 = $this->getMiddleware(); $m2 = $this->getMiddleware(); @@ -246,7 +246,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testAfterExceptionOrder(){ + public function testAfterExceptionOrder() { $m1 = $this->getMiddleware(); $m2 = $this->getMiddleware(); @@ -259,7 +259,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testBeforeOutputOrder(){ + public function testBeforeOutputOrder() { $m1 = $this->getMiddleware(); $m2 = $this->getMiddleware(); @@ -270,7 +270,7 @@ class MiddlewareDispatcherTest extends \Test\TestCase { } - public function testExceptionShouldRunAfterExceptionOfOnlyPreviouslyExecutedMiddlewares(){ + public function testExceptionShouldRunAfterExceptionOfOnlyPreviouslyExecutedMiddlewares() { $m1 = $this->getMiddleware(); $m2 = $this->getMiddleware(true); $m3 = $this->getMockBuilder('\OCP\AppFramework\Middleware')->getMock(); diff --git a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php index 85e1ac4e205..422087241f6 100644 --- a/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php +++ b/tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php @@ -112,7 +112,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @PublicPage * @NoCSRFRequired */ - public function testSetNavigationEntry(){ + public function testSetNavigationEntry() { $this->navigationManager->expects($this->once()) ->method('setActiveEntry') ->with($this->equalTo('files')); @@ -208,7 +208,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @PublicPage * @NoCSRFRequired */ - public function testNoChecks(){ + public function testNoChecks() { $this->request->expects($this->never()) ->method('passesCSRFCheck') ->willReturn(false); @@ -224,7 +224,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @param string $method * @param string $expects */ - private function securityCheck($method, $expects, $shouldFail=false){ + private function securityCheck($method, $expects, $shouldFail=false) { // admin check requires login if ($expects === 'isAdminUser') { $isLoggedIn = true; @@ -250,7 +250,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { /** * @PublicPage */ - public function testCsrfCheck(){ + public function testCsrfCheck() { $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException::class); $this->request->expects($this->once()) @@ -268,7 +268,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @PublicPage * @NoCSRFRequired */ - public function testNoCsrfCheck(){ + public function testNoCsrfCheck() { $this->request->expects($this->never()) ->method('passesCSRFCheck') ->willReturn(false); @@ -280,7 +280,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { /** * @PublicPage */ - public function testPassesCsrfCheck(){ + public function testPassesCsrfCheck() { $this->request->expects($this->once()) ->method('passesCSRFCheck') ->willReturn(true); @@ -295,7 +295,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { /** * @PublicPage */ - public function testFailCsrfCheck(){ + public function testFailCsrfCheck() { $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException::class); $this->request->expects($this->once()) @@ -411,7 +411,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @NoCSRFRequired * @NoAdminRequired */ - public function testLoggedInCheck(){ + public function testLoggedInCheck() { $this->securityCheck(__FUNCTION__, 'isLoggedIn'); } @@ -420,7 +420,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @NoCSRFRequired * @NoAdminRequired */ - public function testFailLoggedInCheck(){ + public function testFailLoggedInCheck() { $this->securityCheck(__FUNCTION__, 'isLoggedIn', true); } @@ -428,7 +428,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { /** * @NoCSRFRequired */ - public function testIsAdminCheck(){ + public function testIsAdminCheck() { $this->securityCheck(__FUNCTION__, 'isAdminUser'); } @@ -436,7 +436,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @NoCSRFRequired * @SubAdminRequired */ - public function testIsNotSubAdminCheck(){ + public function testIsNotSubAdminCheck() { $this->reader->reflect(__CLASS__,__FUNCTION__); $sec = $this->getMiddleware(true, false, false); @@ -448,7 +448,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @NoCSRFRequired * @SubAdminRequired */ - public function testIsSubAdminCheck(){ + public function testIsSubAdminCheck() { $this->reader->reflect(__CLASS__,__FUNCTION__); $sec = $this->getMiddleware(true, false, true); @@ -460,7 +460,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { * @NoCSRFRequired * @SubAdminRequired */ - public function testIsSubAdminAndAdminCheck(){ + public function testIsSubAdminAndAdminCheck() { $this->reader->reflect(__CLASS__,__FUNCTION__); $sec = $this->getMiddleware(true, true, true); @@ -471,12 +471,12 @@ class SecurityMiddlewareTest extends \Test\TestCase { /** * @NoCSRFRequired */ - public function testFailIsAdminCheck(){ + public function testFailIsAdminCheck() { $this->securityCheck(__FUNCTION__, 'isAdminUser', true); } - public function testAfterExceptionNotCaughtThrowsItAgain(){ + public function testAfterExceptionNotCaughtThrowsItAgain() { $ex = new \Exception(); $this->expectException(\Exception::class); $this->middleware->afterException($this->controller, 'test', $ex); @@ -588,7 +588,7 @@ class SecurityMiddlewareTest extends \Test\TestCase { $this->assertEquals($expected , $response); } - public function testAfterAjaxExceptionReturnsJSONError(){ + public function testAfterAjaxExceptionReturnsJSONError() { $response = $this->middleware->afterException($this->controller, 'test', $this->secAjaxException); |