/**
  * @test
  */
 public function it_should_publish_a_message()
 {
     $message = Mockery::mock(Message::class);
     $publisher = Mockery::mock(Publisher::class);
     $publisher->shouldReceive('publish')->once()->with($message)->andReturn('rpc');
     $this->locator->shouldReceive('getPublisherForMessage')->atLeast()->once()->with($message)->andReturn($publisher);
     $this->assertEquals('rpc', $this->middleware->execute($message, function () {
         throw new \LogicException('Middleware fell through to next callable, this should not happen in the test.');
     }));
 }
 private function mockMessagePublish(array $messages)
 {
     foreach ($messages as $message) {
         $publisher = Mockery::mock(Publisher::class);
         $publisher->shouldReceive('publish')->with($message)->once();
         $this->locator->shouldReceive('getPublisherForMessage')->with($message)->andReturn($publisher)->once();
     }
 }