components() публичный метод

If called with the first parameter, it will be set as the controller $this->_components property
public components ( Cake\Controller\ComponentRegistry | null $components = null ) : Cake\Controller\ComponentRegistry
$components Cake\Controller\ComponentRegistry | null Component registry.
Результат Cake\Controller\ComponentRegistry
 /**
  * Returns the test controller
  *
  * @param \Cake\Network\Request $request Request object
  * @param \Cake\Network\Response $response Response for the controller.
  * @return \Cake\Controller\Controller
  */
 protected function _getController($request, $response)
 {
     if ($this->testController === null) {
         $this->testController = parent::_getController($request, $response);
     }
     $default = array('InterceptContent' => array('className' => 'Cake\\TestSuite\\InterceptContentHelper'));
     $this->testController->helpers = array_merge($default, $this->testController->helpers);
     $this->testController->setRequest($request);
     $this->testController->response = $this->response;
     $registry = $this->testController->components();
     foreach ($registry->loaded() as $component) {
         $object = $registry->{$component};
         if (isset($object->response)) {
             $object->response = $response;
         }
         if (isset($object->request)) {
             $object->request = $request;
         }
     }
     return $this->testController;
 }
 /**
  * Convenience method for testing: Initializes the controller and the Ratings component
  *
  * @param array $params Controller params
  * @return void
  */
 protected function _initControllerAndRatings($params = [])
 {
     $_default = ['?' => [], 'pass' => []];
     $this->Controller->request->params = array_merge($_default, $params);
     if (!empty($this->Controller->request->params['?'])) {
         $this->Controller->request->query = $this->Controller->request->params['?'];
     }
     $this->Controller->components()->unload('Ratings');
     $options = isset($this->Controller->components['Ratings.Ratings']) ? $this->Controller->components['Ratings.Ratings'] : [];
     $this->Controller->loadComponent('Ratings.Ratings', $options);
     $event = new Event('beforeFilter', $this->Controller);
     $this->Controller->Ratings->beforeFilter($event);
     //$this->Controller->Components->trigger('initialize', array(&$this->Controller));
     //$this->Controller->Auth = $this->AuthComponent;
     //$this->Controller->Ratings->beforeFilter($this->Controller);
 }
 public function testManipulationHandling()
 {
     $request = new Request(['url' => 'controller_posts/index?Filter-Posts-title=foo&Filter-Posts-body=bar&Filter-Posts-author_id=invalid&Filter-Posts-multi[0]=valid1&Filter-Posts-multi[1]=invalid', 'action' => 'index', '_method' => 'POST']);
     $request->action = 'index';
     $controller = new Controller($request);
     $controller->listFilters = ['index' => ['fields' => ['Posts.title' => ['searchType' => 'wildcard'], 'Posts.author_id' => ['searchType' => 'select', 'options' => ['valid' => 'valid']], 'Posts.multi' => ['searchType' => 'multipleselect', 'options' => ['valid1' => 'valid1', 'valid2' => 'valid2']]]]];
     $controller->paginate = [];
     $ListFilter = new ListFilterComponent($controller->components(), []);
     $event = new Event('Controller.startup', $controller);
     $ListFilter->startup($event);
     // the 'body' field from the filter URL is not configured in listFilters and
     // should not be added to the paginate array
     // author_id has a value not defined in the options key of the listFilter config
     // and must be ignored
     $this->assertEquals(['conditions' => ['Posts.title LIKE' => '%foo%', 'Posts.multi IN' => ['valid1']]], $controller->paginate);
 }