使用autorun.php的Kohana 3和SimpleTest
如何将Simpletest与Kohana3集成?我已经检查过了,但是我喜欢使用SimpleTest中的autorun.php功能。在查看了几个小时的代码之后,我发现了如何做使用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.
<?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是用于呈现内容的视图。视图中的变量是可用的,如上所示(变量内容在视图中定义)。在查看代码几个小时后,我发现了如何执行该操作
<?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是用于呈现内容的视图。视图中的变量是可用的,如上所示(变量内容在视图中定义)