Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用autorun.php的Kohana 3和SimpleTest_Php_Unit Testing_Kohana - Fatal编程技术网

使用autorun.php的Kohana 3和SimpleTest

使用autorun.php的Kohana 3和SimpleTest,php,unit-testing,kohana,Php,Unit Testing,Kohana,如何将Simpletest与Kohana3集成?我已经检查过了,但是我喜欢使用SimpleTest中的autorun.php功能。在查看了几个小时的代码之后,我发现了如何做 创建index.php的新副本,并将其命名为test_index.php 在test_index.php中禁用错误报告行 创建bootstrap.php的新副本,并将其命名为test_bootstrap.php 在底部注释掉请求 确保test_index.php包含test_boostrap.php而不是bootstrap.

如何将Simpletest与Kohana3集成?我已经检查过了,但是我喜欢使用SimpleTest中的autorun.php功能。

在查看了几个小时的代码之后,我发现了如何做

  • 创建index.php的新副本,并将其命名为test_index.php
  • 在test_index.php中禁用错误报告行
  • 创建bootstrap.php的新副本,并将其命名为test_bootstrap.php
  • 在底部注释掉请求
  • 确保test_index.php包含test_boostrap.php而不是bootstrap.php
  • 将simpletests添加到目录结构中
  • 编写测试用例——包括“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变量取决于您使用的是视图还是纯文本输出。如果使用的是模板控制器或视图,则$response是用于呈现内容的视图。视图中的变量是可用的,如上所示(变量内容在视图中定义)。

    在查看代码几个小时后,我发现了如何执行该操作

  • 创建index.php的新副本,并将其命名为test_index.php
  • 在test_index.php中禁用错误报告行
  • 创建bootstrap.php的新副本,并将其命名为test_bootstrap.php
  • 在底部注释掉请求
  • 确保test_index.php包含test_boostrap.php而不是bootstrap.php
  • 将simpletests添加到目录结构中
  • 编写测试用例——包括“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变量取决于您使用的是视图还是纯文本输出。如果使用的是模板控制器或视图,则$response是用于呈现内容的视图。视图中的变量是可用的,如上所示(变量内容在视图中定义)