protected function _path($path)
{
$path = rtrim(str_replace('\\', '/', $path), '/');
if (!$path) {
$this->error('Please provide a path to tests.');
return false;
}
if ($path[0] === '/') {
$library = $this->_library($path);
}
if ($path[0] !== '/') {
$libraries = array_reduce(Libraries::get(), function ($v, $w) {
$v[] = basename($w['path']);
return $v;
});
$library = $this->_library($this->request->env('working') . '/' . $path);
$parts = explode('/', str_replace("../", "", $path));
$plugin = array_shift($parts);
if ($plugin === 'libraries') {
$plugin = array_shift($parts);
}
if (in_array($plugin, $libraries)) {
$library = $plugin;
$path = join('/', $parts);
}
}
if (empty($library)) {
$this->error("No library found in path `{$path}`.");
return false;
}
if (!($config = Libraries::get($library))) {
$this->error("Library `{$library}` does not exist.");
return false;
}
$path = str_replace($config['path'], null, $path);
$realpath = $config['path'] . '/' . $path;
if (!realpath($realpath)) {
$this->error("Path `{$realpath}` not found.");
return false;
}
$class = str_replace(".php", "", str_replace('/', '\\', ltrim($path, '/')));
return $config['prefix'] . $class;
}