/**
  * @test
  * @dataProvider providePersistence
  * @param Persistence $persistence
  */
 public function retrieved_AggregateRoot_should_behave_the_same_as_the_original_AggregateRoot(Persistence $persistence)
 {
     $unitOfWork = $this->buildUnitOfWork($persistence);
     $repository = new OrderRepository($unitOfWork);
     $this->order->pay(50);
     $repository->add($this->order);
     $unitOfWork->commit();
     $retrievedOrder = $repository->get($this->orderId);
     $retrievedOrder->pay(50);
     $changes = $retrievedOrder->getChanges();
     $this->assertInstanceOf(OrderWasPaidInFull::class, $changes[1]);
 }
 /**
  * @test
  * @dataProvider providePersistence
  * @param Persistence $persistence
  */
 public function retrieved_order_should_behave_the_same_as_the_original_order(Persistence $persistence)
 {
     $unitOfWork = $this->buildUnitOfWork($persistence);
     $repository = new OrderRepository($unitOfWork);
     $orderId = OrderId::generate();
     $order = Order::orderProduct($orderId, ProductId::generate(), 100);
     $repository->add($order);
     $unitOfWork->commit();
     $retrievedOrder = $repository->get($orderId);
     /** @var $retrievedOrder Order */
     $retrievedOrder->pay(50);
     $retrievedOrder->pay(50);
     $changes = $retrievedOrder->getChanges();
     $this->assertCount(3, $changes);
     $this->assertInstanceOf(PaymentWasMade::class, $changes[0]);
     $this->assertInstanceOf(PaymentWasMade::class, $changes[1]);
     $this->assertInstanceOf(OrderWasPaidInFull::class, $changes[2]);
 }