mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding a __set() method to make some tests pass.
Updating internal usage to not use deprecated attributes. Updating test cases to not use deprecated attributes.
This commit is contained in:
parent
84565151de
commit
a521291afd
2 changed files with 33 additions and 9 deletions
|
@ -348,6 +348,26 @@ class Controller extends Object {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides backwards compatiblity access for setting values to the request object.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __set($name, $value) {
|
||||
switch ($name) {
|
||||
case 'base':
|
||||
case 'here':
|
||||
case 'webroot':
|
||||
case 'data':
|
||||
return $this->request->{$name} = $value;
|
||||
case 'action':
|
||||
return $this->request->params['action'] = $value;
|
||||
case 'params':
|
||||
return $this->request->params = $value;
|
||||
}
|
||||
return $this->{$name} = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the request objects and configures a number of controller properties
|
||||
* based on the contents of the request.
|
||||
|
@ -716,7 +736,7 @@ class Controller extends Object {
|
|||
* @return mixed Returns the return value of the called action
|
||||
*/
|
||||
public function setAction($action) {
|
||||
$this->action = $action;
|
||||
$this->request->action = $action;
|
||||
$args = func_get_args();
|
||||
unset($args[0]);
|
||||
return call_user_func_array(array(&$this, $action), $args);
|
||||
|
@ -798,7 +818,7 @@ class Controller extends Object {
|
|||
App::import('View', $this->view);
|
||||
}
|
||||
|
||||
$this->params['models'] = $this->modelNames;
|
||||
$this->request->params['models'] = $this->modelNames;
|
||||
|
||||
$View = new $viewClass($this);
|
||||
|
||||
|
@ -899,8 +919,8 @@ class Controller extends Object {
|
|||
*/
|
||||
public function postConditions($data = array(), $op = null, $bool = 'AND', $exclusive = false) {
|
||||
if (!is_array($data) || empty($data)) {
|
||||
if (!empty($this->data)) {
|
||||
$data = $this->data;
|
||||
if (!empty($this->request->data)) {
|
||||
$data = $this->request->data;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -345,8 +345,10 @@ class TestController extends AppController {
|
|||
* @return void
|
||||
*/
|
||||
function index($testId, $test2Id) {
|
||||
$this->data['testId'] = $testId;
|
||||
$this->data['test2Id'] = $test2Id;
|
||||
$this->data = array(
|
||||
'testId' => $testId,
|
||||
'test2Id' => $test2Id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -880,8 +882,10 @@ class ControllerTest extends CakeTestCase {
|
|||
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)));
|
||||
$Controller = new Controller(null);
|
||||
App::build(array(
|
||||
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
|
||||
));
|
||||
$Controller = new Controller($request);
|
||||
$Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$Controller->flash('this should work', '/flash', 1, 'ajax2');
|
||||
$result = $Controller->response->body();
|
||||
|
@ -979,7 +983,7 @@ class ControllerTest extends CakeTestCase {
|
|||
$core[0]
|
||||
)
|
||||
), true);
|
||||
$Controller =& new Controller(null, $this->getMock('CakeResponse'));
|
||||
$Controller =& new Controller($this->getMock('CakeRequest'));
|
||||
$Controller->uses = array();
|
||||
$Controller->components = array('Test');
|
||||
$Controller->constructClasses();
|
||||
|
|
Loading…
Reference in a new issue