예제 #1
0
<?php

require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Hoa\Exception;
use Hoa\Dispatcher;
use Hoa\Router;
Exception\Error::enableErrorHandler();
Exception\Idle::enableUncaughtHandler();
$dispatcher = new Dispatcher\ClassMethod(['synchronous.call' => 'Application\\Resource\\(:call:U:)', 'synchronous.able' => '(:%variables._method:U:)', 'asynchronous.call' => '(:%synchronous.call:)', 'asynchronous.able' => '(:%synchronous.able:)']);
$router = new Router\Http();
$router->_get('_resource', '/Static/(?<resource>)')->get('dates', '/api/dates(?:/(?<limit>\\d+))?', 'Dates')->get('discography', '/api/discography', 'Discography')->get('album', '/api/album/(?<albumId>.+)', 'Album')->get('videos', '/api/videos', 'Videos')->get('fallback', '/.*', 'Fallback');
$dispatcher->dispatch($router);
예제 #2
0
 public function case_enable_uncaught_handler()
 {
     $self = $this;
     $this->given($this->function->set_exception_handler = function ($handler) use($self, &$called) {
         $called = true;
         $self->object($handler)->isInstanceOf('Closure')->let($reflection = new \ReflectionObject($handler))->array($invokeParameters = $reflection->getMethod('__invoke')->getParameters())->hasSize(1)->string($invokeParameters[0]->getName())->isEqualTo('exception');
         return null;
     })->when($result = SUT::enableUncaughtHandler())->then->variable($result)->isNull()->boolean($called)->isTrue();
 }