1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00
Oinktube/objects/simple-php-router/test/Helpers/TestRouter.php
2018-06-06 03:29:44 +02:00

41 lines
No EOL
882 B
PHP

<?php
class TestRouter extends \Pecee\SimpleRouter\SimpleRouter
{
public static function debugNoReset($testUrl, $testMethod = 'get')
{
static::request()->setUrl($testUrl);
static::request()->setMethod($testMethod);
static::start();
}
public static function debug($testUrl, $testMethod = 'get')
{
try {
static::debugNoReset($testUrl, $testMethod);
} catch(\Exception $e) {
static::router()->reset();
throw $e;
}
static::router()->reset();
}
public static function debugOutput($testUrl, $testMethod = 'get')
{
$response = null;
// Route request
ob_start();
static::debug($testUrl, $testMethod);
$response = ob_get_contents();
ob_end_clean();
// Return response
return $response;
}
}