File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -1285,9 +1285,11 @@ public static function freezeUuids(Closure $callback = null)
1285
1285
Str::createUuidsUsing (fn () => $ uuid );
1286
1286
1287
1287
if ($ callback !== null ) {
1288
- $ callback ($ uuid );
1289
-
1290
- Str::createUuidsNormally ();
1288
+ try {
1289
+ $ callback ($ uuid );
1290
+ } finally {
1291
+ Str::createUuidsNormally ();
1292
+ }
1291
1293
}
1292
1294
1293
1295
return $ uuid ;
Original file line number Diff line number Diff line change @@ -991,6 +991,19 @@ public function testItCanFreezeUuidsInAClosure()
991
991
Str::createUuidsNormally ();
992
992
}
993
993
994
+ public function testItCreatesUuidsNormallyAfterFailureWithinFreezeMethod ()
995
+ {
996
+ try {
997
+ Str::freezeUuids (function () {
998
+ Str::createUuidsUsing (fn () => Str::of ('1234 ' ));
999
+ $ this ->assertSame ('1234 ' , Str::uuid ()->toString ());
1000
+ throw new \Exception ('Something failed. ' );
1001
+ });
1002
+ } catch (\Exception $ e ) {
1003
+ $ this ->assertNotSame ('1234 ' , Str::uuid ()->toString ());
1004
+ }
1005
+ }
1006
+
994
1007
public function testItCanSpecifyASequenceOfUuidsToUtilise ()
995
1008
{
996
1009
Str::createUuidsUsingSequence ([
You can’t perform that action at this time.
0 commit comments