The error message "Received Mockery_0_Illuminate_Routing_Router::getRoutes(), but no expectations were specified" suggests that the test is not properly setting up the mock for the \Route::getRoutes() method. One possible solution is to use the shouldReceive method to set the expectation for the getRoutes method before calling the Livewire component. Here's an example:
use Illuminate\Routing\RouteCollection;
use Illuminate\Support\Facades\Route;
use Livewire\Livewire;
// ...
public function testInlineLivewireComponent()
{
// Set up the mock for Route::getRoutes()
Route::shouldReceive('getRoutes')
->once()
->withNoArgs()
->andReturn(new RouteCollection());
// Set up the mock for Route::currentRouteName()
Route::shouldReceive('currentRouteName')
->once()
->withNoArgs()
->andReturn('surveys.create');
// Call the Livewire component
Livewire::actingAs($user)
->test(\App\Http\Livewire\Survey\Edit::class)
->set('date', $data['date'])
->call('save')
->assertHasNoErrors();
}
In this example, we first set up the mock for Route::getRoutes() using the shouldReceive method. We specify that the method should be called once with no arguments, and should return a new RouteCollection instance. We then set up the mock for Route::currentRouteName() in a similar way.
Finally, we call the Livewire component using the Livewire::actingAs()->test() method chain, and then call the set, call, and assertHasNoErrors methods as before.
By setting up the mock for Route::getRoutes() before calling the Livewire component, we ensure that the Livewire component can access the routes it needs to function properly.