Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

error on language library using test unit #188

Closed
bitbucket-import opened this Issue Aug 19, 2011 · 3 comments

Comments

Projects
None yet
5 participants

I'm using the test unit library to evaluate my code. All goes fine, but I have seen that in the error log of CI there are reported several errors from language library like this:

ERROR - 2011-06-30 11:41:07 --> Could not find the language line "ut_shortcode 1 = 31220"

ERROR - 2011-06-30 11:41:07 --> Could not find the language line "ut_/var/www/html/site/application/controllers/test/test_program.php"

though the web page doesn't show any error.

I don't know how to fix the code or how to improve it. Please help

mi contact is apolinux at gmail dot com

It looks like this problem is with the result function on line 221. It accesses language strings that don't exist with a prefix of "ut_". These are based on the titles and descriptions that are set.

Here's what I did:

In the Unit_test.php file comment out the following block starting at line number 246:

if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$v))))
{
$v = $line;
}

In the Unit_test.php file comment out the following block starting at line number 255:

if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val))))
{
$val = $line;
}

It The errors don't appear anymore but the green/red formatting of the default template disappears. It would be nice if this issue could get resolved in a better way as it is difficult to wade through ERROR messages when I'm tailing the log during unit tests.

ziyun commented Sep 26, 2012

I added a bool parameter to the Lang::line() function that will determine whether or not the error is logged.

Open up "Lang.php" in /system/core

Change the line function to this:

function line($line = '', $report = TRUE)
{
$value = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];

// Because killer robots like unicorns!
if ($value === FALSE && $report === TRUE)
{
    log_message('error', 'Could not find the language line "'.$line.'"');
}

return $value;
}

Now in "Unit_test.php" in /system/libraries

Go to line 246:

if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$v), FALSE)))

And line 255:

if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val), FALSE)))

This way you kept to maintain the formatting and keep your log file clean.

Contributor

alexbilbie commented Sep 26, 2012

@ziyun can you send a pull request please.

Please change the Yoda conditions though to a normal comparison

Dentxinho pushed a commit to Dentxinho/CodeIgniter that referenced this issue Sep 28, 2012

Merge pull request #188 from hitno/2
Croatian characters was messed

@narfbg narfbg closed this Nov 22, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment