[英]Kohana 3 and SimpleTest using autorun.php
After some hours of looking over the code, I have discovered how to do it 经过几个小时的检查,我发现了如何做
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. 一些注意事项:$ response变量取决于您使用的是View还是纯文本输出。 If you are using the template controller or a view, then $response is the view which you have used to render the content.
如果使用模板控制器或视图,则$ response是用于呈现内容的视图。 Variables in the view are avaliable , as shown above (the variable content is defined inside the view).
视图中的变量可用,如上所示(变量内容在视图内部定义)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.