diff --git a/dev/tests/functional/composer.json b/dev/tests/functional/composer.json index 3567ec530f437..cfa06fbf60402 100644 --- a/dev/tests/functional/composer.json +++ b/dev/tests/functional/composer.json @@ -1,6 +1,6 @@ { "require": { - "magento/mtf": "1.0.0-rc51", + "magento/mtf": "1.0.0-rc52", "php": "~5.6.5|7.0.2|~7.0.6", "phpunit/phpunit": "~4.8.0|~5.5.0", "phpunit/phpunit-selenium": ">=1.2" diff --git a/dev/tests/functional/etc/repository_replacer_payments.xml b/dev/tests/functional/etc/repository_replacer_payments.xml new file mode 100644 index 0000000000000..6b9b9fe54515f --- /dev/null +++ b/dev/tests/functional/etc/repository_replacer_payments.xml @@ -0,0 +1,17 @@ + + + + + + BRAINTREEE_ENVIRONMENT + BRAINTREEE_MERCHANT_ID + BRAINTREE_PUBLIC_KEY + BRAINTREE_PRIVATE_KEY + + + diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/AssertTransactionIsPresentInSettlementReport.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/AssertTransactionIsPresentInSettlementReport.php index ca9d4ebea309f..2ae10ed4305ba 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/AssertTransactionIsPresentInSettlementReport.php +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/AssertTransactionIsPresentInSettlementReport.php @@ -11,7 +11,7 @@ use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; /** - * Class AssertTransactionIsPresentInSettlementReport + * Assert that comment with transaction id exists in Comments History section on order page in Admin. */ class AssertTransactionIsPresentInSettlementReport extends AbstractConstraint { @@ -26,6 +26,8 @@ class AssertTransactionIsPresentInSettlementReport extends AbstractConstraint private $settlementReportIndex; /** + * Assert that comment with transaction id exists in Comments History section on order page in Admin. + * * @param $orderId * @param OrderIndex $orderIndex * @param SalesOrderView $salesOrderView @@ -58,7 +60,9 @@ public function processAssert( } /** - * @inheritdoc + * Returns a string representation of the object. + * + * @return string */ public function toString() { @@ -66,15 +70,18 @@ public function toString() } /** - * Get transaction id from order comments - * @return mixed + * Get transaction id from order comments. + * + * @return null|string */ private function getTransactionId() { - $comments = $this->salesOrderView->getOrderHistoryBlock()->getCommentsHistory(); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $this->salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); $transactionId = null; - preg_match('/(\w+-*\w+)"/', $comments, $matches); + preg_match('/(\w+-*\w+)"/', $latestComment['comment'], $matches); if (!empty($matches[1])) { $transactionId = $matches[1]; } diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Fixture/BraintreeSandboxCustomer.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/Fixture/BraintreeSandboxCustomer.xml new file mode 100644 index 0000000000000..ed7d001af06d2 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/Fixture/BraintreeSandboxCustomer.xml @@ -0,0 +1,19 @@ + + + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/BraintreeSandboxCustomer.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/BraintreeSandboxCustomer.xml new file mode 100644 index 0000000000000..e11d49b867d1a --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/BraintreeSandboxCustomer.xml @@ -0,0 +1,17 @@ + + + + + + BRAINTREEE_ENVIRONMENT + BRAINTREEE_MERCHANT_ID + BRAINTREE_PUBLIC_KEY + BRAINTREE_PRIVATE_KEY + + + diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.xml index 0fc9162effca7..996ce28f10b00 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.xml @@ -11,10 +11,17 @@ catalogProductSimple::product_10_dollar bundleProduct::bundle_fixed_100_dollar_product default - login + guest us_ca_ny_rule - - 139.90 + + + 0 + + + + + 139.90 + US_address_1_without_email Flat Rate @@ -22,7 +29,6 @@ braintree_paypal braintree, braintree_paypal, braintree_paypal_sale, braintree_paypal_skip_order_review sale - - test_type:3rd_party_test, severity:S1 @@ -31,10 +37,28 @@ catalogProductSimple::simple_for_sales default - login + guest us_ca_ny_rule - - 621.20 + + + 0 + + + 1 + + + + + 0 + + + + + 621.20 + + + 606.20 + US_address_1_without_email Flat Rate @@ -42,9 +66,6 @@ braintree_paypal braintree, braintree_paypal, braintree_paypal_skip_order_review 2 - 1 - default - Yes test_type:3rd_party_test, severity:S1 diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreeTest.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreeTest.php new file mode 100644 index 0000000000000..16aa003bd04b7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreeTest.php @@ -0,0 +1,40 @@ +executeScenario(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreeTest.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreeTest.xml new file mode 100644 index 0000000000000..638c76cadb55d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreeTest.xml @@ -0,0 +1,102 @@ + + + + + + test_type:3rd_party_test, severity:S1 + + catalogProductSimple::product_10_dollar + configurableProduct::with_one_option + bundleProduct::bundle_fixed_100_dollar_product + + default + braintree_sandbox_default + us_ca_ny_rule + US_address_1_without_email + guest + + Flat Rate + Fixed + + braintree + visa_default + braintree + braintree + Closed + + + 0 + + + + + 145.98 + + + + Refund + Yes + + + + + + + + test_type:3rd_party_test, severity:S1 + + catalogProductSimple::product_10_dollar + configurableProduct::with_one_option + bundleProduct::bundle_fixed_100_dollar_product + + default + braintree_sandbox_default + us_ca_ny_rule + US_address_1_without_email + guest + + Flat Rate + Fixed + + braintree + visa_default + braintree + braintree + Processing + + + 0 + + + 0 + + + + + 0 + + + + + 134.07 + + + 1.08 + + + + + 0 + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/PlaceOrderWithPaypalStep.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/PlaceOrderWithPaypalStep.php index d90dfeeb17f31..38d3221418620 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/PlaceOrderWithPaypalStep.php +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/PlaceOrderWithPaypalStep.php @@ -11,47 +11,69 @@ use Magento\Checkout\Test\Page\CheckoutOnepageSuccess; use Magento\Mtf\Fixture\FixtureFactory; 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 { /** + * Onepage checkout page. + * * @var CheckoutOnepage */ private $checkoutOnepage; /** + * Assert that Order Grand Total is correct on checkout page review block. + * * @var AssertGrandTotalOrderReview */ private $assertGrandTotalOrderReview; /** + * Assert billing address is not present in selected payment method. + * * @var AssertBillingAddressAbsentInPayment */ private $assertBillingAddressAbsentInPayment; /** + * One page checkout success page. + * * @var CheckoutOnepageSuccess */ private $checkoutOnepageSuccess; /** + * Price array. + * * @var array */ private $prices; /** + * Factory for fixtures. + * * @var FixtureFactory */ private $fixtureFactory; /** + * Array of product entities. + * * @var array */ private $products; + /** + * Fixture OrderInjectable. + * + * @var OrderInjectable + */ + private $order; + /** * @param CheckoutOnepage $checkoutOnepage * @param AssertGrandTotalOrderReview $assertGrandTotalOrderReview @@ -60,6 +82,7 @@ class PlaceOrderWithPaypalStep implements TestStepInterface * @param FixtureFactory $fixtureFactory * @param array $products * @param array $prices + * @param OrderInjectable|null $order */ public function __construct( CheckoutOnepage $checkoutOnepage, @@ -68,7 +91,8 @@ public function __construct( CheckoutOnepageSuccess $checkoutOnepageSuccess, FixtureFactory $fixtureFactory, array $products, - array $prices = [] + array $prices = [], + OrderInjectable $order = null ) { $this->checkoutOnepage = $checkoutOnepage; $this->assertGrandTotalOrderReview = $assertGrandTotalOrderReview; @@ -77,10 +101,13 @@ public function __construct( $this->fixtureFactory = $fixtureFactory; $this->products = $products; $this->prices = $prices; + $this->order = $order; } /** - * @inheritdoc + * Place order after checking order totals on review step. + * + * @return array */ public function run() { @@ -94,15 +121,15 @@ public function run() ->getSelectedPaymentMethodBlock() ->clickPayWithPaypal(); $this->checkoutOnepage->getBraintreePaypalBlock()->process($parentWindow); - + $data = [ + 'entity_id' => ['products' => $this->products] + ]; + $orderData = $this->order !== null ? $this->order->getData() : []; $order = $this->fixtureFactory->createByCode( 'orderInjectable', - [ - 'data' => [ - 'entity_id' => ['products' => $this->products] - ] - ] + ['data' => array_merge($data, $orderData)] ); + return [ 'orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(), 'order' => $order diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/SettleTransactionStep.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/SettleTransactionStep.php new file mode 100644 index 0000000000000..977b95fb8b9aa --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/SettleTransactionStep.php @@ -0,0 +1,93 @@ +braintreeSandboxCustomer = $braintreeSandboxCustomer; + $this->salesOrder = $salesOrder; + $this->salesOrderView = $salesOrderView; + $this->orderId = $orderId; + } + + /** + * Settle transaction for Braintree Credit Card. + * + * @return void + */ + public function run() + { + $credentials = $this->braintreeSandboxCustomer->getData(); + $gateway = ObjectManagerFactory::getObjectManager()->create(Gateway::class, ['config' => $credentials]); + $transactionId = $this->getTransactionId(); + $gateway->testing()->settle($transactionId); + } + + /** + * Get transaction id. + * + * @return string + */ + private function getTransactionId() + { + $this->salesOrder->open(); + $this->salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $this->orderId]); + $this->salesOrderView->getOrderForm()->openTab('transactions'); + $actualTransactions = $this->salesOrderView->getOrderForm()->getTab('transactions')->getGridBlock()->getIds(); + + return current(array_keys($actualTransactions)); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/testcase.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/testcase.xml index d55bde9089b9f..ffe67f1979ee0 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/testcase.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/testcase.xml @@ -188,4 +188,22 @@ + + + + + + + + + + + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Fixture/Cart/Items.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Fixture/Cart/Items.php index 5aa80efe329c4..a5c9499e2b792 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Fixture/Cart/Items.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Fixture/Cart/Items.php @@ -34,13 +34,6 @@ public function __construct(array $params, array $data = []) { $this->params = $params; $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 @@ protected function getModuleName(FixtureInterface $product) 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 parent::getData($key); + } + /** * Get source products. * diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php index 985780a30eae0..88466249ba2e8 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php @@ -11,6 +11,7 @@ use Magento\Checkout\Test\Page\CheckoutOnepageSuccess; use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\TestStep\TestStepInterface; +use Magento\Sales\Test\Fixture\OrderInjectable; /** * Place order in one page checkout. @@ -59,6 +60,13 @@ class PlaceOrderStep implements TestStepInterface */ private $products; + /** + * Fixture OrderInjectable. + * + * @var OrderInjectable + */ + private $order; + /** * @param CheckoutOnepage $checkoutOnepage * @param AssertGrandTotalOrderReview $assertGrandTotalOrderReview @@ -66,6 +74,7 @@ class PlaceOrderStep implements TestStepInterface * @param FixtureFactory $fixtureFactory * @param array $products * @param array $prices + * @param OrderInjectable|null $order */ public function __construct( CheckoutOnepage $checkoutOnepage, @@ -73,7 +82,8 @@ public function __construct( CheckoutOnepageSuccess $checkoutOnepageSuccess, FixtureFactory $fixtureFactory, array $products = [], - array $prices = [] + array $prices = [], + OrderInjectable $order = null ) { $this->checkoutOnepage = $checkoutOnepage; $this->assertGrandTotalOrderReview = $assertGrandTotalOrderReview; @@ -81,6 +91,7 @@ public function __construct( $this->fixtureFactory = $fixtureFactory; $this->products = $products; $this->prices = $prices; + $this->order = $order; } /** @@ -95,14 +106,14 @@ public function run() } $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder(); $orderId = $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(); + $data = [ + 'id' => $orderId, + 'entity_id' => ['products' => $this->products] + ]; + $orderData = $this->order !== null ? $this->order->getData() : []; $order = $this->fixtureFactory->createByCode( 'orderInjectable', - [ - 'data' => [ - 'id' => $orderId, - 'entity_id' => ['products' => $this->products], - ] - ] + ['data' => array_merge($data, $orderData)] ); return [ diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/Cart/Item.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/Cart/Item.php index 0b87fc0d1b238..905a382f01897 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/Cart/Item.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Fixture/Cart/Item.php @@ -48,7 +48,11 @@ public function getData($key = null) ]; } $attributeKey = implode(' ', $attributeKey); - $cartItem['sku'] = $productData['configurable_attributes_data']['matrix'][$attributeKey]['sku']; + if (isset($productData['configurable_attributes_data']['matrix'][$attributeKey])) { + $cartItem['sku'] = $productData['configurable_attributes_data']['matrix'][$attributeKey]['sku']; + } else { + $cartItem['sku'] = $productData['sku']; + } $cartItem['name'] = $productData['name']; $cartItem['options'] = isset($cartItem['options']) diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml index 642bbdbdcc664..6f9d04e626a9b 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Repository/Address.xml @@ -309,5 +309,17 @@ California 90230 + + + John + Doe + Magento %isolation% + Culver City + 49 Main + 555-55-555-55 + United States + California + 00382 + diff --git a/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCard.xml b/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCard.xml index 1b59246febbdf..5392509a932cd 100644 --- a/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCard.xml +++ b/dev/tests/functional/tests/app/Magento/Payment/Test/Repository/CreditCard.xml @@ -50,5 +50,12 @@ + + + 4111111111111111 + 01 - January + 2020 + 306 + diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml index 0f26e3bec8afa..51f18cd929a97 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/ConfigData.xml @@ -236,6 +236,15 @@ + + + payment + 1 + Yes + 1 + + + payment @@ -494,6 +503,7 @@ 0 + payment @@ -510,5 +520,34 @@ 0 + + + + payment + 1 + Yes + 1 + + + payment + 1 + No + 0 + + + + + payment + 1 + No + 0 + + + payment + 1 + Yes + 1 + + diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreateOnlineCreditMemoTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreateOnlineCreditMemoTest.xml index b155dacf8f25c..419ccb61a7f79 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreateOnlineCreditMemoTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/CreateOnlineCreditMemoTest.xml @@ -7,12 +7,20 @@ --> - + + test_type:3rd_party_test, severity:S0 catalogProductSimple::product_10_dollar default guest - - 15.00 + + + 0 + + + + + 15.00 + US_address_1_without_email Flat Rate @@ -23,15 +31,54 @@ - Yes Closed - + Refund Yes - + Capture Yes + + + + + + + test_type:3rd_party_test, severity:S0 + catalogProductSimple::product_10_dollar + default + guest + + + 0 + + + + + 15.00 + + + US_address_1_without_email + Flat Rate + Fixed + payflowpro + payflowpro + visa_default + Closed + + Authorization + Yes + + + Refund + Yes + + + Capture + Yes + diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutDeclinedTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutDeclinedTest.xml index 1ca34ae1bab13..e4c0f0196beeb 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutDeclinedTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutDeclinedTest.xml @@ -21,5 +21,33 @@ An error occurred on the server. Please try to place the order again. + + catalogProductSimple::product_10_dollar + default + US_address_1_without_email + guest + Flat Rate + Fixed + payflowpro + visa_default + An error occurred on the server. Please try to place the order again. + payflowpro, payflowpro_use_avs_zip + test_type:3rd_party_test, severity:S1 + + + + test_type:3rd_party_test, severity:S1 + catalogProductSimple::product_10_dollar + default + US_address_1_without_email + guest + Flat Rate + Fixed + payflowpro + visa_cvv_mismatch + payflowpro, payflowpro_avs_security_code_does_not_match + An error occurred on the server. Please try to place the order again. + + diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutTest.xml index 76f5da0b4884f..0229ba550aa01 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/OnePageCheckoutTest.xml @@ -55,7 +55,7 @@ - + test_type:3rd_party_test, severity:S1 catalogProductSimple::product_10_dollar default @@ -99,5 +99,46 @@ + + catalogProductSimple::product_10_dollar + default + AVS_zip_match_address + guest + Flat Rate + Fixed + payflowpro + visa_default + + #Y: Yes. Matched Address and five-didgit ZIP + + payflowpro, payflowpro_use_avs_zip + Processing + test_type:3rd_party_test, severity:S1 + + + + + + test_type:3rd_party_test, severity:S1 + catalogProductSimple::product_10_dollar + default + US_address_1_without_email + guest + Flat Rate + Fixed + payflowpro + + 15.00 + + visa_default + payflowpro, payflowpro_avs_security_code_does_not_match + + #Y: Matched (CVV2CSC) + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm.php index c5c792b24c4fa..3a25d2ed8fc07 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractForm.php @@ -68,8 +68,9 @@ public function fillProductData(array $data, $products = null) { $data = $this->prepareData($data); if (isset($data['items_data']) && $products !== null) { - foreach ($products as $key => $product) { - $this->getItemsBlock()->getItemProductBlock($product)->fillProduct($data['items_data'][$key]); + foreach ($data['items_data'] as $key => $item) { + $productSku = $products[$key]->getData()['sku']; + $this->getItemsBlock()->getItemProductBlock($productSku)->fillProduct($item); } } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItems.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItems.php index 28814e1f23ad0..7b2862dcd6412 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItems.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItems.php @@ -111,7 +111,7 @@ public function getData() * @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 @@ private function getQty(ElementInterface $item) * @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); diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItemsNewBlock.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItemsNewBlock.php index 15fd358256143..71c560894cdf7 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItemsNewBlock.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/AbstractItemsNewBlock.php @@ -8,38 +8,36 @@ use Magento\Sales\Test\Block\Adminhtml\Order\AbstractForm\Product; 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 { /** - * Item product row selector + * Item product row selector. * * @var string */ protected $productItem = '//tr[contains(.,"%s")]'; /** - * 'Update Qty's' button css selector + * 'Update Qty's' button css selector. * * @var string */ protected $updateQty = '.update-button'; /** - * Get item product block + * Get item product block. * - * @param FixtureInterface $product + * @param string $productSku * @return Product */ - abstract public function getItemProductBlock(FixtureInterface $product); + abstract public function getItemProductBlock($productSku); /** - * Click update qty button + * Click update qty button. * * @return void */ diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items.php index b244448e2b6b1..a1c4000e36f26 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Form/Items.php @@ -9,7 +9,6 @@ use Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items\Product; use Magento\Mtf\Block\Block; use Magento\Mtf\Client\Locator; -use Magento\Mtf\Fixture\FixtureInterface; /** * Credit Memo Items block on Credit Memo new page. @@ -33,12 +32,12 @@ class Items extends Block /** * Get item product block. * - * @param FixtureInterface $product + * @param string $productSku * @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( \Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo\Form\Items\Product::class, ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/History.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/History.php deleted file mode 100644 index c0b2e8ef697f9..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/History.php +++ /dev/null @@ -1,175 +0,0 @@ -waitCommentsHistory(); - return $this->_rootElement->find($this->commentHistory, Locator::SELECTOR_CSS)->getText(); - } - - /** - * Get the authorized amount from the comments history. - * - * @return string - */ - public function getAuthorizedAmount() - { - $this->waitCommentsHistory(); - return $this->_rootElement->find($this->authorizedAmount, Locator::SELECTOR_XPATH)->getText(); - } - - /** - * Get the captured amount from the comments history. - * - * @return array - */ - public function getCapturedAmount() - { - $result = []; - $this->waitCommentsHistory(); - $captureComments = $this->_rootElement->getElements($this->capturedAmount, Locator::SELECTOR_XPATH); - foreach ($captureComments as $captureComment) { - $result[] = $captureComment->getText(); - } - return $result; - } - - /** - * Get the refunded amount from the comments history. - * - * @return array - */ - public function getRefundedAmount() - { - $result = []; - $this->waitCommentsHistory(); - $refundedComments = $this->_rootElement->getElements($this->refundedAmount, Locator::SELECTOR_XPATH); - foreach ($refundedComments as $refundedComment) { - $result[] = $refundedComment->getText(); - } - return $result; - } - - /** - * Get the voided amount from the comments history. - * - * @return string - */ - public function getVoidedAmount() - { - $this->waitCommentsHistory(); - return $this->_rootElement->find($this->voidedAmount, Locator::SELECTOR_XPATH)->getText(); - } - - /** - * Gets the status which presented in comment - * - * @return string - */ - public function getStatus() - { - $this->waitCommentsHistory(); - return $this->_rootElement->find($this->commentHistoryStatus, Locator::SELECTOR_CSS)->getText(); - } - - /** - * Gets the is customer notified status which presented in comment - * - * @return string - */ - public function getNotifiedStatus() - { - $this->waitCommentsHistory(); - return $this->_rootElement->find($this->commentHistoryNotifiedStatus, Locator::SELECTOR_CSS)->getText(); - } - - /** - * Wait for comments history is visible. - * - * @return void - */ - protected function waitCommentsHistory() - { - $element = $this->_rootElement; - $selector = $this->noteList; - $element->waitUntil( - function () use ($element, $selector) { - return $element->find($selector)->isVisible() ? true : null; - } - ); - } -} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form/Items.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form/Items.php index 0ff748e52f9a9..c97807ccc1522 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form/Items.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Invoice/Form/Items.php @@ -9,23 +9,21 @@ use Magento\Sales\Test\Block\Adminhtml\Order\AbstractItemsNewBlock; use Magento\Sales\Test\Block\Adminhtml\Order\Invoice\Form\Items\Product; 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 { /** - * Get item product block + * Get item product block. * - * @param FixtureInterface $product + * @param string $productSku * @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( \Magento\Sales\Test\Block\Adminhtml\Order\Invoice\Form\Items\Product::class, ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Shipment/View/Items.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Shipment/View/Items.php index 5fa78417a20fb..44e6310642ae6 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Shipment/View/Items.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Shipment/View/Items.php @@ -9,13 +9,12 @@ 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 @@ public function getData() 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; } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/CreditMemos/Grid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/CreditMemos/Grid.php index b73887bfd2ddd..2cc0571b330ff 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/CreditMemos/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/CreditMemos/Grid.php @@ -70,6 +70,7 @@ class Grid extends DataGrid */ public function getCreditMemoId() { + $this->resetFilter(); $this->waitForElementNotVisible($this->loader, Locator::SELECTOR_XPATH); return $this->_rootElement->find($this->creditMemoId)->getText(); } @@ -82,6 +83,7 @@ public function getCreditMemoId() public function getIds() { $result = []; + $this->resetFilter(); $this->waitForElementNotVisible($this->loader, Locator::SELECTOR_XPATH); $creditMemoIds = $this->_rootElement->getElements($this->creditMemoId); foreach ($creditMemoIds as $creditMemoId) { diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php index f4bc65a75e017..85aa0665414b0 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info.php @@ -7,6 +7,7 @@ namespace Magento\Sales\Test\Block\Adminhtml\Order\View\Tab; use Magento\Backend\Test\Block\Widget\Tab; +use Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info\CommentsHistoryBlock; use Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info\PaymentInfoBlock; /** @@ -28,6 +29,13 @@ class Info extends Tab */ private $paymentInfoBlockSelector = '.order-payment-method'; + /** + * Selector for Comments history block. + * + * @var string + */ + private $commentsHistoryBlockSelector = '#order_history_block'; + /** * Get order status from info block. * @@ -50,4 +58,17 @@ public function getPaymentInfoBlock() ['element' => $this->_rootElement->find($this->paymentInfoBlockSelector)] ); } + + /** + * Returns Comments history block. + * + * @return CommentsHistoryBlock + */ + public function getCommentsHistoryBlock() + { + return $this->blockFactory->create( + CommentsHistoryBlock::class, + ['element' => $this->_rootElement->find($this->commentsHistoryBlockSelector)] + ); + } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info/CommentsHistoryBlock.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info/CommentsHistoryBlock.php new file mode 100644 index 0000000000000..9daed9e87482c --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Info/CommentsHistoryBlock.php @@ -0,0 +1,93 @@ +_rootElement->getElements($this->commentHistory); + foreach ($elements as $key => $item) { + $result[$key] = [ + 'date' => $item->find($this->commentHistoryDate)->getText(), + 'time' => $item->find($this->commentHistoryTime)->getText(), + 'status' => $item->find($this->commentHistoryStatus)->getText(), + 'is_customer_notified' => $item->find($this->commentHistoryNotifiedStatus)->getText(), + 'comment' => '', + ]; + if ($item->find($this->comment)->isVisible()) { + $result[$key]['comment'] = $item->find($this->comment)->getText(); + } + } + + return $result; + } + + /** + * Get last comment. + * + * @return array + */ + public function getLatestComment() + { + $comments = $this->getComments(); + return current($comments); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAcceptPaymentMessageInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAcceptPaymentMessageInCommentsHistory.php index 638558bdb9066..c25485ee006a8 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAcceptPaymentMessageInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAcceptPaymentMessageInCommentsHistory.php @@ -10,34 +10,42 @@ use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; /** - * Class AssertAcceptPaymentMessageInCommentsHistory + * Assert that accept payment message exists in Comments History section on order page in Admin. * - * Constraint checks accept payment message in order comments history */ class AssertAcceptPaymentMessageInCommentsHistory extends AbstractConstraint { - /** + * Accept payment message. + * * @var string */ private static $message = 'Approved the payment online.'; /** - * @param SalesOrderView $orderView + * Assert that accept payment message exists in Comments History section on order page in Admin. + * + * @param SalesOrderView $salesOrderView * @param OrderIndex $orderIndex * @param $orderId + * @return void */ - public function processAssert(SalesOrderView $orderView, OrderIndex $orderIndex, $orderId) + public function processAssert(SalesOrderView $salesOrderView, OrderIndex $orderIndex, $orderId) { $orderIndex->open(); $orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - $history = $orderView->getOrderHistoryBlock()->getCommentsHistory(); - \PHPUnit_Framework_Assert::assertContains(self::$message, $history); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); + + \PHPUnit_Framework_Assert::assertContains(self::$message, $latestComment['comment']); } /** - * @inheritdoc + * Returns a string representation of the object. + * + * @return string */ public function toString() { diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAuthorizationInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAuthorizationInCommentsHistory.php index cfebf8c390502..78e5a3b31c4cd 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAuthorizationInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertAuthorizationInCommentsHistory.php @@ -21,7 +21,7 @@ class AssertAuthorizationInCommentsHistory extends AbstractConstraint const AUTHORIZED_AMOUNT_PATTERN = '/(IPN "Pending" )*Authorized amount of \w*\W{1,2}%s. Transaction ID: "[\w\-]*"/'; /** - * Assert that comment about authorized amount exist in Comments History section on order page in Admin. + * Assert that comment about authorized amount exists in Comments History section on order page in Admin. * * @param SalesOrderView $salesOrderView * @param OrderIndex $salesOrder @@ -37,11 +37,14 @@ public function processAssert( ) { $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - $actualAuthorizedAmount = $salesOrderView->getOrderHistoryBlock()->getAuthorizedAmount(); + + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); \PHPUnit_Framework_Assert::assertRegExp( sprintf(self::AUTHORIZED_AMOUNT_PATTERN, $prices['grandTotal']), - $actualAuthorizedAmount, + $latestComment['comment'], 'Incorrect authorized amount value for the order #' . $orderId ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCaptureInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCaptureInCommentsHistory.php index b4a0c0c875d3c..11087c98bf0f8 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCaptureInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertCaptureInCommentsHistory.php @@ -6,7 +6,6 @@ namespace Magento\Sales\Test\Constraint; -use Magento\Sales\Test\Fixture\OrderInjectable; use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; use Magento\Sales\Test\Page\Adminhtml\OrderIndex; use Magento\Mtf\Constraint\AbstractConstraint; @@ -22,7 +21,7 @@ class AssertCaptureInCommentsHistory extends AbstractConstraint const CAPTURED_AMOUNT_PATTERN = '/^Captured amount of \w*\W{1,2}%s online. Transaction ID: "[\w\-]*"/'; /** - * Assert that comment about captured amount exist in Comments History section on order page in Admin. + * Assert that comment about captured amount exists in Comments History section on order page in Admin. * * @param SalesOrderView $salesOrderView * @param OrderIndex $salesOrder @@ -39,11 +38,21 @@ public function processAssert( $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - $actualCapturedAmount = $salesOrderView->getOrderHistoryBlock()->getCapturedAmount(); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $comments = $infoTab->getCommentsHistoryBlock()->getComments(); + + foreach ($comments as $key => $comment) { + if (strstr($comment['comment'], 'Captured') === false) { + unset($comments[$key]); + } + } + $comments = array_values($comments); + foreach ($capturedPrices as $key => $capturedPrice) { \PHPUnit_Framework_Assert::assertRegExp( sprintf(self::CAPTURED_AMOUNT_PATTERN, $capturedPrice), - $actualCapturedAmount[$key], + $comments[$key]['comment'], 'Incorrect captured amount value for the order #' . $orderId ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertDenyPaymentMessageInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertDenyPaymentMessageInCommentsHistory.php index ca745ffd801d6..ae37d44c877c1 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertDenyPaymentMessageInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertDenyPaymentMessageInCommentsHistory.php @@ -10,33 +10,43 @@ use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; /** - * Class AssertDenyPaymentMessageInCommentsHistory + * Assert that deny payment message exists in Comments History section on order page in Admin. * * Constraint checks deny payment message in order comments history */ class AssertDenyPaymentMessageInCommentsHistory extends AbstractConstraint { /** + * Deny payment message. + * * @var string */ private static $message = 'Denied the payment online'; /** - * @param SalesOrderView $orderView + * Assert that deny payment message exists in Comments History section on order page in Admin. + * + * @param SalesOrderView $salesOrderView * @param OrderIndex $orderIndex * @param $orderId + * @return void */ - public function processAssert(SalesOrderView $orderView, OrderIndex $orderIndex, $orderId) + public function processAssert(SalesOrderView $salesOrderView, OrderIndex $orderIndex, $orderId) { $orderIndex->open(); $orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - $history = $orderView->getOrderHistoryBlock()->getCommentsHistory(); - \PHPUnit_Framework_Assert::assertContains(self::$message, $history); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); + + \PHPUnit_Framework_Assert::assertContains(self::$message, $latestComment['comment']); } /** - * @inheritdoc + * Returns a string representation of the object. + * + * @return string */ public function toString() { diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderCommentsHistoryNotifyStatus.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderCommentsHistoryNotifyStatus.php index ae5b331d2aea5..b99264198c17c 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderCommentsHistoryNotifyStatus.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertOrderCommentsHistoryNotifyStatus.php @@ -11,12 +11,12 @@ use Magento\Sales\Test\Fixture\OrderInjectable; /** - * Class AssertOrderCommentsHistoryNotifyStatus + * Assert that comment has appropriate notification status in Comments History section on order page in Admin. */ class AssertOrderCommentsHistoryNotifyStatus extends AbstractConstraint { /** - * Assert that comment about refunded amount exist in Comments History section on order page in Admin. + * Assert that comment has appropriate notification status in Comments History section on order page in Admin. * * @param SalesOrderView $salesOrderView * @param OrderIndex $salesOrder @@ -35,8 +35,13 @@ public function processAssert( $data['form_data']['send_email'], FILTER_VALIDATE_BOOLEAN ) : false; + + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); + \PHPUnit_Framework_Assert::assertContains( - $salesOrderView->getOrderHistoryBlock()->getNotifiedStatus(), + $latestComment['is_customer_notified'], (bool)$sendMail ? 'Customer Notified' : 'Customer Not Notified' ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCommentsHistory.php index 93fd1e25a5f21..5be581859df8f 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCommentsHistory.php @@ -6,6 +6,7 @@ namespace Magento\Sales\Test\Constraint; +use Magento\Sales\Test\Fixture\OrderInjectable; use Magento\Sales\Test\Page\Adminhtml\SalesOrderView; use Magento\Sales\Test\Page\Adminhtml\OrderIndex; use Magento\Mtf\Constraint\AbstractConstraint; @@ -21,28 +22,39 @@ class AssertRefundInCommentsHistory extends AbstractConstraint const REFUNDED_AMOUNT_PATTERN = '/^We refunded \w*\W{1,2}%s online. Transaction ID: "[\w\-]*"/'; /** - * Assert that comment about refunded amount exist 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 OrderIndex $salesOrder * @param string $orderId - * @param array $refundedPrices * @return void */ public function processAssert( + OrderInjectable $order, SalesOrderView $salesOrderView, OrderIndex $salesOrder, - $orderId, - array $refundedPrices + $orderId ) { $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); - $actualRefundedAmount = $salesOrderView->getOrderHistoryBlock()->getRefundedAmount(); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $comments = $infoTab->getCommentsHistoryBlock()->getComments(); + + foreach ($comments as $key => $comment) { + if (stristr($comment['comment'], 'refunded') === false) { + unset($comments[$key]); + } + } + $comments = array_reverse(array_values($comments)); + + $refundedPrices = $order->getPrice()['refund']; foreach ($refundedPrices as $key => $refundedPrice) { \PHPUnit_Framework_Assert::assertRegExp( - sprintf(self::REFUNDED_AMOUNT_PATTERN, $refundedPrice), - $actualRefundedAmount[$key], + sprintf(self::REFUNDED_AMOUNT_PATTERN, $refundedPrice['grand_creditmemo_total']), + $comments[$key]['comment'], 'Incorrect refunded amount value for the order #' . $orderId ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCreditMemoTab.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCreditMemoTab.php index f5925564af137..74862b6db45f8 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCreditMemoTab.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCreditMemoTab.php @@ -37,7 +37,7 @@ public function processAssert( $salesOrderView->getOrderForm()->openTab('creditmemos'); /** @var Grid $grid */ $grid = $salesOrderView->getOrderForm()->getTab('creditmemos')->getGridBlock(); - $amount = $order->getPrice(); + $amount = $order->getPrice()['refund']; foreach ($ids['creditMemoIds'] as $key => $creditMemoId) { $filter = [ 'id' => $creditMemoId, diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInRefundsGrid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInRefundsGrid.php index c317d7ce7f1c8..e0e13e4bf67ef 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInRefundsGrid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInRefundsGrid.php @@ -11,13 +11,12 @@ 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 { /** - * 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 OrderInjectable $order @@ -27,7 +26,7 @@ class AssertRefundInRefundsGrid extends AbstractConstraint public function processAssert(CreditMemoIndex $creditMemoIndex, OrderInjectable $order, array $ids) { $creditMemoIndex->open(); - $amount = $order->getPrice(); + $amount = $order->getPrice()['refund']; $orderId = $order->getId(); foreach ($ids['creditMemoIds'] as $key => $creditMemoId) { $filter = [ @@ -47,7 +46,7 @@ public function processAssert(CreditMemoIndex $creditMemoIndex, OrderInjectable } /** - * Returns a string representation of the object + * Returns a string representation of the object. * * @return string */ diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundNotInRefundsGrid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundNotInRefundsGrid.php index 54456cdb8b04d..2389239bef045 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundNotInRefundsGrid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundNotInRefundsGrid.php @@ -26,7 +26,7 @@ class AssertRefundNotInRefundsGrid extends AbstractConstraint public function processAssert(CreditMemoIndex $creditMemoIndex, OrderInjectable $order, array $ids) { $creditMemoIndex->open(); - $amount = $order->getPrice(); + $amount = $order->getPrice()['refund']; $orderId = $order->getId(); foreach ($ids['creditMemoIds'] as $key => $creditMemoId) { $filter = [ diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundOrderStatusInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundOrderStatusInCommentsHistory.php index 89a968d6692cf..207c634cabdbe 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundOrderStatusInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundOrderStatusInCommentsHistory.php @@ -11,12 +11,12 @@ use Magento\Sales\Test\Fixture\OrderInjectable; /** - * Assert that comment about refunded amount exist in Comments History section on order page in Admin. + * Assert that comment with correct order status exists in Comments History section on order page in Admin. */ class AssertRefundOrderStatusInCommentsHistory extends AbstractConstraint { /** - * Assert that comment about refunded amount exist in Comments History section on order page in Admin. + * Assert that comment with correct order status exists in Comments History section on order page in Admin. * * @param SalesOrderView $salesOrderView * @param OrderIndex $salesOrder @@ -33,9 +33,11 @@ public function processAssert( /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); + \PHPUnit_Framework_Assert::assertContains( $infoTab->getOrderStatus(), - $salesOrderView->getOrderHistoryBlock()->getStatus() + $latestComment['status'] ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundedGrandTotalOnFrontend.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundedGrandTotalOnFrontend.php index 6e6478cb835d2..fce8f03197419 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundedGrandTotalOnFrontend.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundedGrandTotalOnFrontend.php @@ -12,12 +12,12 @@ 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 { /** - * 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 OrderInjectable $order @@ -38,14 +38,14 @@ public function processAssert( $customerOrderView->getOrderViewBlock()->openLinkByName('Refunds'); foreach ($ids['creditMemoIds'] as $key => $creditMemoId) { \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() ); } } /** - * Returns a string representation of the object + * Returns a string representation of the object. * * @return string */ diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertVoidInCommentsHistory.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertVoidInCommentsHistory.php index 6175ef03e2c4e..0c2a723506953 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertVoidInCommentsHistory.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertVoidInCommentsHistory.php @@ -21,7 +21,7 @@ class AssertVoidInCommentsHistory extends AbstractConstraint const VOIDED_AMOUNT = 'Voided authorization. Amount: $'; /** - * Assert that comment about voided amount exist in Comments History section on order page in Admin. + * Assert that comment about voided amount exists in Comments History section on order page in Admin. * * @param SalesOrderView $salesOrderView * @param OrderIndex $salesOrder @@ -38,9 +38,13 @@ public function processAssert( $salesOrder->open(); $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */ + $infoTab = $salesOrderView->getOrderForm()->openTab('info')->getTab('info'); + $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment(); + \PHPUnit_Framework_Assert::assertContains( self::VOIDED_AMOUNT . $prices['grandTotal'], - $salesOrderView->getOrderHistoryBlock()->getVoidedAmount(), + $latestComment['comment'], 'Incorrect voided amount value for the order #' . $orderId ); } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable.xml index 8bd7261eb2d9e..2abd9f70bcfd9 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Fixture/OrderInjectable.xml @@ -206,5 +206,6 @@ + diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/SalesOrderView.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/SalesOrderView.xml index 057acf52bb51c..6d1aceb70bf4f 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/SalesOrderView.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Page/Adminhtml/SalesOrderView.xml @@ -13,7 +13,6 @@ - diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Repository/OrderInjectable/Price.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/Repository/OrderInjectable/Price.xml index ce1774bcd35ea..4d8f8ad44c1f3 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Repository/OrderInjectable/Price.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Repository/OrderInjectable/Price.xml @@ -34,20 +34,27 @@ - - 565 + + + 565 + - - 555 + + + 555 + + - - 110 + + + 110 + @@ -59,8 +66,12 @@ + + + 565 + + - 565 565 565 diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateOnlineCreditMemoStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateOnlineCreditMemoStep.php index c0edef812197c..691d9e5c87d45 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateOnlineCreditMemoStep.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateOnlineCreditMemoStep.php @@ -6,6 +6,7 @@ namespace Magento\Sales\Test\TestStep; +use Magento\Checkout\Test\Fixture\Cart; use Magento\Mtf\TestStep\TestStepInterface; use Magento\Sales\Test\Fixture\OrderInjectable; use Magento\Sales\Test\Page\Adminhtml\OrderCreditMemoNew; @@ -61,7 +62,14 @@ class CreateOnlineCreditMemoStep implements TestStepInterface private $orderInvoiceView; /** - * @construct + * Checkout Cart fixture. + * + * @var Cart + */ + private $cart; + + /** + * @param Cart $cart * @param OrderIndex $orderIndex * @param SalesOrderView $salesOrderView * @param OrderInjectable $order @@ -70,6 +78,7 @@ class CreateOnlineCreditMemoStep implements TestStepInterface * @param array|null refundData [optional] */ public function __construct( + Cart $cart, OrderIndex $orderIndex, SalesOrderView $salesOrderView, OrderInjectable $order, @@ -77,12 +86,13 @@ public function __construct( OrderCreditMemoNew $orderCreditMemoNew, $refundData = null ) { + $this->cart = $cart; $this->orderIndex = $orderIndex; $this->salesOrderView = $salesOrderView; $this->order = $order; + $this->orderInvoiceView = $orderInvoiceView; $this->orderCreditMemoNew = $orderCreditMemoNew; $this->refundData = $refundData; - $this->orderInvoiceView = $orderInvoiceView; } /** @@ -94,19 +104,20 @@ public function run() { $this->orderIndex->open(); $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]); - /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Invoices\Grid $invoicesGrid */ - $invoicesGrid = $this->salesOrderView->getOrderForm()->getTab('invoices')->getGridBlock(); - $this->salesOrderView->getOrderForm()->openTab('invoices'); - $invoicesGrid->viewInvoice(); - $this->salesOrderView->getPageActions()->orderInvoiceCreditMemo(); - if (!empty($this->refundData)) { + $refundsData = $this->order->getRefund(); + foreach ($refundsData as $refundData) { + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Invoices\Grid $invoicesGrid */ + $invoicesGrid = $this->salesOrderView->getOrderForm()->getTab('invoices')->getGridBlock(); + $this->salesOrderView->getOrderForm()->openTab('invoices'); + $invoicesGrid->viewInvoice(); + $this->salesOrderView->getPageActions()->orderInvoiceCreditMemo(); $this->orderCreditMemoNew->getFormBlock()->fillProductData( - $this->refundData, - $this->order->getEntityId()['products'] + $refundData, + $this->cart->getItems() ); $this->orderCreditMemoNew->getFormBlock()->updateQty(); + $this->orderCreditMemoNew->getFormBlock()->submit(); } - $this->orderCreditMemoNew->getFormBlock()->submit(); return ['ids' => ['creditMemoIds' => $this->getCreditMemoIds()]]; } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/SubmitOrderStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/SubmitOrderStep.php index f28cf6bf6aa76..4688fb9778738 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/SubmitOrderStep.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/SubmitOrderStep.php @@ -61,7 +61,6 @@ class SubmitOrderStep implements TestStepInterface private $products; /** - * @constructor * @param OrderCreateIndex $orderCreateIndex * @param SalesOrderView $salesOrderView * @param FixtureFactory $fixtureFactory diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.php b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.php index ee26e2f1e28ec..dd5937fc47705 100644 --- a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.php +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form.php @@ -74,7 +74,7 @@ public function fillData(array $data, $products = null) } 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]); } } } diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items.php b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items.php index bc2fef9239ce9..0cdb42e03b910 100644 --- a/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items.php +++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/Block/Adminhtml/Form/Items.php @@ -9,7 +9,6 @@ use Magento\Sales\Test\Block\Adminhtml\Order\AbstractItemsNewBlock; use Magento\Shipping\Test\Block\Adminhtml\Form\Items\Product; use Magento\Mtf\Client\Locator; -use Magento\Mtf\Fixture\FixtureInterface; /** * Adminhtml items to ship block. @@ -19,12 +18,12 @@ class Items extends AbstractItemsNewBlock /** * Get item product block. * - * @param FixtureInterface $product + * @param string $productSku * @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( \Magento\Shipping\Test\Block\Adminhtml\Form\Items\Product::class, ['element' => $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)] diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Block/Product/ProductList/ProductItem.php b/dev/tests/functional/tests/app/Magento/Swatches/Test/Block/Product/ProductList/ProductItem.php index d7669fbb1feef..3a123d4fbe848 100755 --- a/dev/tests/functional/tests/app/Magento/Swatches/Test/Block/Product/ProductList/ProductItem.php +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Block/Product/ProductList/ProductItem.php @@ -36,7 +36,9 @@ public function fillData(\Magento\ConfigurableProduct\Test\Fixture\ConfigurableP $attributes = $confAttrSource->getAttributes(); foreach ($options as $option) { - if (!isset($attributes[$option['title']])) { + if (!isset($attributes[$option['title']]) + || stripos($attributes[$option['title']]->getFrontendInput(), "swatch") === false + ) { continue; } $availableOptions = $attributes[$option['title']]->getOptions(); diff --git a/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/ConfigurableProduct/CheckoutData.xml b/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/ConfigurableProduct/CheckoutData.xml index 7e571be1129f8..183890a130f14 100644 --- a/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/ConfigurableProduct/CheckoutData.xml +++ b/dev/tests/functional/tests/app/Magento/Swatches/Test/Repository/ConfigurableProduct/CheckoutData.xml @@ -34,6 +34,10 @@ attribute_key_0 option_key_1 + + attribute_key_1 + option_key_1 + 1