I make this simple test:
public function test_my_awesome_test()
{
$user = User::find(1);
$response = $this->actingAs($user)->get('/awesome/test');
$response->assertStatus(200);
}
But after run test it's display me error:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'testing.users' doesn't exist (SQL: select * from
userswhereusers.id= 1 limit 1)
I had this same error if I needed to print some data from database. This tables exist and website works correctly. Who know where is problem?
According to the Laravel documentation, Sail overrides the DB name you defined in the .env file when you run the tests. You need to remove the following line from your phpunit.xml file:
<env name="DB_DATABASE" value="testing"/>
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