/**
  * Get rma items.
  *
  * @param Rma $rma
  * @return array
  */
 protected function getRmaItems(Rma $rma)
 {
     $rmaItems = $rma->getItems();
     /** @var Order $order */
     $order = $rma->getDataFieldConfig('order_id')['source']->getOrder();
     $orderItems = $this->getAssignedProducts($order);
     foreach ($rmaItems as $productKey => $productData) {
         $key = str_replace('product_key_', '', $productKey);
         $product = $orderItems[$key];
         $productData['sku'] = $this->productHandlerClass->getProductSku($product);
         $productData['qty'] = $productData['qty_requested'];
         $productData['product_name'] = $product->getName();
         $productOptions = $this->productHandlerClass->getProductOptions($product);
         if ($productOptions != null) {
             $productData['options'] = $productOptions;
         }
         if (!isset($productData['status'])) {
             $productData['status'] = self::ITEM_DEFAULT_STATUS;
         }
         unset($productData['reason']);
         unset($productData['reason_other']);
         $rmaItems[$productKey] = $productData;
     }
     return $rmaItems;
 }
 /**
  * Assert that return request displayed in Returns grid:
  * - customer
  * - status (pending)
  * - orderID
  *
  * @param Rma $rma
  * @param RmaIndex $rmaIndex
  * @return void
  */
 public function processAssert(Rma $rma, RmaIndex $rmaIndex)
 {
     /** @var Order $order*/
     $order = $rma->getDataFieldConfig('order_id')['source']->getOrder();
     /** @var Customer $customer */
     $customer = $order->getDataFieldConfig('customer_id')['source']->getCustomer();
     $orderId = $rma->getOrderId();
     $filter = ['order_id_from' => $orderId, 'order_id_to' => $orderId, 'customer' => sprintf('%s %s', $customer->getFirstname(), $customer->getLastname()), 'status' => $rma->getStatus()];
     $rmaIndex->open();
     \PHPUnit_Framework_Assert::assertTrue($rmaIndex->getRmaGrid()->isRowVisible($filter), "Rma for order '{$orderId}' is absent in grid.");
 }
Example #3
0
 /**
  * Fill items data.
  *
  * @param Rma $rma
  * @return void
  */
 public function fill(Rma $rma)
 {
     $items = $rma->getItems();
     $products = $rma->getDataFieldConfig('items')['source']->getProducts();
     foreach ($items as $key => $item) {
         $item['order_item_id'] = $products[$key]->getName();
         ++$key;
         $itemBlock = $this->getItemForm($key);
         if (!$itemBlock->isVisible()) {
             $this->clickAddItemToReturn();
         }
         $itemBlock->fillItem($item);
     }
 }
Example #4
0
 /**
  * Get RMA item row.
  *
  * @param Rma $rma
  * @return Item
  */
 public function getItemRow(Rma $rma)
 {
     $selector = sprintf($this->rmaItemRow, $rma->getEntityId());
     return $this->blockFactory->create('Enterprise\\Rma\\Test\\Block\\Returns\\History\\Item', ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)]);
 }
 /**
  * Return rma data.
  *
  * @param Rma $rma
  * @return array
  */
 protected function getRmaData(Rma $rma)
 {
     /** @var Order $order */
     $order = $rma->getDataFieldConfig('order_id')['source']->getOrder();
     $orderItems = $order->getEntityId();
     /** @var Customer $customer */
     $customer = $order->getDataFieldConfig('customer_id')['source']->getCustomer();
     $data = $rma->getData();
     $data['customer_name'] = sprintf('%s %s', $customer->getFirstname(), $customer->getLastname());
     $data['customer_email'] = $customer->getEmail();
     foreach ($data['items'] as $key => $item) {
         $product = $orderItems['products'][$key];
         $item['product'] = $product->getName();
         $item['sku'] = $this->getItemSku($product);
         $data['items'][$key] = $item;
     }
     return $data;
 }
 /**
  * Assert RMA status on RMA guest return page.
  *
  * @param Rma $rma
  * @return void
  */
 protected function assertRmaStatus(Rma $rma)
 {
     \PHPUnit_Framework_Assert::assertEquals($rma->getStatus(), $this->rmaGuestReturn->getReturnsBlock()->getItemRow($rma));
 }
 /**
  * Update RMA fixture.
  *
  * @param Rma $rma
  * @param null|string $rmaId
  * @return Rma
  */
 protected function updateRmaFixture(Rma $rma, $rmaId = null)
 {
     $newData = $rma->getData();
     $newData['items'] = ['data' => $newData['items'], 'products' => $this->products];
     $newData['order_id'] = ['order' => $this->order];
     if ($rmaId !== null) {
         $newData['entity_id'] = $rmaId;
     }
     return $this->fixtureFactory->createByCode('rma', ['data' => $newData]);
 }
 /**
  * Create rma entity.
  *
  * @param Rma $rma
  * @param string $rmaId
  * @return Rma
  */
 protected function createRma(Rma $rma, $rmaId)
 {
     $order = $rma->getDataFieldConfig('order_id')['source']->getOrder();
     $rmaData = $rma->getData();
     $data = array_merge($rma->getData(), ['entity_id' => $rmaId, 'order_id' => ['order' => $order], 'items' => ['data' => $rmaData['items']]]);
     return $this->fixtureFactory->createByCode('rma', ['data' => $data]);
 }
 /**
  * Assert RMA status on history page.
  *
  * @param Rma $rma
  * @return void
  */
 protected function assertRmaStatus(Rma $rma)
 {
     \PHPUnit_Framework_Assert::assertEquals($rma->getStatus(), $this->rmaReturnHistory->getRmaHistory()->getItemRow($rma)->getData()['status']);
 }