Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why having more than one test method in a file using Laravel raises error?

when I have more than one test in a testfile with laravel, and I execute them I get:

Fatal error: Cannot redeclare nameSort() (previously declared in C:\wamp\www\project\app\start\global.php:110) in C:\wamp\www\project\app\start\global.php on line 112

This is even when this is my testfile:

class DealControllerTest extends TestCase {

    public function testIndex()
    {
        $this->assertTrue(true);
    }

    public function testApiKey()
    {
        $this->assertTrue(true);
    }
}
like image 742
Alexander Cogneau Avatar asked Mar 23 '23 20:03

Alexander Cogneau


1 Answers

I was able to solve the issue by replacing require with require_once for includes in the global.php file.

For example,

require app_path().'/helpers.php';

should be

require_once app_path().'/helpers.php';

like image 105
Leon W Avatar answered Apr 11 '23 00:04

Leon W