我试图学习如何在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中的所有帖子的列表.