/**
  * @test
  */
 public function itResolvesEventNames()
 {
     $basketId = BasketId::fromString('some-basket');
     $productId = ProductId::fromString('some-product');
     $this->assertSame('basket_was_picked_up', $this->eventNameResolver->resolveEventName(new BasketWasPickedUp($basketId)));
     $this->assertSame('product_was_added_to_basket', $this->eventNameResolver->resolveEventName(new ProductWasAddedToBasket($basketId, $productId)));
     $this->assertSame('product_was_removed_from_basket', $this->eventNameResolver->resolveEventName(new ProductWasRemovedFromBasket($basketId, $productId)));
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function itResolvesEventNames()
 {
     $basketId = BasketId::fromString('some-basket');
     $productId = ProductId::fromString('some-product');
     $this->assertSame('SimpleES\\EventSourcing\\Example\\Basket\\Events\\BasketWasPickedUp', $this->eventNameResolver->resolveEventName(new BasketWasPickedUp($basketId)));
     $this->assertSame('SimpleES\\EventSourcing\\Example\\Basket\\Events\\ProductWasAddedToBasket', $this->eventNameResolver->resolveEventName(new ProductWasAddedToBasket($basketId, $productId)));
     $this->assertSame('SimpleES\\EventSourcing\\Example\\Basket\\Events\\ProductWasRemovedFromBasket', $this->eventNameResolver->resolveEventName(new ProductWasRemovedFromBasket($basketId, $productId)));
 }
 /**
  * @test
  */
 public function itExposesAProductId()
 {
     $productId = ProductId::fromString('product-1');
     $this->assertTrue($productId->equals($this->event->productId()));
 }
Ejemplo n.º 4
0
 /**
  * @param ProductId $productId
  * @return bool
  */
 private function productNotInBasket(ProductId $productId)
 {
     return empty($this->products[$productId->toString()]);
 }
Ejemplo n.º 5
0
 /**
  * @test
  */
 public function itDoesNotRecordAnEventWhenRemovedProductWasNotInBasket()
 {
     $numberOfEvents = count($this->basket->recordedEvents());
     $productId = ProductId::fromString('product-1');
     $this->basket->removeProduct($productId);
     $this->assertCount($numberOfEvents, $this->basket->recordedEvents());
 }
Ejemplo n.º 6
0
 /**
  * @test
  */
 public function itDoesNotEqualAnotherWithADifferentValue()
 {
     $other = ProductId::fromString('product-2');
     $this->assertNotTrue($this->productId->equals($other));
 }
Ejemplo n.º 7
0
 /**
  * @test
  */
 public function itDoesNotEqualAnotherWithADifferentClass()
 {
     $other = ProductId::fromString('basket-1');
     $this->assertNotTrue($this->basketId->equals($other));
 }