bumbummen99 / LaravelShoppingcart

A simple shopping cart implementation for Laravel
MIT License
501 stars 228 forks source link

Add some unit tests #182

Closed Kwaadpepper closed 1 year ago

Kwaadpepper commented 1 year ago

Please find a weird issue on the last commit.

I found one thing that may be and issue

image

It is not very clear that in case a a integer discount, it would be applied on any item individually. Instead is applied on the item type price sum.

eg : real case, discount of 2$ on tshirt, 1 item that cost 15$ is 13$, a basker of 2 tshirt should be 2*(15-2) = 26$

ths code does discount of 2$ on tshirt, 1 item that cost 15$ is 13$, a basker of 2 tshirt should be 2*15 -2 = 26$

As you can see on the last commit

$this->assertEquals(new Money(2990, new Currency('USD')), $cartItem->discount()); it should be $this->assertEquals(new Money(2970, new Currency('USD')), $cartItem->discount());

And other results are obviously wrong.