Skip to content
Snippets Groups Projects
Commit 87d9218c authored by Vasyl Kozyrenko's avatar Vasyl Kozyrenko
Browse files

MTA-3901: Add variation for Partial Refund an order placed through Braintree with Partial capture

parent df4fbec6
No related merge requests found
......@@ -54,6 +54,9 @@
</data>
<data name="order/data/price/refund" xsi:type="array">
<item name="0" xsi:type="array">
<item name="grand_creditmemo_total" xsi:type="string">621.20</item>
</item>
<item name="1" xsi:type="array">
<item name="grand_creditmemo_total" xsi:type="string">606.20</item>
</item>
</data>
......
......@@ -83,10 +83,10 @@
</data>
<data name="order/data/price/refund" xsi:type="array">
<item name="0" xsi:type="array">
<item name="grand_creditmemo_total" xsi:type="string">1.08</item>
<item name="grand_creditmemo_total" xsi:type="string">134.07</item>
</item>
<item name="1" xsi:type="array">
<item name="grand_creditmemo_total" xsi:type="string">134.07</item>
<item name="grand_creditmemo_total" xsi:type="string">1.08</item>
</item>
</data>
<data name="transactions/refund" xsi:type="array">
......
......@@ -111,7 +111,7 @@ class AbstractItems extends Block
* @param ElementInterface $item
* @return null|int
*/
private function getQty(ElementInterface $item)
protected function getQty(ElementInterface $item)
{
$qty = null;
$elements = $item->getElements($this->qty);
......@@ -127,7 +127,7 @@ class AbstractItems extends Block
* @param ElementInterface $item
* @return string
*/
private function getSku(ElementInterface $item)
protected function getSku(ElementInterface $item)
{
$itemContent = $item->find($this->sku)->getText();
$itemContent = preg_replace('/\n|\r/', '', $itemContent);
......
......@@ -9,13 +9,12 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\Shipment\View;
use Magento\Sales\Test\Block\Adminhtml\Order\AbstractItems;
/**
* Class Items
* Shipment Items block on Shipment view page
* Shipment Items block on Shipment view page.
*/
class Items extends AbstractItems
{
/**
* Get items data
* Get items data.
*
* @return array
*/
......@@ -27,8 +26,9 @@ class Items extends AbstractItems
foreach ($items as $item) {
$itemData = [];
$itemData += $this->parseProductName($item->find($this->product)->getText());
$itemData['qty'] = $item->find($this->qty)->getText();
$itemData['product'] = preg_replace('/\n|\r/', '', $item->find($this->title)->getText());
$itemData['sku'] = $this->getSku($item);
$itemData['qty'] = $this->getQty($item);
$data[] = $itemData;
}
......
......@@ -39,7 +39,7 @@ class AssertRefundInCommentsHistory extends AbstractConstraint
$salesOrder->open();
$salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
$refundedPrices = $order->getPrice()['refund'];
$actualRefundedAmount = $salesOrderView->getOrderHistoryBlock()->getRefundedAmount();
$actualRefundedAmount = array_reverse($salesOrderView->getOrderHistoryBlock()->getRefundedAmount());
foreach ($refundedPrices as $key => $refundedPrice) {
\PHPUnit_Framework_Assert::assertRegExp(
sprintf(self::REFUNDED_AMOUNT_PATTERN, $refundedPrice['grand_creditmemo_total']),
......
......@@ -8,7 +8,6 @@ namespace Magento\Sales\Test\TestStep;
use Magento\Customer\Test\Fixture\Address;
use Magento\Customer\Test\Fixture\Customer;
use Magento\Sales\Test\Fixture\OrderInjectable;
use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex;
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
use Magento\Mtf\Fixture\FixtureFactory;
......@@ -61,20 +60,12 @@ class SubmitOrderStep implements TestStepInterface
*/
private $products;
/**
* Fixture OrderInjectable.
*
* @var OrderInjectable
*/
private $order;
/**
* @param OrderCreateIndex $orderCreateIndex
* @param SalesOrderView $salesOrderView
* @param FixtureFactory $fixtureFactory
* @param Customer $customer
* @param \Magento\Mtf\Fixture\FixtureInterface[] $products
* @param OrderInjectable|null $order
* @param Address|null $billingAddress
*/
public function __construct(
......@@ -83,7 +74,6 @@ class SubmitOrderStep implements TestStepInterface
FixtureFactory $fixtureFactory,
Customer $customer,
array $products,
OrderInjectable $order = null,
Address $billingAddress = null
) {
$this->orderCreateIndex = $orderCreateIndex;
......@@ -91,8 +81,8 @@ class SubmitOrderStep implements TestStepInterface
$this->fixtureFactory = $fixtureFactory;
$this->customer = $customer;
$this->products = $products;
$this->order = $order;
$this->billingAddress = $billingAddress;
$this->products = $products;
}
/**
......@@ -105,16 +95,16 @@ class SubmitOrderStep implements TestStepInterface
$this->orderCreateIndex->getCreateBlock()->submitOrder();
$this->salesOrderView->getMessagesBlock()->waitSuccessMessage();
$orderId = trim($this->salesOrderView->getTitleBlock()->getTitle(), '#');
$data = [
'id' => $orderId,
'customer_id' => ['customer' => $this->customer],
'entity_id' => ['products' => $this->products],
'billing_address_id' => ['billingAddress' => $this->billingAddress],
];
$orderData = $this->order !== null ? $this->order->getData() : [];
$order = $this->fixtureFactory->createByCode(
'orderInjectable',
['data' => array_merge($data, $orderData)]
[
'data' => [
'id' => $orderId,
'customer_id' => ['customer' => $this->customer],
'entity_id' => ['products' => $this->products],
'billing_address_id' => ['billingAddress' => $this->billingAddress],
]
]
);
return ['orderId' => $orderId, 'order' => $order];
......
......@@ -74,7 +74,7 @@ class Form extends AbstractForm
}
if (isset($data['items_data']) && $products !== null) {
foreach ($products as $key => $product) {
$this->getItemsBlock()->getItemProductBlock($product)->fillProduct($data['items_data'][$key]);
$this->getItemsBlock()->getItemProductBlock($product->getSku())->fillProduct($data['items_data'][$key]);
}
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment