mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
updating ShellDispatcher to pass tests
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8112 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
1c76e2e18e
commit
7f853532d9
2 changed files with 10 additions and 6 deletions
|
@ -198,10 +198,14 @@ class ShellDispatcher {
|
||||||
*/
|
*/
|
||||||
function __buildPaths() {
|
function __buildPaths() {
|
||||||
$paths = array();
|
$paths = array();
|
||||||
|
|
||||||
$pluginPaths = Configure::read('pluginPaths');
|
$pluginPaths = Configure::read('pluginPaths');
|
||||||
|
if (!class_exists('Folder')) {
|
||||||
|
require LIBS . 'folder.php';
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($pluginPaths as $pluginPath) {
|
foreach ($pluginPaths as $pluginPath) {
|
||||||
$plugins = Configure::listObjects('plugin', $pluginPath);
|
$Folder =& new Folder($pluginPath);
|
||||||
|
list($plugins,) = $Folder->read(false, true);
|
||||||
foreach ((array)$plugins as $plugin) {
|
foreach ((array)$plugins as $plugin) {
|
||||||
$path = $pluginPath . Inflector::underscore($plugin) . DS . 'vendors' . DS . 'shells' . DS;
|
$path = $pluginPath . Inflector::underscore($plugin) . DS . 'vendors' . DS . 'shells' . DS;
|
||||||
if (file_exists($path)) {
|
if (file_exists($path)) {
|
||||||
|
@ -262,7 +266,6 @@ class ShellDispatcher {
|
||||||
Configure::write('debug', 1);
|
Configure::write('debug', 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatches a CLI request
|
* Dispatches a CLI request
|
||||||
*
|
*
|
||||||
|
@ -542,16 +545,19 @@ class ShellDispatcher {
|
||||||
|
|
||||||
$this->stdout("\nAvailable Shells:");
|
$this->stdout("\nAvailable Shells:");
|
||||||
$_shells = array();
|
$_shells = array();
|
||||||
|
|
||||||
foreach ($this->shellPaths as $path) {
|
foreach ($this->shellPaths as $path) {
|
||||||
if (is_dir($path)) {
|
if (is_dir($path)) {
|
||||||
$shells = Configure::listObjects('file', $path);
|
$shells = Configure::listObjects('file', $path);
|
||||||
$path = str_replace(CORE_PATH, 'CORE/', $path);
|
$path = str_replace(CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS, 'CORE' . DS, $path);
|
||||||
|
$path = str_replace(APP, 'APP' . DS, $path);
|
||||||
$path = str_replace(ROOT, 'ROOT', $path);
|
$path = str_replace(ROOT, 'ROOT', $path);
|
||||||
$path = rtrim($path, DS);
|
$path = rtrim($path, DS);
|
||||||
$this->stdout("\n " . $path . ":");
|
$this->stdout("\n " . $path . ":");
|
||||||
if (empty($shells)) {
|
if (empty($shells)) {
|
||||||
$this->stdout("\t - none");
|
$this->stdout("\t - none");
|
||||||
} else {
|
} else {
|
||||||
|
sort($shells);
|
||||||
foreach ($shells as $shell) {
|
foreach ($shells as $shell) {
|
||||||
if ($shell !== 'shell.php') {
|
if ($shell !== 'shell.php') {
|
||||||
$this->stdout("\t " . str_replace('.php', '', $shell));
|
$this->stdout("\t " . str_replace('.php', '', $shell));
|
||||||
|
|
|
@ -456,12 +456,10 @@ class ShellDispatcherTest extends UnitTestCase {
|
||||||
$this->assertPattern($expected, $Dispatcher->stdout);
|
$this->assertPattern($expected, $Dispatcher->stdout);
|
||||||
|
|
||||||
$expected = "/ APP(\\\|\/)vendors(\\\|\/)shells:";
|
$expected = "/ APP(\\\|\/)vendors(\\\|\/)shells:";
|
||||||
$expected .= "\n\t - none";
|
|
||||||
$expected .= "\n/";
|
$expected .= "\n/";
|
||||||
$this->assertPattern($expected, $Dispatcher->stdout);
|
$this->assertPattern($expected, $Dispatcher->stdout);
|
||||||
|
|
||||||
$expected = "/ ROOT(\\\|\/)vendors(\\\|\/)shells:";
|
$expected = "/ ROOT(\\\|\/)vendors(\\\|\/)shells:";
|
||||||
$expected .= "\n\t - none";
|
|
||||||
$expected .= "\n/";
|
$expected .= "\n/";
|
||||||
$this->assertPattern($expected, $Dispatcher->stdout);
|
$this->assertPattern($expected, $Dispatcher->stdout);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue