/**
  * The main entry point for the task.
  * @return bool
  * @throws BuildException
  */
 public function main()
 {
     if (empty($this->li3Base)) {
         throw new BuildException('"li3Base" is required');
     }
     if (empty($this->tests)) {
         throw new BuildException('"tests" is required');
     }
     if (empty($this->li3Env)) {
         $this->li3Env = 'test';
         putenv("LI3_ENV=test");
     }
     require_once $this->li3Base . '/app/config/bootstrap.php';
     if (!(include_once LITHIUM_LIBRARY_PATH . '/lithium/core/Libraries.php')) {
         $message = "Lithium core could not be found.  Check the value of LITHIUM_LIBRARY_PATH in ";
         $message .= __FILE__ . ".  It should point to the directory containing your ";
         $message .= "/libraries directory. " . LITHIUM_LIBRARY_PATH;
         throw new BuildException($message);
     }
     lithium\core\Libraries::add(basename(LITHIUM_APP_PATH), array('default' => true, 'path' => LITHIUM_APP_PATH));
     $group = $this->tests == 'all' ? lithium\test\Group::all() : $this->tests;
     $report = new lithium\test\Report(array('title' => 'Main Test Run', 'group' => new lithium\test\Group(array('data' => array('app\\tests'))), 'format' => 'html'));
     $result = $report->run();
     $stats = $report->stats();
     $formatter = new XmlFormatter($stats);
     $formatter->save_output($this->results);
     if (!$stats['success']) {
         throw new BuildException("Unit tests failed for {$this->tests}. {$stats['count']['passes']}/{$stats['count']['asserts']} passes. Check lithium's test suite for more information.");
     }
     return true;
 }
Exemple #2
0
$app = null;
/**
 * If we're not running inside an application (i.e. a self-bootstrapping library), bootstrap the
 * core automatically with the default settings.
 */
$bootstrap = function () use($working) {
    define('LITHIUM_LIBRARY_PATH', dirname(dirname(__DIR__)));
    define('LITHIUM_APP_PATH', $working);
    if (!(include LITHIUM_LIBRARY_PATH . '/lithium/core/Libraries.php')) {
        $message = "Lithium core could not be found.  Check the value of LITHIUM_LIBRARY_PATH in ";
        $message .= __FILE__ . ".  It should point to the directory containing your ";
        $message .= "/libraries directory.";
        throw new ErrorException($message);
    }
    lithium\core\Libraries::add('lithium');
    lithium\core\Libraries::add(basename($working), array('default' => true, 'path' => $working, 'resources' => sys_get_temp_dir()));
};
/**
 * The following will dispatch the request and exit with the status code as
 * provided by the `Response` object returned from `run()`.
 *
 * The following will instantiate a new `Request` object and pass it off to the
 * `Dispatcher` class.  By default, the `Request` will automatically aggregate
 * all the server / environment settings, and request content (i.e. options and
 * arguments passed to the command) information.
 *
 * The `Request` is then used by the `Dispatcher` (in conjunction with the
 * `Router`) to determine the correct command to dispatch to. The response
 * information is then encapsulated in a `Response` object, which is returned
 * from the command to the `Dispatcher`.
 *
Exemple #3
0
$bootstrap = function () use($working) {
    define('LITHIUM_LIBRARY_PATH', dirname(dirname(__DIR__)));
    define('LITHIUM_APP_PATH', $working);
    if (!(include LITHIUM_LIBRARY_PATH . '/lithium/core/Libraries.php')) {
        $message = "Lithium core could not be found.  Check the value of LITHIUM_LIBRARY_PATH in ";
        $message .= __FILE__ . ".  It should point to the directory containing your ";
        $message .= "/libraries directory.";
        throw new ErrorException($message);
    }
    $resources = sys_get_temp_dir();
    $templates = $resources . '/tmp/cache/templates/';
    if (!is_dir($templates)) {
        mkdir($resources . '/tmp/cache/templates/', 0777, true);
    }
    lithium\core\Libraries::add('lithium');
    lithium\core\Libraries::add(basename($working), array('default' => true, 'path' => $working, 'resources' => $resources));
};
/**
 * The following will dispatch the request and exit with the status code as
 * provided by the `Response` object returned from `run()`.
 *
 * The following will instantiate a new `Request` object and pass it off to the
 * `Dispatcher` class.  By default, the `Request` will automatically aggregate
 * all the server / environment settings, and request content (i.e. options and
 * arguments passed to the command) information.
 *
 * The `Request` is then used by the `Dispatcher` (in conjunction with the
 * `Router`) to determine the correct command to dispatch to. The response
 * information is then encapsulated in a `Response` object, which is returned
 * from the command to the `Dispatcher`.
 *
Exemple #4
0
}
if ($app && is_dir("{$app}/config/bootstrap") && file_exists("{$app}/webroot/index.php")) {
    include "{$app}/config/bootstrap.php";
    exit(lithium\console\Dispatcher::run(new lithium\console\Request())->status);
}
define('LITHIUM_LIBRARY_PATH', $library);
define('LITHIUM_APP_PATH', $app ? $working : dirname($library) . '/app');
if (!(include LITHIUM_LIBRARY_PATH . '/lithium/core/Libraries.php')) {
    $message = "Lithium core could not be found.  Check the value of LITHIUM_LIBRARY_PATH in ";
    $message .= __FILE__ . ".  It should point to the directory containing your ";
    $message .= "/libraries directory.";
    throw new ErrorException($message);
}
lithium\core\Libraries::add('lithium');
if ($app) {
    lithium\core\Libraries::add(basename(LITHIUM_APP_PATH), array('path' => LITHIUM_APP_PATH, 'default' => true, 'bootstrap' => !file_exists("{$app}/webroot/index.php")));
}
/**
 * The following will dispatch the request and exit with the status code as
 * provided by the `Response` object returned from `run()`.
 *
 * The following will instantiate a new `Request` object and pass it off to the
 * `Dispatcher` class.  By default, the `Request` will automatically aggregate
 * all the server / environment settings, and request content (i.e. options and
 * arguments passed to the command) information.
 *
 * The `Request` is then used by the `Dispatcher` (in conjunction with the
 * `Router`) to determine the correct command to dispatch to. The response
 * information is then encapsulated in a `Response` object, which is returned
 * from the command to the `Dispatcher`.
 *