diff --git a/tests/Rules/Function/IncludeToRender/IncludeToRenderFunctionRule.fixed.twig b/tests/Rules/Function/IncludeToRender/IncludeToRenderFunctionRule.fixed.twig new file mode 100644 index 00000000..d5035fb4 --- /dev/null +++ b/tests/Rules/Function/IncludeToRender/IncludeToRenderFunctionRule.fixed.twig @@ -0,0 +1,17 @@ +{{ render('template.html', _context) }} +{{ render('template.html', {..._context, 'foo': 'bar'}) }} +{{ render('template.html', {..._context, 'foo': 'bar'}, true) }} +{{ render('template.html', {..._context, 'foo': 'bar'}, true, true) }} +{{ render('template.html', _context) }} + +{{ render(['template_a.html', 'template_b.html'], _context) }} +{{ render(['template_a.html', 'template_b.html'], {..._context, 'foo': 'bar'}) }} +{{ render(['template_a.html', 'template_b.html'], {..._context, 'foo': 'bar'}, true) }} +{{ render(['template_a.html', 'template_b.html'], {..._context, 'foo': 'bar'}, true, true) }} +{{ render(['template_a.html', 'template_b.html'], _context) }} + +{{ render(['template_a.html', 'template_b.html']) }} +{{ render(['template_a.html', 'template_b.html'], {'foo': 'bar'}) }} +{{ render(['template_a.html', 'template_b.html'], {'foo': 'bar'}, true) }} +{{ render(['template_a.html', 'template_b.html'], {'foo': 'bar'}, true, true) }} +{{ render(['template_a.html', 'template_b.html'], _context) }} diff --git a/tests/Rules/Function/IncludeToRender/IncludeToRenderFunctionRuleTest.php b/tests/Rules/Function/IncludeToRender/IncludeToRenderFunctionRuleTest.php new file mode 100644 index 00000000..af5bd855 --- /dev/null +++ b/tests/Rules/Function/IncludeToRender/IncludeToRenderFunctionRuleTest.php @@ -0,0 +1,29 @@ +checkRule( + [ + new IncludeToRenderFunctionRule(), + // Extra rule for a better diff + new PunctuationSpacingRule(), + ], + [ + 'IncludeToRender.Error:13:4' => 'Include function must be used instead of include tag.', + 'IncludeToRender.Error:14:4' => 'Include function must be used instead of include tag.', + 'IncludeToRender.Error:15:5' => 'Include function must be used instead of include tag.', + 'IncludeToRender.Error:16:5' => 'Include function must be used instead of include tag.', + ] + ); + } +} diff --git a/tests/Rules/Function/IncludeToRender/IncludeToRenderFunctionRuleTest.twig b/tests/Rules/Function/IncludeToRender/IncludeToRenderFunctionRuleTest.twig new file mode 100644 index 00000000..fcc68ad1 --- /dev/null +++ b/tests/Rules/Function/IncludeToRender/IncludeToRenderFunctionRuleTest.twig @@ -0,0 +1,17 @@ +{{ include('template.html') }} +{{ include('template.html', {'foo': 'bar'}, true) }} +{{ include('template.html', {'foo': 'bar'}, true, true) }} +{{ include('template.html', {'foo': 'bar'}, true, true, true) }} +{{ include('template.html', with_context = true) }} + +{{ include(['template_a.html', 'template_b.html']) }} +{{ include(['template_a.html', 'template_b.html'], {'foo': 'bar'}, true) }} +{{ include(['template_a.html', 'template_b.html'], {'foo': 'bar'}, true, true) }} +{{ include(['template_a.html', 'template_b.html'], {'foo': 'bar'}, true, true, true) }} +{{ include(['template_a.html', 'template_b.html'], with_context = true) }} + +{{ include(['template_a.html', 'template_b.html'], with_context = false) }} +{{ include(['template_a.html', 'template_b.html'], {'foo': 'bar'}, false) }} +{{ include(['template_a.html', 'template_b.html'], {'foo': 'bar'}, false, true) }} +{{ include(['template_a.html', 'template_b.html'], {'foo': 'bar'}, false, true, true) }} +{{ include(['template_a.html', 'template_b.html'], with_context = true) }}