Example #1
0
 public function testRequestProcess()
 {
     $router = Router::getMainInstance();
     $_SERVER['REQUEST_METHOD'] = Request::METHOD_GET;
     $_SERVER['REQUEST_URI'] = '/products/2/?id=12';
     $_SERVER['QUERY_STRING'] = 'id=12';
     $_SERVER['HTTP_HOST'] = 'test.com';
     $_SERVER['DOCUMENT_ROOT'] = '/';
     $request = Request::getIncomeRequest();
     $route = $router->processRequest($request)->getCurrentRoute();
     $this->assertTrue($route->isNotFound(), 'route not found without subfolder');
     $_SERVER['REQUEST_URI'] = 'project1/products/2/?id=12';
     $newIncomeRequest = Request::createInstance()->processEnvironment();
     $route = $router->processRequest($newIncomeRequest)->getCurrentRoute();
     $this->assertEquals('Product', $route->getVar('controller'), 'Route detected');
     $this->assertEquals(12, $route->getRequestVar('id'), 'request var detected');
 }