mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Moving a test case that should be implemented in controller, as that is where the code that needs to be tested is located.
This commit is contained in:
parent
45064315d4
commit
238c734f70
2 changed files with 32 additions and 48 deletions
|
@ -408,54 +408,6 @@ class ComponentTest extends CakeTestCase {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* test that components can modify values from beforeRedirect
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function testBeforeRedirectModification() {
|
|
||||||
$this->markTestIncomplete('This test needs to be implemented');
|
|
||||||
/*
|
|
||||||
*$MockController = new MockController();
|
|
||||||
$MockController->components = array('MockTest');
|
|
||||||
$MockController->Component = new Component();
|
|
||||||
$MockController->Component->init($MockController);
|
|
||||||
$MockController->MockTest->setReturnValue('beforeRedirect', 'http://book.cakephp.org');
|
|
||||||
$MockController->expectAt(0, 'header', array('HTTP/1.1 301 Moved Permanently'));
|
|
||||||
$MockController->expectAt(1, 'header', array('Location: http://book.cakephp.org'));
|
|
||||||
$MockController->expectCallCount('header', 2);
|
|
||||||
$MockController->redirect('http://cakephp.org', 301, false);
|
|
||||||
|
|
||||||
$MockController = new MockController();
|
|
||||||
$MockController->components = array('MockTest');
|
|
||||||
$MockController->Component = new Component();
|
|
||||||
$MockController->Component->init($MockController);
|
|
||||||
$MockController->MockTest->setReturnValue('beforeRedirect', false);
|
|
||||||
$MockController->expectNever('header');
|
|
||||||
$MockController->redirect('http://cakephp.org', 301, false);
|
|
||||||
|
|
||||||
$MockController = new MockController();
|
|
||||||
$MockController->components = array('MockTest', 'MockTestB');
|
|
||||||
$MockController->Component = new Component();
|
|
||||||
$MockController->Component->init($MockController);
|
|
||||||
$MockController->MockTest->setReturnValue('beforeRedirect', 'http://book.cakephp.org');
|
|
||||||
$MockController->MockTestB->setReturnValue('beforeRedirect', 'http://bakery.cakephp.org');
|
|
||||||
$MockController->expectAt(0, 'header', array('HTTP/1.1 301 Moved Permanently'));
|
|
||||||
$MockController->expectAt(1, 'header', array('Location: http://bakery.cakephp.org'));
|
|
||||||
$MockController->expectCallCount('header', 2);
|
|
||||||
$MockController->redirect('http://cakephp.org', 301, false);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test that components can pass modifying values from beforeRedirect
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function testBeforeRedirectPass() {
|
|
||||||
$this->markTestIncomplete('This test needs to be implemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that SessionComponent doesn't get added if its already in the components array.
|
* Test that SessionComponent doesn't get added if its already in the components array.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1109,6 +1109,38 @@ class ControllerTest extends CakeTestCase {
|
||||||
$Controller->redirect('http://cakephp.org', 301, false);
|
$Controller->redirect('http://cakephp.org', 301, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that beforeRedirect callback returnning null doesn't affect things.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testRedirectBeforeRedirectModifyingParamsArrayReturn() {
|
||||||
|
$Controller = $this->getMock('Controller', array('header', '_stop'));
|
||||||
|
$Controller->Components = $this->getMock('ComponentCollection');
|
||||||
|
|
||||||
|
$return = array(
|
||||||
|
array(
|
||||||
|
'url' => 'http://example.com/test/1',
|
||||||
|
'exit' => false,
|
||||||
|
'status' => 302
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'url' => 'http://example.com/test/2',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$Controller->Components->expects($this->once())->method('trigger')
|
||||||
|
->will($this->returnValue($return));
|
||||||
|
|
||||||
|
$Controller->expects($this->at(0))->method('header')
|
||||||
|
->with('HTTP/1.1 302 Found');
|
||||||
|
|
||||||
|
$Controller->expects($this->at(1))->method('header')
|
||||||
|
->with('Location: http://example.com/test/2');
|
||||||
|
|
||||||
|
$Controller->expects($this->never())->method('_stop');
|
||||||
|
$Controller->redirect('http://cakephp.org', 301);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testMergeVars method
|
* testMergeVars method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue