Development

- Fixed issue #227 causing custom resource-routes not to be loaded after latest update.
- Optimized `RouteResource` class.
- Renamed `IRestController` to `IResourceController`.
- Added unit-tests for RouterResource.
- Simplified unit-tests with the `TestRouter` custom router class.
This commit is contained in:
Simon Sessingø
2017-03-05 17:09:46 +01:00
parent 8c5d8c2dc9
commit ff3f1bdcdd
16 changed files with 386 additions and 243 deletions
+8 -13
View File
@@ -2,24 +2,19 @@
class DummyController
{
public function start()
public function method1()
{
echo static::class . '@' . 'start() OK';
}
public function method2()
{
}
public function param($params = null)
{
$params = func_get_args();
echo 'Params: ' . join(', ', $params);
}
public function notFound()
{
echo 'not found';
}
public function silent() {
echo join(', ', func_get_args());
}
}
@@ -0,0 +1,18 @@
<?php
class ResponseException extends \Exception
{
protected $response;
public function __construct($response)
{
$this->response = $response;
parent::__construct('', 0);
}
public function getResponse()
{
return $this->response;
}
}
@@ -1,10 +1,11 @@
<?php
class TestExceptionHandlerFirst implements \Pecee\Handlers\IExceptionHandler
class ExceptionHandlerFirst implements \Pecee\Handlers\IExceptionHandler
{
public function handleError(\Pecee\Http\Request $request, \Exception $error)
{
echo 'ExceptionHandler 1 loaded' . chr(10);
global $stack;
$stack[] = static::class;
$request->setUri('/');
return $request;
@@ -1,10 +1,11 @@
<?php
class TestExceptionHandlerSecond implements \Pecee\Handlers\IExceptionHandler
class ExceptionHandlerSecond implements \Pecee\Handlers\IExceptionHandler
{
public function handleError(\Pecee\Http\Request $request, \Exception $error)
{
echo 'ExceptionHandler 2 loaded' . chr(10);
global $stack;
$stack[] = static::class;
$request->setUri('/');
return $request;
@@ -0,0 +1,13 @@
<?php
class ExceptionHandlerThird implements \Pecee\Handlers\IExceptionHandler
{
public function handleError(\Pecee\Http\Request $request, \Exception $error)
{
global $stack;
$stack[] = static::class;
throw new ResponseException('ExceptionHandler loaded');
}
}
@@ -1,12 +0,0 @@
<?php
class TestExceptionHandlerThird implements \Pecee\Handlers\IExceptionHandler
{
public function handleError(\Pecee\Http\Request $request, \Exception $error)
{
echo 'ExceptionHandler 3 loaded' . chr(10);
throw new ExceptionHandlerException('All good!', 666);
}
}
+39
View File
@@ -0,0 +1,39 @@
<?php
class ResourceController implements \Pecee\Controllers\IResourceController
{
public function index()
{
echo 'index';
}
public function show($id)
{
echo 'show ' . $id;
}
public function store()
{
echo 'store';
}
public function create()
{
echo 'create';
}
public function edit($id)
{
echo 'edit ' . $id;
}
public function update($id)
{
echo 'update ' . $id;
}
public function destroy($id)
{
echo 'destroy ' . $id;
}
}