Commit c642d13b authored by Igor Wiedler's avatar Igor Wiedler

[TwigExtension] initial test case

parent a085d9e2
......@@ -28,3 +28,6 @@
[submodule "vendor/pimple"]
path = vendor/pimple
url = https://github.com/fabpot/Pimple
[submodule "vendor/twig"]
path = vendor/twig
url = https://github.com/fabpot/Twig
<?php
/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Silex\Tests;
use Silex\Application;
use Silex\Extension\TwigExtension;
use Symfony\Component\HttpFoundation\Request;
/**
* TwigExtension test cases.
*
* @author Igor Wiedler <igor@wiedler.ch>
*/
class TwigExtensionTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!is_dir(__DIR__.'/../../../../vendor/twig')) {
$this->markTestSkipped('Twig submodule was not installed.');
}
}
public function testRegisterAndRender()
{
$app = new Application();
$app->register(new TwigExtension(), array(
'twig.templates' => array('hello' => 'Hello {{ name }}!'),
'twig.class_path' => __DIR__.'/../../../../vendor/twig/lib',
));
$app->get('/hello/{name}', function($name) use ($app) {
return $app['twig']->render('hello', array('name' => $name));
});
$request = Request::create('/hello/john');
$response = $app->handle($request);
$this->assertEquals('Hello john!', $response->getContent());
}
}
Subproject commit 2f106a80cc13b4260074e573fa017a770fe20350
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment