mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Make sure ComponentCollection has the controller dependency.
Add setter method as changing ComponentCollection's constructor now is not possible. This fixes issues where components that rely on Collection->getController() in their constructor can work properly. Fixes #3946
This commit is contained in:
parent
4c7bc11a08
commit
95b74bd9ef
2 changed files with 11 additions and 0 deletions
|
@ -54,6 +54,16 @@ class ComponentCollection extends ObjectCollection implements CakeEventListener
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the controller associated with the collection.
|
||||
*
|
||||
* @param Controller $Controller Controller to set
|
||||
* @return void
|
||||
*/
|
||||
public function setController(Controller $Controller) {
|
||||
$this->_Controller = $Controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the controller associated with the collection.
|
||||
*
|
||||
|
|
|
@ -334,6 +334,7 @@ abstract class ControllerTestCase extends CakeTestCase {
|
|||
$request = $this->getMock('CakeRequest');
|
||||
$response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$controllerObj->__construct($request, $response);
|
||||
$controllerObj->Components->setController($controllerObj);
|
||||
|
||||
$config = ClassRegistry::config('Model');
|
||||
foreach ($mocks['models'] as $model => $methods) {
|
||||
|
|
Loading…
Reference in a new issue