Skip to content

Commit 599f66f

Browse files
authored
Merge pull request #53 from tylerdak/fix/global-repo-find-return-null
Fix: Global Repository Can't Return Null
2 parents 95df80d + 788a03d commit 599f66f

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/Repositories/GlobalRepository.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ public function find($id): ?GlobalSet
3939
return (new $global)->register();
4040
}
4141

42-
$r = parent::find($id);
43-
44-
if ($r) {
45-
return $r;
46-
}
42+
return parent::find($id);
4743
}
4844

4945
private function initializeGlobals()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
use Statamic\Facades\GlobalSet;
4+
use Tests\TestCase;
5+
6+
pest()->extend(TestCase::class);
7+
test('::find does not throw when no result is found', function (): void {
8+
GlobalSet::find('id-that-does-not-exist');
9+
})->throwsNoExceptions();
10+
11+
test('::find returns null for nonexistent handles', function (): void {
12+
$nullset = GlobalSet::find('id-that-does-not-exist');
13+
14+
expect($nullset)->toBeNull();
15+
});

0 commit comments

Comments
 (0)