mirror of
https://github.com/twigphp/Twig.git
synced 2026-10-09 21:35:40 +00:00
Merge branch '3.x' into 4.x
* 3.x: Clarify the exception message for nested block chains from another environment Report a clear error when using macros imported in a template body that was not rendered # Conflicts: # CHANGELOG # src/Template.php # tests/CallMacroTest.php
This commit is contained in:
@@ -296,7 +296,7 @@ class BlockChainTest extends TestCase
|
||||
$other = new Environment(new ArrayLoader(['theme' => '']));
|
||||
|
||||
$this->expectException(\LogicException::class);
|
||||
$this->expectExceptionMessage('A block chain cannot contain templates from different Twig environments.');
|
||||
$this->expectExceptionMessage('A block chain cannot contain a block chain from a different Twig environment.');
|
||||
|
||||
new BlockChain($twig, [new BlockChain($other, ['theme'])]);
|
||||
}
|
||||
@@ -519,7 +519,8 @@ class BlockChainTest extends TestCase
|
||||
try {
|
||||
$chain->renderBlock('field', ['helper' => 'macros1']);
|
||||
$this->fail('Rendering an uninitialized import must fail.');
|
||||
} catch (RuntimeError) {
|
||||
} catch (RuntimeError $e) {
|
||||
$this->assertStringContainsString('Macros imported in the body of template "theme" are not available because the body was not rendered', $e->getMessage());
|
||||
}
|
||||
|
||||
$this->assertSame('one', $twig->render('theme', ['helper' => 'macros1']));
|
||||
|
||||
Reference in New Issue
Block a user