コード例 #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
ファイル: DispatcherTest.php プロジェクト: zortje/mvc
 /**
  * @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());
 }