/** * @depends testCreate * * @param OrderModel $order */ public function testUpdateAddress(OrderModel $order) { $deliveryRef = uniqid('DELREF'); $orderAddress = OrderAddressQuery::create()->findPk($order->getDeliveryOrderAddressId()); $title = $orderAddress->getCustomerTitleId() == 3 ? 1 : 3; $country = $orderAddress->getCountryId() == 64 ? 1 : 64; $orderAddressEvent = new OrderAddressEvent($title, 'B', 'C', 'D', 'E', 'F', 'G', 'H', $country, 'J', 'K'); $orderAddressEvent->setOrderAddress($orderAddress); $orderAddressEvent->setOrder($order); $this->orderAction->updateAddress($orderAddressEvent); $newOrderAddress = OrderAddressQuery::create()->findPk($orderAddress->getId()); $this->assertEquals($title, $orderAddressEvent->getOrderAddress()->getCustomerTitleId()); $this->assertEquals('B', $orderAddressEvent->getOrderAddress()->getFirstname()); $this->assertEquals('C', $orderAddressEvent->getOrderAddress()->getLastname()); $this->assertEquals('D', $orderAddressEvent->getOrderAddress()->getAddress1()); $this->assertEquals('E', $orderAddressEvent->getOrderAddress()->getAddress2()); $this->assertEquals('F', $orderAddressEvent->getOrderAddress()->getAddress3()); $this->assertEquals('G', $orderAddressEvent->getOrderAddress()->getZipcode()); $this->assertEquals('H', $orderAddressEvent->getOrderAddress()->getCity()); $this->assertEquals($country, $orderAddressEvent->getOrderAddress()->getCountryId()); $this->assertEquals('J', $orderAddressEvent->getOrderAddress()->getPhone()); $this->assertEquals('K', $orderAddressEvent->getOrderAddress()->getCompany()); $this->assertEquals($title, $newOrderAddress->getCustomerTitleId()); $this->assertEquals('B', $newOrderAddress->getFirstname()); $this->assertEquals('C', $newOrderAddress->getLastname()); $this->assertEquals('D', $newOrderAddress->getAddress1()); $this->assertEquals('E', $newOrderAddress->getAddress2()); $this->assertEquals('F', $newOrderAddress->getAddress3()); $this->assertEquals('G', $newOrderAddress->getZipcode()); $this->assertEquals('H', $newOrderAddress->getCity()); $this->assertEquals($country, $newOrderAddress->getCountryId()); $this->assertEquals('J', $newOrderAddress->getPhone()); $this->assertEquals('K', $newOrderAddress->getCompany()); }
public function updateAddress($order_id) { if (null !== ($response = $this->checkAuth(AdminResources::ORDER, array(), AccessManager::UPDATE))) { return $response; } $message = null; $orderUpdateAddress = new OrderUpdateAddress($this->getRequest()); try { $order = OrderQuery::create()->findPk($order_id); if (null === $order) { throw new \InvalidArgumentException("The order you want to update does not exist"); } $form = $this->validateForm($orderUpdateAddress, "post"); $orderAddress = OrderAddressQuery::create()->findPk($form->get("id")->getData()); if ($orderAddress->getId() !== $order->getInvoiceOrderAddressId() && $orderAddress->getId() !== $order->getDeliveryOrderAddressId()) { throw new \InvalidArgumentException("The order address you want to update does not belong to the current order not exist"); } $event = new OrderAddressEvent($form->get("title")->getData(), $form->get("firstname")->getData(), $form->get("lastname")->getData(), $form->get("address1")->getData(), $form->get("address2")->getData(), $form->get("address3")->getData(), $form->get("zipcode")->getData(), $form->get("city")->getData(), $form->get("country")->getData(), $form->get("phone")->getData(), $form->get("company")->getData()); $event->setOrderAddress($orderAddress); $event->setOrder($order); $this->dispatch(TheliaEvents::ORDER_UPDATE_ADDRESS, $event); } catch (\Exception $e) { $message = $e->getMessage(); } $params = array(); if ($message) { $params["update_status_error_message"] = $message; } $params["tab"] = $this->getRequest()->get("tab", 'bill'); return $this->generateRedirectFromRoute("admin.order.update.view", $params, ['order_id' => $order_id]); }