Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertGiftMessageInBackendOrder.php
Go to the documentation of this file.
1 <?php
8 
11 use Magento\Mtf\Fixture\FixtureFactory;
12 use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
13 use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
14 
19 {
25  protected $skippedFields = [
26  'allow_gift_options_for_items',
27  'allow_gift_messages_for_order',
28  'allow_gift_options',
29  'items',
30  ];
31 
43  public function processAssert(
44  GiftMessage $giftMessage,
45  SalesOrderView $salesOrderView,
46  OrderIndex $orderIndex,
47  FixtureFactory $fixtureFactory,
48  array $products,
49  $orderId
50  ) {
51  $expectedData = [];
52  $actualData = [];
53  $orderIndex->open()->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
54 
55  if ($giftMessage->getAllowGiftMessagesForOrder() === 'Yes') {
56  $formData = [
57  'sender' => $giftMessage->getSender(),
58  'recipient' => $giftMessage->getRecipient(),
59  'message' => $giftMessage->getMessage()
60  ];
61  $giftMessageForm = $fixtureFactory->createByCode('giftMessage', ['data' => $formData]);
62 
63  $expectedData[] = $giftMessageForm->getData();
64  $actualData[] = $salesOrderView->getGiftOptionsBlock()->getData($giftMessageForm);
65  }
66 
67  if ($giftMessage->getAllowGiftOptionsForItems() === 'Yes') {
68  foreach ($giftMessage->getItems() as $key => $giftMessageItem) {
69  $expectedData[] = $giftMessageItem->getData();
70  $product = $products[$key];
71  $actualData[] = $salesOrderView->getGiftItemsBlock()->getItemProduct($product)
72  ->getGiftMessageFormData($giftMessage);
73  }
74  }
75 
76  $errors = $this->verifyData($expectedData, $actualData);
77  \PHPUnit\Framework\Assert::assertEmpty($errors, $errors);
78  }
79 
85  public function toString()
86  {
87  return 'Backend gift message form data is equal to data passed from dataset.';
88  }
89 }
$giftMessage
Definition: items.phtml:47
processAssert(GiftMessage $giftMessage, SalesOrderView $salesOrderView, OrderIndex $orderIndex, FixtureFactory $fixtureFactory, array $products, $orderId)
verifyData(array $fixtureData, array $formData, $isStrict=false, $isPrepareError=true)
$errors
Definition: overview.phtml:9