Exemple #1
0
 public function test500()
 {
     $this->app->route('500', '/500', function () {
         throw new \Exception('Test Exception for 500');
     });
     $this->app->demand('header', function ($header) use(&$headers_list) {
         $headers_list[] = $header;
     });
     $this->app->simulate_request('/500');
     var_dump($headers_list);
     $this->assertNotEmpty($headers_list);
     $this->assertContains('HTTP/1.1 500 Internal Server Error', $headers_list);
 }
Exemple #2
0
 * Build an index for the admin route
 */
$admin->route('admin_index', '/', function () {
    echo "This is the admin index";
});
/**
 * Add the admin app as a handler within the /admin route on the main app
 */
$app->route('admin', '/admin', $admin);
/**
 * Register an on-demand object with the app
 */
$app->demand('mockdb', function ($param) {
    $obj = new stdClass();
    $obj->foo = 'bar';
    $obj->baz = range($param, $param + 15, 3);
    $obj->microtime = microtime(true);
    $obj->param = $param;
    return $obj;
});
/**
 * Return the view data as a json object
 * Fetch the registsered on-demand "mockdb" object from the app
 * Note that the mockdb objects are the different because it was registered with ->demand()
 * If it was registered with ->share() it would be created only once
 */
$app->route('json', '/json', function (App $app) {
    $response = $app->response();
    $response['user'] = '******';
    $response['user_id'] = 1;
    $response['registered'] = true;
    $response['mockdb_obj'] = $app->mockdb(1);