Example #1
0
 public function testGenerateShortRoute()
 {
     $router = new Router();
     $router->get('something/{a}/{b}/{c}')->name('namedRoute');
     $generated = $router->to('namedRoute', ['a' => 'paramA', 'c' => 'paramC', 'b' => 'paramB', 'extra' => 'foobar', 'other' => 'baz']);
     $this->assertEquals('something/paramA/paramB/paramC?extra=foobar&other=baz', $generated);
 }
Example #2
0
 public function testBasePath()
 {
     $called = false;
     $config = new Configuration();
     $config->basePath = 'base/';
     $router = new Router($config);
     $router->get('hello')->name('hello')->onMatch(function () use(&$called) {
         $called = true;
     });
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $_SERVER['REQUEST_URI'] = 'base/hello';
     $router->matchCurrentRequest();
     $this->assertTrue($called);
     $this->assertEquals('base/hello', $router->to('hello'));
 }