小编Bin*_*ary的帖子

cakephp ControllerTest

我是一个菜鸟,试图为Cakephp书的Blog Tutorial编写一个ControllerTest.完成这项任务后,我找到了一个很好的例子,我可以适应.本书提供了以下示例:http: //book.cakephp.org/2.0/en/development/testing.html#testing-controllers 因此,我在/ app/Controller /中创建了一个ArticlesController.php文件,并在其中创建了ArticlesControllerTest.php /应用/测试/箱/控制器/

我的ArticlesController.php的内容是:

<?php
class ArticlesController extends ControllerTestCase {
//public $fixtures = array('app.article');

public function testIndex() {
    $result = $this->testAction('/articles/index');
    debug($result);
}

public function testIndexShort() {
    $result = $this->testAction('/articles/index/short');
    debug($result);
}

public function testIndexShortGetRenderedHtml() {
    $result = $this->testAction(
        '/articles/index/short',
        array('return' => 'contents')
    );
    debug($result);
}

public function testIndexShortGetViewVars() {
    $result = $this->testAction(
        '/articles/index/short',
        array('return' => 'vars')
    );
    debug($result);
}

public function testIndexPostData() {
    $data = array(
        'Article' => array(
            'user_id' => 1,
            'published' …
Run Code Online (Sandbox Code Playgroud)

testing cakephp

3
推荐指数
1
解决办法
825
查看次数

标签 统计

cakephp ×1

testing ×1