Skip to content
Permalink
Browse files

Remove un-necessary calls to constructClasses().

Now that Controller::__constuct() calls constructClasses() it doesn't
need to be called all over the place.
  • Loading branch information...
markstory committed Sep 14, 2014
1 parent 4c52ded commit a42d56a55a75a246d9e78fecce4c9f80426bdc2b
@@ -303,7 +303,7 @@ public function components() {
* This method will also set the component to a property.
* For example:
*
* `$this->addComponent('DebugKit.Toolbar');`
* `$this->addComponent('Acl.Acl');`
*
* Will result in a `Toolbar` property being set.
*
@@ -31,7 +31,6 @@ class ErrorController extends Controller {
*/
public function __construct($request = null, $response = null) {
parent::__construct($request, $response);
$this->constructClasses();
if (count(Router::extensions()) &&
!isset($this->RequestHandler)
) {
@@ -363,7 +363,6 @@ protected function _processModel($subject) {
* @return void
*/
protected function _processController($subject) {
$subject->constructClasses();
$models = [$subject->modelClass];
foreach ($models as $model) {
list(, $model) = pluginSplit($model);
@@ -41,8 +41,7 @@ public function setUp() {
array('redirect'),
array(new Request(), new Response())
);
$controller->components = array('Cookie');
$controller->constructClasses();
$controller->addComponent('Cookie');
$this->Controller = $controller;
$this->Cookie = $controller->Cookie;
$this->request = $controller->request;
@@ -68,7 +68,6 @@ protected function _init() {
$request = new Request('controller_posts/index');
$response = $this->getMock('Cake\Network\Response', array('_sendHeader', 'stop'));
$this->Controller = new RequestHandlerTestController($request, $response);
$this->Controller->constructClasses();
$this->RequestHandler = new RequestHandlerComponent($this->Controller->components());
Router::scope('/', function($routes) {
@@ -141,7 +141,6 @@ public function setUp() {
->will($this->returnValue('/articles/index'));
$this->Controller = new SecurityTestController($request);
$this->Controller->constructClasses();
$this->Controller->Security = $this->Controller->TestSecurity;
$this->Controller->Security->config('blackHoleCallback', 'fail');
$this->Security = $this->Controller->Security;
@@ -112,9 +112,7 @@ public function testMultipleComponentInitialize() {
*/
public function testSomethingReferencingCookieComponent() {
$Controller = new ComponentTestController();
$Controller->components = array('SomethingWithCookie');
$Controller->uses = false;
$Controller->constructClasses();
$Controller->addComponent('SomethingWithCookie');
$Controller->startupProcess();
$this->assertInstanceOf('TestApp\Controller\Component\SomethingWithCookieComponent', $Controller->SomethingWithCookie);
@@ -333,9 +333,8 @@ public function testConstructClassesWithComponents() {
Plugin::load('TestPlugin');
$Controller = new TestPluginController(new Request(), new Response());
$Controller->components[] = 'TestPlugin.Other';
$Controller->addComponent('TestPlugin.Other');
$Controller->constructClasses();
$this->assertInstanceOf('TestPlugin\Controller\Component\OtherComponent', $Controller->Other);
}
@@ -507,9 +506,7 @@ public function testRedirectBeforeRedirectListenerReturnFalse() {
*/
public function testMergeVars() {
$request = new Request();
$TestController = new TestController($request);
$TestController->constructClasses();
$expected = [
'Html' => null,
@@ -524,31 +521,13 @@ public function testMergeVars() {
$this->assertEquals($expected, $TestController->components);
$TestController = new AnotherTestController($request);
$TestController->constructClasses();
$this->assertEquals(
'Posts',
$TestController->modelClass,
'modelClass should not be overwritten when defined.'
);
}
/**
* test that options from child classes replace those in the parent classes.
*
* @return void
*/
public function testChildComponentOptionsSupercedeParents() {
$request = new Request('controller_posts/index');
$TestController = new TestController($request);
$expected = array('foo');
$TestController->components = array('Cookie' => $expected);
$TestController->constructClasses();
$this->assertEquals($expected, $TestController->components['Cookie']);
}
/**
* Ensure that _mergeControllerVars is not being greedy and merging with
* ControllerTestAppController when you make an instance of Controller
@@ -685,7 +664,6 @@ public function testPaginate() {
$Controller = new Controller($request, $response);
$Controller->request->query['url'] = [];
$Controller->constructClasses();
$this->assertEquals([], $Controller->paginate);
$this->assertNotContains('Paginator', $Controller->helpers);
@@ -716,7 +694,6 @@ public function testPaginateUsesModelClass() {
$Controller = new Controller($request, $response);
$Controller->request->query['url'] = [];
$Controller->constructClasses();
$Controller->modelClass = 'Posts';
$results = $Controller->paginate();
@@ -389,7 +389,6 @@ public function testBakeControllerTest() {
$this->assertNotContains('function setUp()', $result);
$this->assertNotContains("\$this->Posts = new PostsController()", $result);
$this->assertNotContains("\$this->Posts->constructClasses()", $result);
$this->assertNotContains('function tearDown()', $result);
$this->assertNotContains('unset($this->Posts)', $result);
@@ -417,7 +416,6 @@ public function testBakePrefixControllerTest() {
$this->assertNotContains('function setUp()', $result);
$this->assertNotContains("\$this->Posts = new PostsController()", $result);
$this->assertNotContains("\$this->Posts->constructClasses()", $result);
$this->assertNotContains('function tearDown()', $result);
$this->assertNotContains('unset($this->Posts)', $result);
@@ -1115,7 +1115,6 @@ public function testRender() {
$this->assertNull($View->render(false, 'ajax2'));
$this->PostsController->helpers = array('Session', 'Html');
$this->PostsController->constructClasses();
$this->PostsController->request->params['action'] = 'index';
Configure::write('Cache.check', true);

0 comments on commit a42d56a

Please sign in to comment.
You can’t perform that action at this time.