Skip to content

Commit 0916fce

Browse files
committed
Add test coverage for people trying to get extra clever.
1 parent 80d6f9e commit 0916fce

1 file changed

Lines changed: 44 additions & 1 deletion

File tree

tests/CascadeTest.php

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class CascadeTest extends TestCase
1212
{
13-
public function tearDown(): void
13+
protected function tearDown(): void
1414
{
1515
if ($this->files->exists($path = base_path('custom_seo.yaml'))) {
1616
$this->files->delete($path);
@@ -126,6 +126,49 @@ public function it_parses_antlers()
126126
$this->assertEquals('RED', $data['description']);
127127
}
128128

129+
public static function phpInAntlersProvider()
130+
{
131+
return [
132+
[
133+
'{{? echo "php used" ?}}',
134+
'{{? echo "php used" ?}}',
135+
],
136+
[
137+
'{{$ "php used" $}}',
138+
'{{$ "php used" $}}',
139+
],
140+
[
141+
"{{ _php_used = '@{@{' + '? echo \"php used\" ?' + '@}}'; _php_used | antlers /}}",
142+
'{{? echo "php used" ?}}',
143+
],
144+
[
145+
"{{ _php_used = (['' => ''] | json); _open = (_php_used | at(0)); _close = (_php_used | at(6)); _antlers_modified = _open + _open + '? echo \"php used\" ?' + _close + _close; _antlers_modified | antlers /}}",
146+
'{{? echo "php used" ?}}',
147+
],
148+
];
149+
}
150+
151+
/**
152+
* @test
153+
*
154+
* @dataProvider phpInAntlersProvider
155+
*/
156+
public function it_doesnt_parse_php_in_antlers($antlers, $output)
157+
{
158+
$entry = Entry::findByUri('/about')->entry();
159+
160+
$data = (new Cascade)
161+
->with(SiteDefaults::load()->all())
162+
->with([
163+
'description' => $antlers,
164+
])
165+
->withCurrent($entry)
166+
->get();
167+
168+
$this->assertNotEquals('hello', $data['description']);
169+
$this->assertEquals($output, $data['description']);
170+
}
171+
129172
/** @test */
130173
public function it_parses_field_references()
131174
{

0 commit comments

Comments
 (0)