コード例 #1
0
ファイル: ControllerTest.php プロジェクト: zortje/mvc
 public function setUp()
 {
     $this->pdo = new \PDO("mysql:host=127.0.0.1;dbname=tests", 'root', '');
     $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     $this->pdo->exec('SET NAMES utf8');
     $this->configuration = new Configuration();
     $this->configuration->set('App.Path', '/var/www/html/');
     $this->request = new Request(new Cookie($this->configuration));
 }
コード例 #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());
 }
コード例 #3
0
ファイル: ConfigurationTest.php プロジェクト: zortje/mvc
 /**
  * @covers ::get
  */
 public function testGet()
 {
     $configuration = new Configuration();
     $configuration->set('foo', 'bar');
     $this->assertSame('bar', $configuration->get('foo'));
 }