Example #1
10
 /**
  * Fill gift message form on order level
  *
  * @param GiftMessage $giftMessage
  * @return void
  */
 public function fillGiftMessageOrder(GiftMessage $giftMessage)
 {
     /** @var \Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm $giftMessageForm */
     if ($giftMessage->getAllowGiftMessagesForOrder() === 'Yes') {
         $this->_rootElement->find($this->allowGiftOptions)->click();
         $giftMessageForm = $this->blockFactory->create('Magento\\GiftMessage\\Test\\Block\\Cart\\GiftOptions\\GiftMessageForm', ['element' => $this->_rootElement->find($this->giftMessageOrderForm)]);
         $formData = ['sender' => $giftMessage->getSender(), 'recipient' => $giftMessage->getRecipient(), 'message' => $giftMessage->getMessage()];
         $formData = $this->fixtureFactory->createByCode('giftMessage', ['data' => $formData]);
         $giftMessageForm->fill($formData);
         $this->_rootElement->find($this->giftMessageOrderButton)->click();
         $this->waitForElementVisible($this->giftMessageSummary);
     }
 }
 /**
  * Assert that message from dataSet is displayed for each items on order(s) view page on frontend
  *
  * @param GiftMessage $giftMessage
  * @param Customer $customer
  * @param OrderHistory $orderHistory
  * @param CustomerOrderView $customerOrderView
  * @param CustomerAccountLogout $customerAccountLogout
  * @param string $orderId
  * @param array $products
  * @return void
  */
 public function processAssert(GiftMessage $giftMessage, Customer $customer, OrderHistory $orderHistory, CustomerOrderView $customerOrderView, CustomerAccountLogout $customerAccountLogout, $orderId, $products = [])
 {
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $expectedData = ['sender' => $giftMessage->getSender(), 'recipient' => $giftMessage->getRecipient(), 'message' => $giftMessage->getMessage()];
     $orderHistory->open();
     $orderHistory->getOrderHistoryBlock()->openOrderById($orderId);
     foreach ($products as $key => $product) {
         if ($giftMessage->hasData('items')) {
             $itemGiftMessage = $giftMessage->getItems()[$key];
             $expectedData = ['sender' => $itemGiftMessage->getSender(), 'recipient' => $itemGiftMessage->getRecipient(), 'message' => $itemGiftMessage->getMessage()];
         }
         \PHPUnit_Framework_Assert::assertEquals($expectedData, $customerOrderView->getGiftMessageForItemBlock()->getGiftMessage($product->getName()), 'Wrong gift message is displayed on "' . $product->getName() . '" item.');
     }
     $customerAccountLogout->open();
 }
 /**
  * Assert that message from dataset is displayed on order(s) view page on backend.
  *
  * @param GiftMessage $giftMessage
  * @param SalesOrderView $salesOrderView
  * @param OrderIndex $orderIndex
  * @param FixtureFactory $fixtureFactory
  * @param array $products
  * @param string $orderId
  * @return void
  */
 public function processAssert(GiftMessage $giftMessage, SalesOrderView $salesOrderView, OrderIndex $orderIndex, FixtureFactory $fixtureFactory, array $products, $orderId)
 {
     $expectedData = [];
     $actualData = [];
     $orderIndex->open()->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
     if ($giftMessage->getAllowGiftMessagesForOrder() === 'Yes') {
         $formData = ['sender' => $giftMessage->getSender(), 'recipient' => $giftMessage->getRecipient(), 'message' => $giftMessage->getMessage()];
         $giftMessageForm = $fixtureFactory->createByCode('giftMessage', ['data' => $formData]);
         $expectedData[] = $giftMessageForm->getData();
         $actualData[] = $salesOrderView->getGiftOptionsBlock()->getData($giftMessageForm);
     }
     if ($giftMessage->getAllowGiftOptionsForItems() === 'Yes') {
         foreach ($giftMessage->getItems() as $key => $giftMessageItem) {
             $expectedData[] = $giftMessageItem->getData();
             $product = $products[$key];
             $actualData[] = $salesOrderView->getGiftItemsBlock()->getItemProduct($product)->getGiftMessageFormData($giftMessage);
         }
     }
     $errors = $this->verifyData($expectedData, $actualData);
     \PHPUnit_Framework_Assert::assertEmpty($errors, $errors);
 }
 /**
  * Assert that message from dataset is displayed on order(s) view page on frontend.
  *
  * @param GiftMessage $giftMessage
  * @param Customer $customer
  * @param OrderHistory $orderHistory
  * @param CustomerOrderView $customerOrderView
  * @param CustomerAccountLogout $customerAccountLogout
  * @param string $orderId
  * @return void
  */
 public function processAssert(GiftMessage $giftMessage, Customer $customer, OrderHistory $orderHistory, CustomerOrderView $customerOrderView, CustomerAccountLogout $customerAccountLogout, $orderId)
 {
     $this->objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $expectedData = ['sender' => $giftMessage->getSender(), 'recipient' => $giftMessage->getRecipient(), 'message' => $giftMessage->getMessage()];
     $orderHistory->open();
     $orderHistory->getOrderHistoryBlock()->openOrderById($orderId);
     \PHPUnit_Framework_Assert::assertEquals($expectedData, $customerOrderView->getGiftMessageForOrderBlock()->getGiftMessage(), 'Wrong gift message is displayed on order.');
     $customerAccountLogout->open();
 }
 /**
  * Add gift message to backend order.
  *
  * @return array
  */
 public function run()
 {
     if ($this->giftMessage->getAllowGiftMessagesForOrder()) {
         $this->orderCreateIndex->getGiftMessageForOrderBlock()->fill($this->giftMessage);
     }
     if ($this->giftMessage->getAllowGiftOptionsForItems()) {
         $this->orderCreateIndex->getCreateGiftMessageBlock()->fillGiftMessageForItems($this->products, $this->giftMessage);
     }
     return ['giftMessage' => $this->giftMessage];
 }
