我想用这个头文件测试一个函数:
public function includeNumComments($posts){
其中 $post 是一个数据数组。
我想知道如何测试向它传递一组帖子的方法。
我试过这样的事情,但它不起作用:
$result = $this->testAction("/comments/includeNumComments/", array('data' => $posts));
$result = $this->testAction("/comments/includeNumComments/", array($posts));
谢谢
最佳答案
这是正确的案例,它对我有用。希望对您有所帮助:
public function testAddUser() {
$data = array(
'User' => array(
'id' => 12,
'username' => 'testname1',
'password' => 'Pass@123!',
'email' => 'test@example.com'
)
);
$result = $this->testAction(
'/users/add',
array('data' => $data, 'method' => 'post')
);
debug($result);
}
关于cakephp - CakePHP2.0中如何用testAction传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10127216/