function run_all_tests() { // list .phpt files in specified directories $test_files =& list_test_files(); // generate HTML that requests .phpt tests asynchronously and in parallel ?> <ul id='list'> </ul> <script type="text/javascript"> files = <?php emit_js_array(&$test_files); ?> ; </script> <?php }
<?php $action = isset($_GET["action"]) ? $_GET["action"] : "welcome"; $welcome = "<h1 class='well'>Aiki2 Test Suite</h1>"; switch ($action) { case "welcome": $welcome = "\n\t<div class='hero-unit'>\n <h1>Aiki2 Test Suite</h1>\n <p class='lead'>Test-driven development</p>\n </div>"; case "home": $content = list_test_files(); break; case "test": $file = basename($_GET["file"]); ob_start(); include $file; echo "<div class='actions'><a class='btn btn-primary' href='index.php?action=home'><i class='icon-repeat icon-white'></i> list of test</a></p>"; $content = ob_get_contents(); ob_clean(); break; } function list_test_files() { $files = false; foreach (glob("*.php") as $file) { if (substr($file, 0, 5) == "test_") { $files[] = $file; } } if (!$files) { return "No test files found"; } $ret .= "<table class='table table-striped'><thead><th>filename</th><th>action</th></thead>\n<tbody>";