Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Test command can now find and run test for a given file.

Directories aren't yet supported.
Updating docblock with example.
  • Loading branch information...
commit 2d52c6a15c6b7a0e986379e57fa3f450a3468bd5 1 parent dd3b3c6
David Persson davidpersson authored
Showing with 16 additions and 2 deletions.
  1. +16 −2 console/command/Test.php
18 console/command/Test.php
View
@@ -10,6 +10,7 @@
use lithium\core\Libraries;
use lithium\test\Dispatcher;
+use lithium\test\Unit;
/**
* Runs a given set of tests and outputs the results.
@@ -181,15 +182,28 @@ protected function _init() {
* li3 test <plugin>/tests/cases
* }}}
*
- * @param string $path Absolute or relative path to tests.
+ *
+ * This will run `<library>/tests/cases/<package>/<class>Test.php`:
+ *
+ * {{{
+ * li3 test <library>/<package>/<class>.php
+ * }}}
+ *
+ * @param string $path Absolute or relative path to tests or a file which
+ * corresponding test should be run.
* @return boolean Will exit with status `1` if one or more tests failed otherwise with `0`.
*/
public function run($path = null) {
if (!$path = $this->_path($path)) {
return false;
}
+ if (strpos($path, 'tests') === false) {
+ if (!$path = Unit::get($path)) {
+ $this->error('Cannot map path to test path.');
+ return false;
+ }
+ }
$handlers = $this->_handlers;
-
if (!isset($handlers[$this->format]) || !is_callable($handlers[$this->format])) {
$this->error(sprintf('No handler for format `%s`... ', $this->format));
return false;
Please sign in to comment.
Something went wrong with that request. Please try again.