private function setUpTestData() { // initialize order data $this->data = new OrderDataSetup($this->em, $this->getItemFactory(), $this->getContactRepository()); // load order-statuses $statusFixtures = new LoadShippingStatus(); $shippingStatuses = $statusFixtures->load($this->em); $this->statusCreated = $shippingStatuses[ShippingStatus::STATUS_CREATED]; $this->shippingAddress = clone $this->data->orderAddressDelivery; $this->shipping = new Shipping(); $this->shipping->setNumber('00001'); $this->shipping->setShippingNumber('432'); $this->shipping->setStatus($this->statusCreated); $this->shipping->setOrder($this->data->order); $this->shipping->setChanged(new DateTime()); $this->shipping->setCreated(new DateTime()); $this->shipping->setCommission('shipping-commission'); $this->shipping->setDeliveryAddress($this->shippingAddress); $this->shipping->setExpectedDeliveryDate(new DateTime('2015-01-01')); $this->shipping->setHeight(101); $this->shipping->setWidth(102); $this->shipping->setLength(103); $this->shipping->setWeight(10); $this->shipping->setNote('simple shipping note'); $this->shipping->setTermsOfDeliveryContent($this->data->termsOfDelivery->getTerms()); $this->shipping->setTermsOfPaymentContent($this->data->termsOfPayment->getTerms()); $this->shipping->setTrackingId('abcd1234'); $this->shipping->setTrackingUrl('http://www.tracking.url?token=abcd1234'); $this->shipping->setBitmaskStatus($this->statusCreated->getId()); $this->shipping->setInternalNote('Tiny internal note'); $this->shipping2 = clone $this->shipping; $this->shipping2->setNumber('00002'); $this->shipping2->setStatus($this->statusCreated); $this->shipping2->setBitmaskStatus($this->statusCreated->getId()); $this->shippingAddress2 = clone $this->shippingAddress; $this->shipping2->setDeliveryAddress($this->shippingAddress2); $this->shippingItem = new ShippingItem(); $this->shippingItem->setShipping($this->shipping); $this->shippingItem->setItem($this->data->item); $this->shippingItem->setQuantity(1); $this->shippingItem->setNote('shipping-item-note'); $this->shipping->addShippingItem($this->shippingItem); // persist $this->em->persist($this->shipping); $this->em->persist($this->shipping2); $this->em->persist($this->shippingItem); $this->em->persist($this->shippingAddress); $this->em->persist($this->shippingAddress2); }
/** * creates a ShippingItem Entity by a given (shipping-)data array * @param $data * @return ShippingItemEntity * @throws Exception\ShippingDependencyNotFoundException * @throws Exception\MissingShippingAttributeException */ private function createShippingItemEntity($data) { // check if necessary item data is set if (array_key_exists('item', $data) && array_key_exists('id', $data['item'])) { $itemId = $data['item']['id']; $item = $this->itemManager->findEntityById($itemId); if (!$item) { throw new ShippingDependencyNotFoundException('SuluSalesCoreBundle:Items', $itemId); } $shippingItem = new ShippingItemEntity(); $shippingItem->setItem($item); $this->em->persist($shippingItem); } else { throw new MissingShippingAttributeException('ShippingItems.item.id'); } return $shippingItem; }