/** * @test */ public function it_should_rollback_if_consumer_throws_exception() { $this->setExpectedException(\Exception::class); $this->transactionManager->shouldReceive('beginTransaction'); $this->transactionManager->shouldReceive('commit')->never(); $this->transactionManager->shouldReceive('rollback'); $this->consumer->shouldReceive('consume')->andThrow(\Exception::class); $consumer = new TransactionalConsumer($this->consumer, $this->transactionManager); $consumer->consume('test'); }