Skip to content

Commit a42d56a

Browse files
committed
Remove un-necessary calls to constructClasses().
Now that Controller::__constuct() calls constructClasses() it doesn't need to be called all over the place.
1 parent 4c52ded commit a42d56a

File tree

10 files changed

+4
-37
lines changed

10 files changed

+4
-37
lines changed

src/Controller/Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public function components() {
303303
* This method will also set the component to a property.
304304
* For example:
305305
*
306-
* `$this->addComponent('DebugKit.Toolbar');`
306+
* `$this->addComponent('Acl.Acl');`
307307
*
308308
* Will result in a `Toolbar` property being set.
309309
*

src/Controller/ErrorController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class ErrorController extends Controller {
3131
*/
3232
public function __construct($request = null, $response = null) {
3333
parent::__construct($request, $response);
34-
$this->constructClasses();
3534
if (count(Router::extensions()) &&
3635
!isset($this->RequestHandler)
3736
) {

src/Shell/Task/TestTask.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ protected function _processModel($subject) {
363363
* @return void
364364
*/
365365
protected function _processController($subject) {
366-
$subject->constructClasses();
367366
$models = [$subject->modelClass];
368367
foreach ($models as $model) {
369368
list(, $model) = pluginSplit($model);

tests/TestCase/Controller/Component/CookieComponentTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ public function setUp() {
4141
array('redirect'),
4242
array(new Request(), new Response())
4343
);
44-
$controller->components = array('Cookie');
45-
$controller->constructClasses();
44+
$controller->addComponent('Cookie');
4645
$this->Controller = $controller;
4746
$this->Cookie = $controller->Cookie;
4847
$this->request = $controller->request;

tests/TestCase/Controller/Component/RequestHandlerComponentTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ protected function _init() {
6868
$request = new Request('controller_posts/index');
6969
$response = $this->getMock('Cake\Network\Response', array('_sendHeader', 'stop'));
7070
$this->Controller = new RequestHandlerTestController($request, $response);
71-
$this->Controller->constructClasses();
7271
$this->RequestHandler = new RequestHandlerComponent($this->Controller->components());
7372

7473
Router::scope('/', function($routes) {

tests/TestCase/Controller/Component/SecurityComponentTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ public function setUp() {
141141
->will($this->returnValue('/articles/index'));
142142

143143
$this->Controller = new SecurityTestController($request);
144-
$this->Controller->constructClasses();
145144
$this->Controller->Security = $this->Controller->TestSecurity;
146145
$this->Controller->Security->config('blackHoleCallback', 'fail');
147146
$this->Security = $this->Controller->Security;

tests/TestCase/Controller/ComponentTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ public function testMultipleComponentInitialize() {
112112
*/
113113
public function testSomethingReferencingCookieComponent() {
114114
$Controller = new ComponentTestController();
115-
$Controller->components = array('SomethingWithCookie');
116-
$Controller->uses = false;
117-
$Controller->constructClasses();
115+
$Controller->addComponent('SomethingWithCookie');
118116
$Controller->startupProcess();
119117

120118
$this->assertInstanceOf('TestApp\Controller\Component\SomethingWithCookieComponent', $Controller->SomethingWithCookie);

tests/TestCase/Controller/ControllerTest.php

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,8 @@ public function testConstructClassesWithComponents() {
333333
Plugin::load('TestPlugin');
334334

335335
$Controller = new TestPluginController(new Request(), new Response());
336-
$Controller->components[] = 'TestPlugin.Other';
336+
$Controller->addComponent('TestPlugin.Other');
337337

338-
$Controller->constructClasses();
339338
$this->assertInstanceOf('TestPlugin\Controller\Component\OtherComponent', $Controller->Other);
340339
}
341340

@@ -507,9 +506,7 @@ public function testRedirectBeforeRedirectListenerReturnFalse() {
507506
*/
508507
public function testMergeVars() {
509508
$request = new Request();
510-
511509
$TestController = new TestController($request);
512-
$TestController->constructClasses();
513510

514511
$expected = [
515512
'Html' => null,
@@ -524,31 +521,13 @@ public function testMergeVars() {
524521
$this->assertEquals($expected, $TestController->components);
525522

526523
$TestController = new AnotherTestController($request);
527-
$TestController->constructClasses();
528-
529524
$this->assertEquals(
530525
'Posts',
531526
$TestController->modelClass,
532527
'modelClass should not be overwritten when defined.'
533528
);
534529
}
535530

536-
/**
537-
* test that options from child classes replace those in the parent classes.
538-
*
539-
* @return void
540-
*/
541-
public function testChildComponentOptionsSupercedeParents() {
542-
$request = new Request('controller_posts/index');
543-
544-
$TestController = new TestController($request);
545-
546-
$expected = array('foo');
547-
$TestController->components = array('Cookie' => $expected);
548-
$TestController->constructClasses();
549-
$this->assertEquals($expected, $TestController->components['Cookie']);
550-
}
551-
552531
/**
553532
* Ensure that _mergeControllerVars is not being greedy and merging with
554533
* ControllerTestAppController when you make an instance of Controller
@@ -685,7 +664,6 @@ public function testPaginate() {
685664

686665
$Controller = new Controller($request, $response);
687666
$Controller->request->query['url'] = [];
688-
$Controller->constructClasses();
689667
$this->assertEquals([], $Controller->paginate);
690668

691669
$this->assertNotContains('Paginator', $Controller->helpers);
@@ -716,7 +694,6 @@ public function testPaginateUsesModelClass() {
716694

717695
$Controller = new Controller($request, $response);
718696
$Controller->request->query['url'] = [];
719-
$Controller->constructClasses();
720697
$Controller->modelClass = 'Posts';
721698
$results = $Controller->paginate();
722699

tests/TestCase/Shell/Task/TestTaskTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ public function testBakeControllerTest() {
389389

390390
$this->assertNotContains('function setUp()', $result);
391391
$this->assertNotContains("\$this->Posts = new PostsController()", $result);
392-
$this->assertNotContains("\$this->Posts->constructClasses()", $result);
393392

394393
$this->assertNotContains('function tearDown()', $result);
395394
$this->assertNotContains('unset($this->Posts)', $result);
@@ -417,7 +416,6 @@ public function testBakePrefixControllerTest() {
417416

418417
$this->assertNotContains('function setUp()', $result);
419418
$this->assertNotContains("\$this->Posts = new PostsController()", $result);
420-
$this->assertNotContains("\$this->Posts->constructClasses()", $result);
421419

422420
$this->assertNotContains('function tearDown()', $result);
423421
$this->assertNotContains('unset($this->Posts)', $result);

tests/TestCase/View/ViewTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,6 @@ public function testRender() {
11151115
$this->assertNull($View->render(false, 'ajax2'));
11161116

11171117
$this->PostsController->helpers = array('Session', 'Html');
1118-
$this->PostsController->constructClasses();
11191118
$this->PostsController->request->params['action'] = 'index';
11201119
Configure::write('Cache.check', true);
11211120

0 commit comments

Comments
 (0)