Skip to content

Commit 4c5b8f8

Browse files
committed
Add unit test for dot helper with array prototype
1 parent 97a7618 commit 4c5b8f8

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/helpers.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,25 @@ public function testHelperFile()
227227

228228
$this->assertEquals(6, $jsPhpize->render('13 + 7'));
229229
}
230+
231+
public function testDotHelperWithArrayPrototype()
232+
{
233+
$jsPhpize = new JsPhpize(array(
234+
'helpers' => array(
235+
'dot' => 'dotWithArrayPrototype',
236+
),
237+
'returnLastStatement' => true,
238+
));
239+
240+
file_put_contents(
241+
'error.php',
242+
"<?php\n".
243+
$jsPhpize->compile('a = [1,2,3]; a.filter(function (i) { return i % 2; })')
244+
);
245+
exit;
246+
$this->assertEquals(
247+
array(1, 3),
248+
$jsPhpize->render('a = [1,2,3]; a.filter(function (i) { return i % 2; })')
249+
);
250+
}
230251
}

0 commit comments

Comments
 (0)