/**
  * 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.");
 }
 /**
  * Assert that rma is correct display for guest on frontend (Orders and Returns):
  * - status on rma history page
  * - details and items on rma view page
  *
  * @param Rma $rma
  * @param SalesGuestView $salesGuestView
  * @param RmaGuestReturn $rmaGuestReturn
  * @param RmaGuestView $rmaGuestView
  * @return void
  */
 public function processAssert(Rma $rma, SalesGuestView $salesGuestView, RmaGuestReturn $rmaGuestReturn, RmaGuestView $rmaGuestView)
 {
     $this->rmaGuestReturn = $rmaGuestReturn;
     $this->rmaGuestView = $rmaGuestView;
     $this->order = $rma->getDataFieldConfig('order_id')['source']->getOrder();
     $this->customer = $this->order->getDataFieldConfig('customer_id')['source']->getCustomer();
     $this->objectManager->create('Mage\\Sales\\Test\\TestStep\\OpenSalesOrderOnFrontendForGuestStep', ['order' => $this->order])->run();
     $salesGuestView->getViewBlock()->openLinkByName('Returns');
     $this->assertRmaStatus($rma);
     $this->rmaGuestReturn->getReturnsBlock()->getItemRow($rma)->open();
     $this->assertRequestInformation($rma);
     $this->assertItemsData($rma);
 }
Example #4
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);
     }
 }
 /**
  * Assert that rma is correct display on frontend (MyAccount - My Returns):
  * - status on rma history page
  * - details and items on rma view page
  *
  * @param Rma $rma
  * @param CmsIndex $cmsIndex
  * @param CustomerAccountIndex $customerAccountIndex
  * @param RmaReturnHistory $rmaReturnHistory
  * @param RmaReturnView $rmaReturnView
  * @return void
  */
 public function processAssert(Rma $rma, CmsIndex $cmsIndex, CustomerAccountIndex $customerAccountIndex, RmaReturnHistory $rmaReturnHistory, RmaReturnView $rmaReturnView)
 {
     $this->rmaReturnHistory = $rmaReturnHistory;
     $this->rmaReturnView = $rmaReturnView;
     $this->order = $rma->getDataFieldConfig('order_id')['source']->getOrder();
     $this->customer = $this->order->getDataFieldConfig('customer_id')['source']->getCustomer();
     $this->productHandlerClass = $this->getProductHandlerClass();
     $this->login();
     $cmsIndex->getTopLinksBlock()->openAccountLink('My Account');
     $customerAccountIndex->getAccountNavigationBlock()->openNavigationItem('My Returns');
     $this->assertRmaStatus($rma);
     $rmaReturnHistory->getRmaHistory()->getItemRow($rma)->open();
     $this->assertRequestInformation($rma);
     $this->assertItemsData($rma);
 }
 /**
  * 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;
 }
 /**
  * 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]);
 }