-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove $templateName from Template::loadTemplate()
- Loading branch information
Showing
10 changed files
with
76 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
namespace Twig\Tests\Node; | ||
|
||
/* | ||
* This file is part of Twig. | ||
* | ||
* (c) Fabien Potencier | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Twig\Environment; | ||
use Twig\Error\LoaderError; | ||
use Twig\Loader\ArrayLoader; | ||
use Twig\Loader\FilesystemLoader; | ||
use Twig\Test\NodeTestCase; | ||
|
||
class ExtendsTest extends NodeTestCase | ||
{ | ||
public function testErrorFromArrayLoader() | ||
{ | ||
$twig = new Environment(new ArrayLoader([ | ||
'index.twig' => '{% include "include.twig" %}', | ||
'include.twig' => $include = <<<EOF | ||
{% extends 'invalid.twig' %} | ||
EOF, | ||
]), ['debug' => true]); | ||
try { | ||
$twig->render('index.twig'); | ||
$this->fail('Expected LoaderError to be thrown'); | ||
} catch (LoaderError $e) { | ||
$this->assertSame('Template "invalid.twig" is not defined.', $e->getRawMessage()); | ||
$this->assertSame(4, $e->getTemplateLine()); | ||
$this->assertSame('include.twig', $e->getSourceContext()->getName()); | ||
$this->assertSame($include, $e->getSourceContext()->getCode()); | ||
} | ||
} | ||
|
||
public function testErrorFromFilesystemLoader() | ||
{ | ||
$twig = new Environment(new FilesystemLoader([ | ||
$dir = dirname(__DIR__, 2).'/_templates', | ||
]), ['debug' => true]); | ||
$include = file_get_contents($dir.'/include.twig'); | ||
try { | ||
$twig->render('index.twig'); | ||
$this->fail('Expected LoaderError to be thrown'); | ||
} catch (LoaderError $e) { | ||
$this->assertStringContainsString('Unable to find template "invalid.twig"', $e->getRawMessage()); | ||
$this->assertSame(4, $e->getTemplateLine()); | ||
$this->assertSame('include.twig', $e->getSourceContext()->getName()); | ||
$this->assertSame($include, $e->getSourceContext()->getCode()); | ||
} | ||
} | ||
|
||
public static function provideTests(): iterable | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters