/**
  * Test get method
  * 
  * @return void
  */
 public function testGet()
 {
     $testInstance = new RouteCollection();
     $testInstance->get('test.com/test', function () {
     });
     $definedRoute = $testInstance->getRoutes()[0];
     $this->assertEquals(Method::GET, $definedRoute->getMethod());
     $this->assertEquals('test.com/test', $definedRoute->getUrl());
     $this->assertTrue($this->_isClosure($definedRoute->getHandler()));
 }
Esempio n. 2
0
 /**
  * Test dynamic controller, dynamic action in module REQUEST 
  * 
  * @return void
  */
 public function testWithoutModeRewriteFullUrl()
 {
     $routeCollection = new RouteCollection();
     $routeCollection->get('/{module}/{controler}/{action}/{id:\\d+}', ['module' => '{module}', 'controler' => '{controler}', 'action' => '{action}']);
     $dispatcher = new DispatcherController();
     $dispatcher->setBaseNamespace('Test\\Application');
     $matcher = new Matcher($routeCollection, $dispatcher);
     $matcher->setUrlFormat(RouteMode::GET_FORMAT);
     $enviromentData = ['QUERY_STRING' => 'r=testModule/test/view/123', 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/index.php?r=testModule/test/view/123'];
     $enviroment = new Request\Enviroment($enviromentData);
     $videoId = $matcher->match(new Request\Request($enviroment));
     $this->assertEquals(123, $videoId);
 }