diff --git a/src/Repositories/GlobalRepository.php b/src/Repositories/GlobalRepository.php index f287685..46facad 100644 --- a/src/Repositories/GlobalRepository.php +++ b/src/Repositories/GlobalRepository.php @@ -39,11 +39,7 @@ public function find($id): ?GlobalSet return (new $global)->register(); } - $r = parent::find($id); - - if ($r) { - return $r; - } + return parent::find($id); } private function initializeGlobals() diff --git a/tests/Unit/GlobalRepositoryTest.php b/tests/Unit/GlobalRepositoryTest.php new file mode 100644 index 0000000..8c83aef --- /dev/null +++ b/tests/Unit/GlobalRepositoryTest.php @@ -0,0 +1,15 @@ +extend(TestCase::class); +test('::find does not throw when no result is found', function (): void { + GlobalSet::find('id-that-does-not-exist'); +})->throwsNoExceptions(); + +test('::find returns null for nonexistent handles', function (): void { + $nullset = GlobalSet::find('id-that-does-not-exist'); + + expect($nullset)->toBeNull(); +});