Codeigniter 单元测试栈
这里有人用过吗 理解它有困难。T_T 我所做的很简单 例如 我有一个控制器方法myphp() CI单元测试:Codeigniter 单元测试栈,codeigniter,phpunit,Codeigniter,Phpunit,这里有人用过吗 理解它有困难。T_T 我所做的很简单 例如 我有一个控制器方法myphp() CI单元测试: public function setUp() { // Set the tested controller $this->CI = set_controller('home'); // date_default_timezone_set('America/Los_Angeles'); } function testMyPhp() {
public function setUp()
{
// Set the tested controller
$this->CI = set_controller('home');
// date_default_timezone_set('America/Los_Angeles');
}
function testMyPhp()
{
$this->CI->myphp();
$out = output();
var_dump($out); //return empty eventhough function myphp is returning a string ('boom')
}
发生了什么事。??我只想测试是否可以获取方法myphp的输出。什么是output()?您使用的是什么版本的CI?fooStack网站说他们测试的最新版本是1.7.2,现在已经很旧了。空“.string(0)”。我使用的是CI 2.1.0。不,我的意思是函数的输出是什么,就像字面上它是做什么的?我想不起有哪一个本机PHP或CI助手函数具有这样的名称。是你自己的助手吗?CI 2.1.0与1.7.2非常不同,您可能必须简单地接受此CI单元不支持2.1.0获取缓冲输出。在我的例子中,它获取myphp函数的返回。因此,假设它应该输出CIUnit的一个字符串“boom”尝试,我正在成功地使用codeigniter版本2.1.2的
0.18-dev\u for_CI2.1.0
分支。
public function setUp()
{
// Set the tested controller
$this->CI = set_controller('home');
// date_default_timezone_set('America/Los_Angeles');
}
function testMyPhp()
{
$this->CI->myphp();
$out = output();
var_dump($out); //return empty eventhough function myphp is returning a string ('boom')
}