1<?php 2 3/* 4 * This file is part of Twig. 5 * 6 * (c) Fabien Potencier 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12use Twig\Node\SandboxNode; 13use Twig\Node\TextNode; 14use Twig\Test\NodeTestCase; 15 16class Twig_Tests_Node_SandboxTest extends NodeTestCase 17{ 18 public function testConstructor() 19 { 20 $body = new TextNode('foo', 1); 21 $node = new SandboxNode($body, 1); 22 23 $this->assertEquals($body, $node->getNode('body')); 24 } 25 26 public function getTests() 27 { 28 $tests = []; 29 30 $body = new TextNode('foo', 1); 31 $node = new SandboxNode($body, 1); 32 33 $tests[] = [$node, <<<EOF 34// line 1 35if (!\$alreadySandboxed = \$this->sandbox->isSandboxed()) { 36 \$this->sandbox->enableSandbox(); 37} 38echo "foo"; 39if (!\$alreadySandboxed) { 40 \$this->sandbox->disableSandbox(); 41} 42EOF 43 ]; 44 45 return $tests; 46 } 47} 48