Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPUnit says route not defined (Laravel)

I run a unit-test on routing. Funny thing is: PHPUnit says "all good" for the first test in a test file, but fails with "route not defined" for exactly the same test if it only goes second in the file.

I tried to create dummy test with only

$this->assertTrue(true);

and put is as a first test, the second test doing some work, precisely:

$this->call('GET', "http:....."); 
$this->assertRedirectedToRoute('login');

and it fails.

But this same test gives me success if it goes first in the file. Very strange.

Does anyone know why is it happening?

like image 668
Yevgeniy Afanasyev Avatar asked Dec 04 '22 01:12

Yevgeniy Afanasyev


1 Answers

I solved the case. It was routing. In my \app\Http\routes.php file I had inclusions.

The fix was changing require_once to require in my routes.php file.

like image 100
Yevgeniy Afanasyev Avatar answered Dec 06 '22 13:12

Yevgeniy Afanasyev