35 lines
946 B
PHP
35 lines
946 B
PHP
<?php
|
|
|
|
use App\Models\Hunts;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
it('filters hunts using the search parameter', function (string $param) {
|
|
config(['scout.driver' => 'collection']);
|
|
|
|
$user = User::factory()->create();
|
|
$matching = Hunts::factory()->create([
|
|
'title' => 'Chasse au tresor de Bordeaux',
|
|
'description' => 'Une aventure urbaine',
|
|
]);
|
|
$nonMatching = Hunts::factory()->create([
|
|
'title' => 'Parcours decouverte Lyon',
|
|
'description' => 'Balade tranquille',
|
|
]);
|
|
|
|
$response = $this->actingAs($user, 'sanctum')
|
|
->getJson("/api/hunts?{$param}=tresor");
|
|
|
|
$response->assertOk();
|
|
$huntIds = collect($response->json('data'))->pluck('id')->all();
|
|
|
|
expect($huntIds)
|
|
->toContain($matching->id)
|
|
->not->toContain($nonMatching->id);
|
|
})->with([
|
|
'search' => 'search',
|
|
'q' => 'q',
|
|
]);
|