When I create a PHPUnit test case in Laravel Lumen and call the visit('/')
function, PHPUnit always returns a 404 error code.
I have the following code to test the weird behavior:
class TestCase extends Laravel\Lumen\Testing\TestCase {
protected $baseUrl = 'https://google.com'; // this used to be my own url but even this doesn't work.
public function createApplication() {
return require __DIR__.'/../bootstrap/app.php';
}
}
class CountryTest extends TestCase {
public function testIndex() {
$this->visit('/');
}
}
Does anyone know what I did wrong or how to fix this?
Thanks in advance.
I fixed this by including my routes with require
instead of require_once
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With