Example #1
0
 public function testPageException()
 {
     $this->request->expects($this->once())->method('getPathInfo')->will($this->returnValue('/fail'));
     $this->twig->expects($this->at(0))->method('render')->with('page/fail.html.twig')->will($this->throwException(new Twig_Error_Loader('Unable to find template')));
     $this->twig->expects($this->at(1))->method('render')->with('error/404.html.twig');
     $result = $this->controller->page($this->request);
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $result);
     $this->assertSame(404, $result->getStatusCode());
 }
Example #2
0
<?php

use Demontpx\EasyTwig\Controller;
use Demontpx\EasyTwig\TwigFactory;
use Symfony\Component\HttpFoundation\Request;
$root = __DIR__ . '/../';
require_once $root . 'config.php';
require_once $root . 'vendor/autoload.php';
$twigFactory = new TwigFactory();
$twig = $twigFactory->create($templatesPath, $cachePath, $debug);
$controller = new Controller($twig);
$request = Request::createFromGlobals();
$response = $controller->page($request);
$response->send();