繁体   English   中英

Kohana 3和SimpleTest使用autorun.php

[英]Kohana 3 and SimpleTest using autorun.php

如何将Simpletest与Kohana 3集成在一起? 我已经签出了这个答案,但是我想使用SimpleTest的autorun.php功能。

经过几个小时的检查,我发现了如何做

  1. 创建index.php的新副本,并将其命名为test_index.php
  2. 禁用test_index.php中的error_reporting行
  3. 创建bootstrap.php的新副本,并将其命名为test_bootstrap.php
  4. 在底部注释掉请求
  5. 确保test_index.php包含test_boostrap.php而不是bootstrap.php
  6. 向目录结构添加simpletests
  7. 编写测试用例-像往常一样包括“ test_index.php”和“ autorun.php”(来自simpletests)并编写代码测试用例。

我的例子:

<?php
include_once ("../../test_index.php");
include_once ("../simpletest/autorun.php");

class kohana_init_test extends UnitTestCase
{
    function testTrue()
    {
        $this->assertTrue(true);
    }

    function testWelcome()
    {
        $response = Request::factory('main/index')->execute()->response;

        $this->assertEqual($response->content, 'testing');

    }
}

?>

一些注意事项:$ response变量取决于您使用的是View还是纯文本输出。 如果使用模板控制器或视图,则$ response是用于呈现内容的视图。 视图中的变量可用,如上所示(变量内容在视图内部定义)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM