cakephp - CakePHP2.0中如何用testAction传递参数

标签 cakephp testing parameters phpunit cakephp-2.0

我想用这个头文件测试一个函数:

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/

相关文章:

node.js - Nodejs调试-自动生成错误信息

rest - 在端到端测试中处理第三方 API 请求

javascript - 将对象作为参数传递到 Angular ui-router

command-line - luigi:命令行参数没有成为任务签名的一部分?

php - 在 CAKEPHP 中,我们可以动态更改链接到特定模型的表吗?

ruby-on-rails - 如何使用 rspec 在 Controller 中测试自定义路由

php - 显示 jquery ajax 执行状态

Java Netbeans 直观的参数名称

php - CakePHP : Validation message not displaying

cakephp - 如何使用cakephp和mysql使用LIKE OR运算符