コード例 #1
0
 /**
  * Change created order status and unassign custom order status if order was created.
  *
  * @return void
  */
 public function tearDown()
 {
     if ($this->order->hasData('id')) {
         $this->orderIndex->open()->getSalesOrderGrid()->massaction([['id' => $this->order->getId()]], 'Cancel');
         $filter = ['label' => $this->orderStatus->getLabel(), 'status' => $this->orderStatusInitial->getStatus()];
         $this->orderStatusIndex->open()->getOrderStatusGrid()->searchAndUnassign($filter);
     }
 }
コード例 #2
0
 /**
  * Assert that order is present in Orders grid on frontend.
  *
  * @param OrderInjectable $order
  * @param Customer $customer
  * @param ObjectManager $objectManager
  * @param CustomerAccountIndex $customerAccountIndex
  * @param OrderHistory $orderHistory
  * @param string $status
  * @param string $orderId
  * @param string|null $statusToCheck
  * @return void
  */
 public function processAssert(OrderInjectable $order, Customer $customer, ObjectManager $objectManager, CustomerAccountIndex $customerAccountIndex, OrderHistory $orderHistory, $status, $orderId = '', $statusToCheck = null)
 {
     $filter = ['id' => $order->hasData('id') ? $order->getId() : $orderId, 'status' => $statusToCheck === null ? $status : $statusToCheck];
     $objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders');
     $errorMessage = implode(', ', $filter);
     \PHPUnit_Framework_Assert::assertTrue($orderHistory->getOrderHistoryBlock()->isOrderVisible($filter), 'Order with following data \'' . $errorMessage . '\' is absent in Orders block on frontend.');
 }
コード例 #3
0
 /**
  * Change created order status and unassign custom order status if order was created.
  *
  * @return void
  */
 public function tearDown()
 {
     if ($this->order->hasData('id')) {
         $this->orderIndex->open()->getSalesOrderGrid()->massaction([['id' => $this->order->getId()]], 'Cancel');
         $filter = ['label' => $this->orderStatus->getLabel(), 'status' => $this->orderStatusInitial->getStatus()];
         $this->orderStatusIndex->open()->getOrderStatusGrid()->searchAndUnassign($filter);
         $this->objectManager->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => 'checkmo_custom_new_order_status_rollback'])->run();
     }
 }
コード例 #4
0
 /**
  * Process assert
  *
  * @param OrderInjectable $order
  * @param OrderIndex $orderIndex
  * @param string $status
  * @param string $orderId [optional]
  * @return void
  */
 protected function assert(OrderInjectable $order, OrderIndex $orderIndex, $status, $orderId = '')
 {
     $filter = ['id' => $order->hasData('id') ? $order->getId() : $orderId, 'status' => $status];
     $errorMessage = implode(', ', $filter);
     \PHPUnit_Framework_Assert::assertTrue($orderIndex->getSalesOrderGrid()->isRowVisible($filter), 'Order with following data \'' . $errorMessage . '\' is absent in Orders grid.');
 }
コード例 #5
0
 /**
  * Set shipping information to quote
  *
  * @param OrderInjectable $order
  * @throws \Exception
  */
 protected function setShippingInformation(OrderInjectable $order)
 {
     if (!$order->hasData('shipping_method')) {
         return;
     }
     $url = $this->url . '/shipping-information';
     list($carrier, $method) = explode('_', $order->getShippingMethod());
     $address = $order->hasData('shipping_address_id') ? $order->getShippingAddressId() : $order->getBillingAddressId();
     unset($address['default_billing']);
     unset($address['default_shipping']);
     foreach (array_keys($this->mappingData) as $key) {
         if (isset($address[$key])) {
             $address[$key] = $this->mappingData[$key][$address[$key]];
         }
     }
     $data = ['addressInformation' => ['shippingAddress' => $address, 'shippingMethodCode' => $method, 'shippingCarrierCode' => $carrier]];
     $this->webapiTransport->write($url, $data, WebapiDecorator::POST);
     $response = json_decode($this->webapiTransport->read(), true);
     $this->webapiTransport->close();
     if (!isset($response['payment_methods'], $response['totals'])) {
         $this->eventManager->dispatchEvent(['webapi_failed'], [$response]);
         throw new \Exception('Could not set shipping method to quote!');
     }
 }
コード例 #6
0
ファイル: Webapi.php プロジェクト: whoople/magento2-testing
 /**
  * Set shipping method to quote.
  *
  * @param OrderInjectable $order
  * @return void
  * @throws \Exception
  */
 protected function setShippingMethod(OrderInjectable $order)
 {
     if (!$order->hasData('shipping_method')) {
         return;
     }
     $url = $this->url . '/selected-shipping-method';
     list($carrier, $method) = explode('_', $order->getShippingMethod());
     $data = ["carrierCode" => $carrier, "methodCode" => $method];
     $this->webapiTransport->write($url, $data, WebapiDecorator::PUT);
     $response = json_decode($this->webapiTransport->read(), true);
     $this->webapiTransport->close();
     if ($response !== true) {
         $this->eventManager->dispatchEvent(['webapi_failed'], [$response]);
         throw new \Exception('Could not set shipping method to quote!');
     }
 }