Updating tests to use new Component api. There are still a pile of tests failing because of SessionComponent.

This commit is contained in:
mark_story 2010-07-04 20:31:23 -04:00
parent 0f5e881f26
commit fa8a43f038
3 changed files with 29 additions and 21 deletions

View file

@ -489,8 +489,8 @@ class AuthTest extends CakeTestCase {
Configure::write('Acl.classname', 'DbAcl'); Configure::write('Acl.classname', 'DbAcl');
$this->Controller = new AuthTestController(); $this->Controller = new AuthTestController();
$this->Controller->Component->init($this->Controller); $this->Controller->Components->init($this->Controller);
$this->Controller->Component->initialize($this->Controller); $this->Controller->Components->initialize($this->Controller);
$this->Controller->beforeFilter(); $this->Controller->beforeFilter();
ClassRegistry::addObject('view', new View($this->Controller)); ClassRegistry::addObject('view', new View($this->Controller));
@ -1551,8 +1551,8 @@ class AuthTest extends CakeTestCase {
), ),
'Session' 'Session'
); );
$this->Controller->Component->init($this->Controller); $this->Controller->Components->init($this->Controller);
$this->Controller->Component->initialize($this->Controller); $this->Controller->Components->initialize($this->Controller);
Router::reload(); Router::reload();
$this->AuthUserCustomField = new AuthUserCustomField(); $this->AuthUserCustomField = new AuthUserCustomField();

View file

@ -217,7 +217,7 @@ class EmailComponentTest extends CakeTestCase {
$this->Controller = new EmailTestController(); $this->Controller = new EmailTestController();
$this->Controller->Component->init($this->Controller); $this->Controller->Components->init($this->Controller);
$this->Controller->EmailTest->initialize($this->Controller, array()); $this->Controller->EmailTest->initialize($this->Controller, array());
ClassRegistry::addObject('view', new View($this->Controller)); ClassRegistry::addObject('view', new View($this->Controller));

View file

@ -191,6 +191,20 @@ class RequestHandlerComponentTest extends CakeTestCase {
App::build(); App::build();
} }
/**
* Test that the constructor sets the settings.
*
* @return void
*/
function testConstructorSettings() {
$settings = array(
'ajaxLayout' => 'test_ajax'
);
$Collection = new ComponentCollection();
$RequestHandler = new RequestHandlerComponent($Collection, $settings);
$this->assertEqual($RequestHandler->ajaxLayout, 'test_ajax');
}
/** /**
* testInitializeCallback method * testInitializeCallback method
* *
@ -204,12 +218,6 @@ class RequestHandlerComponentTest extends CakeTestCase {
$this->Controller->params['url']['ext'] = 'rss'; $this->Controller->params['url']['ext'] = 'rss';
$this->RequestHandler->initialize($this->Controller); $this->RequestHandler->initialize($this->Controller);
$this->assertEqual($this->RequestHandler->ext, 'rss'); $this->assertEqual($this->RequestHandler->ext, 'rss');
$settings = array(
'ajaxLayout' => 'test_ajax'
);
$this->RequestHandler->initialize($this->Controller, $settings);
$this->assertEqual($this->RequestHandler->ajaxLayout, 'test_ajax');
} }
/** /**
@ -221,16 +229,16 @@ class RequestHandlerComponentTest extends CakeTestCase {
function testDisabling() { function testDisabling() {
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
$this->_init(); $this->_init();
$this->Controller->Component->initialize($this->Controller); $this->Controller->Components->trigger('initialize', array(&$this->Controller));
$this->Controller->beforeFilter(); $this->Controller->beforeFilter();
$this->Controller->Component->startup($this->Controller); $this->Controller->Components->trigger('startup', array(&$this->Controller));
$this->assertEqual($this->Controller->params, array('isAjax' => true)); $this->assertEqual($this->Controller->params, array('isAjax' => true));
$this->Controller = new RequestHandlerTestDisabledController(array('components' => array('RequestHandler'))); $this->Controller = new RequestHandlerTestDisabledController(array('components' => array('RequestHandler')));
$this->Controller->constructClasses(); $this->Controller->constructClasses();
$this->Controller->Component->initialize($this->Controller); $this->Controller->Components->trigger('initialize', array(&$this->Controller));
$this->Controller->beforeFilter(); $this->Controller->beforeFilter();
$this->Controller->Component->startup($this->Controller); $this->Controller->Components->trigger('startup', array(&$this->Controller));
$this->assertEqual($this->Controller->params, array()); $this->assertEqual($this->Controller->params, array());
unset($_SERVER['HTTP_X_REQUESTED_WITH']); unset($_SERVER['HTTP_X_REQUESTED_WITH']);
} }
@ -313,7 +321,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
$debug = Configure::read('debug'); $debug = Configure::read('debug');
Configure::write('debug', 0); Configure::write('debug', 0);
$RequestHandler = $this->getMock('RequestHandlerComponent', array('_header')); $RequestHandler = $this->getMock('RequestHandlerComponent', array('_header'), array(&$this->Controller->Components));
$RequestHandler->expects($this->at(0))->method('_header') $RequestHandler->expects($this->at(0))->method('_header')
->with('Content-type: application/json'); ->with('Content-type: application/json');
$RequestHandler->expects($this->at(1))->method('_header') $RequestHandler->expects($this->at(1))->method('_header')
@ -337,7 +345,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
$debug = Configure::read('debug'); $debug = Configure::read('debug');
Configure::write('debug', 0); Configure::write('debug', 0);
$RequestHandler = $this->getMock('RequestHandlerComponent', array('_header')); $RequestHandler = $this->getMock('RequestHandlerComponent', array('_header'), array(&$this->Controller->Components));
$RequestHandler->expects($this->at(0))->method('_header') $RequestHandler->expects($this->at(0))->method('_header')
->with('Content-Disposition: attachment; filename="myfile.xml"'); ->with('Content-Disposition: attachment; filename="myfile.xml"');
$RequestHandler->expects($this->at(1))->method('_header') $RequestHandler->expects($this->at(1))->method('_header')
@ -632,7 +640,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
), true); ), true);
$this->Controller->RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop')); $this->Controller->RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
$this->Controller->RequestHandler->expects($this->once())->method('_stop'); $this->Controller->RequestHandler->expects($this->once())->method('_stop');
ob_start(); ob_start();
@ -659,7 +667,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
), true); ), true);
$this->Controller->RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop')); $this->Controller->RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
$this->Controller->RequestHandler->expects($this->once())->method('_stop'); $this->Controller->RequestHandler->expects($this->once())->method('_stop');
ob_start(); ob_start();
@ -690,7 +698,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
array('base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/') array('base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/')
)); ));
$RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop')); $RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
ob_start(); ob_start();
$RequestHandler->beforeRedirect( $RequestHandler->beforeRedirect(
@ -710,7 +718,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
$controller = $this->getMock('Controller', array('header')); $controller = $this->getMock('Controller', array('header'));
$RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop')); $RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
$controller->expects($this->once())->method('header')->with('HTTP/1.1 403 Forbidden'); $controller->expects($this->once())->method('header')->with('HTTP/1.1 403 Forbidden');