Example #6
0
 /**
  * Fill order items gift messages.
  *
  * @param array $products
  * @param GiftMessage $giftMessage
  */
 public function fillGiftMessageForItems(array $products, GiftMessage $giftMessage)
 {
     // Click on rootElement to solve overlapping inner elements by header menu.
     $this->_rootElement->click();
     /** @var \Magento\GiftMessage\Test\Block\Adminhtml\Order\Create\Items $items */
     $items = $this->blockFactory->create('Magento\\GiftMessage\\Test\\Block\\Adminhtml\\Order\\Create\\Items', ['element' => $this->_rootElement->find($this->itemsBlock)]);
     foreach ($giftMessage->getItems() as $key => $giftMessageItem) {
         $product = $products[$key];
         $items->getItemProduct($product)->fillGiftMessageForm($giftMessageItem);
     }
 }
Example #7
0
 /**
  * Fill gift message form on order level
  *
  * @param GiftMessage $giftMessage
  * @return void
  */
 public function fillGiftMessageOrder(GiftMessage $giftMessage)
 {
     /** @var \Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm $giftMessageForm */
     if ($giftMessage->getAllowGiftMessagesForOrder() === 'Yes') {
         $this->_rootElement->find($this->allowGiftOptions)->click();
         $giftMessageForm = $this->blockFactory->create('Magento\\GiftMessage\\Test\\Block\\Cart\\GiftOptions\\GiftMessageForm', ['element' => $this->_rootElement->find($this->giftMessageOrderForm)]);
         $giftMessageForm->fill($giftMessage);
         $this->_rootElement->find($this->giftMessageOrderButton)->click();
         $this->waitForElementVisible($this->giftMessageSummary);
     }
 }
 /**
  * Add gift message to backend order.
  *
  * @return array
  */
 public function run()
 {
     if ($this->giftMessage->getAllowGiftMessagesForOrder() === 'Yes') {
         $giftMessageForOrderBlock = $this->orderCreateIndex->getGiftMessageForOrderBlock();
         $giftMessageForOrderBlock->fill($this->giftMessage);
         $giftMessageForOrderBlock->waitForElementNotVisible('.loading-mask');
     }
     if ($this->giftMessage->getAllowGiftOptionsForItems() === 'Yes') {
         $giftMessageBlock = $this->orderCreateIndex->getCreateGiftMessageBlock();
         $giftMessageBlock->fillGiftMessageForItems($this->products, $this->giftMessage);
         $giftMessageBlock->waitForElementNotVisible('.loading-mask');
     }
     return ['giftMessage' => $this->giftMessage];
 }
