Welcome Guest, Not a member yet? Register   Sign In
Unit Test class - set_test_items() not working for report(). Is that intentional?
#1

[eluser]matula[/eluser]
Code:
$test = 1 + 1;
        $expected_result = 2;
        $test_name = 'Adds one plus one';
        $this->unit->set_test_items(array('test_name', 'result'));
        echo $this->unit->run($test, $expected_result, $test_name);
        echo $this->unit->report();

The top "run()" outputs as expected, but "report()" outputs the entire test. Is this intentional? I was expecting set_test_items() to work on both the result() and report() methods. It looks like a pretty simple fix, but I don't want to mess with it if those methods were designed that way.

FYI... the fix would be in the result() method. It only checks for "_test_items_visible" in the top level of an array. Since the "run()" method actually puts the results into a multi level array, it breaks...
Code:
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))))
        {
...




Theme © iAndrew 2016 - Forum software by © MyBB