Exemple #1
0
{
    $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;
                }
            }
        }
    }
    return $fileList;
}
echo '<pre>';
$fileList = readDirectory(dirname(__FILE__) . '/../../js');
foreach ($fileList as $file) {
    echo '<h2>' . $file . '</h2>';
    $js = file_get_contents($file);
    if (!$lint->Lint($js)) {
        echo "bad js code! full output:\n";
        echo $lint->output();
    } else {
        echo $lint->output();
    }
}
?>
</body>
</html>
 /**
  * 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);
         }
     }
 }