Function on helper.php not detected with codeception Laravel

187 views Asked by At

I'm making function test on my laravel(4) project with Codeception. But it doesn't detected function define in Laravel helper.php file. If anybody know please let me know the way to fix it. Thanks.

function rangeWithKeys($from, $to, $leadingZeros = false)
{

    if ($leadingZeros === TRUE )
    {
        $array = [];

        for($i =$from; $i <= $to; $i++)
        {
            if($i<10){
                $prefixedNumber = '0'.$i;
                $array[$prefixedNumber] = $prefixedNumber;
            }else{
                $array[$i] = $i;
            }
        }

        return $array;

    }

    $array = array_combine(range($from,$to),range($from,$to));

    return $array;
}

I use this helper function for form select but when run codeception, got Call to undefined function rangeWithKeys() error.

{{ Form::select('birthMonth', array('M' => 'M') + rangeWithKeys(1,12, TRUE), Input::old('Month') ? Input::old('Month') : 'M',['class' => 'form-control'])}}
1

There are 1 answers

2
Mansoor H On

You can include the following syntax in top of the controller file.

use <helper class name>;