/** * @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))); }
/** * @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())); }
/** * @param ProductId $productId * @return bool */ private function productNotInBasket(ProductId $productId) { return empty($this->products[$productId->toString()]); }
/** * @test */ public function itDoesNotRecordAnEventWhenRemovedProductWasNotInBasket() { $numberOfEvents = count($this->basket->recordedEvents()); $productId = ProductId::fromString('product-1'); $this->basket->removeProduct($productId); $this->assertCount($numberOfEvents, $this->basket->recordedEvents()); }
/** * @test */ public function itDoesNotEqualAnotherWithADifferentValue() { $other = ProductId::fromString('product-2'); $this->assertNotTrue($this->productId->equals($other)); }
/** * @test */ public function itDoesNotEqualAnotherWithADifferentClass() { $other = ProductId::fromString('basket-1'); $this->assertNotTrue($this->basketId->equals($other)); }