CodeIgniter
CodeIgniter copied to clipboard
Unit Test class - set_test_items() not working for report().
I don't know if this is intentional or not, but using the Unit Test library, if do:
$this->unit->set_test_items(array('test_name', 'result'));
echo $this->unit->run($test, $expected_result, $test_name);
echo $this->unit->report();
The first "run()" outputs only the expected test_name and result fields. The "report()" outputs everything.
If this is expected and intentional, that's fine. If not, it's a really simple fix.
if ( !in_array($key, $this->_test_items_visible))
{
continue;
}
if (is_array($val))
{
foreach ($val as $k => $v)
{
// begin fix
if ( !in_array($k, $this->_test_items_visible))
{
continue;
}
//end fix
if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$v))))
{
...
I just spent the last 15-30 minutes trying to figure out this exact fix, I come here to report it as a bug with a fix... Did a search to see if there was a previous bug open already... BOOM. Should really start working the other way. Would have saved me 15 minutes.
Based on the documentation, this is definitely a bug.
I'll submit a pull request with this fix in it.