示例#1
0
文件: RouterTest.php 项目: zortje/mvc
 /**
  * @covers ::route
  */
 public function testNotConnected()
 {
     $this->expectException(RouteNonexistentException::class);
     $this->expectExceptionMessage('Route /signin is not connected');
     $router = new Router();
     $router->route('/signin');
 }
示例#2
0
 /**
  * @covers ::dispatch
  */
 public function testDispatch()
 {
     $router = new Router();
     $router->connect('\\/cars', CarsController::class, 'index');
     $configuration = new Configuration();
     $configuration->set('Router', $router);
     $configuration->set('App.Path', realpath(dirname(__FILE__)) . '/../../src/');
     $dispatcher = new Dispatcher($this->pdo, $configuration);
     $cookie = new Cookie($configuration);
     $request = new Request($cookie, ['REQUEST_URI' => '/cars'], []);
     $response = $dispatcher->dispatch($request);
     $this->assertSame(['content-type' => 'Content-Type: text/html; charset=utf-8'], $response->getHeaders());
     $this->assertSame($cookie, $response->getCookie());
     $this->assertSame('<h1>Auto</h1><p>Ford Model T</p><p>Ford Model A</p>', $response->getOutput());
 }