Do you have use RefreshDatabase; in your tests?
https://laravel.com/docs/5.7/database-testing#resetting-the-database-after-each-test
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
All testing on PHPUnit was working completely fine. But when I added View::share in AppServiceProvider then all the PHPUnit tests failed.
AppServiceProvider.php
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
\View::share('categories', \App\Models\Category::all());
}
}
Error
Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such table: categories (SQL: select * from "categories")
Please guide me, how can I fix this. Where should I call View::share in Laravel app so, all tests should pass.
Please or to participate in this conversation.