From e4a382f27488ed549861b153b99f519488a15fd0 Mon Sep 17 00:00:00 2001 From: rliukshyn Date: Thu, 3 Mar 2016 20:19:42 +0200 Subject: [PATCH 01/27] MAGETWO-48211: Create functional tests for creating online refunds --- .../Braintree/Test/Repository/ConfigData.xml | 52 +++++++ .../CreateOnlineCreditMemoBraintreeTest.php | 50 +++++++ .../CreateOnlineCreditMemoBraintreeTest.xml | 37 +++++ .../CreateBraintreeCreditMemoStep.php | 141 ++++++++++++++++++ .../app/Magento/Braintree/Test/etc/di.xml | 10 ++ .../Magento/Braintree/Test/etc/testcase.xml | 16 ++ .../Checkout/Test/TestStep/PlaceOrderStep.php | 29 +++- .../Test/Block/Adminhtml/Order/History.php | 23 +++ .../Order/View/Tab/Invoices/Grid.php | 20 +++ .../AssertRefundInCommentsHistory.php | 60 ++++++++ 10 files changed, 437 insertions(+), 1 deletion(-) create mode 100644 dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreeTest.php create mode 100644 dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreeTest.xml create mode 100644 dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/CreateBraintreeCreditMemoStep.php create mode 100644 dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCommentsHistory.php diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/ConfigData.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/ConfigData.xml index 95cecff4a3d92..d60a0c012b37a 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/ConfigData.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/Repository/ConfigData.xml @@ -59,6 +59,58 @@ 0 + + + payment + 1 + + PAYMENT_BRAINTREETWO_MERCHANT_ID + + + payment + 1 + + PAYMENT_PAYMENT_BRAINTREETWO_PUBLIC_KEY + + + payment + 1 + + PAYMENT_BRAINTREETWO_PRIVATE_KEY + + + payment + 1 + Yes + PAYMENT_BRAINTREETWO_MERCHANT_ACCOUNT_ID + + + payment + 1 + Authorize and Capture + authorize_capture + + + payment + 1 + Yes + 1 + + + payment + 1 + Yes + 1 + + + + + payment + 1 + Yes + 0 + + payment 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..dc2ae8879a3cd --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreeTest.php @@ -0,0 +1,50 @@ +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..4897fb594fb8b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreeTest.xml @@ -0,0 +1,37 @@ + + + + + + Refund an order placed through Braintree with full capture + catalogProductSimple::product_10_dollar, bundleProduct::bundle_fixed_100_dollar_product + default + login + us_ca_ny_rule + + 139.9 + + US_address_1_without_email + Flat Rate + Fixed + braintreetwo + credit_card_braintree + visa_braintree + braintreetwo_sale + Processing + Back, Send Email, Credit Memo, Hold, Ship, Reorder + - + default + partial_refund + test_type:3rd_party_test + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/CreateBraintreeCreditMemoStep.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/CreateBraintreeCreditMemoStep.php new file mode 100644 index 0000000000000..1a61633413df5 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/CreateBraintreeCreditMemoStep.php @@ -0,0 +1,141 @@ +orderIndex = $orderIndex; + $this->salesOrderView = $salesOrderView; + $this->order = $order; + $this->orderCreditMemoNew = $orderCreditMemoNew; + $this->data = $data; + $this->gateway = $gateway; + $this->orderInvoiceView = $orderInvoiceView; + } + + /** + * Create credit memo. + * + * @return array + */ + public function run() + { + $transactionId = ''; + $this->orderIndex->open(); + $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]); + $comment = $this->salesOrderView->getOrderHistoryBlock()->getCommentsHistory(); + preg_match('/(ID: ")(\w+-*\w+)(")/', $comment, $matches); + if (!empty($matches[2])) { + $transactionId = $matches[2]; + } + $this->gateway->testing()->settle($transactionId); + /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Invoices\Grid $invoicesGrid */ + $invoicesGrid = $this->salesOrderView->getOrderForm()->getTab('invoices')->getGridBlock(); + foreach ($invoiceIds = $invoicesGrid->getIds() as $invoiceId) { + $this->salesOrderView->getOrderForm()->openTab('invoices'); + $invoicesGrid->viewInvoice($invoiceId); + $this->salesOrderView->getPageActions()->orderInvoiceCreditMemo(); + if (!empty($this->data)) { + $this->orderCreditMemoNew->getFormBlock()->fillProductData( + $this->data, + $this->order->getEntityId()['products'] + ); + $this->orderCreditMemoNew->getFormBlock()->updateQty(); + $this->orderCreditMemoNew->getFormBlock()->fillFormData($this->data); + } + $this->orderCreditMemoNew->getFormBlock()->submit(); + } + + return ['ids' => ['creditMemoIds' => $this->getCreditMemoIds()]]; + } + + /** + * Get credit memo ids. + * + * @return array + */ + protected function getCreditMemoIds() + { + $this->salesOrderView->getOrderForm()->openTab('creditmemos'); + return $this->salesOrderView->getOrderForm()->getTab('creditmemos')->getGridBlock()->getIds(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/di.xml index cb11b8cd3ce55..98fe882a465af 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/di.xml @@ -16,4 +16,14 @@ high + + + + sandbox + d4pdjhxgjfrsmzbf + ryygybnwzfqjg3xw + dbqzcm6bmq7n5nyb + + + 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 fd4564dc13674..f7d2c85000b21 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 @@ -62,4 +62,20 @@ + + + + + + + + + + + + + + + + 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 92cdc7b5546bb..0d305eeea683b 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 @@ -9,6 +9,7 @@ use Magento\Checkout\Test\Constraint\AssertGrandTotalOrderReview; use Magento\Checkout\Test\Page\CheckoutOnepage; use Magento\Checkout\Test\Page\CheckoutOnepageSuccess; +use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\TestStep\TestStepInterface; /** @@ -44,23 +45,38 @@ class PlaceOrderStep implements TestStepInterface */ protected $prices; + /** + * @var FixtureFactory + */ + private $fixtureFactory; + /** + * @var array + */ + private $products; + /** * @construct * @param CheckoutOnepage $checkoutOnepage * @param AssertGrandTotalOrderReview $assertGrandTotalOrderReview * @param CheckoutOnepageSuccess $checkoutOnepageSuccess + * @param FixtureFactory $fixtureFactory + * @param array $products * @param array $prices */ public function __construct( CheckoutOnepage $checkoutOnepage, AssertGrandTotalOrderReview $assertGrandTotalOrderReview, CheckoutOnepageSuccess $checkoutOnepageSuccess, + FixtureFactory $fixtureFactory, + array $products, array $prices = [] ) { $this->checkoutOnepage = $checkoutOnepage; $this->assertGrandTotalOrderReview = $assertGrandTotalOrderReview; $this->prices = $prices; $this->checkoutOnepageSuccess = $checkoutOnepageSuccess; + $this->fixtureFactory = $fixtureFactory; + $this->products = $products; } /** @@ -74,7 +90,18 @@ public function run() $this->assertGrandTotalOrderReview->processAssert($this->checkoutOnepage, $this->prices['grandTotal']); } $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder(); + $order = $this->fixtureFactory->createByCode( + 'orderInjectable', + [ + 'data' => [ + 'entity_id' => ['products' => $this->products] + ] + ] + ); - return ['orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId()]; + return [ + 'orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(), + 'order' => $order + ]; } } 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 index 25ed6613a8e09..56f8d44d07635 100644 --- 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 @@ -28,6 +28,13 @@ class History extends Block */ protected $capturedAmount = '//div[@class="note-list-comment"][contains(text(), "Captured amount of")]'; + /** + * Refunded Amount. + * + * @var string + */ + protected $refundedAmount = '//div[@class="note-list-comment"][contains(text(), "We refunded")]'; + /** * Note list locator. * @@ -62,6 +69,22 @@ public function getCapturedAmount() 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; + } + /** * Wait for comments history is visible. * diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php index 1b697a839740b..ee358834104fc 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php @@ -18,6 +18,15 @@ class Grid extends \Magento\Backend\Test\Block\Widget\Grid */ protected $editLink = '[data-column="increment_id"]'; + /** + * Invoice 'View' link. + * + * @var string + */ + protected $invoiceViewLink = 'a.action-menu-item[href$="invoice_id/%d/"]'; + + /** + /** * Locator for invoice ids * @@ -61,4 +70,15 @@ public function getIds() return $result; } + + + /** + * Click the 'View' link for invoice in Invoices grid. + * + * @param $invoiceId + */ + public function viewInvoice($invoiceId) + { + $this->_rootElement->find(sprintf($this->invoiceViewLink, $invoiceId))->click(); + } } 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 new file mode 100644 index 0000000000000..820e8bd2cb78e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Constraint/AssertRefundInCommentsHistory.php @@ -0,0 +1,60 @@ +open(); + $salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $orderId]); + + $actualRefundedAmount = $salesOrderView->getOrderHistoryBlock()->getRefundedAmount(); + foreach ($refundedPrices as $key => $refundedPrice) { + \PHPUnit_Framework_Assert::assertContains( + self::REFUNDED_AMOUNT . $refundedPrice, + $actualRefundedAmount[$key], + 'Incorrect refunded amount value for the order #' . $orderId + ); + } + } + + /** + * Returns string representation of successful assertion. + * + * @return string + */ + public function toString() + { + return "Message about refunded amount is available in Comments History section."; + } +} From 0b401a0fbbd867c9d4b601d3c4734b289940d5e7 Mon Sep 17 00:00:00 2001 From: rliukshyn Date: Fri, 11 Mar 2016 17:09:33 +0200 Subject: [PATCH 02/27] MAGETWO-48211: Create functional tests for creating online refunds - CR changes --- ...teOnlineCreditMemoBraintreePaypalTest.php} | 0 ...ateOnlineCreditMemoBraintreePaypalTest.xml | 55 +++++++++++ .../CreateOnlineCreditMemoBraintreeTest.xml | 37 ------- .../CreateBraintreeCreditMemoStep.php | 60 +++++------ .../TestStep/PlaceOrderWithPaypalStep.php | 30 +++++- .../Magento/Braintree/Test/etc/testcase.xml | 99 ++++++++++--------- .../Order/View/Tab/Invoices/Grid.php | 13 +-- .../Sales/Test/TestStep/CreateInvoiceStep.php | 33 +++++-- 8 files changed, 183 insertions(+), 144 deletions(-) rename dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/{CreateOnlineCreditMemoBraintreeTest.php => CreateOnlineCreditMemoBraintreePaypalTest.php} (100%) create mode 100644 dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.xml delete mode 100644 dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreeTest.xml diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreeTest.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.php similarity index 100% rename from dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreeTest.php rename to dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.php 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 new file mode 100644 index 0000000000000..cecb7c2743e49 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.xml @@ -0,0 +1,55 @@ + + + + + + catalogProductSimple::product_10_dollar, bundleProduct::bundle_fixed_100_dollar_product + default + login + us_ca_ny_rule + + 139.9 + + US_address_1_without_email + Flat Rate + Fixed + braintreetwo_paypal + braintreetwo, braintreetwo_paypal_sale + sale + Back, Send Email, Credit Memo, Hold, Ship, Reorder + - + test_type:3rd_party_test + + + + + + catalogProductSimple::simple_for_sales + default + login + us_ca_ny_rule + + 621.2 + + US_address_1_without_email + Flat Rate + Fixed + braintreetwo_paypal + braintreetwo, braintreetwo_paypal + Back, Send Email, Credit Memo, Hold, Ship, Reorder + 2 + 1 + default + Yes + test_type:3rd_party_test + + + + + + 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 deleted file mode 100644 index 4897fb594fb8b..0000000000000 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreeTest.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - Refund an order placed through Braintree with full capture - catalogProductSimple::product_10_dollar, bundleProduct::bundle_fixed_100_dollar_product - default - login - us_ca_ny_rule - - 139.9 - - US_address_1_without_email - Flat Rate - Fixed - braintreetwo - credit_card_braintree - visa_braintree - braintreetwo_sale - Processing - Back, Send Email, Credit Memo, Hold, Ship, Reorder - - - default - partial_refund - test_type:3rd_party_test - - - - - - diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/CreateBraintreeCreditMemoStep.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/CreateBraintreeCreditMemoStep.php index 1a61633413df5..32869a3860e7b 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/CreateBraintreeCreditMemoStep.php +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/CreateBraintreeCreditMemoStep.php @@ -6,6 +6,8 @@ namespace Magento\Braintree\Test\TestStep; +use Magento\Config\Test\Fixture\ConfigData; +use Magento\Mtf\ObjectManager; use Magento\Sales\Test\Fixture\OrderInjectable; use Magento\Sales\Test\Page\Adminhtml\OrderCreditMemoNew; use Magento\Sales\Test\Page\Adminhtml\OrderIndex; @@ -24,42 +26,39 @@ class CreateBraintreeCreditMemoStep implements TestStepInterface * * @var OrderIndex */ - protected $orderIndex; + private $orderIndex; /** * Order View Page. * * @var SalesOrderView */ - protected $salesOrderView; + private $salesOrderView; /** * OrderCreditMemoNew Page. * * @var OrderCreditMemoNew */ - protected $orderCreditMemoNew; + private $orderCreditMemoNew; /** * OrderInjectable fixture. * * @var OrderInjectable */ - protected $order; + private $order; /** * Credit memo data. * * @var array|null */ - protected $data; - - /** - * @var Gateway - */ - private $gateway; + private $refundData; /** + * Order invoice view page. + * * @var OrderInvoiceView */ private $orderInvoiceView; @@ -71,8 +70,7 @@ class CreateBraintreeCreditMemoStep implements TestStepInterface * @param OrderInjectable $order * @param OrderInvoiceView $orderInvoiceView * @param OrderCreditMemoNew $orderCreditMemoNew - * @param Gateway $gateway - * @param array|null $data [optional] + * @param array|null refundData [optional] */ public function __construct( OrderIndex $orderIndex, @@ -80,15 +78,13 @@ public function __construct( OrderInjectable $order, OrderInvoiceView $orderInvoiceView, OrderCreditMemoNew $orderCreditMemoNew, - Gateway $gateway, - $data = null + $refundData = null ) { $this->orderIndex = $orderIndex; $this->salesOrderView = $salesOrderView; $this->order = $order; $this->orderCreditMemoNew = $orderCreditMemoNew; - $this->data = $data; - $this->gateway = $gateway; + $this->refundData = $refundData; $this->orderInvoiceView = $orderInvoiceView; } @@ -99,31 +95,21 @@ public function __construct( */ public function run() { - $transactionId = ''; $this->orderIndex->open(); $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]); - $comment = $this->salesOrderView->getOrderHistoryBlock()->getCommentsHistory(); - preg_match('/(ID: ")(\w+-*\w+)(")/', $comment, $matches); - if (!empty($matches[2])) { - $transactionId = $matches[2]; - } - $this->gateway->testing()->settle($transactionId); /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Invoices\Grid $invoicesGrid */ $invoicesGrid = $this->salesOrderView->getOrderForm()->getTab('invoices')->getGridBlock(); - foreach ($invoiceIds = $invoicesGrid->getIds() as $invoiceId) { - $this->salesOrderView->getOrderForm()->openTab('invoices'); - $invoicesGrid->viewInvoice($invoiceId); - $this->salesOrderView->getPageActions()->orderInvoiceCreditMemo(); - if (!empty($this->data)) { - $this->orderCreditMemoNew->getFormBlock()->fillProductData( - $this->data, - $this->order->getEntityId()['products'] - ); - $this->orderCreditMemoNew->getFormBlock()->updateQty(); - $this->orderCreditMemoNew->getFormBlock()->fillFormData($this->data); - } - $this->orderCreditMemoNew->getFormBlock()->submit(); + $this->salesOrderView->getOrderForm()->openTab('invoices'); + $invoicesGrid->viewInvoice(); + $this->salesOrderView->getPageActions()->orderInvoiceCreditMemo(); + if (!empty($this->refundData)) { + $this->orderCreditMemoNew->getFormBlock()->fillProductData( + $this->refundData, + $this->order->getEntityId()['products'] + ); + $this->orderCreditMemoNew->getFormBlock()->updateQty(); } + $this->orderCreditMemoNew->getFormBlock()->submit(); return ['ids' => ['creditMemoIds' => $this->getCreditMemoIds()]]; } @@ -133,7 +119,7 @@ public function run() * * @return array */ - protected function getCreditMemoIds() + private function getCreditMemoIds() { $this->salesOrderView->getOrderForm()->openTab('creditmemos'); return $this->salesOrderView->getOrderForm()->getTab('creditmemos')->getGridBlock()->getIds(); 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 f81071070a123..ae671182b1f8c 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 @@ -8,6 +8,7 @@ use Magento\Checkout\Test\Constraint\AssertGrandTotalOrderReview; use Magento\Checkout\Test\Page\CheckoutOnepage; use Magento\Checkout\Test\Page\CheckoutOnepageSuccess; +use Magento\Mtf\Fixture\FixtureFactory; use Magento\Mtf\TestStep\TestStepInterface; /** @@ -35,21 +36,37 @@ class PlaceOrderWithPaypalStep implements TestStepInterface */ private $prices; + /** + * @var FixtureFactory + */ + private $fixtureFactory; + + /** + * @var array + */ + private $products; + /** * @param CheckoutOnepage $checkoutOnepage * @param AssertGrandTotalOrderReview $assertGrandTotalOrderReview * @param CheckoutOnepageSuccess $checkoutOnepageSuccess + * @param FixtureFactory $fixtureFactory + * @param array $products * @param array $prices */ public function __construct( CheckoutOnepage $checkoutOnepage, AssertGrandTotalOrderReview $assertGrandTotalOrderReview, CheckoutOnepageSuccess $checkoutOnepageSuccess, + FixtureFactory $fixtureFactory, + array $products, array $prices = [] ) { $this->checkoutOnepage = $checkoutOnepage; $this->assertGrandTotalOrderReview = $assertGrandTotalOrderReview; $this->checkoutOnepageSuccess = $checkoutOnepageSuccess; + $this->fixtureFactory = $fixtureFactory; + $this->products = $products; $this->prices = $prices; } @@ -63,6 +80,17 @@ public function run() } $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock()->clickPlaceOrder(); $this->checkoutOnepage->getBraintreePaypalBlock()->process(); - return ['orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId()]; + $order = $this->fixtureFactory->createByCode( + 'orderInjectable', + [ + 'data' => [ + 'entity_id' => ['products' => $this->products] + ] + ] + ); + return [ + 'orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(), + 'order' => $order + ]; } } 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 86f3fd5147bc2..b927985513865 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 @@ -7,60 +7,60 @@ --> - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - - - - - - - - + + + + + + + + + + + + @@ -71,7 +71,7 @@ - + @@ -83,8 +83,9 @@ - - + + + diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php index ee358834104fc..e1834b447f86a 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php @@ -18,13 +18,6 @@ class Grid extends \Magento\Backend\Test\Block\Widget\Grid */ protected $editLink = '[data-column="increment_id"]'; - /** - * Invoice 'View' link. - * - * @var string - */ - protected $invoiceViewLink = 'a.action-menu-item[href$="invoice_id/%d/"]'; - /** /** @@ -75,10 +68,10 @@ public function getIds() /** * Click the 'View' link for invoice in Invoices grid. * - * @param $invoiceId + * @return void */ - public function viewInvoice($invoiceId) + public function viewInvoice() { - $this->_rootElement->find(sprintf($this->invoiceViewLink, $invoiceId))->click(); + $this->_rootElement->find($this->invoiceId)->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateInvoiceStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateInvoiceStep.php index 2840263ad9a86..77ed5418b38cd 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateInvoiceStep.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateInvoiceStep.php @@ -24,56 +24,63 @@ class CreateInvoiceStep implements TestStepInterface * * @var OrderIndex */ - protected $orderIndex; + private $orderIndex; /** * Order View Page. * * @var SalesOrderView */ - protected $salesOrderView; + private $salesOrderView; /** * Order New Invoice Page. * * @var OrderInvoiceNew */ - protected $orderInvoiceNew; + private $orderInvoiceNew; /** * Order invoice view page. * * @var OrderInvoiceView */ - protected $orderInvoiceView; + private $orderInvoiceView; /** * Order shipment view page. * * @var OrderShipmentView */ - protected $orderShipmentView; + private $orderShipmentView; /** * OrderInjectable fixture. * * @var OrderInjectable */ - protected $order; + private $order; /** * Invoice data. * * @var array|null */ - protected $data; + private $data; /** * Whether Invoice is partial. * * @var string */ - protected $isInvoicePartial; + private $isInvoicePartial; + + /** + * Payment Action. + * + * @var string + */ + private $paymentAction; /** * @construct @@ -85,6 +92,7 @@ class CreateInvoiceStep implements TestStepInterface * @param OrderShipmentView $orderShipmentView * @param array|null $data [optional] * @param string $isInvoicePartial [optional] + * @param string $paymentAction */ public function __construct( OrderIndex $orderIndex, @@ -94,7 +102,8 @@ public function __construct( OrderInjectable $order, OrderShipmentView $orderShipmentView, $data = null, - $isInvoicePartial = null + $isInvoicePartial = null, + $paymentAction = 'authorize' ) { $this->orderIndex = $orderIndex; $this->salesOrderView = $salesOrderView; @@ -104,15 +113,19 @@ public function __construct( $this->orderShipmentView = $orderShipmentView; $this->data = $data; $this->isInvoicePartial = $isInvoicePartial; + $this->paymentAction = $paymentAction; } /** - * Create invoice (with shipment optionally) for order on backend. + * Create invoice (with shipment optionally) for order in Admin. * * @return array */ public function run() { + if ($this->paymentAction == 'sale') { + return null; + } $this->orderIndex->open(); $this->orderIndex->getSalesOrderGrid()->searchAndOpen(['id' => $this->order->getId()]); $this->salesOrderView->getPageActions()->invoice(); From abb9b79a6b3fb41e5a750314801e593ebbe6dd2f Mon Sep 17 00:00:00 2001 From: rliukshyn Date: Fri, 11 Mar 2016 17:14:27 +0200 Subject: [PATCH 03/27] MAGETWO-48211: Create functional tests for creating online refunds - Removed braintree config from di.xml --- .../tests/app/Magento/Braintree/Test/etc/di.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/di.xml index 98fe882a465af..cb11b8cd3ce55 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/etc/di.xml @@ -16,14 +16,4 @@ high - - - - sandbox - d4pdjhxgjfrsmzbf - ryygybnwzfqjg3xw - dbqzcm6bmq7n5nyb - - - From cd282e13d27395f10716c7b7227245b3dd21e65e Mon Sep 17 00:00:00 2001 From: rliukshyn Date: Fri, 11 Mar 2016 18:42:31 +0200 Subject: [PATCH 04/27] MAGETWO-48211: Create functional tests for creating online refunds - Fixed static tests --- .../app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php | 1 + .../Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) 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 0d305eeea683b..34679f8df5394 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 @@ -49,6 +49,7 @@ class PlaceOrderStep implements TestStepInterface * @var FixtureFactory */ private $fixtureFactory; + /** * @var array */ diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php index e1834b447f86a..615cc33738595 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/View/Tab/Invoices/Grid.php @@ -18,8 +18,6 @@ class Grid extends \Magento\Backend\Test\Block\Widget\Grid */ protected $editLink = '[data-column="increment_id"]'; - /** - /** * Locator for invoice ids * @@ -64,7 +62,6 @@ public function getIds() return $result; } - /** * Click the 'View' link for invoice in Invoices grid. * From 8ecdc711404b4cf385e364692b8d202ae8751302 Mon Sep 17 00:00:00 2001 From: rliukshyn Date: Mon, 14 Mar 2016 12:33:01 +0200 Subject: [PATCH 05/27] MAGETWO-48211: Create functional tests for creating online refunds - Fixed static tests, phpdoc --- ...ateOnlineCreditMemoBraintreePaypalTest.php | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.php index dc2ae8879a3cd..40c4ce644c3ad 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.php +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.php @@ -9,28 +9,18 @@ /** * Preconditions: - * 1. Configure shipping method. - * 2. Configure payment method. - * 3. Create products. - * 4. Create and setup customer. - * 5. Create tax rule according to dataset. + * 1. PLace order via Briantree PayPal. * * Steps: - * 1. Log in Storefront. - * 2. Add products to the Shopping Cart. - * 3. Go to one page checkout. - * 4. Select a shipping method. - * 5. Select a payment method. - * 6. Click 'Place Order' button. - * 7. Log in to Admin. - * 8. Open created order. - * 9. Create credit memo. - * 12. Perform assertions. + * 1. Log in to Admin. + * 2. Open created order. + * 3. Create credit memo. + * 4. Perform assertions. * * @group Braintree_(CS) - * @ZephyrId MAGETWO-39363 + * @ZephyrId MAGETWO-48689, MAGETWO-48698 */ -class CreateOnlineCreditMemoBraintreeTest extends Scenario +class CreateOnlineCreditMemoBraintreePaypalTest extends Scenario { /* tags */ const MVP = 'yes'; @@ -39,7 +29,7 @@ class CreateOnlineCreditMemoBraintreeTest extends Scenario /* end tags */ /** - * Runs test for online credit memo creation for order placed via Braintree caredit card. + * Runs test for online credit memo creation for order placed via Braintree PayPal. * * @return void */ From b499b04a41b24101b8ce4b314ba83ace87ef5b91 Mon Sep 17 00:00:00 2001 From: rliukshyn Date: Wed, 30 Mar 2016 12:59:22 +0000 Subject: [PATCH 06/27] MAGETWO-48211: Create functional tests for creating online refunds - Fixed copyright --- .../Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.php index 40c4ce644c3ad..f45270012dd39 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.php +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.php @@ -1,6 +1,6 @@ Date: Thu, 31 Mar 2016 09:31:14 +0000 Subject: [PATCH 07/27] MAGETWO-48211: Create functional tests for creating online refunds - Fixed copyright --- .../Test/TestCase/CreateOnlineCreditMemoBraintreePaypalTest.xml | 2 +- .../Braintree/Test/TestStep/CreateBraintreeCreditMemoStep.php | 2 +- .../Sales/Test/Constraint/AssertRefundInCommentsHistory.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 cecb7c2743e49..2e189409174a6 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 @@ -1,7 +1,7 @@ diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/CreateBraintreeCreditMemoStep.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/CreateBraintreeCreditMemoStep.php index 32869a3860e7b..61455ceaac4fd 100644 --- a/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/CreateBraintreeCreditMemoStep.php +++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/TestStep/CreateBraintreeCreditMemoStep.php @@ -1,6 +1,6 @@ Date: Thu, 14 Apr 2016 16:05:01 +0000 Subject: [PATCH 08/27] MAGETWO-51173: "Create Cart Price Rule" test fails on waiting Shipping Price block --- .../AssertCartPriceRuleConditionIsApplied.php | 4 +-- .../TestCase/CreateSalesRuleEntityTest.xml | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleConditionIsApplied.php b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleConditionIsApplied.php index 53446ed1a58ec..8c0660089dd19 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleConditionIsApplied.php +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/Constraint/AssertCartPriceRuleConditionIsApplied.php @@ -7,12 +7,12 @@ namespace Magento\SalesRule\Test\Constraint; /** - * Assert that Catalog Price Rule is applied in Shopping Cart. + * Assert that Cart Price Rule is applied in Shopping Cart. */ class AssertCartPriceRuleConditionIsApplied extends AssertCartPriceRuleApplying { /** - * Assert that Catalog Price Rule is applied in Shopping Cart. + * Assert that Cart Price Rule is applied in Shopping Cart. * * @return void */ diff --git a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.xml b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.xml index 8b9303579b201..bfa18c65bdcf8 100644 --- a/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/SalesRule/Test/TestCase/CreateSalesRuleEntityTest.xml @@ -22,6 +22,11 @@ 100.00 55.00 50.00 + United States + California + 95814 + Flat Rate + Fixed simple_for_salesrule_1 1 @@ -29,6 +34,11 @@ + United States + California + 95814 + Flat Rate + Fixed Cart Price Rule2 %isolation% Cart Price Rule Description %isolation% Yes @@ -51,6 +61,11 @@ + United States + California + 95814 + Flat Rate + Fixed Cart Price Rule3 %isolation% Cart Price Rule Description %isolation% Yes @@ -73,6 +88,11 @@ + United States + California + 95814 + Flat Rate + Fixed Cart Price Rule4 %isolation% Cart Price Rule Description %isolation% Yes @@ -96,6 +116,11 @@ + United States + California + 95814 + Flat Rate + Fixed test_type:extended_acceptance_test 1 default From 6773d9044f11628b8f6144002992a3cb639ea1a6 Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Fri, 15 Apr 2016 14:06:58 +0300 Subject: [PATCH 09/27] MAGETWO-48372: Billing Agreement popup doesn't appear on product page after clicking on Checkout with Express button --- .../Magento/Paypal/Block/Express/Shortcut.php | 32 ------ .../Paypal/CustomerData/BillingAgreement.php | 107 ++++++++++++++++++ .../CustomerData/BillingAgreementTest.php | 102 +++++++++++++++++ app/code/Magento/Paypal/etc/frontend/di.xml | 12 ++ .../templates/billing/agreement/view.phtml | 10 +- .../onepage/success/billing_agreement.phtml | 2 +- .../frontend/templates/express/shortcut.phtml | 6 +- .../web/js/in-context/billing-agreement.js | 47 ++++++++ .../view/frontend/web/js/paypal-checkout.js | 12 +- 9 files changed, 283 insertions(+), 47 deletions(-) create mode 100644 app/code/Magento/Paypal/CustomerData/BillingAgreement.php create mode 100644 app/code/Magento/Paypal/Test/Unit/CustomerData/BillingAgreementTest.php create mode 100644 app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js diff --git a/app/code/Magento/Paypal/Block/Express/Shortcut.php b/app/code/Magento/Paypal/Block/Express/Shortcut.php index c92dc1668f7ab..5561e62bb5f9d 100644 --- a/app/code/Magento/Paypal/Block/Express/Shortcut.php +++ b/app/code/Magento/Paypal/Block/Express/Shortcut.php @@ -51,13 +51,6 @@ class Shortcut extends \Magento\Framework\View\Element\Template implements Catal */ protected $_alias = ''; - /** - * Paypal data - * - * @var \Magento\Paypal\Helper\Data - */ - protected $_paypalData; - /** * @var \Magento\Paypal\Model\ConfigFactory */ @@ -78,11 +71,6 @@ class Shortcut extends \Magento\Framework\View\Element\Template implements Catal */ protected $_mathRandom; - /** - * @var \Magento\Customer\Helper\Session\CurrentCustomer - */ - protected $currentCustomer; - /** * @var \Magento\Framework\Locale\ResolverInterface */ @@ -100,11 +88,9 @@ class Shortcut extends \Magento\Framework\View\Element\Template implements Catal /** * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Paypal\Helper\Data $paypalData * @param \Magento\Paypal\Model\ConfigFactory $paypalConfigFactory * @param \Magento\Paypal\Model\Express\Checkout\Factory $checkoutFactory * @param \Magento\Framework\Math\Random $mathRandom - * @param \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param ValidatorInterface $shortcutValidator * @param string $paymentMethodCode @@ -118,11 +104,9 @@ class Shortcut extends \Magento\Framework\View\Element\Template implements Catal */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, - \Magento\Paypal\Helper\Data $paypalData, \Magento\Paypal\Model\ConfigFactory $paypalConfigFactory, \Magento\Paypal\Model\Express\Checkout\Factory $checkoutFactory, \Magento\Framework\Math\Random $mathRandom, - \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer, \Magento\Framework\Locale\ResolverInterface $localeResolver, ValidatorInterface $shortcutValidator, $paymentMethodCode, @@ -133,7 +117,6 @@ public function __construct( \Magento\Checkout\Model\Session $checkoutSession = null, array $data = [] ) { - $this->_paypalData = $paypalData; $this->_paypalConfigFactory = $paypalConfigFactory; $this->_checkoutSession = $checkoutSession; $this->_checkoutFactory = $checkoutFactory; @@ -151,7 +134,6 @@ public function __construct( $this->config = $this->_paypalConfigFactory->create(); $this->config->setMethod($this->_paymentMethodCode); - $this->currentCustomer = $currentCustomer; } /** @@ -187,20 +169,6 @@ protected function _beforeToHtml() $this->setImageUrl($checkoutModel->getCheckoutShortcutImageUrl()); } - // ask whether to create a billing agreement - $customerId = $this->currentCustomer->getCustomerId(); // potential issue for caching - if ($this->_paypalData->shouldAskToCreateBillingAgreement($this->config, $customerId)) { - $this->setConfirmationUrl( - $this->getUrl( - $this->_startAction, - [\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1] - ) - ); - $this->setConfirmationMessage( - __('Would you like to sign a billing agreement to streamline further purchases with PayPal?') - ); - } - return $result; } diff --git a/app/code/Magento/Paypal/CustomerData/BillingAgreement.php b/app/code/Magento/Paypal/CustomerData/BillingAgreement.php new file mode 100644 index 0000000000000..c3d0e059bb1fb --- /dev/null +++ b/app/code/Magento/Paypal/CustomerData/BillingAgreement.php @@ -0,0 +1,107 @@ +currentCustomer = $currentCustomer; + $this->paypalData = $paypalData; + $this->urlBuilder = $urlBuilder; + $this->escaper = $escaper; + $this->startAction = $startAction; + $this->config = $paypalConfigFactory->create(); + $this->config->setMethod(Config::METHOD_EXPRESS); + } + + /** + * {@inheritdoc} + */ + public function getSectionData() + { + $customerId = $this->currentCustomer->getCustomerId(); + if ($this->paypalData->shouldAskToCreateBillingAgreement($this->config, $customerId)) { + return [ + 'askToCreate' => true, + 'confirmUrl' => $this->escaper->escapeUrl( + $this->urlBuilder->getUrl( + $this->startAction, + [\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1] + ) + ), + 'confirmMessage' => $this->escaper->escapeJsQuote( + __('Would you like to sign a billing agreement to streamline further purchases with PayPal?') + ) + ]; + } + + return []; + } +} \ No newline at end of file diff --git a/app/code/Magento/Paypal/Test/Unit/CustomerData/BillingAgreementTest.php b/app/code/Magento/Paypal/Test/Unit/CustomerData/BillingAgreementTest.php new file mode 100644 index 0000000000000..268c04cd22eba --- /dev/null +++ b/app/code/Magento/Paypal/Test/Unit/CustomerData/BillingAgreementTest.php @@ -0,0 +1,102 @@ +paypalConfig = $this->getMock(Config::class, [], [], '', false); + $this->paypalConfig + ->expects($this->once()) + ->method('setMethod') + ->will($this->returnSelf()); + + $this->paypalConfig->expects($this->once()) + ->method('setMethod') + ->with(Config::METHOD_EXPRESS); + + $paypalConfigFactory = $this->getMock(ConfigFactory::class, ['create'], [], '', false); + $paypalConfigFactory->expects($this->once()) + ->method('create') + ->will($this->returnValue($this->paypalConfig)); + + $customerId = 20; + $this->currentCustomer = $this->getMock(CurrentCustomer::class, [], [], '', false); + $this->currentCustomer->expects($this->any()) + ->method('getCustomerId') + ->willReturn($customerId); + + $this->paypalData = $this->getMock(Data::class, [], [], '', false); + + + $helper = new ObjectManager($this); + $this->billingAgreement = $helper->getObject( + BillingAgreement::class, + [ + 'paypalConfigFactory' => $paypalConfigFactory, + 'paypalData' => $this->paypalData, + 'currentCustomer' => $this->currentCustomer + ] + ); + } + + public function testGetSectionData() + { + $this->paypalData->expects($this->once()) + ->method('shouldAskToCreateBillingAgreement') + ->with($this->paypalConfig, $this->currentCustomer->getCustomerId()) + ->willReturn(true); + + $result = $this->billingAgreement->getSectionData(); + + $this->assertArrayHasKey('askToCreate', $result); + $this->assertArrayHasKey('confirmUrl', $result); + $this->assertArrayHasKey('confirmMessage', $result); + $this->assertTrue($result['askToCreate']); + } + + + public function testGetSectionDataNotNeedToCreateBillingAgreement() + { + $this->paypalData->expects($this->once()) + ->method('shouldAskToCreateBillingAgreement') + ->with($this->paypalConfig, $this->currentCustomer->getCustomerId()) + ->willReturn(false); + + $result = $this->billingAgreement->getSectionData(); + + $this->assertEmpty($result); + } +} \ No newline at end of file diff --git a/app/code/Magento/Paypal/etc/frontend/di.xml b/app/code/Magento/Paypal/etc/frontend/di.xml index 4bcb3f24b3238..9181ae9ea320b 100644 --- a/app/code/Magento/Paypal/etc/frontend/di.xml +++ b/app/code/Magento/Paypal/etc/frontend/di.xml @@ -105,4 +105,16 @@ + + + paypal/express/start/button/1 + + + + + + Magento\Paypal\CustomerData\BillingAgreement + + + diff --git a/app/code/Magento/Paypal/view/frontend/templates/billing/agreement/view.phtml b/app/code/Magento/Paypal/view/frontend/templates/billing/agreement/view.phtml index b21602e5f3cfc..95def49290b1c 100644 --- a/app/code/Magento/Paypal/view/frontend/templates/billing/agreement/view.phtml +++ b/app/code/Magento/Paypal/view/frontend/templates/billing/agreement/view.phtml @@ -17,10 +17,12 @@ $relatedOrders = $block->getRelatedOrders(); escapeHtml($block->getReferenceId()); ?> getCanCancel()): ?> - diff --git a/app/code/Magento/Paypal/view/frontend/templates/checkout/onepage/success/billing_agreement.phtml b/app/code/Magento/Paypal/view/frontend/templates/checkout/onepage/success/billing_agreement.phtml index 7785b7af449c1..4af0a82e67983 100644 --- a/app/code/Magento/Paypal/view/frontend/templates/checkout/onepage/success/billing_agreement.phtml +++ b/app/code/Magento/Paypal/view/frontend/templates/checkout/onepage/success/billing_agreement.phtml @@ -9,7 +9,7 @@ * @var \Magento\Paypal\Block\Checkout\Onepage\Success\BillingAgreement $block */ ?> -

+

escapeHtml(__('Your billing agreement # is: ')); ?> escapeHtml($block->getAgreementRefId()); ?> diff --git a/app/code/Magento/Paypal/view/frontend/templates/express/shortcut.phtml b/app/code/Magento/Paypal/view/frontend/templates/express/shortcut.phtml index 488132f8293b2..a0237adf9d982 100644 --- a/app/code/Magento/Paypal/view/frontend/templates/express/shortcut.phtml +++ b/app/code/Magento/Paypal/view/frontend/templates/express/shortcut.phtml @@ -17,10 +17,8 @@ if ($block->isOrPositionBefore()) { $labelPosition = ' after'; } $shortcutHtmlId = $block->escapeHtml($block->getShortcutHtmlId()); -$confirmationUrl = ''; $isInCatalogProduct = false; -if ($block->getConfirmationUrl() || $block->getIsInCatalogProduct()) { - $confirmationUrl = $block->escapeUrl($block->getConfirmationUrl()); +if ($block->getIsInCatalogProduct()) { $isInCatalogProduct = $block->getIsInCatalogProduct(); } ?> @@ -29,8 +27,6 @@ if ($block->getConfirmationUrl() || $block->getIsInCatalogProduct()) { " data-mage-init='{ "paypalCheckout": { - "confirmMessage": "escapeJsQuote($block->getConfirmationMessage()); ?>", - "confirmUrl": "", "isCatalogProduct": "", "shortcutContainerClass": "" } diff --git a/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js b/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js new file mode 100644 index 0000000000000..aa618a065eedc --- /dev/null +++ b/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js @@ -0,0 +1,47 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'jquery', + 'Magento_Customer/js/customer-data' +], function ($, customerData) { + 'use strict'; + + $.widget('mage.billingAgreement', { + options: { + invalidateOnCreate: false, + cancelButtonSelector: '.block-billing-agreements-view button.cancel', + cancelMessage: '', + cancelUrl: '' + }, + + /** + * Initialize billing agreements events + * @private + */ + _create: function () { + if (this.options.invalidateOnCreate) { + this.invalidate(); + } + this.element.on('click', $.proxy(function () { + if (confirm(this.options.cancelMessage)) { + this.invalidate(); + window.location.href = this.options.cancelUrl; + } + + return false; + }, this)); + }, + + /** + * clear paypal billing agreement customer data + * @returns void + */ + invalidate: function () { + customerData.invalidate(['paypal-billing-agreement']); + } + }); + + return $.mage.billingAgreement; +}); diff --git a/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js b/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js index 5fab3d86a0eb5..015ea107da27d 100644 --- a/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js +++ b/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js @@ -6,9 +6,10 @@ define([ 'jquery', 'Magento_Ui/js/modal/confirm', + 'Magento_Customer/js/customer-data', 'jquery/ui', 'mage/mage' -], function ($, confirm) { +], function ($, confirm, customerData) { 'use strict'; $.widget('mage.paypalCheckout', { @@ -30,13 +31,14 @@ define([ returnUrl = $target.data('checkout-url'), productId = $target.closest('form').find(this.options.productId).val(), originalForm = this.options.originalForm.replace('%1', productId), - self = this; + self = this, + billingAgreement = customerData.get('paypal-billing-agreement'); e.preventDefault(); - if (this.options.confirmUrl && this.options.confirmMessage) { + if (billingAgreement().askToCreate) { confirm({ - content: this.options.confirmMessage, + content: billingAgreement().confirmMessage, actions: { /** @@ -44,7 +46,7 @@ define([ * */ confirm: function () { - returnUrl = self.options.confirmUrl; + returnUrl = billingAgreement().confirmUrl; self._redirect(returnUrl, originalForm); }, From bed69045a230a2e199b508505aee0564b7b09026 Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Fri, 15 Apr 2016 15:31:03 +0300 Subject: [PATCH 10/27] MAGETWO-48372: Billing Agreement popup doesn't appear on product page after clicking on Checkout with Express button - add new line at the end of files --- app/code/Magento/Paypal/CustomerData/BillingAgreement.php | 2 +- .../Paypal/Test/Unit/CustomerData/BillingAgreementTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Paypal/CustomerData/BillingAgreement.php b/app/code/Magento/Paypal/CustomerData/BillingAgreement.php index c3d0e059bb1fb..304f6d02cf714 100644 --- a/app/code/Magento/Paypal/CustomerData/BillingAgreement.php +++ b/app/code/Magento/Paypal/CustomerData/BillingAgreement.php @@ -104,4 +104,4 @@ public function getSectionData() return []; } -} \ No newline at end of file +} diff --git a/app/code/Magento/Paypal/Test/Unit/CustomerData/BillingAgreementTest.php b/app/code/Magento/Paypal/Test/Unit/CustomerData/BillingAgreementTest.php index 268c04cd22eba..2d7da11c77a87 100644 --- a/app/code/Magento/Paypal/Test/Unit/CustomerData/BillingAgreementTest.php +++ b/app/code/Magento/Paypal/Test/Unit/CustomerData/BillingAgreementTest.php @@ -99,4 +99,4 @@ public function testGetSectionDataNotNeedToCreateBillingAgreement() $this->assertEmpty($result); } -} \ No newline at end of file +} From eef298f2cdba149253a73f81dd0a71e42c201576 Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Fri, 15 Apr 2016 15:47:16 +0300 Subject: [PATCH 11/27] MAGETWO-48372: Billing Agreement popup doesn't appear on product page after clicking on Checkout with Express button --- .../Paypal/view/frontend/web/js/in-context/billing-agreement.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js b/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js index aa618a065eedc..bbeaab4ee151b 100644 --- a/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js +++ b/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js @@ -24,7 +24,7 @@ define([ if (this.options.invalidateOnCreate) { this.invalidate(); } - this.element.on('click', $.proxy(function () { + $(this.options.cancelButtonSelector).on('click', $.proxy(function () { if (confirm(this.options.cancelMessage)) { this.invalidate(); window.location.href = this.options.cancelUrl; From 74b5eb9e386c8e3ab129cf0e249153a77dd4653f Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Mon, 18 Apr 2016 16:15:12 +0300 Subject: [PATCH 12/27] MAGETWO-48372: Billing Agreement popup doesn't appear on product page after clicking on Checkout with Express button --- .../Paypal/CustomerData/BillingAgreement.php | 2 +- .../web/js/in-context/billing-agreement.js | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Paypal/CustomerData/BillingAgreement.php b/app/code/Magento/Paypal/CustomerData/BillingAgreement.php index 304f6d02cf714..861da6791a9c3 100644 --- a/app/code/Magento/Paypal/CustomerData/BillingAgreement.php +++ b/app/code/Magento/Paypal/CustomerData/BillingAgreement.php @@ -62,7 +62,7 @@ class BillingAgreement implements SectionSourceInterface * @param ConfigFactory $paypalConfigFactory * @param UrlInterface $urlBuilder * @param Escaper $escaper - * @param $startAction + * @param string $startAction */ public function __construct( CurrentCustomer $currentCustomer, diff --git a/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js b/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js index bbeaab4ee151b..1e96de45f24c6 100644 --- a/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js +++ b/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js @@ -4,8 +4,9 @@ */ define([ 'jquery', + 'Magento_Ui/js/modal/confirm', 'Magento_Customer/js/customer-data' -], function ($, customerData) { +], function ($, confirm, customerData) { 'use strict'; $.widget('mage.billingAgreement', { @@ -21,17 +22,27 @@ define([ * @private */ _create: function () { + var self = this; + if (this.options.invalidateOnCreate) { this.invalidate(); } - $(this.options.cancelButtonSelector).on('click', $.proxy(function () { - if (confirm(this.options.cancelMessage)) { - this.invalidate(); - window.location.href = this.options.cancelUrl; - } + this.element.on('click', function () { + confirm({ + content: self.options.cancelMessage, + actions: { + /** + * 'Confirm' action handler. + */ + confirm: function () { + self.invalidate(); + window.location.href = self.options.cancelUrl; + } + } + }); return false; - }, this)); + }); }, /** From 82b97d3b5015647ff3e46dbf9faa7a13097e5832 Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Mon, 18 Apr 2016 16:18:51 +0300 Subject: [PATCH 13/27] MAGETWO-48372: Billing Agreement popup doesn't appear on product page after clicking on Checkout with Express button --- .../Paypal/view/frontend/web/js/in-context/billing-agreement.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js b/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js index 1e96de45f24c6..a793aa2959f92 100644 --- a/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js +++ b/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js @@ -27,7 +27,7 @@ define([ if (this.options.invalidateOnCreate) { this.invalidate(); } - this.element.on('click', function () { + $(this.options.cancelButtonSelector).on('click', function () { confirm({ content: self.options.cancelMessage, actions: { From a5979f5a44060e2dc8e9d337e2c3d5e25d4b05e2 Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Mon, 18 Apr 2016 16:49:37 +0300 Subject: [PATCH 14/27] MAGETWO-48372: Billing Agreement popup doesn't appear on product page after clicking on Checkout with Express button --- .../Paypal/Test/Unit/CustomerData/BillingAgreementTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Paypal/Test/Unit/CustomerData/BillingAgreementTest.php b/app/code/Magento/Paypal/Test/Unit/CustomerData/BillingAgreementTest.php index 2d7da11c77a87..b8d3f7ffe1b3e 100644 --- a/app/code/Magento/Paypal/Test/Unit/CustomerData/BillingAgreementTest.php +++ b/app/code/Magento/Paypal/Test/Unit/CustomerData/BillingAgreementTest.php @@ -60,7 +60,6 @@ protected function setUp() $this->paypalData = $this->getMock(Data::class, [], [], '', false); - $helper = new ObjectManager($this); $this->billingAgreement = $helper->getObject( BillingAgreement::class, @@ -87,7 +86,6 @@ public function testGetSectionData() $this->assertTrue($result['askToCreate']); } - public function testGetSectionDataNotNeedToCreateBillingAgreement() { $this->paypalData->expects($this->once()) From afa3a6f2436dc9674417bc7c9ea7039c5ae366a7 Mon Sep 17 00:00:00 2001 From: Ievgen Sentiabov Date: Mon, 18 Apr 2016 18:42:08 +0300 Subject: [PATCH 15/27] MAGETWO-47252: Some data is being exported as IDs, not names - Added document data provider for custom fields --- .../Model/ResourceModel/Grid/Collection.php | 3 + .../Component/DataProvider/DocumentTest.php | 175 ++++++++++++++++++ .../Ui/Component/DataProvider/Document.php | 137 ++++++++++++++ .../Order/Invoice/Grid/Collection.php | 6 + .../Component/DataProvider/DocumentTest.php | 98 ++++++++++ .../Ui/Component/DataProvider/Document.php | 91 +++++++++ .../UiComponent/DataProvider/SearchResult.php | 11 +- 7 files changed, 518 insertions(+), 3 deletions(-) create mode 100644 app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php create mode 100644 app/code/Magento/Customer/Ui/Component/DataProvider/Document.php create mode 100644 app/code/Magento/Sales/Test/Unit/Ui/Component/DataProvider/DocumentTest.php create mode 100644 app/code/Magento/Sales/Ui/Component/DataProvider/Document.php diff --git a/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php index d31e3c2930522..71b639493b1cb 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php @@ -6,6 +6,7 @@ namespace Magento\Customer\Model\ResourceModel\Grid; +use Magento\Customer\Ui\Component\DataProvider\Document; use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy; use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory; use Magento\Framework\Event\ManagerInterface as EventManager; @@ -13,6 +14,8 @@ class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult { + protected $document = Document::class; + /** * Initialize dependencies. * diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php new file mode 100644 index 0000000000000..3a09772a09644 --- /dev/null +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php @@ -0,0 +1,175 @@ +initAttributeValueFactoryMock(); + + $this->groupRepository = $this->getMockForAbstractClass(GroupRepositoryInterface::class); + + $this->customerMetadata = $this->getMockForAbstractClass(CustomerMetadataInterface::class); + + $this->storeManager = $this->getMockForAbstractClass(StoreManagerInterface::class); + + $this->document = new Document( + $this->attributeValueFactory, + $this->groupRepository, + $this->customerMetadata, + $this->storeManager + ); + } + + /** + * @covers \Magento\Customer\Ui\Component\DataProvider\Document::getCustomAttribute + */ + public function testGetGenderAttribute() + { + $genderId = 1; + $this->document->setData('gender', $genderId); + + $this->groupRepository->expects(static::never()) + ->method('getById'); + + $this->storeManager->expects(static::never()) + ->method('getWebsites'); + + $metadata = $this->getMockForAbstractClass(AttributeMetadataInterface::class); + + $this->customerMetadata->expects(static::once()) + ->method('getAttributeMetadata') + ->willReturn($metadata); + + $option = $this->getMockForAbstractClass(OptionInterface::class); + + $metadata->expects(static::once()) + ->method('getOptions') + ->willReturn([$genderId => $option]); + + $option->expects(static::once()) + ->method('getLabel') + ->willReturn('Male'); + + $attribute = $this->document->getCustomAttribute('gender'); + static::assertEquals('Male', $attribute->getValue()); + } + + /** + * @covers \Magento\Customer\Ui\Component\DataProvider\Document::getCustomAttribute + */ + public function testGetGroupAttribute() + { + $this->document->setData('group_id', 1); + + $this->customerMetadata->expects(static::never()) + ->method('getAttributeMetadata'); + + $this->storeManager->expects(static::never()) + ->method('getWebsites'); + + $group = $this->getMockForAbstractClass(GroupInterface::class); + + $this->groupRepository->expects(static::once()) + ->method('getById') + ->willReturn($group); + + $group->expects(static::once()) + ->method('getCode') + ->willReturn('General'); + + $attribute = $this->document->getCustomAttribute('group_id'); + static::assertEquals('General', $attribute->getValue()); + } + + /** + * @covers \Magento\Customer\Ui\Component\DataProvider\Document::getCustomAttribute + */ + public function testGetWebsiteAttribute() + { + $websiteId = 1; + $this->document->setData('website_id', $websiteId); + + $this->groupRepository->expects(static::never()) + ->method('getById'); + + $this->customerMetadata->expects(static::never()) + ->method('getAttributeMetadata'); + + $website = $this->getMockForAbstractClass(WebsiteInterface::class); + + $this->storeManager->expects(static::once()) + ->method('getWebsites') + ->willReturn([$websiteId => $website]); + + $website->expects(static::once()) + ->method('getName') + ->willReturn('Main Website'); + + $attribute = $this->document->getCustomAttribute('website_id'); + static::assertEquals('Main Website', $attribute->getValue()); + } + + /** + * Create mock for attribute value factory + * @return void + */ + private function initAttributeValueFactoryMock() + { + $this->attributeValueFactory = $this->getMockBuilder(AttributeValueFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $attributeValue = new AttributeValue(); + + $this->attributeValueFactory->expects(static::once()) + ->method('create') + ->willReturn($attributeValue); + } +} diff --git a/app/code/Magento/Customer/Ui/Component/DataProvider/Document.php b/app/code/Magento/Customer/Ui/Component/DataProvider/Document.php new file mode 100644 index 0000000000000..aa3d79c069545 --- /dev/null +++ b/app/code/Magento/Customer/Ui/Component/DataProvider/Document.php @@ -0,0 +1,137 @@ +customerMetadata = $customerMetadata; + $this->groupRepository = $groupRepository; + $this->storeManager = $storeManager; + } + + /** + * @inheritdoc + */ + public function getCustomAttribute($attributeCode) + { + switch ($attributeCode) { + case self::$genderAttributeCode: + $this->setGenderValue(); + break; + case self::$groupAttributeCode: + $this->setCustomerGroupValue(); + break; + case self::$websiteAttributeCode: + $this->setWebsiteValue(); + break; + } + return parent::getCustomAttribute($attributeCode); + } + + /** + * Update customer gender value + * Method set gender label instead of id value + * @return void + */ + private function setGenderValue() + { + $value = $this->getData(self::$genderAttributeCode); + + if (!$value) { + $this->setCustomAttribute(self::$genderAttributeCode, 'N/A'); + return; + } + + try { + $attributeMetadata = $this->customerMetadata->getAttributeMetadata(self::$genderAttributeCode); + $option = $attributeMetadata->getOptions()[$value]; + $this->setCustomAttribute(self::$genderAttributeCode, $option->getLabel()); + } catch (NoSuchEntityException $e) { + $this->setCustomAttribute(self::$genderAttributeCode, 'N/A'); + } + } + + /** + * Update customer group value + * Method set group code instead id value + * @return void + */ + private function setCustomerGroupValue() + { + $value = $this->getData(self::$groupAttributeCode); + try { + $group = $this->groupRepository->getById($value); + $this->setCustomAttribute(self::$groupAttributeCode, $group->getCode()); + } catch (NoSuchEntityException $e) { + $this->setCustomAttribute(self::$groupAttributeCode, 'N/A'); + } + } + + /** + * Update website value + * Method set website name instead id value + * @return void + */ + private function setWebsiteValue() + { + $value = $this->getData(self::$websiteAttributeCode); + $list = $this->storeManager->getWebsites(); + $this->setCustomAttribute(self::$websiteAttributeCode, $list[$value]->getName()); + } +} diff --git a/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Grid/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Grid/Collection.php index 97a8cda9ab1eb..e4c12a3a5f9ba 100644 --- a/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Grid/Collection.php +++ b/app/code/Magento/Sales/Model/ResourceModel/Order/Invoice/Grid/Collection.php @@ -9,10 +9,16 @@ use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy; use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory; use Magento\Framework\Event\ManagerInterface as EventManager; +use Magento\Sales\Ui\Component\DataProvider\Document; use Psr\Log\LoggerInterface as Logger; class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult { + /** + * @inheritdoc + */ + protected $document = Document::class; + /** * Initialize dependencies. * diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/DataProvider/DocumentTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/DataProvider/DocumentTest.php new file mode 100644 index 0000000000000..5528999d1adb7 --- /dev/null +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/DataProvider/DocumentTest.php @@ -0,0 +1,98 @@ +initAttributeValueFactoryMock(); + + $this->groupRepository = $this->getMockForAbstractClass(GroupRepositoryInterface::class); + + $this->document = new Document($this->attributeValueFactory, $this->groupRepository); + } + + /** + * @covers \Magento\Sales\Ui\Component\DataProvider\Document::getCustomAttribute + */ + public function testGetStateAttribute() + { + $this->document->setData('state', Invoice::STATE_PAID); + + $this->groupRepository->expects(static::never()) + ->method('getById'); + + $attribute = $this->document->getCustomAttribute('state'); + static::assertEquals('Paid', $attribute->getValue()); + } + + /** + * @covers \Magento\Sales\Ui\Component\DataProvider\Document::getCustomAttribute + */ + public function testGetCustomerGroupAttribute() + { + $this->document->setData('customer_group_id', 1); + + $group = $this->getMockForAbstractClass(GroupInterface::class); + + $this->groupRepository->expects(static::once()) + ->method('getById') + ->willReturn($group); + + $group->expects(static::once()) + ->method('getCode') + ->willReturn('General'); + + $attribute = $this->document->getCustomAttribute('customer_group_id'); + static::assertEquals('General', $attribute->getValue()); + } + + /** + * Create mock for attribute value factory + * @return void + */ + private function initAttributeValueFactoryMock() + { + $this->attributeValueFactory = $this->getMockBuilder(AttributeValueFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $attributeValue = new AttributeValue(); + + $this->attributeValueFactory->expects(static::once()) + ->method('create') + ->willReturn($attributeValue); + } +} diff --git a/app/code/Magento/Sales/Ui/Component/DataProvider/Document.php b/app/code/Magento/Sales/Ui/Component/DataProvider/Document.php new file mode 100644 index 0000000000000..ce74beac76ff6 --- /dev/null +++ b/app/code/Magento/Sales/Ui/Component/DataProvider/Document.php @@ -0,0 +1,91 @@ +groupRepository = $groupRepository; + } + + /** + * @inheritdoc + */ + public function getCustomAttribute($attributeCode) + { + switch ($attributeCode) { + case self::$stateAttributeCode: + $this->setStateValue(); + break; + case self::$customerGroupAttributeCode: + $this->setCustomerGroupValue(); + break; + } + return parent::getCustomAttribute($attributeCode); + } + + /** + * Update invoice state value + * Method set text label instead id value + * @return void + */ + private function setStateValue() + { + $value = $this->getData(self::$stateAttributeCode); + /** @var \Magento\Framework\Phrase $state */ + $state = Invoice::getStates()[$value]; + + $this->setCustomAttribute(self::$stateAttributeCode, $state->getText()); + } + + /** + * Update customer group value + * Method set group code instead id value + * @return void + */ + private function setCustomerGroupValue() + { + $value = $this->getData(self::$customerGroupAttributeCode); + try { + $group = $this->groupRepository->getById($value); + $this->setCustomAttribute(self::$customerGroupAttributeCode, $group->getCode()); + } catch (NoSuchEntityException $e) { + $this->setCustomAttribute(self::$customerGroupAttributeCode, 'N/A'); + } + } +} diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/SearchResult.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/SearchResult.php index 41f39296d594d..be4d9d1793718 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/SearchResult.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/SearchResult.php @@ -7,10 +7,10 @@ namespace Magento\Framework\View\Element\UiComponent\DataProvider; use Magento\Framework\Api; -use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; -use Magento\Framework\Event\ManagerInterface as EventManager; use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy; use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory; +use Magento\Framework\Event\ManagerInterface as EventManager; +use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; use Psr\Log\LoggerInterface as Logger; /** @@ -34,6 +34,11 @@ class SearchResult extends AbstractCollection implements Api\Search\SearchResult */ protected $totalCount; + /** + * @var string class name of document + */ + protected $document = Document::class; + /** * @param EntityFactory $entityFactory * @param Logger $logger @@ -51,7 +56,7 @@ public function __construct( $mainTable, $resourceModel ) { - $this->_init('Magento\Framework\View\Element\UiComponent\DataProvider\Document', $resourceModel); + $this->_init($this->document, $resourceModel); $this->setMainTable(true); $this->setMainTable($this->_resource->getTable($mainTable)); parent::__construct( From d817a9ea5e2e988c37103a91b1c7af8d665ca936 Mon Sep 17 00:00:00 2001 From: Roman Liukshyn Date: Mon, 18 Apr 2016 16:42:04 +0000 Subject: [PATCH 16/27] MAGETWO-48211: Create functional tests for creating online refunds - sync with mainline --- .../CreateOnlineCreditMemoBraintreePaypalTest.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 2e189409174a6..d0071ddd75db0 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 @@ -18,8 +18,8 @@ US_address_1_without_email Flat Rate Fixed - braintreetwo_paypal - braintreetwo, braintreetwo_paypal_sale + braintree_paypal + braintree, braintree_paypal_sale sale Back, Send Email, Credit Memo, Hold, Ship, Reorder - @@ -39,8 +39,8 @@ US_address_1_without_email Flat Rate Fixed - braintreetwo_paypal - braintreetwo, braintreetwo_paypal + braintree_paypal + braintree, braintree_paypal Back, Send Email, Credit Memo, Hold, Ship, Reorder 2 1 From c5feedbc516d4fd4b0262b2b44739b8eb0d2007b Mon Sep 17 00:00:00 2001 From: Ievgen Sentiabov Date: Tue, 19 Apr 2016 10:14:43 +0300 Subject: [PATCH 17/27] MAGETWO-47252: Some data is being exported as IDs, not names - Fixed failed static tests --- .../Magento/Customer/Model/ResourceModel/Grid/Collection.php | 3 +++ .../Test/Unit/Ui/Component/DataProvider/DocumentTest.php | 2 ++ 2 files changed, 5 insertions(+) diff --git a/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php index 71b639493b1cb..9808f5c0b4186 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php @@ -14,6 +14,9 @@ class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult { + /** + * @inheritdoc + */ protected $document = Document::class; /** diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php index 3a09772a09644..7d263bc05ebd7 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php @@ -20,6 +20,8 @@ /** * Class DocumentTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class DocumentTest extends \PHPUnit_Framework_TestCase { From 026bb9bab4891975d58cf7482434b11bec82b0af Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Tue, 19 Apr 2016 15:41:33 +0300 Subject: [PATCH 18/27] MAGETWO-48372: Billing Agreement popup doesn't appear on product page after clicking on Checkout with Express button --- app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js b/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js index 015ea107da27d..38873de260216 100644 --- a/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js +++ b/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js @@ -78,7 +78,7 @@ define([ var $form, ppCheckoutInput; - if (this.options.isCatalogProduct && originalForm) { + if (this.options.isCatalogProduct) { // find the form from which the button was clicked $form = originalForm ? $(originalForm) : $($(this.options.shortcutContainerClass).closest('form')); From 45306d63aeb82fd96097c57d1aad98d19e756f0c Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Tue, 19 Apr 2016 16:14:19 +0300 Subject: [PATCH 19/27] MAGETWO-48372: Billing Agreement popup doesn't appear on product page after clicking on Checkout with Express button --- .../view/frontend/web/js/in-context/billing-agreement.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js b/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js index a793aa2959f92..a03512a9b78f8 100644 --- a/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js +++ b/app/code/Magento/Paypal/view/frontend/web/js/in-context/billing-agreement.js @@ -11,7 +11,7 @@ define([ $.widget('mage.billingAgreement', { options: { - invalidateOnCreate: false, + invalidateOnLoad: false, cancelButtonSelector: '.block-billing-agreements-view button.cancel', cancelMessage: '', cancelUrl: '' @@ -24,7 +24,7 @@ define([ _create: function () { var self = this; - if (this.options.invalidateOnCreate) { + if (this.options.invalidateOnLoad) { this.invalidate(); } $(this.options.cancelButtonSelector).on('click', function () { From 1b3d0449360c4051b8e9b42264d69c87ca838a5c Mon Sep 17 00:00:00 2001 From: Alexander Makeev Date: Tue, 19 Apr 2016 16:53:16 +0000 Subject: [PATCH 20/27] MAGETWO-51768: Checkout agreement is not a link on PayPal Order Review page - added modal form with agreements text --- .../templates/additional_agreements.phtml | 74 ++++++++++--------- .../web/js/model/agreement-validator.js | 4 +- .../web/js/view/checkout-agreements.js | 5 +- .../checkout/checkout-agreements.html | 7 +- .../Paypal/view/frontend/web/order-review.js | 22 ++++-- 5 files changed, 63 insertions(+), 49 deletions(-) diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/templates/additional_agreements.phtml b/app/code/Magento/CheckoutAgreements/view/frontend/templates/additional_agreements.phtml index 936c857d9e35b..d1ea98951c12c 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/templates/additional_agreements.phtml +++ b/app/code/Magento/CheckoutAgreements/view/frontend/templates/additional_agreements.phtml @@ -6,43 +6,45 @@ // @codingStandardsIgnoreFile -?> - -getAgreements()) { +if (!$block->getAgreements()) { return; -} ?> -

    - - getAgreements() as $agreement): ?> -
  1. -
    getContentHeight() ? ' style="height:' . $agreement->getContentHeight() . '"' : '')?>> - getIsHtml()):?> - getContent() ?> - - escapeHtml($agreement->getContent())) ?> - -
    - getMode() == \Magento\CheckoutAgreements\Model\AgreementModeOptions::MODE_MANUAL): ?> -
    - - -
    - getMode() == \Magento\CheckoutAgreements\Model\AgreementModeOptions::MODE_AUTO): ?> -
    - getIsHtml() ? $agreement->getCheckboxText() : $block->escapeHtml($agreement->getCheckboxText()) ?> -
    - -
  2. - -
+} + +/** @var \Magento\CheckoutAgreements\Model\ResourceModel\Agreement\Collection $argeementsCollection */ +$argeementsCollection = $block->getAgreements(); +$agreementMappedArray = []; +/** @var \Magento\CheckoutAgreements\Model\Agreement $agreement */ +foreach ($argeementsCollection as $agreement) { + if ($agreement->getIsActive()) { + $agreementMappedArray[] = [ + 'mode' => $agreement->getMode(), + 'agreementId' => $agreement->getAgreementId(), + 'checkboxText' => $agreement->getCheckboxText(), + 'content' => $agreement->getContent() + ]; + } +} +$agreementJson = json_encode($agreementMappedArray); +?> + +
+ +
+ diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreement-validator.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreement-validator.js index 5f8055ca497e7..13673326605a4 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreement-validator.js +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreement-validator.js @@ -11,7 +11,9 @@ define( ], function ($) { 'use strict'; - var agreementsConfig = window.checkoutConfig.checkoutAgreements; + var checkoutConfig = window.checkoutConfig, + agreementsConfig = checkoutConfig ? checkoutConfig.checkoutAgreements : {}; + return { /** * Validate checkout agreements diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements.js index 1390afeaacc09..292fb69ca6bfa 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements.js +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements.js @@ -11,8 +11,9 @@ define( ], function (ko, $, Component, agreementsModal) { 'use strict'; - var agreementsConfig = window.checkoutConfig.checkoutAgreements, - agreementManualMode = 1; + var checkoutConfig = window.checkoutConfig, + agreementManualMode = 1, + agreementsConfig = checkoutConfig ? checkoutConfig.checkoutAgreements : {}; return Component.extend({ defaults: { diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html b/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html index 1373b9946a99d..bb7d5de636ce5 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ --> -
+
@@ -15,8 +15,7 @@ 'name': 'agreement[' + agreementId + ']', 'value': agreementId }" - data-validate="{required:true}" - > + data-validate="{required:true}" />
-
+ diff --git a/app/code/Magento/Paypal/view/frontend/web/order-review.js b/app/code/Magento/Paypal/view/frontend/web/order-review.js index d5fe3cab587b1..16ec108476caa 100644 --- a/app/code/Magento/Paypal/view/frontend/web/order-review.js +++ b/app/code/Magento/Paypal/view/frontend/web/order-review.js @@ -24,6 +24,7 @@ define([ updateContainerSelector: '#details-reload', waitLoadingContainer: '#review-please-wait', shippingMethodContainer: '#shipping-method-container', + agreementSelector: 'div.checkout-agreements input', isAjax: false, updateShippingMethodSubmitSelector: "#update-shipping-method-submit", reviewSubmitSelector: "#review-submit", @@ -63,7 +64,6 @@ define([ .find('select').not(this.options.shippingSelector).on('change', this._propertyChange); this._updateOrderSubmit(isDisable); } - }, /** @@ -163,6 +163,11 @@ define([ * Validate Order form */ _validateForm: function () { + this.element.find(this.options.agreementSelector).off('change').on('change', $.proxy(function (e) { + var isValid = this._validateForm(); + this._updateOrderSubmit(!isValid); + }, this)); + if (this.element.data('mageValidation')) { return this.element.validation().valid(); } @@ -236,15 +241,20 @@ define([ callBackResponseHandler = null, shippingMethod = $.trim($(this.options.shippingSelector).val()); this._shippingTobilling(); - if (url && resultId && this._validateForm() && shippingMethod) { - this._updateOrderSubmit(true); - this._toggleButton(this.options.updateOrderSelector, true); + + var validateFormResult = this._validateForm(); + var isShippingUpdate = url == $(this.options.shippingSubmitFormSelector).prop('action') && shippingMethod; + + if (url && resultId && (validateFormResult || isShippingUpdate)) { + this._updateOrderSubmit(validateFormResult); + this._toggleButton(this.options.updateOrderSelector, !validateFormResult); + // form data and callBack updated based on the shippping Form element if (this.isShippingSubmitForm) { formData = $(this.options.shippingSubmitFormSelector).serialize() + "&isAjax=true"; callBackResponseHandler = function (response) { $(resultId).html(response); - this._updateOrderSubmit(false); + this._updateOrderSubmit(!validateFormResult); this._ajaxComplete(); }; } else { @@ -300,4 +310,4 @@ define([ }); return $.mage.orderReview; -}); \ No newline at end of file +}); From 448acbadd7f06c7fa9ad6602211310dfad74c719 Mon Sep 17 00:00:00 2001 From: Ievgen Sentiabov Date: Wed, 20 Apr 2016 14:08:22 +0300 Subject: [PATCH 21/27] MAGETWO-52069: Customer can't place Order using FedEx - Fixed shipping method exploder --- .../ShippingAssignment/ShippingProcessor.php | 5 +- .../ShippingProcessorTest.php | 111 ++++++++++++++++++ 2 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Quote/Test/Unit/Model/Quote/ShippingAssignment/ShippingProcessorTest.php diff --git a/app/code/Magento/Quote/Model/Quote/ShippingAssignment/ShippingProcessor.php b/app/code/Magento/Quote/Model/Quote/ShippingAssignment/ShippingProcessor.php index d6b0ff59d5476..71d0465d709c0 100644 --- a/app/code/Magento/Quote/Model/Quote/ShippingAssignment/ShippingProcessor.php +++ b/app/code/Magento/Quote/Model/Quote/ShippingAssignment/ShippingProcessor.php @@ -65,7 +65,10 @@ public function save(ShippingInterface $shipping, CartInterface $quote) { $this->shippingAddressManagement->assign($quote->getId(), $shipping->getAddress()); if (!empty($shipping->getMethod()) && $quote->getItemsCount() > 0) { - list($carrierCode, $methodCode) = explode("_", $shipping->getMethod()); + $nameComponents = explode('_', $shipping->getMethod()); + $carrierCode = array_shift($nameComponents); + // carrier method code can contains more one name component + $methodCode = implode('_', $nameComponents); $this->shippingMethodManagement->apply($quote->getId(), $carrierCode, $methodCode); } } diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/ShippingAssignment/ShippingProcessorTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/ShippingAssignment/ShippingProcessorTest.php new file mode 100644 index 0000000000000..71cf24a0fed1c --- /dev/null +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/ShippingAssignment/ShippingProcessorTest.php @@ -0,0 +1,111 @@ +shippingAddressManagement = $this->getMockBuilder(ShippingAddressManagement::class) + ->disableOriginalConstructor() + ->setMethods(['assign']) + ->getMock(); + + $this->shippingMethodManagement = $this->getMockBuilder(ShippingMethodManagement::class) + ->disableOriginalConstructor() + ->setMethods(['apply']) + ->getMock(); + + $objectManager = new ObjectManager($this); + + $this->shippingProcessor = $objectManager->getObject(ShippingProcessor::class, [ + 'shippingAddressManagement' => $this->shippingAddressManagement, + 'shippingMethodManagement' => $this->shippingMethodManagement + ]); + } + + /** + * @param string $method + * @param string $carrierCode + * @param string $methodCode + * @dataProvider saveDataProvider + */ + public function testSave($method, $carrierCode, $methodCode) + { + $shipping = $this->getMockForAbstractClass(ShippingInterface::class); + $quote = $this->getMockForAbstractClass(CartInterface::class); + $quoteId = 1; + + $address = $this->getMockForAbstractClass(AddressInterface::class); + + $quote->expects(static::exactly(2)) + ->method('getId') + ->willReturn($quoteId); + + $shipping->expects(static::once()) + ->method('getAddress') + ->willReturn($address); + + $this->shippingAddressManagement->expects(static::once()) + ->method('assign') + ->with($quoteId, $address); + + $shipping->expects(static::exactly(2)) + ->method('getMethod') + ->willReturn($method); + + $quote->expects(static::once()) + ->method('getItemsCount') + ->willReturn(1); + + $this->shippingMethodManagement->expects(static::once()) + ->method('apply') + ->with($quoteId, $carrierCode, $methodCode); + + $this->shippingProcessor->save($shipping, $quote); + } + + /** + * Get variations for save method testing + * @return array + */ + public function saveDataProvider() + { + return [ + ['carrier_Global_World_Economy', 'carrier', 'Global_World_Economy'], + ['carrier_International_Economy', 'carrier', 'International_Economy'], + ['carrier_Express', 'carrier', 'Express'], + ['flat_rate', 'flat', 'rate'], + ]; + } +} From 9361f63bc4d098c8d10970ce532c4b542ae1a9ef Mon Sep 17 00:00:00 2001 From: Alexander Makeev Date: Wed, 20 Apr 2016 11:37:22 +0000 Subject: [PATCH 22/27] MAGETWO-51768: Checkout agreement is not a link on PayPal Order Review page - added noEscape --- .../view/frontend/templates/additional_agreements.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/templates/additional_agreements.phtml b/app/code/Magento/CheckoutAgreements/view/frontend/templates/additional_agreements.phtml index d1ea98951c12c..5aea3bf200aaf 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/templates/additional_agreements.phtml +++ b/app/code/Magento/CheckoutAgreements/view/frontend/templates/additional_agreements.phtml @@ -40,7 +40,7 @@ $agreementJson = json_encode($agreementMappedArray); "components": { "checkout-agreements-component-scope": { "component": "Magento_CheckoutAgreements/js/view/checkout-agreements", - "agreements": , + "agreements": , "isVisible": true } } From b3ae6cb9ee064dea69d39cd8879ac698f70687e8 Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Thu, 21 Apr 2016 11:32:56 +0300 Subject: [PATCH 23/27] MAGETWO-48211: Create functional tests for creating online refunds --- .../tests/app/Magento/Checkout/Test/TestStep/PlaceOrderStep.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 00dbd13bd8723..2bfd346fbcaeb 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 @@ -69,7 +69,7 @@ public function __construct( AssertGrandTotalOrderReview $assertGrandTotalOrderReview, CheckoutOnepageSuccess $checkoutOnepageSuccess, FixtureFactory $fixtureFactory, - array $products, + array $products = [], array $prices = [] ) { $this->checkoutOnepage = $checkoutOnepage; From 0224211bc3d23c2602f6c4e01b22ba4a96a93027 Mon Sep 17 00:00:00 2001 From: Alexander Makeev Date: Thu, 21 Apr 2016 09:40:06 +0000 Subject: [PATCH 24/27] MAGETWO-51535: Default DB logger is set to Magento\Framework\DB\Logger\File - set to Quiet --- app/etc/di.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/etc/di.xml b/app/etc/di.xml index 7317a19b3e608..06c6c4c74272f 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -96,7 +96,7 @@ - + From cefb54bd02b4f9a3a82da671ded361b0380152ff Mon Sep 17 00:00:00 2001 From: Alexander Makeev Date: Thu, 21 Apr 2016 12:20:17 +0000 Subject: [PATCH 25/27] MAGETWO-51768: Checkout agreement is not a link on PayPal Order Review page - fixed problem with validation error notification --- .../Paypal/view/frontend/web/order-review.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Paypal/view/frontend/web/order-review.js b/app/code/Magento/Paypal/view/frontend/web/order-review.js index 16ec108476caa..dc389493e46cc 100644 --- a/app/code/Magento/Paypal/view/frontend/web/order-review.js +++ b/app/code/Magento/Paypal/view/frontend/web/order-review.js @@ -102,8 +102,8 @@ define([ this.element.find(this.options.updateOrderSelector).fadeTo(0, 0.5) .end().find(this.options.waitLoadingContainer).show() .end().submit(); + this._updateOrderSubmit(true); } - this._updateOrderSubmit(true); }, /** @@ -242,19 +242,16 @@ define([ shippingMethod = $.trim($(this.options.shippingSelector).val()); this._shippingTobilling(); - var validateFormResult = this._validateForm(); - var isShippingUpdate = url == $(this.options.shippingSubmitFormSelector).prop('action') && shippingMethod; - - if (url && resultId && (validateFormResult || isShippingUpdate)) { - this._updateOrderSubmit(validateFormResult); - this._toggleButton(this.options.updateOrderSelector, !validateFormResult); + if (url && resultId && shippingMethod) { + this._updateOrderSubmit(true); + this._toggleButton(this.options.updateOrderSelector, true); // form data and callBack updated based on the shippping Form element if (this.isShippingSubmitForm) { formData = $(this.options.shippingSubmitFormSelector).serialize() + "&isAjax=true"; callBackResponseHandler = function (response) { $(resultId).html(response); - this._updateOrderSubmit(!validateFormResult); + this._updateOrderSubmit(false); this._ajaxComplete(); }; } else { From e1d81b81c8c1baf0688ac78f40aefa9f6466be74 Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Thu, 21 Apr 2016 17:40:21 +0300 Subject: [PATCH 26/27] MAGETWO-48372: Billing Agreement popup doesn't appear on product page after clicking on Checkout with Express button --- app/code/Magento/Paypal/CustomerData/BillingAgreement.php | 7 ++----- app/code/Magento/Paypal/etc/frontend/di.xml | 7 +------ 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/Paypal/CustomerData/BillingAgreement.php b/app/code/Magento/Paypal/CustomerData/BillingAgreement.php index 861da6791a9c3..9d74e98b8e0a7 100644 --- a/app/code/Magento/Paypal/CustomerData/BillingAgreement.php +++ b/app/code/Magento/Paypal/CustomerData/BillingAgreement.php @@ -54,7 +54,7 @@ class BillingAgreement implements SectionSourceInterface * * @var string */ - private $startAction = ''; + private $startAction = 'paypal/express/start/button/1'; /** * @param CurrentCustomer $currentCustomer @@ -62,21 +62,18 @@ class BillingAgreement implements SectionSourceInterface * @param ConfigFactory $paypalConfigFactory * @param UrlInterface $urlBuilder * @param Escaper $escaper - * @param string $startAction */ public function __construct( CurrentCustomer $currentCustomer, Data $paypalData, ConfigFactory $paypalConfigFactory, UrlInterface $urlBuilder, - Escaper $escaper, - $startAction + Escaper $escaper ) { $this->currentCustomer = $currentCustomer; $this->paypalData = $paypalData; $this->urlBuilder = $urlBuilder; $this->escaper = $escaper; - $this->startAction = $startAction; $this->config = $paypalConfigFactory->create(); $this->config->setMethod(Config::METHOD_EXPRESS); } diff --git a/app/code/Magento/Paypal/etc/frontend/di.xml b/app/code/Magento/Paypal/etc/frontend/di.xml index 9181ae9ea320b..8b98901f53150 100644 --- a/app/code/Magento/Paypal/etc/frontend/di.xml +++ b/app/code/Magento/Paypal/etc/frontend/di.xml @@ -105,12 +105,7 @@ - - - paypal/express/start/button/1 - - - + Magento\Paypal\CustomerData\BillingAgreement From ea9044112cec972b35901181e4bf21d03c10bbed Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Wed, 20 Apr 2016 16:23:05 +0300 Subject: [PATCH 27/27] MAGETWO-52107: After clicking "X" sign on billing agreement pop up customer is redirected to PayPal --- .../Paypal/view/frontend/web/js/paypal-checkout.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js b/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js index 38873de260216..d82e0ba5ae2f1 100644 --- a/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js +++ b/app/code/Magento/Paypal/view/frontend/web/js/paypal-checkout.js @@ -54,17 +54,16 @@ define([ * Cancel confirmation handler * */ - cancel: function () { - self._redirect(returnUrl); + cancel: function (event) { + if (event && !$(event.target).hasClass('action-close')) { + self._redirect(returnUrl); + } } } }); - - return false; + } else { + this._redirect(returnUrl, originalForm); } - - this._redirect(returnUrl, originalForm); - }, this)); },