i am new in Laravel. Using local development environment with Homestead Try to run simple test
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class UserTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
{
$response = $this->get('/');
$response->assertStatus(200);
}
}
routes/web.php :
Route::get('/', function () {
return view('main');
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
running phpunit returns 404 error
vagrant@homestead:~/code/laravel$ phpunit PHPUnit 6.4.3 by Sebastian Bergmann and contributors.
.F. 3 / 3 (100%)
Time: 1.07 seconds, Memory: 10.00MB
There was 1 failure:
1) Tests\Feature\UserTest::testBasicTest Expected status code 200 but received 404. Failed asserting that false is true.
/home/vagrant/code/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:78 /home/vagrant/code/laravel/tests/Feature/UserTest.php:25
I have tried to fix it with these ways
1. Laravel phpunit always 404 updateTestCase.php
protected $baseUrl = 'http://localhost'
change with
protected $baseUrl = 'http://laravel.local'
2. https://github.com/dingo/api/issues/540 and next to it https://github.com/dingo/api/issues/571
use Illuminate\Foundation\Testing\WithoutMiddleware;
class BankTest extends TestCase {
use WithoutMiddleware;
Changing APP_URL in .env to
APP_URL=laravel.local
none of this helped
'laravel.local' works fine in browser
Please, help me fix it