Esempio n. 1
0
 public function testInvalidTemplatePath()
 {
     $tm = new TemplatesManager();
     $tm->addTemplatePath('c', 'invalid-path');
     $this->setExpectedException('RuntimeException', "Invalid template path with namespace \"c\"");
     $tm->getTemplatePath('c');
 }
Esempio n. 2
0
 public function setUp()
 {
     $_SERVER = array('SERVER_NAME' => 'localhost', 'SCRIPT_NAME' => 'index.php');
     $this->provider = new ServiceProvider();
     $router = new Router();
     $router->setRoutes(['my' => ['methods' => ['GET'], 'route' => '/my/{id}', 'handler' => [], 'filters' => ['id' => '([\\d-]+)'], 'child_routes' => ['my-sub' => ['methods' => ['GET', 'POST'], 'route' => '/sub/{p}', 'handler' => [], 'filters' => ['p' => '(\\d+)']]]]]);
     $this->provider->setRouter($router);
     $tm = new TemplatesManager();
     $layout = __DIR__ . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'SomeModule' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'main.phtml';
     $layout2 = __DIR__ . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'SomeModule' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'main2.phtml';
     $tm->setTemplateMap(['main' => $layout, 'main2' => $layout2]);
     $tm->addTemplatePath('foo', __DIR__ . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'SomeModule' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'foo');
     $this->provider->setTemplatesManager($tm);
     $this->provider->setConfig(['layout' => 'main']);
     $file = __DIR__ . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'SomeModule' . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . 'FooController.php';
     require_once $file;
     $class = 'Foo\\FooController';
     $this->controller = new $class($this->provider);
 }