Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 18d4c41

Browse files
committed
[TwigBundle] added some tests
1 parent 0d537c4 commit 18d4c41

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\TwigBundle\Tests;
13+
14+
use Symfony\Component\HttpKernel\Kernel;
15+
use Symfony\Component\Config\Loader\LoaderInterface;
16+
use Symfony\Component\Filesystem\Filesystem;
17+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
18+
use Symfony\Bundle\TwigBundle\TwigBundle;
19+
20+
class NoTemplatingEntryTest extends \PHPUnit_Framework_TestCase
21+
{
22+
public function test()
23+
{
24+
$kernel = new NoTemplatingEntryKernel('dev', true);
25+
$kernel->boot();
26+
27+
$container = $kernel->getContainer();
28+
$content = $container->get('twig')->render('index.html.twig');
29+
$this->assertContains('{ a: b }', $content);
30+
}
31+
32+
protected function setUp()
33+
{
34+
$this->deleteTempDir();
35+
}
36+
37+
protected function tearDown()
38+
{
39+
$this->deleteTempDir();
40+
}
41+
42+
protected function deleteTempDir()
43+
{
44+
if (!file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel')) {
45+
return;
46+
}
47+
48+
$fs = new Filesystem();
49+
$fs->remove($dir);
50+
}
51+
}
52+
53+
class NoTemplatingEntryKernel extends Kernel
54+
{
55+
public function registerBundles()
56+
{
57+
return array(new FrameworkBundle(), new TwigBundle());
58+
}
59+
60+
public function registerContainerConfiguration(LoaderInterface $loader)
61+
{
62+
$loader->load(function ($container) {
63+
$container->loadFromExtension('framework', array(
64+
'secret' => '$ecret',
65+
));
66+
});
67+
}
68+
69+
public function getCacheDir()
70+
{
71+
return sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel/cache/'.$this->environment;
72+
}
73+
74+
public function getLogDir()
75+
{
76+
return sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel/logs';
77+
}
78+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ {a: 'b'}|yaml_encode }}

src/Symfony/Bundle/TwigBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=5.3.9",
20-
"symfony/twig-bridge": "~2.6|~3.0.0",
20+
"symfony/twig-bridge": "~2.7|~3.0.0",
2121
"symfony/http-foundation": "~2.5|~3.0.0",
2222
"symfony/http-kernel": "~2.3.24|~2.5.9|~2.6,>=2.6.2|~3.0.0"
2323
},

0 commit comments

Comments
 (0)