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());
Please find a weird issue on the last commit.
I found one thing that may be and issue
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.