/**
* @test
*/
public function it_sends_remove_file_command_to_file_remover_via_php_resque()
{
$this->assertTrue(file_exists($this->testFile));
$commandBus = new CommandBus();
$commandRouter = new CommandRouter();
$messageDispatcher = new MessageDispatcher(['track_job_status' => true, 'queue' => 'php-resque-test-queue']);
$commandRouter->route('Prooph\\ServiceBusTest\\Mock\\RemoveFileCommand')->to($messageDispatcher);
$commandBus->utilize($commandRouter);
$commandBus->utilize(new ForwardToRemoteMessageDispatcherStrategy(new ProophDomainMessageToRemoteMessageTranslator()));
$jobId = null;
$messageDispatcher->events()->attach('dispatch.post', function (EventInterface $e) use(&$jobId) {
$jobId = $e->getParam('jobId');
});
$removeFile = RemoveFileCommand::fromPayload($this->testFile);
$commandBus->dispatch($removeFile);
$this->assertNotNull($jobId);
$status = new \Resque_Job_Status($jobId);
$this->assertEquals(\Resque_Job_Status::STATUS_WAITING, $status->get());
$worker = new \Resque_Worker(array('php-resque-test-queue'));
$worker->logLevel = 1;
$worker->work(0);
$worker->shutdown();
$this->assertEquals(\Resque_Job_Status::STATUS_COMPLETE, $status->get());
$this->assertFalse(file_exists($this->testFile));
}