test specific extensions
git-svn-id: file:///home/shish/svn/shimmie2/trunk@1085 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
8b1ce21465
commit
a124addf96
@ -7,12 +7,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
require_once('simpletest/web_tester.php');
|
require_once('simpletest/web_tester.php');
|
||||||
|
require_once('simpletest/unit_tester.php');
|
||||||
require_once('simpletest/reporter.php');
|
require_once('simpletest/reporter.php');
|
||||||
|
|
||||||
class AllTests extends TestSuite {
|
class TestFinder extends TestSuite {
|
||||||
function AllTests() {
|
function TestFinder($hint) {
|
||||||
|
$dir = "*";
|
||||||
|
if(file_exists("ext/$hint/test.php")) $dir = $hint; // FIXME: check for ..
|
||||||
$this->TestSuite('All tests');
|
$this->TestSuite('All tests');
|
||||||
foreach(glob("ext/*/test.php") as $file) {
|
foreach(glob("ext/$dir/test.php") as $file) {
|
||||||
$this->addFile($file);
|
$this->addFile($file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -24,12 +27,12 @@ class SimpleSCoreTest implements Extension {
|
|||||||
public function receive_event(Event $event) {
|
public function receive_event(Event $event) {
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
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_title("Test Results");
|
||||||
$event->page->set_heading("Test Results");
|
$event->page->set_heading("Test Results");
|
||||||
$event->page->add_block(new NavBlock());
|
$event->page->add_block(new NavBlock());
|
||||||
|
|
||||||
$all = new AllTests();
|
$all = new TestFinder($event->get_arg(0));
|
||||||
$all->run(new SCoreReporter($event->page));
|
$all->run(new SCoreReporter($event->page));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ class SCoreReporter extends HtmlReporter {
|
|||||||
|
|
||||||
public function SCoreReporter($page) {
|
public function SCoreReporter($page) {
|
||||||
$this->page = $page;
|
$this->page = $page;
|
||||||
|
$this->_fails = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function paintHeader($test_name) {
|
function paintHeader($test_name) {
|
||||||
@ -18,10 +19,18 @@ class SCoreReporter extends HtmlReporter {
|
|||||||
|
|
||||||
function paintFooter($test_name) {
|
function paintFooter($test_name) {
|
||||||
//parent::paintFooter($test_name);
|
//parent::paintFooter($test_name);
|
||||||
$html = "".
|
$fail = $this->getFailCount() > 0;
|
||||||
|
if($fail) {
|
||||||
|
$style = "background: red;";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$style = "background: green;";
|
||||||
|
}
|
||||||
|
$html = "<div style=\"padding: 4px; $style\">".
|
||||||
$this->getPassCount() . " passes, " .
|
$this->getPassCount() . " passes, " .
|
||||||
$this->getFailCount() . " failures" .
|
$this->getFailCount() . " failures" .
|
||||||
"<br>Passed modules: " . $this->clear_modules;
|
"<br>Passed modules: " . $this->clear_modules .
|
||||||
|
"</div>";
|
||||||
$this->page->add_block(new Block("Results", $html, "main", 40));
|
$this->page->add_block(new Block("Results", $html, "main", 40));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,13 +40,19 @@ class SCoreReporter extends HtmlReporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function paintGroupEnd($name) {
|
function paintGroupEnd($name) {
|
||||||
$name = substr($name, 4, strlen($name)-13);
|
$matches = array();
|
||||||
|
if(preg_match("#ext/(.*)/test.php#", $name, $matches)) {
|
||||||
|
$name = $matches[1];
|
||||||
|
$link = "<a href=\"".make_link("test/$name")."\"></a>";
|
||||||
|
}
|
||||||
parent::paintGroupEnd($name);
|
parent::paintGroupEnd($name);
|
||||||
if($this->current_html == "") {
|
if($this->current_html == "") {
|
||||||
$this->clear_modules .= "$name, ";
|
$this->clear_modules .= "$name, ";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
$this->current_html .= "<p>$link";
|
||||||
$this->page->add_block(new Block($name, $this->current_html, "main", 50));
|
$this->page->add_block(new Block($name, $this->current_html, "main", 50));
|
||||||
|
$this->current_html = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user