protected function publish() { foreach ($this->transactionMessages as $message) { $this->locator->getPublisherForMessage($message)->publish($message); } $this->transactionMessages = []; }
/** * {@inheritdoc} */ public function execute($command, callable $next) { if (!$command instanceof Message) { return $next($command); } return $this->locator->getPublisherForMessage($command)->publish($command); }
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(); } }
/** * @test */ public function it_should_continue_if_its_not_a_message() { $this->locator->shouldNotReceive('getPublisherForMessage'); $command = new \stdClass(); $this->execute($this->middleware, $command, $command); }