[TwigBundle] fixed usage of getSource in tests
This commit is contained in:
parent
b9a4586b24
commit
317d46f249
@ -17,7 +17,7 @@ use Symfony\Bundle\TwigBundle\Tests\TestCase;
|
||||
|
||||
class FilesystemLoaderTest extends TestCase
|
||||
{
|
||||
public function testGetSource()
|
||||
public function testGetSourceContext()
|
||||
{
|
||||
$parser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
|
||||
$locator = $this->getMock('Symfony\Component\Config\FileLocatorInterface');
|
||||
@ -30,10 +30,10 @@ class FilesystemLoaderTest extends TestCase
|
||||
$loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views', 'namespace');
|
||||
|
||||
// Twig-style
|
||||
$this->assertEquals("This is a layout\n", $loader->getSource('@namespace/layout.html.twig'));
|
||||
$this->assertEquals("This is a layout\n", $loader->getSourceContext('@namespace/layout.html.twig')->getCode());
|
||||
|
||||
// Symfony-style
|
||||
$this->assertEquals("This is a layout\n", $loader->getSource('TwigBundle::layout.html.twig'));
|
||||
$this->assertEquals("This is a layout\n", $loader->getSourceContext('TwigBundle::layout.html.twig')->getCode());
|
||||
}
|
||||
|
||||
public function testExists()
|
||||
|
@ -27,7 +27,7 @@ class LegacyRenderTokenParserTest extends TestCase
|
||||
{
|
||||
$env = new \Twig_Environment($this->getMock('Twig_LoaderInterface'), array('cache' => false, 'autoescape' => false, 'optimizations' => 0));
|
||||
$env->addTokenParser(new RenderTokenParser());
|
||||
$stream = $env->tokenize(new \Twig_Source($source));
|
||||
$stream = $env->tokenize(new \Twig_Source($source, ''));
|
||||
$parser = new \Twig_Parser($env);
|
||||
|
||||
$this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0));
|
||||
|
@ -126,7 +126,11 @@ class TemplateManager
|
||||
}
|
||||
|
||||
try {
|
||||
if ($loader instanceof \Twig_SourceContextLoaderInterface) {
|
||||
$loader->getSourceContext($template);
|
||||
} else {
|
||||
$loader->getSource($template);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (\Twig_Error_Loader $e) {
|
||||
|
@ -31,11 +31,6 @@ class TemplateManagerTest extends TestCase
|
||||
*/
|
||||
protected $profiler;
|
||||
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $profile;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Bundle\WebProfilerBundle\Profiler\TemplateManager
|
||||
*/
|
||||
@ -129,11 +124,7 @@ class TemplateManagerTest extends TestCase
|
||||
|
||||
protected function mockProfile()
|
||||
{
|
||||
$this->profile = $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
return $this->profile;
|
||||
return $this->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profile')->disableOriginalConstructor()->getMock();
|
||||
}
|
||||
|
||||
protected function mockTwigEnvironment()
|
||||
@ -144,9 +135,12 @@ class TemplateManagerTest extends TestCase
|
||||
->method('loadTemplate')
|
||||
->will($this->returnValue('loadedTemplate'));
|
||||
|
||||
$this->twigEnvironment->expects($this->any())
|
||||
->method('getLoader')
|
||||
->will($this->returnValue($this->getMock('\Twig_LoaderInterface')));
|
||||
if (interface_exists('\Twig_SourceContextLoaderInterface')) {
|
||||
$loader = $this->getMock('\Twig_SourceContextLoaderInterface');
|
||||
} else {
|
||||
$loader = $this->getMock('\Twig_LoaderInterface');
|
||||
}
|
||||
$this->twigEnvironment->expects($this->any())->method('getLoader')->will($this->returnValue($loader));
|
||||
|
||||
return $this->twigEnvironment;
|
||||
}
|
||||
|
Reference in New Issue
Block a user