Reputation: 1274
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);
}
}
Upvotes: 4
Views: 1426
Reputation: 61
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';
Upvotes: 6
Reputation: 1274
The cause were custom helper functions declared in global.php, I had to put them in a separate class to solve the error. So if you have any helper functions, put them in a helper class and autoload it by adding it to composer.json.
Upvotes: 1