diff --git a/contrib/simpletest/main.php b/contrib/simpletest/main.php index 52df5dce..997cb3c0 100644 --- a/contrib/simpletest/main.php +++ b/contrib/simpletest/main.php @@ -7,12 +7,15 @@ */ require_once('simpletest/web_tester.php'); +require_once('simpletest/unit_tester.php'); require_once('simpletest/reporter.php'); -class AllTests extends TestSuite { - function AllTests() { +class TestFinder extends TestSuite { + function TestFinder($hint) { + $dir = "*"; + if(file_exists("ext/$hint/test.php")) $dir = $hint; // FIXME: check for .. $this->TestSuite('All tests'); - foreach(glob("ext/*/test.php") as $file) { + foreach(glob("ext/$dir/test.php") as $file) { $this->addFile($file); } } @@ -24,12 +27,12 @@ class SimpleSCoreTest implements Extension { public function receive_event(Event $event) { if(is_null($this->theme)) $this->theme = get_theme_object($this); - if(($event instanceof PageRequestEvent) && $event->page_matches("test/all")) { + if(($event instanceof PageRequestEvent) && $event->page_matches("test")) { $event->page->set_title("Test Results"); $event->page->set_heading("Test Results"); $event->page->add_block(new NavBlock()); - $all = new AllTests(); + $all = new TestFinder($event->get_arg(0)); $all->run(new SCoreReporter($event->page)); } diff --git a/contrib/simpletest/theme.php b/contrib/simpletest/theme.php index c8879bd7..5a4049fd 100644 --- a/contrib/simpletest/theme.php +++ b/contrib/simpletest/theme.php @@ -9,6 +9,7 @@ class SCoreReporter extends HtmlReporter { public function SCoreReporter($page) { $this->page = $page; + $this->_fails = 0; } function paintHeader($test_name) { @@ -18,10 +19,18 @@ class SCoreReporter extends HtmlReporter { function paintFooter($test_name) { //parent::paintFooter($test_name); - $html = "". + $fail = $this->getFailCount() > 0; + if($fail) { + $style = "background: red;"; + } + else { + $style = "background: green;"; + } + $html = "
". $this->getPassCount() . " passes, " . $this->getFailCount() . " failures" . - "
Passed modules: " . $this->clear_modules; + "
Passed modules: " . $this->clear_modules . + "
"; $this->page->add_block(new Block("Results", $html, "main", 40)); } @@ -31,13 +40,19 @@ class SCoreReporter extends HtmlReporter { } function paintGroupEnd($name) { - $name = substr($name, 4, strlen($name)-13); + $matches = array(); + if(preg_match("#ext/(.*)/test.php#", $name, $matches)) { + $name = $matches[1]; + $link = ""; + } parent::paintGroupEnd($name); if($this->current_html == "") { $this->clear_modules .= "$name, "; } else { + $this->current_html .= "

$link"; $this->page->add_block(new Block($name, $this->current_html, "main", 50)); + $this->current_html = ""; } }