小编Joa*_*uez的帖子

testAction()函数在CakePhp测试中的debug()上返回null

我试图学习如何在CakePhp中使用单元测试,我正在尝试编写控制器测试.我读了关于testAction()和debug()的函数,但它对我不起作用,我的意思是,测试方法通过了,但是debug()返回null(因为testAction没有)

这是我的代码:

<?php
App::uses('Controller', 'Controller');
App::uses('View', 'View');
App::uses('PostsController', 'Controller');

class PostsControllerTest extends ControllerTestCase {
    public function setUp() {
       parent::setUp();
       $Controller = new Controller();
       $View = new View($Controller);
       $this->Posts = new PostsController($View);
    }

    public function testIndex() {
          $result = $this->testAction('Posts/Index');
        debug($result);        

    }
}
Run Code Online (Sandbox Code Playgroud)

帖子/索引控制器返回存储在DB中的所有帖子的列表.

php phpunit cakephp

5
推荐指数
1
解决办法
2409
查看次数

标签 统计

cakephp ×1

php ×1

phpunit ×1