Upgrade CakePHP from 2.2.5 to 2.9.5

This commit is contained in:
Brm Ko 2017-02-26 15:29:44 +01:00
parent 5a580df460
commit 235a541597
793 changed files with 60746 additions and 23753 deletions

View file

@ -2,19 +2,18 @@
/**
* ShellDispatcherTest file
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* 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://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
* @package Cake.Test.Case.Console
* @since CakePHP(tm) v 1.2.0.5432
* @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');
@ -138,9 +137,8 @@ class ShellDispatcherTest extends CakeTestCase {
*
* @return void
*/
public function testParseParams() {
public function testParseParamsAppWorkingAbsolute() {
$Dispatcher = new TestShellDispatcher();
$params = array(
'/cake/1.2.x.x/cake/console/cake.php',
'bake',
@ -153,11 +151,19 @@ class ShellDispatcherTest extends CakeTestCase {
'app' => 'new',
'webroot' => 'webroot',
'working' => str_replace('/', DS, '/var/www/htdocs/new'),
'root' => str_replace('/', DS,'/var/www/htdocs')
'root' => str_replace('/', DS, '/var/www/htdocs')
);
$Dispatcher->parseParams($params);
$this->assertEquals($expected, $Dispatcher->params);
}
/**
* testParseParams method
*
* @return void
*/
public function testParseParamsNone() {
$Dispatcher = new TestShellDispatcher();
$params = array('cake.php');
$expected = array(
'app' => 'app',
@ -168,7 +174,15 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher->params = $Dispatcher->args = array();
$Dispatcher->parseParams($params);
$this->assertEquals($expected, $Dispatcher->params);
}
/**
* testParseParams method
*
* @return void
*/
public function testParseParamsApp() {
$Dispatcher = new TestShellDispatcher();
$params = array(
'cake.php',
'-app',
@ -183,7 +197,15 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher->params = $Dispatcher->args = array();
$Dispatcher->parseParams($params);
$this->assertEquals($expected, $Dispatcher->params);
}
/**
* testParseParams method
*
* @return void
*/
public function testParseParamsAppWorkingRelative() {
$Dispatcher = new TestShellDispatcher();
$params = array(
'./cake.php',
'bake',
@ -192,17 +214,24 @@ class ShellDispatcherTest extends CakeTestCase {
'-working',
'/cake/1.2.x.x/cake/console'
);
$expected = array(
'app' => 'new',
'webroot' => 'webroot',
'working' => str_replace('\\', DS, dirname(CAKE_CORE_INCLUDE_PATH) . DS . 'new'),
'root' => str_replace('\\', DS, dirname(CAKE_CORE_INCLUDE_PATH))
);
$Dispatcher->params = $Dispatcher->args = array();
$Dispatcher->parseParams($params);
$this->assertEquals($expected, $Dispatcher->params);
}
/**
* testParseParams method
*
* @return void
*/
public function testParseParams() {
$Dispatcher = new TestShellDispatcher();
$params = array(
'./console/cake.php',
@ -379,7 +408,7 @@ class ShellDispatcherTest extends CakeTestCase {
'app' => 'old',
'webroot' => 'webroot',
'working' => str_replace('/', DS, '/var/www/htdocs/old'),
'root' => str_replace('/', DS,'/var/www/htdocs')
'root' => str_replace('/', DS, '/var/www/htdocs')
);
$Dispatcher->parseParams($params);
$this->assertEquals($expected, $Dispatcher->params);
@ -428,6 +457,14 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher = new TestShellDispatcher();
$result = $Dispatcher->getShell('TestPlugin.example');
$this->assertInstanceOf('ExampleShell', $result);
$Dispatcher = new TestShellDispatcher();
$result = $Dispatcher->getShell('test_plugin');
$this->assertInstanceOf('TestPluginShell', $result);
$Dispatcher = new TestShellDispatcher();
$result = $Dispatcher->getShell('TestPlugin');
$this->assertInstanceOf('TestPluginShell', $result);
}
/**
@ -437,15 +474,14 @@ class ShellDispatcherTest extends CakeTestCase {
*/
public function testDispatchShellWithMain() {
$Dispatcher = new TestShellDispatcher();
$Mock = $this->getMock('Shell', array(), array(), 'MockWithMainShell');
$Shell = $this->getMock('Shell');
$Mock->expects($this->once())->method('initialize');
$Mock->expects($this->once())->method('loadTasks');
$Mock->expects($this->once())->method('runCommand')
$Shell->expects($this->once())->method('initialize');
$Shell->expects($this->once())->method('runCommand')
->with(null, array())
->will($this->returnValue(true));
$Dispatcher->TestShell = $Mock;
$Dispatcher->TestShell = $Shell;
$Dispatcher->args = array('mock_with_main');
$result = $Dispatcher->dispatch();
@ -460,13 +496,9 @@ class ShellDispatcherTest extends CakeTestCase {
*/
public function testDispatchShellWithoutMain() {
$Dispatcher = new TestShellDispatcher();
$Shell = $this->getMock('Shell', array(), array(), 'MockWithoutMainShell');
$Shell = new MockWithoutMainShell();
$this->mockObjects[] = $Shell;
$Shell = $this->getMock('Shell');
$Shell->expects($this->once())->method('initialize');
$Shell->expects($this->once())->method('loadTasks');
$Shell->expects($this->once())->method('runCommand')
->with('initdb', array('initdb'))
->will($this->returnValue(true));
@ -485,12 +517,11 @@ class ShellDispatcherTest extends CakeTestCase {
*/
public function testDispatchNotAShellWithMain() {
$Dispatcher = new TestShellDispatcher();
$methods = get_class_methods('Object');
$methods = get_class_methods('CakeObject');
array_push($methods, 'main', 'initdb', 'initialize', 'loadTasks', 'startup', '_secret');
$Shell = $this->getMock('Object', $methods, array(), 'MockWithMainNotAShell');
$Shell = $this->getMock('CakeObject', $methods);
$Shell->expects($this->never())->method('initialize');
$Shell->expects($this->never())->method('loadTasks');
$Shell->expects($this->once())->method('startup');
$Shell->expects($this->once())->method('main')->will($this->returnValue(true));
$Dispatcher->TestShell = $Shell;
@ -500,8 +531,7 @@ class ShellDispatcherTest extends CakeTestCase {
$this->assertTrue($result);
$this->assertEquals(array(), $Dispatcher->args);
$Shell = new MockWithMainNotAShell($Dispatcher);
$this->mockObjects[] = $Shell;
$Shell = $this->getMock('CakeObject', $methods);
$Shell->expects($this->once())->method('initdb')->will($this->returnValue(true));
$Shell->expects($this->once())->method('startup');
$Dispatcher->TestShell = $Shell;
@ -518,12 +548,11 @@ class ShellDispatcherTest extends CakeTestCase {
*/
public function testDispatchNotAShellWithoutMain() {
$Dispatcher = new TestShellDispatcher();
$methods = get_class_methods('Object');
$methods = get_class_methods('CakeObject');
array_push($methods, 'main', 'initdb', 'initialize', 'loadTasks', 'startup', '_secret');
$Shell = $this->getMock('Object', $methods, array(&$Dispatcher), 'MockWithoutMainNotAShell');
$Shell = $this->getMock('CakeObject', $methods);
$Shell->expects($this->never())->method('initialize');
$Shell->expects($this->never())->method('loadTasks');
$Shell->expects($this->once())->method('startup');
$Shell->expects($this->once())->method('main')->will($this->returnValue(true));
$Dispatcher->TestShell = $Shell;
@ -533,8 +562,7 @@ class ShellDispatcherTest extends CakeTestCase {
$this->assertTrue($result);
$this->assertEquals(array(), $Dispatcher->args);
$Shell = new MockWithoutMainNotAShell($Dispatcher);
$this->mockObjects[] = $Shell;
$Shell = $this->getMock('CakeObject', $methods);
$Shell->expects($this->once())->method('initdb')->will($this->returnValue(true));
$Shell->expects($this->once())->method('startup');
$Dispatcher->TestShell = $Shell;
@ -564,7 +592,7 @@ class ShellDispatcherTest extends CakeTestCase {
$this->assertEquals('a', $Dispatcher->shiftArgs());
$this->assertSame($Dispatcher->args, array('b' => 'c', 'd'));
$Dispatcher->args = array(0 => 'a', 2 => 'b', 30 => 'c');
$Dispatcher->args = array(0 => 'a', 2 => 'b', 30 => 'c');
$this->assertEquals('a', $Dispatcher->shiftArgs());
$this->assertSame($Dispatcher->args, array(0 => 'b', 1 => 'c'));