vendor/illuminate/support/Testing/Fakes/BusFake.php
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<?php
namespace Illuminate\Support\Testing\Fakes;
use Illuminate\Contracts\Bus\Dispatcher;
use PHPUnit\Framework\Assert as PHPUnit;
class BusFake implements Dispatcher
{
/**
* The commands that have been dispatched.
*
* @var array
*/
protected $commands = [];
/**
* Assert if a job was dispatched based on a truth-test callback.
*
* @param string $command
* @param callable|int|null $callback
* @return void
*/
public function assertDispatched($command, $callback = null)
{
if (is_numeric($callback)) {
return $this->assertDispatchedTimes($command, $callback);
}
PHPUnit::assertTrue(
$this->dispatched($command, $callback)->count() > 0,
"The expected [{$command}] job was not dispatched."
);
}
/**
* Assert if a job was pushed a number of times.
*
* @param string $command
* @param int $times
* @return void
*/
protected function assertDispatchedTimes($command, $times = 1)
{
PHPUnit::assertTrue(
($count = $this->dispatched($command)->count()) === $times,
"The expected [{$command}] job was pushed {$count} times instead of {$times} times."
);
}
/**
* Determine if a job was dispatched based on a truth-test callback.
*
* @param string $command
* @param callable|null $callback
* @return void
*/
public function assertNotDispatched($command, $callback = null)
{
PHPUnit::assertTrue(
后面还有 105 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
