I have a little helper function, and I'd like to write a test for it.
if ( ! function_exists('lang') )
{
/**
* Get the translation for the given key or return the default value.
*
* @param string $key
* @param array $default
* @return string
*/
function lang($key, $default = null)
{
if (Lang::has('system.'.$key)) return Lang::get('system.'.$key);
return $default;
}
}
I don't know how it goes when testing a single helper function (I've always tested classes), but if that was a method, in phpspec would look something like:
I've thought of that too, but I couldn't think of any solution, since you Lang doesn't have something like Lang::put, which would be ideal to use right before the test.