Skip to content

Commit 1536df3

Browse files
xurshudyanXurshudyan
andauthored
Fix: always restore original queue in fakeFor and fakeExceptFor (#56165)
Co-authored-by: Xurshudyan <v.khurshudyan@aico.swiss>
1 parent 57ba15f commit 1536df3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Illuminate/Support/Facades/Queue.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,11 @@ public static function fakeFor(callable $callable, array $jobsToFake = [])
120120

121121
static::fake($jobsToFake);
122122

123-
return tap($callable(), function () use ($originalQueueManager) {
123+
try {
124+
return $callable();
125+
} finally {
124126
static::swap($originalQueueManager);
125-
});
127+
}
126128
}
127129

128130
/**
@@ -138,9 +140,11 @@ public static function fakeExceptFor(callable $callable, array $jobsToAllow = []
138140

139141
static::fakeExcept($jobsToAllow);
140142

141-
return tap($callable(), function () use ($originalQueueManager) {
143+
try {
144+
return $callable();
145+
} finally {
142146
static::swap($originalQueueManager);
143-
});
147+
}
144148
}
145149

146150
/**

0 commit comments

Comments
 (0)