Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added test coverage for Report.

  • Loading branch information...
commit d4a14da94596cfb54794e770cb3142e727ee53e9 1 parent 986bc9e
@indiefan indiefan authored gwoo committed
View
2  libraries/lithium/console/command/Test.php
@@ -97,7 +97,7 @@ public function run() {
$this->out('done.', 2);
$this->hr();
- $this->out($report->render('stats', $report->stats()));
+ $this->out($report->render('stats'));
if ($filterResults = $report->filters("\n")) {
$this->out($filterResults);
View
5 libraries/lithium/test/Report.php
@@ -69,7 +69,7 @@ public function __construct(array $config = array()) {
'group' => null,
'filters' => array(),
'format' => 'txt',
- 'reporter' => 'txt'
+ 'reporter' => 'console'
);
parent::__construct((array) $config + $defaults);
}
@@ -204,6 +204,9 @@ function($value) { return is_array($value) ? count($value) : $value; },
*/
public function render($template, $data = array()) {
$config = $this->_config;
+ if ($template == "stats") {
+ $data = $this->stats();
+ }
$template = Libraries::locate("test.templates.{$config['reporter']}", $template, array(
'filter' => false, 'type' => 'file', 'suffix' => ".{$config['format']}.php",
));
View
2  libraries/lithium/test/templates/html/layout.html.php
@@ -54,7 +54,7 @@ function($class) use ($request) {
)); ?>
</span>
<?php
- echo $report->render("stats", $report->stats());
+ echo $report->render("stats");
echo $report->filters();
?>
View
44 libraries/lithium/tests/cases/test/ReportTest.php
@@ -10,6 +10,7 @@
use \lithium\test\Report;
use \lithium\test\Group;
+//use \lithium\test\filter\Complexity;
class ReportTest extends \lithium\test\Unit {
@@ -48,6 +49,49 @@ public function testStats() {
$this->assertTrue($result['success']);
}
+
+ public function testSingleFilter() {
+ $report = new Report(array(
+ 'title' => '\lithium\tests\mocks\test\MockUnitTest',
+ 'group' => new Group(array('items' => array('\lithium\tests\mocks\test\MockUnitTest'))),
+ 'filters' => array("Complexity" => "")
+ ));
+ $report->run();
+
+ $class = 'lithium\test\filter\Complexity';
+ $this->assertNotEqual(null, $report->results['filters'][$class]);
+ }
+
+ public function testRender() {
+ $report = new Report(array(
+ 'title' => '\lithium\tests\mocks\test\MockUnitTest',
+ 'group' => new Group(array('items' => array('\lithium\tests\mocks\test\MockUnitTest'))),
+ 'format' => 'html',
+ 'reporter' => 'html'
+ ));
+ $report->run();
+
+ $output = $report->render("stats");
+
+ $this->assertPattern("/1 \/ 1 passes, 0 fails and 0 exceptions/", $output);
+ }
+
+ public function testFilters() {
+ $report = new Report(array(
+ 'title' => '\lithium\tests\mocks\test\filters\MockCoverageClassTest',
+ 'group' => new Group(
+ array('items' => array('\lithium\tests\mocks\test\filters\MockCoverageClassTest'))
+ ),
+ 'filters' => array("Complexity" => ""),
+ 'format' => 'html',
+ 'reporter' => 'html'
+ ));
+ $report->run();
+
+ $output = $report->filters();
+
+ $this->assertPattern("/<h3>Cyclomatic Complexity<\/h3>/", $output);
+ }
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.