Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor detail, but this file shoud be named IncludeToRenderFunctionRuleTest.fixed.twig (the Test suffix is missing)

tests/Rules/Function/IncludeToRender/IncludeToRenderFunctionRuleTest.fixed.twig

Original file line number Diff line number Diff line change
@@ -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) }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace TwigCsFixer\Tests\Rules\Function\RenderFunction;

use TwigCsFixer\Rules\Function\IncludeToRenderFunctionRule;
use TwigCsFixer\Rules\Punctuation\PunctuationSpacingRule;
use TwigCsFixer\Test\AbstractRuleTestCase;

final class IncludeToRenderFunctionRuleTest extends AbstractRuleTestCase
{
public function testRule(): void
{
$this->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.',
]
);
}
}
Original file line number Diff line number Diff line change
@@ -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) }}