Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 12, 2021
1 parent bbfa760 commit 414f382
Showing 1 changed file with 40 additions and 40 deletions.
80 changes: 40 additions & 40 deletions src/Illuminate/Support/Testing/Fakes/BusFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ class BusFake implements QueueingDispatcher
protected $commands = [];

/**
* The commands that have been dispatched after the response has been sent.
* The commands that have been dispatched synchronously.
*
* @var array
*/
protected $commandsAfterResponse = [];
protected $commandsSync = [];

/**
* The commands that have been explicitly dispatched synchronously.
* The commands that have been dispatched after the response has been sent.
*
* @var array
*/
protected $commandsSync = [];
protected $commandsAfterResponse = [];

/**
* The batches that have been dispatched.
Expand Down Expand Up @@ -136,42 +136,42 @@ public function assertNotDispatched($command, $callback = null)
}

/**
* Assert if a job was dispatched after the response was sent based on a truth-test callback.
* Assert if a job was explicitly dispatched synchronously based on a truth-test callback.
*
* @param string|\Closure $command
* @param callable|int|null $callback
* @return void
*/
public function assertDispatchedAfterResponse($command, $callback = null)
public function assertDispatchedSync($command, $callback = null)
{
if ($command instanceof Closure) {
[$command, $callback] = [$this->firstClosureParameterType($command), $command];
}

if (is_numeric($callback)) {
return $this->assertDispatchedAfterResponseTimes($command, $callback);
return $this->assertDispatchedSyncTimes($command, $callback);
}

PHPUnit::assertTrue(
$this->dispatchedAfterResponse($command, $callback)->count() > 0,
"The expected [{$command}] job was not dispatched for after sending the response."
$this->dispatchedSync($command, $callback)->count() > 0,
"The expected [{$command}] job was not dispatched synchronously."
);
}

/**
* Assert if a job was pushed after the response was sent a number of times.
* Assert if a job was pushed synchronously a number of times.
*
* @param string $command
* @param int $times
* @return void
*/
public function assertDispatchedAfterResponseTimes($command, $times = 1)
public function assertDispatchedSyncTimes($command, $times = 1)
{
$count = $this->dispatchedAfterResponse($command)->count();
$count = $this->dispatchedSync($command)->count();

PHPUnit::assertSame(
$times, $count,
"The expected [{$command}] job was pushed {$count} times instead of {$times} times."
"The expected [{$command}] job was synchronously pushed {$count} times instead of {$times} times."
);
}

Expand All @@ -182,55 +182,55 @@ public function assertDispatchedAfterResponseTimes($command, $times = 1)
* @param callable|null $callback
* @return void
*/
public function assertNotDispatchedAfterResponse($command, $callback = null)
public function assertNotDispatchedSync($command, $callback = null)
{
if ($command instanceof Closure) {
[$command, $callback] = [$this->firstClosureParameterType($command), $command];
}

PHPUnit::assertCount(
0, $this->dispatchedAfterResponse($command, $callback),
"The unexpected [{$command}] job was dispatched for after sending the response."
0, $this->dispatchedSync($command, $callback),
"The unexpected [{$command}] job was dispatched synchronously."
);
}

/**
* Assert if a job was explicitly dispatched synchronously based on a truth-test callback.
* Assert if a job was dispatched after the response was sent based on a truth-test callback.
*
* @param string|\Closure $command
* @param callable|int|null $callback
* @return void
*/
public function assertDispatchedSync($command, $callback = null)
public function assertDispatchedAfterResponse($command, $callback = null)
{
if ($command instanceof Closure) {
[$command, $callback] = [$this->firstClosureParameterType($command), $command];
}

if (is_numeric($callback)) {
return $this->assertDispatchedSyncTimes($command, $callback);
return $this->assertDispatchedAfterResponseTimes($command, $callback);
}

PHPUnit::assertTrue(
$this->dispatchedSync($command, $callback)->count() > 0,
"The expected [{$command}] job was not dispatched synchronously."
$this->dispatchedAfterResponse($command, $callback)->count() > 0,
"The expected [{$command}] job was not dispatched for after sending the response."
);
}

