diff --git a/src/Shell/Task/ExtractTask.php b/src/Shell/Task/ExtractTask.php index 0830ac997b1..155410124fb 100644 --- a/src/Shell/Task/ExtractTask.php +++ b/src/Shell/Task/ExtractTask.php @@ -482,9 +482,10 @@ protected function _buildFiles() $sentence .= "msgstr[1] \"\"\n\n"; } - $this->_store($domain, $header, $sentence); if ($domain !== 'default' && $this->_merge) { $this->_store('default', $header, $sentence); + } else { + $this->_store($domain, $header, $sentence); } } } diff --git a/tests/TestCase/Shell/Task/ExtractTaskTest.php b/tests/TestCase/Shell/Task/ExtractTaskTest.php index c7481933b92..ae86691fb37 100644 --- a/tests/TestCase/Shell/Task/ExtractTaskTest.php +++ b/tests/TestCase/Shell/Task/ExtractTaskTest.php @@ -69,11 +69,11 @@ public function tearDown() */ public function testExecute() { - $this->Task->interactive = false; - $this->Task->params['paths'] = TEST_APP . 'TestApp' . DS . 'Template' . DS . 'Pages'; $this->Task->params['output'] = $this->path . DS; $this->Task->params['extract-core'] = 'no'; + $this->Task->params['merge'] = 'no'; + $this->Task->expects($this->never())->method('err'); $this->Task->expects($this->any())->method('in') ->will($this->returnValue('y')); @@ -132,6 +132,29 @@ public function testExecute() $this->assertRegExp($pattern, $result); } + /** + * testExecute with merging on method + * + * @return void + */ + public function testExecuteMerge() + { + $this->Task->params['paths'] = TEST_APP . 'TestApp' . DS . 'Template' . DS . 'Pages'; + $this->Task->params['output'] = $this->path . DS; + $this->Task->params['extract-core'] = 'no'; + $this->Task->params['merge'] = 'yes'; + + $this->Task->expects($this->never())->method('err'); + $this->Task->expects($this->any())->method('in') + ->will($this->returnValue('y')); + $this->Task->expects($this->never())->method('_stop'); + + $this->Task->main(); + $this->assertFileExists($this->path . DS . 'default.pot'); + $this->assertFileNotExists($this->path . DS . 'cake.pot'); + $this->assertFileNotExists($this->path . DS . 'domain.pot'); + } + /** * test exclusions *