Two things:

1) I would suggest using the more fully qualified format of
testAction: testAction(array('controller'=>'galleries', 'action' =>
'show', 'xyz')); For simple requests both formats should be identical,
but the latter will be more useful when you start applying more
complex routing schemes.

2) If your controller method being tested calls Controller::redirect()
at any time, the test exit without any warning. This is because the
redirect method was refactored some time ago to call Object::_stop()
upon completion (a smart thing, IMHO), which is actually just a
wrapper for exit(). You can get around this by overriding the _stop
method in your app_controller, but only for test execution:

/**
* Override of Object::_stop.
*
* For unit testing of controllers.
*
* @param integer $status
* @return mixed Null if testing, execution of Object::_stop otherwise.
*/
function _stop($status = 0) {

  if (defined('CAKEPHP_UNIT_TEST_EXECUTION') &&
CAKEPHP_UNIT_TEST_EXECUTION == 1) {
      return;
  }
  else return parent::_stop();
}


hth.

-J.


On Oct 22, 8:11 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> today i tried to implement some testing classes in my project. But i
> can't ge t them run the right way.
>
> For example this simple test method:
> The first test calls the show action with a string that should fail
> and redirect. The second test with an integer as parameter should run
> correctly.
>
> function testShowAction() {
>         $this->testAction('/galleries/show/xyz');
>         $this->assertResponse(REDIRECT);
>         $this->testAction('/galleries/show/2');
>         $this->assertResponse(SUCCESS);
>
> }
>
> When i call this method in the "myproject/test.php" it redirects me to
> the gallery and exit the test.
> Whats the right way to test an controller action ?
>
> Best Regards
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to