Пример #1
0
 /**
  * Router runner
  *
  * @throws NotFoundException
  * @return bool|\PHPRouter\Route
  */
 public function run()
 {
     $routes = Config::loadFromFile($this->routePath);
     $router = Route::parseConfig($routes);
     $exec = $router->matchCurrentRequest();
     if ($exec) {
         return $exec;
     }
     throw new NotFoundException('Route does not found', NotFoundException::CODE);
 }
Пример #2
0
 public function testParseConfig()
 {
     $config = Config::loadFromFile(__DIR__ . '/../../Fixtures/router.yaml');
     $router = Router::parseConfig($config);
     self::assertAttributeEquals($config['base_path'], 'basePath', $router);
 }
 public function testConfigFileCanReadAndReturnDataOfAYamlFile()
 {
     $expected = array('base_path' => '/blog', 'routes' => array('index' => array('/index', 'Controller.method', 'GET'), 'contact' => array('/contact', 'someClass.contactAction', 'GET'), 'about' => array('/about', 'someClass.aboutAction', 'GET')));
     $result = Config::loadFromFile(__DIR__ . '/../../Fixtures/router.yaml');
     $this->assertSame($expected, $result);
 }