Skip to content

Commit

Permalink
Merge remote-tracking branch 'cakephp/2.2' into 3.0-namespace
Browse files Browse the repository at this point in the history
Conflicts:
	lib/Cake/Console/Shell.php
	lib/Cake/Test/TestCase/BasicsTest.php
	lib/Cake/Test/TestCase/Console/Command/AclShellTest.php
	lib/Cake/Test/TestCase/Console/Command/ApiShellTest.php
	lib/Cake/Test/TestCase/Console/Command/BakeShellTest.php
	lib/Cake/Test/TestCase/Console/Command/Task/ControllerTaskTest.php
	lib/Cake/Test/TestCase/Console/Command/Task/ExtractTaskTest.php
  • Loading branch information
jrbasso committed May 26, 2012
2 parents 2f598d4 + 907b322 commit 3fbf077
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 9 deletions.
9 changes: 9 additions & 0 deletions lib/Cake/Console/Command/Task/ExtractTask.php
Expand Up @@ -307,6 +307,11 @@ public function getOptionParser() {
->addOption('exclude', array(
'help' => __d('cake_console', 'Comma separated list of directories to exclude.' .
' Any path containing a path segment with the provided values will be skipped. E.g. test,vendors')
))
->addOption('overwrite', array(
'boolean' => true,
'default' => false,
'help' => __d('cake_console', 'Always overwrite existing .pot files.')
));
}

Expand Down Expand Up @@ -540,6 +545,10 @@ protected function _store($domain, $header, $sentence) {
*/
protected function _writeFiles() {
$overwriteAll = false;
if (!empty($this->params['overwrite'])) {
$overwriteAll = true;
}

foreach ($this->_storage as $domain => $sentences) {
$output = $this->_writeHeader();
foreach ($sentences as $sentence => $header) {
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Console/Command/Task/TestTask.php
Expand Up @@ -392,6 +392,7 @@ protected function _processController($subject) {
$models = $subject->uses;
}
foreach ($models as $model) {
list($plugin, $model) = pluginSplit($model);
$this->_processModel($subject->{$model});
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/Cake/Console/ConsoleOutput.php
Expand Up @@ -130,9 +130,13 @@ class ConsoleOutput {
* @var array
*/
protected static $_styles = array(
'emergency' => array('text' => 'red', 'underline' => true),
'alert' => array('text' => 'red', 'underline' => true),
'critical' => array('text' => 'red', 'underline' => true),
'error' => array('text' => 'red', 'underline' => true),
'warning' => array('text' => 'yellow'),
'info' => array('text' => 'cyan'),
'debug' => array('text' => 'yellow'),
'success' => array('text' => 'green'),
'comment' => array('text' => 'blue'),
'question' => array('text' => "magenta"),
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Shell.php
Expand Up @@ -180,7 +180,7 @@ public function __construct($stdout = null, $stderr = null, $stdin = null) {
}
Log::config('stderr', array(
'engine' => 'Cake\Log\Engine\ConsoleLog',
'types' => array('error', 'warning'),
'types' => array('emergency', 'alert', 'critical', 'error', 'warning', 'debug'),
'stream' => $this->stderr,
));
if ($this->stdin == null) {
Expand Down
8 changes: 6 additions & 2 deletions lib/Cake/Test/TestCase/BasicsTest.php
Expand Up @@ -602,12 +602,16 @@ public function testLogError() {
@unlink(LOGS . 'error.log');

// disable stderr output for this test
Log::disable('stderr');
if (Log::stream('stderr')) {
Log::disable('stderr');
}

LogError('Testing LogError() basic function');
LogError("Testing with\nmulti-line\nstring");

Log::enable('stderr');
if (Log::stream('stderr')) {
Log::enable('stderr');
}

$result = file_get_contents(LOGS . 'error.log');
$this->assertRegExp('/Error: Testing LogError\(\) basic function/', $result);
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Test/TestCase/Console/Command/ApiShellTest.php
Expand Up @@ -16,6 +16,7 @@
* @since CakePHP v 1.2.0.7726
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

namespace Cake\Test\TestCase\Console\Command;
use Cake\TestSuite\TestCase,
Cake\Console\Command\ApiShellShell;
Expand Down
6 changes: 0 additions & 6 deletions lib/Cake/Test/TestCase/Console/Command/BakeShellTest.php
Expand Up @@ -23,12 +23,6 @@
Cake\Controller\Controller,
Cake\Core\App;

class UsersController extends Controller {

public $name = 'Users';

}

class BakeShellTest extends TestCase {

/**
Expand Down
23 changes: 23 additions & 0 deletions lib/Cake/Test/TestCase/Console/Command/Task/ExtractTaskTest.php
Expand Up @@ -18,6 +18,7 @@
* @since CakePHP v 1.2.0.7726
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

namespace Cake\Test\TestCase\Console\Command\Task;
use Cake\TestSuite\TestCase,
Cake\Console\Command\Task\ExtractTask,
Expand Down Expand Up @@ -400,4 +401,26 @@ public function testExtractModelValidationInPlugin() {
$pattern = '#Plugin/TestPlugin/Model/TestPluginPost.php:validation for field title#';
$this->assertNotRegExp($pattern, $result);
}


/**
* Test that the extract shell overwrites existing files with the overwrite parameter
*
* @return void
*/
public function testExtractOverwrite() {
$this->Task->interactive = false;

$this->Task->params['paths'] = CAKE . 'Test' . DS . 'TestApp' . DS;
$this->Task->params['output'] = $this->path . DS;
$this->Task->params['overwrite'] = true;

file_put_contents($this->path . DS . 'default.pot', 'will be overwritten');
$this->assertTrue(file_exists($this->path . DS . 'default.pot'));
$original = file_get_contents($this->path . DS . 'default.pot');

$this->Task->execute();
$result = file_get_contents($this->path . DS . 'default.pot');
$this->assertNotEquals($original, $result);
}
}

0 comments on commit 3fbf077

Please sign in to comment.