From a28956ffee0b3b6826038a705a7109b85689a290 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Fri, 8 Dec 2023 13:50:33 -0500 Subject: [PATCH] Set conference key type to fix scout search error --- app/Models/UuidBase.php | 2 ++ phpunit.xml.dist | 2 +- tests/Feature/ConferenceTest.php | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/Models/UuidBase.php b/app/Models/UuidBase.php index f9ffec29..c85c6257 100644 --- a/app/Models/UuidBase.php +++ b/app/Models/UuidBase.php @@ -12,6 +12,8 @@ class UuidBase extends Eloquent */ public $incrementing = false; + protected $keyType = 'string'; + /** * Boot function from laravel. */ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f28f36be..7017dc96 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -35,7 +35,7 @@ - + diff --git a/tests/Feature/ConferenceTest.php b/tests/Feature/ConferenceTest.php index 5bba3e10..18a2b2d8 100644 --- a/tests/Feature/ConferenceTest.php +++ b/tests/Feature/ConferenceTest.php @@ -1215,4 +1215,16 @@ function checking_whether_a_conferences_is_rejected() $this->assertFalse($conferenceA->isRejected()); $this->assertTrue($conferenceB->isRejected()); } + + /** @test */ + public function searching_conferences_by_name(): void + { + $conferenceA = Conference::factory()->create(['location' => 'Boston, MA']); + $conferenceB = Conference::factory()->create(['location' => 'New York, NY']); + + $results = Conference::searchQuery('boston', fn ($query) => $query)->get(); + + $this->assertContains($conferenceA->id, $results->pluck('id')); + $this->assertNotContains($conferenceB->id, $results->pluck('id')); + } }