mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing the CommandList shell, renaming the TestSuiteShell to TestsuiteShell for BC
This commit is contained in:
parent
0c9f4c1935
commit
48b3593a25
5 changed files with 22 additions and 27 deletions
|
@ -16,6 +16,8 @@
|
|||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
App::uses('Inflector', 'Utility');
|
||||
|
||||
/**
|
||||
* Shows a list of commands available from the console.
|
||||
*
|
||||
|
@ -79,17 +81,18 @@ class CommandListShell extends Shell {
|
|||
protected function _getShellList() {
|
||||
$shellList = array();
|
||||
|
||||
$corePaths = App::core('shells');
|
||||
$shellList = $this->_appendShells('CORE', $corePaths, $shellList);
|
||||
$shells = App::objects('file', App::core('Console/Command'));
|
||||
$shellList = $this->_appendShells('CORE', $shells, $shellList);
|
||||
|
||||
$appPaths = array_diff(App::path('shells'), $corePaths);
|
||||
$shellList = $this->_appendShells('app', $appPaths, $shellList);
|
||||
$appShells = App::objects('Console/Command', null, false);
|
||||
$shellList = $this->_appendShells('app', $appShells, $shellList);
|
||||
|
||||
$plugins = App::objects('plugin');
|
||||
foreach ($plugins as $plugin) {
|
||||
$pluginPath = App::pluginPath($plugin) . 'console' . DS . 'shells' . DS;
|
||||
$shellList = $this->_appendShells($plugin, array($pluginPath), $shellList);
|
||||
$pluginShells = App::objects($plugin . '.Console/Command');
|
||||
$shellList = $this->_appendShells($plugin, $pluginShells, $shellList);
|
||||
}
|
||||
|
||||
return $shellList;
|
||||
}
|
||||
|
||||
|
@ -98,20 +101,10 @@ class CommandListShell extends Shell {
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _appendShells($type, $paths, $shellList) {
|
||||
foreach ($paths as $path) {
|
||||
if (!is_dir($path)) {
|
||||
continue;
|
||||
}
|
||||
$shells = App::objects('file', $path);
|
||||
|
||||
if (empty($shells)) {
|
||||
continue;
|
||||
}
|
||||
foreach ($shells as $shell) {
|
||||
$shell = str_replace('Shell.php', '', $shell);
|
||||
$shellList[$shell][$type] = $type;
|
||||
}
|
||||
protected function _appendShells($type, $shells, $shellList) {
|
||||
foreach ($shells as $shell) {
|
||||
$shell = Inflector::underscore(str_replace('Shell', '', $shell));
|
||||
$shellList[$shell][$type] = $type;
|
||||
}
|
||||
return $shellList;
|
||||
}
|
||||
|
|
|
@ -454,7 +454,7 @@ class App {
|
|||
if ($type === 'file' && !$path) {
|
||||
return false;
|
||||
} elseif ($type === 'file') {
|
||||
$extension = '/.*/';
|
||||
$extension = '/\.php$/';
|
||||
$name = $type . str_replace(DS, '', $path);
|
||||
}
|
||||
|
||||
|
@ -477,9 +477,10 @@ class App {
|
|||
$files = new RegexIterator(new DirectoryIterator($dir), $extension);
|
||||
foreach ($files as $file) {
|
||||
if (!$file->isDot()) {
|
||||
if ($file->isDir() && $includeDirectories) {
|
||||
$isDir = $file->isDir() ;
|
||||
if ($isDir && $includeDirectories) {
|
||||
$objects[] = basename($file);
|
||||
} elseif (!$includeDirectories) {
|
||||
} elseif (!$includeDirectories && !$isDir) {
|
||||
$objects[] = substr(basename($file), 0, -4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
*/
|
||||
|
||||
App::uses('CommandListShell', 'Console/Command');
|
||||
App::uses('ConsoleOutput', 'Console');
|
||||
App::uses('ConsoleInput', 'Console');
|
||||
App::uses('Shell', 'Console');
|
||||
|
||||
|
||||
class TestStringOutput extends ConsoleOutput {
|
||||
|
@ -40,10 +43,7 @@ class CommandListTest extends CakeTestCase {
|
|||
'plugins' => array(
|
||||
LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
|
||||
),
|
||||
'shells' => array(
|
||||
CORE_PATH ?
|
||||
CORE_PATH . CAKE . 'console' . DS . 'shells' . DS :
|
||||
CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'console' . DS . 'shells' .DS,
|
||||
'Console/Command' => array(
|
||||
LIBS . 'tests' . DS . 'test_app' . DS . 'console' . DS . 'shells' . DS
|
||||
)
|
||||
), true);
|
||||
|
@ -84,6 +84,7 @@ class CommandListTest extends CakeTestCase {
|
|||
$expected = "/welcome \[.*TestPluginTwo.*\]/";
|
||||
$this->assertPattern($expected, $output);
|
||||
|
||||
|
||||
$expected = "/acl \[.*CORE.*\]/";
|
||||
$this->assertPattern($expected, $output);
|
||||
|
||||
|
|
Loading…
Reference in a new issue