public function testRun() { Router::connect('/', array('controller' => 'test', 'action' => 'test')); $request = new Request(); $request->url = '/'; MockDispatcher::run($request); $result = end(MockDispatcher::$dispatched); $expected = array('controller' => 'test', 'action' => 'test'); $this->assertEqual($expected, $result->params); }
public function testAutoHandler() { $result = MockDispatcher::run(new Request(array('url' => '/auto'))); $this->assertEqual(array('location: /redirect'), $result->headers()); }
public function testMatchWithScopeAndWithoutController() { Router::scope('app', function () { Router::connect('/{:id}', 'Posts::index'); }); $request = new Request(array('url' => '/1', 'base' => '')); MockDispatcher::run($request); $result = Router::match(array('id' => 2), $request); $this->assertEqual('/2', $result); }