public static function registerBusDispatcher(ContainerInterface $container)
 {
     $bus = new QueueingDispatcher($container, function ($connection = null) use($container) {
         return $container->get(FactoryContract::class)->connection($connection);
     });
     $bus->setContainer($container);
     return $bus;
 }
 public function testCallWithInteractsWithQueue()
 {
     $command = serialize(new InteractsWithQueue());
     $job = $this->mock(JobContract::class);
     $job->shouldReceive('isDeletedOrReleased')->once()->andReturn(false);
     $job->shouldReceive('delete')->once();
     $encrypter = $this->mock(EncrypterContract::class);
     $encrypter->shouldReceive('decrypt')->once()->with($command)->andReturn($command);
     $container = new ArrayContainer();
     $handler = $this->mock(stdClass::class);
     $handler->shouldReceive('handle')->once()->andReturn('foo');
     $container->set('stdClass', $handler);
     $dispatcher = new QueueingDispatcher($container);
     $dispatcher->mapUsing(function () {
         return 'stdClass@handle';
     });
     $callHandler = new CallQueuedHandler($dispatcher, $encrypter);
     $callHandler->call($job, ['command' => $command]);
 }