Example #9
0
 /**
  * Fill gift message form on item level
  *
  * @param GiftMessage $giftMessage
  * @param array $products
  * @return void
  */
 public function fillGiftMessageItem(GiftMessage $giftMessage, $products = [])
 {
     /** @var \Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm $giftMessageForm */
     if ($giftMessage->getAllowGiftOptionsForItems() === 'Yes') {
         foreach ($products as $product) {
             if ($product->getIsVirtual() !== 'Yes') {
                 $this->_rootElement->find(sprintf($this->allowGiftOptions, $product->getName()), Locator::SELECTOR_XPATH)->click();
                 $giftMessageForm = $this->blockFactory->create('Magento\\GiftMessage\\Test\\Block\\Cart\\GiftOptions\\GiftMessageForm', ['element' => $this->_rootElement->find(sprintf($this->giftMessageItemForm, $product->getName()), Locator::SELECTOR_XPATH)]);
                 $giftMessageForm->fill($giftMessage);
                 $this->_rootElement->find($this->giftMessageItemButton)->click();
                 $this->waitForElementVisible(sprintf($this->giftMessageSummary, $product->getName()), Locator::SELECTOR_XPATH);
             }
         }
     }
 }
 /**
  * Assert that message from dataSet is displayed on order(s) view page on backend.
  *
  * @param GiftMessage $giftMessage
  * @param SalesOrderView $salesOrderView
  * @param OrderIndex $orderIndex
  * @param array $products
  * @param string $orderId
  * @return void
  */
 public function processAssert(GiftMessage $giftMessage, SalesOrderView $salesOrderView, OrderIndex $orderIndex, array $products, $orderId)
 {
     $orderIndex->open()->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
     if ($giftMessage->getAllowGiftMessagesForOrder()) {
         $expectedData[] = $giftMessage->getData();
         $actualData[] = $salesOrderView->getGiftOptionsBlock()->getData($giftMessage);
     }
     if ($giftMessage->getAllowGiftOptionsForItems()) {
         foreach ($products as $key => $product) {
             $expectedData[] = $giftMessage->getItems()[$key]->getData();
             $actualData[] = $salesOrderView->getGiftItemsBlock()->getItemProduct($product)->getGiftMessageFormData($giftMessage);
         }
     }
     $errors = $this->verifyData($expectedData, $actualData);
     \PHPUnit_Framework_Assert::assertEmpty($errors, $errors);
 }
 /**
  * Fill gift message form on item level
  *
  * @param GiftMessage $giftMessage
  * @param array $products
  * @return void
  */
 public function fillGiftMessageItem(GiftMessage $giftMessage, $products = [])
 {
     /** @var \Magento\GiftMessage\Test\Block\Cart\GiftOptions\GiftMessageForm $giftMessageForm */
     if ($giftMessage->getAllowGiftOptionsForItems() === 'Yes') {
         foreach ($products as $product) {
             if ($product->getProductHasWeight() == 'Yes') {
                 $this->_rootElement->find(sprintf($this->allowGiftOptions, $product->getName()), Locator::SELECTOR_XPATH)->click();
                 $giftMessageForm = $this->blockFactory->create('Magento\\GiftMessage\\Test\\Block\\Cart\\GiftOptions\\GiftMessageForm', ['element' => $this->_rootElement->find($this->giftMessageItemForm)]);
                 $giftMessage = $giftMessage->getItems()[0];
                 $formData = ['sender' => $giftMessage->getSender(), 'recipient' => $giftMessage->getRecipient(), 'message' => $giftMessage->getMessage()];
                 $formData = $this->fixtureFactory->createByCode('giftMessage', ['data' => $formData]);
                 $giftMessageForm->fill($formData);
                 $this->_rootElement->find($this->giftMessageItemButton)->click();
                 $this->waitForElementVisible(sprintf($this->giftMessageSummary, $product->getName()), Locator::SELECTOR_XPATH);
             }
         }
     }
 }