mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
ff3f1bdcdd
- 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.
41 lines
882 B
PHP
41 lines
882 B
PHP
<?php
|
|
|
|
class TestRouter extends \Pecee\SimpleRouter\SimpleRouter
|
|
{
|
|
|
|
public static function debugNoReset($testUri, $testMethod = 'get')
|
|
{
|
|
static::request()->setUri($testUri);
|
|
static::request()->setMethod($testMethod);
|
|
|
|
static::start();
|
|
}
|
|
|
|
public static function debug($testUri, $testMethod = 'get')
|
|
{
|
|
try {
|
|
static::debugNoReset($testUri, $testMethod);
|
|
} catch(\Exception $e) {
|
|
static::router()->reset();
|
|
throw $e;
|
|
}
|
|
|
|
static::router()->reset();
|
|
|
|
}
|
|
|
|
public static function debugOutput($testUri, $testMethod = 'get')
|
|
{
|
|
$response = null;
|
|
|
|
// Route request
|
|
ob_start();
|
|
static::debug($testUri, $testMethod);
|
|
$response = ob_get_contents();
|
|
ob_end_clean();
|
|
|
|
// Return response
|
|
return $response;
|
|
}
|
|
|
|
} |