コード例 #1
0
 /**
  * @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)));
 }
コード例 #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)));
 }
コード例 #3
0
 /**
  * @test
  */
 public function itExposesAProductId()
 {
     $productId = ProductId::fromString('product-1');
     $this->assertTrue($productId->equals($this->event->productId()));
 }
コード例 #4
0
ファイル: Basket.php プロジェクト: f500/event-sourcing
 /**
  * @param ProductId $productId
  * @return bool
  */
 private function productNotInBasket(ProductId $productId)
 {
     return empty($this->products[$productId->toString()]);
 }
コード例 #5
0
ファイル: BasketTest.php プロジェクト: f500/event-sourcing
 /**
  * @test
  */
 public function itDoesNotRecordAnEventWhenRemovedProductWasNotInBasket()
 {
     $numberOfEvents = count($this->basket->recordedEvents());
     $productId = ProductId::fromString('product-1');
     $this->basket->removeProduct($productId);
     $this->assertCount($numberOfEvents, $this->basket->recordedEvents());
 }
コード例 #6
0
ファイル: ProductIdTest.php プロジェクト: f500/event-sourcing
 /**
  * @test
  */
 public function itDoesNotEqualAnotherWithADifferentValue()
 {
     $other = ProductId::fromString('product-2');
     $this->assertNotTrue($this->productId->equals($other));
 }
コード例 #7
0
ファイル: BasketIdTest.php プロジェクト: f500/event-sourcing
 /**
  * @test
  */
 public function itDoesNotEqualAnotherWithADifferentClass()
 {
     $other = ProductId::fromString('basket-1');
     $this->assertNotTrue($this->basketId->equals($other));
 }