require_once 'private/JSLEngine.php'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <style type="text/css"> body { background: black; color: white; } </style> </head> <body> <?php $lint = new JSLEngine(); function readDirectory($dirName) { $fileList = array(); $dir = opendir($dirName); while ($file = readdir($dir)) { if ($file != '.' && $file != '..' && $file != 'ext') { if (is_dir($dirName . '/' . $file)) { $fileList = array_merge($fileList, readDirectory($dirName . '/' . $file)); } else { if (StringTool::endsWith($file, '.js')) { $fileList[] = $dirName . '/' . $file; } } } }
/** * Validates the JavaScript that composes the core widgets. */ function test_core_widget_javascript() { // Test JavaScript if (file_exists(WP_CONTENT_DIR . '/plugins/ibm-sbtk/tests/lib/jsl/_jsl_online.php')) { require 'lib/jsl/_jsl_online.php'; $engine = new JSLEngine('.priv/jsl', '.priv/jsl.server.conf'); if ($handle = opendir(WP_CONTENT_DIR . '/plugins/ibm-sbtk/views/widgets/')) { while (false !== ($widget = readdir($handle))) { if ($widget != "." && $widget != ".." && strtolower(substr($widget, strrpos($widget, '.') + 1)) == 'php') { $js = file_get_contents(WP_CONTENT_DIR . '/plugins/ibm-sbtk/views/widgets/' . $widget); $result = $engine->Lint($js); $this->assertTrue($result); } } closedir($handle); } } }