From d9e8b3b6a2b80e6f79b04e53e7351777b1921fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renan=20Gonc=CC=A7alves?= Date: Fri, 21 Oct 2011 12:20:31 +0200 Subject: [PATCH] Parsing every parameter until there is no more. Good to have alias but with the ability to override the arguments. --- lib/Cake/Console/ShellDispatcher.php | 3 +-- .../Test/Case/Console/ShellDispatcherTest.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index f40aa7350..e3320fc7b 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -288,8 +288,7 @@ class ShellDispatcher { $parsed = array(); $keys = array('-working', '--working', '-app', '--app', '-root', '--root'); foreach ($keys as $key) { - $index = array_search($key, $args); - if ($index !== false) { + while (($index = array_search($key, $args)) !== false) { $keyname = str_replace('-', '', $key); $valueIndex = $index + 1; $parsed[$keyname] = $args[$valueIndex]; diff --git a/lib/Cake/Test/Case/Console/ShellDispatcherTest.php b/lib/Cake/Test/Case/Console/ShellDispatcherTest.php index 2e2991974..303ff802e 100644 --- a/lib/Cake/Test/Case/Console/ShellDispatcherTest.php +++ b/lib/Cake/Test/Case/Console/ShellDispatcherTest.php @@ -365,6 +365,25 @@ class ShellDispatcherTest extends CakeTestCase { $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); + $params = array( + '/cake/1.2.x.x/cake/console/cake.php', + 'bake', + '-app', + 'new', + '-app', + 'old', + '-working', + '/var/www/htdocs' + ); + $expected = array( + 'app' => 'old', + 'webroot' => 'webroot', + 'working' => str_replace('/', DS, '/var/www/htdocs/old'), + 'root' => str_replace('/', DS,'/var/www/htdocs') + ); + $Dispatcher->parseParams($params); + $this->assertEqual($expected, $Dispatcher->params); + if (DS === '\\') { $params = array( 'cake.php',