Beispiel #1
0
 public function setUp()
 {
     $basketId = BasketId::fromString('basket-1');
     $productId = ProductId::fromString('product-1');
     $this->basket = Basket::pickUp($basketId);
     $this->basket->addProduct($productId);
     $this->basket->removeProduct($productId);
 }
 /**
  * @test
  */
 public function itReconstitutesAnAggregateFromHistoryRetrievedFromTheEventStore()
 {
     $id = BasketId::fromString('some-basket');
     $eventStream = $this->testHelper->getEventStream($id);
     $aggregateHistory = $this->testHelper->getAggregateHistory($id);
     $aggregate = Basket::pickUp($id);
     $this->eventStore->expects($this->once())->method('read')->with($this->equalTo($id))->will($this->returnValue($eventStream));
     $this->eventWrapper->expects($this->once())->method('unwrap')->with($this->equalTo($eventStream))->will($this->returnValue($aggregateHistory));
     $this->aggregateFactory->expects($this->once())->method('reconstituteFromHistory')->with($this->equalTo($aggregateHistory))->will($this->returnValue($aggregate));
     $foundAggregate = $this->repository->get($id);
     $this->assertSame($aggregate, $foundAggregate);
 }