lithium\console\command\Test::run PHP Method

run() public method

sh li3 test lithium/tests/cases/core/ObjectTest.php li3 test lithium/tests/cases/core If you are in the working directory of an application or plugin and wish to run all tests, simply execute the following: sh li3 test tests/cases If you are in the working directory of an application and wish to run a plugin, execute one of the following: sh li3 test libraries//tests/cases li3 test /tests/cases This will run /tests/cases//Test.php: sh li3 test //.php
public run ( string $path = null ) : integer | boolean
$path string Absolute or relative path to tests or a file which corresponding test should be run.
return integer | boolean Will (indirectly) 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 (!preg_match('/(tests|Test\\.php)/', $path)) {
            if (!($path = Unit::get($path))) {
                $this->error('Cannot map path to test path.');
                return static::EXIT_NO_TEST;
            }
        }
        $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;
        }
        $filters = $this->filters ? array_map('trim', explode(',', $this->filters)) : array();
        $params = compact('filters') + array('format' => $this->format);
        $runner = function ($options = array()) use($path, $params) {
            return Dispatcher::run($path, $params + $options);
        };
        $report = $handlers[$this->format]($runner, $path);
        $stats = $report->stats();
        return $stats['success'];
    }

Usage Example

Beispiel #1
0
 public function testJsonFormat()
 {
     $command = new Test(array('request' => $this->request, 'classes' => $this->classes));
     $path = LITHIUM_LIBRARY_PATH . '/lithium/tests/mocks/test/cases/MockTest.php';
     $command->format = 'json';
     $command->run($path);
     $result = $command->response->output;
     $result = json_decode($result, true);
     $this->assertTrue(isset($result['count']));
     $this->assertTrue(isset($result['stats']));
 }
All Usage Examples Of lithium\console\command\Test::run