dquoj04882 2010-01-22 07:15
浏览 36

Kohana 3和SimpleTest使用autorun.php

How do I go about integrating Simpletest with Kohana 3? I have checked out this answer but I like to use the autorun.php functionality from SimpleTest.

  • 写回答

1条回答 默认 最新

  • douan4106 2010-01-23 15:35
    关注

    After some hours of looking over the code, I have discovered how to do it

    1. Create a new copy of index.php, and name it test_index.php
    2. disable the error_reporting line in test_index.php
    3. Create a new copy of bootstrap.php, and name it test_bootstrap.php
    4. comment out the request at the bottom
    5. Ensure that test_index.php includes test_boostrap.php instead of bootstrap.php
    6. Add simpletests to the directory structure
    7. Write the test case - include 'test_index.php' and 'autorun.php' (from simpletests) and code test cases as usual.

    My example:

    <?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');
    
        }
    }
    
    ?>
    

    Some notes: the $response variable depends on if you are using a View or pure text output. If you are using the template controller or a view, then $response is the view which you have used to render the content. Variables in the view are avaliable , as shown above (the variable content is defined inside the view).

    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测