Laravel\Lumen\Testing\TestCase::expectsEvents PHP Method

expectsEvents() public method

These events will be mocked, so that handlers will not actually be executed.
public expectsEvents ( array | string $events )
$events array | string
    public function expectsEvents($events)
    {
        $events = is_array($events) ? $events : func_get_args();
        $mock = Mockery::spy('Illuminate\\Contracts\\Events\\Dispatcher');
        $mock->shouldReceive('fire')->andReturnUsing(function ($called) use(&$events) {
            foreach ($events as $key => $event) {
                if (is_string($called) && $called === $event || is_string($called) && is_subclass_of($called, $event) || is_object($called) && $called instanceof $event) {
                    unset($events[$key]);
                }
            }
        });
        $this->beforeApplicationDestroyed(function () use(&$events) {
            if ($events) {
                throw new Exception('The following events were not fired: [' . implode(', ', $events) . ']');
            }
        });
        $this->app->instance('events', $mock);
        return $this;
    }