public function requireJs(array $json = array())
{
// Encode the array to a JSON array.
$js = JsonFile::encode($json);
// Construct the JavaScript output.
$output = <<<EOT
var components = {$js};
if (typeof require !== "undefined" && require.config) {
require.config(components);
} else {
var require = components;
}
if (typeof exports !== "undefined" && typeof module !== "undefined") {
module.exports = components;
}
EOT;
return $output;
}
/** * testRequireJs * * @dataProvider providerRequireJs * @param array $json * @param string $expected */ public function testRequireJs(array $json = array(), $expected = '') { $result = $this->process->requireJs($json); $this->assertEquals($expected, $result); }