1
我知道如何设置和执行一个控制器来测试它。设置Codeigniter My_ciunit控制器测试的不同输入
查看框架链接https://bitbucket.org/kenjis/my-ciunit
但我怎么能确定给定的测试数据输入?当然,我可以自己设置$ _GET和$ _POST,但是输入库重新解析了这个吗?
我无法在Google上找到答案。我也想知道为什么Codeigniter测试有如此糟糕的谷歌结果。
<?php
/**
* @group Controller
*/
class SomeControllerTest extends CIUnit_TestCase
{
public function setUp()
{
// Set the tested controller
$this->CI = set_controller('welcome');
}
public function testWelcomeController()
{
// Call the controllers method
$this->CI->index();
// Fetch the buffered output
$out = output();
$viewData = viewvars();
// Check if the content is OK
$this->assertSame(0, preg_match('/(error|notice)/i', $out));
}
public function testInput(){
//reset $_GET and $_POST?
$this->CI->login();
//assert valid login etc ...
}
}