public function testFire() { $job = new Job(); $job->state = JobState::SCHEDULED; $job->run_at = Carbon::now()->subMinute(); $job->task = 'sometask'; $job->save(); $impersonator = new Impersonator(); $impersonator->mock(JobSchedulerInterface::class, function (MockInterface $mock) use($job) { $mock->shouldReceive('findReady')->atLeast()->once()->andReturn(new Collection([$job])); }); $impersonator->mock(Repository::class, function (MockInterface $mock) { $mock->shouldReceive('get')->with('jobs.queue.connection')->andReturnNull()->once(); $mock->shouldReceive('get')->with('jobs.queue.id')->andReturnNull()->once(); }); $impersonator->mock(QueuePusherInterface::class, function (MockInterface $mock) { $mock->shouldReceive('push')->atLeast()->once()->with(m::type('string'), m::type('array'), null, null); }); /** @var EnqueueScheduledCommand $command */ $command = $impersonator->make(EnqueueScheduledCommand::class); $input = new StringInput('--take=25'); $output = new NullOutput(); $command->setLaravel($this->app); $command->run($input, $output); $this->assertEquals(JobState::QUEUED, $job->fresh()->state); }