Skip to content

Commit 459fa29

Browse files
committed
Update tests according the format changes
1 parent 9fb15a5 commit 459fa29

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

tests/JsPhpize/JsPhpizePhugTest.php

+23-6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ public function testPlug()
1414
'compiler_modules' => [JsPhpizePhug::class],
1515
]);
1616

17+
ob_start();
18+
$php = $compiler->compile('a(data-foo={message: "Hello"})');
19+
eval('?>' . $php);
20+
$html = ob_get_contents();
21+
ob_end_clean();
22+
1723
self::assertSame(
18-
'<a data-foo="<?= htmlspecialchars((is_array($_pug_temp = array( \'message\' => "Hello" )) || (is_object($_pug_temp) && !method_exists($_pug_temp, "__toString")) ? json_encode($_pug_temp) : strval($_pug_temp))) ?>"></a>',
19-
$compiler->compile('a(data-foo={message: "Hello"})')
24+
'<a data-foo="{&quot;message&quot;:&quot;Hello&quot;}"></a>',
25+
$html
2026
);
2127

2228
$compiler = new Compiler([
@@ -57,18 +63,29 @@ public function testPlug()
5763
'compiler_modules' => [JsPhpizePhug::class],
5864
]);
5965

66+
ob_start();
67+
$foo = '<a>" b="b';
68+
$php = $compiler->compile('a(foo?!=foo)');
69+
eval('?>' . $php);
70+
$html = ob_get_contents();
71+
ob_end_clean();
6072
self::assertSame(
61-
'<a foo="<?= (is_array($_pug_temp = $foo) || (is_object($_pug_temp) && !method_exists($_pug_temp, "__toString")) ? json_encode($_pug_temp) : strval($_pug_temp)) ?>"></a>',
62-
$compiler->compile('a(foo?!=foo)')
73+
'<a foo="<a>" b="b"></a>',
74+
$html
6375
);
6476

6577
$compiler = new Compiler([
6678
'compiler_modules' => [JsPhpizePhug::class],
6779
]);
6880

81+
ob_start();
82+
$php = $compiler->compile('a(foo=array("foo" => "bar")[\'foo\'])');
83+
eval('?>' . $php);
84+
$html = ob_get_contents();
85+
ob_end_clean();
6986
self::assertSame(
70-
'<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>',
71-
$compiler->compile('a(foo?!=array("foo" => "bar")[\'foo\'])')
87+
'<a foo="bar"></a>',
88+
$html
7289
);
7390
}
7491

0 commit comments

Comments
 (0)