From 94fc492623fbc4f6dd042cca84109dcb8cc45194 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 6 Jun 2010 22:39:04 -0400 Subject: [PATCH] Correcting how ExtractTask collects files. Test added. Fixes #775 --- cake/console/libs/tasks/extract.php | 2 +- .../cases/console/libs/tasks/extract.test.php | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/cake/console/libs/tasks/extract.php b/cake/console/libs/tasks/extract.php index 8ce1be068..5dc928b04 100644 --- a/cake/console/libs/tasks/extract.php +++ b/cake/console/libs/tasks/extract.php @@ -488,7 +488,7 @@ class ExtractTask extends Shell { foreach ($this->__paths as $path) { $Folder = new Folder($path); $files = $Folder->findRecursive('.*\.(php|ctp|thtml|inc|tpl)', true); - $this->__files += $files; + $this->__files = array_merge($this->__files, $files); } } } diff --git a/cake/tests/cases/console/libs/tasks/extract.test.php b/cake/tests/cases/console/libs/tasks/extract.test.php index 29c4f2bd8..f93a9a6a7 100644 --- a/cake/tests/cases/console/libs/tasks/extract.test.php +++ b/cake/tests/cases/console/libs/tasks/extract.test.php @@ -155,4 +155,33 @@ class ExtractTaskTest extends CakeTestCase { $Folder = new Folder($path); $Folder->delete(); } + function getTests() { + return array('start', 'startCase', 'testExtractMultiplePaths', 'endCase', 'end'); + } + +/** + * test extract can read more than one path. + * + * @return void + */ + function testExtractMultiplePaths() { + $path = TMP . 'tests' . DS . 'extract_task_test'; + new Folder($path . DS . 'locale', true); + + $this->Task->interactive = false; + + $this->Task->params['paths'] = + TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'pages,' . + TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'posts'; + + $this->Task->params['output'] = $path . DS; + $this->Task->Dispatch->expectNever('stderr'); + $this->Task->Dispatch->expectNever('_stop'); + $this->Task->execute(); + + $result = file_get_contents($path . DS . 'default.pot'); + + $pattern = '/msgid "Add User"/'; + $this->assertPattern($pattern, $result); + } }