Browse Source

Fix failing tests.

A bunch of tests relied on old behavior, update those tests so they
continue to pass.
mark_story 12 years ago
parent
commit
a47f29136f

+ 1 - 6
src/Controller/ErrorController.php

@@ -1,9 +1,5 @@
 <?php
 /**
- * Error Handling Controller
- *
- * Controller used by ErrorHandler to render error views.
- *
  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *
@@ -24,7 +20,6 @@ use Cake\Routing\Router;
  * Error Handling Controller
  *
  * Controller used by ErrorHandler to render error views.
- *
  */
 class ErrorController extends Controller {
 
@@ -47,7 +42,7 @@ class ErrorController extends Controller {
 		if (count(Router::extensions()) &&
 			!isset($this->RequestHandler)
 		) {
-			$this->RequestHandler = $this->Components->load('RequestHandler');
+			$this->addComponent('RequestHandler');
 		}
 		$eventManager = $this->getEventManager();
 		if (isset($this->Auth)) {

+ 3 - 5
tests/TestCase/Controller/Component/AuthComponentTest.php

@@ -1,7 +1,5 @@
 <?php
 /**
- * AuthComponentTest file
- *
  * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
  * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  *
@@ -79,7 +77,7 @@ class AuthComponentTest extends TestCase {
 		$this->Controller = new AuthTestController($request, $this->getMock('Cake\Network\Response'));
 		$this->Controller->constructClasses();
 
-		$this->Auth = new TestAuthComponent($this->Controller->Components);
+		$this->Auth = new TestAuthComponent($this->Controller->components());
 		$this->Auth->request = $request;
 		$this->Auth->response = $this->getMock('Cake\Network\Response');
 		AuthComponent::$sessionKey = 'Auth.User';
@@ -752,7 +750,7 @@ class AuthComponentTest extends TestCase {
 		$this->Auth->Session = $this->getMock(
 			'Cake\Controller\Component\SessionComponent',
 			array('setFlash'),
-			array($Controller->Components)
+			array($Controller->components())
 		);
 
 		$Controller->expects($this->once())
@@ -790,7 +788,7 @@ class AuthComponentTest extends TestCase {
 		$this->Auth->Session = $this->getMock(
 			'Cake\Controller\Component\SessionComponent',
 			array('setFlash'),
-			array($Controller->Components)
+			array($Controller->components())
 		);
 
 		$Controller->expects($this->once())

+ 25 - 9
tests/TestCase/Controller/Component/RequestHandlerComponentTest.php

@@ -68,7 +68,7 @@ class RequestHandlerComponentTest extends TestCase {
 		$response = new Response();
 		$this->Controller = new RequestHandlerTestController($request, $response);
 		$this->Controller->constructClasses();
-		$this->RequestHandler = new RequestHandlerComponent($this->Controller->Components);
+		$this->RequestHandler = new RequestHandlerComponent($this->Controller->components());
 		$this->_extensions = Router::extensions();
 	}
 
@@ -499,7 +499,7 @@ class RequestHandlerComponentTest extends TestCase {
 		$this->RequestHandler = $this->getMock(
 			'Cake\Controller\Component\RequestHandlerComponent',
 			array('_header'),
-			array(&$this->Controller->Components)
+			array($this->Controller->components())
 		);
 		$this->RequestHandler->response = $this->getMock('Cake\Network\Response', array('type', 'download'));
 		$this->RequestHandler->request = $this->getMock('Cake\Network\Request', ['parseAccept']);
@@ -699,7 +699,7 @@ class RequestHandlerComponentTest extends TestCase {
 		$this->Controller->RequestHandler = $this->getMock(
 			'Cake\Controller\Component\RequestHandlerComponent',
 			array('_stop'),
-			array(&$this->Controller->Components)
+			array($this->Controller->components())
 		);
 		$this->Controller->request = $this->getMock('Cake\Network\Request', ['is']);
 		$this->Controller->response = $this->getMock('Cake\Network\Response', array('_sendHeader'));
@@ -732,7 +732,7 @@ class RequestHandlerComponentTest extends TestCase {
 		$this->Controller->RequestHandler = $this->getMock(
 			'Cake\Controller\Component\RequestHandlerComponent',
 			array('_stop'),
-			array(&$this->Controller->Components)
+			array($this->Controller->components())
 		);
 		$this->Controller->request = $this->getMock('Cake\Network\Request', ['is']);
 		$this->Controller->response = $this->getMock('Cake\Network\Response', array('_sendHeader'));
@@ -774,7 +774,7 @@ class RequestHandlerComponentTest extends TestCase {
 		$RequestHandler = $this->getMock(
 			'Cake\Controller\Component\RequestHandlerComponent',
 			array('_stop'),
-			array(&$this->Controller->Components)
+			array($this->Controller->components())
 		);
 		$RequestHandler->response = $this->getMock('Cake\Network\Response', array('_sendHeader'));
 		$RequestHandler->request = new Request('posts/index');
@@ -806,7 +806,11 @@ class RequestHandlerComponentTest extends TestCase {
 	public function testCheckNotModifiedByEtagStar() {
 		$_SERVER['HTTP_IF_NONE_MATCH'] = '*';
 		$event = new Event('Controller.beforeRender', $this->Controller);
-		$RequestHandler = $this->getMock('Cake\Controller\Component\RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
+		$RequestHandler = $this->getMock(
+			'Cake\Controller\Component\RequestHandlerComponent',
+			array('_stop'),
+			array($this->Controller->components())
+		);
 		$RequestHandler->response = $this->getMock('Cake\Network\Response', array('notModified'));
 		$RequestHandler->response->etag('something');
 		$RequestHandler->response->expects($this->once())->method('notModified');
@@ -821,7 +825,11 @@ class RequestHandlerComponentTest extends TestCase {
 	public function testCheckNotModifiedByEtagExact() {
 		$_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"';
 		$event = new Event('Controller.beforeRender');
-		$RequestHandler = $this->getMock('Cake\Controller\Component\RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
+		$RequestHandler = $this->getMock(
+			'Cake\Controller\Component\RequestHandlerComponent',
+			array('_stop'),
+			array($this->Controller->components())
+		);
 		$RequestHandler->response = $this->getMock('Cake\Network\Response', array('notModified'));
 		$RequestHandler->response->etag('something', true);
 		$RequestHandler->response->expects($this->once())->method('notModified');
@@ -837,7 +845,11 @@ class RequestHandlerComponentTest extends TestCase {
 		$_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"';
 		$_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00';
 		$event = new Event('Controller.beforeRender', $this->Controller);
-		$RequestHandler = $this->getMock('Cake\Controller\Component\RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
+		$RequestHandler = $this->getMock(
+			'Cake\Controller\Component\RequestHandlerComponent',
+			array('_stop'),
+			array($this->Controller->components())
+		);
 		$RequestHandler->response = $this->getMock('Cake\Network\Response', array('notModified'));
 		$RequestHandler->response->etag('something', true);
 		$RequestHandler->response->modified('2012-01-01 00:00:00');
@@ -852,7 +864,11 @@ class RequestHandlerComponentTest extends TestCase {
  */
 	public function testCheckNotModifiedNoInfo() {
 		$event = new Event('Controller.beforeRender', $this->Controller);
-		$RequestHandler = $this->getMock('Cake\Controller\Component\RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
+		$RequestHandler = $this->getMock(
+			'Cake\Controller\Component\RequestHandlerComponent',
+			array('_stop'),
+			array($this->Controller->components())
+		);
 		$RequestHandler->response = $this->getMock('Cake\Network\Response', array('notModified'));
 		$RequestHandler->response->expects($this->never())->method('notModified');
 		$this->assertNull($RequestHandler->beforeRender($event, '', $RequestHandler->response));

+ 2 - 2
tests/TestCase/Controller/Component/SecurityComponentTest.php

@@ -174,7 +174,7 @@ class SecurityComponentTest extends TestCase {
 		]);
 		$Controller = new \TestApp\Controller\SomePagesController($request);
 		$event = new Event('Controller.startup', $Controller, $this->Controller);
-		$Security = new SecurityComponent($Controller->Components);
+		$Security = new SecurityComponent($Controller->components());
 		$Security->blackHoleCallback = '_fail';
 		$Security->startup($event);
 		$Security->blackHole($Controller, 'csrf');
@@ -207,7 +207,7 @@ class SecurityComponentTest extends TestCase {
 			'requireSecure' => array('update_account'),
 			'validatePost' => false,
 		);
-		$Security = new SecurityComponent($this->Controller->Components, $settings);
+		$Security = new SecurityComponent($this->Controller->components(), $settings);
 		$this->assertEquals($Security->validatePost, $settings['validatePost']);
 	}
 

+ 1 - 1
tests/TestCase/Utility/DebuggerTest.php

@@ -317,7 +317,7 @@ class DebuggerTest extends TestCase {
 		$result = Debugger::exportVar($View);
 		$expected = <<<TEXT
 object(Cake\View\View) {
-	Helpers => object(Cake\View\HelperRegistry) {}
+	_helpers => object(Cake\View\HelperRegistry) {}
 	Blocks => object(Cake\View\ViewBlock) {}
 	plugin => null
 	name => ''

+ 1 - 1
tests/TestCase/View/XmlViewTest.php

@@ -190,7 +190,7 @@ class XmlViewTest extends TestCase {
 		$expected = Xml::build($expected)->asXML();
 		$this->assertSame($expected, $output);
 		$this->assertSame('application/xml', $Response->type());
-		$this->assertInstanceOf('Cake\View\HelperRegistry', $View->Helpers);
+		$this->assertInstanceOf('Cake\View\HelperRegistry', $View->helpers());
 	}
 
 }