【发布时间】:2010-01-22 07:15:41
【问题描述】:
如何将 Simpletest 与 Kohana 3 集成?我已经检查了这个answer,但我喜欢使用 SimpleTest 中的 autorun.php 功能。
【问题讨论】:
标签: php unit-testing kohana
如何将 Simpletest 与 Kohana 3 集成?我已经检查了这个answer,但我喜欢使用 SimpleTest 中的 autorun.php 功能。
【问题讨论】:
标签: php unit-testing kohana
在查看代码几个小时后,我发现了如何做到这一点
我的例子:
<?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 就是您用来呈现内容的视图。视图中的变量可用,如上图(变量内容在视图内部定义)。
【讨论】: