-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test examples for include to render #327
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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']) }} | ||
alexander-schranz marked this conversation as resolved.
Show resolved
Hide resolved
|
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( | ||
[ | ||
Check failure on line 16 in tests/Rules/Function/IncludeToRender/IncludeToRenderFunctionRuleTest.php GitHub Actions / PHPStan
Check failure on line 16 in tests/Rules/Function/IncludeToRender/IncludeToRenderFunctionRuleTest.php GitHub Actions / PsalmMixedArgumentTypeCoercion
|
||
new IncludeToRenderFunctionRule(), | ||
Check failure on line 17 in tests/Rules/Function/IncludeToRender/IncludeToRenderFunctionRuleTest.php GitHub Actions / PHPStan
Check failure on line 17 in tests/Rules/Function/IncludeToRender/IncludeToRenderFunctionRuleTest.php GitHub Actions / PsalmUndefinedClass
|
||
// 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) }} |
There was a problem hiding this comment.
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