/**
* Assert if a job was pushed synchronously a number of times.
* Assert if a job was pushed after the response was sent a number of times.
*
* @param string $command
* @param int $times
* @return void
*/
public function assertDispatchedSyncTimes($command, $times = 1)
public function assertDispatchedAfterResponseTimes($command, $times = 1)
{
$count = $this->dispatchedSync($command)->count();
$count = $this->dispatchedAfterResponse($command)->count();

PHPUnit::assertSame(
$times, $count,
"The expected [{$command}] job was synchronously pushed {$count} times instead of {$times} times."
"The expected [{$command}] job was pushed {$count} times instead of {$times} times."
);
}

Expand All @@ -241,15 +241,15 @@ public function assertDispatchedSyncTimes($command, $times = 1)
* @param callable|null $callback
* @return void
*/
public function assertNotDispatchedSync($command, $callback = null)
public function assertNotDispatchedAfterResponse($command, $callback = null)
{
if ($command instanceof Closure) {
[$command, $callback] = [$this->firstClosureParameterType($command), $command];
}

PHPUnit::assertCount(
0, $this->dispatchedSync($command, $callback),
"The unexpected [{$command}] job was dispatched synchronously."
0, $this->dispatchedAfterResponse($command, $callback),
"The unexpected [{$command}] job was dispatched for after sending the response."
);
}

Expand Down Expand Up @@ -426,45 +426,45 @@ public function dispatched($command, $callback = null)
}

/**
* Get all of the jobs dispatched after the response was sent matching a truth-test callback.
* Get all of the jobs dispatched synchronously matching a truth-test callback.
*
* @param string $command
* @param callable|null $callback
* @return \Illuminate\Support\Collection
*/
public function dispatchedAfterResponse(string $command, $callback = null)
public function dispatchedSync(string $command, $callback = null)
{
if (! $this->hasDispatchedAfterResponse($command)) {
if (! $this->hasDispatchedSync($command)) {
return collect();
}

$callback = $callback ?: function () {
return true;
};

return collect($this->commandsAfterResponse[$command])->filter(function ($command) use ($callback) {
return collect($this->commandsSync[$command])->filter(function ($command) use ($callback) {
return $callback($command);
});
}

/**
* Get all of the jobs dispatched synchronously matching a truth-test callback.
* Get all of the jobs dispatched after the response was sent matching a truth-test callback.
*
* @param string $command
* @param callable|null $callback
* @return \Illuminate\Support\Collection
*/
public function dispatchedSync(string $command, $callback = null)
public function dispatchedAfterResponse(string $command, $callback = null)
{
if (! $this->hasDispatchedSync($command)) {
if (! $this->hasDispatchedAfterResponse($command)) {
return collect();
}

$callback = $callback ?: function () {
return true;
};

return collect($this->commandsSync[$command])->filter(function ($command) use ($callback) {
return collect($this->commandsAfterResponse[$command])->filter(function ($command) use ($callback) {
return $callback($command);
});
}
Expand Down Expand Up @@ -503,9 +503,9 @@ public function hasDispatched($command)
* @param string $command
* @return bool
*/
public function hasDispatchedAfterResponse($command)
public function hasDispatchedSync($command)
{
return isset($this->commandsAfterResponse[$command]) && ! empty($this->commandsAfterResponse[$command]);
return isset($this->commandsSync[$command]) && ! empty($this->commandsSync[$command]);
}

/**
Expand All @@ -514,9 +514,9 @@ public function hasDispatchedAfterResponse($command)
* @param string $command
* @return bool
*/
public function hasDispatchedSync($command)
public function hasDispatchedAfterResponse($command)
{
return isset($this->commandsSync[$command]) && ! empty($this->commandsSync[$command]);
return isset($this->commandsAfterResponse[$command]) && ! empty($this->commandsAfterResponse[$command]);
}

/**
Expand Down

0 comments on commit 414f382

Please sign in to comment.