Browse Source

Remove un-necessary calls to constructClasses().

Now that Controller::__constuct() calls constructClasses() it doesn't
need to be called all over the place.
mark_story 11 years ago
parent
commit
a42d56a55a

+ 1 - 1
src/Controller/Controller.php

@@ -303,7 +303,7 @@ class Controller implements EventListener {
  * 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.
  *

+ 0 - 1
src/Controller/ErrorController.php

@@ -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)
 		) {

+ 0 - 1
src/Shell/Task/TestTask.php

@@ -363,7 +363,6 @@ class TestTask extends BakeTask {
  * @return void
  */
 	protected function _processController($subject) {
-		$subject->constructClasses();
 		$models = [$subject->modelClass];
 		foreach ($models as $model) {
 			list(, $model) = pluginSplit($model);

+ 1 - 2
tests/TestCase/Controller/Component/CookieComponentTest.php

@@ -41,8 +41,7 @@ class CookieComponentTest extends TestCase {
 			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;

+ 0 - 1
tests/TestCase/Controller/Component/RequestHandlerComponentTest.php

@@ -68,7 +68,6 @@ class RequestHandlerComponentTest extends TestCase {
 		$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) {

+ 0 - 1
tests/TestCase/Controller/Component/SecurityComponentTest.php

@@ -141,7 +141,6 @@ class SecurityComponentTest extends TestCase {
 			->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;

+ 1 - 3
tests/TestCase/Controller/ComponentTest.php

@@ -112,9 +112,7 @@ class ComponentTest extends TestCase {
  */
 	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);

+ 1 - 24
tests/TestCase/Controller/ControllerTest.php

@@ -333,9 +333,8 @@ class ControllerTest extends TestCase {
 		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 @@ class ControllerTest extends TestCase {
  */
 	public function testMergeVars() {
 		$request = new Request();
-
 		$TestController = new TestController($request);
-		$TestController->constructClasses();
 
 		$expected = [
 			'Html' => null,
@@ -524,8 +521,6 @@ class ControllerTest extends TestCase {
 		$this->assertEquals($expected, $TestController->components);
 
 		$TestController = new AnotherTestController($request);
-		$TestController->constructClasses();
-
 		$this->assertEquals(
 			'Posts',
 			$TestController->modelClass,
@@ -534,22 +529,6 @@ class ControllerTest extends TestCase {
 	}
 
 /**
- * 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 @@ class ControllerTest extends TestCase {
 
 		$Controller = new Controller($request, $response);
 		$Controller->request->query['url'] = [];
-		$Controller->constructClasses();
 		$this->assertEquals([], $Controller->paginate);
 
 		$this->assertNotContains('Paginator', $Controller->helpers);
@@ -716,7 +694,6 @@ class ControllerTest extends TestCase {
 
 		$Controller = new Controller($request, $response);
 		$Controller->request->query['url'] = [];
-		$Controller->constructClasses();
 		$Controller->modelClass = 'Posts';
 		$results = $Controller->paginate();
 

+ 0 - 2
tests/TestCase/Shell/Task/TestTaskTest.php

@@ -389,7 +389,6 @@ class TestTaskTest extends TestCase {
 
 		$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 @@ class TestTaskTest extends TestCase {
 
 		$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);

+ 0 - 1
tests/TestCase/View/ViewTest.php

@@ -1115,7 +1115,6 @@ class ViewTest extends TestCase {
 		$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);