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)); }
/** * @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()); }
/** * @covers ::get */ public function testGet() { $configuration = new Configuration(); $configuration->set('foo', 'bar'); $this->assertSame('bar', $configuration->get('foo')); }