mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Updating tests to use new Component api. There are still a pile of tests failing because of SessionComponent.
This commit is contained in:
parent
0f5e881f26
commit
fa8a43f038
3 changed files with 29 additions and 21 deletions
|
@ -489,8 +489,8 @@ class AuthTest extends CakeTestCase {
|
|||
Configure::write('Acl.classname', 'DbAcl');
|
||||
|
||||
$this->Controller = new AuthTestController();
|
||||
$this->Controller->Component->init($this->Controller);
|
||||
$this->Controller->Component->initialize($this->Controller);
|
||||
$this->Controller->Components->init($this->Controller);
|
||||
$this->Controller->Components->initialize($this->Controller);
|
||||
$this->Controller->beforeFilter();
|
||||
|
||||
ClassRegistry::addObject('view', new View($this->Controller));
|
||||
|
@ -1551,8 +1551,8 @@ class AuthTest extends CakeTestCase {
|
|||
),
|
||||
'Session'
|
||||
);
|
||||
$this->Controller->Component->init($this->Controller);
|
||||
$this->Controller->Component->initialize($this->Controller);
|
||||
$this->Controller->Components->init($this->Controller);
|
||||
$this->Controller->Components->initialize($this->Controller);
|
||||
Router::reload();
|
||||
|
||||
$this->AuthUserCustomField = new AuthUserCustomField();
|
||||
|
|
|
@ -217,7 +217,7 @@ class EmailComponentTest extends CakeTestCase {
|
|||
|
||||
$this->Controller = new EmailTestController();
|
||||
|
||||
$this->Controller->Component->init($this->Controller);
|
||||
$this->Controller->Components->init($this->Controller);
|
||||
|
||||
$this->Controller->EmailTest->initialize($this->Controller, array());
|
||||
ClassRegistry::addObject('view', new View($this->Controller));
|
||||
|
|
|
@ -191,6 +191,20 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
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
|
||||
*
|
||||
|
@ -204,12 +218,6 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
$this->Controller->params['url']['ext'] = 'rss';
|
||||
$this->RequestHandler->initialize($this->Controller);
|
||||
$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() {
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
|
||||
$this->_init();
|
||||
$this->Controller->Component->initialize($this->Controller);
|
||||
$this->Controller->Components->trigger('initialize', array(&$this->Controller));
|
||||
$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->Controller = new RequestHandlerTestDisabledController(array('components' => array('RequestHandler')));
|
||||
$this->Controller->constructClasses();
|
||||
$this->Controller->Component->initialize($this->Controller);
|
||||
$this->Controller->Components->trigger('initialize', array(&$this->Controller));
|
||||
$this->Controller->beforeFilter();
|
||||
$this->Controller->Component->startup($this->Controller);
|
||||
$this->Controller->Components->trigger('startup', array(&$this->Controller));
|
||||
$this->assertEqual($this->Controller->params, array());
|
||||
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
|
||||
}
|
||||
|
@ -313,7 +321,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
$debug = Configure::read('debug');
|
||||
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')
|
||||
->with('Content-type: application/json');
|
||||
$RequestHandler->expects($this->at(1))->method('_header')
|
||||
|
@ -337,7 +345,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
$debug = Configure::read('debug');
|
||||
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')
|
||||
->with('Content-Disposition: attachment; filename="myfile.xml"');
|
||||
$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)
|
||||
), 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');
|
||||
|
||||
ob_start();
|
||||
|
@ -659,7 +667,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
|
||||
), 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');
|
||||
|
||||
ob_start();
|
||||
|
@ -690,7 +698,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
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();
|
||||
$RequestHandler->beforeRedirect(
|
||||
|
@ -710,7 +718,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
|
||||
|
||||
$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');
|
||||
|
||||
|
|
Loading…
Reference in a new issue