mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-12-17 14:13:58 +01:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
|
@ -4,24 +4,24 @@
|
|||
*
|
||||
* Test Case for Shell
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc.
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc.
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP Project
|
||||
* @package Cake.Test.Case.Console.Command
|
||||
* @since CakePHP v 1.2.0.7726
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('ShellDispatcher', 'Console');
|
||||
App::uses('Shell', 'Console');
|
||||
App::uses('Folder', 'Utility');
|
||||
App::uses("ProgressHelper", "Console/Helper");
|
||||
|
||||
/**
|
||||
* ShellTestShell class
|
||||
|
|
@ -40,7 +40,7 @@ class ShellTestShell extends Shell {
|
|||
/**
|
||||
* stopped property
|
||||
*
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
public $stopped;
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ class ShellTestShell extends Shell {
|
|||
/**
|
||||
* stop method
|
||||
*
|
||||
* @param integer $status
|
||||
* @param int $status
|
||||
* @return void
|
||||
*/
|
||||
protected function _stop($status = 0) {
|
||||
|
|
@ -194,6 +194,7 @@ class ShellTest extends CakeTestCase {
|
|||
), App::RESET);
|
||||
|
||||
CakePlugin::load('TestPlugin');
|
||||
$this->Shell->tasks = array('DbConfig' => array('one', 'two'));
|
||||
$this->Shell->uses = array('TestPlugin.TestPluginPost');
|
||||
$this->Shell->initialize();
|
||||
|
||||
|
|
@ -207,6 +208,33 @@ class ShellTest extends CakeTestCase {
|
|||
$this->assertTrue(isset($this->Shell->Comment));
|
||||
$this->assertInstanceOf('Comment', $this->Shell->Comment);
|
||||
$this->assertEquals('Comment', $this->Shell->modelClass);
|
||||
$this->assertInstanceOf('DbConfigTask', $this->Shell->DbConfig);
|
||||
|
||||
App::build();
|
||||
}
|
||||
|
||||
/**
|
||||
* testLoadModel method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testLoadModel() {
|
||||
App::build(array(
|
||||
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS),
|
||||
'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS)
|
||||
), App::RESET);
|
||||
|
||||
$Shell = new TestMergeShell();
|
||||
$this->assertEquals('Comment', $Shell->Comment->alias);
|
||||
$this->assertInstanceOf('Comment', $Shell->Comment);
|
||||
$this->assertEquals('Comment', $Shell->modelClass);
|
||||
|
||||
CakePlugin::load('TestPlugin');
|
||||
$this->Shell->loadModel('TestPlugin.TestPluginPost');
|
||||
$this->assertTrue(isset($this->Shell->TestPluginPost));
|
||||
$this->assertInstanceOf('TestPluginPost', $this->Shell->TestPluginPost);
|
||||
$this->assertEquals('TestPluginPost', $this->Shell->modelClass);
|
||||
CakePlugin::unload('TestPlugin');
|
||||
|
||||
App::build();
|
||||
}
|
||||
|
|
@ -341,6 +369,36 @@ class ShellTest extends CakeTestCase {
|
|||
$this->Shell->out('Quiet', 1, Shell::QUIET);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test overwriting.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testOverwrite() {
|
||||
$number = strlen('Some text I want to overwrite');
|
||||
|
||||
$this->Shell->stdout->expects($this->at(0))
|
||||
->method('write')
|
||||
->with('Some <info>text</info> I want to overwrite', 0)
|
||||
->will($this->returnValue($number));
|
||||
|
||||
$this->Shell->stdout->expects($this->at(1))
|
||||
->method('write')
|
||||
->with(str_repeat("\x08", $number), 0);
|
||||
|
||||
$this->Shell->stdout->expects($this->at(2))
|
||||
->method('write')
|
||||
->with('Less text', 0)
|
||||
->will($this->returnValue(9));
|
||||
|
||||
$this->Shell->stdout->expects($this->at(3))
|
||||
->method('write')
|
||||
->with(str_repeat(' ', $number - 9), 0);
|
||||
|
||||
$this->Shell->out('Some <info>text</info> I want to overwrite', 0);
|
||||
$this->Shell->overwrite('Less text');
|
||||
}
|
||||
|
||||
/**
|
||||
* testErr method
|
||||
*
|
||||
|
|
@ -545,7 +603,7 @@ class ShellTest extends CakeTestCase {
|
|||
$path = TMP . 'shell_test';
|
||||
$file = $path . DS . 'file1.php';
|
||||
|
||||
$Folder = new Folder($path, true);
|
||||
new Folder($path, true);
|
||||
|
||||
$this->Shell->interactive = false;
|
||||
|
||||
|
|
@ -572,7 +630,7 @@ class ShellTest extends CakeTestCase {
|
|||
|
||||
$path = TMP . 'shell_test';
|
||||
$file = $path . DS . 'file1.php';
|
||||
$Folder = new Folder($path, true);
|
||||
new Folder($path, true);
|
||||
|
||||
$this->Shell->interactive = true;
|
||||
|
||||
|
|
@ -611,7 +669,7 @@ class ShellTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testCreateFileNoPermissions() {
|
||||
$this->skipIf(DIRECTORY_SEPARATOR === '\\', 'Cant perform operations using permissions on windows.');
|
||||
$this->skipIf(DIRECTORY_SEPARATOR === '\\', 'Cant perform operations using permissions on Windows.');
|
||||
|
||||
$path = TMP . 'shell_test';
|
||||
$file = $path . DS . 'no_perms';
|
||||
|
|
@ -663,7 +721,6 @@ class ShellTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testRunCommandMain() {
|
||||
$methods = get_class_methods('Shell');
|
||||
$Mock = $this->getMock('Shell', array('main', 'startup'), array(), '', false);
|
||||
|
||||
$Mock->expects($this->once())->method('main')->will($this->returnValue(true));
|
||||
|
|
@ -677,7 +734,6 @@ class ShellTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testRunCommandWithMethod() {
|
||||
$methods = get_class_methods('Shell');
|
||||
$Mock = $this->getMock('Shell', array('hit_me', 'startup'), array(), '', false);
|
||||
|
||||
$Mock->expects($this->once())->method('hit_me')->will($this->returnValue(true));
|
||||
|
|
@ -700,7 +756,7 @@ class ShellTest extends CakeTestCase {
|
|||
$Mock->expects($this->never())->method('hr');
|
||||
$Mock->expects($this->once())->method('out');
|
||||
|
||||
$result = $Mock->runCommand('hr', array());
|
||||
$Mock->runCommand('hr', array());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -709,7 +765,6 @@ class ShellTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testRunCommandMissingMethod() {
|
||||
$methods = get_class_methods('Shell');
|
||||
$Mock = $this->getMock('Shell', array('startup', 'getOptionParser', 'out'), array(), '', false);
|
||||
$Parser = $this->getMock('ConsoleOptionParser', array(), array(), '', false);
|
||||
|
||||
|
|
@ -762,7 +817,7 @@ class ShellTest extends CakeTestCase {
|
|||
|
||||
$Shell->RunCommand = $task;
|
||||
|
||||
$result = $Shell->runCommand('run_command', array('run_command', 'one', 'value'));
|
||||
$Shell->runCommand('run_command', array('run_command', 'one', 'value'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -801,6 +856,51 @@ TEXT;
|
|||
$this->assertEquals($expected, $this->Shell->TestApple->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test reading params
|
||||
*
|
||||
* @dataProvider paramReadingDataProvider
|
||||
*/
|
||||
public function testParamReading($toRead, $expected) {
|
||||
$this->Shell->params = array(
|
||||
'key' => 'value',
|
||||
'help' => false,
|
||||
'emptykey' => '',
|
||||
'truthy' => true
|
||||
);
|
||||
$this->assertSame($expected, $this->Shell->param($toRead));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testing reading values with Shell::param()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function paramReadingDataProvider() {
|
||||
return array(
|
||||
array(
|
||||
'key',
|
||||
'value',
|
||||
),
|
||||
array(
|
||||
'help',
|
||||
false,
|
||||
),
|
||||
array(
|
||||
'emptykey',
|
||||
'',
|
||||
),
|
||||
array(
|
||||
'truthy',
|
||||
true,
|
||||
),
|
||||
array(
|
||||
'does_not_exist',
|
||||
null,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that option parsers are created with the correct name/command.
|
||||
*
|
||||
|
|
@ -816,8 +916,12 @@ TEXT;
|
|||
|
||||
/**
|
||||
* Test file and console and logging
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFileAndConsoleLogging() {
|
||||
CakeLog::disable('stdout');
|
||||
CakeLog::disable('stderr');
|
||||
// file logging
|
||||
$this->Shell->log_something();
|
||||
$this->assertTrue(file_exists(LOGS . 'error.log'));
|
||||
|
|
@ -831,7 +935,7 @@ TEXT;
|
|||
array('types' => 'error'),
|
||||
));
|
||||
TestCakeLog::config('console', array(
|
||||
'engine' => 'ConsoleLog',
|
||||
'engine' => 'Console',
|
||||
'stream' => 'php://stderr',
|
||||
));
|
||||
TestCakeLog::replace('console', $mock);
|
||||
|
|
@ -842,13 +946,16 @@ TEXT;
|
|||
$this->assertTrue(file_exists(LOGS . 'error.log'));
|
||||
$contents = file_get_contents(LOGS . 'error.log');
|
||||
$this->assertContains($this->Shell->testMessage, $contents);
|
||||
|
||||
CakeLog::enable('stdout');
|
||||
CakeLog::enable('stderr');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that _useLogger works properly
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
*/
|
||||
public function testProtectedUseLogger() {
|
||||
CakeLog::drop('stdout');
|
||||
CakeLog::drop('stderr');
|
||||
|
|
@ -862,6 +969,8 @@ TEXT;
|
|||
|
||||
/**
|
||||
* Test file and console and logging quiet output
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testQuietLog() {
|
||||
$output = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
|
|
@ -872,4 +981,53 @@ TEXT;
|
|||
$this->Shell->runCommand('foo', array('--quiet'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getting an instance of a helper
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGetInstanceOfHelper() {
|
||||
$actual = $this->Shell->helper("progress");
|
||||
$this->assertInstanceOf("ProgressShellHelper", $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getting an invalid helper
|
||||
*
|
||||
* @expectedException RunTimeException
|
||||
* @return void
|
||||
*/
|
||||
public function testGetInvalidHelper() {
|
||||
$this->Shell->helper("tomato");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that shell loggers do not get overridden in constructor if already configured
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testShellLoggersDoNotGetOverridden() {
|
||||
$shell = $this->getMock(
|
||||
"Shell", array(
|
||||
"_loggerIsConfigured",
|
||||
"configureStdOutLogger",
|
||||
"configureStdErrLogger",
|
||||
),
|
||||
array(),
|
||||
"",
|
||||
false
|
||||
);
|
||||
|
||||
$shell->expects($this->exactly(2))
|
||||
->method("_loggerIsConfigured")
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$shell->expects($this->never())
|
||||
->method("_configureStdOutLogger");
|
||||
|
||||
$shell->expects($this->never())
|
||||
->method("_configureStdErrLogger");
|
||||
|
||||
$shell->__construct();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue