Skip to content

Commit 7875670

Browse files
committed
Add tests
1 parent 58e0d3b commit 7875670

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/JsPhpize/JsPhpizePhugTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,34 @@ public function testPlug()
1818
$compiler->compile('a(data-foo={message: "Hello"})')
1919
);
2020

21+
$compiler = new Compiler([
22+
'modules' => [JsPhpizePhug::class],
23+
]);
24+
25+
ob_start();
26+
$other = array('message' => 'Bye');
27+
$php = $compiler->compile('a(data-foo={message: other.message})');
28+
eval('?>' . $php);
29+
$html = ob_get_contents();
30+
ob_end_clean();
31+
self::assertSame(
32+
'<a data-foo="{&quot;message&quot;:&quot;Bye&quot;}"></a>',
33+
$html
34+
);
35+
36+
$compiler = new Compiler([
37+
'modules' => [JsPhpizePhug::class],
38+
]);
39+
2140
self::assertSame(
2241
'<a foo="<?= (is_array($_pug_temp = $foo) || (is_object($_pug_temp) && !method_exists($_pug_temp, "__toString")) ? json_encode($_pug_temp) : strval($_pug_temp)) ?>"></a>',
2342
$compiler->compile('a(foo?!=foo)')
2443
);
2544

45+
$compiler = new Compiler([
46+
'modules' => [JsPhpizePhug::class],
47+
]);
48+
2649
self::assertSame(
2750
'<a foo="<?= (is_array($_pug_temp = array("foo" => "bar")[\'foo\']) || (is_object($_pug_temp) && !method_exists($_pug_temp, "__toString")) ? json_encode($_pug_temp) : strval($_pug_temp)) ?>"></a>',
2851
$compiler->compile('a(foo?!=array("foo" => "bar")[\'foo\'])')

0 commit comments

Comments
 (0)