-
-
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.
bug #4511 Ignore exceptions from undefined handlers when using the gu…
…ard tag (fabpot) This PR was merged into the 3.x branch. Discussion ---------- Ignore exceptions from undefined handlers when using the guard tag Fixes #4505 Commits ------- b53c639 Ignore exceptions from undefined handlers when using the guard tag
- Loading branch information
Showing
3 changed files
with
28 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Twig\Tests\TokenParser; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Twig\Environment; | ||
use Twig\Error\SyntaxError; | ||
use Twig\Loader\ArrayLoader; | ||
use Twig\Parser; | ||
use Twig\Source; | ||
|
||
class GuardTokenParserTest extends TestCase | ||
{ | ||
public function testUndefinedHandlers() | ||
{ | ||
$this->expectNotToPerformAssertions(); | ||
|
||
$env = new Environment(new ArrayLoader(), ['cache' => false, 'autoescape' => false]); | ||
$env->registerUndefinedFunctionCallback(fn ($name) => throw new SyntaxError('boom.')); | ||
(new Parser($env))->parse($env->tokenize(new Source('{% guard function boom %}{% endguard %}', ''))); | ||
} | ||
} |