beConstructedWith( $factory, $cloner, $shipmentCloner, $entityManager, $orderItemCloner, $itemFactory, $shipmentFactory ) ; } public function it_is_initializable(): void { $this->shouldHaveType(OrderManager::class); } public function it_generate_order_with_given_item( OrderInterface $order, OrderItemInterface $orderItem, VendorInterface $itemVendor, OrderInterface $newOrder, OrderFactoryInterface $factory, OrderItemFactoryInterface $itemFactory, ShipmentInterface $shipment, ShipmentInterface $newShipment, OrderItemInterface $newItem, ShipmentFactoryInterface $shipmentFactory, ShipmentClonerInterface $shipmentCloner ): void { $factory->createNew()->willReturn($newOrder); $itemFactory->createNew()->willReturn($newItem); $order->getShipmentByVendor($itemVendor)->willReturn($shipment); $shipmentFactory->createNew()->willReturn($newShipment); $newShipment->setOrder($newOrder)->shouldBeCalled(); $shipmentCloner->clone($shipment, $newShipment)->shouldBeCalled(); $newOrder->addShipment($newShipment)->shouldBeCalled(); $this->generateNewSecondaryOrder($order, $itemVendor, $orderItem)->shouldReturn($newOrder); $newOrder->addItem($newItem)->shouldHaveBeenCalledTimes(1); $newOrder->setVendor($itemVendor)->shouldHaveBeenCalledTimes(1); $newOrder->setPrimaryOrder($order)->shouldHaveBeenCalledTimes(1); $newOrder->setMode(OrderInterface::SECONDARY_ORDER_MODE)->shouldHaveBeenCalledTimes(1); } public function it_adds_item_into_order( OrderInterface $order, OrderInterface $order2, OrderItemInterface $orderItem, VendorInterface $itemVendor, OrderItemFactoryInterface $itemFactory, ShipmentInterface $shipment, OrderItemInterface $newItem, ): void { $orders = [$order, $order2]; $shipments = new ArrayCollection([$shipment->getWrappedObject()]); $itemFactory->createNew()->willReturn($newItem); $order->getVendor()->willReturn($itemVendor); $order->getShipments()->willReturn($shipments); $order->addItem($newItem)->shouldBeCalledOnce(); $this->addItemIntoSecondaryOrder($orders, $itemVendor, $orderItem); } }