public function register()
 {
     $this->forge->singleton(['routing', Routing::class], function () {
         $routing = new Routing(new HttpRequest(ServerRequestFactory::fromGlobals()), new HttpResponse(new Response()));
         $routing->makeDispatcher(HTTP . "routes.php");
         return $routing;
     });
     $this->provides += [Routing::class];
 }
Exemple #2
0
 public function test_Routing()
 {
     //$request = new Request('/controller/amiguchi','GET');
     //die_dump($request);
     //$this->routing->makeRoutes();
     $route = $this->routing->makeDispatcher(TEST_PATH . '/tests/core/app/routes.php')->match();
     # status will be in the following:
     #   NOT_FOUND = 0;
     #   FOUND = 1;
     #   METHOD_NOT_ALLOWED = 2;
     $status = array_key_exists(0, $route) ? $route[0] : NULL;
     # get the target callable
     $target = array_key_exists(1, $route) ? $route[1] : NULL;
     # get the request parameters
     $params = array_key_exists(2, $route) ? $route[2] : NULL;
     # should be found with correct parameters
     //$this->assertTrue($status === Dispatcher::FOUND);
     //$this->assertTrue($params === ['name' => 'greg']);
     # simulate routing middleware for this test case
     //$result = call_user_func_array($target, [new Input($route[2]), new Response()]);
     //$this->assertEquals("Test Route [greg]", $result,
     //    'Test route should return `Test Route [greg]`.');
 }