From 2c13e0ca12212f6619adda63694b1c439dc861d3 Mon Sep 17 00:00:00 2001 From: Lachlan Turner Date: Thu, 20 Aug 2020 14:37:33 +0930 Subject: [PATCH 01/69] Allow ignored columns for mview to be specified at the subscription level. --- .../Framework/Mview/View/Subscription.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/Mview/View/Subscription.php b/lib/internal/Magento/Framework/Mview/View/Subscription.php index ddfa39f0a089f..181e9f790d2a0 100644 --- a/lib/internal/Magento/Framework/Mview/View/Subscription.php +++ b/lib/internal/Magento/Framework/Mview/View/Subscription.php @@ -57,13 +57,19 @@ class Subscription implements SubscriptionInterface protected $linkedViews = []; /** - * List of columns that can be updated in a subscribed table + * List of columns that can be updated in any subscribed table * without creating a new change log entry * * @var array */ private $ignoredUpdateColumns = []; + /** + * List of columns that can be updated in a specific subscribed table + * for a specific view without creating a new change log entry + */ + private $ignoredUpdateColumnsBySubscription = []; + /** * @var Resource */ @@ -77,6 +83,7 @@ class Subscription implements SubscriptionInterface * @param string $tableName * @param string $columnName * @param array $ignoredUpdateColumns + * @param array $ignoredUpdateColumnsBySubscription */ public function __construct( ResourceConnection $resource, @@ -85,7 +92,8 @@ public function __construct( \Magento\Framework\Mview\ViewInterface $view, $tableName, $columnName, - $ignoredUpdateColumns = [] + $ignoredUpdateColumns = [], + $ignoredUpdateColumnsBySubscription = [] ) { $this->connection = $resource->getConnection(); $this->triggerFactory = $triggerFactory; @@ -95,6 +103,7 @@ public function __construct( $this->columnName = $columnName; $this->resource = $resource; $this->ignoredUpdateColumns = $ignoredUpdateColumns; + $this->ignoredUpdateColumnsBySubscription = $ignoredUpdateColumnsBySubscription; } /** @@ -209,7 +218,9 @@ protected function buildStatement($event, $changelog) $describe = $this->connection->describeTable($tableName) ) { $columnNames = array_column($describe, 'COLUMN_NAME'); - $columnNames = array_diff($columnNames, $this->ignoredUpdateColumns); + $ignoredColumns = array_merge($this->ignoredUpdateColumns, + $this->ignoredUpdateColumnsBySubscription[$changelog->getViewId()][$this->getTableName()] ?? []); + $columnNames = array_diff($columnNames, $ignoredColumns); if ($columnNames) { $columns = []; foreach ($columnNames as $columnName) { From d1983b4c39caecdef0e0181a7cbca60781ff3b19 Mon Sep 17 00:00:00 2001 From: Lachlan Turner Date: Mon, 24 Aug 2020 08:37:40 +0930 Subject: [PATCH 02/69] Fix formatting --- lib/internal/Magento/Framework/Mview/View/Subscription.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Mview/View/Subscription.php b/lib/internal/Magento/Framework/Mview/View/Subscription.php index 181e9f790d2a0..41c59f032179f 100644 --- a/lib/internal/Magento/Framework/Mview/View/Subscription.php +++ b/lib/internal/Magento/Framework/Mview/View/Subscription.php @@ -218,8 +218,10 @@ protected function buildStatement($event, $changelog) $describe = $this->connection->describeTable($tableName) ) { $columnNames = array_column($describe, 'COLUMN_NAME'); - $ignoredColumns = array_merge($this->ignoredUpdateColumns, - $this->ignoredUpdateColumnsBySubscription[$changelog->getViewId()][$this->getTableName()] ?? []); + $ignoredColumns = array_merge( + $this->ignoredUpdateColumns, + $this->ignoredUpdateColumnsBySubscription[$changelog->getViewId()][$this->getTableName()] ?? [] + ); $columnNames = array_diff($columnNames, $ignoredColumns); if ($columnNames) { $columns = []; From d58bed10e6781bbdfd8889d754f4896a3cb068d9 Mon Sep 17 00:00:00 2001 From: Lachlan Turner Date: Mon, 24 Aug 2020 09:27:01 +0930 Subject: [PATCH 03/69] Fix failing static test due to class documentation --- lib/internal/Magento/Framework/Mview/View/Subscription.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/Mview/View/Subscription.php b/lib/internal/Magento/Framework/Mview/View/Subscription.php index 41c59f032179f..a1512dbd305bb 100644 --- a/lib/internal/Magento/Framework/Mview/View/Subscription.php +++ b/lib/internal/Magento/Framework/Mview/View/Subscription.php @@ -11,9 +11,7 @@ use Magento\Framework\Mview\View\StateInterface; /** - * Class Subscription - * - * @package Magento\Framework\Mview\View + * Class Subscription for handling partial indexation triggers */ class Subscription implements SubscriptionInterface { From b5a64c7242c00e66e5daefe3a2989c4a0b767ced Mon Sep 17 00:00:00 2001 From: Nitish Singh Date: Sat, 10 Oct 2020 15:24:28 +0530 Subject: [PATCH 04/69] Customer Attributes Options with option group fixed --- .../Customer/Ui/Component/Listing/AttributeRepository.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php b/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php index 0a89cb6ea1449..b562adf228d7c 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php @@ -143,9 +143,13 @@ protected function getOptionArray(array $options) { /** @var \Magento\Customer\Api\Data\OptionInterface $option */ foreach ($options as &$option) { + $value = $option->getValue(); + if ($option->getOptions()) { + $value = $this->getOptionArray($option->getOptions()); + } $option = [ 'label' => (string)$option->getLabel(), - 'value' => $option->getValue(), + 'value' => $value, '__disableTmpl' => true ]; } From 0417ffcba0e99108a6fba8281315c368dae33fb6 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Tue, 13 Oct 2020 14:22:01 +0300 Subject: [PATCH 05/69] test coverage --- .../Mview/Test/Unit/View/SubscriptionTest.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php index b91c0b525390f..c321f796253c4 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php @@ -323,4 +323,54 @@ public function testRemove() $this->model->remove(); } + + /** + * Test ignored columns for mview specified at the subscription level + * + * @return void + */ + public function testBuildStatementIgnoredColumnSubscriptionLevel(): void + { + $tableName = 'cataloginventory_stock_item'; + $ignoredColumnName = 'low_stock_date'; + $viewId = 'cataloginventory_stock'; + $ignoredData = [ + $viewId => [$tableName => [$ignoredColumnName]] + ]; + + $this->connectionMock->expects($this->once()) + ->method('isTableExists') + ->willReturn(true); + $this->connectionMock->expects($this->once()) + ->method('describeTable') + ->willReturn([ + 'item_id' => ['COLUMN_NAME' => 'item_id'], + 'product_id' => ['COLUMN_NAME' => 'product_id'], + 'stock_id' => ['COLUMN_NAME' => 'stock_id'], + 'qty' => ['COLUMN_NAME' => 'qty'], + $ignoredColumnName => ['COLUMN_NAME' => $ignoredColumnName], + ]); + + $otherChangelogMock = $this->getMockForAbstractClass(ChangelogInterface::class); + $otherChangelogMock->expects($this->once()) + ->method('getViewId') + ->willReturn($viewId); + + $model = new Subscription( + $this->resourceMock, + $this->triggerFactoryMock, + $this->viewCollectionMock, + $this->viewMock, + $tableName, + 'columnName', + [], + $ignoredData + ); + + $method = new \ReflectionMethod($model, 'buildStatement'); + $method->setAccessible(true); + $statement = $method->invoke($model, Trigger::EVENT_UPDATE, $otherChangelogMock); + + $this->assertStringNotContainsString($ignoredColumnName, $statement); + } } From f3663f05d08539f6b42bcc708fab50c924765e83 Mon Sep 17 00:00:00 2001 From: David Haecker Date: Wed, 14 Oct 2020 11:31:08 -0500 Subject: [PATCH 06/69] magento/partners-magento2b2b#370: [Determine Coverage]: Add Meaningful Titles and Descriptions For All MFTF Tests in the Company, CompanyCredit, CompanyPayment, CompanyShipping, & ConfigurableSharedCatalog Modules - Fixing MFTF annotations for Company module - Fixing AdminCheckThatReorderIsNotAvailableForTeamTest --- ...LinkFromCheckoutSuccessPageActionGroup.xml | 19 +++++++++++++++++++ .../StorefrontCustomerOrderSection.xml | 2 ++ 2 files changed, 21 insertions(+) create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontClickOrderLinkFromCheckoutSuccessPageActionGroup.xml diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontClickOrderLinkFromCheckoutSuccessPageActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontClickOrderLinkFromCheckoutSuccessPageActionGroup.xml new file mode 100644 index 0000000000000..ddff0153f93be --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontClickOrderLinkFromCheckoutSuccessPageActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + Clicks the order number link from the checkout success page + + + + + + diff --git a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerOrderSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerOrderSection.xml index 61ce050aa3ef2..00703d8cc5235 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerOrderSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerOrderSection.xml @@ -15,6 +15,8 @@ + + From 5b8b2524b71bcb429190c9161dde22084b5a38bd Mon Sep 17 00:00:00 2001 From: Oleh Usik Date: Sat, 17 Oct 2020 22:14:58 +0300 Subject: [PATCH 07/69] StorefrontClickProceedToCheckoutActionGroup --- ...frontClickProceedToCheckoutActionGroup.xml | 19 +++++++++++++++++++ ...ckoutAsCustomerUsingDefaultAddressTest.xml | 3 +-- ...eCheckoutAsCustomerUsingNewAddressTest.xml | 3 +-- ...utAsCustomerUsingNonDefaultAddressTest.xml | 3 +-- ...tomerUsingNonExistentCustomerGroupTest.xml | 3 +-- .../OnePageCheckoutUsingSignInLinkTest.xml | 3 +-- ...OnePageCheckoutWithAllProductTypesTest.xml | 4 +--- ...ressAndCreateCustomerAfterCheckoutTest.xml | 3 +-- ...ingAddressAndProductWithTierPricesTest.xml | 3 +-- ...ssAndRegisterCustomerAfterCheckoutTest.xml | 3 +-- ...ntCheckoutWithSpecialPriceProductsTest.xml | 3 +-- ...OnLoginWhenGuestCheckoutIsDisabledTest.xml | 5 ++--- ...egistrationAndDisableGuestCheckoutTest.xml | 5 ++--- ...refrontCustomerLoginDuringCheckoutTest.xml | 3 +-- ...tCheckoutUsingFreeShippingAndTaxesTest.xml | 3 +-- ...tCheckoutWithCouponAndZeroSubtotalTest.xml | 3 +-- ...ntOnePageCheckoutDataWhenChangeQtyTest.xml | 2 +- ...aForGuestCustomerWithPhysicalQuoteTest.xml | 2 +- ...tOnCheckoutPageDifferentStoreViewsTest.xml | 3 +-- ...ngesInBackendAfterCustomerCheckoutTest.xml | 3 +-- ...rontRefreshPageDuringGuestCheckoutTest.xml | 3 +-- ...efrontUKCustomerCheckoutWithCouponTest.xml | 6 ++---- ...uctQuantityEqualsToOrderedQuantityTest.xml | 3 +-- ...CouponAndBankTransferPaymentMethodTest.xml | 3 +-- ...tCheckoutUsingFreeShippingAndTaxesTest.xml | 3 +-- ...dableProductLinkAfterPartialRefundTest.xml | 3 +-- ...erBannerPresentOnAllPagesInSessionTest.xml | 3 +-- .../StorefrontAutoGeneratedCouponCodeTest.xml | 4 ++-- 28 files changed, 50 insertions(+), 57 deletions(-) create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontClickProceedToCheckoutActionGroup.xml diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontClickProceedToCheckoutActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontClickProceedToCheckoutActionGroup.xml new file mode 100644 index 0000000000000..97073106c305e --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontClickProceedToCheckoutActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + Click Proceed to Checkout button. + + + + + + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml index e90e1bf5a2e82..26d05362cbaae 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml @@ -54,8 +54,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml index d867b00310761..fb02d98a9d954 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml @@ -54,8 +54,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml index 13968964436b4..f4bae7922a51a 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml @@ -54,8 +54,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml index 92dad56e81135..f8e5d5bb64d89 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml @@ -66,8 +66,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml index 42d61abca845b..46fe685bc327d 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml @@ -54,8 +54,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml index a519aac72d1b5..158e33292e1a7 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml @@ -168,9 +168,7 @@ - - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml index ef1f30e2d9c36..cd0b4df935026 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml @@ -50,8 +50,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml index c724cf4986aa9..99e393f9b020b 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml @@ -65,8 +65,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml index 118205e912b5e..d8f433d2b70c1 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml @@ -52,8 +52,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml index 6abd62542e5c9..483ae2be8c220 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml @@ -134,8 +134,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml index feab271110356..21d4acd47bfe9 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml @@ -53,7 +53,7 @@ - + @@ -62,8 +62,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml index 0d3bfe7b1fb84..c4243198e7655 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml @@ -50,8 +50,7 @@ - - + @@ -86,7 +85,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml index 27597a72fdb7f..16fda7c1bc951 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml @@ -64,8 +64,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml index e5897501cc067..5d6ad796628df 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml @@ -178,8 +178,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml index f910a9d47244f..3c8434051c255 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml @@ -49,8 +49,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutDataWhenChangeQtyTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutDataWhenChangeQtyTest.xml index 82324525bad24..321511e4e86d9 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutDataWhenChangeQtyTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutDataWhenChangeQtyTest.xml @@ -73,7 +73,7 @@ $grabQty 2 - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontPersistentDataForGuestCustomerWithPhysicalQuoteTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontPersistentDataForGuestCustomerWithPhysicalQuoteTest.xml index e42d5e1bae956..b9f802c8cfe9f 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontPersistentDataForGuestCustomerWithPhysicalQuoteTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontPersistentDataForGuestCustomerWithPhysicalQuoteTest.xml @@ -57,7 +57,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml index f20d0b790edfa..3fab4168ce452 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml @@ -94,8 +94,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductQuantityChangesInBackendAfterCustomerCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductQuantityChangesInBackendAfterCustomerCheckoutTest.xml index 3978389691b55..f2e340c9b7474 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductQuantityChangesInBackendAfterCustomerCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductQuantityChangesInBackendAfterCustomerCheckoutTest.xml @@ -46,8 +46,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml index 43b2262265841..dc11aee9db117 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml @@ -42,8 +42,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml index d037718a1ec94..87b0e8f8b07bc 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml @@ -77,16 +77,14 @@ - - + - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml index 10eee5938b27d..31c44721e1be8 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml @@ -43,8 +43,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml index dc92c0c5ce9ee..4389611302f77 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml @@ -56,8 +56,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml index 49af0a285b5f4..1ae9534a62b88 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml @@ -135,8 +135,7 @@ - - + diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml index d82cc25b0eccf..b53102ccd3d01 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml @@ -67,8 +67,7 @@ - - + diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml index 4f85b9167fa54..6d06f3580dfa6 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml @@ -84,8 +84,7 @@ - - + diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontAutoGeneratedCouponCodeTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontAutoGeneratedCouponCodeTest.xml index 7a12bca389672..2b79599486626 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontAutoGeneratedCouponCodeTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontAutoGeneratedCouponCodeTest.xml @@ -92,7 +92,7 @@ stepKey="waitForElementDiscountVisible"/> - + @@ -132,7 +132,7 @@ stepKey="waitForElementDiscountVisible1"/> - + From 8987cfa0716fe40af004d21cb50933a3ef1a6dad Mon Sep 17 00:00:00 2001 From: Oleh Usik Date: Sun, 18 Oct 2020 00:22:40 +0300 Subject: [PATCH 08/69] revert changes --- ...ntShippingAndBillingAddressAndProductWithTierPricesTest.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml index 99e393f9b020b..c724cf4986aa9 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml @@ -65,7 +65,8 @@ - + + From 16f136d68b0ea0cd43a87b9c96947302c27dd052 Mon Sep 17 00:00:00 2001 From: Oleh Usik Date: Sun, 18 Oct 2020 00:57:07 +0300 Subject: [PATCH 09/69] fixed error --- ...ngAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml index d8f433d2b70c1..118205e912b5e 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml @@ -52,7 +52,8 @@ - + + From d6ae9531d277cf9db3b6a2e0626c183934d5f39f Mon Sep 17 00:00:00 2001 From: Oleh Usik Date: Sun, 18 Oct 2020 10:56:45 +0300 Subject: [PATCH 10/69] fixed error --- ...ntShippingAndBillingAddressAndProductWithTierPricesTest.xml | 3 +-- ...ngAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml index c724cf4986aa9..99e393f9b020b 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml @@ -65,8 +65,7 @@ - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml index 118205e912b5e..d8f433d2b70c1 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml @@ -52,8 +52,7 @@ - - + From b21693a04f4d92fc3afb4c530363d9304beb7b2e Mon Sep 17 00:00:00 2001 From: Marush Denchev Date: Fri, 23 Oct 2020 12:18:24 +0300 Subject: [PATCH 11/69] Prevent multiple quotations of the same word --- .../Magento/Search/Model/SynonymAnalyzer.php | 2 +- .../Test/Unit/Model/SynonymAnalyzerTest.php | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Search/Model/SynonymAnalyzer.php b/app/code/Magento/Search/Model/SynonymAnalyzer.php index 16d0b0b4ddcd9..fce78f13c2f6d 100644 --- a/app/code/Magento/Search/Model/SynonymAnalyzer.php +++ b/app/code/Magento/Search/Model/SynonymAnalyzer.php @@ -138,7 +138,7 @@ private function getSearchPattern(array $words): string $patterns = []; for ($lastItem = count($words); $lastItem > 0; $lastItem--) { $words = array_map(function ($word) { - return preg_quote($word, '/'); + return preg_quote(stripslashes($word), '/'); }, $words); $phrase = implode("\s+", \array_slice($words, 0, $lastItem)); $patterns[] = '^' . $phrase . ','; diff --git a/app/code/Magento/Search/Test/Unit/Model/SynonymAnalyzerTest.php b/app/code/Magento/Search/Test/Unit/Model/SynonymAnalyzerTest.php index 9e6d087f72f99..70e93ca6b4404 100644 --- a/app/code/Magento/Search/Test/Unit/Model/SynonymAnalyzerTest.php +++ b/app/code/Magento/Search/Test/Unit/Model/SynonymAnalyzerTest.php @@ -84,4 +84,42 @@ public function testGetSynonymsForPhraseEmptyPhrase() $actual = $this->synonymAnalyzer->getSynonymsForPhrase($phrase); $this->assertEquals($expected, $actual); } + + /** + * @test + * + * Phrase that is long and has quotes in it scenario + */ + public function testLongQuotedPhrase() + { + $phrase = 'LSS 3/8"X3/4"X25\' EZ-PULL 1/2" INS SWEAT LINESET W/90 END BEND SUCTION LINE INSULATED'; + $expected = [ + 0 => [ 0 => "LSS" ], + 1 => [ 0 => "3/8\"X3/4\"X25'" ], + 2 => [ 0 => "EZ-PULL" ], + 3 => [ 0 => "1/2\"" ], + 4 => [ 0 => "INS" ], + 5 => [ 0 => "SWEAT" ], + 6 => [ 0 => "LINESET" ], + 7 => [ 0 => "W/90" ], + 8 => [ 0 => "END" ], + 9 => [ 0 => "BEND", 1 => "TWIST" ], + 10 => [ 0 => "SUCTION", 1 => "WEIGHT" ], + 11 => [ 0 => "LINE" ], + 12 => [ 0 => "INSULATED" ] + ]; + $this->synReaderModel->expects($this->once()) + ->method('loadByPhrase') + ->with($phrase) + ->willReturnSelf(); + $this->synReaderModel->expects($this->once()) + ->method('getData') + ->willReturn([ + ['synonyms' => 'BEND,TWIST'], + ['synonyms' => 'SUCTION,WEIGHT'], + ]); + + $actual = $this->synonymAnalyzer->getSynonymsForPhrase($phrase); + $this->assertEquals($expected, $actual); + } } From c36f29b1c66720217c52b63b6a79801ff29c5f1e Mon Sep 17 00:00:00 2001 From: Marush Denchev Date: Sat, 24 Oct 2020 10:00:19 +0300 Subject: [PATCH 12/69] Use new array with quoted words to prevent recurrsive adding of escape symbols --- app/code/Magento/Search/Model/SynonymAnalyzer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Search/Model/SynonymAnalyzer.php b/app/code/Magento/Search/Model/SynonymAnalyzer.php index fce78f13c2f6d..f9d18179be4ee 100644 --- a/app/code/Magento/Search/Model/SynonymAnalyzer.php +++ b/app/code/Magento/Search/Model/SynonymAnalyzer.php @@ -137,10 +137,10 @@ private function getSearchPattern(array $words): string { $patterns = []; for ($lastItem = count($words); $lastItem > 0; $lastItem--) { - $words = array_map(function ($word) { - return preg_quote(stripslashes($word), '/'); + $safeRegexWords = array_map(function ($word) { + return preg_quote($word, '/'); }, $words); - $phrase = implode("\s+", \array_slice($words, 0, $lastItem)); + $phrase = implode("\s+", \array_slice($safeRegexWords, 0, $lastItem)); $patterns[] = '^' . $phrase . ','; $patterns[] = ',' . $phrase . ','; $patterns[] = ',' . $phrase . '$'; From 98e2d0fb46cc6f8e0a5bb611ed3ccb760ef7203b Mon Sep 17 00:00:00 2001 From: Oleh Usik Date: Sat, 24 Oct 2020 19:56:49 +0300 Subject: [PATCH 13/69] add Backward Compatibility --- .../Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml | 1 + .../Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml | 2 +- .../OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml | 1 + ...ePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml | 1 + .../Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml | 1 + .../Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml | 1 + ...ppingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml | 1 + ...entShippingAndBillingAddressAndProductWithTierPricesTest.xml | 1 + ...ingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml | 1 + .../Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml | 1 + ...ntCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml | 1 + ...utWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml | 1 + .../Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml | 1 + .../StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml | 2 +- .../StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml | 1 + ...ProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml | 1 + ...ProductQuantityChangesInBackendAfterCustomerCheckoutTest.xml | 2 +- .../Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml | 1 + .../Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml | 2 ++ ...tWithConditionProductQuantityEqualsToOrderedQuantityTest.xml | 1 + ...stomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml | 1 + ...orefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml | 1 + ...rontAccountDownloadableProductLinkAfterPartialRefundTest.xml | 1 + ...frontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml | 1 + 24 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml index 26d05362cbaae..743c30d6eb134 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml @@ -55,6 +55,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml index fb02d98a9d954..716b4f2ef79a9 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml @@ -55,7 +55,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml index f4bae7922a51a..e1ca55c79776b 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml @@ -55,6 +55,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml index f8e5d5bb64d89..33f9736284509 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml @@ -67,6 +67,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml index 46fe685bc327d..fb47e81d846e8 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml @@ -55,6 +55,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml index 158e33292e1a7..9a4e42b808e34 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml @@ -169,6 +169,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml index cd0b4df935026..8f0f88152028a 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml @@ -51,6 +51,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml index 99e393f9b020b..fc25e45432453 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml @@ -66,6 +66,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml index d8f433d2b70c1..4de5792e0f272 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml @@ -53,6 +53,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml index 483ae2be8c220..ed69a2be14207 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml @@ -135,6 +135,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml index 21d4acd47bfe9..2391b938ac9ef 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml @@ -63,6 +63,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml index c4243198e7655..b730add1a70e9 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml @@ -51,6 +51,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml index 16fda7c1bc951..c7480c0b6e674 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml @@ -65,6 +65,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml index 5d6ad796628df..4c1bd9747eaa8 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml @@ -179,7 +179,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml index 3c8434051c255..5eb60a0c451ba 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml @@ -50,6 +50,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml index 3fab4168ce452..15ed2a6a9166f 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml @@ -95,6 +95,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductQuantityChangesInBackendAfterCustomerCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductQuantityChangesInBackendAfterCustomerCheckoutTest.xml index f2e340c9b7474..09ad04dff7bcd 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductQuantityChangesInBackendAfterCustomerCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductQuantityChangesInBackendAfterCustomerCheckoutTest.xml @@ -47,7 +47,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml index dc11aee9db117..8530512ef57f5 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml @@ -43,6 +43,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml index 87b0e8f8b07bc..9b954d3a6ba37 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml @@ -78,6 +78,7 @@ + @@ -85,6 +86,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml index 31c44721e1be8..1947cf9b5e56f 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml @@ -44,6 +44,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml index 4389611302f77..7e5517f77b6e4 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml @@ -57,6 +57,7 @@ + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml index 1ae9534a62b88..2e1b6114d1d3a 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml @@ -136,6 +136,7 @@ + diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml index b53102ccd3d01..7f25ae42d8603 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml @@ -68,6 +68,7 @@ + diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml index 6d06f3580dfa6..828d989621e23 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml @@ -85,6 +85,7 @@ + From 72cf701a71628bb8fcd96db69c3d6cf0630295cf Mon Sep 17 00:00:00 2001 From: Nazar Klovanych Date: Tue, 27 Oct 2020 13:10:55 +0200 Subject: [PATCH 14/69] Add path verification to Mediagallery uploader plugin --- .../MediaGalleryIntegration/Plugin/SaveImageInformation.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/MediaGalleryIntegration/Plugin/SaveImageInformation.php b/app/code/Magento/MediaGalleryIntegration/Plugin/SaveImageInformation.php index a999b9004d9e5..347e73663589e 100644 --- a/app/code/Magento/MediaGalleryIntegration/Plugin/SaveImageInformation.php +++ b/app/code/Magento/MediaGalleryIntegration/Plugin/SaveImageInformation.php @@ -85,12 +85,15 @@ public function __construct( */ public function afterSave(Uploader $subject, array $result): array { - if (!$this->config->isEnabled()) { + $mediaFolder = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath(); + + if (!$this->config->isEnabled() || substr($result['path'], 0, strlen($mediaFolder)) !== $mediaFolder) { return $result; } $path = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA) ->getRelativePath(rtrim($result['path'], '/') . '/' . ltrim($result['file'], '/')); + if (!$this->isApplicable($path)) { return $result; } From d8a14596bb52ebacb5cca4a357401bb37ef24a1d Mon Sep 17 00:00:00 2001 From: David Haecker Date: Tue, 27 Oct 2020 08:56:51 -0500 Subject: [PATCH 15/69] magento/partners-magento2b2b#370: [Determine Coverage]: Add Meaningful Titles and Descriptions For All MFTF Tests in the Company, CompanyCredit, CompanyPayment, CompanyShipping, & ConfigurableSharedCatalog Modules - Fixing MFTF annotations for Company module - Cleaning up AdminReplaceCompanyAdminTest - Cleaning up AdminSetActiveCustomerGridWorkCorrectTest --- ...rontGoToCustomerAddressesPageActionGroup.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontGoToCustomerAddressesPageActionGroup.xml diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontGoToCustomerAddressesPageActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontGoToCustomerAddressesPageActionGroup.xml new file mode 100644 index 0000000000000..33287b87346e5 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontGoToCustomerAddressesPageActionGroup.xml @@ -0,0 +1,17 @@ + + + + + + Goes to the storefront customer addresses page + + + + + From 9dc798fbcb11e35f3aa77874dbda92b58cde99b3 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Mon, 2 Nov 2020 12:47:00 +0200 Subject: [PATCH 16/69] add integration test --- .../Listing/AttributeRepositoryTest.php | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Ui/Component/Listing/AttributeRepositoryTest.php diff --git a/dev/tests/integration/testsuite/Magento/Customer/Ui/Component/Listing/AttributeRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Ui/Component/Listing/AttributeRepositoryTest.php new file mode 100644 index 0000000000000..4633ee20629b4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Ui/Component/Listing/AttributeRepositoryTest.php @@ -0,0 +1,66 @@ +model = Bootstrap::getObjectManager()->create(AttributeRepository::class); + } + + /** + * Test for get store_id option array + * + * @magentoDataFixture Magento/Store/_files/core_fixturestore.php + * @return void + */ + public function testGetOptionArray(): void + { + $result = $this->model->getMetadataByCode('store_id'); + + $this->assertTrue(isset($result['options']['1']['value'])); + $this->assertEquals( + ['Default Store View', 'Fixture Store'], + $this->getStoreViewLabels($result['options'][1]['value']) + ); + + } + + /** + * Returns prepared store view labels + * + * @param array $storeViewsData + * @return array + */ + private function getStoreViewLabels(array $storeViewsData): array + { + $result = []; + foreach ($storeViewsData as $storeView) { + $result[] = str_replace("\xc2\xa0", '', $storeView['label']); + } + + return $result; + } +} From 55f6ce96c11f0485bd7fe7a036beff513f182dcb Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Mon, 2 Nov 2020 13:58:31 +0200 Subject: [PATCH 17/69] fix static --- .../Customer/Ui/Component/Listing/AttributeRepositoryTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Customer/Ui/Component/Listing/AttributeRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Ui/Component/Listing/AttributeRepositoryTest.php index 4633ee20629b4..3982f9a76d57f 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Ui/Component/Listing/AttributeRepositoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Ui/Component/Listing/AttributeRepositoryTest.php @@ -45,7 +45,6 @@ public function testGetOptionArray(): void ['Default Store View', 'Fixture Store'], $this->getStoreViewLabels($result['options'][1]['value']) ); - } /** From 8c754b292f46bac4455b9483929bfc065d3f15cc Mon Sep 17 00:00:00 2001 From: Lachlan Turner Date: Tue, 3 Nov 2020 09:26:11 +1030 Subject: [PATCH 18/69] Allow ignored columns at subscription level to be enabled/disabled --- .../Mview/Test/Unit/View/SubscriptionTest.php | 10 +++++++++- .../Magento/Framework/Mview/View/Subscription.php | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php index c321f796253c4..697071d0d3067 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/View/SubscriptionTest.php @@ -333,9 +333,15 @@ public function testBuildStatementIgnoredColumnSubscriptionLevel(): void { $tableName = 'cataloginventory_stock_item'; $ignoredColumnName = 'low_stock_date'; + $notIgnoredColumnName = 'backorders'; $viewId = 'cataloginventory_stock'; $ignoredData = [ - $viewId => [$tableName => [$ignoredColumnName]] + $viewId => [ + $tableName => [ + $ignoredColumnName => true, + $notIgnoredColumnName => false + ] + ] ]; $this->connectionMock->expects($this->once()) @@ -349,6 +355,7 @@ public function testBuildStatementIgnoredColumnSubscriptionLevel(): void 'stock_id' => ['COLUMN_NAME' => 'stock_id'], 'qty' => ['COLUMN_NAME' => 'qty'], $ignoredColumnName => ['COLUMN_NAME' => $ignoredColumnName], + $notIgnoredColumnName => ['COLUMN_NAME' => $notIgnoredColumnName] ]); $otherChangelogMock = $this->getMockForAbstractClass(ChangelogInterface::class); @@ -372,5 +379,6 @@ public function testBuildStatementIgnoredColumnSubscriptionLevel(): void $statement = $method->invoke($model, Trigger::EVENT_UPDATE, $otherChangelogMock); $this->assertStringNotContainsString($ignoredColumnName, $statement); + $this->assertStringContainsString($notIgnoredColumnName, $statement); } } diff --git a/lib/internal/Magento/Framework/Mview/View/Subscription.php b/lib/internal/Magento/Framework/Mview/View/Subscription.php index a1512dbd305bb..510a4579d160b 100644 --- a/lib/internal/Magento/Framework/Mview/View/Subscription.php +++ b/lib/internal/Magento/Framework/Mview/View/Subscription.php @@ -216,9 +216,12 @@ protected function buildStatement($event, $changelog) $describe = $this->connection->describeTable($tableName) ) { $columnNames = array_column($describe, 'COLUMN_NAME'); + $ignoredColumnsBySubscription = array_filter( + $this->ignoredUpdateColumnsBySubscription[$changelog->getViewId()][$this->getTableName()] ?? [] + ); $ignoredColumns = array_merge( $this->ignoredUpdateColumns, - $this->ignoredUpdateColumnsBySubscription[$changelog->getViewId()][$this->getTableName()] ?? [] + array_keys($ignoredColumnsBySubscription) ); $columnNames = array_diff($columnNames, $ignoredColumns); if ($columnNames) { From 482db88dfe280ee6a3f5d7703b306e11a3e9b743 Mon Sep 17 00:00:00 2001 From: Oleh Usik Date: Wed, 4 Nov 2020 11:33:31 +0200 Subject: [PATCH 19/69] Chanhed message --- .../Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml | 2 +- .../Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml | 2 +- .../OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml | 2 +- ...ageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml | 2 +- .../Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml | 2 +- .../Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml | 2 +- ...ingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml | 2 +- ...tShippingAndBillingAddressAndProductWithTierPricesTest.xml | 2 +- ...gAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml | 2 +- .../Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml | 2 +- ...CustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml | 2 +- ...WithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml | 2 +- .../Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml | 2 +- .../StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml | 2 +- .../StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml | 2 +- ...oductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml | 2 +- ...oductQuantityChangesInBackendAfterCustomerCheckoutTest.xml | 2 +- .../Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml | 2 +- .../Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml | 4 ++-- ...ithConditionProductQuantityEqualsToOrderedQuantityTest.xml | 2 +- ...omerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml | 2 +- ...efrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml | 2 +- ...ntAccountDownloadableProductLinkAfterPartialRefundTest.xml | 2 +- ...ontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml | 2 +- 24 files changed, 25 insertions(+), 25 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml index 743c30d6eb134..5fb53f0df7250 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml @@ -55,7 +55,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml index 716b4f2ef79a9..813511897246a 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml @@ -55,7 +55,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml index e1ca55c79776b..7bcebba50e3ae 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml @@ -55,7 +55,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml index 33f9736284509..318a93fab861c 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml @@ -67,7 +67,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml index fb47e81d846e8..e995068b72a60 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml @@ -55,7 +55,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml index 9a4e42b808e34..93a561cb957d8 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml @@ -169,7 +169,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml index 8f0f88152028a..93edf648c52b2 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml @@ -51,7 +51,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml index fc25e45432453..357628a35082a 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml @@ -66,7 +66,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml index 4de5792e0f272..55fc51bc3d6d6 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml @@ -53,7 +53,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml index ed69a2be14207..4306edcc3c748 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml @@ -135,7 +135,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml index 2391b938ac9ef..b6e001a051b1f 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml @@ -63,7 +63,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml index b730add1a70e9..6abf99a4eee8e 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml @@ -51,7 +51,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml index c7480c0b6e674..32fd8e427c5ed 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml @@ -65,7 +65,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml index 4c1bd9747eaa8..1e158d41e5605 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml @@ -179,7 +179,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml index 5eb60a0c451ba..e9fcd571d3f21 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml @@ -50,7 +50,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml index 15ed2a6a9166f..48ea3ed3dd4c2 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml @@ -95,7 +95,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductQuantityChangesInBackendAfterCustomerCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductQuantityChangesInBackendAfterCustomerCheckoutTest.xml index 09ad04dff7bcd..50f906fa9d2ca 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductQuantityChangesInBackendAfterCustomerCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductQuantityChangesInBackendAfterCustomerCheckoutTest.xml @@ -47,7 +47,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml index 8530512ef57f5..2e8fd321fd2e3 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml @@ -43,7 +43,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml index 9b954d3a6ba37..3ee0202d655ad 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml @@ -78,7 +78,7 @@ - + @@ -86,7 +86,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml index 1947cf9b5e56f..e6eb67489bf69 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml @@ -44,7 +44,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml index 7e5517f77b6e4..7208884b70560 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml @@ -57,7 +57,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml index 2e1b6114d1d3a..d839003a8d576 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml @@ -136,7 +136,7 @@ - + diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml index 7f25ae42d8603..17f5d95d041dd 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml @@ -68,7 +68,7 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml index 828d989621e23..fd845c97429ae 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml @@ -85,7 +85,7 @@ - + From 868e856316ec24c1dd03011c39a9066a87461eba Mon Sep 17 00:00:00 2001 From: Oleh Usik Date: Wed, 4 Nov 2020 12:55:59 +0200 Subject: [PATCH 20/69] minor fix --- .../Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml | 2 +- .../Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml | 2 +- .../OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml | 2 +- ...ageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml | 2 +- .../Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml | 2 +- .../Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml | 2 +- ...ingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml | 2 +- ...tShippingAndBillingAddressAndProductWithTierPricesTest.xml | 2 +- ...gAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml | 2 +- .../Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml | 2 +- ...CustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml | 2 +- ...WithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml | 2 +- .../Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml | 2 +- .../StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml | 2 +- .../StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml | 2 +- ...oductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml | 2 +- .../Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml | 2 +- .../Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml | 4 ++-- ...ithConditionProductQuantityEqualsToOrderedQuantityTest.xml | 2 +- ...omerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml | 2 +- ...efrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml | 2 +- ...ntAccountDownloadableProductLinkAfterPartialRefundTest.xml | 2 +- ...ontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml | 2 +- 23 files changed, 24 insertions(+), 24 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml index 5fb53f0df7250..3d7f8e1dcfed4 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingDefaultAddressTest.xml @@ -55,7 +55,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml index 813511897246a..2a458ce8added 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNewAddressTest.xml @@ -55,7 +55,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml index 7bcebba50e3ae..8fcb8211c4625 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonDefaultAddressTest.xml @@ -55,7 +55,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml index 318a93fab861c..6b1d3a7ba66aa 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutAsCustomerUsingNonExistentCustomerGroupTest.xml @@ -67,7 +67,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml index e995068b72a60..c7b1c441f1978 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutUsingSignInLinkTest.xml @@ -55,7 +55,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml index 93a561cb957d8..ce8bfc37389fb 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml @@ -169,7 +169,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml index 93edf648c52b2..1ea3f118f9f23 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndCreateCustomerAfterCheckoutTest.xml @@ -51,7 +51,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml index 357628a35082a..35328c58cdd49 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndProductWithTierPricesTest.xml @@ -66,7 +66,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml index 55fc51bc3d6d6..e50a1880dee3c 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithDifferentShippingAndBillingAddressAndRegisterCustomerAfterCheckoutTest.xml @@ -53,7 +53,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml index 4306edcc3c748..646983eafcf08 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutWithSpecialPriceProductsTest.xml @@ -135,7 +135,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml index b6e001a051b1f..bc24b8895d50a 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutOnLoginWhenGuestCheckoutIsDisabledTest.xml @@ -63,7 +63,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml index 6abf99a4eee8e..526d23afa05e0 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutWithNewCustomerRegistrationAndDisableGuestCheckoutTest.xml @@ -51,7 +51,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml index 32fd8e427c5ed..4b98a1f177af8 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml @@ -65,7 +65,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml index 1e158d41e5605..533876c1b03c2 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutUsingFreeShippingAndTaxesTest.xml @@ -179,7 +179,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml index e9fcd571d3f21..c58e4ab7513af 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml @@ -50,7 +50,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml index 48ea3ed3dd4c2..91086a4b3788e 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml @@ -95,7 +95,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml index 2e8fd321fd2e3..99a9e0273430d 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontRefreshPageDuringGuestCheckoutTest.xml @@ -43,7 +43,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml index 3ee0202d655ad..a8b8cf66f545b 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml @@ -78,7 +78,7 @@ - + @@ -86,7 +86,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml index e6eb67489bf69..dfb778bc2e027 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKGuestCheckoutWithConditionProductQuantityEqualsToOrderedQuantityTest.xml @@ -44,7 +44,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml index 7208884b70560..7be123d9cb71f 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUSCustomerCheckoutWithCouponAndBankTransferPaymentMethodTest.xml @@ -57,7 +57,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml index d839003a8d576..38cc4fe8abcf3 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontVerifyGuestCheckoutUsingFreeShippingAndTaxesTest.xml @@ -136,7 +136,7 @@ - + diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml index 17f5d95d041dd..b89aa7d126686 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml @@ -68,7 +68,7 @@ - + diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml index fd845c97429ae..be2749e64f65c 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml @@ -85,7 +85,7 @@ - + From c62a878a6c16f342d5ac9a5faa62ff981e2dbd12 Mon Sep 17 00:00:00 2001 From: Oleh Usik Date: Wed, 4 Nov 2020 15:08:47 +0200 Subject: [PATCH 21/69] select shipping method --- ...vailableToConfigureDisabledProductTest.xml | 8 ++++---- ...kGetShippingMethodsAndRatesActionGroup.xml | 19 +++++++++++++++++++ ...inSelectFixedShippingMethodActionGroup.xml | 19 +++++++++++++++++++ .../CreateInvoiceAndCheckInvoiceOrderTest.xml | 8 ++++---- ...iceWithCashOnDeliveryPaymentMethodTest.xml | 8 ++++---- ...eWithShipmentAndCheckInvoicedOrderTest.xml | 8 ++++---- .../CreateOrderFromEditCustomerPageTest.xml | 4 ++-- ...eredConfigurableProductOnOrderPageTest.xml | 8 ++++---- 8 files changed, 60 insertions(+), 22 deletions(-) create mode 100644 app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickGetShippingMethodsAndRatesActionGroup.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminSelectFixedShippingMethodActionGroup.xml diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoOptionAvailableToConfigureDisabledProductTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoOptionAvailableToConfigureDisabledProductTest.xml index aa2c19ebc17f4..6e977a7749145 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoOptionAvailableToConfigureDisabledProductTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoOptionAvailableToConfigureDisabledProductTest.xml @@ -173,10 +173,10 @@ - - - - + + + + diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickGetShippingMethodsAndRatesActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickGetShippingMethodsAndRatesActionGroup.xml new file mode 100644 index 0000000000000..790b0db584e4f --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickGetShippingMethodsAndRatesActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + Click 'Get Shipping Methods And Rates' button on the admin create order page. + + + + + + diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminSelectFixedShippingMethodActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminSelectFixedShippingMethodActionGroup.xml new file mode 100644 index 0000000000000..6b1f882eee5f7 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminSelectFixedShippingMethodActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + Select Fixed Shipping Method on the admin create order page. + + + + + + diff --git a/app/code/Magento/Sales/Test/Mftf/Test/CreateInvoiceAndCheckInvoiceOrderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/CreateInvoiceAndCheckInvoiceOrderTest.xml index de6e7ff22b7af..42faab9dc3f07 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/CreateInvoiceAndCheckInvoiceOrderTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/CreateInvoiceAndCheckInvoiceOrderTest.xml @@ -65,10 +65,10 @@ - - - - + + + + diff --git a/app/code/Magento/Sales/Test/Mftf/Test/CreateInvoiceWithCashOnDeliveryPaymentMethodTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/CreateInvoiceWithCashOnDeliveryPaymentMethodTest.xml index 57e42e9b190e3..f8b171a587e09 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/CreateInvoiceWithCashOnDeliveryPaymentMethodTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/CreateInvoiceWithCashOnDeliveryPaymentMethodTest.xml @@ -62,10 +62,10 @@ - - - - + + + + diff --git a/app/code/Magento/Sales/Test/Mftf/Test/CreateInvoiceWithShipmentAndCheckInvoicedOrderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/CreateInvoiceWithShipmentAndCheckInvoicedOrderTest.xml index 10c6be60f5ba1..cfc42c98a5e71 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/CreateInvoiceWithShipmentAndCheckInvoicedOrderTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/CreateInvoiceWithShipmentAndCheckInvoicedOrderTest.xml @@ -59,10 +59,10 @@ - - - - + + + + diff --git a/app/code/Magento/Sales/Test/Mftf/Test/CreateOrderFromEditCustomerPageTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/CreateOrderFromEditCustomerPageTest.xml index 77b119dd583de..367c50359701c 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/CreateOrderFromEditCustomerPageTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/CreateOrderFromEditCustomerPageTest.xml @@ -182,8 +182,8 @@ - - + + diff --git a/app/code/Magento/Sales/Test/Mftf/Test/MoveLastOrderedConfigurableProductOnOrderPageTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/MoveLastOrderedConfigurableProductOnOrderPageTest.xml index 8e9e117d2d995..b0a63e7326cdf 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/MoveLastOrderedConfigurableProductOnOrderPageTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/MoveLastOrderedConfigurableProductOnOrderPageTest.xml @@ -84,10 +84,10 @@ - - - - + + + + From 6e41d2014c25176f68961975ab656b291e7788ec Mon Sep 17 00:00:00 2001 From: engcom-Echo Date: Thu, 5 Nov 2020 18:05:10 +0200 Subject: [PATCH 22/69] MC-30626: Custom Option with Percent price is converted to a currency twice --- .../Product/View/Options/AbstractOptions.php | 17 ++++++-- .../Catalog/Test/Mftf/Data/ProductData.xml | 4 ++ ...CustomOptionPriceDifferentCurrencyTest.xml | 41 +++++++++++++++++++ 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml diff --git a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php index de92546a8dd88..b6457d8ca880b 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php +++ b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php @@ -12,10 +12,10 @@ namespace Magento\Catalog\Block\Product\View\Options; -use Magento\Catalog\Pricing\Price\BasePrice; use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule; use Magento\Catalog\Pricing\Price\CustomOptionPriceInterface; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Pricing\Adjustment\CalculatorInterface; /** * Product options section abstract block. @@ -55,24 +55,33 @@ abstract class AbstractOptions extends \Magento\Framework\View\Element\Template */ private $calculateCustomOptionCatalogRule; + /** + * @var CalculatorInterface + */ + protected $calculator; + /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\Pricing\Helper\Data $pricingHelper * @param \Magento\Catalog\Helper\Data $catalogData * @param array $data * @param CalculateCustomOptionCatalogRule|null $calculateCustomOptionCatalogRule + * @param CalculatorInterface|null $calculator */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Pricing\Helper\Data $pricingHelper, \Magento\Catalog\Helper\Data $catalogData, array $data = [], - CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null + CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null, + CalculatorInterface $calculator = null ) { $this->pricingHelper = $pricingHelper; $this->_catalogHelper = $catalogData; $this->calculateCustomOptionCatalogRule = $calculateCustomOptionCatalogRule ?? ObjectManager::getInstance()->get(CalculateCustomOptionCatalogRule::class); + $this->calculator = $calculator + ?? ObjectManager::getInstance()->get(CalculatorInterface::class); parent::__construct($context, $data); } @@ -188,7 +197,9 @@ protected function _formatPrice($value, $flag = true) } $context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true]; - $optionAmount = $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context); + $optionAmount = !$isPercent + ? $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context) + : $this->calculator->getAmount($value['pricing_value'], $this->getProduct(), null, $context); $priceStr .= $this->getLayout()->getBlock('product.price.render.default')->renderAmount( $optionAmount, $customOptionPrice, diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml index 716c4b07d2f1d..e7760a9b90f0c 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml @@ -577,6 +577,10 @@ ProductOptionDropDownWithLongValuesTitle + + + ProductOptionCheckbox + ProductOptionValueDropdown diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml new file mode 100644 index 0000000000000..f58daac8fbbd9 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml @@ -0,0 +1,41 @@ + + + + + + + + + <description value="Check custom option price with different currency on the product page"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-38926"/> + <useCaseId value="MC-30626"/> + <group value="catalog"/> + </annotations> + <before> + <magentoCLI command="config:set currency/options/allow EUR,USD" stepKey="setCurrencyAllow"/> + <createData entity="SimpleProduct2" stepKey="createProduct"> + <field key="price">10</field> + </createData> + <updateData createDataKey="createProduct" entity="productWithCheckbox" stepKey="updateProductWithOptions"/> + </before> + <after> + <magentoCLI command="config:set currency/options/allow USD" stepKey="setCurrencyAllow"/> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + </after> + <actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProductPageOnStorefront"> + <argument name="product" value="$createProduct$"/> + </actionGroup> + <seeElement selector="{{StorefrontProductInfoMainSection.productAttributeOptionsCheckbox(ProductOptionCheckbox.title, '12.3')}}" stepKey="checkPriceProductOptionUSD"/> + <actionGroup ref="StorefrontSwitchCurrencyActionGroup" stepKey="switchEURCurrency"> + <argument name="currency" value="EUR"/> + </actionGroup> + <seeElement selector="{{StorefrontProductInfoMainSection.productAttributeOptionsCheckbox(ProductOptionCheckbox.title, '8.6961')}}" stepKey="checkPriceProductOptionEUR"/> + </test> +</tests> From a029681a4ec1e4fffe4a61b6fb148ebbd6322d2f Mon Sep 17 00:00:00 2001 From: engcom-Echo <engcom-vendorworker-echo@adobe.com> Date: Fri, 6 Nov 2020 10:41:40 +0200 Subject: [PATCH 23/69] MC-30626: Custom Option with Percent price is converted to a currency twice --- .../Product/View/Options/AbstractOptions.php | 14 ++------------ .../Catalog/Pricing/Price/CustomOptionPrice.php | 15 +++++++++++++++ ...heckCustomOptionPriceDifferentCurrencyTest.xml | 10 ++++++++-- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php index b6457d8ca880b..20cf3322512ce 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php +++ b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php @@ -15,7 +15,6 @@ use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule; use Magento\Catalog\Pricing\Price\CustomOptionPriceInterface; use Magento\Framework\App\ObjectManager; -use Magento\Framework\Pricing\Adjustment\CalculatorInterface; /** * Product options section abstract block. @@ -55,33 +54,24 @@ abstract class AbstractOptions extends \Magento\Framework\View\Element\Template */ private $calculateCustomOptionCatalogRule; - /** - * @var CalculatorInterface - */ - protected $calculator; - /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\Pricing\Helper\Data $pricingHelper * @param \Magento\Catalog\Helper\Data $catalogData * @param array $data * @param CalculateCustomOptionCatalogRule|null $calculateCustomOptionCatalogRule - * @param CalculatorInterface|null $calculator */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Pricing\Helper\Data $pricingHelper, \Magento\Catalog\Helper\Data $catalogData, array $data = [], - CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null, - CalculatorInterface $calculator = null + CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null ) { $this->pricingHelper = $pricingHelper; $this->_catalogHelper = $catalogData; $this->calculateCustomOptionCatalogRule = $calculateCustomOptionCatalogRule ?? ObjectManager::getInstance()->get(CalculateCustomOptionCatalogRule::class); - $this->calculator = $calculator - ?? ObjectManager::getInstance()->get(CalculatorInterface::class); parent::__construct($context, $data); } @@ -199,7 +189,7 @@ protected function _formatPrice($value, $flag = true) $context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true]; $optionAmount = !$isPercent ? $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context) - : $this->calculator->getAmount($value['pricing_value'], $this->getProduct(), null, $context); + : $customOptionPrice->getCustomRoundAmount($value['pricing_value'], $context); $priceStr .= $this->getLayout()->getBlock('product.price.render.default')->renderAmount( $optionAmount, $customOptionPrice, diff --git a/app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php b/app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php index 93bf7920355db..b5348f9048e82 100644 --- a/app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php +++ b/app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php @@ -124,6 +124,8 @@ public function getValue($priceCode = \Magento\Catalog\Pricing\Price\BasePrice:: } /** + * Get Custom Amount object + * * @param float $amount * @param null|bool|string|array $exclude * @param null|array $context @@ -161,6 +163,19 @@ public function getCustomOptionRange($getMin, $priceCode = \Magento\Catalog\Pric return $this->priceCurrency->convertAndRound($optionValue); } + /** + * Get custom amount without currency convert + * + * @param float|string $amount + * @param null|array $context + * @return AmountInterface + */ + public function getCustomRoundAmount($amount, $context = []) + { + $amount = $this->priceCurrency->roundPrice($amount); + return $this->calculator->getAmount($amount, $this->getProduct(), null, $context); + } + /** * Return price for select custom options * diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml index f58daac8fbbd9..a75accd665e23 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml @@ -20,14 +20,20 @@ </annotations> <before> <magentoCLI command="config:set currency/options/allow EUR,USD" stepKey="setCurrencyAllow"/> - <createData entity="SimpleProduct2" stepKey="createProduct"> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="_defaultProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> <field key="price">10</field> </createData> <updateData createDataKey="createProduct" entity="productWithCheckbox" stepKey="updateProductWithOptions"/> + <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> + <argument name="indices" value=""/> + </actionGroup> </before> <after> <magentoCLI command="config:set currency/options/allow USD" stepKey="setCurrencyAllow"/> <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> </after> <actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProductPageOnStorefront"> <argument name="product" value="$createProduct$"/> @@ -36,6 +42,6 @@ <actionGroup ref="StorefrontSwitchCurrencyActionGroup" stepKey="switchEURCurrency"> <argument name="currency" value="EUR"/> </actionGroup> - <seeElement selector="{{StorefrontProductInfoMainSection.productAttributeOptionsCheckbox(ProductOptionCheckbox.title, '8.6961')}}" stepKey="checkPriceProductOptionEUR"/> + <seeElement selector="{{StorefrontProductInfoMainSection.productAttributeOptionsCheckbox(ProductOptionCheckbox.title, '8.7')}}" stepKey="checkPriceProductOptionEUR"/> </test> </tests> From a1309c212db790963c0e9069a2dc03a9bc1b9b96 Mon Sep 17 00:00:00 2001 From: Stas Kozar <stas.kozar@transoftgroup.com> Date: Fri, 6 Nov 2020 18:10:55 +0200 Subject: [PATCH 24/69] MC-38807: Preview Template button does not work in Queue Edit Page --- lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js index d74838b0c26bf..fdb2e626e1263 100644 --- a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js +++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js @@ -749,6 +749,13 @@ define([ */ addContentEditableAttributeBackToNonEditableNodes: function () { jQuery('.mceNonEditable', this.activeEditor().getDoc()).attr('contenteditable', false); + }, + + /** + * Calls the save method on all editor instances in the collection. + */ + triggerSave: function () { + tinyMCE4.triggerSave(); } }; From 6eff50743ab356795666a2d013a0aebab9655333 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" <engcom-vendorworker-charlie@adobe.com> Date: Mon, 9 Nov 2020 11:58:14 +0200 Subject: [PATCH 25/69] add a check on is array --- .../Customer/Ui/Component/Listing/AttributeRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php b/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php index b562adf228d7c..c409257a40123 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/AttributeRepository.php @@ -144,7 +144,7 @@ protected function getOptionArray(array $options) /** @var \Magento\Customer\Api\Data\OptionInterface $option */ foreach ($options as &$option) { $value = $option->getValue(); - if ($option->getOptions()) { + if (is_array($option->getOptions())) { $value = $this->getOptionArray($option->getOptions()); } $option = [ From 1327f542276221929bb38086c6679d9110fac3ad Mon Sep 17 00:00:00 2001 From: "rostyslav.hymon" <rostyslav.hymon@transoftgroup.com> Date: Tue, 10 Nov 2020 10:55:11 +0200 Subject: [PATCH 26/69] MC-38247: Failure of connections to UPS XML/USPS/DHL API will cause the checkout to break --- app/code/Magento/Dhl/Model/Carrier.php | 21 ++++-- app/code/Magento/Ups/Model/Carrier.php | 16 +++-- app/code/Magento/Usps/Model/Carrier.php | 25 +++++-- .../HTTP/AsyncClientInterfaceMock.php | 22 +++++- .../Magento/Dhl/Model/CarrierTest.php | 30 ++++++++ .../Magento/Ups/Model/CarrierTest.php | 47 ++++++++++++ .../Magento/Usps/Model/CarrierTest.php | 71 +++++++++++++++++++ 7 files changed, 213 insertions(+), 19 deletions(-) diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index c5eb27b21e58b..9781b521597ba 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -7,22 +7,23 @@ namespace Magento\Dhl\Model; use Magento\Catalog\Model\Product\Type; +use Magento\Dhl\Model\Validator\XmlValidator; use Magento\Framework\App\ObjectManager; use Magento\Framework\App\ProductMetadataInterface; use Magento\Framework\Async\CallbackDeferred; +use Magento\Framework\HTTP\AsyncClient\HttpException; use Magento\Framework\HTTP\AsyncClient\HttpResponseDeferredInterface; use Magento\Framework\HTTP\AsyncClient\Request; use Magento\Framework\HTTP\AsyncClientInterface; use Magento\Framework\Module\Dir; -use Magento\Sales\Exception\DocumentValidationException; -use Magento\Sales\Model\Order\Shipment; +use Magento\Framework\Xml\Security; use Magento\Quote\Model\Quote\Address\RateRequest; use Magento\Quote\Model\Quote\Address\RateResult\Error; +use Magento\Sales\Exception\DocumentValidationException; +use Magento\Sales\Model\Order\Shipment; use Magento\Shipping\Model\Carrier\AbstractCarrier; use Magento\Shipping\Model\Rate\Result; use Magento\Shipping\Model\Rate\Result\ProxyDeferredFactory; -use Magento\Framework\Xml\Security; -use Magento\Dhl\Model\Validator\XmlValidator; /** * DHL International (API v1.4) @@ -1064,8 +1065,15 @@ protected function _getQuotes() function () use ($deferredResponses, $responseBodies) { //Loading rates not found in cache foreach ($deferredResponses as $deferredResponseData) { + $responseResult = null; + try { + $responseResult = $deferredResponseData['deferred']->get(); + } catch (HttpException $exception) { + $this->_logger->critical($exception); + } + $responseBody = $responseResult ? $responseResult->getBody() : ''; $responseBodies[] = [ - 'body' => $deferredResponseData['deferred']->get()->getBody(), + 'body' => $responseBody, 'date' => $deferredResponseData['date'], 'request' => $deferredResponseData['request'], 'from_cache' => false @@ -2028,7 +2036,8 @@ protected function _checkDomesticStatus($origCountryCode, $destCountryCode) $isDomestic = (string)$this->getCountryParams($destCountryCode)->getData('domestic'); if (($origCountry == $destCountry && $isDomestic) - || ($this->_carrierHelper->isCountryInEU($origCountryCode) + || ( + $this->_carrierHelper->isCountryInEU($origCountryCode) && $this->_carrierHelper->isCountryInEU($destCountryCode) ) ) { diff --git a/app/code/Magento/Ups/Model/Carrier.php b/app/code/Magento/Ups/Model/Carrier.php index 28a4a3a7e0b41..452f488050202 100644 --- a/app/code/Magento/Ups/Model/Carrier.php +++ b/app/code/Magento/Ups/Model/Carrier.php @@ -17,6 +17,7 @@ use Magento\Framework\Async\CallbackDeferred; use Magento\Framework\DataObject; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\HTTP\AsyncClient\HttpException; use Magento\Framework\HTTP\AsyncClient\HttpResponseDeferredInterface; use Magento\Framework\HTTP\AsyncClient\Request; use Magento\Framework\HTTP\AsyncClientInterface; @@ -33,6 +34,7 @@ use Magento\Shipping\Model\Rate\Result; use Magento\Shipping\Model\Rate\Result\ProxyDeferredFactory; use Magento\Shipping\Model\Rate\ResultFactory as RateFactory; +use Magento\Shipping\Model\Shipment\Request as Shipment; use Magento\Shipping\Model\Simplexml\Element; use Magento\Shipping\Model\Simplexml\ElementFactory; use Magento\Shipping\Model\Tracking\Result\ErrorFactory as TrackErrorFactory; @@ -40,7 +42,6 @@ use Magento\Shipping\Model\Tracking\ResultFactory as TrackFactory; use Magento\Store\Model\ScopeInterface; use Magento\Ups\Helper\Config; -use Magento\Shipping\Model\Shipment\Request as Shipment; use Psr\Log\LoggerInterface; use RuntimeException; use Throwable; @@ -811,10 +812,15 @@ protected function _getXmlQuotes() [ 'deferred' => new CallbackDeferred( function () use ($httpResponse) { - if ($httpResponse->get()->getStatusCode() >= 400) { - $xmlResponse = ''; - } else { - $xmlResponse = $httpResponse->get()->getBody(); + $responseResult = null; + $xmlResponse = ''; + try { + $responseResult = $httpResponse->get(); + } catch (HttpException $exception) { + $this->_logger->critical($exception); + } + if ($responseResult) { + $xmlResponse = $responseResult->getStatusCode() >= 400 ? '' : $responseResult->getBody(); } return $this->_parseXmlResponse($xmlResponse); diff --git a/app/code/Magento/Usps/Model/Carrier.php b/app/code/Magento/Usps/Model/Carrier.php index 85e0cf2f6999a..47bb68a10ad50 100644 --- a/app/code/Magento/Usps/Model/Carrier.php +++ b/app/code/Magento/Usps/Model/Carrier.php @@ -8,6 +8,8 @@ use Magento\Framework\App\ObjectManager; use Magento\Framework\Async\CallbackDeferred; +use Magento\Framework\DataObject; +use Magento\Framework\HTTP\AsyncClient\HttpException; use Magento\Framework\HTTP\AsyncClient\Request; use Magento\Framework\HTTP\AsyncClientInterface; use Magento\Framework\Xml\Security; @@ -25,19 +27,19 @@ */ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\Carrier\CarrierInterface { - /** @deprecated */ + /** @deprecated Redundant dependency */ const CONTAINER_VARIABLE = 'VARIABLE'; - /** @deprecated */ + /** @deprecated Redundant dependency */ const CONTAINER_FLAT_RATE_BOX = 'FLAT RATE BOX'; - /** @deprecated */ + /** @deprecated Redundant dependency */ const CONTAINER_FLAT_RATE_ENVELOPE = 'FLAT RATE ENVELOPE'; - /** @deprecated */ + /** @deprecated Redundant dependency */ const CONTAINER_RECTANGULAR = 'RECTANGULAR'; - /** @deprecated */ + /** @deprecated Redundant dependency */ const CONTAINER_NONRECTANGULAR = 'NONRECTANGULAR'; /** @@ -149,6 +151,11 @@ class Carrier extends AbstractCarrierOnline implements \Magento\Shipping\Model\C */ private $proxyDeferredFactory; + /** + * @var DataObject + */ + private $_rawTrackRequest; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory @@ -560,7 +567,13 @@ protected function _getXmlQuotes() [ 'deferred' => new CallbackDeferred( function () use ($deferredResponse, $request, $debugData) { - $responseBody = $deferredResponse->get()->getBody(); + $responseResult = null; + try { + $responseResult = $deferredResponse->get(); + } catch (HttpException $exception) { + $this->_logger->critical($exception); + } + $responseBody = $responseResult ? $responseResult->getBody() : ''; $debugData['result'] = $responseBody; $this->_setCachedQuotes($request, $responseBody); $this->_debug($debugData); diff --git a/dev/tests/integration/framework/Magento/TestFramework/HTTP/AsyncClientInterfaceMock.php b/dev/tests/integration/framework/Magento/TestFramework/HTTP/AsyncClientInterfaceMock.php index ab0020917a9e9..8f2ae2a7b0bdf 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/HTTP/AsyncClientInterfaceMock.php +++ b/dev/tests/integration/framework/Magento/TestFramework/HTTP/AsyncClientInterfaceMock.php @@ -38,6 +38,11 @@ class AsyncClientInterfaceMock implements AsyncClientInterface */ private $requests = []; + /** + * @var HttpResponseDeferredInterface + */ + private $mockDeferredResponse; + /** * AsyncClientInterfaceMock constructor. * @param GuzzleAsyncClient $client @@ -89,6 +94,19 @@ public function clearRequests() $this->lastRequest = null; } + /** + * Next responses will be as given. + * + * @param HttpResponseDeferredInterface $mockDeferredResponse + * @return self + */ + public function setDeferredResponseMock(HttpResponseDeferredInterface $mockDeferredResponse): self + { + $this->mockDeferredResponse = $mockDeferredResponse; + + return $this; + } + /** * @inheritDoc */ @@ -96,8 +114,8 @@ public function request(Request $request): HttpResponseDeferredInterface { $this->lastRequest = $request; $this->requests[] = $request; - if ($mockResponse = array_shift($this->mockResponses)) { - return new MockDeferredResponse($mockResponse); + if ($mockResponse = $this->mockDeferredResponse ?? array_shift($this->mockResponses)) { + return $this->mockDeferredResponse ?? new MockDeferredResponse($mockResponse); } return $this->client->request($request); diff --git a/dev/tests/integration/testsuite/Magento/Dhl/Model/CarrierTest.php b/dev/tests/integration/testsuite/Magento/Dhl/Model/CarrierTest.php index 7f9ca38353b2e..f9a1d2923e5be 100644 --- a/dev/tests/integration/testsuite/Magento/Dhl/Model/CarrierTest.php +++ b/dev/tests/integration/testsuite/Magento/Dhl/Model/CarrierTest.php @@ -9,10 +9,13 @@ use Magento\Framework\App\Config\ReinitableConfigInterface; use Magento\Framework\DataObject; +use Magento\Framework\HTTP\AsyncClient\HttpException; +use Magento\Framework\HTTP\AsyncClient\HttpResponseDeferredInterface; use Magento\Framework\HTTP\AsyncClient\Response; use Magento\Framework\HTTP\AsyncClientInterface; use Magento\Framework\Simplexml\Element; use Magento\Quote\Model\Quote\Address\RateRequest; +use Magento\Quote\Model\Quote\Address\RateResult\Error; use Magento\Shipping\Model\Shipment\Request; use Magento\Shipping\Model\Tracking\Result\Status; use Magento\Store\Model\ScopeInterface; @@ -475,6 +478,33 @@ public function testCollectRatesWithoutDimensions(?string $size, ?string $height $this->config->reinit(); } + /** + * Test get carriers rates if has HttpException. + * + * @magentoConfigFixture default_store carriers/dhl/active 1 + */ + public function testGetRatesWithHttpException(): void + { + $this->setDhlConfig(['showmethod' => 1]); + $requestData = $this->getRequestData(); + $deferredResponse = $this->getMockBuilder(HttpResponseDeferredInterface::class) + ->onlyMethods(['get']) + ->getMockForAbstractClass(); + $exception = new HttpException('Exception message'); + $deferredResponse->method('get')->willThrowException($exception); + $this->httpClient->setDeferredResponseMock($deferredResponse); + /** @var RateRequest $request */ + $request = Bootstrap::getObjectManager()->create(RateRequest::class, $requestData); + $this->dhlCarrier = Bootstrap::getObjectManager()->create(Carrier::class); + $resultRate = $this->dhlCarrier->collectRates($request)->getAllRates()[0]; + $error = Bootstrap::getObjectManager()->get(Error::class); + $error->setCarrier('dhl'); + $error->setCarrierTitle($this->dhlCarrier->getConfigData('title')); + $error->setErrorMessage($this->dhlCarrier->getConfigData('specificerrmsg')); + + $this->assertEquals($error, $resultRate); + } + /** * @return array */ diff --git a/dev/tests/integration/testsuite/Magento/Ups/Model/CarrierTest.php b/dev/tests/integration/testsuite/Magento/Ups/Model/CarrierTest.php index 345c572b92861..7000fadd5154d 100644 --- a/dev/tests/integration/testsuite/Magento/Ups/Model/CarrierTest.php +++ b/dev/tests/integration/testsuite/Magento/Ups/Model/CarrierTest.php @@ -9,9 +9,12 @@ use Magento\Framework\App\Config\ReinitableConfigInterface; use Magento\Framework\DataObject; +use Magento\Framework\HTTP\AsyncClient\HttpException; +use Magento\Framework\HTTP\AsyncClient\HttpResponseDeferredInterface; use Magento\Framework\HTTP\AsyncClient\Response; use Magento\Framework\HTTP\AsyncClientInterface; use Magento\Quote\Model\Quote\Address\RateRequest; +use Magento\Quote\Model\Quote\Address\RateResult\Error; use Magento\TestFramework\Helper\Bootstrap; use Magento\Quote\Model\Quote\Address\RateRequestFactory; use Magento\TestFramework\HTTP\AsyncClientInterfaceMock; @@ -290,6 +293,50 @@ public function testRequestToShipment(): void $this->httpClient->clearRequests(); } + /** + * Test get carriers rates if has HttpException. + * + * @magentoConfigFixture default_store shipping/origin/country_id GB + * @magentoConfigFixture default_store carriers/ups/type UPS_XML + * @magentoConfigFixture default_store carriers/ups/active 1 + * @magentoConfigFixture default_store carriers/ups/shipper_number 12345 + * @magentoConfigFixture default_store carriers/ups/origin_shipment Shipments Originating in the European Union + * @magentoConfigFixture default_store carriers/ups/username user + * @magentoConfigFixture default_store carriers/ups/password pass + * @magentoConfigFixture default_store carriers/ups/access_license_number acn + * @magentoConfigFixture default_store currency/options/allow GBP,USD,EUR + * @magentoConfigFixture default_store currency/options/base GBP + */ + public function testGetRatesWithHttpException(): void + { + $deferredResponse = $this->getMockBuilder(HttpResponseDeferredInterface::class) + ->onlyMethods(['get']) + ->getMockForAbstractClass(); + $exception = new HttpException('Exception message'); + $deferredResponse->method('get')->willThrowException($exception); + $this->httpClient->setDeferredResponseMock($deferredResponse); + $request = Bootstrap::getObjectManager()->create( + RateRequest::class, + [ + 'data' => [ + 'dest_country' => 'GB', + 'dest_postal' => '01105', + 'product' => '11', + 'action' => 'Rate', + 'unit_measure' => 'KGS', + 'base_currency' => new DataObject(['code' => 'GBP']) + ] + ] + ); + $resultRate = $this->carrier->collectRates($request)->getAllRates()[0]; + $error = Bootstrap::getObjectManager()->get(Error::class); + $error->setCarrier('ups'); + $error->setCarrierTitle($this->carrier->getConfigData('title')); + $error->setErrorMessage($this->carrier->getConfigData('specificerrmsg')); + + $this->assertEquals($error, $resultRate); + } + /** * Extracts shipment request. * diff --git a/dev/tests/integration/testsuite/Magento/Usps/Model/CarrierTest.php b/dev/tests/integration/testsuite/Magento/Usps/Model/CarrierTest.php index 901db842acb7d..011381cb5917d 100644 --- a/dev/tests/integration/testsuite/Magento/Usps/Model/CarrierTest.php +++ b/dev/tests/integration/testsuite/Magento/Usps/Model/CarrierTest.php @@ -13,6 +13,9 @@ use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\HTTP\AsyncClientInterfaceMock; use PHPUnit\Framework\TestCase; +use Magento\Framework\HTTP\AsyncClient\HttpResponseDeferredInterface; +use Magento\Framework\HTTP\AsyncClient\HttpException; +use Magento\Quote\Model\Quote\Address\RateResult\Error; /** * Test for USPS integration. @@ -176,4 +179,72 @@ public function testCollectUnavailableRates(): void $rates = $this->carrier->collectRates($request); $this->assertCount(5, $rates->getAllRates()); } + + /** + * Test get carriers rates if has HttpException. + * + * @magentoConfigFixture default_store carriers/usps/allowed_methods 0_FCLE,0_FCL,0_FCP,1,2,3,4,6,7,13,16,17,22,23,25,27,28,33,34,35,36,37,42,43,53,55,56,57,61,INT_1,INT_2,INT_4,INT_6,INT_7,INT_8,INT_9,INT_10,INT_11,INT_12,INT_13,INT_14,INT_15,INT_16,INT_20,INT_26 + * @magentoConfigFixture default_store carriers/usps/showmethod 1 + * @magentoConfigFixture default_store carriers/usps/debug 1 + * @magentoConfigFixture default_store carriers/usps/userid test + * @magentoConfigFixture default_store carriers/usps/mode 0 + * @magentoConfigFixture default_store carriers/usps/active 1 + * @magentoConfigFixture default_store shipping/origin/country_id US + * @magentoConfigFixture default_store shipping/origin/postcode 90034 + * @magentoConfigFixture default_store carriers/usps/machinable true + */ + public function testGetRatesWithHttpException(): void + { + $deferredResponse = $this->getMockBuilder(HttpResponseDeferredInterface::class) + ->onlyMethods(['get']) + ->getMockForAbstractClass(); + $exception = new HttpException('Exception message'); + $deferredResponse->method('get')->willThrowException($exception); + $this->httpClient->setDeferredResponseMock($deferredResponse); + /** @var RateRequest $request */ + $request = Bootstrap::getObjectManager()->create( + RateRequest::class, + [ + 'data' => [ + 'dest_country_id' => 'US', + 'dest_region_code' => 'NY', + 'dest_street' => 'main st1', + 'dest_city' => 'New York', + 'dest_postcode' => '10029', + 'package_value' => '5', + 'package_value_with_discount' => '5', + 'package_weight' => '4.2657', + 'package_qty' => '1', + 'package_physical_value' => '5', + 'free_method_weight' => '5', + 'store_id' => '1', + 'website_id' => '1', + 'free_shipping' => '0', + 'limit_carrier' => 'null', + 'base_subtotal_incl_tax' => '5', + 'orig_country_id' => 'US', + 'country_id' => 'US', + 'region_id' => '12', + 'city' => 'Culver City', + 'postcode' => '90034', + 'usps_userid' => '213MAGEN6752', + 'usps_container' => 'VARIABLE', + 'usps_size' => 'REGULAR', + 'girth' => null, + 'height' => null, + 'length' => null, + 'width' => null, + ] + ] + ); + + $rates = $this->carrier->collectRates($request); + $resultRate = $rates->getAllRates()[0]; + $error = Bootstrap::getObjectManager()->get(Error::class); + $error->setCarrier('usps'); + $error->setCarrierTitle($this->carrier->getConfigData('title')); + $error->setErrorMessage($this->carrier->getConfigData('specificerrmsg')); + + $this->assertEquals($error, $resultRate); + } } From cf13b9dca1efec08258bbca7adda856fc59888bc Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi <tsviklinskyi@gmail.com> Date: Thu, 12 Nov 2020 08:25:29 +0200 Subject: [PATCH 27/69] MC-38917: Unexpected order cancellation --- .../Adminhtml/Order/Create/Index.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index.php index 634ecd50c6f9a..44ec1218abc7d 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index.php @@ -20,6 +20,12 @@ class Index extends \Magento\Sales\Controller\Adminhtml\Order\Create implements public function execute() { $this->_initSession(); + + // Clear existing order in session when creating a new order for a customer + if ($this->getRequest()->getParam('customer_id')) { + $this->clearSessionOrderData(); + } + $this->_getOrderCreateModel()->initRuleData(); /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); @@ -28,4 +34,16 @@ public function execute() $resultPage->getConfig()->getTitle()->prepend(__('New Order')); return $resultPage; } + + /** + * Clear order data in session + * + * @return $this + */ + private function clearSessionOrderData(): self + { + $this->_getSession()->setOrderId(null); + + return $this; + } } From 7d48b44e5ef733597f5119cfba49e82983c8a27f Mon Sep 17 00:00:00 2001 From: "rostyslav.hymon" <rostyslav.hymon@transoftgroup.com> Date: Thu, 12 Nov 2020 11:27:11 +0200 Subject: [PATCH 28/69] MC-38829: We couldn't find any records shown at Reports > Sales > Paypal Settlement --- app/code/Magento/Paypal/Model/Report/Settlement.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Paypal/Model/Report/Settlement.php b/app/code/Magento/Paypal/Model/Report/Settlement.php index 462ca2f979420..e23a3535aca91 100644 --- a/app/code/Magento/Paypal/Model/Report/Settlement.php +++ b/app/code/Magento/Paypal/Model/Report/Settlement.php @@ -603,13 +603,16 @@ protected function _fileNameToDate($filename) /** * Filter SFTP file list by filename format * + * Single Account format = STL-yyyymmdd.sequenceNumber.version.format + * Multiple Account format = STL-yyyymmdd.reportingWindow.sequenceNumber.totalFiles.version.format + * * @param array $list List of files as per $connection->rawls() * @return array Trimmed down list of files */ protected function _filterReportsList($list) { $result = []; - $pattern = '/^STL-(\d{8,8})\.(\d{2,2})\.(.{3,3})\.CSV$/'; + $pattern = '/^STL-(\d{8,8})\.((\d{2,2})|(([A-Z])\.(\d{2,2})\.(\d{2,2})))\.(.{3,3})\.CSV$/'; foreach ($list as $filename => $data) { if (preg_match($pattern, $filename)) { $result[$filename] = $data; From bfebade04dc86ffb720aa9e3fee529575bbef9fc Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi <tsviklinskyi@gmail.com> Date: Thu, 12 Nov 2020 11:46:31 +0200 Subject: [PATCH 29/69] MC-38917: Unexpected order cancellation --- .../Controller/Adminhtml/Order/Create/Index.php | 14 +------------- .../Adminhtml/Order/Create/IndexTest.php | 8 ++++++++ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index.php index 44ec1218abc7d..e6f470f5c1a85 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index.php @@ -23,7 +23,7 @@ public function execute() // Clear existing order in session when creating a new order for a customer if ($this->getRequest()->getParam('customer_id')) { - $this->clearSessionOrderData(); + $this->_getSession()->setOrderId(null); } $this->_getOrderCreateModel()->initRuleData(); @@ -34,16 +34,4 @@ public function execute() $resultPage->getConfig()->getTitle()->prepend(__('New Order')); return $resultPage; } - - /** - * Clear order data in session - * - * @return $this - */ - private function clearSessionOrderData(): self - { - $this->_getSession()->setOrderId(null); - - return $this; - } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/IndexTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/IndexTest.php index 764c48b523968..a748183a9a026 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/IndexTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/IndexTest.php @@ -52,9 +52,17 @@ protected function setUp(): void public function testExecute(): void { $customerId = 1; + $editingOrderId = 10; + $this->getRequest()->setMethod(Http::METHOD_GET); $this->getRequest()->setParam('customer_id', $customerId); + $this->quoteSession->setOrderId($editingOrderId); + $this->assertEquals($editingOrderId, $this->quoteSession->getOrderId()); $this->dispatch('backend/sales/order_create/index'); + + // Check that existing order in session was cleared + $this->assertEquals(null, $this->quoteSession->getOrderId()); + $store = $this->storeManager->getStore(); $this->assertEquals($customerId, $this->quoteSession->getCustomerId()); $ruleData = $this->registry->registry('rule_data'); From e5a79506e34b5c3610fb7c80d2a04b2a473067d9 Mon Sep 17 00:00:00 2001 From: Serhiy Yelahin <serhiy.yelahin@transoftgroup.com> Date: Thu, 12 Nov 2020 12:54:43 +0200 Subject: [PATCH 30/69] MC-38825: Incorrect subtotal in the cart with virtual product --- .../Model/Cart/Controller/CartPlugin.php | 34 +++++++++- ...tishippingModeCheckoutOnBackToCartTest.xml | 67 +++++++++++++++++++ .../Model/Cart/Controller/CartPluginTest.php | 39 +++++++---- 3 files changed, 125 insertions(+), 15 deletions(-) create mode 100644 app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontDisableMultishippingModeCheckoutOnBackToCartTest.xml diff --git a/app/code/Magento/Multishipping/Model/Cart/Controller/CartPlugin.php b/app/code/Magento/Multishipping/Model/Cart/Controller/CartPlugin.php index b450232395b88..ea3e765ebb5cc 100644 --- a/app/code/Magento/Multishipping/Model/Cart/Controller/CartPlugin.php +++ b/app/code/Magento/Multishipping/Model/Cart/Controller/CartPlugin.php @@ -13,6 +13,7 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Multishipping\Model\Checkout\Type\Multishipping\State; +use Magento\Multishipping\Model\DisableMultishipping; use Magento\Quote\Api\CartRepositoryInterface; use Magento\Quote\Model\Quote; @@ -36,19 +37,27 @@ class CartPlugin */ private $addressRepository; + /** + * @var DisableMultishipping + */ + private $disableMultishipping; + /** * @param CartRepositoryInterface $cartRepository * @param Session $checkoutSession * @param AddressRepositoryInterface $addressRepository + * @param DisableMultishipping $disableMultishipping */ public function __construct( CartRepositoryInterface $cartRepository, Session $checkoutSession, - AddressRepositoryInterface $addressRepository + AddressRepositoryInterface $addressRepository, + DisableMultishipping $disableMultishipping ) { $this->cartRepository = $cartRepository; $this->checkoutSession = $checkoutSession; $this->addressRepository = $addressRepository; + $this->disableMultishipping = $disableMultishipping; } /** @@ -76,6 +85,9 @@ public function beforeDispatch(Cart $subject, RequestInterface $request) $shippingAddress->importCustomerAddressData($defaultCustomerAddress); } $this->cartRepository->save($quote); + } elseif ($this->disableMultishipping->execute($quote) && $this->isVirtualItemInQuote($quote)) { + $quote->setTotalsCollectedFlag(false); + $this->cartRepository->save($quote); } } @@ -88,4 +100,24 @@ private function isCheckoutComplete() : bool { return (bool) ($this->checkoutSession->getStepData(State::STEP_SHIPPING)['is_complete'] ?? true); } + + /** + * Checks whether quote has virtual items + * + * @param Quote $quote + * @return bool + */ + private function isVirtualItemInQuote(Quote $quote): bool + { + $items = $quote->getItems(); + if (!empty($items)) { + foreach ($items as $item) { + if ($item->getIsVirtual()) { + return true; + } + } + } + + return false; + } } diff --git a/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontDisableMultishippingModeCheckoutOnBackToCartTest.xml b/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontDisableMultishippingModeCheckoutOnBackToCartTest.xml new file mode 100644 index 0000000000000..8fa2c83fc6c0c --- /dev/null +++ b/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontDisableMultishippingModeCheckoutOnBackToCartTest.xml @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontDisableMultishippingModeCheckoutOnBackToCartTest"> + <annotations> + <features value="Multishipping"/> + <stories value="Multishipping"/> + <title value="Disable multishipping checkout on backing to cart"/> + <description value="Cart page summary block should count virtual product price after backing back to the cart from multishipping checkout."/> + <severity value="CRITICAL"/> + <testCaseId value="MC-39007"/> + <useCaseId value="MC-38825"/> + <group value="multishipping"/> + </annotations> + <before> + <createData entity="ApiCategory" stepKey="createCategory"/> + <createData entity="_defaultProduct" stepKey="createSimpleProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="VirtualProduct" stepKey="createVirtualProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="Simple_US_Customer_Multiple_Addresses" stepKey="createCustomerWithMultipleAddresses"/> + </before> + <after> + <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> + <deleteData createDataKey="createVirtualProduct" stepKey="deleteVirtualProduct"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createCustomerWithMultipleAddresses" stepKey="deleteCustomer"/> + </after> + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginAsCustomer"> + <argument name="Customer" value="$createCustomerWithMultipleAddresses$"/> + </actionGroup> + + <actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openVirtualProductPage"> + <argument name="product" value="$createVirtualProduct$"/> + </actionGroup> + <actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="addVirtualProductToCart"> + <argument name="product" value="$createVirtualProduct$"/> + <argument name="productCount" value="1"/> + </actionGroup> + + <actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openSimpleProductPage"> + <argument name="product" value="$createSimpleProduct$"/> + </actionGroup> + <actionGroup ref="StorefrontAddProductToCartActionGroup" stepKey="addSimpleProductToCart"> + <argument name="product" value="$createSimpleProduct$"/> + <argument name="productCount" value="2"/> + </actionGroup> + + <actionGroup ref="ClickViewAndEditCartFromMiniCartActionGroup" stepKey="goToShoppingCartFromMinicart"/> + <grabTextFrom selector="{{CheckoutPaymentSection.orderSummaryTotal}}" stepKey="grabTotal"/> + + <actionGroup ref="StorefrontGoCheckoutWithMultipleAddressesActionGroup" stepKey="goCheckoutWithMultipleAddresses"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goBackToShoppingCartPage"/> + <actionGroup ref="AssertStorefrontCheckoutPaymentSummaryTotalActionGroup" stepKey="assertSummaryTotal"> + <argument name="orderTotal" value="{$grabTotal}"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/Multishipping/Test/Unit/Model/Cart/Controller/CartPluginTest.php b/app/code/Magento/Multishipping/Test/Unit/Model/Cart/Controller/CartPluginTest.php index fec7a064a13ad..e5ec970ef8587 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Model/Cart/Controller/CartPluginTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Model/Cart/Controller/CartPluginTest.php @@ -14,6 +14,7 @@ use Magento\Customer\Api\Data\CustomerInterface; use Magento\Framework\App\RequestInterface; use Magento\Multishipping\Model\Cart\Controller\CartPlugin; +use Magento\Multishipping\Model\DisableMultishipping; use Magento\Quote\Api\CartRepositoryInterface; use Magento\Quote\Model\Quote; use Magento\Quote\Model\Quote\Address; @@ -47,10 +48,12 @@ protected function setUp(): void $this->cartRepositoryMock = $this->getMockForAbstractClass(CartRepositoryInterface::class); $this->checkoutSessionMock = $this->createMock(Session::class); $this->addressRepositoryMock = $this->getMockForAbstractClass(AddressRepositoryInterface::class); + $disableMultishippingMock = $this->createMock(DisableMultishipping::class); $this->model = new CartPlugin( $this->cartRepositoryMock, $this->checkoutSessionMock, - $this->addressRepositoryMock + $this->addressRepositoryMock, + $disableMultishippingMock ); } @@ -65,33 +68,41 @@ public function testBeforeDispatch() 'getShippingAddress', 'getCustomer' ]); - $this->checkoutSessionMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); + $this->checkoutSessionMock->method('getQuote') + ->willReturn($quoteMock); $addressMock = $this->createMock(Address::class); - $addressMock->expects($this->once())->method('getId')->willReturn($addressId); + $addressMock->method('getId') + ->willReturn($addressId); - $quoteMock->expects($this->once())->method('isMultipleShippingAddresses')->willReturn(true); - $quoteMock->expects($this->once())->method('getAllShippingAddresses')->willReturn([$addressMock]); - $quoteMock->expects($this->once())->method('removeAddress')->with($addressId)->willReturnSelf(); + $quoteMock->method('isMultipleShippingAddresses') + ->willReturn(true); + $quoteMock->method('getAllShippingAddresses') + ->willReturn([$addressMock]); + $quoteMock->method('removeAddress') + ->with($addressId)->willReturnSelf(); $shippingAddressMock = $this->createMock(Address::class); - $quoteMock->expects($this->once())->method('getShippingAddress')->willReturn($shippingAddressMock); + $quoteMock->method('getShippingAddress') + ->willReturn($shippingAddressMock); $customerMock = $this->getMockForAbstractClass(CustomerInterface::class); - $quoteMock->expects($this->once())->method('getCustomer')->willReturn($customerMock); - $customerMock->expects($this->once())->method('getDefaultShipping')->willReturn($customerAddressId); + $quoteMock->method('getCustomer') + ->willReturn($customerMock); + $customerMock->method('getDefaultShipping') + ->willReturn($customerAddressId); $customerAddressMock = $this->getMockForAbstractClass(AddressInterface::class); - $this->addressRepositoryMock->expects($this->once()) - ->method('getById') + $this->addressRepositoryMock->method('getById') ->with($customerAddressId) ->willReturn($customerAddressMock); - $shippingAddressMock->expects($this->once()) - ->method('importCustomerAddressData') + $shippingAddressMock->method('importCustomerAddressData') ->with($customerAddressMock) ->willReturnSelf(); - $this->cartRepositoryMock->expects($this->once())->method('save')->with($quoteMock); + $this->cartRepositoryMock->expects($this->once()) + ->method('save') + ->with($quoteMock); $this->model->beforeDispatch( $this->createMock(Cart::class), From a7c061c9327496ffe2857bcb8e2a7c080dfaf554 Mon Sep 17 00:00:00 2001 From: "rostyslav.hymon" <rostyslav.hymon@transoftgroup.com> Date: Thu, 12 Nov 2020 12:54:44 +0200 Subject: [PATCH 31/69] MC-38829: We couldn't find any records shown at Reports > Sales > Paypal Settlement --- .../Paypal/Model/Report/Settlement.php | 1 + .../Test/Unit/Model/Report/SettlementTest.php | 73 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 app/code/Magento/Paypal/Test/Unit/Model/Report/SettlementTest.php diff --git a/app/code/Magento/Paypal/Model/Report/Settlement.php b/app/code/Magento/Paypal/Model/Report/Settlement.php index e23a3535aca91..f429fdaac4c34 100644 --- a/app/code/Magento/Paypal/Model/Report/Settlement.php +++ b/app/code/Magento/Paypal/Model/Report/Settlement.php @@ -595,6 +595,7 @@ public function getSftpCredentials($automaticMode = false) protected function _fileNameToDate($filename) { // Currently filenames look like STL-YYYYMMDD, so that is what we care about. + // phpcs:ignore Magento2.Functions.DiscouragedFunction $dateSnippet = substr(basename($filename), 4, 8); $result = substr($dateSnippet, 0, 4) . '-' . substr($dateSnippet, 4, 2) . '-' . substr($dateSnippet, 6, 2); return $result; diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Report/SettlementTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Report/SettlementTest.php new file mode 100644 index 0000000000000..ed4b35e9c08c9 --- /dev/null +++ b/app/code/Magento/Paypal/Test/Unit/Model/Report/SettlementTest.php @@ -0,0 +1,73 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Paypal\Test\Unit\Model\Report; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Paypal\Model\Report\Settlement; +use Magento\Framework\Filesystem\Io\Sftp; +use Magento\Framework\Filesystem\Directory\WriteInterface; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; + +/** + * Test for paypal settlement + */ +class SettlementTest extends TestCase +{ + /** + * @var Settlement + */ + private $settlement; + + /** + * @var WriteInterface|MockObject + */ + private $tmpDirectory; + + /** + * @inheritDoc + */ + protected function setUp(): void + { + $objectManagerHelper = new ObjectManagerHelper($this); + $this->tmpDirectory = $this->getMockBuilder(WriteInterface::class) + ->disableOriginalConstructor() + ->getMock(); + $this->settlement = $objectManagerHelper->getObject( + Settlement::class, + [ + '_tmpDirectory' => $this->tmpDirectory + ] + ); + } + + /** + * Test for filter report list + * + * @return void + */ + public function testFilterReportList(): void + { + $this->tmpDirectory->method('getAbsolutePath') + ->willReturn(''); + /** @var Sftp|MockObject $connection */ + $connection = $this->getMockBuilder(Sftp::class) + ->onlyMethods(['rawls', 'read']) + ->disableOriginalConstructor() + ->getMock(); + $connection->method('rawls') + ->willReturn( + [ + 'STL-20201221.01.009.CSV' => 'Single account', + 'STL-20201221.H.01.01.009.CSV' => 'Multiple account', + ] + ); + $connection->expects($this->exactly(2))->method('read')->willReturn(false); + $this->settlement->fetchAndSave($connection); + } +} From d5e9f59bcc0275c47ec698bfb3e370ec9bc24910 Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi <tsviklinskyi@gmail.com> Date: Thu, 12 Nov 2020 15:41:38 +0200 Subject: [PATCH 32/69] MC-38930: Product type changed from virtual to simple --- .../Helper/Plugin/UpdateConfigurations.php | 4 +- .../Plugin/UpdateConfigurationsTest.php | 38 +++++++++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php index 76ad93564e96e..0180fd5bfba4b 100644 --- a/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php +++ b/app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurations.php @@ -115,9 +115,9 @@ protected function getConfigurations() if (isset($item['qty'])) { $result[$item['id']]['quantity_and_stock_status']['qty'] = $item['qty']; } - + // Changing product to simple on weight change - if (isset($item['weight']) && $item['weight'] >= 0) { + if (!empty($item['weight']) && $item['weight'] >= 0) { $result[$item['id']]['type_id'] = \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE; $result[$item['id']]['product_has_weight'] = WeightResolver::HAS_WEIGHT; } diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurationsTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurationsTest.php index 735560f00a11a..e5aa4a353f3b1 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurationsTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Controller/Adminhtml/Product/Initialization/Helper/Plugin/UpdateConfigurationsTest.php @@ -119,6 +119,22 @@ private function getConfigurableMatrix() 'price' => '3.33', 'weight' => '5.55', ], + [ + 'newProduct' => false, + 'id' => 'product5', + 'status' => 'simple5_status', + 'sku' => 'simple5_sku', + 'name' => 'simple5_name', + 'price' => '3.33', + 'configurable_attribute' => 'simple5_configurable_attribute', + 'weight' => '', + 'media_gallery' => 'simple5_media_gallery', + 'swatch_image' => 'simple5_swatch_image', + 'small_image' => 'simple5_small_image', + 'thumbnail' => 'simple5_thumbnail', + 'image' => 'simple5_image', + 'was_changed' => true, + ], ]; } @@ -144,12 +160,26 @@ public function testAfterInitialize() ], 'product3' => [ 'quantity_and_stock_status' => ['qty' => '3'] - ] + ], + 'product5' => [ + 'status' => 'simple5_status', + 'sku' => 'simple5_sku', + 'name' => 'simple5_name', + 'price' => '3.33', + 'configurable_attribute' => 'simple5_configurable_attribute', + 'weight' => '', + 'media_gallery' => 'simple5_media_gallery', + 'swatch_image' => 'simple5_swatch_image', + 'small_image' => 'simple5_small_image', + 'thumbnail' => 'simple5_thumbnail', + 'image' => 'simple5_image', + ], ]; /** @var Product[]|MockObject[] $productMocks */ $productMocks = [ 'product2' => $this->getProductMock($configurations['product2'], true, true), 'product3' => $this->getProductMock($configurations['product3'], false, true), + 'product5' => $this->getProductMock($configurations['product5'], false, true), ]; $this->requestMock->expects(static::any()) @@ -169,7 +199,8 @@ public function testAfterInitialize() ->willReturnMap( [ ['product2', false, 0, false, $productMocks['product2']], - ['product3', false, 0, false, $productMocks['product3']] + ['product3', false, 0, false, $productMocks['product3']], + ['product5', false, 0, false, $productMocks['product5']], ] ); $this->variationHandlerMock->expects(static::any()) @@ -177,7 +208,8 @@ public function testAfterInitialize() ->willReturnMap( [ [$productMocks['product2'], $configurations['product2'], $configurations['product2']], - [$productMocks['product3'], $configurations['product3'], $configurations['product3']] + [$productMocks['product3'], $configurations['product3'], $configurations['product3']], + [$productMocks['product5'], $configurations['product5'], $configurations['product5']] ] ); From 761a48b415c357e32a8eeaf90886bea0aa063c93 Mon Sep 17 00:00:00 2001 From: David Haecker <dhaecker@magento.com> Date: Thu, 12 Nov 2020 08:25:07 -0600 Subject: [PATCH 33/69] magento/partners-magento2b2b#370: [Determine Coverage]: Add Meaningful Titles and Descriptions For All MFTF Tests in the Company, CompanyCredit, CompanyPayment, CompanyShipping, & ConfigurableSharedCatalog Modules - Updating AdminSetActiveCustomerGridWorkCorrectTest --- ...minSetCustomerActiveViaGridActionGroup.xml | 26 +++++++++++++++++++ ...nSetCustomerInactiveViaGridActionGroup.xml | 18 +++++++++++++ .../AdminCustomerGridMainActionsSection.xml | 2 ++ .../Mftf/Section/AdminCustomerGridSection.xml | 1 + 4 files changed, 47 insertions(+) create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerActiveViaGridActionGroup.xml create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerInactiveViaGridActionGroup.xml diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerActiveViaGridActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerActiveViaGridActionGroup.xml new file mode 100644 index 0000000000000..7dff20dcb657b --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerActiveViaGridActionGroup.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminSetCustomerActiveViaGridActionGroup"> + <annotations> + <description>Sets a Customer to the Active status from the admin All Customers grid</description> + </annotations> + <arguments> + <argument name="customerEmail" type="string" defaultValue="{{Simple_US_CA_Customer.email}}"/> + </arguments> + <waitForElementVisible selector="{{AdminCustomerGridMainActionsSection.customerCheckbox(customerEmail)}}" stepKey="waitForCustomerRow"/> + <click selector="{{AdminCustomerGridMainActionsSection.customerCheckbox(customerEmail)}}" stepKey="selectCustomer"/> + <click selector="{{AdminCustomerGridMainActionsSection.actions}}" stepKey="clickActions"/> + <waitForElementVisible selector="{{AdminCustomerGridMainActionsSection.setActive}}" stepKey="waitForDropDownOpen"/> + <click selector="{{AdminCustomerGridMainActionsSection.setActive}}" stepKey="clickSetActive"/> + <waitForPageLoad stepKey="waitForLoad"/> + <waitForText selector="{{AdminMessagesSection.success}}" userInput="A total of 1 record(s) were updated." stepKey="seeSuccessMessage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerInactiveViaGridActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerInactiveViaGridActionGroup.xml new file mode 100644 index 0000000000000..94151d72dffcb --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerInactiveViaGridActionGroup.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminSetCustomerInactiveViaGridActionGroup" extends="AdminSetCustomerActiveViaGridActionGroup"> + <annotations> + <description>Sets a Customer to the Inactive status from the admin All Customers grid</description> + </annotations> + <waitForElementVisible selector="{{AdminCustomerGridMainActionsSection.setInactive}}" stepKey="waitForDropDownOpen"/> + <click selector="{{AdminCustomerGridMainActionsSection.setInactive}}" stepKey="clickSetActive"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridMainActionsSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridMainActionsSection.xml index 44ab653259b55..a2d77a093db3d 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridMainActionsSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridMainActionsSection.xml @@ -17,5 +17,7 @@ <element name="ok" type="button" selector="//button[@data-role='action']//span[text()='OK']"/> <element name="addNewAddress" type="button" selector=".add-new-address-button" timeout="30"/> <element name="actions" type="text" selector=".admin__data-grid-header-row .action-select"/> + <element name="setActive" type="button" selector="//*[contains(@class, 'admin__data-grid-header')]//span[contains(@class,'action-menu-item') and text()='Set Active']" timeout="30"/> + <element name="setInactive" type="button" selector="//*[contains(@class, 'admin__data-grid-header')]//span[contains(@class,'action-menu-item') and text()='Set Inactive']" timeout="30"/> </section> </sections> diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridSection.xml index 9562a902b26da..a713a606426c8 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridSection.xml @@ -17,6 +17,7 @@ <element name="customerEditLinkByEmail" type="text" selector="//tr[@class='data-row' and //div[text()='{{customerEmail}}']]//a[@class='action-menu-item']" parameterized="true" timeout="30"/> <element name="customerGroupByEmail" type="text" selector="//tr[@class='data-row' and //div[text()='{{customerEmail}}']]//div[text()='{{customerGroup}}']" parameterized="true"/> <element name="customerGenderByEmail" type="text" selector="//tr[@class='data-row']//div[text()='{{customerEmail}}']/ancestor::tr/td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Gender')]/preceding-sibling::th) +1]" parameterized="true"/> + <element name="status" type="text" selector="//tr[@class='data-row' and //div[text()='{{customerEmail}}']]//div[contains(text(), '{{status}}')]" parameterized="true" timeout="30"/> </section> </sections> From 402fadbc19cfb115896c1ca5be9bc75cf8ceb716 Mon Sep 17 00:00:00 2001 From: engcom-Echo <engcom-vendorworker-echo@adobe.com> Date: Wed, 11 Nov 2020 11:35:19 +0200 Subject: [PATCH 34/69] MC-30626: Custom Option with Percent price is converted to a currency twice --- .../Product/View/Options/AbstractOptions.php | 7 +++--- .../Pricing/Price/CustomOptionPrice.php | 20 ++++------------- ...CustomOptionCheckboxByPriceActionGroup.xml | 22 +++++++++++++++++++ ...CustomOptionPriceDifferentCurrencyTest.xml | 8 +++++-- 4 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertCustomOptionCheckboxByPriceActionGroup.xml diff --git a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php index 20cf3322512ce..e95ea31a80596 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php +++ b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php @@ -186,10 +186,9 @@ protected function _formatPrice($value, $flag = true) } } - $context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true]; - $optionAmount = !$isPercent - ? $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context) - : $customOptionPrice->getCustomRoundAmount($value['pricing_value'], $context); + $context['should_not_be_converted'] = $isPercent; + $context[CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG] = true; + $optionAmount = $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context); $priceStr .= $this->getLayout()->getBlock('product.price.render.default')->renderAmount( $optionAmount, $customOptionPrice, diff --git a/app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php b/app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php index b5348f9048e82..24b4c90feec69 100644 --- a/app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php +++ b/app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php @@ -14,7 +14,6 @@ /** * Class OptionPrice - * */ class CustomOptionPrice extends AbstractPrice implements CustomOptionPriceInterface { @@ -124,7 +123,7 @@ public function getValue($priceCode = \Magento\Catalog\Pricing\Price\BasePrice:: } /** - * Get Custom Amount object + * Calculate Custom Amount * * @param float $amount * @param null|bool|string|array $exclude @@ -134,7 +133,9 @@ public function getValue($priceCode = \Magento\Catalog\Pricing\Price\BasePrice:: public function getCustomAmount($amount = null, $exclude = null, $context = []) { if (null !== $amount) { - $amount = $this->priceCurrency->convertAndRound($amount); + $amount = (isset($context['should_not_be_converted']) && $context['should_not_be_converted']) + ? $this->priceCurrency->roundPrice($amount) + : $this->priceCurrency->convertAndRound($amount); } else { $amount = $this->getValue(); } @@ -163,19 +164,6 @@ public function getCustomOptionRange($getMin, $priceCode = \Magento\Catalog\Pric return $this->priceCurrency->convertAndRound($optionValue); } - /** - * Get custom amount without currency convert - * - * @param float|string $amount - * @param null|array $context - * @return AmountInterface - */ - public function getCustomRoundAmount($amount, $context = []) - { - $amount = $this->priceCurrency->roundPrice($amount); - return $this->calculator->getAmount($amount, $this->getProduct(), null, $context); - } - /** * Return price for select custom options * diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertCustomOptionCheckboxByPriceActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertCustomOptionCheckboxByPriceActionGroup.xml new file mode 100644 index 0000000000000..afc57257f63e2 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertCustomOptionCheckboxByPriceActionGroup.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="StorefrontAssertCustomOptionCheckboxByPriceActionGroup"> + <annotations> + <description>Validates that the provided price for Custom Option Checkbox is present on the Storefront Product page.</description> + </annotations> + <arguments> + <argument name="optionTitle" type="string" defaultValue="{{ProductOptionCheckbox.title}}"/> + <argument name="price" type="string"/> + </arguments> + + <seeElement selector="{{StorefrontProductInfoMainSection.productAttributeOptionsCheckbox(optionTitle, price)}}" stepKey="checkPriceProductOptionCheckbox"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml index a75accd665e23..dfcda77974d32 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml @@ -38,10 +38,14 @@ <actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProductPageOnStorefront"> <argument name="product" value="$createProduct$"/> </actionGroup> - <seeElement selector="{{StorefrontProductInfoMainSection.productAttributeOptionsCheckbox(ProductOptionCheckbox.title, '12.3')}}" stepKey="checkPriceProductOptionUSD"/> + <actionGroup ref="StorefrontAssertCustomOptionCheckboxByPriceActionGroup" stepKey="checkPriceProductOptionUSD"> + <argument name="price" value="12.3"/> + </actionGroup> <actionGroup ref="StorefrontSwitchCurrencyActionGroup" stepKey="switchEURCurrency"> <argument name="currency" value="EUR"/> </actionGroup> - <seeElement selector="{{StorefrontProductInfoMainSection.productAttributeOptionsCheckbox(ProductOptionCheckbox.title, '8.7')}}" stepKey="checkPriceProductOptionEUR"/> + <actionGroup ref="StorefrontAssertCustomOptionCheckboxByPriceActionGroup" stepKey="checkPriceProductOptionEUR"> + <argument name="price" value="8.7"/> + </actionGroup> </test> </tests> From fbb3d510d23325a2567b7482e25c6259c4e24e28 Mon Sep 17 00:00:00 2001 From: Serhii Balko <serhii.balko@transoftgroup.com> Date: Fri, 13 Nov 2020 13:44:34 +0200 Subject: [PATCH 35/69] MC-35755: [Magento Cloud] B2B - Negotiable Quotes REST response time is over 1 minute --- app/code/Magento/Quote/Model/QuoteRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Quote/Model/QuoteRepository.php b/app/code/Magento/Quote/Model/QuoteRepository.php index 1533194023e3e..b1bef834197aa 100644 --- a/app/code/Magento/Quote/Model/QuoteRepository.php +++ b/app/code/Magento/Quote/Model/QuoteRepository.php @@ -134,8 +134,8 @@ public function get($cartId, array $sharedStoreIds = []) { if (!isset($this->quotesById[$cartId])) { $quote = $this->loadQuote('loadByIdWithoutStore', 'cartId', $cartId, $sharedStoreIds); - $this->getLoadHandler()->load($quote); $this->quotesById[$cartId] = $quote; + $this->getLoadHandler()->load($quote); } return $this->quotesById[$cartId]; } From f2e46ec49783ad245624a034465bac25bd15e343 Mon Sep 17 00:00:00 2001 From: engcom-Echo <engcom-vendorworker-echo@adobe.com> Date: Fri, 13 Nov 2020 15:13:15 +0200 Subject: [PATCH 36/69] MC-30626: Custom Option with Percent price is converted to a currency twice --- .../Product/View/Options/AbstractOptions.php | 31 +++++++++++++++++-- .../Pricing/Price/CustomOptionPrice.php | 7 ++--- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php index e95ea31a80596..68a6ea74f6ec5 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php +++ b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php @@ -15,6 +15,8 @@ use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule; use Magento\Catalog\Pricing\Price\CustomOptionPriceInterface; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Pricing\Adjustment\CalculatorInterface; +use Magento\Framework\Pricing\PriceCurrencyInterface; /** * Product options section abstract block. @@ -54,24 +56,42 @@ abstract class AbstractOptions extends \Magento\Framework\View\Element\Template */ private $calculateCustomOptionCatalogRule; + /** + * @var CalculatorInterface + */ + private $calculator; + + /** + * @var PriceCurrencyInterface + */ + private $priceCurrency; + /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Framework\Pricing\Helper\Data $pricingHelper * @param \Magento\Catalog\Helper\Data $catalogData * @param array $data * @param CalculateCustomOptionCatalogRule|null $calculateCustomOptionCatalogRule + * @param CalculatorInterface|null $calculator + * @param PriceCurrencyInterface|null $priceCurrency */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Pricing\Helper\Data $pricingHelper, \Magento\Catalog\Helper\Data $catalogData, array $data = [], - CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null + CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null, + CalculatorInterface $calculator = null, + PriceCurrencyInterface $priceCurrency = null ) { $this->pricingHelper = $pricingHelper; $this->_catalogHelper = $catalogData; $this->calculateCustomOptionCatalogRule = $calculateCustomOptionCatalogRule ?? ObjectManager::getInstance()->get(CalculateCustomOptionCatalogRule::class); + $this->calculator = $calculator + ?? ObjectManager::getInstance()->get(CalculatorInterface::class); + $this->priceCurrency = $priceCurrency + ?? ObjectManager::getInstance()->get(PriceCurrencyInterface::class); parent::__construct($context, $data); } @@ -186,9 +206,14 @@ protected function _formatPrice($value, $flag = true) } } - $context['should_not_be_converted'] = $isPercent; $context[CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG] = true; - $optionAmount = $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context); + $optionAmount = $isPercent + ? $this->calculator->getAmount( + $this->priceCurrency->roundPrice($value['pricing_value']), + $this->getProduct(), + null, + $context + ): $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context); $priceStr .= $this->getLayout()->getBlock('product.price.render.default')->renderAmount( $optionAmount, $customOptionPrice, diff --git a/app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php b/app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php index 24b4c90feec69..93bf7920355db 100644 --- a/app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php +++ b/app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php @@ -14,6 +14,7 @@ /** * Class OptionPrice + * */ class CustomOptionPrice extends AbstractPrice implements CustomOptionPriceInterface { @@ -123,8 +124,6 @@ public function getValue($priceCode = \Magento\Catalog\Pricing\Price\BasePrice:: } /** - * Calculate Custom Amount - * * @param float $amount * @param null|bool|string|array $exclude * @param null|array $context @@ -133,9 +132,7 @@ public function getValue($priceCode = \Magento\Catalog\Pricing\Price\BasePrice:: public function getCustomAmount($amount = null, $exclude = null, $context = []) { if (null !== $amount) { - $amount = (isset($context['should_not_be_converted']) && $context['should_not_be_converted']) - ? $this->priceCurrency->roundPrice($amount) - : $this->priceCurrency->convertAndRound($amount); + $amount = $this->priceCurrency->convertAndRound($amount); } else { $amount = $this->getValue(); } From 04400b0f1c2672ecac8d152da0f8292276380d0e Mon Sep 17 00:00:00 2001 From: "vadim.malesh" <engcom-vendorworker-charlie@adobe.com> Date: Mon, 16 Nov 2020 11:25:53 +0200 Subject: [PATCH 37/69] add integration test --- .../Magento/Framework/File/UploaderTest.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/Framework/File/UploaderTest.php b/dev/tests/integration/testsuite/Magento/Framework/File/UploaderTest.php index 3852fde042c87..293831f3850b3 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/File/UploaderTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/File/UploaderTest.php @@ -85,6 +85,51 @@ public function testUploadFileFromNotAllowedFolder(): void $this->uploaderFactory->create(['fileId' => $type]); } + /** + * Upload file test when `Old Media Gallery` is disabled + * + * @magentoConfigFixture system/media_gallery/enabled 1 + * @magentoAppArea adminhtml + * @dataProvider dirCodeDataProvider + * + * @param string $directoryCode + * @return void + */ + public function testUploadFileWhenOldMediaGalleryDisabled(string $directoryCode): void + { + $destinationDirectory = $this->filesystem->getDirectoryWrite($directoryCode); + $tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::SYS_TMP); + + $fileName = 'file.txt'; + $destinationDir = 'tmp'; + $filePath = $tmpDirectory->getAbsolutePath($fileName); + + $tmpDirectory->writeFile($fileName, 'some data'); + + $type = [ + 'tmp_name' => $filePath, + 'name' => $fileName, + ]; + + $uploader = $this->uploaderFactory->create(['fileId' => $type]); + $uploader->save($destinationDirectory->getAbsolutePath($destinationDir)); + + $this->assertTrue($destinationDirectory->isFile($destinationDir . DIRECTORY_SEPARATOR . $fileName)); + } + + /** + * DataProvider for testUploadFileWhenOldMediaGalleryDisabled + * + * @return array + */ + public function dirCodeDataProvider(): array + { + return [ + 'media destination' => [DirectoryList::MEDIA], + 'non-media destination' => [DirectoryList::VAR_DIR], + ]; + } + /** * @inheritdoc */ From 6aaac9e098f5e9936b70d6ddf530519cfd4c00ed Mon Sep 17 00:00:00 2001 From: David Haecker <dhaecker@magento.com> Date: Mon, 16 Nov 2020 13:56:12 -0600 Subject: [PATCH 38/69] magento/partners-magento2b2b#370: [Determine Coverage]: Add Meaningful Titles and Descriptions For All MFTF Tests in the Company, CompanyCredit, CompanyPayment, CompanyShipping, & ConfigurableSharedCatalog Modules - Cleaning up StorefrontNonCompanyCustomerCreatesCompanyTest - Cleaning up StorefrontCompanyUserCreateTest - Cleaning up AdminVerifyCustomerGroupOfACustomerChangesWhenACompanyIsAssignedToTheCustomerTest - Cleaning up AdminVerifyCustomerGroupOfCompanyCustomerChangesWhenNewCustomerGroupIsAssignedToACompanyTest --- ...tionTabFromCustomerEditPageActionGroup.xml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminOpenAccountInformationTabFromCustomerEditPageActionGroup.xml diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminOpenAccountInformationTabFromCustomerEditPageActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminOpenAccountInformationTabFromCustomerEditPageActionGroup.xml new file mode 100644 index 0000000000000..e7d91fc187425 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminOpenAccountInformationTabFromCustomerEditPageActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminOpenAccountInformationTabFromCustomerEditPageActionGroup"> + <annotations> + <description>Open Account Information tab from Customer's edit page</description> + </annotations> + <waitForElementVisible selector="{{AdminCustomerAccountInformationSection.accountInformationTab}}" stepKey="waitForAccountInformationTab"/> + <click selector="{{AdminCustomerAccountInformationSection.accountInformationTab}}" stepKey="clickAccountInformationTab"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + </actionGroup> +</actionGroups> From ca2baa98d82e901914a642f3bcc310a1199710ee Mon Sep 17 00:00:00 2001 From: Viktor Kopin <viktor.kopin@transoftgroup.com> Date: Tue, 17 Nov 2020 10:30:46 +0200 Subject: [PATCH 39/69] MC-38993: Magento\Authorization\Model\ResourceModel\Rules missing update method --- .../Magento/Authorization/Model/Rules.php | 32 ++++++------------- .../Test/Legacy/_files/obsolete_methods.php | 1 + 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/app/code/Magento/Authorization/Model/Rules.php b/app/code/Magento/Authorization/Model/Rules.php index 07ce8e57e3933..44e254fac6201 100644 --- a/app/code/Magento/Authorization/Model/Rules.php +++ b/app/code/Magento/Authorization/Model/Rules.php @@ -25,28 +25,7 @@ class Rules extends \Magento\Framework\Model\AbstractModel { /** - * Class constructor - * - * @param \Magento\Framework\Model\Context $context - * @param \Magento\Framework\Registry $registry - * @param \Magento\Authorization\Model\ResourceModel\Rules $resource - * @param \Magento\Authorization\Model\ResourceModel\Rules\Collection $resourceCollection - * @param array $data - */ - public function __construct( - \Magento\Framework\Model\Context $context, - \Magento\Framework\Registry $registry, - \Magento\Authorization\Model\ResourceModel\Rules $resource, - \Magento\Authorization\Model\ResourceModel\Rules\Collection $resourceCollection, - array $data = [] - ) { - parent::__construct($context, $registry, $resource, $resourceCollection, $data); - } - - /** - * Class constructor - * - * @return void + * @inheritdoc */ protected function _construct() { @@ -54,15 +33,22 @@ protected function _construct() } /** + * Obsolete method of update + * * @return $this + * @deprecated Method was never implemented and used. */ public function update() { - $this->getResource()->update($this); + // phpcs:disable Magento2.Functions.DiscouragedFunction + trigger_error('Method was never implemented and used.', E_USER_DEPRECATED); + return $this; } /** + * Save authorization rule relation + * * @return $this */ public function saveRel() diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index ff8e7db0f4260..d6a4053448fc8 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -2569,4 +2569,5 @@ 'Magento\Framework\MessageQueue\ConsumerInterface' ], ['isOrderIncrementIdUsed', 'Magento\Quote\Model\ResourceModel\Quote', 'Magento\Sales\Model\OrderIncrementIdChecker::isIncrementIdUsed'], + ['update', 'Magento\Authorization\Model\Rules', 'Magento\Authorization\Model\Rules::update'], ]; From 8b11ca10912c911a9c2bc0be8925c28451941eab Mon Sep 17 00:00:00 2001 From: SmVladyslav <vlatame.tsg@gmail.com> Date: Tue, 17 Nov 2020 15:19:05 +0200 Subject: [PATCH 40/69] MC-37870: Same As Billing Address checkbox is missed after added product by sku --- .../adminhtml/templates/order/create/form/address.phtml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml index 69b26d70e684a..80083569df889 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml @@ -73,14 +73,14 @@ endif; ?> <input type="checkbox" id="order-shipping_same_as_billing" name="shipping_same_as_billing" class="admin__control-checkbox" <?php if ($block->getIsAsBilling()): ?>checked<?php endif; ?> /> + <label for="order-shipping_same_as_billing" class="admin__field-label"> + <?= $block->escapeHtml(__('Same As Billing Address')) ?> + </label> <?= /* @noEscape */ $secureRenderer->renderEventListenerAsTag( 'onclick', "order.setShippingAsBilling(this.checked)", 'input#order-shipping_same_as_billing' ) ?> - <label for="order-shipping_same_as_billing" class="admin__field-label"> - <?= $block->escapeHtml(__('Same As Billing Address')) ?> - </label> </div> <?php endif; ?> <div class="admin__field admin__field-select-from-existing-address"> From e6df759a4a535b0172e3e652e36c9d98fd8416b9 Mon Sep 17 00:00:00 2001 From: David Haecker <dhaecker@magento.com> Date: Tue, 17 Nov 2020 10:26:33 -0600 Subject: [PATCH 41/69] magento/partners-magento2b2b#370: [Determine Coverage]: Add Meaningful Titles and Descriptions For All MFTF Tests in the Company, CompanyCredit, CompanyPayment, CompanyShipping, & ConfigurableSharedCatalog Modules - Cleaning up StorefrontVerifyOrdersVisibleInCompanyStructureAcrossMultipleWebsitesTest - Adding inline comments to before & after sections --- ...enCheckoutPageInCustomStoreActionGroup.xml | 20 +++++++++++++++++++ .../StorefrontCustomStoreCheckoutPage.xml | 20 +++++++++++++++++++ ...ntCustomStoreCustomerLogoutActionGroup.xml | 20 +++++++++++++++++++ .../StorefrontCustomStoreLoginActionGroup.xml | 20 +++++++++++++++++++ ...ToCustomerOrdersHistoryPageActionGroup.xml | 19 ++++++++++++++++++ ...torefrontCustomStoreCustomerLogoutPage.xml | 11 ++++++++++ ...torefrontCustomStoreCustomerSignInPage.xml | 15 ++++++++++++++ ...ntCustomStoreCustomerOrdersHistoryPage.xml | 14 +++++++++++++ 8 files changed, 139 insertions(+) create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCheckoutPageInCustomStoreActionGroup.xml create mode 100644 app/code/Magento/Checkout/Test/Mftf/Page/StorefrontCustomStoreCheckoutPage.xml create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreCustomerLogoutActionGroup.xml create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreLoginActionGroup.xml create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreNavigateToCustomerOrdersHistoryPageActionGroup.xml create mode 100644 app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomStoreCustomerLogoutPage.xml create mode 100644 app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomStoreCustomerSignInPage.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/Page/StorefrontCustomStoreCustomerOrdersHistoryPage.xml diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCheckoutPageInCustomStoreActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCheckoutPageInCustomStoreActionGroup.xml new file mode 100644 index 0000000000000..11102702454e8 --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCheckoutPageInCustomStoreActionGroup.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="StorefrontOpenCustomStoreCheckoutPageActionGroup" extends="StorefrontOpenCheckoutPageActionGroup"> + <annotations> + <description>Goes to the Storefront Checkout page in a custom store. Must have Add Store Code To Urls enabled</description> + </annotations> + <arguments> + <argument name="storeCode"/> + </arguments> + <amOnPage url="{{StorefrontCustomStoreCheckoutPage.url(storeCode)}}" stepKey="openCheckoutPage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Checkout/Test/Mftf/Page/StorefrontCustomStoreCheckoutPage.xml b/app/code/Magento/Checkout/Test/Mftf/Page/StorefrontCustomStoreCheckoutPage.xml new file mode 100644 index 0000000000000..632687d049b1f --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/Page/StorefrontCustomStoreCheckoutPage.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> + <page name="StorefrontCustomStoreCheckoutPage" url="/{{storeCode}}/checkout" area="storefront" module="Magento_Checkout" parameterized="true"> + <section name="StorefrontCheckoutPageMessagesSection"/> + <section name="CheckoutShippingSection"/> + <section name="CheckoutShippingMethodsSection"/> + <section name="CheckoutOrderSummarySection"/> + <section name="CheckoutSuccessMainSection"/> + <section name="CheckoutPaymentSection"/> + <section name="SelectShippingBillingPopupSection"/> + </page> +</pages> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreCustomerLogoutActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreCustomerLogoutActionGroup.xml new file mode 100644 index 0000000000000..ff1f29adf925d --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreCustomerLogoutActionGroup.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="StorefrontCustomStoreCustomerLogoutActionGroup" extends="StorefrontCustomerLogoutActionGroup"> + <annotations> + <description>Goes to the storefront Customer Logout page for a custom store. Must have Add Store Code To Urls enabled.</description> + </annotations> + <arguments> + <argument name="storeCode"/> + </arguments> + <amOnPage url="{{StorefrontCustomStoreCustomerLogoutPage.url(storeCode)}}" stepKey="storefrontSignOut"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreLoginActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreLoginActionGroup.xml new file mode 100644 index 0000000000000..ff3f9658cd303 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreLoginActionGroup.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="StorefrontCustomStoreLoginActionGroup" extends="LoginToStorefrontActionGroup"> + <annotations> + <description>Goes to the storefront Customer Sign In page for a custom store. Logs in using the provided Customer. Must have Add Store Code To Urls enabled</description> + </annotations> + <arguments> + <argument name="storeCode"/> + </arguments> + <amOnPage url="{{StorefrontCustomStoreCustomerSignInPage.url(storeCode)}}" stepKey="amOnSignInPage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreNavigateToCustomerOrdersHistoryPageActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreNavigateToCustomerOrdersHistoryPageActionGroup.xml new file mode 100644 index 0000000000000..827128db663f7 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreNavigateToCustomerOrdersHistoryPageActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="StorefrontCustomStoreNavigateToCustomerOrdersHistoryPageActionGroup" extends="StorefrontNavigateToCustomerOrdersHistoryPageActionGroup"> + <annotations> + <description>Goes to the storefront Customer Order History page for a custom store. Must have Add Store Code To Urls enabled</description> + </annotations> + <arguments> + <argument name="storeCode"/> + </arguments> + <amOnPage url="{{StorefrontCustomStoreCustomerOrdersHistoryPage.url(storeCode)}}" stepKey="amOnTheCustomerPage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomStoreCustomerLogoutPage.xml b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomStoreCustomerLogoutPage.xml new file mode 100644 index 0000000000000..c4f215470a3b7 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomStoreCustomerLogoutPage.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> + <page name="StorefrontCustomStoreCustomerLogoutPage" url="/{{storeCode}}/customer/account/logout/" area="storefront" module="Magento_Customer" parameterized="true"/> +</pages> diff --git a/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomStoreCustomerSignInPage.xml b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomStoreCustomerSignInPage.xml new file mode 100644 index 0000000000000..822aae12e8344 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomStoreCustomerSignInPage.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> + <page name="StorefrontCustomStoreCustomerSignInPage" url="/{{storeCode}}/customer/account/login/" area="storefront" module="Magento_Customer" parameterized="true"> + <section name="StorefrontCustomerSignInFormSection" /> + <section name="StorefrontCustomerLoginMessagesSection"/> + </page> +</pages> diff --git a/app/code/Magento/Sales/Test/Mftf/Page/StorefrontCustomStoreCustomerOrdersHistoryPage.xml b/app/code/Magento/Sales/Test/Mftf/Page/StorefrontCustomStoreCustomerOrdersHistoryPage.xml new file mode 100644 index 0000000000000..8393d4b490924 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Page/StorefrontCustomStoreCustomerOrdersHistoryPage.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> + <page name="StorefrontCustomStoreCustomerOrdersHistoryPage" url="/{{storeCode}}/sales/order/history/" module="Magento_Sales" area="storefront" parameterized="true"> + <section name="StorefrontCustomerOrdersGridSection"/> + </page> +</pages> From 1c3e95363480e5d1f515d0e3e1d99dd92e770304 Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi <tsviklinskyi@gmail.com> Date: Wed, 18 Nov 2020 12:42:41 +0200 Subject: [PATCH 42/69] MC-38717: Sales emails asynchronous sending sends out old emails --- .../Sales/Model/EmailSenderHandler.php | 54 ++++++++++++++-- .../Unit/Model/EmailSenderHandlerTest.php | 62 +++++++++++++++++-- 2 files changed, 105 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/Sales/Model/EmailSenderHandler.php b/app/code/Magento/Sales/Model/EmailSenderHandler.php index 7c7005bf0da75..98a120488b993 100644 --- a/app/code/Magento/Sales/Model/EmailSenderHandler.php +++ b/app/code/Magento/Sales/Model/EmailSenderHandler.php @@ -5,6 +5,10 @@ */ namespace Magento\Sales\Model; +use Magento\Framework\App\Config\ValueFactory; +use Magento\Framework\App\Config\ValueInterface; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Sales\Model\Order\Email\Container\IdentityInterface; /** @@ -53,14 +57,27 @@ class EmailSenderHandler */ private $storeManager; + /** + * Config data factory + * + * @var ValueFactory + */ + private $configValueFactory; + + /** + * @var TimezoneInterface + */ + private $localeDate; + /** * @param \Magento\Sales\Model\Order\Email\Sender $emailSender * @param \Magento\Sales\Model\ResourceModel\EntityAbstract $entityResource * @param \Magento\Sales\Model\ResourceModel\Collection\AbstractCollection $entityCollection * @param \Magento\Framework\App\Config\ScopeConfigInterface $globalConfig * @param IdentityInterface|null $identityContainer - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @throws \InvalidArgumentException + * @param \Magento\Store\Model\StoreManagerInterface|null $storeManager + * @param ValueFactory|null $configValueFactory + * @param TimezoneInterface|null $localeDate */ public function __construct( \Magento\Sales\Model\Order\Email\Sender $emailSender, @@ -68,17 +85,22 @@ public function __construct( \Magento\Sales\Model\ResourceModel\Collection\AbstractCollection $entityCollection, \Magento\Framework\App\Config\ScopeConfigInterface $globalConfig, IdentityInterface $identityContainer = null, - \Magento\Store\Model\StoreManagerInterface $storeManager = null + \Magento\Store\Model\StoreManagerInterface $storeManager = null, + ?ValueFactory $configValueFactory = null, + ?TimezoneInterface $localeDate = null ) { $this->emailSender = $emailSender; $this->entityResource = $entityResource; $this->entityCollection = $entityCollection; $this->globalConfig = $globalConfig; - $this->identityContainer = $identityContainer ?: \Magento\Framework\App\ObjectManager::getInstance() + $this->identityContainer = $identityContainer ?: ObjectManager::getInstance() ->get(\Magento\Sales\Model\Order\Email\Container\NullIdentity::class); - $this->storeManager = $storeManager ?: \Magento\Framework\App\ObjectManager::getInstance() + $this->storeManager = $storeManager ?: ObjectManager::getInstance() ->get(\Magento\Store\Model\StoreManagerInterface::class); + + $this->configValueFactory = $configValueFactory ?: ObjectManager::getInstance()->get(ValueFactory::class); + $this->localeDate = $localeDate ?: ObjectManager::getInstance()->get(TimezoneInterface::class); } /** @@ -90,6 +112,8 @@ public function sendEmails() if ($this->globalConfig->getValue('sales_email/general/async_sending')) { $this->entityCollection->addFieldToFilter('send_email', ['eq' => 1]); $this->entityCollection->addFieldToFilter('email_sent', ['null' => true]); + $startFromDate = $this->getStartFromDate(); + $this->entityCollection->addFieldToFilter('created_at', ['from' => $startFromDate]); $this->entityCollection->setPageSize( $this->globalConfig->getValue('sales_email/general/sending_limit') ); @@ -140,4 +164,24 @@ private function getStores( return $stores; } + + /** + * Get start from date for collection filter + * + * @return string + */ + private function getStartFromDate(): string + { + $fromDate = $this->localeDate->date()->format('Y-m-d H:i:s'); + /** @var $configValue ValueInterface */ + $configValue = $this->configValueFactory->create(); + $configValue->load('sales_email/general/async_sending', 'path'); + + if ($configValue->getId()) { + $fromDate = $this->localeDate->date($configValue->getUpdatedAt()) + ->modify('-1 day')->format('Y-m-d H:i:s'); + } + + return $fromDate; + } } diff --git a/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php b/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php index 386a919e41c90..84dc82b8f942a 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php @@ -7,8 +7,12 @@ namespace Magento\Sales\Test\Unit\Model; +use Magento\Config\Model\Config\Backend\Encrypted; use Magento\Framework\App\Config; +use Magento\Framework\App\Config\Value; +use Magento\Framework\App\Config\ValueFactory; use Magento\Framework\DB\Select; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Sales\Model\AbstractModel; use Magento\Sales\Model\EmailSenderHandler; @@ -71,6 +75,16 @@ class EmailSenderHandlerTest extends TestCase */ private $storeManagerMock; + /** + * @var ValueFactory|MockObject + */ + private $configValueFactory; + + /** + * @var TimezoneInterface|MockObject + */ + private $localeDate; + protected function setUp(): void { $objectManager = new ObjectManager($this); @@ -110,15 +124,25 @@ protected function setUp(): void StoreManagerInterface::class ); + $this->configValueFactory = $this->createMock( + ValueFactory::class + ); + + $this->localeDate = $this->createMock( + TimezoneInterface::class + ); + $this->object = $objectManager->getObject( EmailSenderHandler::class, [ - 'emailSender' => $this->emailSender, - 'entityResource' => $this->entityResource, - 'entityCollection' => $this->entityCollection, - 'globalConfig' => $this->globalConfig, - 'identityContainer' => $this->identityContainerMock, - 'storeManager' => $this->storeManagerMock, + 'emailSender' => $this->emailSender, + 'entityResource' => $this->entityResource, + 'entityCollection' => $this->entityCollection, + 'globalConfig' => $this->globalConfig, + 'identityContainer' => $this->identityContainerMock, + 'storeManager' => $this->storeManagerMock, + 'configValueFactory' => $this->configValueFactory, + 'localeDate' => $this->localeDate, ] ); } @@ -151,6 +175,14 @@ public function testExecute($configValue, $collectionItems, $emailSendingResult) ->method('addFieldToFilter') ->with('email_sent', ['null' => true]); + $dateTime = new \DateTime(); + $nowDate = $dateTime->format('Y-m-d H:i:s'); + $fromDate = $dateTime->modify('-1 day')->format('Y-m-d H:i:s'); + $this->entityCollection + ->expects($this->at(2)) + ->method('addFieldToFilter') + ->with('created_at', ['from' => $fromDate]); + $this->entityCollection ->expects($this->any()) ->method('addAttributeToSelect') @@ -175,6 +207,24 @@ public function testExecute($configValue, $collectionItems, $emailSendingResult) ->method('getItems') ->willReturn($collectionItems); + /** @var Value|Encrypted|MockObject $valueMock */ + $backendModelMock = $this->getMockBuilder(Value::class) + ->disableOriginalConstructor() + ->onlyMethods(['load', 'getId']) + ->addMethods(['getUpdatedAt']) + ->getMock(); + $backendModelMock->expects($this->once())->method('load')->willReturnSelf(); + $backendModelMock->expects($this->once())->method('getId')->willReturn(1); + $backendModelMock->expects($this->once())->method('getUpdatedAt')->willReturn($nowDate); + + $this->configValueFactory->expects($this->once()) + ->method('create') + ->willReturn($backendModelMock); + + $this->localeDate->expects($this->exactly(2)) + ->method('date') + ->willReturn(new \DateTime($nowDate)); + if ($collectionItems) { /** @var AbstractModel|MockObject $collectionItem */ From ac0500b3d63bfa75e87c74509dd548eee344b261 Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi <tsviklinskyi@gmail.com> Date: Wed, 18 Nov 2020 14:47:43 +0200 Subject: [PATCH 43/69] MC-38717: Sales emails asynchronous sending sends out old emails --- .../Sales/Model/EmailSenderHandler.php | 12 ++++++++-- .../Unit/Model/EmailSenderHandlerTest.php | 24 ++++++++++++------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/Sales/Model/EmailSenderHandler.php b/app/code/Magento/Sales/Model/EmailSenderHandler.php index 98a120488b993..d7d766339bebd 100644 --- a/app/code/Magento/Sales/Model/EmailSenderHandler.php +++ b/app/code/Magento/Sales/Model/EmailSenderHandler.php @@ -69,6 +69,11 @@ class EmailSenderHandler */ private $localeDate; + /** + * @var string + */ + private $modifyStartFromDate = '-1 day'; + /** * @param \Magento\Sales\Model\Order\Email\Sender $emailSender * @param \Magento\Sales\Model\ResourceModel\EntityAbstract $entityResource @@ -78,6 +83,7 @@ class EmailSenderHandler * @param \Magento\Store\Model\StoreManagerInterface|null $storeManager * @param ValueFactory|null $configValueFactory * @param TimezoneInterface|null $localeDate + * @param string|null $modifyStartFromDate */ public function __construct( \Magento\Sales\Model\Order\Email\Sender $emailSender, @@ -87,7 +93,8 @@ public function __construct( IdentityInterface $identityContainer = null, \Magento\Store\Model\StoreManagerInterface $storeManager = null, ?ValueFactory $configValueFactory = null, - ?TimezoneInterface $localeDate = null + ?TimezoneInterface $localeDate = null, + ?string $modifyStartFromDate = null ) { $this->emailSender = $emailSender; $this->entityResource = $entityResource; @@ -101,6 +108,7 @@ public function __construct( $this->configValueFactory = $configValueFactory ?: ObjectManager::getInstance()->get(ValueFactory::class); $this->localeDate = $localeDate ?: ObjectManager::getInstance()->get(TimezoneInterface::class); + $this->modifyStartFromDate = $modifyStartFromDate ?: $this->modifyStartFromDate; } /** @@ -179,7 +187,7 @@ private function getStartFromDate(): string if ($configValue->getId()) { $fromDate = $this->localeDate->date($configValue->getUpdatedAt()) - ->modify('-1 day')->format('Y-m-d H:i:s'); + ->modify($this->modifyStartFromDate)->format('Y-m-d H:i:s'); } return $fromDate; diff --git a/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php b/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php index 84dc82b8f942a..a177f411751b7 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php @@ -85,6 +85,11 @@ class EmailSenderHandlerTest extends TestCase */ private $localeDate; + /** + * @var string + */ + private $modifyStartFromDate = '-1 day'; + protected function setUp(): void { $objectManager = new ObjectManager($this); @@ -135,14 +140,15 @@ protected function setUp(): void $this->object = $objectManager->getObject( EmailSenderHandler::class, [ - 'emailSender' => $this->emailSender, - 'entityResource' => $this->entityResource, - 'entityCollection' => $this->entityCollection, - 'globalConfig' => $this->globalConfig, - 'identityContainer' => $this->identityContainerMock, - 'storeManager' => $this->storeManagerMock, - 'configValueFactory' => $this->configValueFactory, - 'localeDate' => $this->localeDate, + 'emailSender' => $this->emailSender, + 'entityResource' => $this->entityResource, + 'entityCollection' => $this->entityCollection, + 'globalConfig' => $this->globalConfig, + 'identityContainer' => $this->identityContainerMock, + 'storeManager' => $this->storeManagerMock, + 'configValueFactory' => $this->configValueFactory, + 'localeDate' => $this->localeDate, + 'modifyStartFromDate' => $this->modifyStartFromDate ] ); } @@ -177,7 +183,7 @@ public function testExecute($configValue, $collectionItems, $emailSendingResult) $dateTime = new \DateTime(); $nowDate = $dateTime->format('Y-m-d H:i:s'); - $fromDate = $dateTime->modify('-1 day')->format('Y-m-d H:i:s'); + $fromDate = $dateTime->modify($this->modifyStartFromDate)->format('Y-m-d H:i:s'); $this->entityCollection ->expects($this->at(2)) ->method('addFieldToFilter') From e1f6547f69c1d7dfa4251c9fc3d76322b7037f27 Mon Sep 17 00:00:00 2001 From: David Haecker <dhaecker@magento.com> Date: Wed, 18 Nov 2020 08:47:27 -0600 Subject: [PATCH 44/69] magento/partners-magento2b2b#370: [Determine Coverage]: Add Meaningful Titles and Descriptions For All MFTF Tests in the Company, CompanyCredit, CompanyPayment, CompanyShipping, & ConfigurableSharedCatalog Modules - Fixing PR feedback --- ...orefrontClickOrderLinkFromCheckoutSuccessPageActionGroup.xml | 2 +- .../ActionGroup/AdminSetCustomerActiveViaGridActionGroup.xml | 2 +- .../ActionGroup/AdminSetCustomerInactiveViaGridActionGroup.xml | 2 +- .../StorefrontGoToCustomerAddressesPageActionGroup.xml | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontClickOrderLinkFromCheckoutSuccessPageActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontClickOrderLinkFromCheckoutSuccessPageActionGroup.xml index ddff0153f93be..455d86d3709ac 100644 --- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontClickOrderLinkFromCheckoutSuccessPageActionGroup.xml +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontClickOrderLinkFromCheckoutSuccessPageActionGroup.xml @@ -14,6 +14,6 @@ </annotations> <click selector="{{CheckoutSuccessMainSection.orderLink}}" stepKey="clickOrderLink"/> <waitForPageLoad stepKey="waitForPageLoad"/> - <waitForText selector="{{StorefrontCustomerAccountMainSection.pageTitle}}" userInput="Order # " stepKey="waitForPageTitle"/> + <waitForText selector="{{StorefrontCustomerAccountMainSection.pageTitle}}" userInput="Order #" stepKey="waitForPageTitle"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerActiveViaGridActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerActiveViaGridActionGroup.xml index 7dff20dcb657b..132491da553a5 100644 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerActiveViaGridActionGroup.xml +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerActiveViaGridActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminSetCustomerActiveViaGridActionGroup"> + <actionGroup name="AdminSuccessfullySetCustomerActiveViaGridActionGroup"> <annotations> <description>Sets a Customer to the Active status from the admin All Customers grid</description> </annotations> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerInactiveViaGridActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerInactiveViaGridActionGroup.xml index 94151d72dffcb..b7d5c335aa8db 100644 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerInactiveViaGridActionGroup.xml +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSetCustomerInactiveViaGridActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminSetCustomerInactiveViaGridActionGroup" extends="AdminSetCustomerActiveViaGridActionGroup"> + <actionGroup name="AdminSuccessfullySetCustomerInactiveViaGridActionGroup" extends="AdminSuccessfullySetCustomerActiveViaGridActionGroup"> <annotations> <description>Sets a Customer to the Inactive status from the admin All Customers grid</description> </annotations> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontGoToCustomerAddressesPageActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontGoToCustomerAddressesPageActionGroup.xml index 33287b87346e5..ba942d9a1d904 100644 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontGoToCustomerAddressesPageActionGroup.xml +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontGoToCustomerAddressesPageActionGroup.xml @@ -12,6 +12,5 @@ <description>Goes to the storefront customer addresses page</description> </annotations> <amOnPage url="{{StorefrontCustomerAddressesPage.url}}" stepKey="goToAddressPage"/> - <waitForPageLoad stepKey="waitForPageLoad"/> </actionGroup> </actionGroups> From ac6bdfb25997c7230f8f8a6def7af03f2279aa4e Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi <tsviklinskyi@gmail.com> Date: Wed, 18 Nov 2020 17:30:26 +0200 Subject: [PATCH 45/69] MC-38717: Sales emails asynchronous sending sends out old emails --- .../Sales/Model/EmailSenderHandler.php | 41 ++++++++----------- .../Unit/Model/EmailSenderHandlerTest.php | 20 +-------- app/code/Magento/Sales/etc/di.xml | 5 +++ 3 files changed, 24 insertions(+), 42 deletions(-) diff --git a/app/code/Magento/Sales/Model/EmailSenderHandler.php b/app/code/Magento/Sales/Model/EmailSenderHandler.php index d7d766339bebd..a201c1285ae49 100644 --- a/app/code/Magento/Sales/Model/EmailSenderHandler.php +++ b/app/code/Magento/Sales/Model/EmailSenderHandler.php @@ -8,8 +8,8 @@ use Magento\Framework\App\Config\ValueFactory; use Magento\Framework\App\Config\ValueInterface; use Magento\Framework\App\ObjectManager; -use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Sales\Model\Order\Email\Container\IdentityInterface; +use Magento\Sales\Model\ResourceModel\Collection\AbstractCollection; /** * Sales emails sending @@ -36,7 +36,7 @@ class EmailSenderHandler /** * Entity collection model. * - * @var \Magento\Sales\Model\ResourceModel\Collection\AbstractCollection + * @var AbstractCollection */ protected $entityCollection; @@ -64,36 +64,29 @@ class EmailSenderHandler */ private $configValueFactory; - /** - * @var TimezoneInterface - */ - private $localeDate; - /** * @var string */ - private $modifyStartFromDate = '-1 day'; + private $modifyStartFromDate; /** * @param \Magento\Sales\Model\Order\Email\Sender $emailSender * @param \Magento\Sales\Model\ResourceModel\EntityAbstract $entityResource - * @param \Magento\Sales\Model\ResourceModel\Collection\AbstractCollection $entityCollection + * @param AbstractCollection $entityCollection * @param \Magento\Framework\App\Config\ScopeConfigInterface $globalConfig * @param IdentityInterface|null $identityContainer * @param \Magento\Store\Model\StoreManagerInterface|null $storeManager * @param ValueFactory|null $configValueFactory - * @param TimezoneInterface|null $localeDate * @param string|null $modifyStartFromDate */ public function __construct( \Magento\Sales\Model\Order\Email\Sender $emailSender, \Magento\Sales\Model\ResourceModel\EntityAbstract $entityResource, - \Magento\Sales\Model\ResourceModel\Collection\AbstractCollection $entityCollection, + AbstractCollection $entityCollection, \Magento\Framework\App\Config\ScopeConfigInterface $globalConfig, IdentityInterface $identityContainer = null, \Magento\Store\Model\StoreManagerInterface $storeManager = null, ?ValueFactory $configValueFactory = null, - ?TimezoneInterface $localeDate = null, ?string $modifyStartFromDate = null ) { $this->emailSender = $emailSender; @@ -107,7 +100,6 @@ public function __construct( ->get(\Magento\Store\Model\StoreManagerInterface::class); $this->configValueFactory = $configValueFactory ?: ObjectManager::getInstance()->get(ValueFactory::class); - $this->localeDate = $localeDate ?: ObjectManager::getInstance()->get(TimezoneInterface::class); $this->modifyStartFromDate = $modifyStartFromDate ?: $this->modifyStartFromDate; } @@ -120,8 +112,7 @@ public function sendEmails() if ($this->globalConfig->getValue('sales_email/general/async_sending')) { $this->entityCollection->addFieldToFilter('send_email', ['eq' => 1]); $this->entityCollection->addFieldToFilter('email_sent', ['null' => true]); - $startFromDate = $this->getStartFromDate(); - $this->entityCollection->addFieldToFilter('created_at', ['from' => $startFromDate]); + $this->filterCollectionByStartFromDate($this->entityCollection); $this->entityCollection->setPageSize( $this->globalConfig->getValue('sales_email/general/sending_limit') ); @@ -158,7 +149,7 @@ public function sendEmails() * @throws \Magento\Framework\Exception\NoSuchEntityException */ private function getStores( - \Magento\Sales\Model\ResourceModel\Collection\AbstractCollection $entityCollection + AbstractCollection $entityCollection ): array { $stores = []; @@ -174,22 +165,24 @@ private function getStores( } /** - * Get start from date for collection filter + * Filter collection by start from date * - * @return string + * @param AbstractCollection $collection + * @return void */ - private function getStartFromDate(): string + private function filterCollectionByStartFromDate(AbstractCollection $collection): void { - $fromDate = $this->localeDate->date()->format('Y-m-d H:i:s'); /** @var $configValue ValueInterface */ $configValue = $this->configValueFactory->create(); $configValue->load('sales_email/general/async_sending', 'path'); if ($configValue->getId()) { - $fromDate = $this->localeDate->date($configValue->getUpdatedAt()) - ->modify($this->modifyStartFromDate)->format('Y-m-d H:i:s'); - } + $startFromDate = date( + 'Y-m-d H:i:s', + strtotime($configValue->getUpdatedAt() . ' ' . $this->modifyStartFromDate) + ); - return $fromDate; + $collection->addFieldToFilter('created_at', ['from' => $startFromDate]); + } } } diff --git a/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php b/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php index a177f411751b7..757a026aa5d68 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/EmailSenderHandlerTest.php @@ -12,7 +12,6 @@ use Magento\Framework\App\Config\Value; use Magento\Framework\App\Config\ValueFactory; use Magento\Framework\DB\Select; -use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Sales\Model\AbstractModel; use Magento\Sales\Model\EmailSenderHandler; @@ -80,11 +79,6 @@ class EmailSenderHandlerTest extends TestCase */ private $configValueFactory; - /** - * @var TimezoneInterface|MockObject - */ - private $localeDate; - /** * @var string */ @@ -133,10 +127,6 @@ protected function setUp(): void ValueFactory::class ); - $this->localeDate = $this->createMock( - TimezoneInterface::class - ); - $this->object = $objectManager->getObject( EmailSenderHandler::class, [ @@ -147,7 +137,6 @@ protected function setUp(): void 'identityContainer' => $this->identityContainerMock, 'storeManager' => $this->storeManagerMock, 'configValueFactory' => $this->configValueFactory, - 'localeDate' => $this->localeDate, 'modifyStartFromDate' => $this->modifyStartFromDate ] ); @@ -181,9 +170,8 @@ public function testExecute($configValue, $collectionItems, $emailSendingResult) ->method('addFieldToFilter') ->with('email_sent', ['null' => true]); - $dateTime = new \DateTime(); - $nowDate = $dateTime->format('Y-m-d H:i:s'); - $fromDate = $dateTime->modify($this->modifyStartFromDate)->format('Y-m-d H:i:s'); + $nowDate = date('Y-m-d H:i:s'); + $fromDate = date('Y-m-d H:i:s', strtotime($nowDate . ' ' . $this->modifyStartFromDate)); $this->entityCollection ->expects($this->at(2)) ->method('addFieldToFilter') @@ -227,10 +215,6 @@ public function testExecute($configValue, $collectionItems, $emailSendingResult) ->method('create') ->willReturn($backendModelMock); - $this->localeDate->expects($this->exactly(2)) - ->method('date') - ->willReturn(new \DateTime($nowDate)); - if ($collectionItems) { /** @var AbstractModel|MockObject $collectionItem */ diff --git a/app/code/Magento/Sales/etc/di.xml b/app/code/Magento/Sales/etc/di.xml index b4dadfa944a5b..1ad411f70eaa4 100644 --- a/app/code/Magento/Sales/etc/di.xml +++ b/app/code/Magento/Sales/etc/di.xml @@ -215,6 +215,11 @@ </argument> </arguments> </type> + <type name="Magento\Sales\Model\EmailSenderHandler"> + <arguments> + <argument name="modifyStartFromDate" xsi:type="string">-1 day</argument> + </arguments> + </type> <virtualType name="SalesOrderIndexGridSyncRemove" type="Magento\Sales\Observer\GridSyncRemoveObserver"> <arguments> <argument name="entityGrid" xsi:type="object">Magento\Sales\Model\ResourceModel\Order\Grid</argument> From 68449751f428ca7f1d37ed2a18379c60647d4c38 Mon Sep 17 00:00:00 2001 From: Viktor Petryk <victor.petryk@transoftgroup.com> Date: Thu, 19 Nov 2020 10:45:26 +0200 Subject: [PATCH 46/69] MC-24217: Elastic Search Throwing 400 error status if you use incorrect filter value --- .../Model/Layer/Filter/Attribute.php | 36 ++++-- .../Model/Layer/Filter/Decimal.php | 54 ++++---- .../Unit/Model/Layer/Filter/AttributeTest.php | 115 +++++++++++++----- .../Model/Layer/Filter/AttributeTest.php | 63 ++++++---- .../Model/Layer/Filter/DecimalTest.php | 107 +++++++++------- 5 files changed, 242 insertions(+), 133 deletions(-) diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php index 080af5daa0322..22ad385dc2fc3 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php @@ -7,7 +7,10 @@ namespace Magento\CatalogSearch\Model\Layer\Filter; +use Magento\Catalog\Api\Data\ProductAttributeInterface; use Magento\Catalog\Model\Layer\Filter\AbstractFilter; +use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection; +use Magento\Framework\App\RequestInterface; /** * Layer attribute filter @@ -48,11 +51,10 @@ public function __construct( /** * Apply attribute option filter to product collection * - * @param \Magento\Framework\App\RequestInterface $request + * @param RequestInterface $request * @return $this - * @throws \Magento\Framework\Exception\LocalizedException */ - public function apply(\Magento\Framework\App\RequestInterface $request) + public function apply(RequestInterface $request) { $attributeValue = $request->getParam($this->_requestVar); if (empty($attributeValue) && !is_numeric($attributeValue)) { @@ -60,13 +62,16 @@ public function apply(\Magento\Framework\App\RequestInterface $request) } $attribute = $this->getAttributeModel(); - /** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */ + /** @var Collection $productCollection */ $productCollection = $this->getLayer() ->getProductCollection(); - $productCollection->addFieldToFilter($attribute->getAttributeCode(), $attributeValue); + $productCollection->addFieldToFilter( + $attribute->getAttributeCode(), + $this->convertAttributeValue($attribute, $attributeValue) + ); $labels = []; - foreach ((array) $attributeValue as $value) { + foreach ((array)$attributeValue as $value) { $label = $this->getOptionText($value); $labels[] = is_array($label) ? $label : [$label]; } @@ -76,6 +81,7 @@ public function apply(\Magento\Framework\App\RequestInterface $request) ->addFilter($this->_createItem($label, $attributeValue)); $this->setItems([]); // set items to disable show filtering + return $this; } @@ -88,7 +94,7 @@ public function apply(\Magento\Framework\App\RequestInterface $request) protected function _getItemsData() { $attribute = $this->getAttributeModel(); - /** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */ + /** @var Collection $productCollection */ $productCollection = $this->getLayer() ->getProductCollection(); $optionsFacetedData = $productCollection->getFacetedData($attribute->getAttributeCode()); @@ -163,6 +169,22 @@ private function getOptionCount($value, $optionsFacetedData) : 0; } + /** + * Convert attribute value according to its backend type. + * + * @param ProductAttributeInterface $attribute + * @param mixed $value + * @return int|string + */ + private function convertAttributeValue(ProductAttributeInterface $attribute, $value) + { + if ($attribute->getBackendType() === 'int') { + return (int)$value; + } + + return $value; + } + /** * @inheritdoc */ diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php index e2cb9174b5e97..7622f1d50ab60 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Decimal.php @@ -7,7 +7,17 @@ namespace Magento\CatalogSearch\Model\Layer\Filter; +use Magento\Catalog\Model\Layer; use Magento\Catalog\Model\Layer\Filter\AbstractFilter; +use Magento\Catalog\Model\Layer\Filter\Item\DataBuilder; +use Magento\Catalog\Model\Layer\Filter\ItemFactory; +use Magento\Catalog\Model\ResourceModel\Layer\Filter\Decimal as ResourceDecimal; +use Magento\Catalog\Model\ResourceModel\Layer\Filter\DecimalFactory; +use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection as ProductCollection; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\Phrase; +use Magento\Framework\Pricing\PriceCurrencyInterface; +use Magento\Store\Model\StoreManagerInterface; /** * Layer decimal filter @@ -15,31 +25,31 @@ class Decimal extends AbstractFilter { /** - * @var \Magento\Framework\Pricing\PriceCurrencyInterface + * @var PriceCurrencyInterface */ private $priceCurrency; /** - * @var \Magento\Catalog\Model\ResourceModel\Layer\Filter\Decimal + * @var ResourceDecimal */ private $resource; /** - * @param \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Catalog\Model\Layer $layer - * @param \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder - * @param \Magento\Catalog\Model\ResourceModel\Layer\Filter\DecimalFactory $filterDecimalFactory - * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency + * @param ItemFactory $filterItemFactory + * @param StoreManagerInterface $storeManager + * @param Layer $layer + * @param DataBuilder $itemDataBuilder + * @param DecimalFactory $filterDecimalFactory + * @param PriceCurrencyInterface $priceCurrency * @param array $data */ public function __construct( - \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory, - \Magento\Store\Model\StoreManagerInterface $storeManager, - \Magento\Catalog\Model\Layer $layer, - \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder, - \Magento\Catalog\Model\ResourceModel\Layer\Filter\DecimalFactory $filterDecimalFactory, - \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, + ItemFactory $filterItemFactory, + StoreManagerInterface $storeManager, + Layer $layer, + DataBuilder $itemDataBuilder, + DecimalFactory $filterDecimalFactory, + PriceCurrencyInterface $priceCurrency, array $data = [] ) { parent::__construct( @@ -56,11 +66,10 @@ public function __construct( /** * Apply price range filter * - * @param \Magento\Framework\App\RequestInterface $request + * @param RequestInterface $request * @return $this - * @throws \Magento\Framework\Exception\LocalizedException */ - public function apply(\Magento\Framework\App\RequestInterface $request) + public function apply(RequestInterface $request) { /** * Filter must be string: $fromPrice-$toPrice @@ -71,6 +80,8 @@ public function apply(\Magento\Framework\App\RequestInterface $request) } list($from, $to) = explode('-', $filter); + $from = (float)$from; + $to = (float)$to; $this->getLayer() ->getProductCollection() @@ -90,14 +101,12 @@ public function apply(\Magento\Framework\App\RequestInterface $request) * Get data array for building attribute filter items * * @return array - * @throws \Magento\Framework\Exception\LocalizedException - * @SuppressWarnings(PHPMD.NPathComplexity) */ protected function _getItemsData() { $attribute = $this->getAttributeModel(); - /** @var \Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection $productCollection */ + /** @var ProductCollection $productCollection */ $productCollection = $this->getLayer()->getProductCollection(); $productSize = $productCollection->getSize(); $facets = $productCollection->getFacetedData($attribute->getAttributeCode()); @@ -123,7 +132,7 @@ protected function _getItemsData() 'value' => $value, 'count' => $count, 'from' => $from, - 'to' => $to + 'to' => $to, ]; } @@ -135,7 +144,7 @@ protected function _getItemsData() * * @param float|string $fromPrice * @param float|string $toPrice - * @return \Magento\Framework\Phrase + * @return Phrase */ protected function renderRangeLabel($fromPrice, $toPrice) { @@ -146,6 +155,7 @@ protected function renderRangeLabel($fromPrice, $toPrice) if ($fromPrice != $toPrice) { $toPrice -= .01; } + return __('%1 - %2', $formattedFromPrice, $this->priceCurrency->format($toPrice)); } } diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Layer/Filter/AttributeTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Layer/Filter/AttributeTest.php index d90b612b7a1bc..6036798e446df 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Layer/Filter/AttributeTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Layer/Filter/AttributeTest.php @@ -13,6 +13,7 @@ use Magento\Catalog\Model\Layer\Filter\Item\DataBuilder; use Magento\Catalog\Model\Layer\Filter\ItemFactory; use Magento\Catalog\Model\Layer\State; +use Magento\Catalog\Model\ResourceModel\Eav\Attribute as EavAttribute; use Magento\Catalog\Model\ResourceModel\Layer\Filter\AttributeFactory; use Magento\CatalogSearch\Model\Layer\Filter\Attribute; use Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection; @@ -25,6 +26,8 @@ use PHPUnit\Framework\TestCase; /** + * Unit tests for \Magento\CatalogSearch\Model\Layer\Filter\Attribute class. + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AttributeTest extends TestCase @@ -34,36 +37,39 @@ class AttributeTest extends TestCase */ private $target; - /** @var AbstractFrontend|MockObject */ + /** @var AbstractFrontend|MockObject */ private $frontend; - /** @var Collection|MockObject */ + /** @var Collection|MockObject */ private $fulltextCollection; - /** @var State|MockObject */ + /** @var State|MockObject */ private $state; - /** @var \Magento\Eav\Model\Entity\Attribute|MockObject */ + /** @var EavAttribute|MockObject */ private $attribute; /** @var RequestInterface|MockObject */ private $request; - /** @var AttributeFactory|MockObject */ + /** @var AttributeFactory|MockObject */ private $filterAttributeFactory; - /** @var ItemFactory|MockObject */ + /** @var ItemFactory|MockObject */ private $filterItemFactory; - /** @var StoreManagerInterface|MockObject */ + /** @var StoreManagerInterface|MockObject */ private $storeManager; - /** @var Layer|MockObject */ + /** @var Layer|MockObject */ private $layer; /** @var DataBuilder|MockObject */ private $itemDataBuilder; + /** + * @inheritdoc + */ protected function setUp(): void { /** @var ItemFactory $filterItemFactory */ @@ -96,9 +102,7 @@ protected function setUp(): void ->setMethods(['addItemData', 'build']) ->getMock(); - $this->filterAttributeFactory = $this->getMockBuilder( - AttributeFactory::class - ) + $this->filterAttributeFactory = $this->getMockBuilder(AttributeFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); @@ -115,9 +119,14 @@ protected function setUp(): void ->disableOriginalConstructor() ->setMethods(['getOption', 'getSelectOptions']) ->getMock(); - $this->attribute = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute::class) + $this->attribute = $this->getMockBuilder(EavAttribute::class) ->disableOriginalConstructor() - ->setMethods(['getAttributeCode', 'getFrontend', 'getIsFilterable']) + ->onlyMethods([ + 'getAttributeCode', + 'getFrontend', + 'getIsFilterable', + 'getBackendType', + ]) ->getMock(); $this->request = $this->getMockBuilder(RequestInterface::class) @@ -146,15 +155,16 @@ protected function setUp(): void ); } - public function testApplyFilter() + /** + * @dataProvider attributeDataProvider + * @param array $attributeData + * @return void + */ + public function testApplyFilter(array $attributeData) { - $attributeCode = 'attributeCode'; - $attributeValue = 'attributeValue'; - $attributeLabel = 'attributeLabel'; - $this->attribute->expects($this->exactly(2)) ->method('getAttributeCode') - ->willReturn($attributeCode); + ->willReturn($attributeData['attribute_code']); $this->attribute->expects($this->atLeastOnce()) ->method('getFrontend') ->willReturn($this->frontend); @@ -163,45 +173,88 @@ public function testApplyFilter() $this->request->expects($this->once()) ->method('getParam') - ->with($attributeCode) - ->willReturn($attributeValue); + ->with($attributeData['attribute_code']) + ->willReturn($attributeData['attribute_value']); + + $this->attribute->expects($this->once()) + ->method('getBackendType') + ->willReturn($attributeData['backend_type']); $this->fulltextCollection->expects($this->once()) ->method('addFieldToFilter') - ->with($attributeCode, $attributeValue)->willReturnSelf(); + ->with( + $attributeData['attribute_code'], + $attributeData['attribute_value'] + ) + ->willReturnSelf(); $this->frontend->expects($this->once()) ->method('getOption') - ->with($attributeValue) - ->willReturn($attributeLabel); - - $filterItem = $this->createFilterItem(0, $attributeLabel, $attributeValue, 0); + ->with($attributeData['attribute_value']) + ->willReturn($attributeData['attribute_label']); + + $filterItem = $this->createFilterItem( + 0, + $attributeData['attribute_label'], + $attributeData['attribute_value'], + 0 + ); $filterItem->expects($this->once()) ->method('setFilter') - ->with($this->target)->willReturnSelf(); + ->with($this->target) + ->willReturnSelf(); $filterItem->expects($this->once()) ->method('setLabel') - ->with($attributeLabel)->willReturnSelf(); + ->with($attributeData['attribute_label']) + ->willReturnSelf(); $filterItem->expects($this->once()) ->method('setValue') - ->with($attributeValue)->willReturnSelf(); + ->with($attributeData['attribute_value']) + ->willReturnSelf(); $filterItem->expects($this->once()) ->method('setCount') - ->with(0)->willReturnSelf(); + ->with(0) + ->willReturnSelf(); $this->state->expects($this->once()) ->method('addFilter') - ->with($filterItem)->willReturnSelf(); + ->with($filterItem) + ->willReturnSelf(); $result = $this->target->apply($this->request); $this->assertEquals($this->target, $result); } + /** + * @return array + */ + public function attributeDataProvider(): array + { + return [ + 'Attribute with \'text\' backend type' => [ + [ + 'attribute_code' => 'attributeCode', + 'attribute_value' => 'attributeValue', + 'attribute_label' => 'attributeLabel', + 'backend_type' => 'text', + ], + ], + 'Attribute with \'int\' backend type' => [ + [ + 'attribute_code' => 'attributeCode', + 'attribute_value' => '0', + 'attribute_label' => 'attributeLabel', + 'backend_type' => 'int', + ], + ], + ]; + } + public function testGetItemsWithApply() { $attributeCode = 'attributeCode'; diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Layer/Filter/AttributeTest.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Layer/Filter/AttributeTest.php index 463cb026a4c69..a0a445f19e17a 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Layer/Filter/AttributeTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Layer/Filter/AttributeTest.php @@ -3,17 +3,24 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\CatalogSearch\Model\Layer\Filter; +use Magento\Catalog\Api\Data\ProductAttributeInterface; +use Magento\Catalog\Model\Layer\Category as LayerCategory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Request; +use PHPUnit\Framework\TestCase; + /** * Test class for \Magento\CatalogSearch\Model\Layer\Filter\Attribute. * * @magentoDataFixture Magento/Catalog/Model/Layer/Filter/_files/attribute_with_option.php */ -class AttributeTest extends \PHPUnit\Framework\TestCase +class AttributeTest extends TestCase { /** - * @var \Magento\CatalogSearch\Model\Layer\Filter\Attribute + * @var Attribute */ protected $_model; @@ -23,16 +30,18 @@ class AttributeTest extends \PHPUnit\Framework\TestCase protected $_attributeOptionId; /** - * @var \Magento\Catalog\Model\Layer + * @var mixed */ - protected $_layer; + private $request; + /** + * @inheritdoc + */ protected function setUp(): void { - /** @var $attribute \Magento\Catalog\Model\Entity\Attribute */ - $attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Catalog\Model\Entity\Attribute::class - ); + $objectManager = Bootstrap::getObjectManager(); + /** @var ProductAttributeInterface $attribute */ + $attribute = $objectManager->get(ProductAttributeInterface::class); $attribute->loadByCode('catalog_product', 'attribute_with_option'); foreach ($attribute->getSource()->getAllOptions() as $optionInfo) { if ($optionInfo['label'] == 'Option Label') { @@ -41,51 +50,53 @@ protected function setUp(): void } } - $this->_layer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create(\Magento\Catalog\Model\Layer\Category::class); - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create(\Magento\CatalogSearch\Model\Layer\Filter\Attribute::class, ['layer' => $this->_layer]); + /** @var LayerCategory $layer */ + $layer = $objectManager->get(LayerCategory::class); + $this->request = $objectManager->get(Request::class); + $this->_model = $objectManager->create(Attribute::class, ['layer' => $layer]); $this->_model->setAttributeModel($attribute); $this->_model->setRequestVar('attribute'); } + /** + * @return void + */ public function testOptionIdNotEmpty() { $this->assertNotEmpty($this->_attributeOptionId, 'Fixture attribute option id.'); // just in case } + /** + * @return void + */ public function testApplyInvalid() { $this->assertEmpty($this->_model->getLayer()->getState()->getFilters()); - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $request = $objectManager->get(\Magento\TestFramework\Request::class); - $request->setParam('attribute', []); - $this->_model->apply($request); + $this->request->setParam('attribute', []); + $this->_model->apply($this->request); $this->assertEmpty($this->_model->getLayer()->getState()->getFilters()); } + /** + * @return void + */ public function testApply() { $this->assertEmpty($this->_model->getLayer()->getState()->getFilters()); - - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $request = $objectManager->get(\Magento\TestFramework\Request::class); - $request->setParam('attribute', $this->_attributeOptionId); - $this->_model->apply($request); + $this->request->setParam('attribute', $this->_attributeOptionId); + $this->_model->apply($this->request); $this->assertNotEmpty($this->_model->getLayer()->getState()->getFilters()); } /** - * @depends testApply + * @return void */ public function testGetItemsWithApply() { - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $request = $objectManager->get(\Magento\TestFramework\Request::class); - $request->setParam('attribute', $this->_attributeOptionId); - $this->_model->apply($request); + $this->request->setParam('attribute', $this->_attributeOptionId); + $this->_model->apply($this->request); $items = $this->_model->getItems(); $this->assertIsArray($items); diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Layer/Filter/DecimalTest.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Layer/Filter/DecimalTest.php index def90b0b5e97b..69e6a0ff87848 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Layer/Filter/DecimalTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/Layer/Filter/DecimalTest.php @@ -3,8 +3,16 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\CatalogSearch\Model\Layer\Filter; +use Magento\Catalog\Api\CategoryRepositoryInterface; +use Magento\Catalog\Api\Data\ProductAttributeInterface; +use Magento\Catalog\Model\Layer\Category as LayerCategory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Request; +use PHPUnit\Framework\TestCase; + /** * Test class for \Magento\CatalogSearch\Model\Layer\Filter\Decimal. * @@ -14,78 +22,83 @@ * @magentoDbIsolation enabled * @magentoAppIsolation enabled */ -class DecimalTest extends \PHPUnit\Framework\TestCase +class DecimalTest extends TestCase { /** - * @var \Magento\CatalogSearch\Model\Layer\Filter\Decimal + * @var Decimal */ protected $_model; + /** + * @var mixed + */ + private $request; + + /** + * @inheritdoc + */ protected function setUp(): void { - $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create( - \Magento\Catalog\Model\Category::class - ); - $category->load(4); + $objectManager = Bootstrap::getObjectManager(); + /** @var CategoryRepositoryInterface $categoryRepository */ + $categoryRepository = $objectManager->get(CategoryRepositoryInterface::class); + $category = $categoryRepository->get(4); - $layer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create( - \Magento\Catalog\Model\Layer\Category::class, - [ - 'data' => ['current_category' => $category] - ] - ); - - /** @var $attribute \Magento\Catalog\Model\Entity\Attribute */ - $attribute = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create( - \Magento\Catalog\Model\Entity\Attribute::class - ); + /** @var LayerCategory $layer */ + $layer = $objectManager->create( + LayerCategory::class, + ['data' => ['current_category' => $category]] + ); + /** @var ProductAttributeInterface $attribute */ + $attribute = $objectManager->get(ProductAttributeInterface::class); $attribute->loadByCode('catalog_product', 'weight'); - - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create(\Magento\CatalogSearch\Model\Layer\Filter\Decimal::class, ['layer' => $layer]); + $this->request = $objectManager->get(Request::class); + $this->_model = $objectManager->create(Decimal::class, ['layer' => $layer]); $this->_model->setAttributeModel($attribute); + $this->_model->setRequestVar('decimal'); } + /** + * @return void + */ public function testApplyNothing() { - $this->assertEmpty($this->_model->getData('range')); - /** @var $objectManager \Magento\TestFramework\ObjectManager */ - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - /** @var $request \Magento\TestFramework\Request */ - $request = $objectManager->get(\Magento\TestFramework\Request::class); - $this->_model->apply($request); - - $this->assertEmpty($this->_model->getData('range')); + $this->assertEmpty($this->_model->getLayer()->getState()->getFilters()); + $this->_model->apply($this->request); + $this->assertEmpty($this->_model->getLayer()->getState()->getFilters()); } + /** + * @return void + */ public function testApplyInvalid() { - $this->assertEmpty($this->_model->getData('range')); - /** @var $objectManager \Magento\TestFramework\ObjectManager */ - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - /** @var $request \Magento\TestFramework\Request */ - $request = $objectManager->get(\Magento\TestFramework\Request::class); - $request->setParam('decimal', 'non-decimal'); - $this->_model->apply($request); + $this->assertEmpty($this->_model->getLayer()->getState()->getFilters()); + $this->request->setParam('decimal', 'non-decimal'); + $this->_model->apply($this->request); - $this->assertEmpty($this->_model->getData('range')); + $filters = $this->_model->getLayer()->getState()->getFilters(); + $this->assertArrayHasKey(0, $filters); + $this->assertEquals( + '<span class="price">$0.00</span> - <span class="price">$0.00</span>', + (string)$filters[0]->getLabel() + ); } /** - * @return Decimal + * @return void */ public function testApply() { - /** @var $objectManager \Magento\TestFramework\ObjectManager */ - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - /** @var $request \Magento\TestFramework\Request */ - $request = $objectManager->get(\Magento\TestFramework\Request::class); - $request->setParam('decimal', '1-100'); - $this->_model->apply($request); + $this->assertEmpty($this->_model->getLayer()->getState()->getFilters()); + $this->request->setParam('decimal', '1-100'); + $this->_model->apply($this->request); - return $this->_model; + $filters = $this->_model->getLayer()->getState()->getFilters(); + $this->assertArrayHasKey(0, $filters); + $this->assertEquals( + '<span class="price">$1.00</span> - <span class="price">$99.99</span>', + (string)$filters[0]->getLabel() + ); } } From e94a9fd170756f572215a70305e19803b61643ad Mon Sep 17 00:00:00 2001 From: Serhiy Yelahin <serhiy.yelahin@transoftgroup.com> Date: Thu, 19 Nov 2020 13:36:33 +0200 Subject: [PATCH 47/69] MC-39127: Account Issue when Persistance is enabled and clear Persistence on Sign Out is set to No --- ...efrontCorrectWelcomeMessageAfterCustomerIsLoggedOutTest.xml | 3 +++ .../Persistent/view/frontend/web/js/view/additional-welcome.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontCorrectWelcomeMessageAfterCustomerIsLoggedOutTest.xml b/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontCorrectWelcomeMessageAfterCustomerIsLoggedOutTest.xml index 45ccab54de5f3..d6e1f2a247ebe 100644 --- a/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontCorrectWelcomeMessageAfterCustomerIsLoggedOutTest.xml +++ b/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontCorrectWelcomeMessageAfterCustomerIsLoggedOutTest.xml @@ -75,5 +75,8 @@ <see userInput="Welcome, $$createCustomerForPersistent.firstname$$ $$createCustomerForPersistent.lastname$$! Not you?" selector="{{StorefrontHeaderSection.welcomeMessage}}" stepKey="seePersistentWelcomeMessage"/> + <dontSee userInput="Not you? Not you?" + selector="{{StorefrontHeaderSection.welcomeMessage}}" + stepKey="verifyNotYouLinkNotDuplicated"/> </test> </tests> diff --git a/app/code/Magento/Persistent/view/frontend/web/js/view/additional-welcome.js b/app/code/Magento/Persistent/view/frontend/web/js/view/additional-welcome.js index 8e69325860167..4875617ef5ea1 100644 --- a/app/code/Magento/Persistent/view/frontend/web/js/view/additional-welcome.js +++ b/app/code/Magento/Persistent/view/frontend/web/js/view/additional-welcome.js @@ -40,8 +40,8 @@ define([ $(this).attr('data-bind', html); $(this).html(html); - $(this).after(' <span><a ' + window.notYouLink + '>' + $t('Not you?') + '</a></span>'); }); + $(welcomeElems).append(' <span><a ' + window.notYouLink + '>' + $t('Not you?') + '</a>'); } } }, From ba1ce66b4ae1ecc199920e33deb0853b93d0e803 Mon Sep 17 00:00:00 2001 From: engcom-Echo <engcom-vendorworker-echo@adobe.com> Date: Thu, 19 Nov 2020 14:57:22 +0200 Subject: [PATCH 48/69] MC-30626: Custom Option with Percent price is converted to a currency twice --- .../Block/Product/View/Options/AbstractOptions.php | 4 ++-- ...refrontCustomOptionCheckboxByPriceActionGroup.xml} | 4 ++-- ...ontCheckCustomOptionPriceDifferentCurrencyTest.xml | 11 ++++------- 3 files changed, 8 insertions(+), 11 deletions(-) rename app/code/Magento/Catalog/Test/Mftf/ActionGroup/{StorefrontAssertCustomOptionCheckboxByPriceActionGroup.xml => AssertStorefrontCustomOptionCheckboxByPriceActionGroup.xml} (86%) diff --git a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php index 68a6ea74f6ec5..8655897fa5cad 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php +++ b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php @@ -206,14 +206,14 @@ protected function _formatPrice($value, $flag = true) } } - $context[CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG] = true; + $context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true]; $optionAmount = $isPercent ? $this->calculator->getAmount( $this->priceCurrency->roundPrice($value['pricing_value']), $this->getProduct(), null, $context - ): $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context); + ) : $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context); $priceStr .= $this->getLayout()->getBlock('product.price.render.default')->renderAmount( $optionAmount, $customOptionPrice, diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertCustomOptionCheckboxByPriceActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertStorefrontCustomOptionCheckboxByPriceActionGroup.xml similarity index 86% rename from app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertCustomOptionCheckboxByPriceActionGroup.xml rename to app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertStorefrontCustomOptionCheckboxByPriceActionGroup.xml index afc57257f63e2..ddd26e9ff0544 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertCustomOptionCheckboxByPriceActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertStorefrontCustomOptionCheckboxByPriceActionGroup.xml @@ -8,13 +8,13 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="StorefrontAssertCustomOptionCheckboxByPriceActionGroup"> + <actionGroup name="AssertStorefrontCustomOptionCheckboxByPriceActionGroup"> <annotations> <description>Validates that the provided price for Custom Option Checkbox is present on the Storefront Product page.</description> </annotations> <arguments> <argument name="optionTitle" type="string" defaultValue="{{ProductOptionCheckbox.title}}"/> - <argument name="price" type="string"/> + <argument name="price" type="string" defaultValue="10"/> </arguments> <seeElement selector="{{StorefrontProductInfoMainSection.productAttributeOptionsCheckbox(optionTitle, price)}}" stepKey="checkPriceProductOptionCheckbox"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml index dfcda77974d32..a8368fcd95035 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckCustomOptionPriceDifferentCurrencyTest.xml @@ -19,32 +19,29 @@ <group value="catalog"/> </annotations> <before> - <magentoCLI command="config:set currency/options/allow EUR,USD" stepKey="setCurrencyAllow"/> + <magentoCLI command="config:set {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}},{{SetAllowedCurrenciesConfigForEUR.value}}" stepKey="setCurrencyAllow"/> <createData entity="_defaultCategory" stepKey="createCategory"/> <createData entity="_defaultProduct" stepKey="createProduct"> <requiredEntity createDataKey="createCategory"/> <field key="price">10</field> </createData> <updateData createDataKey="createProduct" entity="productWithCheckbox" stepKey="updateProductWithOptions"/> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> </before> <after> - <magentoCLI command="config:set currency/options/allow USD" stepKey="setCurrencyAllow"/> + <magentoCLI command="config:set {{SetAllowedCurrenciesConfigForUSD.path}} {{SetAllowedCurrenciesConfigForUSD.value}}" stepKey="setCurrencyAllow"/> <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> </after> <actionGroup ref="StorefrontOpenProductEntityPageActionGroup" stepKey="openProductPageOnStorefront"> <argument name="product" value="$createProduct$"/> </actionGroup> - <actionGroup ref="StorefrontAssertCustomOptionCheckboxByPriceActionGroup" stepKey="checkPriceProductOptionUSD"> + <actionGroup ref="AssertStorefrontCustomOptionCheckboxByPriceActionGroup" stepKey="checkPriceProductOptionUSD"> <argument name="price" value="12.3"/> </actionGroup> <actionGroup ref="StorefrontSwitchCurrencyActionGroup" stepKey="switchEURCurrency"> <argument name="currency" value="EUR"/> </actionGroup> - <actionGroup ref="StorefrontAssertCustomOptionCheckboxByPriceActionGroup" stepKey="checkPriceProductOptionEUR"> + <actionGroup ref="AssertStorefrontCustomOptionCheckboxByPriceActionGroup" stepKey="checkPriceProductOptionEUR"> <argument name="price" value="8.7"/> </actionGroup> </test> From 92f84bea570291a2c655ea56b0cc15c34460e34d Mon Sep 17 00:00:00 2001 From: SmVladyslav <vlatame.tsg@gmail.com> Date: Thu, 19 Nov 2020 16:13:48 +0200 Subject: [PATCH 49/69] MC-23554: Customer custom multiline attribute displays incorrectly --- .../Model/Metadata/Form/Multiline.php | 21 ++++--- .../Ui/Component/Form/Element/Multiline.php | 3 + .../view/base/ui_component/etc/definition.xml | 2 +- .../base/web/js/form/components/multiline.js | 57 +++++++++++++++++ .../base/js/form/components/multiline.test.js | 63 +++++++++++++++++++ 5 files changed, 137 insertions(+), 9 deletions(-) create mode 100644 app/code/Magento/Ui/view/base/web/js/form/components/multiline.js create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/components/multiline.test.js diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php b/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php index 643a73302825d..20ad691b1c72e 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php @@ -10,7 +10,7 @@ class Multiline extends Text { /** - * {@inheritdoc} + * @inheritDoc */ public function extractValue(\Magento\Framework\App\RequestInterface $request) { @@ -24,7 +24,8 @@ public function extractValue(\Magento\Framework\App\RequestInterface $request) } /** - * {@inheritdoc} + * @inheritDoc + * * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function validateValue($value) @@ -43,7 +44,8 @@ public function validateValue($value) if (!is_array($value)) { $value = [$value]; } - for ($i = 0; $i < $attribute->getMultilineCount(); $i++) { + $multilineCount = $attribute->getMultilineCount(); + for ($i = 0; $i < $multilineCount; $i++) { if (!isset($value[$i])) { $value[$i] = null; } @@ -57,6 +59,7 @@ public function validateValue($value) if (!empty($value[$i])) { $result = parent::validateValue($value[$i]); if ($result !== true) { + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $errors = array_merge($errors, $result); } } @@ -70,18 +73,20 @@ public function validateValue($value) } /** - * {@inheritdoc} + * @inheritDoc */ public function compactValue($value) { - if (!is_array($value)) { - $value = [$value]; + if (is_array($value)) { + $value = implode("\n", $value); } + $value = [$value]; + return parent::compactValue($value); } /** - * {@inheritdoc} + * @inheritDoc */ public function restoreValue($value) { @@ -89,7 +94,7 @@ public function restoreValue($value) } /** - * {@inheritdoc} + * @inheritDoc */ public function outputValue($format = \Magento\Customer\Model\Metadata\ElementFactory::OUTPUT_FORMAT_TEXT) { diff --git a/app/code/Magento/Ui/Component/Form/Element/Multiline.php b/app/code/Magento/Ui/Component/Form/Element/Multiline.php index fc8e96638fc50..6ef206308125e 100644 --- a/app/code/Magento/Ui/Component/Form/Element/Multiline.php +++ b/app/code/Magento/Ui/Component/Form/Element/Multiline.php @@ -66,6 +66,7 @@ public function prepare() { $size = abs((int) $this->getData('config/size')); $validation = [$this->getData('config/validation')]; + $namespace = $this->getContext()->getNamespace(); while ($size--) { $identifier = $this->getName() . '_' . $size; $arguments = [ @@ -74,6 +75,8 @@ public function prepare() 'config' => [ 'dataScope' => $size, 'dataType' => static::DATA_TYPE, + 'deps' => "{$namespace}.areas.customer.customer.{$this->getName()}", + 'provider' => $namespace . '.' . $this->getContext()->getDataProvider()->getName(), 'formElement' => static::FORM_ELEMENT, 'sortOrder' => $size, ] diff --git a/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml b/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml index f0a5f357f8a92..298ae22cb8904 100644 --- a/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml +++ b/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml @@ -141,7 +141,7 @@ </settings> </multiselect> <textarea class="Magento\Ui\Component\Form\Element\Textarea" component="Magento_Ui/js/form/element/textarea" template="ui/form/field"/> - <multiline class="Magento\Ui\Component\Form\Element\Multiline" component="Magento_Ui/js/form/components/group"/> + <multiline class="Magento\Ui\Component\Form\Element\Multiline" component="Magento_Ui/js/form/components/multiline"/> <range class="Magento\Ui\Component\Form\Element\Range" component="Magento_Ui/js/grid/filters/range"/> <fileUploader class="Magento\Ui\Component\Form\Element\DataType\Media" component="Magento_Ui/js/form/element/file-uploader" template="ui/form/element/uploader/uploader"/> <imageUploader class="Magento\Ui\Component\Form\Element\DataType\Media\Image" component="Magento_Ui/js/form/element/image-uploader" template="ui/form/element/uploader/image"> diff --git a/app/code/Magento/Ui/view/base/web/js/form/components/multiline.js b/app/code/Magento/Ui/view/base/web/js/form/components/multiline.js new file mode 100644 index 0000000000000..8c8816a0559a8 --- /dev/null +++ b/app/code/Magento/Ui/view/base/web/js/form/components/multiline.js @@ -0,0 +1,57 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +/** + * @api + */ +define([ + './group' +], function (Group) { + 'use strict'; + + return Group.extend({ + defaults: { + links: { + value: '${ $.provider }:${ $.dataScope }' + } + }, + + /** + * Initialize Multiline component. + * + * @returns {Object} + */ + initialize: function () { + return this._super() + ._prepareValue(); + }, + + /** + * {@inheritdoc} + */ + initObservable: function () { + this._super() + .observe('value'); + + return this; + }, + + /** + * Prepare value for Multiline options. + * + * @returns {Object} Chainable. + * @private + */ + _prepareValue: function () { + var value = this.value(); + + if (typeof value === 'string') { + this.value(value.split('\n')); + } + + return this; + } + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/components/multiline.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/components/multiline.test.js new file mode 100644 index 0000000000000..7ecfb24c2deef --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/components/multiline.test.js @@ -0,0 +1,63 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'uiRegistry', + 'Magento_Ui/js/form/components/multiline' +], function (registry, Constr) { + 'use strict'; + + describe('Magento_Ui/js/form/components/multiline', function () { + var obj, + dataScope = 'data', + providerName = 'provider', + prepareDataProvider = function (value) { // jscs:ignore jsDoc + registry.set(providerName, { + /** Stub */ + on: function () {}, + /** Stub */ + set: function () {}, + /** Stub */ + get: function () { + return value; + } + }); + }; + + describe('Verify process of preparing value for Multiline options', function () { + it('Check _prepareValue method', function () { + obj = new Constr({ + _prepareValue: jasmine.createSpy() + }); + + expect(obj._prepareValue).toHaveBeenCalled(); + }); + + it('Check array preparation', function () { + var value = ['some_array']; + + prepareDataProvider(value); + obj = new Constr({ + provider: providerName, + dataScope: dataScope + }); + + expect(obj.value().slice(0)).toEqual(value); + }); + + it('Check preparation of string value with line breaks', function () { + var value = '\n222\n'; + + prepareDataProvider(value); + obj = new Constr({ + provider: providerName, + dataScope: dataScope + }); + + expect(obj.value()).toEqual(['', '222', '']); + }); + }); + }); +}); From fecb1e46e8e86d986024f84c1930f70aa6238f52 Mon Sep 17 00:00:00 2001 From: Stas Kozar <stas.kozar@transoftgroup.com> Date: Thu, 19 Nov 2020 16:30:37 +0200 Subject: [PATCH 50/69] MC-38807: Preview Template button does not work in Queue Edit Page --- .../jasmine/tests/lib/mage/tinymce4Adapter.test.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/dev/tests/js/jasmine/tests/lib/mage/tinymce4Adapter.test.js b/dev/tests/js/jasmine/tests/lib/mage/tinymce4Adapter.test.js index 7af1a19e4b4c1..dee57ea3a0ad7 100644 --- a/dev/tests/js/jasmine/tests/lib/mage/tinymce4Adapter.test.js +++ b/dev/tests/js/jasmine/tests/lib/mage/tinymce4Adapter.test.js @@ -5,8 +5,9 @@ define([ 'wysiwygAdapter', - 'underscore' -], function (wysiwygAdapter, _) { + 'underscore', + 'tinymce4' +], function (wysiwygAdapter, _, tinyMCE4) { 'use strict'; var obj; @@ -38,4 +39,12 @@ define([ expect(_.size(obj.eventBus.arrEvents['open_browser_callback'])).toBe(1); }); }); + + describe('"triggerSave" method', function () { + it('Check method call.', function () { + spyOn(tinyMCE4, 'triggerSave') + obj.triggerSave(); + expect(tinyMCE4.triggerSave).toHaveBeenCalled(); + }); + }); }); From e42f90d5f1125a575b896d66ef412daf710aab70 Mon Sep 17 00:00:00 2001 From: David Haecker <dhaecker@magento.com> Date: Thu, 19 Nov 2020 15:04:23 -0600 Subject: [PATCH 51/69] magento/partners-magento2b2b#370: [Determine Coverage]: Add Meaningful Titles and Descriptions For All MFTF Tests in the Company, CompanyCredit, CompanyPayment, CompanyShipping, & ConfigurableSharedCatalog Modules - Fixing StorefrontCreateAnOrderWithCompanyCreditAndPurchaseOrderNumberTest - Cleaning up StorefrontCreateAnOrderWithCompanyCreditTest - Cleaning up StorefrontCreateInvoiceForPendingOrderTest --- ...dminOpenOrderCommentsHistoryActionGroup.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOpenOrderCommentsHistoryActionGroup.xml diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOpenOrderCommentsHistoryActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOpenOrderCommentsHistoryActionGroup.xml new file mode 100644 index 0000000000000..a33abcc03c31f --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOpenOrderCommentsHistoryActionGroup.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminOpenOrderCommentsHistoryActionGroup"> + <annotations> + <description>Clicks on the 'Comments History' on Admin View Order page.</description> + </annotations> + <click selector="{{AdminOrderDetailsOrderViewSection.commentsHistory}}" stepKey="clickOnTabCommentsHistory"/> + <waitForPageLoad stepKey="waitForComments"/> + </actionGroup> +</actionGroups> From 6cad7ae0064330ddb9ac01322b17f11d4e5ceb4b Mon Sep 17 00:00:00 2001 From: David Haecker <dhaecker@magento.com> Date: Thu, 19 Nov 2020 18:47:10 -0600 Subject: [PATCH 52/69] magento/partners-magento2b2b#370: [Determine Coverage]: Add Meaningful Titles and Descriptions For All MFTF Tests in the Company, CompanyCredit, CompanyPayment, CompanyShipping, & ConfigurableSharedCatalog Modules - Cleaning up StorefrontVerifyCompanyCreditStaticsForAnOrderWithOneRefundedProductTest - Cleaning up StorefrontVerifyCompanyCreditStaticsForAnOrderWithReimburseBalanceTest - Cleaning up StorefrontVerifyCreditAndCommentHistoryForCanceledOrderTest - Deprecating unused entities --- .../Test/Mftf/ActionGroup/SubmitCreditMemoActionGroup.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/SubmitCreditMemoActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/SubmitCreditMemoActionGroup.xml index 2605adbfc91a7..5e47f5fae2b93 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/SubmitCreditMemoActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/SubmitCreditMemoActionGroup.xml @@ -9,9 +9,12 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> <actionGroup name="SubmitCreditMemoActionGroup"> + <arguments> + <argument name="refundButton" defaultValue="{{AdminCreditMemoTotalSection.submitRefundOfflineEnabled}}" type="string"/> + </arguments> <grabFromCurrentUrl regex="~/order_id/(\d+)/~" stepKey="grabOrderId"/> - <waitForElementVisible selector="{{AdminCreditMemoTotalSection.submitRefundOfflineEnabled}}" stepKey="waitButtonEnabled"/> - <click selector="{{AdminCreditMemoTotalSection.submitRefundOfflineEnabled}}" stepKey="clickSubmitCreditMemo"/> + <waitForElementVisible selector="{{refundButton}}" stepKey="waitButtonEnabled"/> + <click selector="{{refundButton}}" stepKey="clickSubmitCreditMemo"/> <waitForElementVisible selector="{{AdminMessagesSection.success}}" stepKey="waitForMessageAppears"/> <see selector="{{AdminMessagesSection.success}}" userInput="You created the credit memo." stepKey="seeCreditMemoCreateSuccess"/> <seeInCurrentUrl url="{{AdminOrderDetailsPage.url}}$grabOrderId" stepKey="seeViewOrderPageCreditMemo"/> From b5d0c583cbf9568474c8bf2cc0c7fbc40d423d56 Mon Sep 17 00:00:00 2001 From: Serhii Balko <serhii.balko@transoftgroup.com> Date: Fri, 20 Nov 2020 14:24:22 +0200 Subject: [PATCH 53/69] MC-38925: [On Premise] - Admin resource availability and Access control related errors for SUB-ADMINISTRATORS --- app/code/Magento/Customer/ViewModel/Customer/Store.php | 7 ++++++- .../_files/second_website_with_store_group_and_store.php | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/ViewModel/Customer/Store.php b/app/code/Magento/Customer/ViewModel/Customer/Store.php index 1e6ca69e2d77a..1d6fa2b30912f 100644 --- a/app/code/Magento/Customer/ViewModel/Customer/Store.php +++ b/app/code/Magento/Customer/ViewModel/Customer/Store.php @@ -113,7 +113,12 @@ private function getStoreOptionsWithCurrentWebsiteId(): array if (!empty($this->dataPersistor->get('customer')['account'])) { $currentWebsiteId = (string)$this->dataPersistor->get('customer')['account']['website_id']; } else { - $currentWebsiteId = $this->storeManager->getDefaultStoreView()->getWebsiteId(); + $defaultStore = $this->storeManager->getDefaultStoreView(); + if (!$defaultStore) { + $stores = $this->storeManager->getStores(); + $defaultStore = array_shift($stores); + } + $currentWebsiteId = $defaultStore->getWebsiteId(); } foreach ($options as $key => $option) { diff --git a/dev/tests/integration/testsuite/Magento/Store/_files/second_website_with_store_group_and_store.php b/dev/tests/integration/testsuite/Magento/Store/_files/second_website_with_store_group_and_store.php index a4e2b05b1a28c..ee677b35176d6 100644 --- a/dev/tests/integration/testsuite/Magento/Store/_files/second_website_with_store_group_and_store.php +++ b/dev/tests/integration/testsuite/Magento/Store/_files/second_website_with_store_group_and_store.php @@ -56,5 +56,6 @@ $storeResource->save($store); /* Refresh CatalogSearch index */ /** @var IndexerRegistry $indexerRegistry */ +$storeManager->reinitStores(); $indexerRegistry = $objectManager->get(IndexerRegistry::class); $indexerRegistry->get(Fulltext::INDEXER_ID)->reindexAll(); From a9d515a66dca153b860dcc373c10068b179b7826 Mon Sep 17 00:00:00 2001 From: SmVladyslav <vlatame.tsg@gmail.com> Date: Fri, 20 Nov 2020 16:48:32 +0200 Subject: [PATCH 54/69] MC-23554: Customer custom multiline attribute displays incorrectly --- .../DataProviderWithDefaultAddresses.php | 20 +++++++++++++++++++ .../Model/Metadata/Form/Multiline.php | 2 +- .../Ui/Component/Form/Element/Multiline.php | 3 --- .../base/js/form/components/multiline.test.js | 6 ++++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Customer/Model/Customer/DataProviderWithDefaultAddresses.php b/app/code/Magento/Customer/Model/Customer/DataProviderWithDefaultAddresses.php index 604295cc0c078..ed84b0204e8ba 100644 --- a/app/code/Magento/Customer/Model/Customer/DataProviderWithDefaultAddresses.php +++ b/app/code/Magento/Customer/Model/Customer/DataProviderWithDefaultAddresses.php @@ -17,6 +17,7 @@ use Magento\Framework\Session\SessionManagerInterface; use Magento\Customer\Model\FileUploaderDataResolver; use Magento\Customer\Model\AttributeMetadataResolver; +use Magento\Ui\Component\Form\Element\Multiline; use Magento\Ui\DataProvider\AbstractDataProvider; /** @@ -130,6 +131,7 @@ public function getData(): array $result['customer'], array_flip(self::$forbiddenCustomerFields) ); + $this->prepareCustomAttributeValue($result['customer']); unset($result['address']); $result['default_billing_address'] = $this->prepareDefaultAddress( @@ -179,6 +181,24 @@ private function prepareDefaultAddress($address): array return $addressData; } + /*** + * Prepare values for Custom Attributes. + * + * @param array $data + * @return void + */ + private function prepareCustomAttributeValue(array &$data): void + { + foreach ($this->meta['customer']['children'] as $attributeName => $attributeMeta) { + if ($attributeMeta['arguments']['data']['config']['dataType'] === Multiline::NAME + && isset($data[$attributeName]) + && !is_array($data[$attributeName]) + ) { + $data[$attributeName] = explode("\n", $data[$attributeName]); + } + } + } + /** * Get attributes meta * diff --git a/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php b/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php index 20ad691b1c72e..c10052c631e58 100644 --- a/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php +++ b/app/code/Magento/Customer/Model/Metadata/Form/Multiline.php @@ -78,7 +78,7 @@ public function validateValue($value) public function compactValue($value) { if (is_array($value)) { - $value = implode("\n", $value); + $value = trim(implode("\n", $value)); } $value = [$value]; diff --git a/app/code/Magento/Ui/Component/Form/Element/Multiline.php b/app/code/Magento/Ui/Component/Form/Element/Multiline.php index 6ef206308125e..fc8e96638fc50 100644 --- a/app/code/Magento/Ui/Component/Form/Element/Multiline.php +++ b/app/code/Magento/Ui/Component/Form/Element/Multiline.php @@ -66,7 +66,6 @@ public function prepare() { $size = abs((int) $this->getData('config/size')); $validation = [$this->getData('config/validation')]; - $namespace = $this->getContext()->getNamespace(); while ($size--) { $identifier = $this->getName() . '_' . $size; $arguments = [ @@ -75,8 +74,6 @@ public function prepare() 'config' => [ 'dataScope' => $size, 'dataType' => static::DATA_TYPE, - 'deps' => "{$namespace}.areas.customer.customer.{$this->getName()}", - 'provider' => $namespace . '.' . $this->getContext()->getDataProvider()->getName(), 'formElement' => static::FORM_ELEMENT, 'sortOrder' => $size, ] diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/components/multiline.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/components/multiline.test.js index 7ecfb24c2deef..431d97605e318 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/components/multiline.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/components/multiline.test.js @@ -17,8 +17,10 @@ define([ registry.set(providerName, { /** Stub */ on: function () {}, + /** Stub */ set: function () {}, + /** Stub */ get: function () { return value; @@ -48,7 +50,7 @@ define([ }); it('Check preparation of string value with line breaks', function () { - var value = '\n222\n'; + var value = 'first\n\nthird'; prepareDataProvider(value); obj = new Constr({ @@ -56,7 +58,7 @@ define([ dataScope: dataScope }); - expect(obj.value()).toEqual(['', '222', '']); + expect(obj.value()).toEqual(['first', '', 'third']); }); }); }); From b459fcf50dc2a7fc43e3fd3715d23a6cf272ff23 Mon Sep 17 00:00:00 2001 From: David Haecker <dhaecker@magento.com> Date: Fri, 20 Nov 2020 13:28:28 -0600 Subject: [PATCH 55/69] magento/partners-magento2b2b#370: [Determine Coverage]: Add Meaningful Titles and Descriptions For All MFTF Tests in the Company, CompanyCredit, CompanyPayment, CompanyShipping, & ConfigurableSharedCatalog Modules - Fixing failing tests --- .../Sales/Test/Mftf/ActionGroup/AdminSubmitOrderActionGroup.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminSubmitOrderActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminSubmitOrderActionGroup.xml index f53e41386a389..3670839545e82 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminSubmitOrderActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminSubmitOrderActionGroup.xml @@ -9,6 +9,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> <actionGroup name="AdminSubmitOrderActionGroup"> + <scrollTo selector="{{OrdersGridSection.submitOrder}}" stepKey="scrollToSubmitButton"/> <click selector="{{OrdersGridSection.submitOrder}}" stepKey="submitOrder"/> <waitForPageLoad stepKey="waitForPageLoad"/> <see stepKey="seeSuccessMessageForOrder" userInput="You created the order."/> From f7850422bc010f23ffaed2f5e205b6b3e20cfff2 Mon Sep 17 00:00:00 2001 From: Stas Kozar <stas.kozar@transoftgroup.com> Date: Sat, 21 Nov 2020 04:49:18 +0200 Subject: [PATCH 56/69] MC-38807: Preview Template button does not work in Queue Edit Page --- dev/tests/js/jasmine/tests/lib/mage/tinymce4Adapter.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/js/jasmine/tests/lib/mage/tinymce4Adapter.test.js b/dev/tests/js/jasmine/tests/lib/mage/tinymce4Adapter.test.js index dee57ea3a0ad7..55eab905e8725 100644 --- a/dev/tests/js/jasmine/tests/lib/mage/tinymce4Adapter.test.js +++ b/dev/tests/js/jasmine/tests/lib/mage/tinymce4Adapter.test.js @@ -42,7 +42,7 @@ define([ describe('"triggerSave" method', function () { it('Check method call.', function () { - spyOn(tinyMCE4, 'triggerSave') + spyOn(tinyMCE4, 'triggerSave'); obj.triggerSave(); expect(tinyMCE4.triggerSave).toHaveBeenCalled(); }); From 2762f8fc839722abca1c41b985a7c4561ae9138d Mon Sep 17 00:00:00 2001 From: David Haecker <dhaecker@magento.com> Date: Sun, 22 Nov 2020 10:40:38 -0600 Subject: [PATCH 57/69] magento/partners-magento2b2b#370: [Determine Coverage]: Add Meaningful Titles and Descriptions For All MFTF Tests in the Company, CompanyCredit, CompanyPayment, CompanyShipping, & ConfigurableSharedCatalog Modules - Fixing failing/flaky tests --- ...oryToAnotherPositionInCategoryTreeTest.xml | 23 ++++++++++++------- ...gRecalculationAfterCouponCodeAddedTest.xml | 5 ++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryToAnotherPositionInCategoryTreeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryToAnotherPositionInCategoryTreeTest.xml index 654ddb4d8d872..8eb3d9bbb8063 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryToAnotherPositionInCategoryTreeTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryToAnotherPositionInCategoryTreeTest.xml @@ -38,23 +38,27 @@ <waitForPageLoad stepKey="waitForPageToLoad"/> <!-- Create three level deep sub Category --> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickAddSubCategoryButton"/> + <waitForPageLoad stepKey="waitForAddSubCategoryClick1"/> + <waitForElementVisible selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" stepKey="waitForSubCategoryName1"/> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{FirstLevelSubCat.name}}" stepKey="fillSubCategoryName"/> <actionGroup ref="AdminSaveCategoryActionGroup" stepKey="saveFirstLevelSubCategory"/> - <seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="seeSuccessMessage"/> + <waitForElementVisible selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="seeSuccessMessage"/> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButtonAgain"/> + <waitForPageLoad stepKey="waitForAddSubCategoryClick2"/> + <waitForElementVisible selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" stepKey="waitForSubCategoryName2"/> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{SecondLevelSubCat.name}}" stepKey="fillSecondLevelSubCategoryName"/> <actionGroup ref="AdminSaveCategoryActionGroup" stepKey="saveSecondLevelSubCategory"/> - <seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="seeSaveSuccessMessage"/> + <waitForElementVisible selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="seeSaveSuccessMessage"/> <grabFromCurrentUrl stepKey="categoryId" regex="#\/([0-9]*)?\/$#" /> <!-- Move Category to another position in category tree, but click cancel button --> <dragAndDrop selector1="{{AdminCategorySidebarTreeSection.categoryInTree(SecondLevelSubCat.name)}}" selector2="{{AdminCategorySidebarTreeSection.categoryInTree('Default Category')}}" stepKey="moveCategory"/> - <see selector="{{AdminCategoryModalSection.message}}" userInput="This operation can take a long time" stepKey="seeWarningMessage"/> + <waitForText selector="{{AdminCategoryModalSection.message}}" userInput="This operation can take a long time" stepKey="seeWarningMessage"/> <click selector="{{AdminCategoryModalSection.cancel}}" stepKey="clickCancelButtonOnWarningPopup"/> <!-- Verify Category in store front page after clicking cancel button --> <amOnPage url="/$$createDefaultCategory.name$$/{{FirstLevelSubCat.name}}/{{SecondLevelSubCat.name}}.html" stepKey="seeTheCategoryInStoreFrontPage"/> <waitForPageLoad stepKey="waitForStoreFrontPageLoad"/> - <seeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(_defaultCategory.name)}}" stepKey="seeDefaultCategoryOnStoreNavigationBar"/> + <waitForElementVisible selector="{{StorefrontHeaderSection.NavigationCategoryByName(_defaultCategory.name)}}" stepKey="seeDefaultCategoryOnStoreNavigationBar"/> <dontSeeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(SimpleSubCategory.name)}}" stepKey="dontSeeSubCategoryOnStoreNavigationBar"/> <!-- Verify breadcrumbs in store front page after clicking cancel button --> <grabMultiple selector="{{StorefrontNavigationSection.categoryBreadcrumbs}}" stepKey="breadcrumbs"/> @@ -67,17 +71,18 @@ <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openTheAdminCategoryIndexPage"/> <actionGroup ref="AdminExpandCategoryTreeActionGroup" stepKey="clickOnExpandTree"/> <dragAndDrop selector1="{{AdminCategorySidebarTreeSection.categoryInTree(SecondLevelSubCat.name)}}" selector2="{{AdminCategorySidebarTreeSection.categoryInTree('Default Category')}}" stepKey="DragCategory"/> - <see selector="{{AdminCategoryModalSection.message}}" userInput="This operation can take a long time" stepKey="seeWarningMessageForOneMoreTime"/> + <waitForText selector="{{AdminCategoryModalSection.message}}" userInput="This operation can take a long time" stepKey="seeWarningMessageForOneMoreTime"/> + <waitForElementVisible selector="{{AdminCategoryModalSection.ok}}" stepKey="waitForOkButtonOnWarningPopup"/> <click selector="{{AdminCategoryModalSection.ok}}" stepKey="clickOkButtonOnWarningPopup"/> <waitForPageLoad stepKey="waitTheForPageToLoad"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You moved the category." stepKey="seeSuccessMoveMessage"/> + <waitForText selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You moved the category." stepKey="seeSuccessMoveMessage"/> <amOnPage url="/{{SimpleSubCategory.name}}.html" stepKey="seeCategoryNameInStoreFrontPage"/> <waitForPageLoad stepKey="waitForStoreFrontPageToLoad"/> <!-- Verify Category in store front after moving category to another position in category tree --> <amOnPage url="{{StorefrontCategoryPage.url(SecondLevelSubCat.name)}}" stepKey="amOnCategoryPage"/> <waitForPageLoad stepKey="waitForPageToBeLoaded"/> - <seeElement selector="{{StorefrontCategoryMainSection.CategoryTitle(SecondLevelSubCat.name)}}" stepKey="seeCategoryInTitle"/> - <seeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(SecondLevelSubCat.name)}}" stepKey="seeCategoryOnStoreNavigationBarAfterMove"/> + <waitForElementVisible selector="{{StorefrontCategoryMainSection.CategoryTitle(SecondLevelSubCat.name)}}" stepKey="seeCategoryInTitle"/> + <waitForElementVisible selector="{{StorefrontHeaderSection.NavigationCategoryByName(SecondLevelSubCat.name)}}" stepKey="seeCategoryOnStoreNavigationBarAfterMove"/> <!-- Verify breadcrumbs in store front page after moving category to another position in category tree --> <click selector="{{StorefrontHeaderSection.NavigationCategoryByName(SecondLevelSubCat.name)}}" stepKey="clickCategoryOnNavigation"/> <waitForPageLoad stepKey="waitForCategoryLoad"/> @@ -91,6 +96,7 @@ <amOnPage url="{{AdminUrlRewriteIndexPage.url}}" stepKey="openUrlRewriteIndexPage"/> <waitForPageLoad stepKey="waitForUrlRewritePageLoad"/> <click selector="{{AdminDataGridHeaderSection.filters}}" stepKey="openUrlRewriteGridFilters"/> + <waitForElementVisible selector="{{AdminDataGridHeaderSection.filterFieldInput('request_path')}}" stepKey="waitForCategoryUrlKey"/> <fillField selector="{{AdminDataGridHeaderSection.filterFieldInput('request_path')}}" userInput="{{SecondLevelSubCat.name_lwr}}.html" stepKey="fillCategoryUrlKey"/> <click selector="{{AdminDataGridHeaderSection.applyFilters}}" stepKey="clickOrderApplyFilters"/> <waitForPageLoad stepKey="waitForSearch"/> @@ -102,6 +108,7 @@ <see selector="{{AdminUrlRewriteIndexSection.gridCellByColumnRowNumber('2', 'Redirect Type')}}" userInput="No" stepKey="verifyTheRedirectTypeAfterMove"/> <!-- Verify before move Redirect Path displayed with associated Target Path and Redirect Type--> <click selector="{{AdminDataGridHeaderSection.filters}}" stepKey="openUrlRewriteGridFilters1"/> + <waitForElementVisible selector="{{AdminDataGridHeaderSection.filterFieldInput('request_path')}}" stepKey="waitForTheCategoryUrlKey"/> <fillField selector="{{AdminDataGridHeaderSection.filterFieldInput('request_path')}}" userInput="{{SecondLevelSubCat.name_lwr}}" stepKey="fillTheCategoryUrlKey"/> <click selector="{{AdminDataGridHeaderSection.applyFilters}}" stepKey="clickOrderApplyFilters1"/> <waitForPageLoad stepKey="waitForSearch1"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontFreeShippingRecalculationAfterCouponCodeAddedTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontFreeShippingRecalculationAfterCouponCodeAddedTest.xml index 20b94d0f4ec8a..f31e8342ead23 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontFreeShippingRecalculationAfterCouponCodeAddedTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontFreeShippingRecalculationAfterCouponCodeAddedTest.xml @@ -87,8 +87,9 @@ <waitForPageLoad stepKey="waitForPageLoad"/> <see userInput="Your coupon was successfully applied." stepKey="seeSuccessMessage"/> <click selector="{{CheckoutPaymentSection.placeOrder}}" stepKey="clickPlaceOrder1"/> - <waitForPageLoad stepKey="waitForError"/> - <see stepKey="seeShippingMethodError" userInput="The shipping method is missing. Select the shipping method and try again."/> + <!-- Cannot use waitForPageLoad as the below error message will disappear after a few seconds & waitForPageLoad will cause this test to be flaky --> + <comment userInput="BIC workaround" stepKey="waitForError"/> + <waitForText stepKey="seeShippingMethodError" userInput="The shipping method is missing. Select the shipping method and try again."/> <amOnPage stepKey="navigateToShippingPage" url="{{CheckoutShippingPage.url}}"/> <waitForPageLoad stepKey="waitForShippingPageLoad"/> <click stepKey="chooseFlatRateShipping" selector="{{CheckoutShippingMethodsSection.shippingMethodRowByName('Flat Rate')}}"/> From a75033bc9eb749d274338b928e834fbb98ba6b7d Mon Sep 17 00:00:00 2001 From: "rostyslav.hymon" <rostyslav.hymon@transoftgroup.com> Date: Mon, 23 Nov 2020 12:02:54 +0200 Subject: [PATCH 58/69] MC-39109: Vault throw The requested Payment Method is not available. error --- .../PaymentVaultInformationManagement.php | 68 +++++++++++++++++++ app/code/Magento/Vault/etc/di.xml | 4 ++ 2 files changed, 72 insertions(+) create mode 100644 app/code/Magento/Vault/Plugin/PaymentVaultInformationManagement.php diff --git a/app/code/Magento/Vault/Plugin/PaymentVaultInformationManagement.php b/app/code/Magento/Vault/Plugin/PaymentVaultInformationManagement.php new file mode 100644 index 0000000000000..f8bb3a68cdfcb --- /dev/null +++ b/app/code/Magento/Vault/Plugin/PaymentVaultInformationManagement.php @@ -0,0 +1,68 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Vault\Plugin; + +use Magento\Checkout\Api\PaymentInformationManagementInterface; +use Magento\Quote\Api\Data\AddressInterface; +use Magento\Quote\Api\Data\PaymentInterface; +use Magento\Vault\Model\PaymentMethodList; +use Magento\Store\Model\StoreManagerInterface; + +/** + * Payment vault information management process + */ +class PaymentVaultInformationManagement +{ + /** + * @var PaymentMethodList + */ + private $vaultPaymentMethodList; + + /** + * @var StoreManagerInterface + */ + private $storeManager; + + /** + * PaymentVaultInformationManagement constructor. + * + * @param PaymentMethodList $vaultPaymentMethodList + * @param StoreManagerInterface $storeManager + */ + public function __construct( + PaymentMethodList $vaultPaymentMethodList, + StoreManagerInterface $storeManager + ) { + $this->vaultPaymentMethodList = $vaultPaymentMethodList; + $this->storeManager = $storeManager; + } + + /** + * Set available vault method code without index to payment + * + * @param PaymentInformationManagementInterface $subject + * @param string $cartId + * @param PaymentInterface $paymentMethod + * @param AddressInterface|null $billingAddress + * @return void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function beforeSavePaymentInformation( + PaymentInformationManagementInterface $subject, + string $cartId, + PaymentInterface $paymentMethod, + AddressInterface $billingAddress = null + ): void { + $availableMethods = $this->vaultPaymentMethodList->getActiveList($this->storeManager->getStore()->getId()); + foreach ($availableMethods as $availableMethod) { + if (strpos($paymentMethod->getMethod(), $availableMethod->getCode()) !== false) { + $paymentMethod->setMethod($availableMethod->getCode()); + } + } + } +} diff --git a/app/code/Magento/Vault/etc/di.xml b/app/code/Magento/Vault/etc/di.xml index 0192a783bd5a8..e02aa9277258c 100644 --- a/app/code/Magento/Vault/etc/di.xml +++ b/app/code/Magento/Vault/etc/di.xml @@ -53,4 +53,8 @@ </argument> </arguments> </type> + <type name="Magento\Checkout\Api\PaymentInformationManagementInterface"> + <plugin name="ProcessPaymentVaultInformationManagement" + type="Magento\Vault\Plugin\PaymentVaultInformationManagement"/> + </type> </config> From 60c0dbb54976bbb3784540afe45507f5eed5fe9f Mon Sep 17 00:00:00 2001 From: "rostyslav.hymon" <rostyslav.hymon@transoftgroup.com> Date: Mon, 23 Nov 2020 14:25:33 +0200 Subject: [PATCH 59/69] MC-39109: Vault throw The requested Payment Method is not available. error --- .../PaymentVaultInformationManagement.php | 8 +- .../PaymentVaultInformationManagementTest.php | 130 ++++++++++++++++++ 2 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 app/code/Magento/Vault/Test/Unit/Plugin/PaymentVaultInformationManagementTest.php diff --git a/app/code/Magento/Vault/Plugin/PaymentVaultInformationManagement.php b/app/code/Magento/Vault/Plugin/PaymentVaultInformationManagement.php index f8bb3a68cdfcb..0d0a7fdfbd0e0 100644 --- a/app/code/Magento/Vault/Plugin/PaymentVaultInformationManagement.php +++ b/app/code/Magento/Vault/Plugin/PaymentVaultInformationManagement.php @@ -10,7 +10,7 @@ use Magento\Checkout\Api\PaymentInformationManagementInterface; use Magento\Quote\Api\Data\AddressInterface; use Magento\Quote\Api\Data\PaymentInterface; -use Magento\Vault\Model\PaymentMethodList; +use Magento\Vault\Api\PaymentMethodListInterface; use Magento\Store\Model\StoreManagerInterface; /** @@ -19,7 +19,7 @@ class PaymentVaultInformationManagement { /** - * @var PaymentMethodList + * @var PaymentMethodListInterface */ private $vaultPaymentMethodList; @@ -31,11 +31,11 @@ class PaymentVaultInformationManagement /** * PaymentVaultInformationManagement constructor. * - * @param PaymentMethodList $vaultPaymentMethodList + * @param PaymentMethodListInterface $vaultPaymentMethodList * @param StoreManagerInterface $storeManager */ public function __construct( - PaymentMethodList $vaultPaymentMethodList, + PaymentMethodListInterface $vaultPaymentMethodList, StoreManagerInterface $storeManager ) { $this->vaultPaymentMethodList = $vaultPaymentMethodList; diff --git a/app/code/Magento/Vault/Test/Unit/Plugin/PaymentVaultInformationManagementTest.php b/app/code/Magento/Vault/Test/Unit/Plugin/PaymentVaultInformationManagementTest.php new file mode 100644 index 0000000000000..3fd75f9ba6284 --- /dev/null +++ b/app/code/Magento/Vault/Test/Unit/Plugin/PaymentVaultInformationManagementTest.php @@ -0,0 +1,130 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Vault\Test\Unit\Plugin; + +use Magento\Checkout\Api\PaymentInformationManagementInterface; +use Magento\Store\Api\Data\StoreInterface; +use Magento\Store\Model\StoreManagerInterface; +use Magento\Vault\Api\PaymentMethodListInterface; +use Magento\Vault\Plugin\PaymentVaultInformationManagement; +use Magento\Quote\Api\Data\PaymentInterface; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; + +/** + * Test for payment vault information management plugin + */ +class PaymentVaultInformationManagementTest extends TestCase +{ + /** + * @var StoreManagerInterface|MockObject + */ + private $storeManager; + + /** + * @var StoreInterface|MockObject + */ + private $store; + + /** + * @var PaymentMethodListInterface|MockObject + */ + private $paymentMethodList; + + /** + * @var PaymentVaultInformationManagement + */ + private $plugin; + + /** + * @var PaymentInformationManagementInterface|MockObject + */ + private $paymentInformationManagement; + + /** + * @var PaymentInterface|MockObject + */ + private $payment; + + /** + * @inheritDoc + */ + protected function setUp(): void + { + $this->storeManager = $this->getMockBuilder(StoreManagerInterface::class) + ->disableOriginalConstructor() + ->onlyMethods(['getStore']) + ->getMockForAbstractClass(); + $this->store = $this->getMockBuilder(StoreInterface::class) + ->disableOriginalConstructor() + ->onlyMethods(['getId']) + ->getMockForAbstractClass(); + $this->paymentMethodList = $this->getMockBuilder(PaymentMethodListInterface::class) + ->disableOriginalConstructor() + ->onlyMethods(['getActiveList']) + ->getMockForAbstractClass(); + $this->paymentInformationManagement = $this + ->getMockBuilder(PaymentInformationManagementInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->payment = $this->getMockBuilder(PaymentInterface::class) + ->onlyMethods(['setMethod']) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->plugin = new PaymentVaultInformationManagement($this->paymentMethodList, $this->storeManager); + } + + /** + * Test payment method for vault before saving payment information + * + * @param string $requestPaymentMethodCode + * @param string $methodCode + * @dataProvider vaultPaymentMethodDataProvider + * + * @return void + */ + public function testBeforeSavePaymentInformation($requestPaymentMethodCode, $methodCode): void + { + $this->store->method('getId') + ->willReturn(1); + $this->storeManager->method('getStore') + ->willReturn($this->store); + $activeVaultMethod = $this->getMockBuilder(PaymentInterface::class) + ->disableOriginalConstructor() + ->addMethods(['getCode', 'getProviderCode']) + ->getMockForAbstractClass(); + $activeVaultMethod->method('getCode') + ->willReturn($methodCode); + $this->paymentMethodList->method('getActiveList') + ->willReturn([$activeVaultMethod]); + $this->payment->method('getMethod') + ->willReturn($requestPaymentMethodCode); + $this->payment->expects($this->once()) + ->method('setMethod') + ->with($methodCode); + + $this->plugin->beforeSavePaymentInformation( + $this->paymentInformationManagement, + '1', + $this->payment, + null + ); + } + + /** + * Data provider for BeforeSavePaymentInformation. + * + * @return array + */ + public function vaultPaymentMethodDataProvider(): array + { + return [ + ['braintree_cc_vault_01', 'braintree_cc_vault'], + ]; + } +} From 7ed4a6c952ec1d3ec86623e9578f42961895a6e2 Mon Sep 17 00:00:00 2001 From: Viktor Petryk <victor.petryk@transoftgroup.com> Date: Mon, 23 Nov 2020 18:55:24 +0200 Subject: [PATCH 60/69] MC-35194: [Cloud] Some fields of UPS Delivery Method are disabled --- app/code/Magento/Ups/etc/adminhtml/system.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/app/code/Magento/Ups/etc/adminhtml/system.xml b/app/code/Magento/Ups/etc/adminhtml/system.xml index 3a1676d221977..6890e1bdaf870 100644 --- a/app/code/Magento/Ups/etc/adminhtml/system.xml +++ b/app/code/Magento/Ups/etc/adminhtml/system.xml @@ -13,9 +13,6 @@ <field id="access_license_number" translate="label" type="obscure" sortOrder="30" showInDefault="1" showInWebsite="1"> <label>Access License Number</label> <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model> - <depends> - <field id="carriers/ups/active">1</field> - </depends> </field> <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" canRestore="1"> <label>Enabled for Checkout</label> @@ -89,9 +86,6 @@ <field id="password" translate="label" type="obscure" sortOrder="30" showInDefault="1" showInWebsite="1"> <label>Password</label> <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model> - <depends> - <field id="carriers/ups/active">1</field> - </depends> </field> <field id="pickup" translate="label" type="select" sortOrder="80" showInDefault="1" showInWebsite="1" canRestore="1"> <label>Pickup Method</label> @@ -123,9 +117,6 @@ <field id="username" translate="label" type="obscure" sortOrder="30" showInDefault="1" showInWebsite="1"> <label>User ID</label> <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model> - <depends> - <field id="carriers/ups/active">1</field> - </depends> </field> <field id="negotiated_active" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" canRestore="1"> <label>Enable Negotiated Rates</label> From 5c25bb12f173c56945f1f5ce93d7cca6ada26e2a Mon Sep 17 00:00:00 2001 From: Viktor Petryk <victor.petryk@transoftgroup.com> Date: Tue, 24 Nov 2020 10:54:59 +0200 Subject: [PATCH 61/69] MC-35194: [Cloud] Some fields of UPS Delivery Method are disabled --- .../system/shipping/carrier_config.phtml | 51 ++++++++++++------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/app/code/Magento/Ups/view/adminhtml/templates/system/shipping/carrier_config.phtml b/app/code/Magento/Ups/view/adminhtml/templates/system/shipping/carrier_config.phtml index f068b0cf0079f..b6b7040a41bca 100644 --- a/app/code/Magento/Ups/view/adminhtml/templates/system/shipping/carrier_config.phtml +++ b/app/code/Magento/Ups/view/adminhtml/templates/system/shipping/carrier_config.phtml @@ -4,10 +4,17 @@ * See COPYING.txt for license details. */ -/** @var $upsModel \Magento\Ups\Helper\Config */ -/** @var $block \Magento\Ups\Block\Backend\System\CarrierConfig */ -/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */ +use Magento\Framework\Escaper; +use Magento\Framework\Json\Helper\Data; +use Magento\Framework\View\Helper\SecureHtmlRenderer; +use Magento\Store\Model\Website; +use Magento\Ups\Block\Backend\System\CarrierConfig; +/** + * @var CarrierConfig $block + * @var Escaper $escaper + * @var SecureHtmlRenderer $secureRenderer + */ $upsCarrierConfig = $block->getCarrierConfig(); $orShipArr = $upsCarrierConfig->getCode('originShipment'); $defShipArr = $upsCarrierConfig->getCode('method'); @@ -15,26 +22,26 @@ $defShipArr = $upsCarrierConfig->getCode('method'); $sectionCode = $block->getRequest()->getParam('section'); $websiteCode = $block->getRequest()->getParam('website'); $storeCode = $block->getRequest()->getParam('store'); -/** @var \Magento\Framework\Json\Helper\Data $jsonHelper */ +/** @var Data $jsonHelper */ $jsonHelper = $block->getData('jsonHelper'); if (!$storeCode && $websiteCode) { - /** @var $web \Magento\Store\Model\Website */ + /** @var Website $web */ $web = $block->getWebsiteModel()->load($websiteCode); $storedAllowedMethods = explode(',', $web->getConfig('carriers/ups/allowed_methods')); - $storedOriginShipment = $block->escapeHtml($web->getConfig('carriers/ups/origin_shipment')); - $storedFreeShipment = $block->escapeHtml($web->getConfig('carriers/ups/free_method')); - $storedUpsType = $block->escapeHtml($web->getConfig('carriers/ups/type')); + $storedOriginShipment = $escaper->escapeHtml($web->getConfig('carriers/ups/origin_shipment')); + $storedFreeShipment = $escaper->escapeHtml($web->getConfig('carriers/ups/free_method')); + $storedUpsType = $escaper->escapeHtml($web->getConfig('carriers/ups/type')); } elseif ($storeCode) { $storedAllowedMethods = explode(',', $block->getConfig('carriers/ups/allowed_methods', $storeCode)); - $storedOriginShipment = $block->escapeHtml($block->getConfig('carriers/ups/origin_shipment', $storeCode)); - $storedFreeShipment = $block->escapeHtml($block->getConfig('carriers/ups/free_method', $storeCode)); - $storedUpsType = $block->escapeHtml($block->getConfig('carriers/ups/type', $storeCode)); + $storedOriginShipment = $escaper->escapeHtml($block->getConfig('carriers/ups/origin_shipment', $storeCode)); + $storedFreeShipment = $escaper->escapeHtml($block->getConfig('carriers/ups/free_method', $storeCode)); + $storedUpsType = $escaper->escapeHtml($block->getConfig('carriers/ups/type', $storeCode)); } else { $storedAllowedMethods = explode(',', $block->getConfig('carriers/ups/allowed_methods')); - $storedOriginShipment = $block->escapeHtml($block->getConfig('carriers/ups/origin_shipment')); - $storedFreeShipment = $block->escapeHtml($block->getConfig('carriers/ups/free_method')); - $storedUpsType = $block->escapeHtml($block->getConfig('carriers/ups/type')); + $storedOriginShipment = $escaper->escapeHtml($block->getConfig('carriers/ups/origin_shipment')); + $storedFreeShipment = $escaper->escapeHtml($block->getConfig('carriers/ups/free_method')); + $storedUpsType = $escaper->escapeHtml($block->getConfig('carriers/ups/type')); } ?> @@ -87,14 +94,16 @@ require(["prototype"], function(){ 'carriers_ups_origin_shipment','carriers_ups_negotiated_active','carriers_ups_shipper_number', 'carriers_ups_mode_xml','carriers_ups_include_taxes']; this.onlyUpsElements = ['carriers_ups_gateway_url']; + this.authUpsXmlElements = ['carriers_ups_username', + 'carriers_ups_password','carriers_ups_access_license_number']; script; $scriptString .= 'this.storedOriginShipment = \'' . /* @noEscape */ $storedOriginShipment . '\'; this.storedFreeShipment = \'' . /* @noEscape */ $storedFreeShipment . '\'; - this.storedUpsType = \'' . /* @noEscape */ $storedUpsType . '\';'; + this.storedUpsType = \'' . /* @noEscape */ $storedUpsType . '\';'; ?> -<?php $scriptString .= 'this.storedAllowedMethods = ' . /* @noEscape */ $jsonHelper->jsonEncode($storedAllowedMethods) . - '; +<?php $scriptString .= 'this.storedAllowedMethods = ' + . /* @noEscape */ $jsonHelper->jsonEncode($storedAllowedMethods) . '; this.originShipmentObj = ' . /* @noEscape */ $jsonHelper->jsonEncode($orShipArr) . '; this.originShipmentObj[\'default\'] = ' . /* @noEscape */ $jsonHelper->jsonEncode($defShipArr) . ';'; @@ -119,8 +128,9 @@ $scriptString .= <<<script script; -$scriptString .= 'freeMethod.insert(new Element(\'option\', {value:\'\'}).update(\'' . $block->escapeHtml(__('None')) . - '\'));'; +$scriptString .= 'freeMethod.insert(new Element(\'option\', {value:\'\'}).update(\'' + . $escaper->escapeHtml(__('None')) + . '\'));'; $scriptString .= <<<script var code, option; @@ -178,6 +188,9 @@ $scriptString .= <<<script } Event.observe($('carriers_ups_origin_shipment'), 'change', this.changeOriginShipment.bind(this)); showRowArrayElements(this.onlyUpsXmlElements); + if (\$F(this.carriersUpsActiveId) !== '1'){ + hideRowArrayElements(this.authUpsXmlElements); + } hideRowArrayElements(this.onlyUpsElements); this.changeOriginShipment(null, null); } From f1e5c457c922aad8f6b0d439a696c61d6dc018cc Mon Sep 17 00:00:00 2001 From: OlgaVasyltsun <olga.vasyltsun@transoftgroup.com> Date: Tue, 24 Nov 2020 11:32:42 +0200 Subject: [PATCH 62/69] MC-39096: Widget parameter depends does not work correctly on specified block --- lib/web/mage/adminhtml/form.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/web/mage/adminhtml/form.js b/lib/web/mage/adminhtml/form.js index 054594ff9e9f2..20ca1d505bb21 100644 --- a/lib/web/mage/adminhtml/form.js +++ b/lib/web/mage/adminhtml/form.js @@ -465,7 +465,7 @@ define([ // define whether the target should show up var shouldShowUp = true, idFrom, from, values, isInArray, isNegative, headElement, isInheritCheckboxChecked, target, inputs, - isAnInputOrSelect, currentConfig, rowElement, fromId, radioFrom; + isAnInputOrSelect, currentConfig, rowElement, fromId, radioFrom, targetArray, isChooser; for (idFrom in valuesFrom) { //eslint-disable-line guard-for-in from = $(idFrom); @@ -502,6 +502,12 @@ define([ // Account for the chooser style parameters. if (target === null && headElement.length === 0 && idTo.substring(0, 16) === 'options_fieldset') { + targetArray = $$('input[id*="' + idTo + '"]'); + isChooser = true; + + if (targetArray !== null && targetArray.length > 0) { + target = targetArray[0]; + } headElement = jQuery('.field-' + idTo).add('.field-chooser' + idTo); } @@ -526,7 +532,7 @@ define([ // don't touch hidden inputs (and Use Default inputs too), bc they may have custom logic if ((!item.type || item.type != 'hidden') && !($(item.id + '_inherit') && $(item.id + '_inherit').checked) && //eslint-disable-line !(currentConfig['can_edit_price'] != undefined && !currentConfig['can_edit_price']) && //eslint-disable-line - !item.getAttribute('readonly') //eslint-disable-line + !item.getAttribute('readonly') || isChooser //eslint-disable-line ) { item.disabled = false; jQuery(item).removeClass('ignore-validate'); From 738c50780bcf2931a612efcbe914eb1bd1cf3535 Mon Sep 17 00:00:00 2001 From: Serhii Balko <serhii.balko@transoftgroup.com> Date: Tue, 24 Nov 2020 13:11:40 +0200 Subject: [PATCH 63/69] MC-39135: Invoices do not send automatically while creating order from admin --- .../Sales/Model/AdminOrder/EmailSender.php | 41 +++++++++-- .../Unit/Model/AdminOrder/EmailSenderTest.php | 73 ++++++++++++++----- 2 files changed, 91 insertions(+), 23 deletions(-) diff --git a/app/code/Magento/Sales/Model/AdminOrder/EmailSender.php b/app/code/Magento/Sales/Model/AdminOrder/EmailSender.php index 4e068eb571deb..2e9518600c27f 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/EmailSender.php +++ b/app/code/Magento/Sales/Model/AdminOrder/EmailSender.php @@ -5,10 +5,13 @@ */ namespace Magento\Sales\Model\AdminOrder; -use Psr\Log\LoggerInterface as Logger; +use Magento\Framework\Exception\MailException; use Magento\Framework\Message\ManagerInterface; use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Email\Sender\InvoiceSender; use Magento\Sales\Model\Order\Email\Sender\OrderSender; +use Magento\Sales\Model\Order\Invoice; +use Psr\Log\LoggerInterface as Logger; /** * Class EmailSender @@ -30,21 +33,31 @@ class EmailSender */ protected $orderSender; + /** + * @var InvoiceSender + */ + private $invoiceSender; + /** * @param ManagerInterface $messageManager * @param Logger $logger * @param OrderSender $orderSender + * @param InvoiceSender $invoiceSender */ - public function __construct(ManagerInterface $messageManager, Logger $logger, OrderSender $orderSender) - { + public function __construct( + ManagerInterface $messageManager, + Logger $logger, + OrderSender $orderSender, + InvoiceSender $invoiceSender + ) { $this->messageManager = $messageManager; $this->logger = $logger; $this->orderSender = $orderSender; + $this->invoiceSender = $invoiceSender; } /** - * Send email about new order. - * Process mail exception + * Send email about new order and handle mail exception * * @param Order $order * @return bool @@ -53,7 +66,8 @@ public function send(Order $order) { try { $this->orderSender->send($order); - } catch (\Magento\Framework\Exception\MailException $exception) { + $this->sendInvoiceEmail($order); + } catch (MailException $exception) { $this->logger->critical($exception); $this->messageManager->addWarningMessage( __('You did not email your customer. Please check your email settings.') @@ -63,4 +77,19 @@ public function send(Order $order) return true; } + + /** + * Send email about invoice paying + * + * @param Order $order + */ + private function sendInvoiceEmail(Order $order): void + { + foreach ($order->getInvoiceCollection()->getItems() as $invoice) { + /** @var Invoice $invoice */ + if ($invoice->getState() === Invoice::STATE_PAID) { + $this->invoiceSender->send($invoice); + } + } + } } diff --git a/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/EmailSenderTest.php b/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/EmailSenderTest.php index 0e80ab7825748..584ce502c5efd 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/EmailSenderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/AdminOrder/EmailSenderTest.php @@ -11,59 +11,81 @@ use Magento\Framework\Message\Manager; use Magento\Sales\Model\AdminOrder\EmailSender; use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Email\Sender\InvoiceSender; use Magento\Sales\Model\Order\Email\Sender\OrderSender; +use Magento\Sales\Model\Order\Invoice; +use Magento\Sales\Model\ResourceModel\Order\Invoice\Collection as InvoiceCollection; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; +/** + * Tests to sent order emails + */ class EmailSenderTest extends TestCase { /** - * @var MockObject + * @var LoggerInterface|MockObject */ - protected $orderMock; + private $loggerMock; /** - * @var MockObject + * @var Manager|MockObject */ - protected $loggerMock; + private $messageManagerMock; /** - * @var MockObject + * @var OrderSender|MockObject */ - protected $messageManagerMock; + private $orderSenderMock; /** - * @var EmailSender + * @var InvoiceSender|MockObject */ - protected $emailSender; + private $invoiceSenderMock; /** - * @var OrderSender + * @var EmailSender */ - protected $orderSenderMock; + private $emailSender; /** - * Test setup + * @inheritdoc */ protected function setUp(): void { $this->messageManagerMock = $this->createMock(Manager::class); $this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class); - $this->orderMock = $this->createMock(Order::class); $this->orderSenderMock = $this->createMock(OrderSender::class); + $this->invoiceSenderMock = $this->createMock(InvoiceSender::class); - $this->emailSender = new EmailSender($this->messageManagerMock, $this->loggerMock, $this->orderSenderMock); + $this->emailSender = new EmailSender( + $this->messageManagerMock, + $this->loggerMock, + $this->orderSenderMock, + $this->invoiceSenderMock + ); } /** - * testSendSuccess + * Test to send order emails */ public function testSendSuccess() { + $invoicePaid = $this->createMock(Invoice::class); + $invoicePaid->method('getState')->willReturn(Invoice::STATE_PAID); + $invoiceOpen = $this->createMock(Invoice::class); + $invoiceOpen->method('getState')->willReturn(Invoice::STATE_OPEN); + $order = $this->createOrderMock([$invoiceOpen, $invoicePaid]); + $this->orderSenderMock->expects($this->once()) - ->method('send'); - $this->assertTrue($this->emailSender->send($this->orderMock)); + ->method('send') + ->with($order); + $this->invoiceSenderMock->expects($this->once()) + ->method('send') + ->with($invoicePaid); + + $this->assertTrue($this->emailSender->send($order)); } /** @@ -71,6 +93,7 @@ public function testSendSuccess() */ public function testSendFailure() { + $orderMock = $this->createOrderMock(); $this->orderSenderMock->expects($this->once()) ->method('send') ->willThrowException(new MailException(__('test message'))); @@ -79,6 +102,22 @@ public function testSendFailure() $this->loggerMock->expects($this->once()) ->method('critical'); - $this->assertFalse($this->emailSender->send($this->orderMock)); + $this->assertFalse($this->emailSender->send($orderMock)); + } + + /** + * Create order mock + * + * @param array $invoiceCollection + * @return MockObject|Order + */ + private function createOrderMock(array $invoiceCollection = []): MockObject + { + $collection = $this->createMock(InvoiceCollection::class); + $collection->method('getItems')->willReturn($invoiceCollection); + $order = $this->createMock(Order::class); + $order->method('getInvoiceCollection')->willReturn($collection); + + return $order; } } From 4538ad04f8d1679c4501a2c02e8adb781ce23778 Mon Sep 17 00:00:00 2001 From: Dan Mooney <dmooney@adobe.com> Date: Tue, 24 Nov 2020 11:13:55 -0600 Subject: [PATCH 64/69] MC-39333: Grids Frequently Fail to Load & Throw getData Undefined Error in Console - Add Magento_Ui/js/grid/data-storage as a dependency to base grid provider component --- app/code/Magento/Ui/view/base/web/js/grid/provider.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Ui/view/base/web/js/grid/provider.js b/app/code/Magento/Ui/view/base/web/js/grid/provider.js index 2ba8bd73af910..021ae83eb1c7d 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/provider.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/provider.js @@ -14,7 +14,8 @@ define([ 'uiLayout', 'Magento_Ui/js/modal/alert', 'mage/translate', - 'uiElement' + 'uiElement', + 'Magento_Ui/js/grid/data-storage' ], function ($, _, utils, resolver, layout, alert, $t, Element) { 'use strict'; From f60c89cec4b21a2884692dc748722de5cdb8fb53 Mon Sep 17 00:00:00 2001 From: David Haecker <dhaecker@magento.com> Date: Tue, 24 Nov 2020 16:54:16 -0600 Subject: [PATCH 65/69] magento/partners-magento2b2b#370: [Determine Coverage]: Add Meaningful Titles and Descriptions For All MFTF Tests in the Company, CompanyCredit, CompanyPayment, CompanyShipping, & ConfigurableSharedCatalog Modules - Fixing PR feedback - Adding equals checks to company credit actiongroups --- .../StorefrontOpenCheckoutPageInCustomStoreActionGroup.xml | 2 +- .../StorefrontCustomStoreCustomerLogoutActionGroup.xml | 2 +- .../Mftf/ActionGroup/StorefrontCustomStoreLoginActionGroup.xml | 2 +- ...ustomStoreNavigateToCustomerOrdersHistoryPageActionGroup.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCheckoutPageInCustomStoreActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCheckoutPageInCustomStoreActionGroup.xml index 11102702454e8..3a9ffade0a8a2 100644 --- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCheckoutPageInCustomStoreActionGroup.xml +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCheckoutPageInCustomStoreActionGroup.xml @@ -13,7 +13,7 @@ <description>Goes to the Storefront Checkout page in a custom store. Must have Add Store Code To Urls enabled</description> </annotations> <arguments> - <argument name="storeCode"/> + <argument name="storeCode" defaultValue="{{customStoreEN.code}}" type="string"/> </arguments> <amOnPage url="{{StorefrontCustomStoreCheckoutPage.url(storeCode)}}" stepKey="openCheckoutPage"/> </actionGroup> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreCustomerLogoutActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreCustomerLogoutActionGroup.xml index ff1f29adf925d..d7e25553da083 100644 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreCustomerLogoutActionGroup.xml +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreCustomerLogoutActionGroup.xml @@ -13,7 +13,7 @@ <description>Goes to the storefront Customer Logout page for a custom store. Must have Add Store Code To Urls enabled.</description> </annotations> <arguments> - <argument name="storeCode"/> + <argument name="storeCode" defaultValue="{{customStoreEN.code}}" type="string"/> </arguments> <amOnPage url="{{StorefrontCustomStoreCustomerLogoutPage.url(storeCode)}}" stepKey="storefrontSignOut"/> </actionGroup> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreLoginActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreLoginActionGroup.xml index ff3f9658cd303..41a6abba1ff2b 100644 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreLoginActionGroup.xml +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreLoginActionGroup.xml @@ -13,7 +13,7 @@ <description>Goes to the storefront Customer Sign In page for a custom store. Logs in using the provided Customer. Must have Add Store Code To Urls enabled</description> </annotations> <arguments> - <argument name="storeCode"/> + <argument name="storeCode" defaultValue="{{customStoreEN.code}}" type="string"/> </arguments> <amOnPage url="{{StorefrontCustomStoreCustomerSignInPage.url(storeCode)}}" stepKey="amOnSignInPage"/> </actionGroup> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreNavigateToCustomerOrdersHistoryPageActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreNavigateToCustomerOrdersHistoryPageActionGroup.xml index 827128db663f7..399b684ba8974 100644 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreNavigateToCustomerOrdersHistoryPageActionGroup.xml +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomStoreNavigateToCustomerOrdersHistoryPageActionGroup.xml @@ -12,7 +12,7 @@ <description>Goes to the storefront Customer Order History page for a custom store. Must have Add Store Code To Urls enabled</description> </annotations> <arguments> - <argument name="storeCode"/> + <argument name="storeCode" defaultValue="{{customStoreEN.code}}" type="string"/> </arguments> <amOnPage url="{{StorefrontCustomStoreCustomerOrdersHistoryPage.url(storeCode)}}" stepKey="amOnTheCustomerPage"/> </actionGroup> From d32287b730c0fd0923c849572d04609a4d9a11c7 Mon Sep 17 00:00:00 2001 From: David Haecker <dhaecker@magento.com> Date: Wed, 25 Nov 2020 13:04:05 -0600 Subject: [PATCH 66/69] magento/partners-magento2b2b#370: [Determine Coverage]: Add Meaningful Titles and Descriptions For All MFTF Tests in the Company, CompanyCredit, CompanyPayment, CompanyShipping, & ConfigurableSharedCatalog Modules - Moving B2B elements from CE to B2B --- .../Mftf/Section/StorefrontCheckoutPaymentMethodSection.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontCheckoutPaymentMethodSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontCheckoutPaymentMethodSection.xml index 40214b9c11fb0..dae6bfca9757d 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontCheckoutPaymentMethodSection.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontCheckoutPaymentMethodSection.xml @@ -13,8 +13,8 @@ <element name="checkPaymentMethodByName" type="radio" selector="//div[@id='checkout-payment-method-load']//div[@class='payment-method']//label//span[contains(., '{{methodName}}')]/../..//input" parameterized="true"/> <element name="billingAddressSameAsShipping" type="checkbox" selector=".payment-method._active [name='billing-address-same-as-shipping']"/> <element name="billingAddressSameAsShippingShared" type="checkbox" selector="#billing-address-same-as-shipping-shared"/> - <element name="paymentOnAccount" type="radio" selector="#companycredit"/> - <element name="paymentOnAccountLabel" type="text" selector="//span[text()='Payment on Account']"/> + <element name="paymentOnAccount" type="radio" selector="#companycredit" deprecated="Use StorefrontCheckoutPaymentSection.paymentOnAccount B2B repository"/> + <element name="paymentOnAccountLabel" type="text" selector="//span[text()='Payment on Account']" deprecated="Use StorefrontCheckoutPaymentSection.paymentOnAccountLabel in B2B repository"/> <element name="purchaseOrderNumber" type="input" selector="#po_number"/> </section> </sections> From 94135ea82375304d1f2eeab27fbd9db339ff9f6f Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi <vtymchynskyi@magento.com> Date: Thu, 26 Nov 2020 11:59:38 -0600 Subject: [PATCH 67/69] MC-39442: Doubling the amount in PayPal express - Removed redundant api call --- .../frontend/web/js/action/set-payment-information-extended.js | 2 +- .../view/payment/method-renderer/in-context/checkout-express.js | 1 - .../frontend/js/action/set-payment-information-extended.test.js | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/action/set-payment-information-extended.js b/app/code/Magento/Checkout/view/frontend/web/js/action/set-payment-information-extended.js index ae5b0914e83a6..43c8c5a3a4fe8 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/action/set-payment-information-extended.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/action/set-payment-information-extended.js @@ -30,7 +30,7 @@ define([ list[key] = filterTemplateData(value); } - if (key === '__disableTmpl') { + if (key === '__disableTmpl' || key === 'title') { delete list[key]; } }); diff --git a/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/in-context/checkout-express.js b/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/in-context/checkout-express.js index 206355f5a9839..448c409da2716 100644 --- a/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/in-context/checkout-express.js +++ b/app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/in-context/checkout-express.js @@ -85,7 +85,6 @@ define([ */ onClick: function () { additionalValidators.validate(); - this.selectPaymentMethod(); }, /** diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/action/set-payment-information-extended.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/action/set-payment-information-extended.test.js index 3a31672848d5c..deea9b087c3f9 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/action/set-payment-information-extended.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/action/set-payment-information-extended.test.js @@ -58,6 +58,7 @@ define([ deferral = new $.Deferred(), paymentData = { method: 'checkmo', + title: 'Method title', additionalData: null, __disableTmpl: { title: true From 8c95f0780e8f9bb98987611a5bc0ecfe19bd9f15 Mon Sep 17 00:00:00 2001 From: Leonid Poluianov <46716220+le0n4ik@users.noreply.github.com> Date: Fri, 27 Nov 2020 02:17:23 -0600 Subject: [PATCH 68/69] [AWS-S3] MC-38609: Support by Magento EAV and MC-37780: Support by Scheduled Import/Export (#6347) Story MC-38609 Support by Magento EAV MC-37780 Support by Scheduled Import/Export MC-37457 Performance optimization MC-39178 Add remote storage synchronization support for import/export MC-38601 Add job to compare local FS adapter vs S3 adapter on PAT MC-37481 Support by Magento Analytics --- app/code/Magento/Analytics/etc/config.xml | 7 +++ app/code/Magento/AwsS3/Driver/AwsS3.php | 3 +- .../Magento/AwsS3/Driver/AwsS3Factory.php | 4 ++ .../Magento/AwsS3/Model/HttpLoggerHandler.php | 61 +++++++++++++++++++ .../Magento/Catalog/Model/Product/Image.php | 25 ++------ app/code/Magento/Customer/etc/config.xml | 7 +++ .../Eav/Model/Attribute/Data/Image.php | 42 +++++++------ .../Block/Adminhtml/Import/Edit/Form.php | 3 + .../Adminhtml/Export/File/Delete.php | 4 +- .../Adminhtml/Export/File/Download.php | 11 ++-- .../Controller/Adminhtml/History/Download.php | 2 +- .../Controller/Adminhtml/Import/Download.php | 2 +- .../Magento/ImportExport/Helper/Report.php | 2 +- .../ImportExport/Model/AbstractModel.php | 2 +- .../Model/Export/Adapter/AbstractAdapter.php | 2 +- .../ImportExport/Model/Export/Consumer.php | 4 +- .../Magento/ImportExport/Model/Report/Csv.php | 4 +- .../DataProvider/ExportFileDataProvider.php | 12 ++-- .../RemoteStorage/Model/Synchronizer.php | 25 ++++++-- .../Magento/RemoteStorage/Plugin/Image.php | 4 +- .../Test/Unit/Model/SynchronizerTest.php | 5 +- app/code/Magento/RemoteStorage/etc/di.xml | 2 +- .../Magento/TestFramework/Application.php | 1 + .../Config/Block/System/Config/FormTest.php | 7 +++ .../Adminhtml/Export/File/DeleteTest.php | 2 +- .../Adminhtml/Export/File/DownloadTest.php | 2 +- .../App/Filesystem/DirectoryList.php | 9 +-- .../Magento/Framework/File/Uploader.php | 46 ++++++++++---- 28 files changed, 213 insertions(+), 87 deletions(-) create mode 100644 app/code/Magento/AwsS3/Model/HttpLoggerHandler.php diff --git a/app/code/Magento/Analytics/etc/config.xml b/app/code/Magento/Analytics/etc/config.xml index 27d608ab46039..d3066e186b25a 100644 --- a/app/code/Magento/Analytics/etc/config.xml +++ b/app/code/Magento/Analytics/etc/config.xml @@ -23,5 +23,12 @@ <token/> </general> </analytics> + <system> + <media_storage_configuration> + <allowed_resources> + <analytics_folder>analytics</analytics_folder> + </allowed_resources> + </media_storage_configuration> + </system> </default> </config> diff --git a/app/code/Magento/AwsS3/Driver/AwsS3.php b/app/code/Magento/AwsS3/Driver/AwsS3.php index 4f753210ca0f6..6b3da8c848fb7 100644 --- a/app/code/Magento/AwsS3/Driver/AwsS3.php +++ b/app/code/Magento/AwsS3/Driver/AwsS3.php @@ -304,6 +304,7 @@ public function getAbsolutePath($basePath, $path, $scheme = null) * Resolves relative path. * * @param string $path Absolute path + * @param bool $fixPath * @return string Relative path */ private function normalizeRelativePath(string $path, bool $fixPath = false): string @@ -358,7 +359,7 @@ public function isFile($path): bool return false; } - $path = $this->normalizeRelativePath($path, true);; + $path = $this->normalizeRelativePath($path, true); if ($this->adapter->has($path) && ($meta = $this->adapter->getMetadata($path))) { return ($meta['type'] ?? null) === self::TYPE_FILE; diff --git a/app/code/Magento/AwsS3/Driver/AwsS3Factory.php b/app/code/Magento/AwsS3/Driver/AwsS3Factory.php index 581c1c276c7e1..a4d3676bffa07 100644 --- a/app/code/Magento/AwsS3/Driver/AwsS3Factory.php +++ b/app/code/Magento/AwsS3/Driver/AwsS3Factory.php @@ -86,6 +86,10 @@ public function createConfigured( throw new DriverException(__('Bucket and region are required values')); } + if (!empty($config['http_handler'])) { + $config['http_handler'] = $this->objectManager->create($config['http_handler'])($config); + } + $client = new S3Client($config); $adapter = new AwsS3Adapter($client, $config['bucket'], $prefix); diff --git a/app/code/Magento/AwsS3/Model/HttpLoggerHandler.php b/app/code/Magento/AwsS3/Model/HttpLoggerHandler.php new file mode 100644 index 0000000000000..9971a81f155d4 --- /dev/null +++ b/app/code/Magento/AwsS3/Model/HttpLoggerHandler.php @@ -0,0 +1,61 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\AwsS3\Model; + +use Aws\Handler\GuzzleV6\GuzzleHandler; +use GuzzleHttp\Client; +use GuzzleHttp\HandlerStack; +use GuzzleHttp\MessageFormatter; +use GuzzleHttp\Middleware; +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Exception\FileSystemException; +use Magento\Framework\Filesystem; +use Monolog\Handler\StreamHandler; +use Monolog\Logger; + +final class HttpLoggerHandler +{ + /** + * @var Filesystem\Directory\WriteInterface + */ + private $directory; + + /** + * @var string + */ + private $file; + + /** + * @param Filesystem $filesystem + * @param string $file + * @throws FileSystemException + */ + public function __construct( + Filesystem $filesystem, + $file = 'debug/s3.log' + ) { + $this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR); + $this->file = $file; + } + + public function __invoke() + { + $this->directory->create(pathinfo($this->file, PATHINFO_DIRNAME)); + $localStream = $this->directory->getDriver()->fileOpen($this->directory->getAbsolutePath($this->file), 'a'); + $streamHandler = new StreamHandler($localStream, Logger::DEBUG, true, null, true); + $logger = new \Monolog\Logger('S3', [$streamHandler]); + $stack = HandlerStack::create(); + $stack->push( + Middleware::log( + $logger, + new MessageFormatter('{code}:{method}:{target} {error}') + ) + ); + return new GuzzleHandler(new Client(['handler' => $stack])); + } +} diff --git a/app/code/Magento/Catalog/Model/Product/Image.php b/app/code/Magento/Catalog/Model/Product/Image.php index 842ee197f83fe..34ce5cad70b04 100644 --- a/app/code/Magento/Catalog/Model/Product/Image.php +++ b/app/code/Magento/Catalog/Model/Product/Image.php @@ -6,15 +6,13 @@ namespace Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException; +use Magento\Catalog\Model\Product\Image\ParamsBuilder; use Magento\Catalog\Model\View\Asset\ImageFactory; use Magento\Catalog\Model\View\Asset\PlaceholderFactory; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\App\ObjectManager; -use Magento\Framework\Exception\FileSystemException; use Magento\Framework\Image as MagentoImage; use Magento\Framework\Serialize\SerializerInterface; -use Magento\Catalog\Model\Product\Image\ParamsBuilder; -use Magento\Framework\Filesystem\Driver\File as FilesystemDriver; /** * Image operations @@ -202,11 +200,6 @@ class Image extends \Magento\Framework\Model\AbstractModel */ private $serializer; - /** - * @var FilesystemDriver - */ - private $filesystemDriver; - /** * Constructor * @@ -227,7 +220,6 @@ class Image extends \Magento\Framework\Model\AbstractModel * @param array $data * @param SerializerInterface $serializer * @param ParamsBuilder $paramsBuilder - * @param FilesystemDriver $filesystemDriver * @throws \Magento\Framework\Exception\FileSystemException * @SuppressWarnings(PHPMD.ExcessiveParameterList) * @SuppressWarnings(PHPMD.UnusedLocalVariable) @@ -249,8 +241,7 @@ public function __construct( \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [], SerializerInterface $serializer = null, - ParamsBuilder $paramsBuilder = null, - FilesystemDriver $filesystemDriver = null + ParamsBuilder $paramsBuilder = null ) { $this->_storeManager = $storeManager; $this->_catalogProductMediaConfig = $catalogProductMediaConfig; @@ -265,7 +256,6 @@ public function __construct( $this->viewAssetPlaceholderFactory = $viewAssetPlaceholderFactory; $this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class); $this->paramsBuilder = $paramsBuilder ?: ObjectManager::getInstance()->get(ParamsBuilder::class); - $this->filesystemDriver = $filesystemDriver ?: ObjectManager::getInstance()->get(FilesystemDriver::class); } /** @@ -675,12 +665,7 @@ public function getDestinationSubdir() public function isCached() { $path = $this->imageAsset->getPath(); - try { - $isCached = is_array($this->loadImageInfoFromCache($path)) || $this->filesystemDriver->isExists($path); - } catch (FileSystemException $e) { - $isCached = false; - } - return $isCached; + return is_array($this->loadImageInfoFromCache($path)) || $this->_mediaDirectory->isExist($path); } /** @@ -952,7 +937,7 @@ private function getImageSize($imagePath) */ private function saveImageInfoToCache(array $imageInfo, string $imagePath) { - $imagePath = $this->cachePrefix . $imagePath; + $imagePath = $this->cachePrefix . $imagePath; $this->_cacheManager->save( $this->serializer->serialize($imageInfo), $imagePath, @@ -968,7 +953,7 @@ private function saveImageInfoToCache(array $imageInfo, string $imagePath) */ private function loadImageInfoFromCache(string $imagePath) { - $imagePath = $this->cachePrefix . $imagePath; + $imagePath = $this->cachePrefix . $imagePath; $cacheData = $this->_cacheManager->load($imagePath); if (!$cacheData) { return false; diff --git a/app/code/Magento/Customer/etc/config.xml b/app/code/Magento/Customer/etc/config.xml index ab2020580a2eb..22596e0b901b2 100644 --- a/app/code/Magento/Customer/etc/config.xml +++ b/app/code/Magento/Customer/etc/config.xml @@ -103,5 +103,12 @@ <section_data_lifetime>60</section_data_lifetime> </online_customers> </customer> + <system> + <media_storage_configuration> + <allowed_resources> + <customer_address_folder>customer_address</customer_address_folder> + </allowed_resources> + </media_storage_configuration> + </system> </default> </config> diff --git a/app/code/Magento/Eav/Model/Attribute/Data/Image.php b/app/code/Magento/Eav/Model/Attribute/Data/Image.php index 24cd0f4fcf61f..d61a8b5fda5b1 100644 --- a/app/code/Magento/Eav/Model/Attribute/Data/Image.php +++ b/app/code/Magento/Eav/Model/Attribute/Data/Image.php @@ -5,6 +5,8 @@ */ namespace Magento\Eav\Model\Attribute\Data; +use Magento\Framework\Filesystem\ExtendedDriverInterface; + /** * EAV Entity Attribute Image File Data Model * @@ -21,24 +23,30 @@ class Image extends \Magento\Eav\Model\Attribute\Data\File * @return array * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) + * @throws \Magento\Framework\Exception\LocalizedException */ protected function _validateByRules($value) { $label = __($this->getAttribute()->getStoreLabel()); $rules = $this->getAttribute()->getValidateRules(); + $localStorage = !$this->_directory->getDriver() instanceof ExtendedDriverInterface; + $imageProp = $localStorage + ? @getimagesize($value['tmp_name']) + : $this->_directory->getDriver()->getMetadata($value['tmp_name']); + $allowImageTypes = ['gif', 'jpg', 'jpeg', 'png']; + if (!isset($imageProp['extension']) && isset($imageProp[2])) { + $extensionsMap = [1 => 'gif', 2 => 'jpg', 3 => 'png']; + $imageProp['extension'] = $extensionsMap[$imageProp[2]] ?? null; + } - $imageProp = @getimagesize($value['tmp_name']); - - $allowImageTypes = [1 => 'gif', 2 => 'jpg', 3 => 'png']; - - if (!isset($allowImageTypes[$imageProp[2]])) { + if (!\in_array($imageProp['extension'], $allowImageTypes, true)) { return [__('"%1" is not a valid image format', $label)]; } // modify image name $extension = pathinfo($value['name'], PATHINFO_EXTENSION); - if ($extension != $allowImageTypes[$imageProp[2]]) { - $value['name'] = pathinfo($value['name'], PATHINFO_FILENAME) . '.' . $allowImageTypes[$imageProp[2]]; + if ($extension !== $imageProp['extension']) { + $value['name'] = pathinfo($value['name'], PATHINFO_FILENAME) . '.' . $imageProp['extension']; } $errors = []; @@ -49,17 +57,17 @@ protected function _validateByRules($value) } } - if (!empty($rules['max_image_width'])) { - if ($rules['max_image_width'] < $imageProp[0]) { - $r = $rules['max_image_width']; - $errors[] = __('"%1" width exceeds allowed value of %2 px.', $label, $r); - } + $imageWidth = $imageProp['extra']['image-width'] ?? $imageProp[0]; + if (!empty($rules['max_image_width']) && !empty($imageWidth) + && ($rules['max_image_width'] < $imageWidth)) { + $r = $rules['max_image_width']; + $errors[] = __('"%1" width exceeds allowed value of %2 px.', $label, $r); } - if (!empty($rules['max_image_height'])) { - if ($rules['max_image_height'] < $imageProp[1]) { - $r = $rules['max_image_height']; - $errors[] = __('"%1" height exceeds allowed value of %2 px.', $label, $r); - } + $imageHeight = $imageProp['extra']['image-height'] ?? $imageProp[1]; + if (!empty($rules['max_image_height']) && !empty($imageHeight) + && ($rules['max_image_height'] < $imageHeight)) { + $r = $rules['max_image_height']; + $errors[] = __('"%1" height exceeds allowed value of %2 px.', $label, $r); } return $errors; diff --git a/app/code/Magento/ImportExport/Block/Adminhtml/Import/Edit/Form.php b/app/code/Magento/ImportExport/Block/Adminhtml/Import/Edit/Form.php index 87cd4cf346288..07cf6f8c733d4 100644 --- a/app/code/Magento/ImportExport/Block/Adminhtml/Import/Edit/Form.php +++ b/app/code/Magento/ImportExport/Block/Adminhtml/Import/Edit/Form.php @@ -248,6 +248,9 @@ protected function _prepareForm() .', e.g. <i>product_images</i>, <i>import_images/batch1</i>.<br><br>' .'For example, in case <i>product_images</i>, files should be placed into ' .'<i><Magento root directory>/' + .$this->imagesDirectoryProvider->getDirectoryRelativePath() . '/product_images</i> folder.<br>' + .'<br>If remote storage is enabled, in case <i>product_images</i>, files should be placed into ' + .'<i><Remote Storage>/' .$this->imagesDirectoryProvider->getDirectoryRelativePath() . '/product_images</i> folder.', ['i', 'br'] ) diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Delete.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Delete.php index e31f36e627a66..8c47412adc835 100644 --- a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Delete.php +++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Delete.php @@ -70,9 +70,9 @@ public function execute() return $resultRedirect; } - $directoryWrite = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_EXPORT); + $directoryWrite = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT); try { - $directoryWrite->delete($directoryWrite->getAbsolutePath($fileName)); + $directoryWrite->delete($directoryWrite->getAbsolutePath() . 'export/' . $fileName); $this->messageManager->addSuccessMessage(__('File %1 deleted', $fileName)); } catch (ValidatorException $exception) { $this->messageManager->addErrorMessage( diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Download.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Download.php index 26ee257c42ff2..8e432e395bdf4 100644 --- a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Download.php +++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/File/Download.php @@ -67,12 +67,13 @@ public function execute() return $resultRedirect; } try { - $directory = $this->filesystem->getDirectoryRead(DirectoryList::VAR_EXPORT); - if ($directory->isFile($fileName)) { + $path = 'export/' . $fileName; + $directory = $this->filesystem->getDirectoryRead(DirectoryList::VAR_IMPORT_EXPORT); + if ($directory->isFile($path)) { return $this->fileFactory->create( - $fileName, - $directory->readFile($fileName), - DirectoryList::VAR_EXPORT + $path, + $directory->readFile($path), + DirectoryList::VAR_IMPORT_EXPORT ); } $this->messageManager->addErrorMessage(__('%1 is not a valid file', $fileName)); diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/History/Download.php b/app/code/Magento/ImportExport/Controller/Adminhtml/History/Download.php index ba37cc8aacff9..9dcb2fdafb74f 100644 --- a/app/code/Magento/ImportExport/Controller/Adminhtml/History/Download.php +++ b/app/code/Magento/ImportExport/Controller/Adminhtml/History/Download.php @@ -62,7 +62,7 @@ public function execute() $this->fileFactory->create( $fileName, null, - DirectoryList::VAR_DIR, + DirectoryList::VAR_IMPORT_EXPORT, 'application/octet-stream', $reportHelper->getReportSize($fileName) ); diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Download.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Download.php index 9918ef8908956..5ff0dd9b63da9 100644 --- a/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Download.php +++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Import/Download.php @@ -109,7 +109,7 @@ public function execute() $this->fileFactory->create( $fileName, null, - DirectoryList::VAR_DIR, + DirectoryList::VAR_IMPORT_EXPORT, 'application/octet-stream', $fileSize ); diff --git a/app/code/Magento/ImportExport/Helper/Report.php b/app/code/Magento/ImportExport/Helper/Report.php index 29d1928d837d6..d5be27a569942 100644 --- a/app/code/Magento/ImportExport/Helper/Report.php +++ b/app/code/Magento/ImportExport/Helper/Report.php @@ -40,7 +40,7 @@ public function __construct( \Magento\Framework\Filesystem $filesystem ) { $this->timeZone = $timeZone; - $this->varDirectory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR); + $this->varDirectory = $filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT); parent::__construct($context); } diff --git a/app/code/Magento/ImportExport/Model/AbstractModel.php b/app/code/Magento/ImportExport/Model/AbstractModel.php index 87fde3fbb68a3..4010f3bfcae4c 100644 --- a/app/code/Magento/ImportExport/Model/AbstractModel.php +++ b/app/code/Magento/ImportExport/Model/AbstractModel.php @@ -56,7 +56,7 @@ public function __construct( array $data = [] ) { $this->_logger = $logger; - $this->_varDirectory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR); + $this->_varDirectory = $filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT); parent::__construct($data); } diff --git a/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php b/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php index 8fbc91de5b211..1e292e849c9f8 100644 --- a/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php +++ b/app/code/Magento/ImportExport/Model/Export/Adapter/AbstractAdapter.php @@ -46,7 +46,7 @@ abstract class AbstractAdapter public function __construct( \Magento\Framework\Filesystem $filesystem, $destination = null, - $destinationDirectoryCode = DirectoryList::VAR_DIR + $destinationDirectoryCode = DirectoryList::VAR_IMPORT_EXPORT ) { $this->_directoryHandle = $filesystem->getDirectoryWrite($destinationDirectoryCode); if (!$destination) { diff --git a/app/code/Magento/ImportExport/Model/Export/Consumer.php b/app/code/Magento/ImportExport/Model/Export/Consumer.php index 955f96fe3de2e..55ffbb9ab213d 100644 --- a/app/code/Magento/ImportExport/Model/Export/Consumer.php +++ b/app/code/Magento/ImportExport/Model/Export/Consumer.php @@ -70,8 +70,8 @@ public function process(ExportInfoInterface $exportInfo) try { $data = $this->exportManager->export($exportInfo); $fileName = $exportInfo->getFileName(); - $directory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_EXPORT); - $directory->writeFile($fileName, $data); + $directory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT); + $directory->writeFile('export/' . $fileName, $data); $this->notifier->addMajor( __('Your export file is ready'), diff --git a/app/code/Magento/ImportExport/Model/Report/Csv.php b/app/code/Magento/ImportExport/Model/Report/Csv.php index e7ddef1008444..26f36c53cb7f8 100644 --- a/app/code/Magento/ImportExport/Model/Report/Csv.php +++ b/app/code/Magento/ImportExport/Model/Report/Csv.php @@ -83,7 +83,7 @@ public function createReport( } } - $directory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR); + $directory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT); $outputFileName = $this->generateOutputFileName($originalFileName); $directory->writeFile(Import::IMPORT_HISTORY_DIR . $outputFileName, $outputCsv->getContents()); @@ -136,7 +136,7 @@ protected function createSourceCsvModel($sourceFile) return $this->sourceCsvFactory->create( [ 'file' => $sourceFile, - 'directory' => $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR), + 'directory' => $this->filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT), 'delimiter' => $this->reportHelper->getDelimiter(), ] ); diff --git a/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php b/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php index 71614bafd138e..e9df0a8127315 100644 --- a/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php +++ b/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php @@ -85,7 +85,7 @@ public function __construct( ); $this->fileIO = $fileIO ?: ObjectManager::getInstance()->get(File::class); - $this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_EXPORT); + $this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_IMPORT_EXPORT); } /** @@ -97,11 +97,11 @@ public function __construct( public function getData() { $emptyResponse = ['items' => [], 'totalRecords' => 0]; - if (!$this->directory->isExist($this->directory->getAbsolutePath())) { + if (!$this->directory->isExist($this->directory->getAbsolutePath() . 'export/')) { return $emptyResponse; } - $files = $this->getExportFiles($this->directory->getAbsolutePath()); + $files = $this->getExportFiles($this->directory->getAbsolutePath() . 'export/'); if (empty($files)) { return $emptyResponse; } @@ -128,14 +128,11 @@ public function getData() */ private function getPathToExportFile($file): string { - $directory = $this->fileSystem->getDirectoryRead(DirectoryList::VAR_EXPORT); $delimiter = '/'; $cutPath = explode( $delimiter, - $directory->getAbsolutePath() + $this->directory->getAbsolutePath() . 'export' ); - // remove . from dirname if file path is not absolute in the file system but just a file name - $file['dirname'] = $file['dirname'] !== '.' ? $file['dirname'] : ''; $filePath = explode( $delimiter, @@ -163,6 +160,7 @@ private function getExportFiles(string $directoryPath): array return []; } foreach ($files as $filePath) { + $filePath = $this->directory->getAbsolutePath($filePath); if ($this->directory->isFile($filePath)) { $fileModificationTime = $this->directory->stat($filePath)['mtime']; $sortedFiles[$fileModificationTime] = $filePath; diff --git a/app/code/Magento/RemoteStorage/Model/Synchronizer.php b/app/code/Magento/RemoteStorage/Model/Synchronizer.php index 4276c7a1a2ffd..3b01e7af5ee54 100644 --- a/app/code/Magento/RemoteStorage/Model/Synchronizer.php +++ b/app/code/Magento/RemoteStorage/Model/Synchronizer.php @@ -8,13 +8,14 @@ namespace Magento\RemoteStorage\Model; use Generator; +use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Exception\FileSystemException; use Magento\Framework\Exception\ValidatorException; +use Magento\Framework\Filesystem\Directory\WriteInterface; use Magento\Framework\Filesystem\DriverPool; use Magento\Framework\Filesystem\Glob; use Magento\RemoteStorage\Driver\DriverPool as RemoteDriverPool; use Magento\RemoteStorage\Filesystem; -use Magento\Framework\Filesystem\Directory\WriteInterface; /** * Synchronize files from local filesystem. @@ -44,10 +45,12 @@ public function __construct(Filesystem $filesystem) public function execute(): Generator { foreach ($this->filesystem->getDirectoryCodes() as $directoryCode) { - $directory = $this->filesystem->getDirectoryWrite($directoryCode, DriverPool::FILE); - $remoteDirectory = $this->filesystem->getDirectoryWrite($directoryCode, RemoteDriverPool::REMOTE); + if ($this->isSynchronizationAllowed($directoryCode)) { + $directory = $this->filesystem->getDirectoryWrite($directoryCode, DriverPool::FILE); + $remoteDirectory = $this->filesystem->getDirectoryWrite($directoryCode, RemoteDriverPool::REMOTE); - yield from $this->copyRecursive($directory, $remoteDirectory, $directory->getAbsolutePath()); + yield from $this->copyRecursive($directory, $remoteDirectory, $directory->getAbsolutePath()); + } } } @@ -101,4 +104,18 @@ private function copyRecursive( yield from $this->copyRecursive($directory, $remoteDirectory, $childDirectory, $pattern, $flags); } } + + /** + * Check if synchronization is allowed. + * + * @param string $directoryCode + * @return bool + * @deprecated This method should be removed when MC-39280 is fixed + * and import export functionality is allocated inside var/import_export directory + */ + private function isSynchronizationAllowed(string $directoryCode): bool + { + // skip synchronization for import export + return $directoryCode !== DirectoryList::VAR_IMPORT_EXPORT; + } } diff --git a/app/code/Magento/RemoteStorage/Plugin/Image.php b/app/code/Magento/RemoteStorage/Plugin/Image.php index 013e3fd23e168..5c40bba238651 100644 --- a/app/code/Magento/RemoteStorage/Plugin/Image.php +++ b/app/code/Magento/RemoteStorage/Plugin/Image.php @@ -185,7 +185,7 @@ public function __destruct() private function copyFileToTmp(string $filePath): string { if ($this->fileExistsInTmp($filePath)) { - return $filePath; + return $this->tmpFiles[$filePath]; } $absolutePath = $this->remoteDirectoryWrite->getAbsolutePath($filePath); if ($this->remoteDirectoryWrite->isFile($absolutePath)) { @@ -223,7 +223,7 @@ private function storeTmpName(string $filePath): string */ private function fileExistsInTmp(string $filePath): bool { - return in_array($filePath, $this->tmpFiles, true); + return array_key_exists($filePath, $this->tmpFiles); } /** diff --git a/app/code/Magento/RemoteStorage/Test/Unit/Model/SynchronizerTest.php b/app/code/Magento/RemoteStorage/Test/Unit/Model/SynchronizerTest.php index 5c3ddb74bb0cf..4e373e7f9c77e 100644 --- a/app/code/Magento/RemoteStorage/Test/Unit/Model/SynchronizerTest.php +++ b/app/code/Magento/RemoteStorage/Test/Unit/Model/SynchronizerTest.php @@ -51,7 +51,7 @@ protected function setUp(): void public function testExecute(): void { $this->filesystemMock->method('getDirectoryCodes') - ->willReturn(['test']); + ->willReturn(['test', 'import_export']); $localDriver = $this->createMock(DriverInterface::class); $remoteDriver = $this->createMock(DriverInterface::class); @@ -63,7 +63,8 @@ public function testExecute(): void $remoteDirectory->method('getDriver') ->willReturn($remoteDriver); - $this->filesystemMock->method('getDirectoryWrite') + $this->filesystemMock->expects(self::exactly(2)) + ->method('getDirectoryWrite') ->willReturnMap([ ['test', DriverPool::FILE, $localDirectory], ['test', RemoteDriverPool::REMOTE, $remoteDirectory] diff --git a/app/code/Magento/RemoteStorage/etc/di.xml b/app/code/Magento/RemoteStorage/etc/di.xml index 04dcc5955ac41..6ba98cdd107e8 100644 --- a/app/code/Magento/RemoteStorage/etc/di.xml +++ b/app/code/Magento/RemoteStorage/etc/di.xml @@ -26,7 +26,7 @@ <arguments> <argument name="directoryCodes" xsi:type="array"> <item name="media" xsi:type="const">Magento\Framework\App\Filesystem\DirectoryList::MEDIA</item> - <item name="var_export" xsi:type="const">Magento\Framework\App\Filesystem\DirectoryList::VAR_EXPORT</item> + <item name="var_import_export" xsi:type="const">Magento\Framework\App\Filesystem\DirectoryList::VAR_IMPORT_EXPORT</item> </argument> </arguments> </virtualType> diff --git a/dev/tests/integration/framework/Magento/TestFramework/Application.php b/dev/tests/integration/framework/Magento/TestFramework/Application.php index af2b72e03e9be..43bb7852e2441 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/Application.php +++ b/dev/tests/integration/framework/Magento/TestFramework/Application.php @@ -731,6 +731,7 @@ protected function getCustomDirs() DirectoryList::TMP => [$path => "{$var}/tmp"], DirectoryList::UPLOAD => [$path => "{$var}/upload"], DirectoryList::PUB => [$path => "{$this->installDir}/pub"], + DirectoryList::VAR_IMPORT_EXPORT => [$path => "{$this->installDir}/var"], ]; return $customDirs; } diff --git a/dev/tests/integration/testsuite/Magento/Config/Block/System/Config/FormTest.php b/dev/tests/integration/testsuite/Magento/Config/Block/System/Config/FormTest.php index aae6ae770063f..a93adeee1307d 100644 --- a/dev/tests/integration/testsuite/Magento/Config/Block/System/Config/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Config/Block/System/Config/FormTest.php @@ -585,6 +585,13 @@ private function setEncryptedValue($encryptedValue) */ protected function tearDown(): void { + $reflection = new \ReflectionObject($this); + foreach ($reflection->getProperties() as $property) { + if (!$property->isStatic() && 0 !== strpos($property->getDeclaringClass()->getName(), 'PHPUnit')) { + $property->setAccessible(true); + $property->setValue($this, null); + } + } $this->setEncryptedValue('{ENCRYPTED_VALUE}'); $configResourceModel = Bootstrap::getObjectManager()->get(\Magento\Config\Model\ResourceModel\Config::class); diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DeleteTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DeleteTest.php index 53e90ebf76f66..e6f631758eb41 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DeleteTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DeleteTest.php @@ -51,7 +51,7 @@ protected function setUp(): void $this->fileSystem = $this->_objectManager->get(Filesystem::class); $this->sourceFilePath = __DIR__ . '/../../Import/_files' . DIRECTORY_SEPARATOR . $this->fileName; //Refers to tests 'var' directory - $this->varDirectory = $this->fileSystem->getDirectoryRead(DirectoryList::VAR_DIR); + $this->varDirectory = $this->fileSystem->getDirectoryRead(DirectoryList::VAR_IMPORT_EXPORT); } /** diff --git a/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DownloadTest.php b/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DownloadTest.php index 2128516189474..277e6af871650 100644 --- a/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DownloadTest.php +++ b/dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/Export/File/DownloadTest.php @@ -105,7 +105,7 @@ public function testExecute($file): void 'Incorrect response header "content-type"' ); $this->assertEquals( - 'attachment; filename="' . $this->fileName . '"', + 'attachment; filename="export/' . $this->fileName . '"', $contentDisposition->getFieldValue(), 'Incorrect response header "content-disposition"' ); diff --git a/lib/internal/Magento/Framework/App/Filesystem/DirectoryList.php b/lib/internal/Magento/Framework/App/Filesystem/DirectoryList.php index fdf524348293b..ce150b00a6665 100644 --- a/lib/internal/Magento/Framework/App/Filesystem/DirectoryList.php +++ b/lib/internal/Magento/Framework/App/Filesystem/DirectoryList.php @@ -63,9 +63,9 @@ class DirectoryList extends \Magento\Framework\Filesystem\DirectoryList const VAR_EXPORT = 'var_export'; /** - * Storage of files which were imported. + * Storage of files for import/export. */ - const VAR_IMPORT = 'var_import'; + const VAR_IMPORT_EXPORT = 'import_export'; /** * Temporary files @@ -156,7 +156,8 @@ public static function getDefaultConfig() self::CONFIG => [parent::PATH => 'app/etc'], self::LIB_INTERNAL => [parent::PATH => 'lib/internal'], self::VAR_DIR => [parent::PATH => 'var'], - self::VAR_EXPORT => [parent::PATH => 'var/export', parent::URL_PATH => 'export'], + /** @deprecated */ + self::VAR_EXPORT => [parent::PATH => 'var/export'], self::CACHE => [parent::PATH => 'var/cache'], self::LOG => [parent::PATH => 'var/log'], self::DI => [parent::PATH => 'generated/metadata'], @@ -175,7 +176,7 @@ public static function getDefaultConfig() self::GENERATED => [parent::PATH => 'generated'], self::GENERATED_CODE => [parent::PATH => Io::DEFAULT_DIRECTORY], self::GENERATED_METADATA => [parent::PATH => 'generated/metadata'], - self::VAR_IMPORT => [parent::PATH => 'var/import', parent::URL_PATH => 'var/import'], + self::VAR_IMPORT_EXPORT => [parent::PATH => 'var', parent::URL_PATH => 'import_export'], ]; return parent::getDefaultConfig() + $result; } diff --git a/lib/internal/Magento/Framework/File/Uploader.php b/lib/internal/Magento/Framework/File/Uploader.php index c3246bfbf1e48..3ed8e274cfecd 100644 --- a/lib/internal/Magento/Framework/File/Uploader.php +++ b/lib/internal/Magento/Framework/File/Uploader.php @@ -13,6 +13,7 @@ use Magento\Framework\Filesystem\DriverInterface; use Magento\Framework\Filesystem\DriverPool; use Magento\Framework\Validation\ValidationException; +use Psr\Log\LoggerInterface; /** * File upload class @@ -133,6 +134,11 @@ class Uploader */ private $fileMime; + /** + * @var LoggerInterface + */ + private $logger; + /**#@+ * File upload type (multiple or single) */ @@ -329,24 +335,42 @@ protected function chmod($file) * @param string $tmpPath * @param string $destPath * @return bool - * @throws FileSystemException */ protected function _moveFile($tmpPath, $destPath) { $rootCode = DirectoryList::PUB; - if (strpos($destPath, $this->getDirectoryList()->getPath($rootCode)) !== 0) { - $rootCode = DirectoryList::ROOT; - } + try { + if (strpos($destPath, $this->getDirectoryList()->getPath($rootCode)) !== 0) { + $rootCode = DirectoryList::ROOT; + } - $destPath = str_replace($this->getDirectoryList()->getPath($rootCode), '', $destPath); - $directory = $this->getTargetDirectory()->getDirectoryWrite($rootCode); + $destPath = str_replace($this->getDirectoryList()->getPath($rootCode), '', $destPath); + $directory = $this->getTargetDirectory()->getDirectoryWrite($rootCode); - return $this->getFileDriver()->rename( - $tmpPath, - $directory->getAbsolutePath($destPath), - $directory->getDriver() - ); + return $this->getFileDriver()->rename( + $tmpPath, + $directory->getAbsolutePath($destPath), + $directory->getDriver() + ); + } catch (FileSystemException $exception) { + $this->getLogger()->critical($exception->getMessage()); + return false; + } + } + + /** + * Get logger instance. + * + * @deprecated + * @return LoggerInterface + */ + private function getLogger(): LoggerInterface + { + if (!$this->logger) { + $this->logger = ObjectManager::getInstance()->get(LoggerInterface::class); + } + return $this->logger; } /** From 77a5a147ca6186cf530bc58e7a2b55a3637b54e2 Mon Sep 17 00:00:00 2001 From: David Haecker <dhaecker@magento.com> Date: Sat, 28 Nov 2020 20:50:21 -0600 Subject: [PATCH 69/69] magento/magento2-page-builder#559: User sees no predefined gutters - Fixing failing tests --- .../StorefrontDeleteSimpleProductFromMiniShoppingCartTest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleProductFromMiniShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleProductFromMiniShoppingCartTest.xml index effd376ab4bfb..2d6f36c78edf6 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleProductFromMiniShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleProductFromMiniShoppingCartTest.xml @@ -54,6 +54,7 @@ <argument name="productName" value="$$simpleProduct.name$$"/> </actionGroup> <reloadPage stepKey="reloadPage"/> + <waitForPageLoad stepKey="waitForPageLoad"/> <!--Check the minicart is empty and verify AssertProductAbsentInMiniShoppingCart--> <actionGroup ref="AssertMiniCartEmptyActionGroup" stepKey="miniCartEnpty"/>