@@ -50,18 +50,18 @@ protected function setUp(): void
5050 '1_basic3 ' => '{% if name %}foo{% endif %} ' ,
5151 '1_basic4 ' => '{{ obj.bar }} ' ,
5252 '1_basic5 ' => '{{ obj }} ' ,
53- '1_basic7 ' => '{{ cycle(["foo","bar"], 1) }} ' ,
53+ '1_basic7 ' => '{{ cycle(["foo", "bar"], 1) }} ' ,
5454 '1_basic8 ' => '{{ obj.getfoobar }}{{ obj.getFooBar }} ' ,
5555 '1_basic9 ' => '{{ obj.foobar }}{{ obj.fooBar }} ' ,
5656 '1_basic ' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %} ' ,
5757 '1_layout ' => '{% block content %}{% endblock %} ' ,
5858 '1_child ' => "{% extends \"1_layout \" %} \n{% block content %} \n{{ \"a \"|json_encode }} \n{% endblock %} " ,
59- '1_include ' => '{{ include ("1_basic1", sandboxed= true) }} ' ,
60- '1_basic2_include_template_from_string_sandboxed ' => '{{ include (template_from_string("{{ name|upper }}"), sandboxed=true) }} ' ,
61- '1_basic2_include_template_from_string ' => '{{ include (template_from_string("{{ name|upper }}")) }} ' ,
59+ '1_render ' => '{{ render ("1_basic1", { obj }, sandboxed: true) }} ' ,
60+ '1_basic2_include_template_from_string_sandboxed ' => '{{ render (template_from_string("{{ name|upper }}"), sandboxed=true) }} ' ,
61+ '1_basic2_include_template_from_string ' => '{{ render (template_from_string("{{ name|upper }}"), { name } ) }} ' ,
6262 '1_range_operator ' => '{{ (1..2)[0] }} ' ,
6363 '1_syntax_error_wrapper_legacy ' => '{% sandbox %}{% include "1_syntax_error" %}{% endsandbox %} ' ,
64- '1_syntax_error_wrapper ' => '{{ include ("1_syntax_error", sandboxed: true) }} ' ,
64+ '1_syntax_error_wrapper ' => '{{ render ("1_syntax_error", sandboxed: true) }} ' ,
6565 '1_syntax_error ' => '{% syntax error }} ' ,
6666 '1_childobj_parentmethod ' => '{{ child_obj.ParentMethod() }} ' ,
6767 '1_childobj_childmethod ' => '{{ child_obj.ChildMethod() }} ' ,
@@ -193,7 +193,7 @@ public function testSandboxGloballyFalseUnallowedFilterWithIncludeTemplateFromSt
193193
194194 public function testSandboxGloballyTrueUnallowedFilterWithIncludeTemplateFromStringSandboxed ()
195195 {
196- $ twig = $ this ->getEnvironment (true , [], self ::$ templates , [], [], [], [], ['include ' , 'template_from_string ' ]);
196+ $ twig = $ this ->getEnvironment (true , [], self ::$ templates , [], [], [], [], ['render ' , 'template_from_string ' ]);
197197 $ twig ->addExtension (new StringLoaderExtension ());
198198 try {
199199 $ twig ->load ('1_basic2_include_template_from_string_sandboxed ' )->render (self ::$ params );
@@ -212,7 +212,7 @@ public function testSandboxGloballyFalseUnallowedFilterWithIncludeTemplateFromSt
212212
213213 public function testSandboxGloballyTrueUnallowedFilterWithIncludeTemplateFromStringNotSandboxed ()
214214 {
215- $ twig = $ this ->getEnvironment (true , [], self ::$ templates , [], [], [], [], ['include ' , 'template_from_string ' ]);
215+ $ twig = $ this ->getEnvironment (true , [], self ::$ templates , [], [], [], [], ['render ' , 'template_from_string ' ]);
216216 $ twig ->addExtension (new StringLoaderExtension ());
217217 try {
218218 $ twig ->load ('1_basic2_include_template_from_string ' )->render (self ::$ params );
@@ -414,11 +414,11 @@ public function testSandboxLocallySetForAnInclude()
414414 $ this ->assertEquals ('fooFOOfoo ' , $ twig ->load ('2_basic ' )->render (self ::$ params ), 'Sandbox does nothing if disabled globally and sandboxed not used for the include ' );
415415
416416 self ::$ templates = [
417- '3_basic ' => '{{ include ("3_included", sandboxed: true) }} ' ,
417+ '3_basic ' => '{{ render ("3_included", sandboxed: true) }} ' ,
418418 '3_included ' => '{% if true %}{{ "foo"|upper }}{% endif %} ' ,
419419 ];
420420
421- $ twig = $ this ->getEnvironment (true , [], self ::$ templates , functions: ['include ' ]);
421+ $ twig = $ this ->getEnvironment (true , [], self ::$ templates , functions: ['render ' ]);
422422 try {
423423 $ twig ->load ('3_basic ' )->render (self ::$ params );
424424 $ this ->fail ('Sandbox throws a SecurityError exception when the included file is sandboxed ' );
@@ -441,20 +441,20 @@ public function testMacrosInASandbox()
441441 $ this ->assertEquals ('<p>username</p> ' , $ twig ->load ('index ' )->render ([]));
442442 }
443443
444- public function testSandboxDisabledAfterIncludeFunctionError ()
444+ public function testSandboxDisabledAfterRenderFunctionError ()
445445 {
446446 $ twig = $ this ->getEnvironment (false , [], self ::$ templates );
447447
448448 $ e = null ;
449449 try {
450- $ twig ->load ('1_include ' )->render (self ::$ params );
450+ $ twig ->load ('1_render ' )->render (self ::$ params );
451451 } catch (\Throwable $ e ) {
452452 }
453453 if (null === $ e ) {
454454 $ this ->fail ('An exception should be thrown for this test to be valid. ' );
455455 }
456456
457- $ this ->assertFalse ($ twig ->getExtension (SandboxExtension::class)->isSandboxed (), 'Sandboxed include () function call should not leave Sandbox enabled when an error occurs. ' );
457+ $ this ->assertFalse ($ twig ->getExtension (SandboxExtension::class)->isSandboxed (), 'Sandboxed render () function call should not leave Sandbox enabled when an error occurs. ' );
458458 }
459459
460460 public function testSandboxWithNoClosureFilter ()
0 commit comments