I have class which mostly to this
$newItem = new SeriesDiscountDecorator($item);
$cart->remove($item);
$cart->add($newItem);
And my spec looks like
$decoratedItem1->beConstructedWith([$item1]);
$cart->add($decoratedItem1)->shouldBeCalled();
But PHPSpec is saying that no right $cart->add call was made because of wrong parameter. In fact my $decoratedItem was not the same object that Cart class made. How to write spec like this right?
PHPSpec returns:
method call:
- add(Domain\Discount\Decorator\SeriesDiscountDecorator:000000006b0917e60000000063743658 Object (
'decoratedItem' => Double\ItemInterface\P66:000000006b0917a60000000063743658 Object (
'objectProphecy' => Prophecy\Prophecy\ObjectProphecy Object (*Prophecy*)
)
))
on Double\Domain\Cart\Cart\P65 was not expected, expected calls were:
- add(exact(Double\Domain\Discount\Decorator\SeriesDiscountDecorator\P69:000000006b0917f90000000063743658 Object (
'objectProphecy' => Prophecy\Prophecy\ObjectProphecy Object (*Prophecy*)
'decoratedItem' => PhpSpec\Wrapper\Collaborator:000000006b0917b30000000063743658 Object (
'prophecy' => Prophecy\Prophecy\ObjectProphecy Object (*Prophecy*)
)
)))