Skip to content

Commit 4d6bd38

Browse files
Merge branch '8.x'
2 parents 00b0ce0 + e720279 commit 4d6bd38

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/Illuminate/Support/Testing/Fakes/BusFake.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,13 @@ public function assertChained(array $expectedChain)
201201
if ($command instanceof Closure) {
202202
[$command, $callback] = [$this->firstClosureParameterType($command), $command];
203203
} elseif (! is_string($command)) {
204-
$command = get_class($command);
204+
$instance = $command;
205+
206+
$command = get_class($instance);
207+
208+
$callback = function ($job) use ($instance) {
209+
return serialize($this->resetChainPropertiesToDefaults($job)) === serialize($instance);
210+
};
205211
}
206212

207213
PHPUnit::assertTrue(
@@ -219,6 +225,22 @@ public function assertChained(array $expectedChain)
219225
: $this->assertDispatchedWithChainOfClasses($command, $expectedChain, $callback);
220226
}
221227

228+
/**
229+
* Reset the chain properties to their default values on the job.
230+
*
231+
* @param mixed $job
232+
* @return mixed
233+
*/
234+
protected function resetChainPropertiesToDefaults($job)
235+
{
236+
return tap(clone $job, function ($job) {
237+
$job->chainConnection = null;
238+
$job->chainQueue = null;
239+
$job->chainCatchCallbacks = null;
240+
$job->chained = [];
241+
});
242+
}
243+
222244
/**
223245
* Assert if a job was dispatched with an empty chain based on a truth-test callback.
224246
*

0 commit comments

Comments
 (0)