mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-15 18:23:26 +03:00
- Optimised Input-classes. - `get` and `getObject` methods on `Input` now supports filtering on multiple method-types when using the `$method` parameter. - Input classes now know how to parse that stupid nested $_FILES array. - It's now possible to change method-names on ResourceControllers. - Removed `getValue` and `setValue` from `InputFile` classes. - Ensured that request-method are only parsed from $_POST or $_SERVER. - Fixed minor parameter-issues with subdomain routing. - Added PHPDocs. - Added even more unit-tests. - Many small optimisations tweaks.
41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
require_once 'Dummy/DummyMiddleware.php';
|
|
require_once 'Dummy/DummyController.php';
|
|
require_once 'Dummy/Handler/ExceptionHandler.php';
|
|
|
|
use Pecee\SimpleRouter\SimpleRouter as SimpleRouter;
|
|
|
|
class MiddlewareTest extends PHPUnit_Framework_TestCase
|
|
{
|
|
public function testMiddlewareFound()
|
|
{
|
|
$this->setExpectedException('MiddlewareLoadedException');
|
|
|
|
SimpleRouter::router()->reset();
|
|
SimpleRouter::request()->setMethod('get');
|
|
SimpleRouter::request()->setUri('/my/test/url');
|
|
|
|
SimpleRouter::group(['exceptionHandler' => 'ExceptionHandler'], function () {
|
|
SimpleRouter::get('/my/test/url', 'DummyController@start', ['middleware' => 'DummyMiddleware']);
|
|
});
|
|
|
|
SimpleRouter::start();
|
|
}
|
|
|
|
public function testNestedMiddlewareLoad()
|
|
{
|
|
$this->setExpectedException('MiddlewareLoadedException');
|
|
|
|
SimpleRouter::router()->reset();
|
|
SimpleRouter::request()->setMethod('get');
|
|
SimpleRouter::request()->setUri('/my/test/url');
|
|
|
|
SimpleRouter::group(['exceptionHandler' => 'ExceptionHandler', 'middleware' => 'DummyMiddleware'], function () {
|
|
SimpleRouter::get('/my/test/url', 'DummyController@start');
|
|
});
|
|
|
|
SimpleRouter::start();
|
|
}
|
|
|
|
} |