Sunday, May 30, 2010

Testing controllers - no param is set

Hey,

i try testing controllers as described by mark story (http://mark-
story.com/posts/view/testing-cakephp-controllers-the-hard-way)..

The Problem - i call the method with one param but the view mehtod
recognize it, even it is in $this->params...

In the Test:

$this->Users->params = Router::parse('/admin/users/delete_member/
14');
$this->Users->beforeFilter();
$this->Users->Component->startup($this->Users);
$this->Users->admin_delete_member();

In the Method
function admin_delete_member($id = null) {
pr($id);
pr($this->params);
die();
}

Result:

Array
(
[controller] => users
[action] => delete_member
[named] => Array
(
)

[pass] => Array
(
[0] => 14
)

[prefix] => admin
[admin] => 1
[plugin] =>
[isAjax] =>
)


If I call the method in the application (not via testsuite), it works
and show me the correct param

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: