Skip to content
Snippets Groups Projects
Commit c85621a8 authored by Thomas Tanghus's avatar Thomas Tanghus
Browse files

Make abstract Middleware class public

It doesn't make sense for subclasses to have to implement
all methods.
parent 485bb100
Branches
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@ namespace OC\AppFramework\Middleware;
use OC\AppFramework\Controller\Controller;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\IMiddleWare;
/**
* This class is used to store and run all the middleware in correct order
......@@ -58,7 +58,7 @@ class MiddlewareDispatcher {
* Adds a new middleware
* @param Middleware $middleware the middleware which will be added
*/
public function registerMiddleware(Middleware $middleWare){
public function registerMiddleware(IMiddleware $middleWare){
array_push($this->middlewares, $middleWare);
}
......
......@@ -29,8 +29,8 @@ use OC\AppFramework\Http\Http;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Http\RedirectResponse;
use OC\AppFramework\Utility\MethodAnnotationReader;
use OC\AppFramework\Middleware\Middleware;
use OC\AppFramework\Core\API;
use OCP\AppFramework\Middleware;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\JSONResponse;
......
......@@ -22,7 +22,7 @@
*/
namespace OC\AppFramework\Middleware;
namespace OCP\AppFramework;
use OCP\AppFramework\Http\Response;
......@@ -33,7 +33,7 @@ use OCP\AppFramework\Http\Response;
* They're modeled after Django's middleware system:
* https://docs.djangoproject.com/en/dev/topics/http/middleware/
*/
abstract class Middleware {
abstract class Middleware implements IMiddleWare {
/**
......
......@@ -25,8 +25,8 @@
namespace OC\AppFramework;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Middleware\Middleware;
use OC\AppFramework\Middleware\MiddlewareDispatcher;
use OCP\AppFramework\Middleware;
use OCP\AppFramework\Http\Response;
......@@ -142,12 +142,12 @@ class MiddlewareDispatcherTest extends \PHPUnit_Framework_TestCase {
public function testAfterExceptionShouldReturnResponseOfMiddleware(){
$response = new Response();
$m1 = $this->getMock('\OC\AppFramework\Middleware\Middleware',
$m1 = $this->getMock('\OCP\AppFramework\Middleware',
array('afterException', 'beforeController'));
$m1->expects($this->never())
->method('afterException');
$m2 = $this->getMock('OC\AppFramework\Middleware\Middleware',
$m2 = $this->getMock('OCP\AppFramework\Middleware',
array('afterException', 'beforeController'));
$m2->expects($this->once())
->method('afterException')
......@@ -267,7 +267,7 @@ class MiddlewareDispatcherTest extends \PHPUnit_Framework_TestCase {
public function testExceptionShouldRunAfterExceptionOfOnlyPreviouslyExecutedMiddlewares(){
$m1 = $this->getMiddleware();
$m2 = $this->getMiddleware(true);
$m3 = $this->getMock('\OC\AppFramework\Middleware\Middleware');
$m3 = $this->getMock('\OCP\AppFramework\Middleware');
$m3->expects($this->never())
->method('afterException');
$m3->expects($this->never())
......
......@@ -25,7 +25,7 @@
namespace OC\AppFramework;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Middleware\Middleware;
use OCP\AppFramework\Middleware;
class ChildMiddleware extends Middleware {};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment