Skip to content
Snippets Groups Projects
Commit 619209f9 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

parents 032ab4ea 87d9218c
Branches
No related merge requests found
Showing
with 243 additions and 93 deletions
...@@ -144,13 +144,4 @@ ...@@ -144,13 +144,4 @@
<field name="id" xsi:type="number">1</field> <field name="id" xsi:type="number">1</field>
</dataset> </dataset>
</repository> </repository>
<repository class="Magento\Braintree\Test\Repository\BraintreeSandboxCustomer">
<dataset name="braintree_sandbox_default">
<field name="environment" xsi:type="string">BRAINTREEE_ENVIRONMENT</field>
<field name="merchantId" xsi:type="string">BRAINTREEE_MERCHANT_ID</field>
<field name="publicKey" xsi:type="string">BRAINTREE_PUBLIC_KEY</field>
<field name="privateKey" xsi:type="string">BRAINTREE_PRIVATE_KEY</field>
</dataset>
</repository>
</config> </config>
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
<repository class="Magento\Braintree\Test\Repository\BraintreeSandboxCustomer">
<dataset name="braintree_sandbox_default">
<field name="environment" xsi:type="string">BRAINTREEE_ENVIRONMENT</field>
<field name="merchantId" xsi:type="string">BRAINTREEE_MERCHANT_ID</field>
<field name="publicKey" xsi:type="string">BRAINTREE_PUBLIC_KEY</field>
<field name="privateKey" xsi:type="string">BRAINTREE_PRIVATE_KEY</field>
</dataset>
</repository>
</config>
...@@ -11,10 +11,17 @@ ...@@ -11,10 +11,17 @@
<data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data>
<data name="products/1" xsi:type="string">bundleProduct::bundle_fixed_100_dollar_product</data> <data name="products/1" xsi:type="string">bundleProduct::bundle_fixed_100_dollar_product</data>
<data name="customer/dataset" xsi:type="string">default</data> <data name="customer/dataset" xsi:type="string">default</data>
<data name="checkoutMethod" xsi:type="string">login</data> <data name="checkoutMethod" xsi:type="string">guest</data>
<data name="taxRule" xsi:type="string">us_ca_ny_rule</data> <data name="taxRule" xsi:type="string">us_ca_ny_rule</data>
<data name="refundedPrices" xsi:type="array"> <data name="order/data/refund" xsi:type="array">
<item name="0" xsi:type="string">139.90</item> <item name="0" xsi:type="array">
<item name="invoiceId" xsi:type="string">0</item>
</item>
</data>
<data name="order/data/price/refund" xsi:type="array">
<item name="0" xsi:type="array">
<item name="grand_creditmemo_total" xsi:type="string">139.90</item>
</item>
</data> </data>
<data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
...@@ -22,7 +29,6 @@ ...@@ -22,7 +29,6 @@
<data name="payment/method" xsi:type="string">braintree_paypal</data> <data name="payment/method" xsi:type="string">braintree_paypal</data>
<data name="configData" xsi:type="string">braintree, braintree_paypal, braintree_paypal_sale, braintree_paypal_skip_order_review</data> <data name="configData" xsi:type="string">braintree, braintree_paypal, braintree_paypal_sale, braintree_paypal_skip_order_review</data>
<data name="paymentAction" xsi:type="string">sale</data> <data name="paymentAction" xsi:type="string">sale</data>
<data name="data/items_data/0/qty" xsi:type="string">-</data>
<data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data> <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data>
<constraint name="Magento\Sales\Test\Constraint\AssertRefundSuccessCreateMessage" /> <constraint name="Magento\Sales\Test\Constraint\AssertRefundSuccessCreateMessage" />
<constraint name="Magento\Sales\Test\Constraint\AssertRefundInCreditMemoTab" /> <constraint name="Magento\Sales\Test\Constraint\AssertRefundInCreditMemoTab" />
...@@ -31,10 +37,28 @@ ...@@ -31,10 +37,28 @@
<variation name="CreateOnlineCreditMemoBraintreePaypalTestVariation2" summary="Partial refund of order placed within Braintree PayPal" ticketId="MAGETWO-48698"> <variation name="CreateOnlineCreditMemoBraintreePaypalTestVariation2" summary="Partial refund of order placed within Braintree PayPal" ticketId="MAGETWO-48698">
<data name="products/0" xsi:type="string">catalogProductSimple::simple_for_sales</data> <data name="products/0" xsi:type="string">catalogProductSimple::simple_for_sales</data>
<data name="customer/dataset" xsi:type="string">default</data> <data name="customer/dataset" xsi:type="string">default</data>
<data name="checkoutMethod" xsi:type="string">login</data> <data name="checkoutMethod" xsi:type="string">guest</data>
<data name="taxRule" xsi:type="string">us_ca_ny_rule</data> <data name="taxRule" xsi:type="string">us_ca_ny_rule</data>
<data name="refundedPrices" xsi:type="array"> <data name="order/data/refund" xsi:type="array">
<item name="0" xsi:type="string">621.20</item> <item name="0" xsi:type="array">
<item name="invoiceId" xsi:type="string">0</item>
<item name="items_data" xsi:type="array">
<item name="0" xsi:type="array">
<item name="qty" xsi:type="string">1</item>
</item>
</item>
</item>
<item name="1" xsi:type="array">
<item name="invoiceId" xsi:type="string">0</item>
</item>
</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> </data>
<data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
...@@ -42,9 +66,6 @@ ...@@ -42,9 +66,6 @@
<data name="payment/method" xsi:type="string">braintree_paypal</data> <data name="payment/method" xsi:type="string">braintree_paypal</data>
<data name="configData" xsi:type="string">braintree, braintree_paypal, braintree_paypal_skip_order_review</data> <data name="configData" xsi:type="string">braintree, braintree_paypal, braintree_paypal_skip_order_review</data>
<data name="data/items_data/0/qty" xsi:type="string">2</data> <data name="data/items_data/0/qty" xsi:type="string">2</data>
<data name="refundData/items_data/0/qty" xsi:type="string">1</data>
<data name="order/dataset" xsi:type="string">default</data>
<data name="isCreditMemoPartial" xsi:type="string">Yes</data>
<data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data> <data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data>
<constraint name="Magento\Sales\Test\Constraint\AssertRefundSuccessCreateMessage" /> <constraint name="Magento\Sales\Test\Constraint\AssertRefundSuccessCreateMessage" />
<constraint name="Magento\Sales\Test\Constraint\AssertRefundInCreditMemoTab" /> <constraint name="Magento\Sales\Test\Constraint\AssertRefundInCreditMemoTab" />
......
...@@ -28,14 +28,80 @@ ...@@ -28,14 +28,80 @@
<data name="creditCard/data/payment_code" xsi:type="string">braintree</data> <data name="creditCard/data/payment_code" xsi:type="string">braintree</data>
<data name="configData" xsi:type="string">braintree</data> <data name="configData" xsi:type="string">braintree</data>
<data name="status" xsi:type="string">Closed</data> <data name="status" xsi:type="string">Closed</data>
<data name="refundedPrices" xsi:type="array"> <data name="order/data/refund" xsi:type="array">
<item name="0" xsi:type="string">145.98</item> <item name="0" xsi:type="array">
<item name="invoiceId" xsi:type="string">0</item>
</item>
</data>
<data name="order/data/price/refund" xsi:type="array">
<item name="0" xsi:type="array">
<item name="grand_creditmemo_total" xsi:type="string">145.98</item>
</item>
</data>
<data name="transactions/refund" xsi:type="array">
<item name="transactionType" xsi:type="string">Refund</item>
<item name="statusIsClosed" xsi:type="string">Yes</item>
</data>
<constraint name="Magento\Sales\Test\Constraint\AssertRefundSuccessCreateMessage" />
<constraint name="Magento\Sales\Test\Constraint\AssertRefundInCommentsHistory" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
<constraint name="Magento\Sales\Test\Constraint\AssertTransactionStatus" />
</variation>
<variation name="CreateOnlineCreditMemoBraintreeTestVariation2" summary="Partial Refund an order placed through Braintree with Partial capture" ticketId="MAGETWO-38325">
<data name="tag" xsi:type="string">test_type:3rd_party_test, severity:S1</data>
<data name="products" xsi:type="array">
<item name="0" xsi:type="string">catalogProductSimple::product_10_dollar</item>
<item name="1" xsi:type="string">configurableProduct::with_one_option</item>
<item name="2" xsi:type="string">bundleProduct::bundle_fixed_100_dollar_product</item>
</data>
<data name="customer/dataset" xsi:type="string">default</data>
<data name="braintreeSandboxCustomer/dataset" xsi:type="string">braintree_sandbox_default</data>
<data name="taxRule" xsi:type="string">us_ca_ny_rule</data>
<data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
<data name="checkoutMethod" xsi:type="string">guest</data>
<data name="shipping" xsi:type="array">
<item name="shipping_service" xsi:type="string">Flat Rate</item>
<item name="shipping_method" xsi:type="string">Fixed</item>
</data>
<data name="payment/method" xsi:type="string">braintree</data>
<data name="creditCard/dataset" xsi:type="string">visa_default</data>
<data name="creditCard/data/payment_code" xsi:type="string">braintree</data>
<data name="configData" xsi:type="string">braintree</data>
<data name="status" xsi:type="string">Processing</data>
<data name="order/data/refund" xsi:type="array">
<item name="0" xsi:type="array">
<item name="invoiceId" xsi:type="string">0</item>
<item name="items_data" xsi:type="array">
<item name="1" xsi:type="array">
<item name="qty" xsi:type="string">0</item>
</item>
</item>
</item>
<item name="1" xsi:type="array">
<item name="invoiceId" xsi:type="string">0</item>
</item>
</data>
<data name="order/data/price/refund" xsi:type="array">
<item name="0" xsi:type="array">
<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">1.08</item>
</item>
</data> </data>
<data name="transactions/refund" xsi:type="array"> <data name="transactions/refund" xsi:type="array">
<item name="transactionType" xsi:type="string">Refund</item> <item name="transactionType" xsi:type="string">Refund</item>
<item name="statusIsClosed" xsi:type="string">Yes</item> <item name="statusIsClosed" xsi:type="string">Yes</item>
</data> </data>
<data name="data/items_data/0/qty" xsi:type="string">-</data> <data name="transactions/capture" xsi:type="array">
<item name="transactionType" xsi:type="string">Capture</item>
<item name="statusIsClosed" xsi:type="string">Yes</item>
</data>
<data name="data/items_data" xsi:type="array">
<item name="0" xsi:type="array">
<item name="qty" xsi:type="string">0</item>
</item>
</data>
<constraint name="Magento\Sales\Test\Constraint\AssertRefundSuccessCreateMessage" /> <constraint name="Magento\Sales\Test\Constraint\AssertRefundSuccessCreateMessage" />
<constraint name="Magento\Sales\Test\Constraint\AssertRefundInCommentsHistory" /> <constraint name="Magento\Sales\Test\Constraint\AssertRefundInCommentsHistory" />
<constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" /> <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusIsCorrect" />
......
...@@ -11,47 +11,69 @@ use Magento\Checkout\Test\Page\CheckoutOnepage; ...@@ -11,47 +11,69 @@ use Magento\Checkout\Test\Page\CheckoutOnepage;
use Magento\Checkout\Test\Page\CheckoutOnepageSuccess; use Magento\Checkout\Test\Page\CheckoutOnepageSuccess;
use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\Fixture\FixtureFactory;
use Magento\Mtf\TestStep\TestStepInterface; use Magento\Mtf\TestStep\TestStepInterface;
use Magento\Sales\Test\Fixture\OrderInjectable;
/** /**
* Class PlaceOrderWithPaypalStep * Place order with Paypal in one page checkout.
*/ */
class PlaceOrderWithPaypalStep implements TestStepInterface class PlaceOrderWithPaypalStep implements TestStepInterface
{ {
/** /**
* Onepage checkout page.
*
* @var CheckoutOnepage * @var CheckoutOnepage
*/ */
private $checkoutOnepage; private $checkoutOnepage;
/** /**
* Assert that Order Grand Total is correct on checkout page review block.
*
* @var AssertGrandTotalOrderReview * @var AssertGrandTotalOrderReview
*/ */
private $assertGrandTotalOrderReview; private $assertGrandTotalOrderReview;
/** /**
* Assert billing address is not present in selected payment method.
*
* @var AssertBillingAddressAbsentInPayment * @var AssertBillingAddressAbsentInPayment
*/ */
private $assertBillingAddressAbsentInPayment; private $assertBillingAddressAbsentInPayment;
/** /**
* One page checkout success page.
*
* @var CheckoutOnepageSuccess * @var CheckoutOnepageSuccess
*/ */
private $checkoutOnepageSuccess; private $checkoutOnepageSuccess;
/** /**
* Price array.
*
* @var array * @var array
*/ */
private $prices; private $prices;
/** /**
* Factory for fixtures.
*
* @var FixtureFactory * @var FixtureFactory
*/ */
private $fixtureFactory; private $fixtureFactory;
/** /**
* Array of product entities.
*
* @var array * @var array
*/ */
private $products; private $products;
/**
* Fixture OrderInjectable.
*
* @var OrderInjectable
*/
private $order;
/** /**
* @param CheckoutOnepage $checkoutOnepage * @param CheckoutOnepage $checkoutOnepage
* @param AssertGrandTotalOrderReview $assertGrandTotalOrderReview * @param AssertGrandTotalOrderReview $assertGrandTotalOrderReview
...@@ -59,7 +81,8 @@ class PlaceOrderWithPaypalStep implements TestStepInterface ...@@ -59,7 +81,8 @@ class PlaceOrderWithPaypalStep implements TestStepInterface
* @param CheckoutOnepageSuccess $checkoutOnepageSuccess * @param CheckoutOnepageSuccess $checkoutOnepageSuccess
* @param FixtureFactory $fixtureFactory * @param FixtureFactory $fixtureFactory
* @param array $products * @param array $products
* @param array $prices * @param array|null $prices
* @param OrderInjectable|null $order
*/ */
public function __construct( public function __construct(
CheckoutOnepage $checkoutOnepage, CheckoutOnepage $checkoutOnepage,
...@@ -68,7 +91,8 @@ class PlaceOrderWithPaypalStep implements TestStepInterface ...@@ -68,7 +91,8 @@ class PlaceOrderWithPaypalStep implements TestStepInterface
CheckoutOnepageSuccess $checkoutOnepageSuccess, CheckoutOnepageSuccess $checkoutOnepageSuccess,
FixtureFactory $fixtureFactory, FixtureFactory $fixtureFactory,
array $products, array $products,
array $prices = [] array $prices = [],
OrderInjectable $order = null
) { ) {
$this->checkoutOnepage = $checkoutOnepage; $this->checkoutOnepage = $checkoutOnepage;
$this->assertGrandTotalOrderReview = $assertGrandTotalOrderReview; $this->assertGrandTotalOrderReview = $assertGrandTotalOrderReview;
...@@ -77,10 +101,13 @@ class PlaceOrderWithPaypalStep implements TestStepInterface ...@@ -77,10 +101,13 @@ class PlaceOrderWithPaypalStep implements TestStepInterface
$this->fixtureFactory = $fixtureFactory; $this->fixtureFactory = $fixtureFactory;
$this->products = $products; $this->products = $products;
$this->prices = $prices; $this->prices = $prices;
$this->order = $order;
} }
/** /**
* @inheritdoc * Place order after checking order totals on review step.
*
* @return array
*/ */
public function run() public function run()
{ {
...@@ -94,15 +121,15 @@ class PlaceOrderWithPaypalStep implements TestStepInterface ...@@ -94,15 +121,15 @@ class PlaceOrderWithPaypalStep implements TestStepInterface
->getSelectedPaymentMethodBlock() ->getSelectedPaymentMethodBlock()
->clickPayWithPaypal(); ->clickPayWithPaypal();
$this->checkoutOnepage->getBraintreePaypalBlock()->process($parentWindow); $this->checkoutOnepage->getBraintreePaypalBlock()->process($parentWindow);
$data = [
'entity_id' => ['products' => $this->products]
];
$orderData = $this->order !== null ? $this->order->getData() : [];
$order = $this->fixtureFactory->createByCode( $order = $this->fixtureFactory->createByCode(
'orderInjectable', 'orderInjectable',
[ ['data' => array_merge($data, $orderData)]
'data' => [
'entity_id' => ['products' => $this->products]
]
]
); );
return [ return [
'orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(), 'orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(),
'order' => $order 'order' => $order
......
...@@ -34,13 +34,6 @@ class Items extends DataSource ...@@ -34,13 +34,6 @@ class Items extends DataSource
{ {
$this->params = $params; $this->params = $params;
$this->products = isset($data['products']) ? $data['products'] : []; $this->products = isset($data['products']) ? $data['products'] : [];
foreach ($this->products as $product) {
$classItem = 'Magento\\' . $this->getModuleName($product) . '\Test\Fixture\Cart\Item';
$item = ObjectManager::getInstance()->create($classItem, ['product' => $product]);
$this->data[] = $item;
}
} }
/** /**
...@@ -55,6 +48,24 @@ class Items extends DataSource ...@@ -55,6 +48,24 @@ class Items extends DataSource
return isset($match[1]) ? $match[1] : ''; return isset($match[1]) ? $match[1] : '';
} }
/**
* Return prepared dataset.
*
* @param null|string $key
* @return array
*/
public function getData($key = null)
{
foreach ($this->products as $product) {
$classItem = 'Magento\\' . $this->getModuleName($product) . '\Test\Fixture\Cart\Item';
$item = ObjectManager::getInstance()->create($classItem, ['product' => $product]);
$item->getData();
$this->data[] = $item;
}
return $this->data;
}
/** /**
* Get source products. * Get source products.
* *
......
...@@ -11,6 +11,7 @@ use Magento\Checkout\Test\Page\CheckoutOnepage; ...@@ -11,6 +11,7 @@ use Magento\Checkout\Test\Page\CheckoutOnepage;
use Magento\Checkout\Test\Page\CheckoutOnepageSuccess; use Magento\Checkout\Test\Page\CheckoutOnepageSuccess;
use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\Fixture\FixtureFactory;
use Magento\Mtf\TestStep\TestStepInterface; use Magento\Mtf\TestStep\TestStepInterface;
use Magento\Sales\Test\Fixture\OrderInjectable;
/** /**
* Place order in one page checkout. * Place order in one page checkout.
...@@ -59,19 +60,28 @@ class PlaceOrderStep implements TestStepInterface ...@@ -59,19 +60,28 @@ class PlaceOrderStep implements TestStepInterface
*/ */
private $products; private $products;
/**
* Fixture OrderInjectable.
*
* @var OrderInjectable
*/
private $order;
/** /**
* @param CheckoutOnepage $checkoutOnepage * @param CheckoutOnepage $checkoutOnepage
* @param AssertGrandTotalOrderReview $assertGrandTotalOrderReview * @param AssertGrandTotalOrderReview $assertGrandTotalOrderReview
* @param CheckoutOnepageSuccess $checkoutOnepageSuccess * @param CheckoutOnepageSuccess $checkoutOnepageSuccess
* @param FixtureFactory $fixtureFactory * @param FixtureFactory $fixtureFactory
* @param array $products * @param OrderInjectable|null $order
* @param array $prices * @param array|null $products
* @param array|null $prices
*/ */
public function __construct( public function __construct(
CheckoutOnepage $checkoutOnepage, CheckoutOnepage $checkoutOnepage,
AssertGrandTotalOrderReview $assertGrandTotalOrderReview, AssertGrandTotalOrderReview $assertGrandTotalOrderReview,
CheckoutOnepageSuccess $checkoutOnepageSuccess, CheckoutOnepageSuccess $checkoutOnepageSuccess,
FixtureFactory $fixtureFactory, FixtureFactory $fixtureFactory,
OrderInjectable $order = null,
array $products = [], array $products = [],
array $prices = [] array $prices = []
) { ) {
...@@ -79,6 +89,7 @@ class PlaceOrderStep implements TestStepInterface ...@@ -79,6 +89,7 @@ class PlaceOrderStep implements TestStepInterface
$this->assertGrandTotalOrderReview = $assertGrandTotalOrderReview; $this->assertGrandTotalOrderReview = $assertGrandTotalOrderReview;
$this->checkoutOnepageSuccess = $checkoutOnepageSuccess; $this->checkoutOnepageSuccess = $checkoutOnepageSuccess;
$this->fixtureFactory = $fixtureFactory; $this->fixtureFactory = $fixtureFactory;
$this->order = $order;
$this->products = $products; $this->products = $products;
$this->prices = $prices; $this->prices = $prices;
} }
...@@ -95,14 +106,14 @@ class PlaceOrderStep implements TestStepInterface ...@@ -95,14 +106,14 @@ class PlaceOrderStep implements TestStepInterface
} }
$this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder(); $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder();
$orderId = $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(); $orderId = $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId();
$data = [
'id' => $orderId,
'entity_id' => ['products' => $this->products]
];
$orderData = $this->order !== null ? $this->order->getData() : [];
$order = $this->fixtureFactory->createByCode( $order = $this->fixtureFactory->createByCode(
'orderInjectable', 'orderInjectable',
[ ['data' => array_merge($data, $orderData)]
'data' => [
'id' => $orderId,
'entity_id' => ['products' => $this->products],
]
]
); );
return [ return [
......
...@@ -11,8 +11,15 @@ ...@@ -11,8 +11,15 @@
<data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data> <data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data>
<data name="customer/dataset" xsi:type="string">default</data> <data name="customer/dataset" xsi:type="string">default</data>
<data name="checkoutMethod" xsi:type="string">guest</data> <data name="checkoutMethod" xsi:type="string">guest</data>
<data name="refundedPrices" xsi:type="array"> <data name="order/data/refund" xsi:type="array">
<item name="0" xsi:type="string">15.00</item> <item name="0" xsi:type="array">
<item name="invoiceId" xsi:type="string">0</item>
</item>
</data>
<data name="order/data/price/refund" xsi:type="array">
<item name="0" xsi:type="array">
<item name="grand_creditmemo_total" xsi:type="string">15.00</item>
</item>
</data> </data>
<data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data> <data name="shippingAddress/dataset" xsi:type="string">US_address_1_without_email</data>
<data name="shipping/shipping_service" xsi:type="string">Flat Rate</data> <data name="shipping/shipping_service" xsi:type="string">Flat Rate</data>
......
...@@ -68,8 +68,9 @@ abstract class AbstractForm extends Form ...@@ -68,8 +68,9 @@ abstract class AbstractForm extends Form
{ {
$data = $this->prepareData($data); $data = $this->prepareData($data);
if (isset($data['items_data']) && $products !== null) { if (isset($data['items_data']) && $products !== null) {
foreach ($products as $key => $product) { foreach ($data['items_data'] as $key => $item) {
$this->getItemsBlock()->getItemProductBlock($product)->fillProduct($data['items_data'][$key]); $productSku = $products[$key]->getData()['sku'];
$this->getItemsBlock()->getItemProductBlock($productSku)->fillProduct($item);
} }
} }
} }
......
...@@ -111,7 +111,7 @@ class AbstractItems extends Block ...@@ -111,7 +111,7 @@ class AbstractItems extends Block
* @param ElementInterface $item * @param ElementInterface $item
* @return null|int * @return null|int
*/ */
private function getQty(ElementInterface $item) protected function getQty(ElementInterface $item)
{ {
$qty = null; $qty = null;
$elements = $item->getElements($this->qty); $elements = $item->getElements($this->qty);
...@@ -127,7 +127,7 @@ class AbstractItems extends Block ...@@ -127,7 +127,7 @@ class AbstractItems extends Block
* @param ElementInterface $item * @param ElementInterface $item
* @return string * @return string
*/ */
private function getSku(ElementInterface $item) protected function getSku(ElementInterface $item)
{ {
$itemContent = $item->find($this->sku)->getText(); $itemContent = $item->find($this->sku)->getText();
$itemContent = preg_replace('/\n|\r/', '', $itemContent); $itemContent = preg_replace('/\n|\r/', '', $itemContent);
......
...@@ -8,38 +8,36 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order; ...@@ -8,38 +8,36 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order;
use Magento\Sales\Test\Block\Adminhtml\Order\AbstractForm\Product; use Magento\Sales\Test\Block\Adminhtml\Order\AbstractForm\Product;
use Magento\Mtf\Block\Block; use Magento\Mtf\Block\Block;
use Magento\Mtf\Fixture\FixtureInterface;
/** /**
* Class AbstractItemsNewBlock * Items block on Credit Memo, Invoice, Shipment new pages.
* Items block on Credit Memo, Invoice, Shipment new pages
*/ */
abstract class AbstractItemsNewBlock extends Block abstract class AbstractItemsNewBlock extends Block
{ {
/** /**
* Item product row selector * Item product row selector.
* *
* @var string * @var string
*/ */
protected $productItem = '//tr[contains(.,"%s")]'; protected $productItem = '//tr[contains(.,"%s")]';
/** /**
* 'Update Qty's' button css selector * 'Update Qty's' button css selector.
* *
* @var string * @var string
*/ */
protected $updateQty = '.update-button'; protected $updateQty = '.update-button';
/** /**
* Get item product block * Get item product block.
* *
* @param FixtureInterface $product * @param string $productSku
* @return Product * @return Product
*/ */
abstract public function getItemProductBlock(FixtureInterface $product); abstract public function getItemProductBlock($productSku);
/** /**
* Click update qty button * Click update qty button.
* *
* @return void * @return void
*/ */
......
...@@ -9,7 +9,6 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form; ...@@ -9,7 +9,6 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form;
use Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items\Product; use Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items\Product;
use Magento\Mtf\Block\Block; use Magento\Mtf\Block\Block;
use Magento\Mtf\Client\Locator; use Magento\Mtf\Client\Locator;
use Magento\Mtf\Fixture\FixtureInterface;
/** /**
* Credit Memo Items block on Credit Memo new page. * Credit Memo Items block on Credit Memo new page.
...@@ -33,12 +32,12 @@ class Items extends Block ...@@ -33,12 +32,12 @@ class Items extends Block
/** /**
* Get item product block. * Get item product block.
* *
* @param FixtureInterface $product * @param string $productSku
* @return Product * @return Product
*/ */
public function getItemProductBlock(FixtureInterface $product) public function getItemProductBlock($productSku)
{ {
$selector = sprintf($this->productItems, $product->getSku()); $selector = sprintf($this->productItems, $productSku);
return $this->blockFactory->create( return $this->blockFactory->create(
\Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items\Product::class, \Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items\Product::class,
['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)]
......
...@@ -9,23 +9,21 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\Invoice\Form; ...@@ -9,23 +9,21 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\Invoice\Form;
use Magento\Sales\Test\Block\Adminhtml\Order\AbstractItemsNewBlock; use Magento\Sales\Test\Block\Adminhtml\Order\AbstractItemsNewBlock;
use Magento\Sales\Test\Block\Adminhtml\Order\Invoice\Form\Items\Product; use Magento\Sales\Test\Block\Adminhtml\Order\Invoice\Form\Items\Product;
use Magento\Mtf\Client\Locator; use Magento\Mtf\Client\Locator;
use Magento\Mtf\Fixture\FixtureInterface;
/** /**
* Class Items * Block for items to invoice on new invoice page.
* Block for items to invoice on new invoice page
*/ */
class Items extends AbstractItemsNewBlock class Items extends AbstractItemsNewBlock
{ {
/** /**
* Get item product block * Get item product block.
* *
* @param FixtureInterface $product * @param string $productSku
* @return Product * @return Product
*/ */
public function getItemProductBlock(FixtureInterface $product) public function getItemProductBlock($productSku)
{ {
$selector = sprintf($this->productItem, $product->getSku()); $selector = sprintf($this->productItem, $productSku);
return $this->blockFactory->create( return $this->blockFactory->create(
\Magento\Sales\Test\Block\Adminhtml\Order\Invoice\Form\Items\Product::class, \Magento\Sales\Test\Block\Adminhtml\Order\Invoice\Form\Items\Product::class,
['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)]
......
...@@ -9,13 +9,12 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\Shipment\View; ...@@ -9,13 +9,12 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\Shipment\View;
use Magento\Sales\Test\Block\Adminhtml\Order\AbstractItems; 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 class Items extends AbstractItems
{ {
/** /**
* Get items data * Get items data.
* *
* @return array * @return array
*/ */
...@@ -27,8 +26,9 @@ class Items extends AbstractItems ...@@ -27,8 +26,9 @@ class Items extends AbstractItems
foreach ($items as $item) { foreach ($items as $item) {
$itemData = []; $itemData = [];
$itemData += $this->parseProductName($item->find($this->product)->getText()); $itemData['product'] = preg_replace('/\n|\r/', '', $item->find($this->title)->getText());
$itemData['qty'] = $item->find($this->qty)->getText(); $itemData['sku'] = $this->getSku($item);
$itemData['qty'] = $this->getQty($item);
$data[] = $itemData; $data[] = $itemData;
} }
......
...@@ -70,6 +70,7 @@ class Grid extends DataGrid ...@@ -70,6 +70,7 @@ class Grid extends DataGrid
*/ */
public function getCreditMemoId() public function getCreditMemoId()
{ {
$this->resetFilter();
$this->waitForElementNotVisible($this->loader, Locator::SELECTOR_XPATH); $this->waitForElementNotVisible($this->loader, Locator::SELECTOR_XPATH);
return $this->_rootElement->find($this->creditMemoId)->getText(); return $this->_rootElement->find($this->creditMemoId)->getText();
} }
...@@ -82,6 +83,7 @@ class Grid extends DataGrid ...@@ -82,6 +83,7 @@ class Grid extends DataGrid
public function getIds() public function getIds()
{ {
$result = []; $result = [];
$this->resetFilter();
$this->waitForElementNotVisible($this->loader, Locator::SELECTOR_XPATH); $this->waitForElementNotVisible($this->loader, Locator::SELECTOR_XPATH);
$creditMemoIds = $this->_rootElement->getElements($this->creditMemoId); $creditMemoIds = $this->_rootElement->getElements($this->creditMemoId);
foreach ($creditMemoIds as $creditMemoId) { foreach ($creditMemoIds as $creditMemoId) {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
namespace Magento\Sales\Test\Constraint; namespace Magento\Sales\Test\Constraint;
use Magento\Sales\Test\Fixture\OrderInjectable;
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
use Magento\Sales\Test\Page\Adminhtml\OrderIndex; use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
use Magento\Mtf\Constraint\AbstractConstraint; use Magento\Mtf\Constraint\AbstractConstraint;
...@@ -23,17 +24,17 @@ class AssertRefundInCommentsHistory extends AbstractConstraint ...@@ -23,17 +24,17 @@ class AssertRefundInCommentsHistory extends AbstractConstraint
/** /**
* Assert that comment about refunded amount exists in Comments History section on order page in Admin. * Assert that comment about refunded amount exists in Comments History section on order page in Admin.
* *
* @param OrderInjectable $order
* @param SalesOrderView $salesOrderView * @param SalesOrderView $salesOrderView
* @param OrderIndex $salesOrder * @param OrderIndex $salesOrder
* @param string $orderId * @param string $orderId
* @param array $refundedPrices
* @return void * @return void
*/ */
public function processAssert( public function processAssert(
OrderInjectable $order,
SalesOrderView $salesOrderView, SalesOrderView $salesOrderView,
OrderIndex $salesOrder, OrderIndex $salesOrder,
$orderId, $orderId
array $refundedPrices
) { ) {
$salesOrder->open(); $salesOrder->open();
$salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]);
...@@ -49,9 +50,10 @@ class AssertRefundInCommentsHistory extends AbstractConstraint ...@@ -49,9 +50,10 @@ class AssertRefundInCommentsHistory extends AbstractConstraint
} }
$comments = array_values($comments); $comments = array_values($comments);
$refundedPrices = $order->getPrice()['refund'];
foreach ($refundedPrices as $key => $refundedPrice) { foreach ($refundedPrices as $key => $refundedPrice) {
\PHPUnit_Framework_Assert::assertRegExp( \PHPUnit_Framework_Assert::assertRegExp(
sprintf(self::REFUNDED_AMOUNT_PATTERN, $refundedPrice), sprintf(self::REFUNDED_AMOUNT_PATTERN, $refundedPrice['grand_creditmemo_total']),
$comments[$key]['comment'], $comments[$key]['comment'],
'Incorrect refunded amount value for the order #' . $orderId 'Incorrect refunded amount value for the order #' . $orderId
); );
......
...@@ -37,7 +37,7 @@ class AssertRefundInCreditMemoTab extends AbstractConstraint ...@@ -37,7 +37,7 @@ class AssertRefundInCreditMemoTab extends AbstractConstraint
$salesOrderView->getOrderForm()->openTab('creditmemos'); $salesOrderView->getOrderForm()->openTab('creditmemos');
/** @var Grid $grid */ /** @var Grid $grid */
$grid = $salesOrderView->getOrderForm()->getTab('creditmemos')->getGridBlock(); $grid = $salesOrderView->getOrderForm()->getTab('creditmemos')->getGridBlock();
$amount = $order->getPrice(); $amount = $order->getPrice()['refund'];
foreach ($ids['creditMemoIds'] as $key => $creditMemoId) { foreach ($ids['creditMemoIds'] as $key => $creditMemoId) {
$filter = [ $filter = [
'id' => $creditMemoId, 'id' => $creditMemoId,
......
...@@ -11,13 +11,12 @@ use Magento\Sales\Test\Page\Adminhtml\CreditMemoIndex; ...@@ -11,13 +11,12 @@ use Magento\Sales\Test\Page\Adminhtml\CreditMemoIndex;
use Magento\Mtf\Constraint\AbstractConstraint; use Magento\Mtf\Constraint\AbstractConstraint;
/** /**
* Class AssertRefundInRefundsGrid * Assert that refund is present in the 'Refunds' grid with correct ID, order ID, refunded amount.
* Assert that refund is present in the 'Refunds' grid with correct ID, order ID, refunded amount
*/ */
class AssertRefundInRefundsGrid extends AbstractConstraint class AssertRefundInRefundsGrid extends AbstractConstraint
{ {
/** /**
* Assert that refund is present in the 'Refunds' grid with correct ID, order ID, refunded amount * Assert that refund is present in the 'Refunds' grid with correct ID, order ID, refunded amount.
* *
* @param CreditMemoIndex $creditMemoIndex * @param CreditMemoIndex $creditMemoIndex
* @param OrderInjectable $order * @param OrderInjectable $order
...@@ -27,7 +26,7 @@ class AssertRefundInRefundsGrid extends AbstractConstraint ...@@ -27,7 +26,7 @@ class AssertRefundInRefundsGrid extends AbstractConstraint
public function processAssert(CreditMemoIndex $creditMemoIndex, OrderInjectable $order, array $ids) public function processAssert(CreditMemoIndex $creditMemoIndex, OrderInjectable $order, array $ids)
{ {
$creditMemoIndex->open(); $creditMemoIndex->open();
$amount = $order->getPrice(); $amount = $order->getPrice()['refund'];
$orderId = $order->getId(); $orderId = $order->getId();
foreach ($ids['creditMemoIds'] as $key => $creditMemoId) { foreach ($ids['creditMemoIds'] as $key => $creditMemoId) {
$filter = [ $filter = [
...@@ -47,7 +46,7 @@ class AssertRefundInRefundsGrid extends AbstractConstraint ...@@ -47,7 +46,7 @@ class AssertRefundInRefundsGrid extends AbstractConstraint
} }
/** /**
* Returns a string representation of the object * Returns a string representation of the object.
* *
* @return string * @return string
*/ */
......
...@@ -26,7 +26,7 @@ class AssertRefundNotInRefundsGrid extends AbstractConstraint ...@@ -26,7 +26,7 @@ class AssertRefundNotInRefundsGrid extends AbstractConstraint
public function processAssert(CreditMemoIndex $creditMemoIndex, OrderInjectable $order, array $ids) public function processAssert(CreditMemoIndex $creditMemoIndex, OrderInjectable $order, array $ids)
{ {
$creditMemoIndex->open(); $creditMemoIndex->open();
$amount = $order->getPrice(); $amount = $order->getPrice()['refund'];
$orderId = $order->getId(); $orderId = $order->getId();
foreach ($ids['creditMemoIds'] as $key => $creditMemoId) { foreach ($ids['creditMemoIds'] as $key => $creditMemoId) {
$filter = [ $filter = [
......
...@@ -12,12 +12,12 @@ use Magento\Sales\Test\Page\OrderHistory; ...@@ -12,12 +12,12 @@ use Magento\Sales\Test\Page\OrderHistory;
use Magento\Sales\Test\Page\CustomerOrderView; use Magento\Sales\Test\Page\CustomerOrderView;
/** /**
* Assert that refunded grand total is equal to data from fixture on My Account page * Assert that refunded grand total is equal to data from fixture on My Account page.
*/ */
class AssertRefundedGrandTotalOnFrontend extends AbstractAssertOrderOnFrontend class AssertRefundedGrandTotalOnFrontend extends AbstractAssertOrderOnFrontend
{ {
/** /**
* Assert that refunded grand total is equal to data from fixture on My Account page * Assert that refunded grand total is equal to data from fixture on My Account page.
* *
* @param OrderHistory $orderHistory * @param OrderHistory $orderHistory
* @param OrderInjectable $order * @param OrderInjectable $order
...@@ -38,14 +38,14 @@ class AssertRefundedGrandTotalOnFrontend extends AbstractAssertOrderOnFrontend ...@@ -38,14 +38,14 @@ class AssertRefundedGrandTotalOnFrontend extends AbstractAssertOrderOnFrontend
$customerOrderView->getOrderViewBlock()->openLinkByName('Refunds'); $customerOrderView->getOrderViewBlock()->openLinkByName('Refunds');
foreach ($ids['creditMemoIds'] as $key => $creditMemoId) { foreach ($ids['creditMemoIds'] as $key => $creditMemoId) {
\PHPUnit_Framework_Assert::assertEquals( \PHPUnit_Framework_Assert::assertEquals(
number_format($order->getPrice()[$key]['grand_creditmemo_total'], 2), number_format($order->getPrice()['refund'][$key]['grand_creditmemo_total'], 2),
$creditMemoView->getCreditMemoBlock()->getItemBlock($creditMemoId)->getGrandTotal() $creditMemoView->getCreditMemoBlock()->getItemBlock($creditMemoId)->getGrandTotal()
); );
} }
} }
/** /**
* Returns a string representation of the object * Returns a string representation of the object.
* *
* @return string * @return string
*/ */
......
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