Skip to content

Commit

Permalink
Moving a test case that should be implemented in controller, as that …
Browse files Browse the repository at this point in the history
…is where the code that needs to be tested is located.
  • Loading branch information
markstory committed Aug 12, 2010
1 parent 4506431 commit 238c734
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 48 deletions.
48 changes: 0 additions & 48 deletions cake/tests/cases/libs/controller/component.test.php
Expand Up @@ -408,54 +408,6 @@ function testSomethingReferencingEmailComponent() {
));
}

/**
* 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.
*
Expand Down
32 changes: 32 additions & 0 deletions cake/tests/cases/libs/controller/controller.test.php
Expand Up @@ -1109,6 +1109,38 @@ function testRedirectBeforeRedirectModifyingParams() {
$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
*
Expand Down

0 comments on commit 238c734

Please sign in to comment.