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,20 +2,20 @@
/**
* ScaffoldTest file
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* 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. (http://cakefoundation.org)
* @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.Controller
* @since CakePHP(tm) v 1.2.0.5436
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
App::uses('Router', 'Routing');
App::uses('Controller', 'Controller');
App::uses('Scaffold', 'Controller');
@ -31,13 +31,6 @@ require_once dirname(dirname(__FILE__)) . DS . 'Model' . DS . 'models.php';
*/
class ScaffoldMockController extends Controller {
/**
* name property
*
* @var string 'ScaffoldMock'
*/
public $name = 'ScaffoldMock';
/**
* scaffold property
*
@ -56,7 +49,7 @@ class ScaffoldMockControllerWithFields extends Controller {
/**
* name property
*
* @var string 'ScaffoldMock'
* @var string
*/
public $name = 'ScaffoldMock';
@ -70,7 +63,8 @@ class ScaffoldMockControllerWithFields extends Controller {
/**
* function beforeScaffold
*
* @param string method
* @param string $method Method name.
* @return bool true
*/
public function beforeScaffold($method) {
$this->set('scaffoldFields', array('title'));
@ -79,6 +73,39 @@ class ScaffoldMockControllerWithFields extends Controller {
}
/**
* ScaffoldMockControllerWithError class
*
* @package Cake.Test.Case.Controller
*/
class ScaffoldMockControllerWithError extends Controller {
/**
* name property
*
* @var string
*/
public $name = 'ScaffoldMock';
/**
* scaffold property
*
* @var mixed
*/
public $scaffold;
/**
* function beforeScaffold
*
* @param string $method Method name.
* @return bool false
*/
public function beforeScaffold($method) {
return false;
}
}
/**
* TestScaffoldMock class
*
@ -89,7 +116,8 @@ class TestScaffoldMock extends Scaffold {
/**
* Overload _scaffold
*
* @param unknown_type $params
* @param CakeRequest $request Request object for scaffolding
* @return void
*/
protected function _scaffold(CakeRequest $request) {
$this->_params = $request;
@ -134,6 +162,7 @@ class ScaffoldTest extends CakeTestCase {
*/
public function setUp() {
parent::setUp();
Configure::write('Config.language', 'eng');
$request = new CakeRequest(null, false);
$this->Controller = new ScaffoldMockController($request);
$this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
@ -230,7 +259,7 @@ class ScaffoldTest extends CakeTestCase {
$this->Controller->theme = 'TestTheme';
$this->Controller->viewClass = 'Theme';
$this->Controller->constructClasses();
$Scaffold = new TestScaffoldMock($this->Controller, $this->Controller->request);
new TestScaffoldMock($this->Controller, $this->Controller->request);
$this->assertEquals('Scaffold', $this->Controller->viewClass);
}
@ -348,4 +377,40 @@ class ScaffoldTest extends CakeTestCase {
$this->assertNotRegExp('/textarea name="data\[ScaffoldMock\]\[body\]" cols="30" rows="6" id="ScaffoldMockBody"/', $result);
}
/**
* test in case of scaffold error
*
* @return void
*/
public function testScaffoldError() {
$request = new CakeRequest(null, false);
$this->Controller = new ScaffoldMockControllerWithError($request);
$this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
$params = array(
'plugin' => null,
'pass' => array(1),
'form' => array(),
'named' => array(),
'url' => array('url' => 'scaffold_mock/edit'),
'controller' => 'scaffold_mock',
'action' => 'edit',
);
$this->Controller->request->base = '';
$this->Controller->request->webroot = '/';
$this->Controller->request->here = '/scaffold_mock/edit';
$this->Controller->request->addParams($params);
//set router.
Router::reload();
Router::setRequestInfo($this->Controller->request);
$this->Controller->constructClasses();
ob_start();
new Scaffold($this->Controller, $this->Controller->request);
$this->Controller->response->send();
$result = ob_get_clean();
$this->assertRegExp('/Scaffold Error/', $result);
}
}