Framework Update

This commit is contained in:
2024-01-31 22:15:08 +08:00
parent b5ff5e8b5f
commit 20678a6a0c
1459 changed files with 25954 additions and 16153 deletions
+3 -1
View File
@@ -79,7 +79,9 @@ class BatchFake extends Batch
*/
public function add($jobs)
{
$this->added[] = array_merge($this->added, $jobs);
foreach ($jobs as $job) {
$this->added[] = $job;
}
return $this;
}
+26 -8
View File
@@ -127,15 +127,21 @@ class BusFake implements QueueingDispatcher
/**
* Assert if a job was pushed a number of times.
*
* @param string $command
* @param string|\Closure $command
* @param int $times
* @return void
*/
public function assertDispatchedTimes($command, $times = 1)
{
$count = $this->dispatched($command)->count() +
$this->dispatchedAfterResponse($command)->count() +
$this->dispatchedSync($command)->count();
$callback = null;
if ($command instanceof Closure) {
[$command, $callback] = [$this->firstClosureParameterType($command), $command];
}
$count = $this->dispatched($command, $callback)->count() +
$this->dispatchedAfterResponse($command, $callback)->count() +
$this->dispatchedSync($command, $callback)->count();
PHPUnit::assertSame(
$times, $count,
@@ -200,13 +206,19 @@ class BusFake implements QueueingDispatcher
/**
* Assert if a job was pushed synchronously a number of times.
*
* @param string $command
* @param string|\Closure $command
* @param int $times
* @return void
*/
public function assertDispatchedSyncTimes($command, $times = 1)
{
$count = $this->dispatchedSync($command)->count();
$callback = null;
if ($command instanceof Closure) {
[$command, $callback] = [$this->firstClosureParameterType($command), $command];
}
$count = $this->dispatchedSync($command, $callback)->count();
PHPUnit::assertSame(
$times, $count,
@@ -259,13 +271,19 @@ class BusFake implements QueueingDispatcher
/**
* Assert if a job was pushed after the response was sent a number of times.
*
* @param string $command
* @param string|\Closure $command
* @param int $times
* @return void
*/
public function assertDispatchedAfterResponseTimes($command, $times = 1)
{
$count = $this->dispatchedAfterResponse($command)->count();
$callback = null;
if ($command instanceof Closure) {
[$command, $callback] = [$this->firstClosureParameterType($command), $command];
}
$count = $this->dispatchedAfterResponse($command, $callback)->count();
PHPUnit::assertSame(
$times, $count,
+9 -4
View File
@@ -85,21 +85,26 @@ class EventFake implements Dispatcher
$actualListener = (new ReflectionFunction($listenerClosure))
->getStaticVariables()['listener'];
$normalizedListener = $expectedListener;
if (is_string($actualListener) && Str::contains($actualListener, '@')) {
$actualListener = Str::parseCallback($actualListener);
if (is_string($expectedListener)) {
if (Str::contains($expectedListener, '@')) {
$expectedListener = Str::parseCallback($expectedListener);
$normalizedListener = Str::parseCallback($expectedListener);
} else {
$expectedListener = [$expectedListener, 'handle'];
$normalizedListener = [
$expectedListener,
method_exists($expectedListener, 'handle') ? 'handle' : '__invoke',
];
}
}
}
if ($actualListener === $expectedListener ||
if ($actualListener === $normalizedListener ||
($actualListener instanceof Closure &&
$expectedListener === Closure::class)) {
$normalizedListener === Closure::class)) {
PHPUnit::assertTrue(true);
return;