removed some usage of loadTemplate in tests

This commit is contained in:
Fabien Potencier
2019-03-16 11:32:43 +01:00
parent f5689b50e5
commit 931a8b5cdf
3 changed files with 14 additions and 14 deletions
+11 -11
View File
@@ -105,7 +105,7 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
$twig = new Environment($loader);
$twig->addGlobal('foo', 'foo');
$twig->getGlobals();
$twig->loadTemplate('index');
$twig->load('index');
$twig->addGlobal('foo', 'bar');
$globals = $twig->getGlobals();
$this->assertEquals('bar', $globals['foo']);
@@ -125,7 +125,7 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
$twig->addGlobal('foo', 'foo');
$twig->getGlobals();
$twig->getFunctions();
$twig->loadTemplate('index');
$twig->load('index');
$twig->addGlobal('foo', 'bar');
$globals = $twig->getGlobals();
$this->assertEquals('bar', $globals['foo']);
@@ -133,7 +133,7 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
$twig = new Environment($arrayLoader);
$twig->getGlobals();
$twig->addGlobal('foo', 'bar');
$template = $twig->loadTemplate('index');
$template = $twig->load('index');
$this->assertEquals('bar', $template->render([]));
/* to be uncomment in Twig 2.0
@@ -141,7 +141,7 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
$twig = new Environment($loader);
$twig->addGlobal('foo', 'foo');
$twig->getGlobals();
$twig->loadTemplate('index');
$twig->load('index');
try {
$twig->addGlobal('bar', 'bar');
$this->fail();
@@ -166,7 +166,7 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
$twig->addGlobal('foo', 'foo');
$twig->getGlobals();
$twig->getFunctions();
$twig->loadTemplate('index');
$twig->load('index');
try {
$twig->addGlobal('bar', 'bar');
$this->fail();
@@ -176,7 +176,7 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
// test adding globals after a template has been loaded without call to getGlobals
$twig = new Environment($loader);
$twig->loadTemplate('index');
$twig->load('index');
try {
$twig->addGlobal('bar', 'bar');
$this->fail();
@@ -238,7 +238,7 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
$cache->expects($this->once())
->method('load');
$twig->loadTemplate($templateName);
$twig->load($templateName);
}
public function testAutoReloadCacheHit()
@@ -266,7 +266,7 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
$cache->expects($this->atLeastOnce())
->method('load');
$twig->loadTemplate($templateName);
$twig->load($templateName);
}
public function testAutoReloadOutdatedCacheHit()
@@ -294,7 +294,7 @@ class Twig_Tests_EnvironmentTest extends \PHPUnit\Framework\TestCase
$cache->expects($this->once())
->method('load');
$twig->loadTemplate($templateName);
$twig->load($templateName);
}
/**
@@ -508,7 +508,7 @@ EOF
'base.html.twig' => '{% extends "base.html.twig" %}',
]));
$twig->loadTemplate('base.html.twig');
$twig->load('base.html.twig');
}
/**
@@ -522,7 +522,7 @@ EOF
'base2.html.twig' => '{% extends "base1.html.twig" %}',
]));
$twig->loadTemplate('base1.html.twig');
$twig->load('base1.html.twig');
}
protected function getMockLoader($templateName, $templateContent)
+1 -1
View File
@@ -118,7 +118,7 @@ class Twig_Tests_Extension_SandboxTest extends \PHPUnit\Framework\TestCase
{
$twig = $this->getEnvironment(true, [], ['index' => $template], [], ['upper'], ['FooObject' => 'getAnotherFooObject'], [], ['random']);
try {
$twig->loadTemplate('index')->render(self::$params);
$twig->load('index')->render(self::$params);
$this->fail('Sandbox throws a SecurityError exception if an unallowed method (__toString()) is called in the template');
} catch (SecurityError $e) {
$this->assertInstanceOf('\Twig\Sandbox\SecurityNotAllowedMethodError', $e, 'Exception should be an instance of Twig_Sandbox_SecurityNotAllowedMethodError');
+2 -2
View File
@@ -44,7 +44,7 @@ class Twig_Tests_FileCachingTest extends \PHPUnit\Framework\TestCase
public function testWritingCacheFiles()
{
$name = 'index';
$this->env->loadTemplate($name);
$this->env->load($name);
$cacheFileName = $this->env->getCacheFilename($name);
$this->assertFileExists($cacheFileName, 'Cache file does not exist.');
@@ -56,7 +56,7 @@ class Twig_Tests_FileCachingTest extends \PHPUnit\Framework\TestCase
public function testClearingCacheFiles()
{
$name = 'index2';
$this->env->loadTemplate($name);
$this->env->load($name);
$cacheFileName = $this->env->getCacheFilename($name);
$this->assertFileExists($cacheFileName, 'Cache file does not exist.');