I'm trying to test my Laravel Scout (Mellisearch) with PestPHP. Testing the model data gets sent to the search index and the search is correct.
For the search, if I were to search user $user = User::search('wanna_coder101')->get();
, then it'd return the user model toArray() results
. Or is that just this example?
Using PestPHP, with Event::fake(), we can test whether a broadcast would dispatch. I want to do the same thing but with the Search.
it('Test Broadcast Dispatches', function () {
// Setup fake event
Event::fake();
// Dispatch Broadcast
MyBroadcast::dispatch(auth()->user());
// Assert Broadcast Correctly Dispatched
Event::assertDispatched(MyBroadcast::class);
});
The broadcast driver, in test, would automatically use null or log during testing instead of redis.
Can scout do the same, use collection instead, hence can locally test search indexes get sent off and can get data back to test it's the correct response.
Is the only option to use this Laravel Scount testing package?
Versions
"php": "^8.1.0",
"laravel/framework": "^10.0",
"laravel/scout": "^9.8",
"pestphp/pest-plugin-laravel": "^1.4",
"phpunit/phpunit": "^9.5.10",