From bf024c1c1f3b86a7c3dd362b78fb124f58f22b96 Mon Sep 17 00:00:00 2001 From: Danny Verkade Date: Mon, 15 Oct 2018 20:31:52 +0200 Subject: [PATCH 001/162] Fix for issue magento/magento2#18630 --- .../Ui/view/base/web/js/form/element/post-code.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js b/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js index 911574a0fb438..3de99aa9af1a3 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js @@ -20,6 +20,21 @@ define([ } }, + /** + * Initializes observable properties of instance + * + * @returns {Abstract} Chainable. + */ + initObservable: function () { + this._super(); + + this.value.equalityComparer = function(a, b) { + return (!a && !b) || (a == b); + }; + + return this; + }, + /** * @param {String} value */ From df90f67822ea0f1c5765b512c1d7613532a41a11 Mon Sep 17 00:00:00 2001 From: Danny Verkade Date: Tue, 16 Oct 2018 15:53:09 +0200 Subject: [PATCH 002/162] Fix coding standard errors. --- .../Magento/Ui/view/base/web/js/form/element/post-code.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js b/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js index 3de99aa9af1a3..4c684f16b7678 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js @@ -28,8 +28,8 @@ define([ initObservable: function () { this._super(); - this.value.equalityComparer = function(a, b) { - return (!a && !b) || (a == b); + this.value.equalityComparer = function (oldValue, newValue) { + return !oldValue && !newValue || oldValue === newValue; }; return this; From 6257fe8a3938c59e207b51da30202e1f5a65eb76 Mon Sep 17 00:00:00 2001 From: Danny Verkade Date: Tue, 16 Oct 2018 22:11:15 +0200 Subject: [PATCH 003/162] Fixed jsdoc-block definition error --- .../Magento/Ui/view/base/web/js/form/element/post-code.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js b/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js index 4c684f16b7678..ec399914ed02e 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js @@ -28,6 +28,11 @@ define([ initObservable: function () { this._super(); + /** + * equalityComparer function + * + * @returns boolean. + */ this.value.equalityComparer = function (oldValue, newValue) { return !oldValue && !newValue || oldValue === newValue; }; From 82970b8c9bd9b7edbdfe77b05f6a73927d2bda6b Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk Date: Thu, 20 Dec 2018 17:10:17 -0600 Subject: [PATCH 004/162] MQE-1069: Migrate Sample Data tests from MTF to MFTF --- ...tProductImagesOnProductPageActionGroup.xml | 20 +++++++++++++++++++ ...ertProductNameOnProductPageActionGroup.xml | 15 ++++++++++++++ ...rtProductPriceOnProductPageActionGroup.xml | 15 ++++++++++++++ ...sertProductSkuOnProductPageActionGroup.xml | 15 ++++++++++++++ .../StorefrontOpenProductPageActionGroup.xml | 16 +++++++++++++++ .../StorefrontProductInfoMainSection.xml | 1 + .../Section/StorefrontProductMediaSection.xml | 4 ++++ ...ertCustomerAccountPageTitleActionGroup.xml | 16 +++++++++++++++ .../LoginToStorefrontActionGroup.xml | 1 + ...NavigateThroughCustomerTabsActionGroup.xml | 17 ++++++++++++++++ .../OpenMyAccountPageActionGroup.xml | 15 ++++++++++++++ .../LoggedInCustomerHeaderLinksSection.xml | 17 ++++++++++++++++ .../StorefrontCustomerAccountMainSection.xml | 14 +++++++++++++ .../StorefrontCustomerSidebarSection.xml | 2 +- 14 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductImagesOnProductPageActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductNameOnProductPageActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductPriceOnProductPageActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductSkuOnProductPageActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontOpenProductPageActionGroup.xml create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertCustomerAccountPageTitleActionGroup.xml create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateThroughCustomerTabsActionGroup.xml create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/OpenMyAccountPageActionGroup.xml create mode 100644 app/code/Magento/Customer/Test/Mftf/Section/LoggedInCustomerHeaderLinksSection.xml create mode 100644 app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerAccountMainSection.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductImagesOnProductPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductImagesOnProductPageActionGroup.xml new file mode 100644 index 0000000000000..e049c7430871f --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductImagesOnProductPageActionGroup.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductNameOnProductPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductNameOnProductPageActionGroup.xml new file mode 100644 index 0000000000000..6cb156723b286 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductNameOnProductPageActionGroup.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductPriceOnProductPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductPriceOnProductPageActionGroup.xml new file mode 100644 index 0000000000000..3c62ef89e584b --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductPriceOnProductPageActionGroup.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductSkuOnProductPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductSkuOnProductPageActionGroup.xml new file mode 100644 index 0000000000000..85d3927a6d6d0 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductSkuOnProductPageActionGroup.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontOpenProductPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontOpenProductPageActionGroup.xml new file mode 100644 index 0000000000000..f5fabae5fc4ce --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontOpenProductPageActionGroup.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductInfoMainSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductInfoMainSection.xml index b93a70559fc4a..63b08b58af6ca 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductInfoMainSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductInfoMainSection.xml @@ -13,6 +13,7 @@ + diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml index 83c3ca5348606..a90525e40b695 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml @@ -9,6 +9,10 @@
+ + + +
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertCustomerAccountPageTitleActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertCustomerAccountPageTitleActionGroup.xml new file mode 100644 index 0000000000000..132b5ca81886f --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertCustomerAccountPageTitleActionGroup.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/LoginToStorefrontActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/LoginToStorefrontActionGroup.xml index 7be36ffbd9bc4..2704f0af38165 100644 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/LoginToStorefrontActionGroup.xml +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/LoginToStorefrontActionGroup.xml @@ -15,5 +15,6 @@ + diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateThroughCustomerTabsActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateThroughCustomerTabsActionGroup.xml new file mode 100644 index 0000000000000..5591bee529690 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateThroughCustomerTabsActionGroup.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/OpenMyAccountPageActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/OpenMyAccountPageActionGroup.xml new file mode 100644 index 0000000000000..6ca0f612deeaa --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/OpenMyAccountPageActionGroup.xml @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/app/code/Magento/Customer/Test/Mftf/Section/LoggedInCustomerHeaderLinksSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/LoggedInCustomerHeaderLinksSection.xml new file mode 100644 index 0000000000000..907551e932fcf --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Section/LoggedInCustomerHeaderLinksSection.xml @@ -0,0 +1,17 @@ + + + + +
+ + + + +
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerAccountMainSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerAccountMainSection.xml new file mode 100644 index 0000000000000..3a4329969ae2b --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerAccountMainSection.xml @@ -0,0 +1,14 @@ + + + + +
+ +
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerSidebarSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerSidebarSection.xml index 7482193031091..56be7a12d7de7 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerSidebarSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerSidebarSection.xml @@ -9,6 +9,6 @@
- +
From 5955ded71ff1367fee224278a1069e09ef711efb Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk Date: Thu, 17 Jan 2019 11:57:51 -0600 Subject: [PATCH 005/162] MQE-1069: Migrate Sample Data tests from MTF to MFTF --- .../StorefrontAssertProductImagesOnProductPageActionGroup.xml | 1 + .../Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductImagesOnProductPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductImagesOnProductPageActionGroup.xml index e049c7430871f..41bfbe608a31d 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductImagesOnProductPageActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductImagesOnProductPageActionGroup.xml @@ -10,6 +10,7 @@ + diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml index a90525e40b695..28f0c1bbf8890 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml @@ -9,6 +9,7 @@
+ From 1f921080c66b7c8392140dc1991c464abe5c10da Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk Date: Thu, 17 Jan 2019 12:53:21 -0600 Subject: [PATCH 006/162] MQE-1069: Migrate Sample Data tests from MTF to MFTF --- .../Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml index 28f0c1bbf8890..3bf1273f05cc2 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml @@ -9,7 +9,7 @@
- + From 3b2bc5b5db0b98cc1a6327cce92daf5318ba79f7 Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk Date: Thu, 17 Jan 2019 14:50:29 -0600 Subject: [PATCH 007/162] MQE-1069: Migrate Sample Data tests from MTF to MFTF - Update test case ids --- .../StorefrontAssertProductImagesOnProductPageActionGroup.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductImagesOnProductPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductImagesOnProductPageActionGroup.xml index 41bfbe608a31d..1bb7c179dfca8 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductImagesOnProductPageActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductImagesOnProductPageActionGroup.xml @@ -17,5 +17,6 @@ + From 48126f0458b6d493792089237cfed8ec88d1d15d Mon Sep 17 00:00:00 2001 From: pganapat Date: Tue, 5 Feb 2019 16:35:12 -0600 Subject: [PATCH 008/162] MC-5784: Image fields using imageUploader UIComponent cannot use gallery image - Modified File Model to suit Image-uploader config - Added coverage through MFTF MC-13832 --- .../Theme/Model/Design/Backend/File.php | 25 +++++++-- .../Mftf/Section/AdminDesignConfigSection.xml | 7 +++ .../Test/AdminMediaGalleryImageUploadTest.xml | 56 +++++++++++++++++++ 3 files changed, 83 insertions(+), 5 deletions(-) create mode 100644 app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml diff --git a/app/code/Magento/Theme/Model/Design/Backend/File.php b/app/code/Magento/Theme/Model/Design/Backend/File.php index b37628e54aa30..8bb73fbb35116 100644 --- a/app/code/Magento/Theme/Model/Design/Backend/File.php +++ b/app/code/Magento/Theme/Model/Design/Backend/File.php @@ -88,23 +88,27 @@ public function beforeSave() { $values = $this->getValue(); $value = reset($values) ?: []; - if (!isset($value['file'])) { + $file = $value['file'] ?? $value['name']; + if (!isset($file)) { throw new LocalizedException( __('%1 does not contain field \'file\'', $this->getData('field_config/field')) ); } if (isset($value['exists'])) { - $this->setValue($value['file']); + $this->setValue($file); return $this; } - $filename = basename($value['file']); + $filename = basename($file); + $relativeMediaUrl = $this->getRelativeMediaPath($value['url']); + $tmpMediaPath = $this->_mediaDirectory->isFile($relativeMediaUrl) ? + $relativeMediaUrl : $this->getTmpMediaPath($filename); $result = $this->_mediaDirectory->copyFile( - $this->getTmpMediaPath($filename), + $tmpMediaPath, $this->_getUploadDir() . '/' . $filename ); if ($result) { - $this->_mediaDirectory->delete($this->getTmpMediaPath($filename)); + $this->_mediaDirectory->delete($tmpMediaPath); if ($this->_addWhetherScopeInfo()) { $filename = $this->_prependScopeInfo($filename); } @@ -231,4 +235,15 @@ private function getMime() } return $this->mime; } + + /** + * Get Relative Media Path + * + * @param string $path + * @return string + */ + private function getRelativeMediaPath(string $path) + { + return str_replace('/pub/media', '', $path); + } } diff --git a/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml b/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml index 0aa2f7f35218a..3f548850b3c06 100644 --- a/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml +++ b/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml @@ -14,5 +14,12 @@ + + + + + + +
diff --git a/app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml b/app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml new file mode 100644 index 0000000000000..2cd74c53baa13 --- /dev/null +++ b/app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml @@ -0,0 +1,56 @@ + + + + + + + + + + <description value="Admin should be able to use Image Uploader to add Gallery Images"/> + <severity value="MAJOR"/> + <testCaseId value="MC-13832"/> + <group value="Content"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginToAdminArea"/> + </before> + <after> + <actionGroup ref="logout" stepKey="logoutOfAdmin"/> + </after> + <amOnPage url="{{DesignConfigPage.url}}" stepKey="navigateToDesignConfigPage" /> + <waitForPageLoad stepKey="waitForPageload1"/> + <click selector="{{AdminDesignConfigSection.scopeRow('3')}}" stepKey="editStoreView"/> + <waitForPageLoad stepKey="waitForPageload2"/> + <scrollTo selector="{{AdminDesignConfigSection.htmlHeaderSection}}" stepKey="scrollToHtmlHeadSection"/> + <click selector="{{AdminDesignConfigSection.htmlHeaderSection}}" stepKey="openHtmlHeadSection"/> + + <click selector="{{AdminDesignConfigSection.selectFromGalleryByFieldsetName('Head')}}" stepKey="openMediaGallery"/> + <wait time="3" stepKey="waitForAddingdSelectedImages"/> + <attachFile selector="{{AdminDesignConfigSection.imageUploadFromMediaGallery}}" userInput="adobe-base.jpg" stepKey="attachFile1"/> + <wait time="3" stepKey="waitForAddingSelectedImages"/> + <click selector="{{AdminDesignConfigSection.addSelectedFromMediaGallery}}" stepKey="addSelectedImages"/> + <waitForElementVisible selector="{{AdminDesignConfigSection.imageUploadPreviewByFieldsetName('Head')}}" stepKey="waitForPreviewImage"/> + <wait time="3" stepKey="waitForWrapperToClose"/> + <click selector="{{AdminDesignConfigSection.saveConfiguration}}" stepKey="saveConfiguration"/> + <waitForElementVisible selector="{{AdminDesignConfigSection.successNotification}}" stepKey="waitForSuccessNotification"/> + <waitForPageLoad stepKey="waitForPageloadSuccess"/> + + <click selector="{{AdminDesignConfigSection.scopeRow('3')}}" stepKey="editStoreView2"/> + <waitForPageLoad stepKey="waitForPageload3"/> + <scrollTo selector="{{AdminDesignConfigSection.htmlHeaderSection}}" stepKey="scrollToHtmlHeadSection2"/> + <click selector="{{AdminDesignConfigSection.htmlHeaderSection}}" stepKey="openHtmlHeadSection2"/> + + <click selector="{{AdminDesignConfigSection.useDefaultByFieldsetName('Head')}}" stepKey="clickUseDefault"/> + <waitForElementVisible selector="{{AdminDesignConfigSection.imageUploadPreviewByFieldsetName('Head')}}" stepKey="waitForPreviewImage2"/> + <click selector="{{AdminDesignConfigSection.saveConfiguration}}" stepKey="saveConfiguration2"/> + <waitForElementVisible selector="{{AdminDesignConfigSection.successNotification}}" stepKey="waitForSuccessNotification2"/> + <waitForPageLoad stepKey="waitForPageloadSuccess2"/> + </test> +</tests> From 7ce57eb86e068ece2c3caa212a3d41344252bfdb Mon Sep 17 00:00:00 2001 From: pganapat <prabhuramgr28493@gmail.com> Date: Wed, 6 Feb 2019 09:30:59 -0600 Subject: [PATCH 009/162] MC-5784: Image fields using imageUploader UIComponent cannot use gallery image - Fixed static, unit and mftf tests. --- app/code/Magento/Theme/Model/Design/Backend/File.php | 11 +++++++++-- .../Mftf/Test/AdminMediaGalleryImageUploadTest.xml | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Theme/Model/Design/Backend/File.php b/app/code/Magento/Theme/Model/Design/Backend/File.php index 8bb73fbb35116..74127484e23b4 100644 --- a/app/code/Magento/Theme/Model/Design/Backend/File.php +++ b/app/code/Magento/Theme/Model/Design/Backend/File.php @@ -22,6 +22,8 @@ use Magento\Theme\Model\Design\Config\FileUploader\FileProcessor; /** + * File Backend + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class File extends BackendFile @@ -88,7 +90,7 @@ public function beforeSave() { $values = $this->getValue(); $value = reset($values) ?: []; - $file = $value['file'] ?? $value['name']; + $file = $value['file'] ?? $value['name'] ?? null; if (!isset($file)) { throw new LocalizedException( __('%1 does not contain field \'file\'', $this->getData('field_config/field')) @@ -121,7 +123,10 @@ public function beforeSave() } /** - * @return array + * After Load + * + * @return File + * @throws LocalizedException */ public function afterLoad() { @@ -170,6 +175,8 @@ protected function getUploadDirPath($uploadDir) } /** + * Get Value + * * @return array */ public function getValue() diff --git a/app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml b/app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml index 2cd74c53baa13..de2363da3e7a5 100644 --- a/app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml +++ b/app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml @@ -49,6 +49,7 @@ <click selector="{{AdminDesignConfigSection.useDefaultByFieldsetName('Head')}}" stepKey="clickUseDefault"/> <waitForElementVisible selector="{{AdminDesignConfigSection.imageUploadPreviewByFieldsetName('Head')}}" stepKey="waitForPreviewImage2"/> + <wait time="3" stepKey="waitForWrapperToClose2"/> <click selector="{{AdminDesignConfigSection.saveConfiguration}}" stepKey="saveConfiguration2"/> <waitForElementVisible selector="{{AdminDesignConfigSection.successNotification}}" stepKey="waitForSuccessNotification2"/> <waitForPageLoad stepKey="waitForPageloadSuccess2"/> From 8bb2a3a4fd90914d12fd26204cb9490c6c044abe Mon Sep 17 00:00:00 2001 From: pganapat <prabhuramgr28493@gmail.com> Date: Wed, 6 Feb 2019 10:53:31 -0600 Subject: [PATCH 010/162] MC-5784: Image fields using imageUploader UIComponent cannot use gallery image - Fixed flaky mftf test. --- .../Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml b/app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml index de2363da3e7a5..f9f6e6b37c5dd 100644 --- a/app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml +++ b/app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml @@ -48,7 +48,6 @@ <click selector="{{AdminDesignConfigSection.htmlHeaderSection}}" stepKey="openHtmlHeadSection2"/> <click selector="{{AdminDesignConfigSection.useDefaultByFieldsetName('Head')}}" stepKey="clickUseDefault"/> - <waitForElementVisible selector="{{AdminDesignConfigSection.imageUploadPreviewByFieldsetName('Head')}}" stepKey="waitForPreviewImage2"/> <wait time="3" stepKey="waitForWrapperToClose2"/> <click selector="{{AdminDesignConfigSection.saveConfiguration}}" stepKey="saveConfiguration2"/> <waitForElementVisible selector="{{AdminDesignConfigSection.successNotification}}" stepKey="waitForSuccessNotification2"/> From 3f84d5fed87f4b02211d63d3a4700b1a368074eb Mon Sep 17 00:00:00 2001 From: Krissy Hiserote <khiserote@magento.com> Date: Fri, 8 Feb 2019 12:17:30 -0600 Subject: [PATCH 011/162] MC-5784: Image fields using imageUploader UIComponent cannot use gallery image - fix return type and mftf test --- .../Theme/Model/Design/Backend/File.php | 2 +- ...signConfigMediaGalleryImageUploadTest.xml} | 26 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) rename app/code/Magento/Theme/Test/Mftf/Test/{AdminMediaGalleryImageUploadTest.xml => AdminDesignConfigMediaGalleryImageUploadTest.xml} (75%) diff --git a/app/code/Magento/Theme/Model/Design/Backend/File.php b/app/code/Magento/Theme/Model/Design/Backend/File.php index 74127484e23b4..81217430c083f 100644 --- a/app/code/Magento/Theme/Model/Design/Backend/File.php +++ b/app/code/Magento/Theme/Model/Design/Backend/File.php @@ -249,7 +249,7 @@ private function getMime() * @param string $path * @return string */ - private function getRelativeMediaPath(string $path) + private function getRelativeMediaPath(string $path): string { return str_replace('/pub/media', '', $path); } diff --git a/app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml b/app/code/Magento/Theme/Test/Mftf/Test/AdminDesignConfigMediaGalleryImageUploadTest.xml similarity index 75% rename from app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml rename to app/code/Magento/Theme/Test/Mftf/Test/AdminDesignConfigMediaGalleryImageUploadTest.xml index f9f6e6b37c5dd..40b80be48efd3 100644 --- a/app/code/Magento/Theme/Test/Mftf/Test/AdminMediaGalleryImageUploadTest.xml +++ b/app/code/Magento/Theme/Test/Mftf/Test/AdminDesignConfigMediaGalleryImageUploadTest.xml @@ -8,7 +8,7 @@ <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> - <test name="AdminMediaGalleryImageUploadTest"> + <test name="AdminDesignConfigMediaGalleryImageUploadTest"> <annotations> <features value="Content"/> <stories value="Content"/> @@ -24,31 +24,35 @@ <after> <actionGroup ref="logout" stepKey="logoutOfAdmin"/> </after> + <!--Edit Store View--> + <comment userInput="Edit Store View" stepKey="editStoreViewComment"/> <amOnPage url="{{DesignConfigPage.url}}" stepKey="navigateToDesignConfigPage" /> <waitForPageLoad stepKey="waitForPageload1"/> <click selector="{{AdminDesignConfigSection.scopeRow('3')}}" stepKey="editStoreView"/> <waitForPageLoad stepKey="waitForPageload2"/> <scrollTo selector="{{AdminDesignConfigSection.htmlHeaderSection}}" stepKey="scrollToHtmlHeadSection"/> <click selector="{{AdminDesignConfigSection.htmlHeaderSection}}" stepKey="openHtmlHeadSection"/> - + <!--Upload Image--> + <comment userInput="Upload Image" stepKey="uploadImageComment"/> <click selector="{{AdminDesignConfigSection.selectFromGalleryByFieldsetName('Head')}}" stepKey="openMediaGallery"/> - <wait time="3" stepKey="waitForAddingdSelectedImages"/> - <attachFile selector="{{AdminDesignConfigSection.imageUploadFromMediaGallery}}" userInput="adobe-base.jpg" stepKey="attachFile1"/> - <wait time="3" stepKey="waitForAddingSelectedImages"/> - <click selector="{{AdminDesignConfigSection.addSelectedFromMediaGallery}}" stepKey="addSelectedImages"/> - <waitForElementVisible selector="{{AdminDesignConfigSection.imageUploadPreviewByFieldsetName('Head')}}" stepKey="waitForPreviewImage"/> - <wait time="3" stepKey="waitForWrapperToClose"/> + <actionGroup ref="VerifyMediaGalleryStorageActions" stepKey="VerifyMediaGalleryStorageBtn"/> + <actionGroup ref="attachImage" stepKey="SelectImageFromMediaStorage"> + <argument name="Image" value="ImageUpload3"/> + </actionGroup> + <actionGroup ref="saveImage" stepKey="insertImage"/> <click selector="{{AdminDesignConfigSection.saveConfiguration}}" stepKey="saveConfiguration"/> <waitForElementVisible selector="{{AdminDesignConfigSection.successNotification}}" stepKey="waitForSuccessNotification"/> <waitForPageLoad stepKey="waitForPageloadSuccess"/> - + <!--Edit Store View--> + <comment userInput="Edit Store View" stepKey="editStoreViewComment2"/> <click selector="{{AdminDesignConfigSection.scopeRow('3')}}" stepKey="editStoreView2"/> <waitForPageLoad stepKey="waitForPageload3"/> <scrollTo selector="{{AdminDesignConfigSection.htmlHeaderSection}}" stepKey="scrollToHtmlHeadSection2"/> <click selector="{{AdminDesignConfigSection.htmlHeaderSection}}" stepKey="openHtmlHeadSection2"/> - + <!--Save Default Configuration--> + <comment userInput="Save Default Configuration" stepKey="saveDefaultConfigurationComment"/> <click selector="{{AdminDesignConfigSection.useDefaultByFieldsetName('Head')}}" stepKey="clickUseDefault"/> - <wait time="3" stepKey="waitForWrapperToClose2"/> + <waitForElementVisible selector="{{AdminDesignConfigSection.saveConfiguration}}" stepKey="waitForWrapperToClose2"/> <click selector="{{AdminDesignConfigSection.saveConfiguration}}" stepKey="saveConfiguration2"/> <waitForElementVisible selector="{{AdminDesignConfigSection.successNotification}}" stepKey="waitForSuccessNotification2"/> <waitForPageLoad stepKey="waitForPageloadSuccess2"/> From 0b4ac19d8f199533ff1859877f649d124bb6af82 Mon Sep 17 00:00:00 2001 From: Krissy Hiserote <khiserote@magento.com> Date: Mon, 11 Feb 2019 12:26:50 -0600 Subject: [PATCH 012/162] MC-5784: Image fields using imageUploader UIComponent cannot use gallery image - save file to correct location --- .../Theme/Model/Design/Backend/File.php | 55 +++++++++++++------ 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/app/code/Magento/Theme/Model/Design/Backend/File.php b/app/code/Magento/Theme/Model/Design/Backend/File.php index 81217430c083f..820144c7f1cb1 100644 --- a/app/code/Magento/Theme/Model/Design/Backend/File.php +++ b/app/code/Magento/Theme/Model/Design/Backend/File.php @@ -101,23 +101,7 @@ public function beforeSave() return $this; } - $filename = basename($file); - $relativeMediaUrl = $this->getRelativeMediaPath($value['url']); - $tmpMediaPath = $this->_mediaDirectory->isFile($relativeMediaUrl) ? - $relativeMediaUrl : $this->getTmpMediaPath($filename); - $result = $this->_mediaDirectory->copyFile( - $tmpMediaPath, - $this->_getUploadDir() . '/' . $filename - ); - if ($result) { - $this->_mediaDirectory->delete($tmpMediaPath); - if ($this->_addWhetherScopeInfo()) { - $filename = $this->_prependScopeInfo($filename); - } - $this->setValue($filename); - } else { - $this->unsValue(); - } + $this->saveFile($value, $file); return $this; } @@ -251,6 +235,41 @@ private function getMime() */ private function getRelativeMediaPath(string $path): string { - return str_replace('/pub/media', '', $path); + return str_replace('/pub/media/', '', $path); + } + + /** + * Save file to the media directory in the correct location + * + * @param array $value + * @param string $file + * @throws LocalizedException + */ + private function saveFile(array $value, string $file) + { + $filename = basename($file); + $relativeMediaPath = $this->getRelativeMediaPath($value['url']); + $tmpMediaPath = $this->getTmpMediaPath($filename); + $mediaPath = $this->_mediaDirectory->isFile($relativeMediaPath) ? $relativeMediaPath : $tmpMediaPath; + $destinationMediaPath = $this->_getUploadDir() . '/' . $filename; + + $result = $mediaPath === $destinationMediaPath; + if (!$result) { + $result = $this->_mediaDirectory->copyFile( + $mediaPath, + $destinationMediaPath + ); + } + if ($result) { + if ($mediaPath === $tmpMediaPath) { + $this->_mediaDirectory->delete($mediaPath); + } + if ($this->_addWhetherScopeInfo()) { + $filename = $this->_prependScopeInfo($filename); + } + $this->setValue($filename); + } else { + $this->unsValue(); + } } } From 9f021b0a79e19d05a3fbb22c4146064c3a6b0997 Mon Sep 17 00:00:00 2001 From: Krissy Hiserote <khiserote@magento.com> Date: Tue, 12 Feb 2019 09:01:19 -0600 Subject: [PATCH 013/162] MC-5784: Image fields using imageUploader UIComponent cannot use gallery image - delete image in the MFTF test --- ...avigateToFaviconMediaFolderActionGroup.xml | 23 +++++++++++++++++++ .../Mftf/Section/AdminDesignConfigSection.xml | 5 ++++ ...esignConfigMediaGalleryImageUploadTest.xml | 12 ++++++++++ 3 files changed, 40 insertions(+) create mode 100644 app/code/Magento/Theme/Test/Mftf/ActionGroup/NavigateToFaviconMediaFolderActionGroup.xml diff --git a/app/code/Magento/Theme/Test/Mftf/ActionGroup/NavigateToFaviconMediaFolderActionGroup.xml b/app/code/Magento/Theme/Test/Mftf/ActionGroup/NavigateToFaviconMediaFolderActionGroup.xml new file mode 100644 index 0000000000000..6b98686574321 --- /dev/null +++ b/app/code/Magento/Theme/Test/Mftf/ActionGroup/NavigateToFaviconMediaFolderActionGroup.xml @@ -0,0 +1,23 @@ +<?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="NavigateToFaviconMediaFolderActionGroup"> + <arguments> + <argument name="StoreFolder" type="string"/> + </arguments> + <conditionalClick selector="{{MediaGallerySection.StorageRootArrow}}" dependentSelector="{{MediaGallerySection.checkIfArrowExpand}}" stepKey="clickArrowIfClosed" visible="true"/> + <waitForElement selector="{{AdminDesignConfigSection.faviconArrow}}" stepKey="waitForFaviconFolder"/> + <conditionalClick selector="{{AdminDesignConfigSection.faviconArrow}}" dependentSelector="{{AdminDesignConfigSection.checkIfFaviconArrowExpand}}" stepKey="clickFaviconArrowIfClosed" visible="true"/> + <waitForElement selector="{{AdminDesignConfigSection.storesArrow}}" stepKey="waitForStoresFolder"/> + <conditionalClick selector="{{AdminDesignConfigSection.storesArrow}}" dependentSelector="{{AdminDesignConfigSection.checkIfStoresArrowExpand}}" stepKey="clickStoresArrowIfClosed" visible="true"/> + <waitForElement selector="{{StoreFolder}}" stepKey="waitForStoreFolder"/> + <click selector="{{StoreFolder}}" stepKey="clickOnCreatedFolder"/> + <waitForLoadingMaskToDisappear stepKey="waitForLoading"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml b/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml index ceb5556b2673d..c2652f33f7606 100644 --- a/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml +++ b/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml @@ -26,5 +26,10 @@ <element name="logoUpload" type ="input" selector="[name='email_logo']" /> <element name="logoWrapperOpen" type ="text" selector="[data-index='email'] [data-state-collapsible ='closed']"/> <element name="logoPreview" type ="text" selector="[alt ='magento-logo.png']"/> + <element name="faviconArrow" type="button" selector="#ZmF2aWNvbg-- > .jstree-icon" /> + <element name="checkIfFaviconArrowExpand" type="button" selector="//li[@id='ZmF2aWNvbg--' and contains(@class,'jstree-closed')]" /> + <element name="storesArrow" type="button" selector="#ZmF2aWNvbi9zdG9yZXM- > .jstree-icon" /> + <element name="checkIfStoresArrowExpand" type="button" selector="//li[@id='ZmF2aWNvbi9zdG9yZXM-' and contains(@class,'jstree-closed')]" /> + <element name="storeLink" type="button" selector="#ZmF2aWNvbi9zdG9yZXMvMQ-- > a"/> </section> </sections> diff --git a/app/code/Magento/Theme/Test/Mftf/Test/AdminDesignConfigMediaGalleryImageUploadTest.xml b/app/code/Magento/Theme/Test/Mftf/Test/AdminDesignConfigMediaGalleryImageUploadTest.xml index 40b80be48efd3..c896c29f42a30 100644 --- a/app/code/Magento/Theme/Test/Mftf/Test/AdminDesignConfigMediaGalleryImageUploadTest.xml +++ b/app/code/Magento/Theme/Test/Mftf/Test/AdminDesignConfigMediaGalleryImageUploadTest.xml @@ -36,6 +36,9 @@ <comment userInput="Upload Image" stepKey="uploadImageComment"/> <click selector="{{AdminDesignConfigSection.selectFromGalleryByFieldsetName('Head')}}" stepKey="openMediaGallery"/> <actionGroup ref="VerifyMediaGalleryStorageActions" stepKey="VerifyMediaGalleryStorageBtn"/> + <actionGroup ref="NavigateToFaviconMediaFolderActionGroup" stepKey="NavigateToFolder"> + <argument name="StoreFolder" value="{{AdminDesignConfigSection.storeLink}}"/> + </actionGroup> <actionGroup ref="attachImage" stepKey="SelectImageFromMediaStorage"> <argument name="Image" value="ImageUpload3"/> </actionGroup> @@ -56,5 +59,14 @@ <click selector="{{AdminDesignConfigSection.saveConfiguration}}" stepKey="saveConfiguration2"/> <waitForElementVisible selector="{{AdminDesignConfigSection.successNotification}}" stepKey="waitForSuccessNotification2"/> <waitForPageLoad stepKey="waitForPageloadSuccess2"/> + <!--Delete Image--> + <comment userInput="Delete Image" stepKey="deleteImageComment"/> + <actionGroup ref="navigateToMediaGallery" stepKey="navigateToMediaGallery"/> + <actionGroup ref="NavigateToFaviconMediaFolderActionGroup" stepKey="NavigateToFolder2"> + <argument name="StoreFolder" value="{{AdminDesignConfigSection.storeLink}}"/> + </actionGroup> + <actionGroup ref="DeleteImageFromStorageActionGroup" stepKey="DeleteImageFromStorage"> + <argument name="Image" value="ImageUpload3"/> + </actionGroup> </test> </tests> From 04acd7b84086c6d423b394c44472645400e20b8e Mon Sep 17 00:00:00 2001 From: Krissy Hiserote <khiserote@magento.com> Date: Tue, 12 Feb 2019 12:00:16 -0600 Subject: [PATCH 014/162] MC-5784: Image fields using imageUploader UIComponent cannot use gallery image --- .../Theme/Model/Design/Backend/File.php | 15 +++++++------- ...esignConfigMediaGalleryImageUploadTest.xml | 20 ++++++++++++------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/app/code/Magento/Theme/Model/Design/Backend/File.php b/app/code/Magento/Theme/Model/Design/Backend/File.php index 820144c7f1cb1..511fe30f79dcd 100644 --- a/app/code/Magento/Theme/Model/Design/Backend/File.php +++ b/app/code/Magento/Theme/Model/Design/Backend/File.php @@ -90,6 +90,8 @@ public function beforeSave() { $values = $this->getValue(); $value = reset($values) ?: []; + + // Need to check name when it is uploaded in the media gallary $file = $value['file'] ?? $value['name'] ?? null; if (!isset($file)) { throw new LocalizedException( @@ -101,7 +103,7 @@ public function beforeSave() return $this; } - $this->saveFile($value, $file); + $this->updateMediaDirectory(basename($file), $value['url']); return $this; } @@ -239,16 +241,15 @@ private function getRelativeMediaPath(string $path): string } /** - * Save file to the media directory in the correct location + * Move file to the correct media directory * - * @param array $value - * @param string $file + * @param string $filename + * @param string $url * @throws LocalizedException */ - private function saveFile(array $value, string $file) + private function updateMediaDirectory(string $filename, string $url) { - $filename = basename($file); - $relativeMediaPath = $this->getRelativeMediaPath($value['url']); + $relativeMediaPath = $this->getRelativeMediaPath($url); $tmpMediaPath = $this->getTmpMediaPath($filename); $mediaPath = $this->_mediaDirectory->isFile($relativeMediaPath) ? $relativeMediaPath : $tmpMediaPath; $destinationMediaPath = $this->_getUploadDir() . '/' . $filename; diff --git a/app/code/Magento/Theme/Test/Mftf/Test/AdminDesignConfigMediaGalleryImageUploadTest.xml b/app/code/Magento/Theme/Test/Mftf/Test/AdminDesignConfigMediaGalleryImageUploadTest.xml index c896c29f42a30..f46328ac151b1 100644 --- a/app/code/Magento/Theme/Test/Mftf/Test/AdminDesignConfigMediaGalleryImageUploadTest.xml +++ b/app/code/Magento/Theme/Test/Mftf/Test/AdminDesignConfigMediaGalleryImageUploadTest.xml @@ -35,11 +35,11 @@ <!--Upload Image--> <comment userInput="Upload Image" stepKey="uploadImageComment"/> <click selector="{{AdminDesignConfigSection.selectFromGalleryByFieldsetName('Head')}}" stepKey="openMediaGallery"/> - <actionGroup ref="VerifyMediaGalleryStorageActions" stepKey="VerifyMediaGalleryStorageBtn"/> - <actionGroup ref="NavigateToFaviconMediaFolderActionGroup" stepKey="NavigateToFolder"> - <argument name="StoreFolder" value="{{AdminDesignConfigSection.storeLink}}"/> + <actionGroup ref="VerifyMediaGalleryStorageActions" stepKey="verifyMediaGalleryStorageBtn"/> + <actionGroup ref="NavigateToMediaFolderActionGroup" stepKey="navigateToFolder"> + <argument name="FolderName" value="Storage Root"/> </actionGroup> - <actionGroup ref="attachImage" stepKey="SelectImageFromMediaStorage"> + <actionGroup ref="attachImage" stepKey="selectImageFromMediaStorage"> <argument name="Image" value="ImageUpload3"/> </actionGroup> <actionGroup ref="saveImage" stepKey="insertImage"/> @@ -59,13 +59,19 @@ <click selector="{{AdminDesignConfigSection.saveConfiguration}}" stepKey="saveConfiguration2"/> <waitForElementVisible selector="{{AdminDesignConfigSection.successNotification}}" stepKey="waitForSuccessNotification2"/> <waitForPageLoad stepKey="waitForPageloadSuccess2"/> - <!--Delete Image--> + <!--Delete Image: will be in both root and favicon--> <comment userInput="Delete Image" stepKey="deleteImageComment"/> <actionGroup ref="navigateToMediaGallery" stepKey="navigateToMediaGallery"/> - <actionGroup ref="NavigateToFaviconMediaFolderActionGroup" stepKey="NavigateToFolder2"> + <actionGroup ref="NavigateToMediaFolderActionGroup" stepKey="navigateToFolder2"> + <argument name="FolderName" value="Storage Root"/> + </actionGroup> + <actionGroup ref="DeleteImageFromStorageActionGroup" stepKey="deleteImageFromStorage"> + <argument name="Image" value="ImageUpload3"/> + </actionGroup> + <actionGroup ref="NavigateToFaviconMediaFolderActionGroup" stepKey="navigateToFolder3"> <argument name="StoreFolder" value="{{AdminDesignConfigSection.storeLink}}"/> </actionGroup> - <actionGroup ref="DeleteImageFromStorageActionGroup" stepKey="DeleteImageFromStorage"> + <actionGroup ref="DeleteImageFromStorageActionGroup" stepKey="deleteImageFromStorage2"> <argument name="Image" value="ImageUpload3"/> </actionGroup> </test> From 6ae859aaa233261b03a6bccf946dccdb369926b6 Mon Sep 17 00:00:00 2001 From: AleksLi <aleksliwork@gmail.com> Date: Sun, 17 Feb 2019 19:32:44 +0100 Subject: [PATCH 015/162] magento/magento2#12396: Total Amount cart rule without tax - Added new condition type to give user opportunity to choose the configuration. --- app/code/Magento/SalesRule/Model/Rule/Condition/Address.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/SalesRule/Model/Rule/Condition/Address.php b/app/code/Magento/SalesRule/Model/Rule/Condition/Address.php index 89ec2b84572fc..cf6301cb31a9c 100644 --- a/app/code/Magento/SalesRule/Model/Rule/Condition/Address.php +++ b/app/code/Magento/SalesRule/Model/Rule/Condition/Address.php @@ -61,6 +61,7 @@ public function __construct( public function loadAttributeOptions() { $attributes = [ + 'base_subtotal_with_discount' => __('Subtotal (Excl. Tax)'), 'base_subtotal' => __('Subtotal'), 'total_qty' => __('Total Items Quantity'), 'weight' => __('Total Weight'), From 05aa8c5c06fde2fc7b5b77c6487a0e107feadbdf Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Tue, 19 Feb 2019 10:11:39 -0600 Subject: [PATCH 016/162] MAGETWO-98151: Add support ZooKeeper locks --- app/etc/di.xml | 2 +- .../Framework/Lock/Backend/Zookeeper.php | 185 ++++++++++++++++++ .../Magento/Framework/Lock/Factory.php | 90 +++++++++ lib/internal/Magento/Framework/Lock/Proxy.php | 80 ++++++++ 4 files changed, 356 insertions(+), 1 deletion(-) create mode 100644 lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php create mode 100644 lib/internal/Magento/Framework/Lock/Factory.php create mode 100644 lib/internal/Magento/Framework/Lock/Proxy.php diff --git a/app/etc/di.xml b/app/etc/di.xml index 19543375aad58..d74377b6194c3 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -38,7 +38,7 @@ <preference for="Magento\Framework\Locale\ListsInterface" type="Magento\Framework\Locale\TranslatedLists" /> <preference for="Magento\Framework\Locale\AvailableLocalesInterface" type="Magento\Framework\Locale\Deployed\Codes" /> <preference for="Magento\Framework\Locale\OptionInterface" type="Magento\Framework\Locale\Deployed\Options" /> - <preference for="Magento\Framework\Lock\LockManagerInterface" type="Magento\Framework\Lock\Backend\Database" /> + <preference for="Magento\Framework\Lock\LockManagerInterface" type="Magento\Framework\Lock\Proxy" /> <preference for="Magento\Framework\Api\AttributeTypeResolverInterface" type="Magento\Framework\Reflection\AttributeTypeResolver" /> <preference for="Magento\Framework\Api\Search\SearchResultInterface" type="Magento\Framework\Api\Search\SearchResult" /> <preference for="Magento\Framework\Api\Search\SearchCriteriaInterface" type="Magento\Framework\Api\Search\SearchCriteria"/> diff --git a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php new file mode 100644 index 0000000000000..20f4dd26b8a08 --- /dev/null +++ b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php @@ -0,0 +1,185 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Lock\Backend; + +use Magento\Framework\Lock\LockManagerInterface; +use Magento\Framework\Exception\RuntimeException; +use Magento\Framework\Phrase; + +/** + * LockManager using the Zookeeper for locks + */ +class Zookeeper implements LockManagerInterface +{ + /** + * Zookeeper provider + * + * @var \Zookeeper + */ + private $zookeeper; + + /** + * The base path to locks in Zookeeper + * + * @var string + */ + private $path; + + /** + * The host to connect to Zookeeper + * + * @var string + */ + private $host; + + /** + * How many seconds to wait before timing out on connections + * + * @var int + */ + private $connectionTimeout = 2; + + /** + * How many microseconds to wait before recheck connections or nodes + * + * @var float + */ + private $sleepCycle = 100000; + + /** + * The default permissions for Zookeeper nodes + * + * @var array + */ + private $acl = [['perms'=>\Zookeeper::PERM_ALL, 'scheme' => 'world', 'id' => 'anyone']]; + + /** + * @param string $host The host to connect to Zookeeper + * @param string $path The base path to locks in Zookeeper + * @throws RuntimeException + */ + public function __construct(string $host, string $path = '/magento/locks') + { + if (empty($path)) { + throw new RuntimeException( + new Phrase('The path needs to be a non-empty string.') + ); + } + + $this->host = $host; + $this->path = preg_replace('#\/*$#', '', $path) ?: '/'; + } + + /** + * {@inheritdoc} + * @throws RuntimeException + */ + public function lock(string $name, int $timeout = -1): bool + { + $skipDeadline = $timeout < 0; + $lockPath = $this->getFullPathToLock($name); + $deadline = microtime(true) + $timeout; + + while($this->getProvider()->exists($lockPath)) { + if (!$skipDeadline && $deadline <= microtime(true)) { + return false; + } + + usleep($this->sleepCycle); + } + + if (!$this->getProvider()->create($lockPath, '1', $this->acl, \Zookeeper::EPHEMERAL)) { + throw new RuntimeException(new Phrase('Failed creating lock %1', [$lockPath])); + } else { + return true; + } + } + + /** + * @inheritdoc + */ + public function unlock(string $name): bool + { + $lockPath = $this->getFullPathToLock($name); + + if (!$this->getProvider()->exists($lockPath)) { + return true; + } + + return $this->getProvider()->delete($lockPath); + } + + /** + * @inheritdoc + */ + public function isLocked(string $name): bool + { + return (bool) $this->getProvider()->exists($this->getFullPathToLock($name)); + } + + /** + * Gets full path to lock by its name + * + * @param string $name + * @return string + */ + private function getFullPathToLock(string $name): string + { + return $this->path . '/' . $name; + } + + /** + * Initiolizes and returns Zookeeper provider + * + * @return \Zookeeper + * @throws RuntimeException + */ + private function getProvider(): \Zookeeper + { + if (!$this->zookeeper) { + $this->zookeeper = new \Zookeeper($this->host); + + $deadline = microtime(true) + $this->connectionTimeout; + while($this->zookeeper->getState() != \Zookeeper::CONNECTED_STATE) { + if ($deadline <= microtime(true)) { + throw new RuntimeException(new Phrase('Zookeeper connection timed out!')); + } + usleep($this->sleepCycle); + } + + if (!$this->createBasePath($this->path)) { + throw new RuntimeException(new Phrase('Failed creating base path %1', [$this->path])); + } + } + + return $this->zookeeper; + } + + /** + * Checks and creates base path recursively + * + * @param $path + * @return bool + */ + private function createBasePath($path) + { + if ($this->zookeeper->exists($path)) { + return true; + } + + if (!$this->createBasePath(dirname($path))) { + return false; + } + + if ($this->zookeeper->create($path, '1', $this->acl)) { + return true; + } + + return $this->zookeeper->exists($path); + } +} diff --git a/lib/internal/Magento/Framework/Lock/Factory.php b/lib/internal/Magento/Framework/Lock/Factory.php new file mode 100644 index 0000000000000..1414358ae42e9 --- /dev/null +++ b/lib/internal/Magento/Framework/Lock/Factory.php @@ -0,0 +1,90 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Lock; + +use Magento\Framework\Phrase; +use Magento\Framework\Exception\RuntimeException; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\App\DeploymentConfig; +use Magento\Framework\Lock\Backend\Database as DatabaseLock; +use Magento\Framework\Lock\Backend\Zookeeper as ZookeeperLock; + +/** + * The factory to create object that implements LockManagerInterface + */ +class Factory +{ + /** + * The Object Manager instance + * + * @var ObjectManagerInterface + */ + private $objectManager; + + /** + * The Application deployment configuration + * + * @var DeploymentConfig + */ + private $deploymentConfig; + + /** + * DB lock provider name + * + * @const string + */ + const LOCK_DB = 'db'; + + /** + * Zookeeper lock provider name + * + * @const string + */ + const LOCK_ZOOKEEPER = 'zookeeper'; + + /** + * The list of lock providers with mapping on classes + * + * @var array + */ + private $lockers = [ + self::LOCK_DB => DatabaseLock::class, + self::LOCK_ZOOKEEPER => ZookeeperLock::class + ]; + + + /** + * @param ObjectManagerInterface $objectManager The Object Manager instance + * @param DeploymentConfig $deploymentConfig The Application deployment configuration + */ + public function __construct( + ObjectManagerInterface $objectManager, + DeploymentConfig $deploymentConfig + ) { + $this->objectManager = $objectManager; + $this->deploymentConfig = $deploymentConfig; + } + + /** + * Creates an instance of LockManagerInterface using information from deployment config + * + * @return LockManagerInterface + * @throws RuntimeException + */ + public function create(): LockManagerInterface + { + $provider = $this->deploymentConfig->get('locks/provider', self::LOCK_DB); + $config = $this->deploymentConfig->get('locks/config', []); + + if (!isset($this->lockers[$provider])) { + throw new RuntimeException(new Phrase('Unknown locks provider.')); + } + + return $this->objectManager->create($this->lockers[$provider], $config); + } +} diff --git a/lib/internal/Magento/Framework/Lock/Proxy.php b/lib/internal/Magento/Framework/Lock/Proxy.php new file mode 100644 index 0000000000000..e140078d05ab8 --- /dev/null +++ b/lib/internal/Magento/Framework/Lock/Proxy.php @@ -0,0 +1,80 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Lock; + +use Magento\Framework\Exception\RuntimeException; + +/** + * Proxy for LockManagers + */ +class Proxy implements LockManagerInterface +{ + /** + * The factory to create LockManagerInterface implementation + * + * @var Factory + */ + private $factory; + + /** + * A LockManagerInterface implementation + * + * @var LockManagerInterface + */ + private $locker; + + /** + * @param Factory $factory The factory to create LockManagerInterface implementation + */ + public function __construct(Factory $factory) + { + $this->factory = $factory; + } + + /** + * {@inheritdoc} + * @throws RuntimeException + */ + public function isLocked(string $name): bool + { + return $this->getLocker()->isLocked($name); + } + + /** + * {@inheritdoc} + * @throws RuntimeException + */ + public function lock(string $name, int $timeout = -1): bool + { + return $this->getLocker()->lock($name, $timeout); + } + + /** + * {@inheritdoc} + * @throws RuntimeException + */ + public function unlock(string $name): bool + { + return $this->getLocker()->unlock($name); + } + + /** + * Gets LockManagerInterface implementation using Factory + * + * @return LockManagerInterface + * @throws RuntimeException + */ + private function getLocker(): LockManagerInterface + { + if (!$this->locker) { + $this->locker = $this->factory->create(); + } + + return $this->locker; + } +} From 7b352ce6c6b2ac0f4e1edf5bdd0d58a346eba3e3 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Tue, 19 Feb 2019 14:48:17 -0600 Subject: [PATCH 017/162] MAGETWO-98151: Add support ZooKeeper locks --- .../Framework/Lock/Backend/Zookeeper.php | 133 ++++++++++++++---- .../{Factory.php => LockBackendFactory.php} | 2 +- lib/internal/Magento/Framework/Lock/Proxy.php | 6 +- .../Framework/Lock/Test/Unit/ProxyTest.php | 106 ++++++++++++++ 4 files changed, 215 insertions(+), 32 deletions(-) rename lib/internal/Magento/Framework/Lock/{Factory.php => LockBackendFactory.php} (98%) create mode 100644 lib/internal/Magento/Framework/Lock/Test/Unit/ProxyTest.php diff --git a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php index 20f4dd26b8a08..d813f209ab96e 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php @@ -30,6 +30,11 @@ class Zookeeper implements LockManagerInterface */ private $path; + /** + * @var string + */ + private $lockName = 'lock-'; + /** * The host to connect to Zookeeper * @@ -58,6 +63,13 @@ class Zookeeper implements LockManagerInterface */ private $acl = [['perms'=>\Zookeeper::PERM_ALL, 'scheme' => 'world', 'id' => 'anyone']]; + /** + * The mapping list of the lock name with the full lock path + * + * @var array + */ + private $locks = []; + /** * @param string $host The host to connect to Zookeeper * @param string $path The base path to locks in Zookeeper @@ -77,6 +89,9 @@ public function __construct(string $host, string $path = '/magento/locks') /** * {@inheritdoc} + * You can see the lock algorithm by the link + * @link https://zookeeper.apache.org/doc/r3.1.2/recipes.html#sc_recipes_Locks + * * @throws RuntimeException */ public function lock(string $name, int $timeout = -1): bool @@ -85,19 +100,29 @@ public function lock(string $name, int $timeout = -1): bool $lockPath = $this->getFullPathToLock($name); $deadline = microtime(true) + $timeout; - while($this->getProvider()->exists($lockPath)) { + if (!$this->checkAndCreateParentNode($lockPath)) { + throw new RuntimeException(new Phrase('Failed creating the path %1', [$lockPath])); + } + + $lockKey = $this->getProvider() + ->create($lockPath, '1', $this->acl, \Zookeeper::EPHEMERAL | \Zookeeper::SEQUENCE); + + if (!$lockKey) { + throw new RuntimeException(new Phrase('Failed creating lock %1', [$lockPath])); + } + + while($this->isAnyLock($lockKey, $this->getIndex($lockKey))) { if (!$skipDeadline && $deadline <= microtime(true)) { + $this->getProvider()->delete($lockKey); return false; } usleep($this->sleepCycle); } - if (!$this->getProvider()->create($lockPath, '1', $this->acl, \Zookeeper::EPHEMERAL)) { - throw new RuntimeException(new Phrase('Failed creating lock %1', [$lockPath])); - } else { - return true; - } + $this->locks[$name] = $lockKey; + + return true; } /** @@ -105,13 +130,11 @@ public function lock(string $name, int $timeout = -1): bool */ public function unlock(string $name): bool { - $lockPath = $this->getFullPathToLock($name); - - if (!$this->getProvider()->exists($lockPath)) { + if (!isset($this->locks[$name])) { return true; } - return $this->getProvider()->delete($lockPath); + return $this->getProvider()->delete($this->locks[$name]); } /** @@ -119,7 +142,7 @@ public function unlock(string $name): bool */ public function isLocked(string $name): bool { - return (bool) $this->getProvider()->exists($this->getFullPathToLock($name)); + return $this->isAnyLock($this->getFullPathToLock($name)); } /** @@ -130,7 +153,7 @@ public function isLocked(string $name): bool */ private function getFullPathToLock(string $name): string { - return $this->path . '/' . $name; + return $this->path . '/' . $name . '/' . $this->lockName; } /** @@ -143,18 +166,14 @@ private function getProvider(): \Zookeeper { if (!$this->zookeeper) { $this->zookeeper = new \Zookeeper($this->host); + } - $deadline = microtime(true) + $this->connectionTimeout; - while($this->zookeeper->getState() != \Zookeeper::CONNECTED_STATE) { - if ($deadline <= microtime(true)) { - throw new RuntimeException(new Phrase('Zookeeper connection timed out!')); - } - usleep($this->sleepCycle); - } - - if (!$this->createBasePath($this->path)) { - throw new RuntimeException(new Phrase('Failed creating base path %1', [$this->path])); + $deadline = microtime(true) + $this->connectionTimeout; + while($this->zookeeper->getState() != \Zookeeper::CONNECTED_STATE) { + if ($deadline <= microtime(true)) { + throw new RuntimeException(new Phrase('Zookeeper connection timed out!')); } + usleep($this->sleepCycle); } return $this->zookeeper; @@ -163,23 +182,81 @@ private function getProvider(): \Zookeeper /** * Checks and creates base path recursively * - * @param $path + * @param string $path * @return bool + * @throws RuntimeException */ - private function createBasePath($path) + private function checkAndCreateParentNode(string $path): bool { - if ($this->zookeeper->exists($path)) { + $path = dirname($path); + if ($this->getProvider()->exists($path)) { return true; } - if (!$this->createBasePath(dirname($path))) { + if (!$this->checkAndCreateParentNode($path)) { return false; } - if ($this->zookeeper->create($path, '1', $this->acl)) { + if ($this->getProvider()->create($path, '1', $this->acl)) { return true; } - return $this->zookeeper->exists($path); + return $this->getProvider()->exists($path); + } + + /** + * Gets int increment of lock key + * + * @param string $key + * @return int|null + */ + private function getIndex(string $key) + { + if (!preg_match("/[0-9]+$/", $key, $matches)) + return null; + + return intval($matches[0]); + } + + /** + * Checks if there is any sequence node under parent of $fullKey. + * At first checks that the $fullKey node is present, if not - returns false. + * + * If $indexKey is non-null and there is a smaller index that $indexKey then returns true, + * if all the nodes are larger than $indexKey then returns false. + * + * @param string $fullKey The full path without any sequence info + * @param int|null $indexKey The index to compare + * @return bool + * @throws RuntimeException + */ + private function isAnyLock(string $fullKey, int $indexKey = null): bool + { + $parent = dirname($fullKey); + + if (!$this->getProvider()->exists($parent)) { + return false; + } + + $children = $this->getProvider()->getChildren($parent); + + foreach($children as $childKey) { + + if (is_null($indexKey)) { + return true; + } + + $childIndex = $this->getIndex($childKey); + + if (is_null($childIndex)) { + continue; + } + + if ($childIndex < $indexKey) { + return true; + } + } + + return false; } } diff --git a/lib/internal/Magento/Framework/Lock/Factory.php b/lib/internal/Magento/Framework/Lock/LockBackendFactory.php similarity index 98% rename from lib/internal/Magento/Framework/Lock/Factory.php rename to lib/internal/Magento/Framework/Lock/LockBackendFactory.php index 1414358ae42e9..4c4896cb35623 100644 --- a/lib/internal/Magento/Framework/Lock/Factory.php +++ b/lib/internal/Magento/Framework/Lock/LockBackendFactory.php @@ -17,7 +17,7 @@ /** * The factory to create object that implements LockManagerInterface */ -class Factory +class LockBackendFactory { /** * The Object Manager instance diff --git a/lib/internal/Magento/Framework/Lock/Proxy.php b/lib/internal/Magento/Framework/Lock/Proxy.php index e140078d05ab8..b5f8eee0f2c4f 100644 --- a/lib/internal/Magento/Framework/Lock/Proxy.php +++ b/lib/internal/Magento/Framework/Lock/Proxy.php @@ -17,7 +17,7 @@ class Proxy implements LockManagerInterface /** * The factory to create LockManagerInterface implementation * - * @var Factory + * @var LockBackendFactory */ private $factory; @@ -29,9 +29,9 @@ class Proxy implements LockManagerInterface private $locker; /** - * @param Factory $factory The factory to create LockManagerInterface implementation + * @param LockBackendFactory $factory The factory to create LockManagerInterface implementation */ - public function __construct(Factory $factory) + public function __construct(LockBackendFactory $factory) { $this->factory = $factory; } diff --git a/lib/internal/Magento/Framework/Lock/Test/Unit/ProxyTest.php b/lib/internal/Magento/Framework/Lock/Test/Unit/ProxyTest.php new file mode 100644 index 0000000000000..c71dad701d715 --- /dev/null +++ b/lib/internal/Magento/Framework/Lock/Test/Unit/ProxyTest.php @@ -0,0 +1,106 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Lock\Test\Unit; + +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\MockObject\MockObject; +use Magento\Framework\Lock\Proxy; +use Magento\Framework\Lock\LockBackendFactory; +use Magento\Framework\Lock\LockManagerInterface; + +/** + * @inheritdoc + */ +class ProxyTest extends TestCase +{ + /** + * @var LockBackendFactory|MockObject + */ + private $factoryMock; + + /** + * @var LockManagerInterface|MockObject + */ + private $lockerMock; + + /** + * @var Proxy + */ + private $proxy; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->factoryMock = $this->createMock(LockBackendFactory::class); + $this->lockerMock = $this->getMockForAbstractClass(LockManagerInterface::class); + $this->proxy = new Proxy($this->factoryMock); + } + + /** + * @return void + */ + public function testIsLocked() + { + $lockName = 'testLock'; + $this->factoryMock->expects($this->once()) + ->method('create') + ->willReturn($this->lockerMock); + $this->lockerMock->expects($this->exactly(2)) + ->method('isLocked') + ->with($lockName) + ->willReturn(true); + + $this->assertTrue($this->proxy->isLocked($lockName)); + + // Call one more time to check that method Factory::create is called one time + $this->assertTrue($this->proxy->isLocked($lockName)); + } + + /** + * @return void + */ + public function testLock() + { + $lockName = 'testLock'; + $timeout = 123; + $this->factoryMock->expects($this->once()) + ->method('create') + ->willReturn($this->lockerMock); + $this->lockerMock->expects($this->exactly(2)) + ->method('lock') + ->with($lockName, $timeout) + ->willReturn(true); + + $this->assertTrue($this->proxy->lock($lockName, $timeout)); + + // Call one more time to check that method Factory::create is called one time + $this->assertTrue($this->proxy->lock($lockName, $timeout)); + } + + /** + * @return void + */ + public function testUnlock() + { + $lockName = 'testLock'; + $this->factoryMock->expects($this->once()) + ->method('create') + ->willReturn($this->lockerMock); + $this->lockerMock->expects($this->exactly(2)) + ->method('unlock') + ->with($lockName) + ->willReturn(true); + + $this->assertTrue($this->proxy->unlock($lockName)); + + // Call one more time to check that method Factory::create is called one time + $this->assertTrue($this->proxy->unlock($lockName)); + } +} From 974a6a53ca7d5ad237654468177d182ff1972b4d Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Tue, 19 Feb 2019 15:34:35 -0600 Subject: [PATCH 018/162] MAGETWO-98151: Add support ZooKeeper locks --- lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php | 2 +- lib/internal/Magento/Framework/Lock/LockBackendFactory.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php index d813f209ab96e..884353eb63e5f 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php @@ -131,7 +131,7 @@ public function lock(string $name, int $timeout = -1): bool public function unlock(string $name): bool { if (!isset($this->locks[$name])) { - return true; + return false; } return $this->getProvider()->delete($this->locks[$name]); diff --git a/lib/internal/Magento/Framework/Lock/LockBackendFactory.php b/lib/internal/Magento/Framework/Lock/LockBackendFactory.php index 4c4896cb35623..ab839a6594a67 100644 --- a/lib/internal/Magento/Framework/Lock/LockBackendFactory.php +++ b/lib/internal/Magento/Framework/Lock/LockBackendFactory.php @@ -57,7 +57,6 @@ class LockBackendFactory self::LOCK_ZOOKEEPER => ZookeeperLock::class ]; - /** * @param ObjectManagerInterface $objectManager The Object Manager instance * @param DeploymentConfig $deploymentConfig The Application deployment configuration From 38ef69db1bc29ec157ab9401a2a1eed548f70485 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Wed, 20 Feb 2019 11:32:24 -0600 Subject: [PATCH 019/162] MAGETWO-98151: Add support ZooKeeper locks --- .../Lock/Test/Unit/LockBackendFactoryTest.php | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php diff --git a/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php b/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php new file mode 100644 index 0000000000000..cf8444dc0a0ba --- /dev/null +++ b/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php @@ -0,0 +1,96 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Lock\Test\Unit; + +use Magento\Framework\Lock\Backend\Database as DatabaseLock; +use Magento\Framework\Lock\Backend\Zookeeper as ZookeeperLock; +use Magento\Framework\Lock\LockBackendFactory; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Lock\LockManagerInterface; +use Magento\Framework\App\DeploymentConfig; +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\MockObject\MockObject; + +class LockBackendFactoryTest extends TestCase +{ + /** + * @var ObjectManagerInterface|MockObject + */ + private $objectManagerMock; + + /** + * @var DeploymentConfig|MockObject + */ + private $deploymentConfigMock; + + /** + * @var LockBackendFactory + */ + private $factory; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->objectManagerMock = $this->getMockForAbstractClass(ObjectManagerInterface::class); + $this->deploymentConfigMock = $this->createMock(DeploymentConfig::class); + $this->factory = new LockBackendFactory($this->objectManagerMock, $this->deploymentConfigMock); + } + + /** + * @expectedException \Magento\Framework\Exception\RuntimeException + * @expectedExceptionMessage Unknown locks provider. + */ + public function testCreateWithException() + { + $this->deploymentConfigMock->expects($this->exactly(2)) + ->method('get') + ->withConsecutive(['locks/provider', LockBackendFactory::LOCK_DB], ['locks/config', []]) + ->willReturnOnConsecutiveCalls('someProvider', []); + + $this->factory->create(); + } + + /** + * @param string $lockProvider + * @param string $lockProviderClass + * @param array $config + * @dataProvider createDataProvider + */ + public function testCreate(string $lockProvider, string $lockProviderClass, array $config) + { + $lockManagerMock = $this->getMockForAbstractClass(LockManagerInterface::class); + $this->deploymentConfigMock->expects($this->exactly(2)) + ->method('get') + ->withConsecutive(['locks/provider', LockBackendFactory::LOCK_DB], ['locks/config', []]) + ->willReturnOnConsecutiveCalls($lockProvider, $config); + $this->objectManagerMock->expects($this->once()) + ->method('create') + ->with($lockProviderClass, $config) + ->willReturn($lockManagerMock); + + $this->assertSame($lockManagerMock, $this->factory->create()); + } + + public function createDataProvider(): array + { + return [ + [ + 'lockProvider' => LockBackendFactory::LOCK_DB, + 'lockProviderClass' => DatabaseLock::class, + 'config' => ['prefix' => 'somePrefix'], + ], + [ + 'lockProvider' => LockBackendFactory::LOCK_ZOOKEEPER, + 'lockProviderClass' => ZookeeperLock::class, + 'config' => ['host' => 'some host'], + ], + ]; + } +} From 0f3c125972654768727dfa130c8badfd49e8cd68 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Wed, 20 Feb 2019 12:07:26 -0600 Subject: [PATCH 020/162] MAGETWO-98151: Add support ZooKeeper locks --- lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php index 884353eb63e5f..02e2739545696 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php @@ -126,7 +126,8 @@ public function lock(string $name, int $timeout = -1): bool } /** - * @inheritdoc + * {@inheritdoc} + * @throws RuntimeException */ public function unlock(string $name): bool { @@ -138,7 +139,8 @@ public function unlock(string $name): bool } /** - * @inheritdoc + * {@inheritdoc} + * @throws RuntimeException */ public function isLocked(string $name): bool { From 9accdd4f278c999c3e1d7b005708494c738f5187 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Wed, 20 Feb 2019 15:35:22 -0600 Subject: [PATCH 021/162] MAGETWO-98151: Add support ZooKeeper locks --- .../testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php | 0 lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php | 2 +- .../Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php | 0 3 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php create mode 100644 lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php diff --git a/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php b/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php index 02e2739545696..d19ba0dd947b0 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php @@ -242,7 +242,7 @@ private function isAnyLock(string $fullKey, int $indexKey = null): bool $children = $this->getProvider()->getChildren($parent); - foreach($children as $childKey) { + foreach ($children as $childKey) { if (is_null($indexKey)) { return true; diff --git a/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php b/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php new file mode 100644 index 0000000000000..e69de29bb2d1d From ba4f6baaea9cf2740f8e0c87ac2af192958742ce Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Wed, 20 Feb 2019 15:37:06 -0600 Subject: [PATCH 022/162] MAGETWO-98151: Add support ZooKeeper locks --- .../Lock/Test/Unit/Backend/ZookeeperTest.php | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php b/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php index e69de29bb2d1d..c004179aa524a 100644 --- a/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php +++ b/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Lock\Test\Unit\Backend; + +use Magento\Framework\Lock\Backend\Zookeeper as ZookeeperProvider; +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\MockObject\MockObject; + +class ZookeeperTest extends TestCase +{ + /** + * @var \Zookeeper|MockObject + */ + private $zookeeperMock; + + /** + * @var ZookeeperProvider + */ + private $zookeeperProvider; + + /** + * @var string + */ + private $host = 'localhost:123'; + + /** + * @var string + */ + private $path = '/some/path'; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->zookeeperProvider = new ZookeeperProvider($this->host, '/some/path/'); + } + + /** + * @expectedException \Magento\Framework\Exception\RuntimeException + * @expectedExceptionMessage The path needs to be a non-empty string. + */ + public function testConstructionWithException() + { + $this->zookeeperProvider = new ZookeeperProvider('some host', ''); + } + + +} From d1752d3cab4d04af1e1bbcf1b968450ed9c735eb Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Wed, 20 Feb 2019 16:00:40 -0600 Subject: [PATCH 023/162] MAGETWO-98151: Add support ZooKeeper locks --- lib/internal/Magento/Framework/Lock/LockBackendFactory.php | 4 ++++ .../Framework/Lock/Test/Unit/Backend/ZookeeperTest.php | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Lock/LockBackendFactory.php b/lib/internal/Magento/Framework/Lock/LockBackendFactory.php index ab839a6594a67..e2119ca3eee11 100644 --- a/lib/internal/Magento/Framework/Lock/LockBackendFactory.php +++ b/lib/internal/Magento/Framework/Lock/LockBackendFactory.php @@ -84,6 +84,10 @@ public function create(): LockManagerInterface throw new RuntimeException(new Phrase('Unknown locks provider.')); } + if (self::LOCK_ZOOKEEPER === $provider && !extension_loaded(self::LOCK_ZOOKEEPER)) { + throw new RuntimeException(new Phrase('php extension Zookeeper is not installed.')); + } + return $this->objectManager->create($this->lockers[$provider], $config); } } diff --git a/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php b/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php index c004179aa524a..c22c49d3427c5 100644 --- a/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php +++ b/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php @@ -38,6 +38,9 @@ class ZookeeperTest extends TestCase */ protected function setUp() { + if (!extension_loaded('zookeeper')) { + $this->markTestSkipped('Test was skipped because php extension Zookeeper is not installed.'); + } $this->zookeeperProvider = new ZookeeperProvider($this->host, '/some/path/'); } @@ -49,6 +52,4 @@ public function testConstructionWithException() { $this->zookeeperProvider = new ZookeeperProvider('some host', ''); } - - } From 7710c226f8b5a193aedda196e34d14e3a13f96af Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Wed, 20 Feb 2019 16:18:23 -0600 Subject: [PATCH 024/162] MAGETWO-98151: Add support ZooKeeper locks --- .../Lock/Test/Unit/LockBackendFactoryTest.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php b/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php index cf8444dc0a0ba..f3b141e9f902b 100644 --- a/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php +++ b/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php @@ -78,19 +78,27 @@ public function testCreate(string $lockProvider, string $lockProviderClass, arra $this->assertSame($lockManagerMock, $this->factory->create()); } + /** + * @return array + */ public function createDataProvider(): array { - return [ - [ + $data = [ + 'db' => [ 'lockProvider' => LockBackendFactory::LOCK_DB, 'lockProviderClass' => DatabaseLock::class, 'config' => ['prefix' => 'somePrefix'], ], - [ + ]; + + if (extension_loaded('zookeeper')) { + $data['zookeeper'] = [ 'lockProvider' => LockBackendFactory::LOCK_ZOOKEEPER, 'lockProviderClass' => ZookeeperLock::class, 'config' => ['host' => 'some host'], - ], - ]; + ]; + } + + return $data; } } From 5c93ba2d7924291e704032969b9b9390cdc7fcca Mon Sep 17 00:00:00 2001 From: Kavitha <kanair@adobe.com> Date: Mon, 25 Feb 2019 12:25:56 -0600 Subject: [PATCH 025/162] MC-4903: Convert UpdateProductUrlRewriteEntityTest to MFTF --- .../AdminUrlRewriteActionGroup.xml | 13 +++++ .../AdminUrlRewriteGridActionGroup.xml | 14 ++++++ .../Test/Mftf/Data/UrlRewriteData.xml | 27 +++++++++++ .../Test/Mftf/MetaData/url_rewrite-meta.xml | 20 ++++++++ ...tUrlRewriteAndAddTemporaryRedirectTest.xml | 48 +++++++++++++++++++ 5 files changed, 122 insertions(+) create mode 100644 app/code/Magento/UrlRewrite/Test/Mftf/Data/UrlRewriteData.xml create mode 100644 app/code/Magento/UrlRewrite/Test/Mftf/MetaData/url_rewrite-meta.xml create mode 100644 app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateProductUrlRewriteAndAddTemporaryRedirectTest.xml diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml index 71475acd8b066..5886b40c4547b 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml @@ -75,4 +75,17 @@ <click selector="{{AdminUrlRewriteEditSection.saveButton}}" stepKey="clickOnSaveButton"/> <seeElement selector="{{AdminUrlRewriteIndexSection.successMessage}}" stepKey="seeSuccessSaveMessage"/> </actionGroup> + <actionGroup name="AdminUpdateUrlRewrite"> + <arguments> + <argument name="requestPath" type="string"/> + <argument name="redirectTypeValue" type="string"/> + <argument name="description" type="string"/> + </arguments> + <fillField selector="{{AdminUrlRewriteEditSection.requestPath}}" userInput="{{requestPath}}" stepKey="fillRequestPath"/> + <click selector="{{AdminUrlRewriteEditSection.redirectType}}" stepKey="selectRedirectType"/> + <click selector="{{AdminUrlRewriteEditSection.redirectTypeValue('redirectTypeValue')}}" stepKey="selectRedirectTypeValue"/> + <fillField selector="{{AdminUrlRewriteEditSection.description}}" userInput="{{description}}" stepKey="fillDescription"/> + <click selector="{{AdminUrlRewriteEditSection.saveButton}}" stepKey="clickOnSaveButton"/> + <seeElement selector="{{AdminUrlRewriteIndexSection.successMessage}}" stepKey="seeSuccessSaveMessage"/> + </actionGroup> </actionGroups> diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteGridActionGroup.xml b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteGridActionGroup.xml index f053d18e79c3e..221dd7f9d316e 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteGridActionGroup.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteGridActionGroup.xml @@ -72,4 +72,18 @@ <waitForPageLoad stepKey="waitForPageToLoad3"/> <see selector="{{AdminUrlRewriteIndexSection.successMessage}}" userInput="You deleted the URL rewrite." stepKey="seeSuccessMessage"/> </actionGroup> + <actionGroup name="AdminSearchAndSelectUrlRewriteInGrid"> + <arguments> + <argument name="requestPath" type="string"/> + </arguments> + <amOnPage url="{{AdminUrlRewriteIndexPage.url}}" stepKey="openUrlRewriteEditPage"/> + <waitForPageLoad stepKey="waitForUrlRewriteEditPageToLoad"/> + <click selector="{{AdminUrlRewriteIndexSection.resetButton}}" stepKey="clickOnResetButton"/> + <waitForPageLoad stepKey="waitForPageToLoad"/> + <fillField selector="{{AdminUrlRewriteIndexSection.requestPathFilter}}" userInput="{{requestPath}}" stepKey="fillRedirectPathFilter"/> + <click selector="{{AdminUrlRewriteIndexSection.searchButton}}" stepKey="clickOnSearchButton"/> + <waitForPageLoad stepKey="waitForPageToLoad1"/> + <click selector="{{AdminUrlRewriteIndexSection.editButton('1')}}" stepKey="clickOnEditButton"/> + <waitForPageLoad stepKey="waitForEditPageToLoad"/> + </actionGroup> </actionGroups> \ No newline at end of file diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Data/UrlRewriteData.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Data/UrlRewriteData.xml new file mode 100644 index 0000000000000..942882be259f9 --- /dev/null +++ b/app/code/Magento/UrlRewrite/Test/Mftf/Data/UrlRewriteData.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="defaultUrlRewrite" type="urlRewrite"> + <data key="request_path" unique="prefix">test-test-test.html</data> + <data key="target_path">http://www.example.com/</data> + <data key="redirect_type">302</data> + <data key="redirect_type_label">Temporary (302)</data> + <data key="store_id">1</data> + <data key="store">Default Store View</data> + </entity> + <entity name="updateUrlRewrite" type="urlRewrite"> + <data key="request_path" unique="prefix">test-aspx-test.aspx</data> + <data key="target_path">http://www.example.com/</data> + <data key="redirect_type">302</data> + <data key="redirect_type_label">Temporary (302)</data> + <data key="store_id">1</data> + <data key="store">Default Store View</data> + </entity> +</entities> \ No newline at end of file diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/MetaData/url_rewrite-meta.xml b/app/code/Magento/UrlRewrite/Test/Mftf/MetaData/url_rewrite-meta.xml new file mode 100644 index 0000000000000..84cf00ac08999 --- /dev/null +++ b/app/code/Magento/UrlRewrite/Test/Mftf/MetaData/url_rewrite-meta.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd"> + <operation name="CreateUrlRewrite" dataType="urlRewrite" type="create" auth="adminFormKey" url="/admin/url_rewrite/save/" method="POST" successRegex="/messages-message-success/"> + <!--<object key="urlRewrite" dataType="urlRewrite">--> + <field key="store_id">integer</field> + <field key="redirect_type">integer</field> + <field key="request_path">string</field> + <field key="target_path">string</field> + <field key="description">string</field> + <!--</object>--> + </operation> +</operations> \ No newline at end of file diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateProductUrlRewriteAndAddTemporaryRedirectTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateProductUrlRewriteAndAddTemporaryRedirectTest.xml new file mode 100644 index 0000000000000..cbb3680f37345 --- /dev/null +++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateProductUrlRewriteAndAddTemporaryRedirectTest.xml @@ -0,0 +1,48 @@ +<?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="AdminUpdateProductUrlRewriteAndAddTemporaryRedirectTest"> + <annotations> + <stories value="Update URL rewrite"/> + <title value="Update Product URL Rewrites"/> + <description value="Login as Admin and update product UrlRewrite and add Temporary redirect type "/> + <testCaseId value="MC-5351"/> + <severity value="CRITICAL"/> + <group value="mtf_migrated"/> + </annotations> + + <before> + <createData entity="defaultSimpleProduct" stepKey="createProduct"/> + <actionGroup ref="LoginAsAdmin" stepKey="login"/> + </before> + <after> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Search and Select Edit option for created product in grid --> + <actionGroup ref="AdminSearchAndSelectUrlRewriteInGrid" stepKey="editUrlRewrite"> + <argument name="requestPath" value="$$createProduct.name$$"/> + </actionGroup> + + <!-- Open UrlRewrite Edit page and update the fields --> + <actionGroup ref="AdminUpdateUrlRewrite" stepKey="updateCategoryUrlRewrite"> + <argument name="requestPath" value="{{defaultUrlRewrite.request_path}}"/> + <argument name="redirectTypeValue" value="Temporary (302)"/> + <argument name="description" value="Update Product Url Rewrite"/> + </actionGroup> + + <!-- Assert product Url Rewrite in StoreFront --> + <actionGroup ref="AssertStorefrontProductRedirect" stepKey="assertProductUrlRewriteInStoreFront"> + <argument name="productName" value="$$createProduct.name$$"/> + <argument name="productSku" value="$$createProduct.sku$$"/> + <argument name="productRequestPath" value="{{defaultUrlRewrite.request_path}}"/> + </actionGroup> + </test> +</tests> From c695c007c3a1d0b3fa0511204e4ef8347e485e26 Mon Sep 17 00:00:00 2001 From: Kavitha <kanair@adobe.com> Date: Mon, 25 Feb 2019 16:26:27 -0600 Subject: [PATCH 026/162] MC-4455: Convert CreateDuplicateUrlProductEntity to MFTF --- .../ActionGroup/AdminProductActionGroup.xml | 25 +++++++++++++++ .../Test/AdminCreateDuplicateProductTest.xml | 31 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateProductTest.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml index 3afdc41888c79..d2d95d811c43d 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml @@ -430,4 +430,29 @@ <click selector="{{AdminAddUpSellProductsModalSection.AddSelectedProductsButton}}" stepKey="addRelatedProductSelected"/> <waitForPageLoad stepKey="waitForPageToLoad1"/> </actionGroup> + <actionGroup name="createDuplicateProduct"> + <arguments> + <argument name="product" defaultValue="$$createSimpleProduct$$" /> + <argument name="quantity" defaultValue="defaultSimpleProduct.quantity"/> + </arguments> + <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="openProductIndexPage"/> + <waitForPageLoad stepKey="waitForProductIndexPageToLoad"/> + <click selector="{{AdminProductGridActionSection.addProductBtn}}" stepKey="clickOnAddNewProduct"/> + <waitForPageLoad stepKey="waitForPageToLoad"/> + <fillField selector="{{AdminProductFormSection.productName}}" userInput="{{product.name}}" stepKey="fillProductName"/> + <fillField selector="{{AdminProductFormSection.productSku}}" userInput="{{product.sku}}" stepKey="fillProductSku"/> + <fillField selector="{{AdminProductFormSection.productPrice}}" userInput="{{product.price}}" stepKey="fillProductPrice"/> + <fillField selector="{{AdminProductFormSection.productQuantity}}" userInput="{{quantity}}" stepKey="fillProductQty"/> + <selectOption selector="{{AdminProductFormSection.productStockStatus}}" userInput="{{product.status}}" stepKey="selectStockStatus"/> + <selectOption selector="{{AdminProductFormSection.productWeightSelect}}" userInput="This item has weight" stepKey="selectWeight"/> + <fillField selector="{{AdminProductFormSection.productWeight}}" userInput="{{product.weight}}" stepKey="fillProductWeight"/> + <scrollTo selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="scrollToSectionHeader"/> + <click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="openSeoSection"/> + <fillField userInput="{{product.custom_attributes[url_key]}}" selector="{{AdminProductSEOSection.urlKeyInput}}" stepKey="fillUrlKey"/> + <scrollToTopOfPage stepKey="scrollTopPageProduct"/> + <waitForElementVisible selector="{{AdminProductFormActionSection.saveButton}}" stepKey="waitForSaveProductButton" /> + <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveProduct"/> + <waitForPageLoad stepKey="waitForProductToSave"/> + <see selector="{{AdminProductFormSection.successMessage}}" userInput="The value specified in the URL Key field would generate a URL that already exists." stepKey="seeErrorMessage"/> + </actionGroup> </actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateProductTest.xml new file mode 100644 index 0000000000000..81a0916be6e77 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateProductTest.xml @@ -0,0 +1,31 @@ +<?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="AdminCreateDuplicateProductTest"> + <annotations> + <stories value="Create Product"/> + <title value="CreateDuplicateUrlProductEntityTestVariation1"/> + <description value="Login as admin and create duplicate Product"/> + <testCaseId value="MC-14714"/> + <severity value="CRITICAL"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + <actionGroup ref="LoginAsAdmin" stepKey="login"/> + <createData entity="defaultSimpleProduct" stepKey="createSimpleProduct"/> + </before> + <after> + <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> + </after> + + <!-- Create duplicate Product and Save the Product --> + <actionGroup ref="createDuplicateProduct" stepKey="createDuplicateProduct"/> + </test> +</tests> From 692afe768d22bb4c5b536eec06b7fa802e394529 Mon Sep 17 00:00:00 2001 From: Kavitha <kanair@adobe.com> Date: Tue, 26 Feb 2019 10:25:42 -0600 Subject: [PATCH 027/162] MC-4454: Convert CreateDuplicateUrlCategoryEntityTest to MFTF --- .../ActionGroup/AdminCategoryActionGroup.xml | 13 ++++++ .../Section/AdminCategoryMessagesSection.xml | 1 + .../Test/AdminCreateDuplicateCategoryTest.xml | 40 +++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateCategoryTest.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml index 86986265bae2c..c658e8b359f81 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml @@ -275,4 +275,17 @@ <waitForPageLoad stepKey="waitForPageToLoad"/> <waitForElementVisible selector="{{AdminCategoryContentSection.categoryPageTitle}}" stepKey="waitForCategoryTitle"/> </actionGroup> + <actionGroup name="adminFillAndSaveCategoryForm"> + <arguments> + <argument name="category" type="string"/> + </arguments> + <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="$$category.name$$" stepKey="enterCategoryName"/> + <scrollTo selector="{{AdminCategorySEOSection.SectionHeader}}" stepKey="scrollToSearchEngineOptimization"/> + <click selector="{{AdminCategorySEOSection.SectionHeader}}" stepKey="openSEO"/> + <waitForPageLoad stepKey="waitForPageToLoad"/> + <fillField selector="{{AdminCategorySEOSection.UrlKeyInput}}" userInput="$$category.custom_attributes[url_key]$$" stepKey="enterURLKey"/> + <scrollToTopOfPage stepKey="scrollToTheTopOfPage"/> + <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategory"/> + <waitForPageLoad stepKey="waitForPageToLoad1"/> + </actionGroup> </actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryMessagesSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryMessagesSection.xml index fee86ca1caa29..ea4f4bf53eb71 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryMessagesSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategoryMessagesSection.xml @@ -10,5 +10,6 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminCategoryMessagesSection"> <element name="SuccessMessage" type="text" selector=".message-success"/> + <element name="errorMessage" type="text" selector="//div[@class='message message-error error']"/> </section> </sections> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateCategoryTest.xml new file mode 100644 index 0000000000000..4865e3a89b67a --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateCategoryTest.xml @@ -0,0 +1,40 @@ +<?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="AdminCreateDuplicateCategoryTest"> + <annotations> + <stories value="Create category"/> + <title value="CreateDuplicateUrlCategoryEntityTestVariation1_Subcategory_RequiredFields"/> + <description value="Login as admin and create duplicate category"/> + <testCaseId value="MC-14702"/> + <severity value="CRITICAL"/> + <group value="mtf_migrated"/> + </annotations> + + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginToAdminPanel"/> + <createData entity="SimpleSubCategory" stepKey="category"/> + </before> + <after> + <deleteData createDataKey="category" stepKey="deleteCategory"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Open Category Page and select Add category --> + <actionGroup ref="goToCreateCategoryPage" stepKey="goToCategoryPage"/> + + <!-- Fill the Category form with same name and urlKey as initially created category(SimpleSubCategory) --> + <actionGroup ref="adminFillAndSaveCategoryForm" stepKey="fillCategoryForm"> + <argument name="category" value="category"/> + </actionGroup> + + <!-- Assert error message --> + <see selector="{{AdminCategoryMessagesSection.errorMessage}}" userInput="The value specified in the URL Key field would generate a URL that already exists." stepKey="seeErrorMessage"/> + </test> +</tests> From caabef2fe931aa69b4955ff8265afa52cb61a361 Mon Sep 17 00:00:00 2001 From: Adarsh Khatri <me.adarshkhatri@gmail.com> Date: Wed, 27 Feb 2019 17:14:44 +1100 Subject: [PATCH 028/162] Update price-bundle.js By default tier price is sorted by "price_id". With this tier price calculation while displaying in bundle product is wrong. Need to sort tier price by "price_qty". Issue created: https://github.com/magento/magento2/issues/21467 --- app/code/Magento/Bundle/view/base/web/js/price-bundle.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js index e56cc6f32d804..a832390b83dc7 100644 --- a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js +++ b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js @@ -375,6 +375,11 @@ define([ var tiers = optionConfig.tierPrice, magicKey = _.keys(oneItemPrice)[0], lowest = false; + + //sorting based on "price_qty" + tiers.sort(function(a, b) { + return a.price_qty - b.price_qty; + }); _.each(tiers, function (tier, index) { if (tier['price_qty'] > qty) { From 4c1c65303c3b60de437cb84d882b16718f2f085a Mon Sep 17 00:00:00 2001 From: Adarsh Khatri <me.adarshkhatri@gmail.com> Date: Wed, 27 Feb 2019 19:28:16 +1100 Subject: [PATCH 029/162] Update price-bundle.js By default tier price is sorted by "price_id". With this tier price calculation while displaying in bundle product is wrong. Need to sort tier price by "price_qty". --- app/code/Magento/Bundle/view/base/web/js/price-bundle.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js index a832390b83dc7..d298c4d6845f0 100644 --- a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js +++ b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js @@ -377,9 +377,11 @@ define([ lowest = false; //sorting based on "price_qty" - tiers.sort(function(a, b) { - return a.price_qty - b.price_qty; - }); + if(tiers){ + tiers.sort(function (a, b) { + return a.price_qty - b.price_qty; + }); + } _.each(tiers, function (tier, index) { if (tier['price_qty'] > qty) { From 64b296e967a916cc4b335f2e10f758fd3dedfc6b Mon Sep 17 00:00:00 2001 From: Maria Kovdrysh <kovdrysh@adobe.com> Date: Wed, 27 Feb 2019 11:22:03 -0600 Subject: [PATCH 030/162] MC-4426: Convert ExportProductsTest to MFTF --- .../Mftf/Data/CatalogSpecialPriceData.xml | 20 +++ .../Metadata/catalog_special_price-meta.xml | 22 +++ .../ActionGroup/AdminExportActionGroup.xml | 58 ++++++++ .../Test/AdminExportBundleProductTest.xml | 120 +++++++++++++++++ ...portGroupedProductWithSpecialPriceTest.xml | 84 ++++++++++++ ...figurableProductsWithCustomOptionsTest.xml | 111 +++++++++++++++ ...igurableProductsWithAssignedImagesTest.xml | 127 ++++++++++++++++++ ...ableProductAssignedToCustomWebsiteTest.xml | 109 +++++++++++++++ ...rtSimpleProductWithCustomAttributeTest.xml | 61 +++++++++ .../Section/AdminExportAttributeSection.xml | 6 + 10 files changed, 718 insertions(+) create mode 100644 app/code/Magento/Catalog/Test/Mftf/Data/CatalogSpecialPriceData.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/Metadata/catalog_special_price-meta.xml create mode 100644 app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml create mode 100644 app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportBundleProductTest.xml create mode 100644 app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportGroupedProductWithSpecialPriceTest.xml create mode 100644 app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleAndConfigurableProductsWithCustomOptionsTest.xml create mode 100644 app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAndConfigurableProductsWithAssignedImagesTest.xml create mode 100644 app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAssignedToMainWebsiteAndConfigurableProductAssignedToCustomWebsiteTest.xml create mode 100644 app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductWithCustomAttributeTest.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/CatalogSpecialPriceData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/CatalogSpecialPriceData.xml new file mode 100644 index 0000000000000..ab4cab2cda5aa --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Data/CatalogSpecialPriceData.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="specialProductPrice" type="catalogSpecialPrice"> + <data key="price">99.99</data> + <data key="store_id">0</data> + <var key="sku" entityType="product2" entityKey="sku" /> + </entity> + <entity name="specialProductPrice2" type="catalogSpecialPrice"> + <data key="price">55.55</data> + <data key="store_id">0</data> + <var key="sku" entityType="product" entityKey="sku" /> + </entity> +</entities> \ No newline at end of file diff --git a/app/code/Magento/Catalog/Test/Mftf/Metadata/catalog_special_price-meta.xml b/app/code/Magento/Catalog/Test/Mftf/Metadata/catalog_special_price-meta.xml new file mode 100644 index 0000000000000..27c9d2ede0f4b --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Metadata/catalog_special_price-meta.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd"> + <operation name="catalogSpecialPrice" dataType="catalogSpecialPrice" type="create" auth="adminOauth" url="/V1/products/special-price" method="POST"> + <contentType>application/json</contentType> + <object key="prices" dataType="catalogSpecialPrice"> + <object dataType="catalogSpecialPrice" key="0"> + <field key="price">number</field> + <field key="store_id">integer</field> + <field key="sku">string</field> + <field key="price_from">string</field> + <field key="price_to">string</field> + </object> + </object> + </operation> +</operations> \ No newline at end of file diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml new file mode 100644 index 0000000000000..21b81648ea479 --- /dev/null +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml @@ -0,0 +1,58 @@ +<?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"> + + <!-- Export products using filtering by attribute --> + <actionGroup name="fillFilterExport"> + <arguments> + <argument name="attribute"/> + <argument name="attributeData"/> + </arguments> + <selectOption selector="{{AdminExportMainSection.entityType}}" userInput="Products" stepKey="selectProductsOption"/> + <waitForElementVisible selector="{{AdminExportMainSection.entityAttributes}}" stepKey="waitForElementVisible"/> + <scrollTo selector="{{AdminExportAttributeSection.chooseAttribute('attribute')}}" stepKey="scrollToAttribute" /> + <checkOption selector="{{AdminExportAttributeSection.chooseAttribute('attribute')}}" stepKey="selectAttribute"/> + <fillField selector="{{AdminExportAttributeSection.fillFilter('attribute')}}" userInput="{{attributeData}}" stepKey="setDataInField"/> + <waitForPageLoad stepKey="waitForUserInput"/> + <scrollTo selector="{{AdminExportAttributeSection.continueBtn}}" stepKey="scrollToContinue" /> + <click selector="{{AdminExportAttributeSection.continueBtn}}" stepKey="clickContinueButton"/> + <see selector="{{AdminMessagesSection.successMessage}}" userInput="Message is added to queue, wait to get your file soon" stepKey="seeSuccessMessage"/> + </actionGroup> + + <!-- Export products without filtering --> + <actionGroup name="exportAllProducts"> + <selectOption selector="{{AdminExportMainSection.entityType}}" userInput="Products" stepKey="selectProductsOption"/> + <waitForElementVisible selector="{{AdminExportMainSection.entityAttributes}}" stepKey="waitForElementVisible" time="5"/> + <scrollTo selector="{{AdminExportAttributeSection.continueBtn}}" stepKey="scrollToContinue"/> + <wait stepKey="waitForScroll" time="5"/> + <click selector="{{AdminExportAttributeSection.continueBtn}}" stepKey="clickContinueButton"/> + <wait stepKey="waitForClick" time="5"/> + <see selector="{{AdminMessagesSection.successMessage}}" userInput="Message is added to queue, wait to get your file soon" stepKey="seeSuccessMessage"/> + </actionGroup> + + <!-- Download first file in the grid --> + <actionGroup name="downloadProduct"> + <reloadPage stepKey="refreshPage"/> + <waitForPageLoad stepKey="waitFormReload"/> + <click stepKey="clickSelectBtn" selector="{{AdminExportAttributeSection.selectByIndex('0')}}"/> + <click stepKey="clickOnDownload" selector="{{AdminExportAttributeSection.download('0')}}" after="clickSelectBtn"/> + </actionGroup> + + <!-- Delete exported file --> + <actionGroup name="deleteExportedFile"> + <reloadPage stepKey="refreshPage"/> + <waitForPageLoad stepKey="waitFormReload"/> + <click stepKey="clickSelectBtn" selector="{{AdminExportAttributeSection.selectByIndex('0')}}"/> + <click stepKey="clickOnDownload" selector="{{AdminExportAttributeSection.delete('0')}}" after="clickSelectBtn"/> + <waitForElementVisible selector="{{AdminProductGridConfirmActionSection.title}}" stepKey="waitForConfirmModal"/> + <click selector="{{AdminProductGridConfirmActionSection.ok}}" stepKey="confirmProductDelete"/> + <see selector="{{AdminDataGridTableSection.dataGridEmpty}}" userInput="We couldn't find any records." stepKey="assertDataGridEmptyMessage"/> + </actionGroup> +</actionGroups> \ No newline at end of file diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportBundleProductTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportBundleProductTest.xml new file mode 100644 index 0000000000000..476e3756f55ca --- /dev/null +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportBundleProductTest.xml @@ -0,0 +1,120 @@ +<?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="AdminExportBundleProductTest"> + <annotations> + <features value="CatalogImportExport"/> + <stories value="Export products"/> + <title value="Export Bundle Product"/> + <description value="Admin should be able to export Bundle Product"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-14008"/> + <group value="catalog_import_export"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <!--Create bundle product with dynamic price with two simple products --> + <createData entity="SimpleProduct2" stepKey="firstSimpleProductForDynamic"/> + <createData entity="SimpleProduct2" stepKey="secondSimpleProductForDynamic"/> + <createData entity="ApiBundleProduct" stepKey="createDynamicBundleProduct"/> + <createData entity="DropDownBundleOption" stepKey="createFirstBundleOption"> + <requiredEntity createDataKey="createDynamicBundleProduct"/> + </createData> + <createData entity="ApiBundleLink" stepKey="firstLinkOptionToDynamicProduct"> + <requiredEntity createDataKey="createDynamicBundleProduct"/> + <requiredEntity createDataKey="createFirstBundleOption"/> + <requiredEntity createDataKey="firstSimpleProductForDynamic"/> + </createData> + <createData entity="ApiBundleLink" stepKey="secondLinkOptionToDynamicProduct"> + <requiredEntity createDataKey="createDynamicBundleProduct"/> + <requiredEntity createDataKey="createFirstBundleOption"/> + <requiredEntity createDataKey="secondSimpleProductForDynamic"/> + </createData> + + <!-- Create bundle product with fixed price with two simple products --> + <createData entity="SimpleProduct2" stepKey="firstSimpleProductForFixed"/> + <createData entity="SimpleProduct2" stepKey="secondSimpleProductForFixed"/> + <createData entity="ApiFixedBundleProduct" stepKey="createFixedBundleProduct"/> + <createData entity="DropDownBundleOption" stepKey="createSecondBundleOption"> + <requiredEntity createDataKey="createFixedBundleProduct"/> + </createData> + <createData entity="ApiBundleLink" stepKey="firstLinkOptionToFixedProduct"> + <requiredEntity createDataKey="createFixedBundleProduct"/> + <requiredEntity createDataKey="createSecondBundleOption"/> + <requiredEntity createDataKey="firstSimpleProductForFixed"/> + </createData> + <createData entity="ApiBundleLink" stepKey="secondLinkOptionToFixedProduct"> + <requiredEntity createDataKey="createFixedBundleProduct"/> + <requiredEntity createDataKey="createSecondBundleOption"/> + <requiredEntity createDataKey="secondSimpleProductForFixed"/> + </createData> + + <!-- Create bundle product with custom textarea attribute with two simple products --> + <createData entity="productAttributeWysiwyg" stepKey="createProductAttribute"/> + <createData entity="AddToDefaultSet" stepKey="addToDefaultAttributeSet"> + <requiredEntity createDataKey="createProductAttribute"/> + </createData> + <createData entity="ApiFixedBundleProduct" stepKey="createFixedBundleProductWithAttribute"> + <requiredEntity createDataKey="addToDefaultAttributeSet"/> + </createData> + <createData entity="SimpleProduct2" stepKey="firstSimpleProductForFixedWithAttribute"/> + <createData entity="SimpleProduct2" stepKey="secondSimpleProductForFixedWithAttribute"/> + <createData entity="DropDownBundleOption" stepKey="createBundleOptionWithAttribute"> + <requiredEntity createDataKey="createFixedBundleProductWithAttribute"/> + </createData> + <createData entity="ApiBundleLink" stepKey="firstLinkOptionToFixedProductWithAttribute"> + <requiredEntity createDataKey="createFixedBundleProductWithAttribute"/> + <requiredEntity createDataKey="createBundleOptionWithAttribute"/> + <requiredEntity createDataKey="firstSimpleProductForFixedWithAttribute"/> + </createData> + <createData entity="ApiBundleLink" stepKey="secondLinkOptionToFixedProductWithAttribute"> + <requiredEntity createDataKey="createFixedBundleProductWithAttribute"/> + <requiredEntity createDataKey="createBundleOptionWithAttribute"/> + <requiredEntity createDataKey="secondSimpleProductForFixedWithAttribute"/> + </createData> + + <!-- Login as admin --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + + <!-- Run cron twice --> + <magentoCLI command="cron:run" stepKey="runCron1"/> + <magentoCLI command="cron:run" stepKey="runCron2"/> + </before> + <after> + <!-- Delete exported file --> + <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"/> + + <!-- Delete products creations --> + <deleteData createDataKey="createDynamicBundleProduct" stepKey="deleteDynamicBundleProduct"/> + <deleteData createDataKey="firstSimpleProductForDynamic" stepKey="deleteFirstSimpleProductForDynamic"/> + <deleteData createDataKey="secondSimpleProductForDynamic" stepKey="deleteSecondSimpleProductForDynamic"/> + <deleteData createDataKey="createFixedBundleProduct" stepKey="deleteFixedBundleProduct"/> + <deleteData createDataKey="firstSimpleProductForFixed" stepKey="deleteFirstSimpleProductForFixed"/> + <deleteData createDataKey="secondSimpleProductForFixed" stepKey="deleteSecondSimpleProductForFixed"/> + <deleteData createDataKey="createFixedBundleProductWithAttribute" stepKey="deleteFixedBundleProductWithAttribute"/> + <deleteData createDataKey="firstSimpleProductForFixedWithAttribute" stepKey="deleteFirstSimpleProductForFixedWithAttribute"/> + <deleteData createDataKey="secondSimpleProductForFixedWithAttribute" stepKey="deleteSecondSimpleProductForFixedWithAttribute"/> + <deleteData createDataKey="createProductAttribute" stepKey="deleteProductAttribute"/> + + <!-- Log out --> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Go to export page --> + <amOnPage url="{{AdminExportIndexPage.url}}" stepKey="goToExportIndexPage"/> + <waitForPageLoad stepKey="waitForExportIndexPageLoad" time="10"/> + + <!-- Export created below products --> + <actionGroup ref="exportAllProducts" stepKey="exportCreatedProducts"/> + + <!-- Download product --> + <actionGroup ref="downloadProduct" stepKey="downloadCreatedProducts"/> + </test> +</tests> diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportGroupedProductWithSpecialPriceTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportGroupedProductWithSpecialPriceTest.xml new file mode 100644 index 0000000000000..adec5daddfeb0 --- /dev/null +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportGroupedProductWithSpecialPriceTest.xml @@ -0,0 +1,84 @@ +<?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="AdminExportGroupedProductWithSpecialPriceTest"> + <annotations> + <features value="CatalogImportExport"/> + <stories value="Export products"/> + <title value="Export grouped product with special price"/> + <description value="Admin should be able to export grouped product with special price"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-14009"/> + <group value="catalog_import_export"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <!-- Create first simple product and add special price --> + <createData entity="SimpleProduct2" stepKey="createFirstSimpleProduct"/> + <createData entity="specialProductPrice2" stepKey="specialPriceToFirstProduct"> + <requiredEntity createDataKey="createFirstSimpleProduct"/> + </createData> + + <!-- Create second simple product and add special price--> + <createData entity="SimpleProduct2" stepKey="createSecondSimpleProduct"/> + <createData entity="specialProductPrice2" stepKey="specialPriceToSecondProduct"> + <requiredEntity createDataKey="createSecondSimpleProduct"/> + </createData> + + <!-- Create category --> + <createData entity="_defaultCategory" stepKey="createCategory"/> + + <!-- Create group product with created below simple products --> + <createData entity="ApiGroupedProduct2" stepKey="createGroupedProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="OneSimpleProductLink" stepKey="addFirstProduct"> + <requiredEntity createDataKey="createGroupedProduct"/> + <requiredEntity createDataKey="createFirstSimpleProduct"/> + </createData> + <updateData entity="OneMoreSimpleProductLink" createDataKey="addFirstProduct" stepKey="addSecondProduct"> + <requiredEntity createDataKey="createGroupedProduct"/> + <requiredEntity createDataKey="createSecondSimpleProduct"/> + </updateData> + + <!-- Login as admin --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + + <!-- Run cron twice --> + <magentoCLI command="cron:run" stepKey="runCron1"/> + <magentoCLI command="cron:run" stepKey="runCron2"/> + </before> + <after> + <!-- Delete exported file --> + <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"/> + + <!-- Deleted created products --> + <deleteData createDataKey="createFirstSimpleProduct" stepKey="deleteFirstSimpleProduct"/> + <deleteData createDataKey="createSecondSimpleProduct" stepKey="deleteSecondSimpleProduct"/> + <deleteData createDataKey="createGroupedProduct" stepKey="deleteGroupedProduct"/> + + <!-- Delete category --> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + + <!-- Log out --> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Go to export page --> + <amOnPage url="{{AdminExportIndexPage.url}}" stepKey="goToExportIndexPage"/> + <waitForPageLoad stepKey="waitForExportIndexPageLoad"/> + + <!-- Export created below products --> + <actionGroup ref="exportAllProducts" stepKey="exportCreatedProducts"/> + + <!-- Download product --> + <actionGroup ref="downloadProduct" stepKey="downloadCreatedProducts"/> + </test> +</tests> diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleAndConfigurableProductsWithCustomOptionsTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleAndConfigurableProductsWithCustomOptionsTest.xml new file mode 100644 index 0000000000000..883cdab2951fd --- /dev/null +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleAndConfigurableProductsWithCustomOptionsTest.xml @@ -0,0 +1,111 @@ +<?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="AdminExportSimpleAndConfigurableProductsWithCustomOptionsTest"> + <annotations> + <features value="CatalogImportExport"/> + <stories value="Export products"/> + <title value="Export Simple and Configurable products with custom options"/> + <description value="Admin should be able to export Simple and Configurable products with custom options"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-14005"/> + <group value="catalog_import_export"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <!-- Create category --> + <createData entity="SimpleSubCategory" stepKey="createCategory"/> + + <!-- Create configurable product with two attributes --> + <createData entity="ApiConfigurableProduct" stepKey="createConfigProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/> + <createData entity="productAttributeOption1" stepKey="createConfigProductAttributeFirstOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="productAttributeOption2" stepKey="createConfigProductAttributeSecondOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeFirstOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + <getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeSecondOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + + <!-- Add custom options to configurable product --> + <updateData createDataKey="createConfigProduct" entity="productWithOptions" stepKey="updateProductWithOptions"/> + + <!-- Create two simple product which will be the part of configurable product --> + <createData entity="ApiSimpleOne" stepKey="createConfigFirstChildProduct"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeFirstOption"/> + </createData> + <createData entity="ApiSimpleTwo" stepKey="createConfigSecondChildProduct"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeSecondOption"/> + </createData> + <createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeFirstOption"/> + <requiredEntity createDataKey="getConfigAttributeSecondOption"/> + </createData> + + <!-- Add created below children products to configurable product --> + <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddFirstChild"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigFirstChildProduct"/> + </createData> + <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddSecondChild"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigSecondChildProduct"/> + </createData> + + <!-- Login as admin --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + + <!-- Run cron twice --> + <magentoCLI command="cron:run" stepKey="runCron1"/> + <magentoCLI command="cron:run" stepKey="runCron2"/> + </before> + <after> + <!-- Delete exported file --> + <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"/> + + <!-- Delete configurable product creation --> + <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> + <deleteData createDataKey="createConfigFirstChildProduct" stepKey="deleteConfigFirstChildProduct"/> + <deleteData createDataKey="createConfigSecondChildProduct" stepKey="deleteConfigSecondChildProduct"/> + <deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + + <!-- Log out --> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Go to export page --> + <amOnPage url="{{AdminExportIndexPage.url}}" stepKey="goToExportIndexPage"/> + <waitForPageLoad stepKey="waitForExportIndexPageLoad"/> + + <!-- Fill entity attributes data --> + <actionGroup ref="fillFilterExport" stepKey="exportProductBySku"> + <argument name="attribute" value="sku"/> + <argument name="attributeData" value="$$createConfigProduct.sku$$"/> + </actionGroup> + + <!-- Download product --> + <actionGroup ref="downloadProduct" stepKey="downloadCreatedProducts"/> + </test> +</tests> \ No newline at end of file diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAndConfigurableProductsWithAssignedImagesTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAndConfigurableProductsWithAssignedImagesTest.xml new file mode 100644 index 0000000000000..10b81c4b1278a --- /dev/null +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAndConfigurableProductsWithAssignedImagesTest.xml @@ -0,0 +1,127 @@ +<?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="AdminExportSimpleProductAndConfigurableProductsWithAssignedImagesTest"> + <annotations> + <features value="CatalogImportExport"/> + <stories value="Export products"/> + <title value="Export Simple product and Configurable products with assigned images"/> + <description value="Admin should be able to export Simple and Configurable products with assigned images"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-14004"/> + <group value="catalog_import_export"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <!-- Create category --> + <createData entity="SimpleSubCategory" stepKey="createCategory"/> + + <!-- Create configurable product with two attributes --> + <createData entity="ApiConfigurableProduct" stepKey="createConfigProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/> + <createData entity="productAttributeOption1" stepKey="createConfigProductAttributeFirstOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="productAttributeOption2" stepKey="createConfigProductAttributeSecondOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeFirstOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + <getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeSecondOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + + <!-- Create first simple product which will be the part of configurable product --> + <createData entity="ApiSimpleOne" stepKey="createConfigFirstChildProduct"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeFirstOption"/> + </createData> + + <!-- Add image to first simple product --> + <createData entity="ApiProductAttributeMediaGalleryEntryTestImage" stepKey="createConfigChildFirstProductImage"> + <requiredEntity createDataKey="createConfigFirstChildProduct"/> + </createData> + + <!-- Create second simple product which will be the part of configurable product --> + <createData entity="ApiSimpleTwo" stepKey="createConfigSecondChildProduct"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeSecondOption"/> + </createData> + + <!-- Add image to second simple product --> + <createData entity="ApiProductAttributeMediaGalleryEntryMagentoLogo" stepKey="createConfigSecondChildProductImage"> + <requiredEntity createDataKey="createConfigSecondChildProduct"/> + </createData> + + <!-- Add two options to configurable product --> + <createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeFirstOption"/> + <requiredEntity createDataKey="getConfigAttributeSecondOption"/> + </createData> + + <!-- Add created below children products to configurable product --> + <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddFirstChild"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigFirstChildProduct"/> + </createData> + <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddSecondChild"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigSecondChildProduct"/> + </createData> + + <!-- Add image to configurable product --> + <createData entity="ApiProductAttributeMediaGalleryEntryTestImage" stepKey="createConfigProductImage"> + <requiredEntity createDataKey="createConfigProduct"/> + </createData> + + <!-- Login as admin --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + + <!-- Run cron twice --> + <magentoCLI command="cron:run" stepKey="runCron1"/> + <magentoCLI command="cron:run" stepKey="runCron2"/> + </before> + <after> + <!-- Delete exported file --> + <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"/> + + <!-- Delete configurable product creation --> + <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> + <deleteData createDataKey="createConfigFirstChildProduct" stepKey="deleteConfigFirstChildProduct"/> + <deleteData createDataKey="createConfigSecondChildProduct" stepKey="deleteConfigSecondChildProduct"/> + <deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + + <!-- Log out --> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Go to export page --> + <amOnPage url="{{AdminExportIndexPage.url}}" stepKey="goToExportIndexPage"/> + <waitForPageLoad stepKey="waitForExportIndexPageLoad"/> + + <!-- Fill entity attributes data --> + <actionGroup ref="fillFilterExport" stepKey="exportProductBySku"> + <argument name="attribute" value="sku"/> + <argument name="attributeData" value="$$createConfigProduct.sku$$"/> + </actionGroup> + + <!-- Download product --> + <actionGroup ref="downloadProduct" stepKey="downloadCreatedProducts"/> + </test> +</tests> \ No newline at end of file diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAssignedToMainWebsiteAndConfigurableProductAssignedToCustomWebsiteTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAssignedToMainWebsiteAndConfigurableProductAssignedToCustomWebsiteTest.xml new file mode 100644 index 0000000000000..72daebfd93bf7 --- /dev/null +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAssignedToMainWebsiteAndConfigurableProductAssignedToCustomWebsiteTest.xml @@ -0,0 +1,109 @@ +<?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="AdminExportSimpleProductAssignedToMainWebsiteAndConfigurableProductAssignedToCustomWebsiteTest"> + <annotations> + <features value="CatalogImportExport"/> + <stories value="Export products"/> + <title value="Export Simple Product assigned to Main Website and Configurable Product assigned to Custom Website"/> + <description value="Admin should be able to export Simple Product assigned to Main Website and Configurable Product assigned to Custom Website"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-14006"/> + <group value="catalog_import_export"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <!-- Create simple product --> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="_defaultProduct" stepKey="createSimpleProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + + <!-- Create configurable product --> + <createData entity="ApiConfigurableProduct" stepKey="createConfigProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="productAttributeWithTwoOptions" stepKey="createConfigProductAttribute"/> + <createData entity="productAttributeOption1" stepKey="createConfigProductAttributeFirstOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="productAttributeOption2" stepKey="createConfigProductAttributeSecondOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeFirstOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + <getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeSecondOption"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + + <!-- Create two simple product which will be the part of configurable product --> + <createData entity="ApiSimpleOne" stepKey="createConfigFirstChildProduct"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeFirstOption"/> + </createData> + <createData entity="ApiSimpleTwo" stepKey="createConfigSecondChildProduct"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeSecondOption"/> + </createData> + <createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeFirstOption"/> + <requiredEntity createDataKey="getConfigAttributeSecondOption"/> + </createData> + <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddFirstChild"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigFirstChildProduct"/> + </createData> + <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddSecondChild"> + <requiredEntity createDataKey="createConfigProduct"/> + <requiredEntity createDataKey="createConfigSecondChildProduct"/> + </createData> + + <!-- Login as admin --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + + <!-- Run cron twice --> + <magentoCLI command="cron:run" stepKey="runCron1"/> + <magentoCLI command="cron:run" stepKey="runCron2"/> + </before> + <after> + <!-- Delete exported file --> + <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"/> + + <!-- Delete simple product --> + <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> + + <!-- Delete configurable product creation --> + <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> + <deleteData createDataKey="createConfigFirstChildProduct" stepKey="deleteConfigFirstChildProduct"/> + <deleteData createDataKey="createConfigSecondChildProduct" stepKey="deleteConfigSecondChildProduct"/> + <deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + + <!-- Log out --> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Go to export page --> + <amOnPage url="{{AdminExportIndexPage.url}}" stepKey="goToExportIndexPage"/> + <waitForPageLoad stepKey="waitForExportIndexPageLoad"/> + + <!-- Export created below products --> + <actionGroup ref="exportAllProducts" stepKey="exportCreatedProducts"/> + + <!-- Download product --> + <actionGroup ref="downloadProduct" stepKey="downloadCreatedProducts"/> + </test> +</tests> diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductWithCustomAttributeTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductWithCustomAttributeTest.xml new file mode 100644 index 0000000000000..6553966b515a4 --- /dev/null +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductWithCustomAttributeTest.xml @@ -0,0 +1,61 @@ +<?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="AdminExportSimpleProductWithCustomAttributeTest"> + <annotations> + <features value="CatalogImportExport"/> + <stories value="Export products"/> + <title value="Export Simple Product with custom attribute"/> + <description value="Admin should be able to export Simple Product with custom attribute"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-14007"/> + <group value="catalog_import_export"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <!-- Create simple product with custom attribute set --> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="CatalogAttributeSet" stepKey="createAttributeSet"/> + <createData entity="SimpleProductWithCustomAttributeSet" stepKey="createSimpleProductWithCustomAttributeSet"> + <requiredEntity createDataKey="createCategory"/> + <requiredEntity createDataKey="createAttributeSet"/> + </createData> + + <!-- Login as admin --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + + <!-- Run cron twice --> + <magentoCLI command="cron:run" stepKey="runCron1"/> + <magentoCLI command="cron:run" stepKey="runCron2"/> + </before> + <after> + <!-- Delete exported file --> + <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"/> + + <!-- Delete product creations --> + <deleteData createDataKey="createSimpleProductWithCustomAttributeSet" stepKey="deleteSimpleProductWithCustomAttributeSet"/> + <deleteData createDataKey="createAttributeSet" stepKey="deleteAttributeSet"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + + <!-- Log out --> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Go to export page --> + <amOnPage url="{{AdminExportIndexPage.url}}" stepKey="goToExportIndexPage"/> + <waitForPageLoad stepKey="waitForExportIndexPageLoad"/> + + <!-- Export created below products --> + <actionGroup ref="exportAllProducts" stepKey="exportCreatedProducts"/> + + <!-- Download product --> + <actionGroup ref="downloadProduct" stepKey="downloadCreatedProducts"/> + </test> +</tests> diff --git a/app/code/Magento/ImportExport/Test/Mftf/Section/AdminExportAttributeSection.xml b/app/code/Magento/ImportExport/Test/Mftf/Section/AdminExportAttributeSection.xml index ad9e7672ce11a..1a759867d9535 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/Section/AdminExportAttributeSection.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/Section/AdminExportAttributeSection.xml @@ -11,5 +11,11 @@ <element name="filterByAttributeCode" type="input" selector="#export_filter_grid_filter_attribute_code"/> <element name="resetFilter" type="button" selector="button[data-action='grid-filter-reset']" timeout="30"/> <element name="search" type="button" selector="button[data-action=grid-filter-apply]" timeout="30"/> + <element name="chooseAttribute" type="checkbox" selector="//*[@name='export_filter[{{var}}]']/ancestor::tr//input[@type='checkbox']" parameterized="true"/> + <element name="fillFilter" type="input" selector="//*[@name='export_filter[{{var}}]']/ancestor::tr//input[@type='text']" parameterized="true"/> + <element name="continueBtn" type="button" selector="//*[@id='export_filter_container']/button"/> + <element name="selectByIndex" type="button" selector="//tr[@data-repeat-index='{{var}}']//button" parameterized="true"/> + <element name="download" type="button" selector="//tr[@data-repeat-index='{{var}}']//a[text()='Download']" parameterized="true" timeout="10"/> + <element name="delete" type="button" selector="//tr[@data-repeat-index='{{var}}']//a[text()='Delete']" parameterized="true" timeout="10"/> </section> </sections> From 739496a0edc7f1d319add2ff9282420133c74789 Mon Sep 17 00:00:00 2001 From: sathakur <sathakur@adobe.com> Date: Wed, 27 Feb 2019 15:41:10 -0600 Subject: [PATCH 031/162] MC-4434: Convert DeleteSearchTermEntityTest to MFTF --- .../Section/StorefrontMessagesSection.xml | 2 +- .../AdminCatalogSearchTermActionGroup.xml | 62 +++++++++++++++++++ ...StorefrontCatalogSearchTermActionGroup.xml | 25 ++++++++ .../Test/Mftf/Data/SearchTermData.xml | 17 +++++ .../Page/AdminCatalogSearchTermIndexPage.xml | 14 +++++ .../Page/AdminCatalogSearchTermNewPage.xml | 14 +++++ .../AdminCatalogSearchTermIndexSection.xml | 22 +++++++ .../AdminCatalogSearchTermMessagesSection.xml | 14 +++++ .../AdminCatalogSearchTermNewSection.xml | 18 ++++++ .../Mftf/Test/AdminDeleteSearchTermTest.xml | 59 ++++++++++++++++++ 10 files changed, 246 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/AdminCatalogSearchTermActionGroup.xml create mode 100644 app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchTermActionGroup.xml create mode 100644 app/code/Magento/CatalogSearch/Test/Mftf/Data/SearchTermData.xml create mode 100644 app/code/Magento/CatalogSearch/Test/Mftf/Page/AdminCatalogSearchTermIndexPage.xml create mode 100644 app/code/Magento/CatalogSearch/Test/Mftf/Page/AdminCatalogSearchTermNewPage.xml create mode 100644 app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermIndexSection.xml create mode 100644 app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermMessagesSection.xml create mode 100644 app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermNewSection.xml create mode 100644 app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminDeleteSearchTermTest.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontMessagesSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontMessagesSection.xml index 4dcda8dcd41ae..4447b27360a80 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontMessagesSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontMessagesSection.xml @@ -11,6 +11,6 @@ <section name="StorefrontMessagesSection"> <element name="success" type="text" selector="div.message-success.success.message"/> <element name="error" type="text" selector="div.message-error.error.message"/> - <element name="noticeMessage" type="text" selector="div.message-notice"/> + <element name="noticeMessage" type="text" selector="//div[@class='message notice']/div"/> </section> </sections> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/AdminCatalogSearchTermActionGroup.xml b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/AdminCatalogSearchTermActionGroup.xml new file mode 100644 index 0000000000000..a9444a4e5baa6 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/AdminCatalogSearchTermActionGroup.xml @@ -0,0 +1,62 @@ +<?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"> + <!--Add new search term and AssertSearchTermSaveSuccessMessage--> + <actionGroup name="AssertSearchTermSaveSuccessMessage"> + <arguments> + <argument name="searchQuery" type="string"/> + <argument name="storeValue" type="string"/> + <argument name="redirectUrl" type="string"/> + <argument name="displayInSuggestedTerm" type="string"/> + </arguments> + <amOnPage url="{{AdminCatalogSearchTermIndexPage.url}}" stepKey="openAdminCatalogSearchTermIndexPage"/> + <waitForPageLoad stepKey="waitForAdminCatalogSearchTermIndexPageLoad"/> + <click selector="{{AdminCatalogSearchTermIndexSection.addNewSearchTermButton}}" stepKey="clickAddNewSearchTermButton"/> + <waitForPageLoad stepKey="waitForAdminCatalogSearchTermNewPageLoad"/> + <fillField selector="{{AdminCatalogSearchTermNewSection.searchQuery}}" userInput="{{searchQuery}}" stepKey="fillSearchQueryTextBox"/> + <click selector="{{AdminCatalogSearchTermNewSection.store('storeValue')}}" stepKey="selectMainWebsiteStore"/> + <fillField selector="{{AdminCatalogSearchTermNewSection.redirectUrl}}" userInput="{{redirectUrl}}" stepKey="fillRedirectUrl"/> + <click selector="{{AdminCatalogSearchTermNewSection.displayInSuggestedTerm('displayInSuggestedTerm')}}" stepKey="selectDisplayInSuggestedTerm"/> + <click selector="{{AdminCatalogSearchTermNewSection.saveSearchButton}}" stepKey="clickSaveSearchButton"/> + <see selector="{{AdminCatalogSearchTermMessagesSection.successMessage}}" userInput="You saved the search term." stepKey="seeSaveSuccessMessage"/> + </actionGroup> + <!--Search and delete search term and AssertSearchTermSuccessDeleteMessage--> + <actionGroup name="AssertSearchTermSuccessDeleteMessage"> + <arguments> + <argument name="searchQuery" type="string"/> + </arguments> + <amOnPage url="{{AdminCatalogSearchTermIndexPage.url}}" stepKey="openCatalogSearchIndexPage"/> + <waitForPageLoad stepKey="waitForAdminCatalogSearchTermIndexPageLoad"/> + <click selector="{{AdminCatalogSearchTermIndexSection.resetFilterButton}}" stepKey="clickOnResetButton"/> + <waitForPageLoad stepKey="waitForPageToLoad"/> + <fillField selector="{{AdminCatalogSearchTermIndexSection.searchQuery}}" userInput="{{searchQuery}}" stepKey="fillSearchQuery"/> + <click selector="{{AdminCatalogSearchTermIndexSection.searchButton}}" stepKey="clickSearchButton"/> + <waitForPageLoad stepKey="waitForSearchResultLoad"/> + <checkOption selector="{{AdminCatalogSearchTermIndexSection.checkBox}}" stepKey="checkCheckBox"/> + <selectOption selector="{{AdminCatalogSearchTermIndexSection.delete}}" userInput="delete" stepKey="selectDeleteOption"/> + <click selector="{{AdminCatalogSearchTermIndexSection.submit}}" stepKey="clickSubmitButton"/> + <click selector="{{AdminCatalogSearchTermIndexSection.okButton}}" stepKey="clickOkButton"/> + <see selector="{{AdminCatalogSearchTermMessagesSection.successMessage}}" userInput="Total of 1 record(s) were deleted." stepKey="seeSuccessMessage"/> + </actionGroup> + <!--Verify deleted search term in grid and AssertSearchTermNotInGridMessage--> + <actionGroup name="AssertSearchTermNotInGrid"> + <arguments> + <argument name="searchQuery" type="string"/> + </arguments> + <amOnPage url="{{AdminCatalogSearchTermIndexPage.url}}" stepKey="openCatalogSearchIndexPage"/> + <waitForPageLoad stepKey="waitForAdminCatalogSearchTermIndexPageLoad"/> + <click selector="{{AdminCatalogSearchTermIndexSection.resetFilterButton}}" stepKey="clickOnResetButton"/> + <waitForPageLoad stepKey="waitForPageToLoad"/> + <fillField selector="{{AdminCatalogSearchTermIndexSection.searchQuery}}" userInput="{{searchQuery}}" stepKey="fillSearchQuery"/> + <click selector="{{AdminCatalogSearchTermIndexSection.searchButton}}" stepKey="clickSearchButton"/> + <waitForPageLoad stepKey="waitForSearchResultToLoad"/> + <see selector="{{AdminCatalogSearchTermIndexSection.emptyRecords}}" userInput="We couldn't find any records." stepKey="seeEmptyRecordMessage"/> + </actionGroup> +</actionGroups> \ No newline at end of file diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchTermActionGroup.xml b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchTermActionGroup.xml new file mode 100644 index 0000000000000..5714cb4eb9f9c --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchTermActionGroup.xml @@ -0,0 +1,25 @@ +<?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"> + <!--Verify AssertSearchTermNotOnFrontend--> + <actionGroup name="AssertSearchTermNotOnFrontend"> + <arguments> + <argument name="searchQuery" type="string"/> + <argument name="url_key" type="string"/> + </arguments> + <amOnPage url="{{StorefrontProductPage.url('url_key')}}" stepKey="goToMagentoStorefrontPage"/> + <waitForPageLoad stepKey="waitForStoreFrontProductPageLoad"/> + <fillField selector="{{StorefrontQuickSearchResultsSection.searchTextBox}}" userInput="{{SimpleTerm.search_query}}" stepKey="fillSearchQuery"/> + <waitForPageLoad stepKey="waitForSearchTextBox"/> + <click selector="{{StorefrontQuickSearchResultsSection.searchTextBoxButton}}" stepKey="clickSearchTextBoxButton"/> + <waitForPageLoad stepKey="waitForSearch"/> + <see selector="{{StorefrontMessagesSection.noticeMessage}}" userInput="Your search returned no results." stepKey="seeAssertSearchTermNotOnFrontendNoticeMessage"/> + </actionGroup> +</actionGroups> \ No newline at end of file diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Data/SearchTermData.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Data/SearchTermData.xml new file mode 100644 index 0000000000000..995b860d107ca --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Data/SearchTermData.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="SimpleTerm" type="searchTerm"> + <data key="search_query" unique="suffix">Query text</data> + <data key="store_id">Default Store View</data> + <data key="redirect" unique="suffix">http://example.com/</data> + <data key="display_in_terms">No</data> + </entity> +</entities> \ No newline at end of file diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Page/AdminCatalogSearchTermIndexPage.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Page/AdminCatalogSearchTermIndexPage.xml new file mode 100644 index 0000000000000..bbafff8ad7739 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Page/AdminCatalogSearchTermIndexPage.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="AdminCatalogSearchTermIndexPage" url="/search/term/index/" area="admin" module="Magento_CatalogSearch"> + <section name="AdminCatalogSearchTermIndexSection"/> + </page> +</pages> \ No newline at end of file diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Page/AdminCatalogSearchTermNewPage.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Page/AdminCatalogSearchTermNewPage.xml new file mode 100644 index 0000000000000..de7491471741c --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Page/AdminCatalogSearchTermNewPage.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="AdminCatalogSearchTermNewPage" url="/search/term/new/" area="admin" module="Magento_CatalogSearch"> + <section name="AdminCatalogSearchTermNewSection"/> + </page> +</pages> \ No newline at end of file diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermIndexSection.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermIndexSection.xml new file mode 100644 index 0000000000000..812c302f9c00a --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermIndexSection.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminCatalogSearchTermIndexSection"> + <element name="addNewSearchTermButton" type="button" selector="//div[@class='page-actions-buttons']/button[@id='add']" timeout="30"/> + <element name="resetFilterButton" type="button" selector="//button[@class='action-default scalable action-reset action-tertiary']" timeout="30"/> + <element name="searchButton" type="button" selector="//button[@class='action-default scalable action-secondary']" timeout="30"/> + <element name="delete" type="text" selector="//div[@class='admin__grid-massaction-form']//select[@id='search_term_grid_massaction-select']"/> + <element name="submit" type="button" selector="//button[@class='action-default scalable']/span" timeout="30"/> + <element name="searchQuery" type="text" selector="//tr[@class='data-grid-filters']//td/input[@name='search_query']"/> + <element name="checkBox" type="checkbox" selector="//label[@class='data-grid-checkbox-cell-inner']/input[@name='search']"/> + <element name="okButton" type="button" selector="//button[@class='action-primary action-accept']/span" timeout="30"/> + <element name="emptyRecords" type="text" selector="//tr[@class='data-grid-tr-no-data even']/td[@class='empty-text']"/> + </section> +</sections> \ No newline at end of file diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermMessagesSection.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermMessagesSection.xml new file mode 100644 index 0000000000000..5d19198a1b94c --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermMessagesSection.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminCatalogSearchTermMessagesSection"> + <element name="successMessage" type="text" selector="//div[@class='message message-success success']/div[@data-ui-id='messages-message-success']"/> + </section> +</sections> \ No newline at end of file diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermNewSection.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermNewSection.xml new file mode 100644 index 0000000000000..7922e994c4965 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermNewSection.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminCatalogSearchTermNewSection"> + <element name="searchQuery" type="text" selector="//div[@class='admin__field-control control']/input[@id='query_text']"/> + <element name="store" type="text" selector="//select[@id='store_id']//optgroup/option[contains(.,'{{store}}')]" parameterized="true"/> + <element name="redirectUrl" type="text" selector="//div[@class='admin__field-control control']/input[@id='redirect']"/> + <element name="displayInSuggestedTerm" type="select" selector="//select[@name='display_in_terms']/option[contains(.,'{{text}}')]" parameterized="true"/> + <element name="saveSearchButton" type="button" selector="//button[@id='save']/span[@class='ui-button-text']" timeout="30"/> + </section> +</sections> \ No newline at end of file diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminDeleteSearchTermTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminDeleteSearchTermTest.xml new file mode 100644 index 0000000000000..dc9d99fabefc6 --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminDeleteSearchTermTest.xml @@ -0,0 +1,59 @@ +<?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="AdminDeleteSearchTermTest"> + <annotations> + <stories value="DeleteSearchTerm"/> + <title value="DeleteSearchTermEntityTestVariation1"/> + <description value="Test log in to SearchTerm and DeleteSearchTerm"/> + <testCaseId value="MC-13988"/> + <severity value="CRITICAL"/> + <group value="CatalogSearch"/> + <group value="mtf_migrated"/> + </annotations> + + <before> + <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <createData entity="SimpleSubCategory" stepKey="initialCategoryEntity"/> + <createData entity="SimpleProduct" stepKey="simpleProduct"> + <requiredEntity createDataKey="initialCategoryEntity"/> + </createData> + </before> + <after> + <deleteData stepKey="deleteSimpleSubCategory" createDataKey="initialCategoryEntity"/> + <deleteData stepKey="deleteSimpleProduct" createDataKey="simpleProduct"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!--Add new search term--> + <actionGroup ref="AssertSearchTermSaveSuccessMessage" stepKey="addNewSearchTerm"> + <argument name="searchQuery" value="{{SimpleTerm.search_query}}"/> + <argument name="storeValue" value="Default Store View"/> + <argument name="redirectUrl" value="{{SimpleTerm.redirect}}"/> + <argument name="displayInSuggestedTerm" value="No"/> + </actionGroup> + + <!--Search and delete search term and AssertSearchTermSuccessDeleteMessage--> + <actionGroup ref="AssertSearchTermSuccessDeleteMessage" stepKey="deleteSearchTerm"> + <argument name="searchQuery" value="{{SimpleTerm.search_query}}"/> + </actionGroup> + + <!--Verify deleted search term in grid and AssertSearchTermNotInGrid--> + <actionGroup ref="AssertSearchTermNotInGrid" stepKey="verifyDeletedSearchTermNotInGrid"> + <argument name="searchQuery" value="{{SimpleTerm.search_query}}"/> + </actionGroup> + + <!--Verify AssertSearchTermNotOnFrontend--> + <actionGroup ref="AssertSearchTermNotOnFrontend" stepKey="verifySearchTermNotOnFrontend"> + <argument name="searchQuery" value="{{SimpleTerm.search_query}}"/> + <argument name="url_key" value="$$simpleProduct.custom_attributes[url_key]$$"/> + </actionGroup> + </test> +</tests> \ No newline at end of file From ec62bf7f1b19ca2fdbffeb4f41fd52b354c895bb Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Wed, 27 Feb 2019 15:50:13 -0600 Subject: [PATCH 032/162] MAGETWO-98151: Add support ZooKeeper locks --- .../Framework/Lock/Backend/ZookeeperTest.php | 90 ++++++ .../Framework/Lock/Backend/Zookeeper.php | 11 +- .../Framework/Lock/LockBackendFactory.php | 15 +- .../Lock/Test/Unit/LockBackendFactoryTest.php | 10 +- .../Magento/Setup/Model/ConfigOptionsList.php | 3 +- .../Setup/Model/ConfigOptionsList/Lock.php | 291 ++++++++++++++++++ .../Unit/Model/ConfigOptionsList/LockTest.php | 196 ++++++++++++ .../Test/Unit/Model/ConfigOptionsListTest.php | 17 +- 8 files changed, 619 insertions(+), 14 deletions(-) create mode 100644 setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php create mode 100644 setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/LockTest.php diff --git a/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php b/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php index e69de29bb2d1d..6e312637c7b5a 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php @@ -0,0 +1,90 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Lock\Backend; + +use Magento\Framework\Lock\Backend\Zookeeper as ZookeeperLock; +use Magento\Framework\Lock\LockBackendFactory; +use Magento\Framework\Config\File\ConfigFilePool; +use Magento\Framework\App\DeploymentConfig\FileReader; +use Magento\Framework\Stdlib\ArrayManager; + +/** + * \Magento\Framework\Lock\Backend\Zookeeper test case + */ +class ZookeeperTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var FileReader + */ + private $configReader; + + /** + * @var \Magento\Framework\ObjectManagerInterface + */ + private $objectManager; + + /** + * @var LockBackendFactory + */ + private $lockBackendFactory; + + /** + * @var ArrayManager + */ + private $arrayManager; + + /** + * @var ZookeeperLock + */ + private $model; + + /** + * @inheritdoc + */ + protected function setUp() + { + if (!extension_loaded('zookeeper')) { + $this->markTestSkipped('php extension Zookeeper is not installed.'); + } + + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->configReader = $this->objectManager->get(FileReader::class); + $this->lockBackendFactory = $this->objectManager->create(LockBackendFactory::class); + $this->arrayManager = $this->objectManager->create(ArrayManager::class); + $config = $this->configReader->load(ConfigFilePool::APP_ENV); + + if ($this->arrayManager->get('lock/provider', $config) !== 'zookeeper') { + $this->markTestSkipped('Zookeeper is not configured during installation.'); + } + + $this->model = $this->lockBackendFactory->create(); + $this->assertInstanceOf(ZookeeperLock::class, $this->model); + } + + public function testLockAndUnlock() + { + $name = 'test_lock'; + + $this->assertFalse($this->model->isLocked($name)); + + $this->assertTrue($this->model->lock($name)); + $this->assertTrue($this->model->isLocked($name)); + + $this->assertTrue($this->model->unlock($name)); + $this->assertFalse($this->model->isLocked($name)); + } + + public function testUnlockWithoutExistingLock() + { + $name = 'test_lock'; + + $this->assertFalse($this->model->isLocked($name)); + $this->assertFalse($this->model->unlock($name)); + } +} + diff --git a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php index d19ba0dd947b0..c2119df300c52 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php @@ -31,6 +31,8 @@ class Zookeeper implements LockManagerInterface private $path; /** + * The name of sequence nodes + * * @var string */ private $lockName = 'lock-'; @@ -70,12 +72,17 @@ class Zookeeper implements LockManagerInterface */ private $locks = []; + /** + * The default path to storage locks + */ + const DEFAULT_PATH = '/magento/locks'; + /** * @param string $host The host to connect to Zookeeper * @param string $path The base path to locks in Zookeeper * @throws RuntimeException */ - public function __construct(string $host, string $path = '/magento/locks') + public function __construct(string $host, string $path = self::DEFAULT_PATH) { if (empty($path)) { throw new RuntimeException( @@ -164,7 +171,7 @@ private function getFullPathToLock(string $name): string * @return \Zookeeper * @throws RuntimeException */ - private function getProvider(): \Zookeeper + public function getProvider(): \Zookeeper { if (!$this->zookeeper) { $this->zookeeper = new \Zookeeper($this->host); diff --git a/lib/internal/Magento/Framework/Lock/LockBackendFactory.php b/lib/internal/Magento/Framework/Lock/LockBackendFactory.php index e2119ca3eee11..ec15736bef534 100644 --- a/lib/internal/Magento/Framework/Lock/LockBackendFactory.php +++ b/lib/internal/Magento/Framework/Lock/LockBackendFactory.php @@ -13,6 +13,7 @@ use Magento\Framework\App\DeploymentConfig; use Magento\Framework\Lock\Backend\Database as DatabaseLock; use Magento\Framework\Lock\Backend\Zookeeper as ZookeeperLock; +use Magento\Framework\Lock\Backend\Cache as CacheLock; /** * The factory to create object that implements LockManagerInterface @@ -47,6 +48,13 @@ class LockBackendFactory */ const LOCK_ZOOKEEPER = 'zookeeper'; + /** + * Cache lock provider name + * + * @const string + */ + const LOCK_CACHE = 'cache'; + /** * The list of lock providers with mapping on classes * @@ -54,7 +62,8 @@ class LockBackendFactory */ private $lockers = [ self::LOCK_DB => DatabaseLock::class, - self::LOCK_ZOOKEEPER => ZookeeperLock::class + self::LOCK_ZOOKEEPER => ZookeeperLock::class, + self::LOCK_CACHE => CacheLock::class, ]; /** @@ -77,8 +86,8 @@ public function __construct( */ public function create(): LockManagerInterface { - $provider = $this->deploymentConfig->get('locks/provider', self::LOCK_DB); - $config = $this->deploymentConfig->get('locks/config', []); + $provider = $this->deploymentConfig->get('lock/provider', self::LOCK_DB); + $config = $this->deploymentConfig->get('lock/config', []); if (!isset($this->lockers[$provider])) { throw new RuntimeException(new Phrase('Unknown locks provider.')); diff --git a/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php b/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php index f3b141e9f902b..18053f20f010c 100644 --- a/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php +++ b/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php @@ -9,6 +9,7 @@ use Magento\Framework\Lock\Backend\Database as DatabaseLock; use Magento\Framework\Lock\Backend\Zookeeper as ZookeeperLock; +use Magento\Framework\Lock\Backend\Cache as CacheLock; use Magento\Framework\Lock\LockBackendFactory; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Lock\LockManagerInterface; @@ -51,7 +52,7 @@ public function testCreateWithException() { $this->deploymentConfigMock->expects($this->exactly(2)) ->method('get') - ->withConsecutive(['locks/provider', LockBackendFactory::LOCK_DB], ['locks/config', []]) + ->withConsecutive(['lock/provider', LockBackendFactory::LOCK_DB], ['lock/config', []]) ->willReturnOnConsecutiveCalls('someProvider', []); $this->factory->create(); @@ -68,7 +69,7 @@ public function testCreate(string $lockProvider, string $lockProviderClass, arra $lockManagerMock = $this->getMockForAbstractClass(LockManagerInterface::class); $this->deploymentConfigMock->expects($this->exactly(2)) ->method('get') - ->withConsecutive(['locks/provider', LockBackendFactory::LOCK_DB], ['locks/config', []]) + ->withConsecutive(['lock/provider', LockBackendFactory::LOCK_DB], ['lock/config', []]) ->willReturnOnConsecutiveCalls($lockProvider, $config); $this->objectManagerMock->expects($this->once()) ->method('create') @@ -89,6 +90,11 @@ public function createDataProvider(): array 'lockProviderClass' => DatabaseLock::class, 'config' => ['prefix' => 'somePrefix'], ], + 'cache' => [ + 'lockProvider' => LockBackendFactory::LOCK_CACHE, + 'lockProviderClass' => CacheLock::class, + 'config' => [], + ], ]; if (extension_loaded('zookeeper')) { diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList.php b/setup/src/Magento/Setup/Model/ConfigOptionsList.php index afe1a5d9e2591..3f2aedae1373c 100644 --- a/setup/src/Magento/Setup/Model/ConfigOptionsList.php +++ b/setup/src/Magento/Setup/Model/ConfigOptionsList.php @@ -50,7 +50,8 @@ class ConfigOptionsList implements ConfigOptionsListInterface private $configOptionsListClasses = [ \Magento\Setup\Model\ConfigOptionsList\Session::class, \Magento\Setup\Model\ConfigOptionsList\Cache::class, - \Magento\Setup\Model\ConfigOptionsList\PageCache::class + \Magento\Setup\Model\ConfigOptionsList\PageCache::class, + \Magento\Setup\Model\ConfigOptionsList\Lock::class, ]; /** diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php b/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php new file mode 100644 index 0000000000000..912b0e42ca822 --- /dev/null +++ b/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php @@ -0,0 +1,291 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Setup\Model\ConfigOptionsList; + +use Magento\Framework\Lock\Backend\Zookeeper as ZookeeperLock; +use Magento\Framework\Lock\LockBackendFactory; +use Magento\Framework\App\DeploymentConfig; +use Magento\Framework\Config\Data\ConfigData; +use Magento\Framework\Config\File\ConfigFilePool; +use Magento\Framework\Setup\ConfigOptionsListInterface; +use Magento\Framework\Setup\Option\SelectConfigOption; +use Magento\Framework\Setup\Option\TextConfigOption; + +/** + * Deployment configuration options for locks + */ +class Lock implements ConfigOptionsListInterface +{ + /** + * The name of an option to set lock provider + * + * @const string + */ + const INPUT_KEY_LOCK_PROVIDER = 'lock-provider'; + + /** + * The name of an option to set DB prefix + * + * @const string + */ + const INPUT_KEY_LOCK_DB_PREFIX = 'lock-db-prefix'; + + /** + * The name of an option to set Zookeeper host + * + * @const string + */ + const INPUT_KEY_LOCK_ZOOKEEPER_HOST = 'lock-zookeeper-host'; + + /** + * The name of an option to set Zookeeper path + * + * @const string + */ + const INPUT_KEY_LOCK_ZOOKEEPER_PATH = 'lock-zookeeper-path'; + + /** + * The configuration path to save lock provider + * + * @const string + */ + const CONFIG_PATH_LOCK_PROVIDER = 'lock/provider'; + + /** + * The configuration path to save DB prefix + * + * @const string + */ + const CONFIG_PATH_LOCK_DB_PREFIX = 'lock/config/prefix'; + + /** + * The configuration path to save Zookeeper host + * + * @const string + */ + const CONFIG_PATH_LOCK_ZOOKEEPER_HOST = 'lock/config/host'; + + /** + * The configuration path to save Zookeeper path + * + * @const string + */ + const CONFIG_PATH_LOCK_ZOOKEEPER_PATH = 'lock/config/path'; + + /** + * The list of lock providers + * + * @var array + */ + private $validLockProviders = [ + LockBackendFactory::LOCK_DB, + LockBackendFactory::LOCK_ZOOKEEPER, + LockBackendFactory::LOCK_CACHE, + ]; + + /** + * The mapping input keys with their configuration paths + * + * @var array + */ + private $mappingInputKeyToConfigPath = [ + LockBackendFactory::LOCK_DB => [ + self::INPUT_KEY_LOCK_PROVIDER => self::CONFIG_PATH_LOCK_PROVIDER, + self::INPUT_KEY_LOCK_DB_PREFIX => self::CONFIG_PATH_LOCK_DB_PREFIX, + ], + LockBackendFactory::LOCK_ZOOKEEPER => [ + self::INPUT_KEY_LOCK_PROVIDER => self::CONFIG_PATH_LOCK_PROVIDER, + self::INPUT_KEY_LOCK_ZOOKEEPER_HOST => self::CONFIG_PATH_LOCK_ZOOKEEPER_HOST, + self::INPUT_KEY_LOCK_ZOOKEEPER_PATH => self::CONFIG_PATH_LOCK_ZOOKEEPER_PATH, + ], + LockBackendFactory::LOCK_CACHE => [ + self::INPUT_KEY_LOCK_PROVIDER => self::CONFIG_PATH_LOCK_PROVIDER, + ], + ]; + + /** + * The list of default values + * + * @var array + */ + private $defaultConfigValues = [ + self::INPUT_KEY_LOCK_PROVIDER => LockBackendFactory::LOCK_DB, + self::INPUT_KEY_LOCK_DB_PREFIX => null, + self::INPUT_KEY_LOCK_ZOOKEEPER_PATH => ZookeeperLock::DEFAULT_PATH, + ]; + + /** + * @inheritdoc + */ + public function getOptions() + { + return [ + new SelectConfigOption( + self::INPUT_KEY_LOCK_PROVIDER, + SelectConfigOption::FRONTEND_WIZARD_SELECT, + $this->validLockProviders, + self::CONFIG_PATH_LOCK_PROVIDER, + 'Lock provider name', + LockBackendFactory::LOCK_DB + ), + new TextConfigOption( + self::INPUT_KEY_LOCK_DB_PREFIX, + TextConfigOption::FRONTEND_WIZARD_TEXT, + self::CONFIG_PATH_LOCK_DB_PREFIX, + 'Installation specific lock prefix to avoid lock conflicts' + ), + new TextConfigOption( + self::INPUT_KEY_LOCK_ZOOKEEPER_HOST, + TextConfigOption::FRONTEND_WIZARD_TEXT, + self::CONFIG_PATH_LOCK_ZOOKEEPER_HOST, + 'Host and port to connect to Zookeeper cluster. For example: 127.0.0.1:2181' + ), + new TextConfigOption( + self::INPUT_KEY_LOCK_ZOOKEEPER_PATH, + TextConfigOption::FRONTEND_WIZARD_TEXT, + self::CONFIG_PATH_LOCK_ZOOKEEPER_PATH, + 'The path where Zookeeper will save locks. The default path is: ' . ZookeeperLock::DEFAULT_PATH + ), + ]; + } + + /** + * @inheritdoc + */ + public function createConfig(array $options, DeploymentConfig $deploymentConfig) + { + $configData = new ConfigData(ConfigFilePool::APP_ENV); + $configData->setOverrideWhenSave(true); + $lockProvider = $this->getLockProvider($options, $deploymentConfig); + + $this->setDefaultConfiguration($configData, $deploymentConfig, $lockProvider); + + foreach ($this->mappingInputKeyToConfigPath[$lockProvider] as $input => $path) { + if (isset($options[$input])) { + $configData->set($path, $options[$input]); + } + } + + return $configData; + } + + /** + * @inheritdoc + */ + public function validate(array $options, DeploymentConfig $deploymentConfig) + { + $lockProvider = $this->getLockProvider($options, $deploymentConfig); + switch ($lockProvider) { + case LockBackendFactory::LOCK_ZOOKEEPER: + $errors = $this->validateZookeeperConfig($options, $deploymentConfig); + break; + case LockBackendFactory::LOCK_CACHE: + case LockBackendFactory::LOCK_DB: + $errors = []; + break; + default: + $errors[] = 'The lock provider ' . $lockProvider . ' does not exist.'; + } + + return $errors; + } + + /** + * Validates Zookeeper configuration + * + * @param array $options + * @param DeploymentConfig $deploymentConfig + * @return array + */ + private function validateZookeeperConfig(array $options, DeploymentConfig $deploymentConfig): array + { + $errors = []; + + if (!extension_loaded(LockBackendFactory::LOCK_ZOOKEEPER)) { + $errors[] = 'php extension Zookeeper is not installed.'; + } + + $host = (string) $options[self::INPUT_KEY_LOCK_ZOOKEEPER_HOST] + ?? $deploymentConfig->get( + self::CONFIG_PATH_LOCK_ZOOKEEPER_HOST, + $this->getDefaultValue(self::INPUT_KEY_LOCK_ZOOKEEPER_HOST) + ); + $path = (string) $options[self::INPUT_KEY_LOCK_ZOOKEEPER_PATH] + ?? $deploymentConfig->get( + self::CONFIG_PATH_LOCK_ZOOKEEPER_PATH, + $this->getDefaultValue(self::INPUT_KEY_LOCK_ZOOKEEPER_PATH) + ); + + if (!$path) { + $errors[] = 'Zookeeper path needs to be a non-empty string.'; + } + + if (!$host) { + $errors[] = 'Zookeeper host is should be set.'; + } + + return $errors; + } + + /** + * Returns the name of lock provider + * + * @param array $options + * @param DeploymentConfig $deploymentConfig + * @return string + */ + private function getLockProvider(array $options, DeploymentConfig $deploymentConfig): string + { + if (empty($options[self::INPUT_KEY_LOCK_PROVIDER])) { + return (string) $deploymentConfig->get( + self::CONFIG_PATH_LOCK_PROVIDER, + $this->getDefaultValue(self::INPUT_KEY_LOCK_PROVIDER) + ); + } + + return (string) $options[self::INPUT_KEY_LOCK_PROVIDER]; + } + + + /** + * Sets default configuration for locks + * + * @param ConfigData $configData + * @param DeploymentConfig $deploymentConfig + * @param string $lockProvider + * @return ConfigData + */ + private function setDefaultConfiguration( + ConfigData $configData, + DeploymentConfig $deploymentConfig, + string $lockProvider + ) { + foreach ($this->mappingInputKeyToConfigPath[$lockProvider] as $input => $path) { + $configData->set($path, $deploymentConfig->get($path, $this->getDefaultValue($input))); + } + + return $configData; + } + + /** + * Returns default value by input key + * + * If default value is not set returns null + * + * @param string $inputKey + * @return mixed|null + */ + private function getDefaultValue(string $inputKey) + { + if (isset($this->defaultConfigValues[$inputKey])) { + return $this->defaultConfigValues[$inputKey]; + } else { + return null; + } + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/LockTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/LockTest.php new file mode 100644 index 0000000000000..f7ca6e0a09b5a --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/LockTest.php @@ -0,0 +1,196 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Setup\Test\Unit\Model\ConfigOptionsList; + +use Magento\Setup\Model\ConfigOptionsList\Lock as LockConfigOptionsList; +use Magento\Framework\Lock\Backend\Zookeeper as ZookeeperLock; +use Magento\Framework\Lock\LockBackendFactory; +use Magento\Framework\Config\Data\ConfigData; +use Magento\Framework\App\DeploymentConfig; +use Magento\Framework\Setup\Option\SelectConfigOption; +use Magento\Framework\Setup\Option\TextConfigOption; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; + +class LockTest extends TestCase +{ + /** + * @var DeploymentConfig|MockObject + */ + private $deploymentConfigMock; + + /** + * @var LockConfigOptionsList + */ + private $lockConfigOptionsList; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->deploymentConfigMock = $this->createMock(DeploymentConfig::class); + $this->lockConfigOptionsList = new LockConfigOptionsList(); + } + + /** + * @return void + */ + public function testGetOptions() + { + $options = $this->lockConfigOptionsList->getOptions(); + $this->assertSame(4, count($options)); + + $this->assertArrayHasKey(0, $options); + $this->assertInstanceOf(SelectConfigOption::class, $options[0]); + $this->assertEquals(LockConfigOptionsList::INPUT_KEY_LOCK_PROVIDER, $options[0]->getName()); + + $this->assertArrayHasKey(1, $options); + $this->assertInstanceOf(TextConfigOption::class, $options[1]); + $this->assertEquals(LockConfigOptionsList::INPUT_KEY_LOCK_DB_PREFIX, $options[1]->getName()); + + $this->assertArrayHasKey(2, $options); + $this->assertInstanceOf(TextConfigOption::class, $options[2]); + $this->assertEquals(LockConfigOptionsList::INPUT_KEY_LOCK_ZOOKEEPER_HOST, $options[2]->getName()); + + $this->assertArrayHasKey(3, $options); + $this->assertInstanceOf(TextConfigOption::class, $options[3]); + $this->assertEquals(LockConfigOptionsList::INPUT_KEY_LOCK_ZOOKEEPER_PATH, $options[3]->getName()); + } + + /** + * @param array $options + * @param array $expectedResult + * @dataProvider createConfigDataProvider + */ + public function testCreateConfig(array $options, array $expectedResult) + { + $this->deploymentConfigMock->expects($this->any()) + ->method('get') + ->willReturnArgument(1); + $data = $this->lockConfigOptionsList->createConfig($options, $this->deploymentConfigMock); + $this->assertInstanceOf(ConfigData::class, $data); + $this->assertTrue($data->isOverrideWhenSave()); + $this->assertSame($expectedResult, $data->getData()); + } + + /** + * @return array + */ + public function createConfigDataProvider(): array + { + return [ + 'Check default values' => [ + 'options' => [], + 'expectedResult' => [ + 'lock' => [ + 'provider' => LockBackendFactory::LOCK_DB, + 'config' => [ + 'prefix' => null, + ], + ], + ], + ], + 'Check default value for cache lock' => [ + 'options' => [ + LockConfigOptionsList::INPUT_KEY_LOCK_PROVIDER => LockBackendFactory::LOCK_CACHE, + ], + 'expectedResult' => [ + 'lock' => [ + 'provider' => LockBackendFactory::LOCK_CACHE, + ], + ], + ], + 'Check default value for zookeeper lock' => [ + 'options' => [ + LockConfigOptionsList::INPUT_KEY_LOCK_PROVIDER => LockBackendFactory::LOCK_ZOOKEEPER, + ], + 'expectedResult' => [ + 'lock' => [ + 'provider' => LockBackendFactory::LOCK_ZOOKEEPER, + 'config' => [ + 'host' => null, + 'path' => ZookeeperLock::DEFAULT_PATH, + ], + ], + ], + ], + 'Check specific db lock options' => [ + 'options' => [ + LockConfigOptionsList::INPUT_KEY_LOCK_PROVIDER => LockBackendFactory::LOCK_DB, + LockConfigOptionsList::INPUT_KEY_LOCK_DB_PREFIX => 'my_prefix' + ], + 'expectedResult' => [ + 'lock' => [ + 'provider' => LockBackendFactory::LOCK_DB, + 'config' => [ + 'prefix' => 'my_prefix', + ], + ], + ], + ], + 'Check specific zookeeper lock options' => [ + 'options' => [ + LockConfigOptionsList::INPUT_KEY_LOCK_PROVIDER => LockBackendFactory::LOCK_ZOOKEEPER, + LockConfigOptionsList::INPUT_KEY_LOCK_ZOOKEEPER_HOST => '123.45.67.89:10', + LockConfigOptionsList::INPUT_KEY_LOCK_ZOOKEEPER_PATH => '/some/path', + ], + 'expectedResult' => [ + 'lock' => [ + 'provider' => LockBackendFactory::LOCK_ZOOKEEPER, + 'config' => [ + 'host' => '123.45.67.89:10', + 'path' => '/some/path', + ], + ], + ], + ], + ]; + } + + /** + * @param array $options + * @param array $expectedResult + * @dataProvider validateDataProvider + */ + public function testValidate(array $options, array $expectedResult) + { + $this->deploymentConfigMock->expects($this->any()) + ->method('get') + ->willReturnArgument(1); + $this->assertSame($expectedResult, $this->lockConfigOptionsList->validate($options, $this->deploymentConfigMock)); + } + + /** + * @return array + */ + public function validateDataProvider(): array + { + return [ + 'Wrong lock provider' => [ + 'options' => [ + LockConfigOptionsList::INPUT_KEY_LOCK_PROVIDER => 'SomeProvider', + ], + 'expectedResult' => [ + 'The lock provider SomeProvider does not exist.', + ], + ], + 'Empty host and path for Zookeeper' => [ + 'options' => [ + LockConfigOptionsList::INPUT_KEY_LOCK_PROVIDER => LockBackendFactory::LOCK_ZOOKEEPER, + LockConfigOptionsList::INPUT_KEY_LOCK_ZOOKEEPER_HOST => '', + LockConfigOptionsList::INPUT_KEY_LOCK_ZOOKEEPER_PATH => '', + ], + 'expectedResult' => [ + 'Zookeeper path needs to be a non-empty string.', + 'Zookeeper host is should be set.', + ], + ], + ]; + } +} diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsListTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsListTest.php index d7f680309c9ef..a85b468cebc92 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsListTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsListTest.php @@ -7,6 +7,7 @@ namespace Magento\Setup\Test\Unit\Model; use Magento\Framework\Config\ConfigOptionsListConstants; +use Magento\Setup\Model\ConfigOptionsList\Lock; use Magento\Setup\Model\ConfigGenerator; use Magento\Setup\Model\ConfigOptionsList; use Magento\Setup\Validator\DbValidator; @@ -82,7 +83,7 @@ public function testCreateOptions() $this->generator->expects($this->once())->method('createXFrameConfig')->willReturn($configDataMock); $this->generator->expects($this->once())->method('createCacheHostsConfig')->willReturn($configDataMock); - $configData = $this->object->createConfig([], $this->deploymentConfig); + $configData = $this->object->createConfig([Lock::INPUT_KEY_LOCK_PROVIDER => 'db'], $this->deploymentConfig); $this->assertGreaterThanOrEqual(6, count($configData)); } @@ -96,7 +97,7 @@ public function testCreateOptionsWithOptionalNull() $this->generator->expects($this->once())->method('createXFrameConfig')->willReturn($configDataMock); $this->generator->expects($this->once())->method('createCacheHostsConfig')->willReturn($configDataMock); - $configData = $this->object->createConfig([], $this->deploymentConfig); + $configData = $this->object->createConfig([Lock::INPUT_KEY_LOCK_PROVIDER => 'db'], $this->deploymentConfig); $this->assertGreaterThanOrEqual(6, count($configData)); } @@ -109,7 +110,8 @@ public function testValidateSuccess() ConfigOptionsListConstants::INPUT_KEY_DB_NAME => 'name', ConfigOptionsListConstants::INPUT_KEY_DB_HOST => 'host', ConfigOptionsListConstants::INPUT_KEY_DB_USER => 'user', - ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD => 'pass' + ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD => 'pass', + Lock::INPUT_KEY_LOCK_PROVIDER => 'db' ]; $this->prepareValidationMocks(); @@ -127,7 +129,8 @@ public function testValidateInvalidSessionHandler() ConfigOptionsListConstants::INPUT_KEY_DB_NAME => 'name', ConfigOptionsListConstants::INPUT_KEY_DB_HOST => 'host', ConfigOptionsListConstants::INPUT_KEY_DB_USER => 'user', - ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD => 'pass' + ConfigOptionsListConstants::INPUT_KEY_DB_PASSWORD => 'pass', + Lock::INPUT_KEY_LOCK_PROVIDER => 'db' ]; $this->prepareValidationMocks(); @@ -141,7 +144,8 @@ public function testValidateEmptyEncryptionKey() { $options = [ ConfigOptionsListConstants::INPUT_KEY_SKIP_DB_VALIDATION => true, - ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY => '' + ConfigOptionsListConstants::INPUT_KEY_ENCRYPTION_KEY => '', + Lock::INPUT_KEY_LOCK_PROVIDER => 'db' ]; $this->assertEquals( ['Invalid encryption key. Encryption key must be 32 character string without any white space.'], @@ -167,7 +171,8 @@ public function testValidateCacheHosts($hosts, $expectedError) { $options = [ ConfigOptionsListConstants::INPUT_KEY_SKIP_DB_VALIDATION => true, - ConfigOptionsListConstants::INPUT_KEY_CACHE_HOSTS => $hosts + ConfigOptionsListConstants::INPUT_KEY_CACHE_HOSTS => $hosts, + Lock::INPUT_KEY_LOCK_PROVIDER => 'db' ]; $result = $this->object->validate($options, $this->deploymentConfig); if ($expectedError) { From bcb2116f116344d8767623d6d731b58cd2201383 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Wed, 27 Feb 2019 16:05:46 -0600 Subject: [PATCH 033/162] MAGETWO-98151: Add support ZooKeeper locks --- lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php index c2119df300c52..d491678d4d7fc 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php @@ -171,7 +171,7 @@ private function getFullPathToLock(string $name): string * @return \Zookeeper * @throws RuntimeException */ - public function getProvider(): \Zookeeper + private function getProvider(): \Zookeeper { if (!$this->zookeeper) { $this->zookeeper = new \Zookeeper($this->host); From d4dd2e6bb7c331a167317e2b67126f1c39df6a0f Mon Sep 17 00:00:00 2001 From: Adarsh Khatri <me.adarshkhatri@gmail.com> Date: Thu, 28 Feb 2019 11:10:10 +1100 Subject: [PATCH 034/162] Update price-bundle.js --- .../Bundle/view/base/web/js/price-bundle.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js index d298c4d6845f0..ee3ab25e90875 100644 --- a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js +++ b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js @@ -376,12 +376,16 @@ define([ magicKey = _.keys(oneItemPrice)[0], lowest = false; - //sorting based on "price_qty" - if(tiers){ - tiers.sort(function (a, b) { - return a.price_qty - b.price_qty; - }); - } + //tiers is undefined when options has only one option + if (undefined == tiers) { + var firstKey = Object.keys(optionConfig)[0]; + tiers = optionConfig[firstKey].tierPrice; + } + + //sorting based on "price_qty" + tiers.sort( function (a, b) { + return a['price_qty'] - b['price_qty']; + }); _.each(tiers, function (tier, index) { if (tier['price_qty'] > qty) { From 6e1a2a067c454e22fcaf239b1da3972bce65ab53 Mon Sep 17 00:00:00 2001 From: Vitalii Zabaznov <vzabaznov@magento.com> Date: Thu, 28 Feb 2019 15:27:11 -0600 Subject: [PATCH 035/162] MC-13864: Consumer always read config from memory --- .../Model/MassConsumer.php | 8 +- .../Api/Data/PoisonPillInterface.php | 29 +++++++ .../Api/PoisonPillCompareInterface.php | 26 ++++++ .../Api/PoisonPillPutInterface.php | 24 ++++++ .../Api/PoisonPillReadInterface.php | 25 ++++++ .../MessageQueue/Model/CallbackInvoker.php | 61 ++++++++++++++ .../Magento/MessageQueue/Model/PoisonPill.php | 32 ++++++++ .../MessageQueue/Model/PoisonPillCompare.php | 38 +++++++++ .../MessageQueue/Model/PoisonPillFactory.php | 36 +++++++++ .../Model/ResourceModel/PoisonPill.php | 80 +++++++++++++++++++ .../Magento/MessageQueue/etc/db_schema.xml | 8 ++ app/code/Magento/MessageQueue/etc/di.xml | 5 ++ .../MessageQueue/CallbackInvoker.php | 2 +- .../MessageQueue/CallbackInvokerInterface.php | 21 +++++ .../Framework/MessageQueue/Consumer.php | 6 +- 15 files changed, 393 insertions(+), 8 deletions(-) create mode 100644 app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php create mode 100644 app/code/Magento/MessageQueue/Api/PoisonPillCompareInterface.php create mode 100644 app/code/Magento/MessageQueue/Api/PoisonPillPutInterface.php create mode 100644 app/code/Magento/MessageQueue/Api/PoisonPillReadInterface.php create mode 100644 app/code/Magento/MessageQueue/Model/CallbackInvoker.php create mode 100644 app/code/Magento/MessageQueue/Model/PoisonPill.php create mode 100644 app/code/Magento/MessageQueue/Model/PoisonPillCompare.php create mode 100644 app/code/Magento/MessageQueue/Model/PoisonPillFactory.php create mode 100644 app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php create mode 100644 lib/internal/Magento/Framework/MessageQueue/CallbackInvokerInterface.php diff --git a/app/code/Magento/AsynchronousOperations/Model/MassConsumer.php b/app/code/Magento/AsynchronousOperations/Model/MassConsumer.php index 86e691daa4213..af1ef4400e442 100644 --- a/app/code/Magento/AsynchronousOperations/Model/MassConsumer.php +++ b/app/code/Magento/AsynchronousOperations/Model/MassConsumer.php @@ -14,7 +14,7 @@ use Magento\Framework\MessageQueue\MessageLockException; use Magento\Framework\MessageQueue\ConnectionLostException; use Magento\Framework\Exception\NotFoundException; -use Magento\Framework\MessageQueue\CallbackInvoker; +use Magento\Framework\MessageQueue\CallbackInvokerInterface; use Magento\Framework\MessageQueue\ConsumerConfigurationInterface; use Magento\Framework\MessageQueue\EnvelopeInterface; use Magento\Framework\MessageQueue\QueueInterface; @@ -30,7 +30,7 @@ class MassConsumer implements ConsumerInterface { /** - * @var \Magento\Framework\MessageQueue\CallbackInvoker + * @var CallbackInvokerInterface */ private $invoker; @@ -67,7 +67,7 @@ class MassConsumer implements ConsumerInterface /** * Initialize dependencies. * - * @param CallbackInvoker $invoker + * @param CallbackInvokerInterface $invoker * @param ResourceConnection $resource * @param MessageController $messageController * @param ConsumerConfigurationInterface $configuration @@ -76,7 +76,7 @@ class MassConsumer implements ConsumerInterface * @param Registry $registry */ public function __construct( - CallbackInvoker $invoker, + CallbackInvokerInterface $invoker, ResourceConnection $resource, MessageController $messageController, ConsumerConfigurationInterface $configuration, diff --git a/app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php b/app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php new file mode 100644 index 0000000000000..f526e0d4ea067 --- /dev/null +++ b/app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php @@ -0,0 +1,29 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MessageQueue\Api\Data; + +/** + * PoisonPill data interface. + * + * @api + */ +interface PoisonPillInterface +{ + /** + * Returns version of poison pill. + * + * @return integer + */ + public function getVersion(): ?int; + + /** + * @param int $version + * @return void + */ + public function setVersion(int $version); +} diff --git a/app/code/Magento/MessageQueue/Api/PoisonPillCompareInterface.php b/app/code/Magento/MessageQueue/Api/PoisonPillCompareInterface.php new file mode 100644 index 0000000000000..32d57353f4426 --- /dev/null +++ b/app/code/Magento/MessageQueue/Api/PoisonPillCompareInterface.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MessageQueue\Api; + +use Magento\MessageQueue\Api\Data\PoisonPillInterface; + +/** + * Interface describes how to describes how to compare poison pill with latest in DB. + * + * @api + */ +interface PoisonPillCompareInterface +{ + /** + * Check is version of current poison pill is latest. + * + * @param PoisonPillInterface $poisonPill + * @return bool + */ + public function isLatest(PoisonPillInterface $poisonPill): bool; +} diff --git a/app/code/Magento/MessageQueue/Api/PoisonPillPutInterface.php b/app/code/Magento/MessageQueue/Api/PoisonPillPutInterface.php new file mode 100644 index 0000000000000..02293c99bb3f4 --- /dev/null +++ b/app/code/Magento/MessageQueue/Api/PoisonPillPutInterface.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MessageQueue\Api; + +/** + * Command interface describes how to create new version on poison pill. + * + * @api + */ +interface PoisonPillPutInterface +{ + /** + * Put new version of poison pill inside DB. + * + * @return int + * @throws \Exception + */ + public function put(): int; +} diff --git a/app/code/Magento/MessageQueue/Api/PoisonPillReadInterface.php b/app/code/Magento/MessageQueue/Api/PoisonPillReadInterface.php new file mode 100644 index 0000000000000..325cfd597956a --- /dev/null +++ b/app/code/Magento/MessageQueue/Api/PoisonPillReadInterface.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MessageQueue\Api; + +use Magento\MessageQueue\Api\Data\PoisonPillInterface; + +/** + * Describes how to get latest version of poison pill. + * + * @api + */ +interface PoisonPillReadInterface +{ + /** + * Returns latest poison pill. + * + * @return PoisonPillInterface + */ + public function getLatest(): PoisonPillInterface; +} diff --git a/app/code/Magento/MessageQueue/Model/CallbackInvoker.php b/app/code/Magento/MessageQueue/Model/CallbackInvoker.php new file mode 100644 index 0000000000000..465c2d366c582 --- /dev/null +++ b/app/code/Magento/MessageQueue/Model/CallbackInvoker.php @@ -0,0 +1,61 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MessageQueue\Model; + +use Magento\Framework\MessageQueue\CallbackInvokerInterface; +use Magento\Framework\MessageQueue\QueueInterface; +use Magento\MessageQueue\Api\Data\PoisonPillInterface; +use Magento\MessageQueue\Api\PoisonPillCompareInterface; +use Magento\MessageQueue\Api\PoisonPillReadInterface; + +class CallbackInvoker implements CallbackInvokerInterface +{ + /** + * @var PoisonPillReadInterface $poisonPillRead + */ + private $poisonPillRead; + + /** + * @var PoisonPillInterface $poisonPill + */ + private $poisonPill; + + /** + * @var PoisonPillCompareInterface + */ + private $poisonPillCompare; + + /** + * @param PoisonPillReadInterface $poisonPillRead + * @param PoisonPillCompareInterface $poisonPillCompare + */ + public function __construct( + PoisonPillReadInterface $poisonPillRead, + PoisonPillCompareInterface $poisonPillCompare + ) { + $this->poisonPillRead = $poisonPillRead; + $this->poisonPill = $poisonPillRead->getLatest(); + $this->poisonPillCompare = $poisonPillCompare; + } + + /** + * @inheritdoc + */ + public function invoke(QueueInterface $queue, $maxNumberOfMessages, $callback) + { + for ($i = $maxNumberOfMessages; $i > 0; $i--) { + do { + $message = $queue->dequeue(); + } while ($message === null && (sleep(1) === 0)); + if (false === $this->poisonPillCompare->isLatest($this->poisonPill)) { + exit(0); + } + $callback($message); + } + } +} diff --git a/app/code/Magento/MessageQueue/Model/PoisonPill.php b/app/code/Magento/MessageQueue/Model/PoisonPill.php new file mode 100644 index 0000000000000..a253ca4c13aa0 --- /dev/null +++ b/app/code/Magento/MessageQueue/Model/PoisonPill.php @@ -0,0 +1,32 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MessageQueue\Model; + +use Magento\MessageQueue\Api\Data\PoisonPillInterface; + +/** + * PoisonPill data class + */ +class PoisonPill extends \Magento\Framework\Model\AbstractModel implements PoisonPillInterface +{ + /** + * @inheritdoc + */ + public function getVersion(): ?int + { + return $this->_getData('version'); + } + + /** + * @inheritdoc + */ + public function setVersion(int $version) + { + $this->setData('version', $version); + } +} diff --git a/app/code/Magento/MessageQueue/Model/PoisonPillCompare.php b/app/code/Magento/MessageQueue/Model/PoisonPillCompare.php new file mode 100644 index 0000000000000..4aa76b4fadfcc --- /dev/null +++ b/app/code/Magento/MessageQueue/Model/PoisonPillCompare.php @@ -0,0 +1,38 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MessageQueue\Model; + +use Magento\MessageQueue\Api\Data\PoisonPillInterface; +use Magento\MessageQueue\Api\PoisonPillCompareInterface; +use Magento\MessageQueue\Api\PoisonPillReadInterface; + +class PoisonPillCompare implements PoisonPillCompareInterface +{ + /** + * @var PoisonPillReadInterface + */ + private $poisonPillRead; + + /** + * PoisonPillCompare constructor. + * @param PoisonPillReadInterface $poisonPillRead + */ + public function __construct( + PoisonPillReadInterface $poisonPillRead + ) { + $this->poisonPillRead = $poisonPillRead; + } + + /** + * @inheritdoc + */ + public function isLatest(PoisonPillInterface $poisonPill): bool + { + return $poisonPill->getVersion() === $this->poisonPillRead->getLatest()->getVersion(); + } +} diff --git a/app/code/Magento/MessageQueue/Model/PoisonPillFactory.php b/app/code/Magento/MessageQueue/Model/PoisonPillFactory.php new file mode 100644 index 0000000000000..0fd85c998866b --- /dev/null +++ b/app/code/Magento/MessageQueue/Model/PoisonPillFactory.php @@ -0,0 +1,36 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MessageQueue\Model; + +use Magento\MessageQueue\Api\Data\PoisonPillInterface; + +class PoisonPillFactory +{ + /** + * @var PoisonPillInterface + */ + private $poisonPill; + + /** + * @param PoisonPillInterface $poisonPill + */ + public function __construct( + PoisonPillInterface $poisonPill + ) { + $this->poisonPill = $poisonPill; + } + + /** + * @param int $version + * @return PoisonPillInterface + */ + public function create(int $version): PoisonPillInterface + { + + } +} diff --git a/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php b/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php new file mode 100644 index 0000000000000..769f723dc9d5a --- /dev/null +++ b/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php @@ -0,0 +1,80 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MessageQueue\Model\ResourceModel; + +use Magento\MessageQueue\Api\Data\PoisonPillInterface; +use Magento\MessageQueue\Api\Data\PoisonPillInterfaceFactory; +use Magento\MessageQueue\Api\PoisonPillReadInterface; +use Magento\MessageQueue\Api\PoisonPillPutInterface; +use Magento\Framework\Model\ResourceModel\Db\Context; +use Magento\Framework\Model\ResourceModel\Db\AbstractDb; + +class PoisonPill extends AbstractDb implements PoisonPillPutInterface, PoisonPillReadInterface +{ + /** + * Table name. + */ + const QUEUE_POISON_PILL_TABLE = 'queue_poison_pill'; + + /** + * @var PoisonPillInterfaceFactory + */ + private $poisonPillFactory; + + /** + * @param Context $context + * @param string|null $connectionName + */ + public function __construct( + Context $context, + PoisonPillInterfaceFactory $poisonPillFactory, + string $connectionName = null + ) { + $this->poisonPillFactory = $poisonPillFactory; + parent::__construct($context, $connectionName); + } + + /** + * @inheritdoc + */ + protected function _construct() + { + $this->_init(self::QUEUE_POISON_PILL_TABLE, 'version'); + } + + /** + * @inheritdoc + */ + public function put(): int + { + /** @var PoisonPillInterface $poisonPill */ + $poisonPill = $this->poisonPillFactory->create(); + return $this->save($poisonPill)->getConnection()->lastInsertId(); + } + + /** + * @inheritdoc + */ + public function getLatest() : PoisonPillInterface + { + $select = $this->getConnection()->select()->from( + $this->getTable(self::QUEUE_POISON_PILL_TABLE), + 'version' + )->order( + 'version ' . \Magento\Framework\DB\Select::SQL_DESC + )->limit( + 1 + ); + + $version = $this->getConnection()->fetchOne($select); + + $poisonPill = $this->poisonPillFactory->create(['data' => ['version' => (int) $version]]); + + return $poisonPill; + } +} diff --git a/app/code/Magento/MessageQueue/etc/db_schema.xml b/app/code/Magento/MessageQueue/etc/db_schema.xml index 7a20d2bd4df5d..9cdf414dd06e1 100644 --- a/app/code/Magento/MessageQueue/etc/db_schema.xml +++ b/app/code/Magento/MessageQueue/etc/db_schema.xml @@ -21,4 +21,12 @@ <column name="message_code"/> </constraint> </table> + <table name="queue_poison_pill" resource="default" engine="innodb" + comment="Sequence table for poison pill versions"> + <column xsi:type="int" name="version" padding="10" unsigned="true" nullable="false" identity="true" + comment="Poison Pill version."/> + <constraint xsi:type="primary" referenceId="PRIMARY"> + <column name="version"/> + </constraint> + </table> </schema> diff --git a/app/code/Magento/MessageQueue/etc/di.xml b/app/code/Magento/MessageQueue/etc/di.xml index c8f2edb862613..3b2cb8718e041 100644 --- a/app/code/Magento/MessageQueue/etc/di.xml +++ b/app/code/Magento/MessageQueue/etc/di.xml @@ -13,6 +13,11 @@ <preference for="Magento\Framework\MessageQueue\EnvelopeInterface" type="Magento\Framework\MessageQueue\Envelope"/> <preference for="Magento\Framework\MessageQueue\ConsumerInterface" type="Magento\Framework\MessageQueue\Consumer"/> <preference for="Magento\Framework\MessageQueue\MergedMessageInterface" type="Magento\Framework\MessageQueue\MergedMessage"/> + <preference for="Magento\MessageQueue\Api\Data\PoisonPillInterface" type="Magento\MessageQueue\Model\PoisonPill"/> + <preference for="Magento\MessageQueue\Api\PoisonPillCompareInterface" type="Magento\MessageQueue\Model\PoisonPillCompare"/> + <preference for="Magento\MessageQueue\Api\PoisonPillPutInterface" type="Magento\MessageQueue\Model\ResourceModel\PoisonPill"/> + <preference for="Magento\MessageQueue\Api\PoisonPillReadInterface" type="Magento\MessageQueue\Model\ResourceModel\PoisonPill"/> + <preference for="Magento\Framework\MessageQueue\CallbackInvokerInterface" type="Magento\MessageQueue\Model\CallbackInvoker"/> <type name="Magento\Framework\Console\CommandListInterface"> <arguments> <argument name="commands" xsi:type="array"> diff --git a/lib/internal/Magento/Framework/MessageQueue/CallbackInvoker.php b/lib/internal/Magento/Framework/MessageQueue/CallbackInvoker.php index cb80bc4becaec..48c33c48f12e6 100644 --- a/lib/internal/Magento/Framework/MessageQueue/CallbackInvoker.php +++ b/lib/internal/Magento/Framework/MessageQueue/CallbackInvoker.php @@ -9,7 +9,7 @@ /** * Class CallbackInvoker to invoke callbacks for consumer classes */ -class CallbackInvoker +class CallbackInvoker implements CallbackInvokerInterface { /** * Run short running process diff --git a/lib/internal/Magento/Framework/MessageQueue/CallbackInvokerInterface.php b/lib/internal/Magento/Framework/MessageQueue/CallbackInvokerInterface.php new file mode 100644 index 0000000000000..bae72d8186a18 --- /dev/null +++ b/lib/internal/Magento/Framework/MessageQueue/CallbackInvokerInterface.php @@ -0,0 +1,21 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\MessageQueue; + +interface CallbackInvokerInterface +{ + /** + * Run short running process + * + * @param QueueInterface $queue + * @param int $maxNumberOfMessages + * @param \Closure $callback + * @return void + */ + public function invoke(QueueInterface $queue, $maxNumberOfMessages, $callback); +} diff --git a/lib/internal/Magento/Framework/MessageQueue/Consumer.php b/lib/internal/Magento/Framework/MessageQueue/Consumer.php index 9bdacfbc1ff6c..72c5f2e0cbdfc 100644 --- a/lib/internal/Magento/Framework/MessageQueue/Consumer.php +++ b/lib/internal/Magento/Framework/MessageQueue/Consumer.php @@ -38,7 +38,7 @@ class Consumer implements ConsumerInterface private $messageEncoder; /** - * @var CallbackInvoker + * @var CallbackInvokerInterface */ private $invoker; @@ -80,7 +80,7 @@ class Consumer implements ConsumerInterface /** * Initialize dependencies. * - * @param CallbackInvoker $invoker + * @param CallbackInvokerInterface $invoker * @param MessageEncoder $messageEncoder * @param ResourceConnection $resource * @param ConsumerConfigurationInterface $configuration @@ -89,7 +89,7 @@ class Consumer implements ConsumerInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function __construct( - CallbackInvoker $invoker, + CallbackInvokerInterface $invoker, MessageEncoder $messageEncoder, ResourceConnection $resource, ConsumerConfigurationInterface $configuration, From 0cc4fbaf6354b280e9b05889aedfc108bc2e1b37 Mon Sep 17 00:00:00 2001 From: Maria Kovdrysh <kovdrysh@adobe.com> Date: Thu, 28 Feb 2019 15:46:25 -0600 Subject: [PATCH 036/162] MC-4435: Convert MassDeleteSearchTermEntityTest to MFTF --- .../AdminSearchTermActionGroup.xml | 30 +++++++ .../Search/Test/Mftf/Data/SearchTermData.xml | 17 ++++ .../Test/Mftf/Metadata/search_term-meta.xml | 17 ++++ .../AdminMassDeleteSearchTermEntityTest.xml | 83 +++++++++++++++++++ 4 files changed, 147 insertions(+) create mode 100644 app/code/Magento/Search/Test/Mftf/ActionGroup/AdminSearchTermActionGroup.xml create mode 100644 app/code/Magento/Search/Test/Mftf/Data/SearchTermData.xml create mode 100644 app/code/Magento/Search/Test/Mftf/Metadata/search_term-meta.xml create mode 100644 app/code/Magento/Search/Test/Mftf/Test/AdminMassDeleteSearchTermEntityTest.xml diff --git a/app/code/Magento/Search/Test/Mftf/ActionGroup/AdminSearchTermActionGroup.xml b/app/code/Magento/Search/Test/Mftf/ActionGroup/AdminSearchTermActionGroup.xml new file mode 100644 index 0000000000000..f116e44e5c141 --- /dev/null +++ b/app/code/Magento/Search/Test/Mftf/ActionGroup/AdminSearchTermActionGroup.xml @@ -0,0 +1,30 @@ +<?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"> + <!-- Filter by search query and select --> + <actionGroup name="searchTermFilterBySearchQuery"> + <arguments> + <argument name="searchQuery" type="string"/> + </arguments> + <click selector="{{AdminCatalogSearchTermIndexSection.resetFilterButton}}" stepKey="clickOnResetButton"/> + <waitForPageLoad stepKey="waitForResetFilter"/> + <fillField selector="{{AdminCatalogSearchTermIndexSection.searchQuery}}" userInput="{{searchQuery}}" stepKey="fillSearchQuery"/> + <click selector="{{AdminCatalogSearchTermIndexSection.searchButton}}" stepKey="clickSearchButton"/> + <waitForPageLoad stepKey="waitForSearchResultLoad"/> + <checkOption selector="{{AdminCatalogSearchTermIndexSection.checkBox}}" stepKey="checkCheckBox"/> + </actionGroup> + + <!-- Delete search term --> + <actionGroup name="deleteSearchTerm"> + <selectOption selector="{{AdminCatalogSearchTermIndexSection.delete}}" userInput="delete" stepKey="selectDeleteOption"/> + <click selector="{{AdminCatalogSearchTermIndexSection.submit}}" stepKey="clickSubmitButton"/> + <click selector="{{AdminCatalogSearchTermIndexSection.okButton}}" stepKey="clickOkButton"/> + <waitForElementVisible selector="{{AdminCatalogSearchTermMessagesSection.successMessage}}" stepKey="waitForSuccessMessage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Search/Test/Mftf/Data/SearchTermData.xml b/app/code/Magento/Search/Test/Mftf/Data/SearchTermData.xml new file mode 100644 index 0000000000000..1518adad01347 --- /dev/null +++ b/app/code/Magento/Search/Test/Mftf/Data/SearchTermData.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="SearchTerm" type="searchTerm"> + <data key="query_text" unique="suffix">Query text</data> + <data key="store_id">1</data> + <data key="redirect" unique="suffix">http://example.com/</data> + <data key="display_in_terms">0</data> + </entity> +</entities> diff --git a/app/code/Magento/Search/Test/Mftf/Metadata/search_term-meta.xml b/app/code/Magento/Search/Test/Mftf/Metadata/search_term-meta.xml new file mode 100644 index 0000000000000..0bd2dc9be4855 --- /dev/null +++ b/app/code/Magento/Search/Test/Mftf/Metadata/search_term-meta.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd"> + <operation name="CreateSearchTerm" dataType="searchTerm" type="create" auth="adminFormKey" url="/search/term/save/" method="POST"> + <field key="query_text">string</field> + <field key="store_id">integer</field> + <field key="redirect">string</field> + <field key="display_in_terms">integer</field> + </operation> +</operations> diff --git a/app/code/Magento/Search/Test/Mftf/Test/AdminMassDeleteSearchTermEntityTest.xml b/app/code/Magento/Search/Test/Mftf/Test/AdminMassDeleteSearchTermEntityTest.xml new file mode 100644 index 0000000000000..eb0797d07bf18 --- /dev/null +++ b/app/code/Magento/Search/Test/Mftf/Test/AdminMassDeleteSearchTermEntityTest.xml @@ -0,0 +1,83 @@ +<?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="AdminMassDeleteSearchTermEntityTest"> + <annotations> + <features value="CatalogSearch"/> + <stories value="Delete search term"/> + <title value="Admin mass delete search term entity test"/> + <description value="Admin should be able to Mass Delete Search Term Entity Test"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-14767"/> + <group value="searchFrontend"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <!-- Create three search term --> + <createData entity="SearchTerm" stepKey="createFirstSearchTerm"/> + <createData entity="SearchTerm" stepKey="createSecondSearchTerm"/> + <createData entity="SearchTerm" stepKey="createThirdSearchTerm"/> + + <!-- Login as admin --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <!-- Log out --> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Go to the catalog search term page --> + <amOnPage url="{{AdminCatalogSearchTermIndexPage.url}}" stepKey="openAdminCatalogSearchTermIndexPage"/> + <waitForPageLoad stepKey="waitForAdminCatalogSearchTermIndexPageLoad"/> + + <!-- Select all created below search terms --> + <actionGroup ref="searchTermFilterBySearchQuery" stepKey="filterByFirstSearchQuery"> + <argument name="searchQuery" value="$createFirstSearchTerm.query_text$"/> + </actionGroup> + <actionGroup ref="searchTermFilterBySearchQuery" stepKey="filterBySecondSearchQuery"> + <argument name="searchQuery" value="$createSecondSearchTerm.query_text$"/> + </actionGroup> + <actionGroup ref="searchTermFilterBySearchQuery" stepKey="filterByThirdSearchQuery"> + <argument name="searchQuery" value="$createThirdSearchTerm.query_text$"/> + </actionGroup> + + <!-- Delete created below search terms --> + <actionGroup ref="deleteSearchTerm" stepKey="deleteSearchTerms"/> + + <!-- Assert search terms are absent on the search term page --> + <actionGroup ref="AssertSearchTermNotInGrid" stepKey="assertFirstSearchTermNotInGrid"> + <argument name="searchQuery" value="$createFirstSearchTerm.query_text$"/> + </actionGroup> + <actionGroup ref="AssertSearchTermNotInGrid" stepKey="assertSecondSearchTermNotInGrid"> + <argument name="searchQuery" value="$createSecondSearchTerm.query_text$"/> + </actionGroup> + <actionGroup ref="AssertSearchTermNotInGrid" stepKey="assertThirdSearchTermNotInGrid"> + <argument name="searchQuery" value="$createThirdSearchTerm.query_text$"/> + </actionGroup> + + <!-- Go to storefront page --> + <amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToStorefrontPage"/> + <waitForPageLoad stepKey="waitForStorefrontPageLoad"/> + + <!-- Verify search term deletion on storefront --> + <actionGroup ref="StorefrontCheckQuickSearchActionGroup" stepKey="quickSearchForFirstSearchTerm"> + <argument name="phrase" value="$createFirstSearchTerm.query_text$"/> + </actionGroup> + <actionGroup ref="StorefrontCheckSearchIsEmpty" stepKey="checkEmptyForFirstSearchTerm"/> + <actionGroup ref="StorefrontCheckQuickSearchActionGroup" stepKey="quickSearchForSecondSearchTerm"> + <argument name="phrase" value="$createSecondSearchTerm.query_text$"/> + </actionGroup> + <actionGroup ref="StorefrontCheckSearchIsEmpty" stepKey="checkEmptyForSecondSearchTerm"/> + <actionGroup ref="StorefrontCheckQuickSearchActionGroup" stepKey="quickSearchForThirdSearchTerm"> + <argument name="phrase" value="$createThirdSearchTerm.query_text$"/> + </actionGroup> + <actionGroup ref="StorefrontCheckSearchIsEmpty" stepKey="checkEmptyForThirdSearchTerm"/> + </test> +</tests> From e7589ad85786211022c3860c78ccb21a26f69e8f Mon Sep 17 00:00:00 2001 From: Adarsh Khatri <me.adarshkhatri@gmail.com> Date: Fri, 1 Mar 2019 09:55:10 +1100 Subject: [PATCH 037/162] Update price-bundle.js --- .../Bundle/view/base/web/js/price-bundle.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js index ee3ab25e90875..02d55d50025cc 100644 --- a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js +++ b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js @@ -374,16 +374,14 @@ define([ function applyTierPrice(oneItemPrice, qty, optionConfig) { var tiers = optionConfig.tierPrice, magicKey = _.keys(oneItemPrice)[0], + tiersFirstKey = _.keys(optionConfig)[0], lowest = false; - - //tiers is undefined when options has only one option - if (undefined == tiers) { - var firstKey = Object.keys(optionConfig)[0]; - tiers = optionConfig[firstKey].tierPrice; - } - - //sorting based on "price_qty" - tiers.sort( function (a, b) { + + if (undefined === tiers) {//tiers is undefined when options has only one option + tiers = optionConfig[tiersFirstKey].tierPrice; + } + + tiers.sort( function (a, b) {//sorting based on "price_qty" return a['price_qty'] - b['price_qty']; }); From 6f49b07031e8e9248a19d8f3ee20402650e60d30 Mon Sep 17 00:00:00 2001 From: Adarsh Khatri <me.adarshkhatri@gmail.com> Date: Fri, 1 Mar 2019 10:01:05 +1100 Subject: [PATCH 038/162] Update price-bundle.js --- app/code/Magento/Bundle/view/base/web/js/price-bundle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js index 02d55d50025cc..c05c9ef58b938 100644 --- a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js +++ b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js @@ -381,7 +381,7 @@ define([ tiers = optionConfig[tiersFirstKey].tierPrice; } - tiers.sort( function (a, b) {//sorting based on "price_qty" + tiers.sort(function (a, b) {//sorting based on "price_qty" return a['price_qty'] - b['price_qty']; }); From 0332391af0883d78daa90de5bafc93a5e67765a2 Mon Sep 17 00:00:00 2001 From: Adarsh Khatri <me.adarshkhatri@gmail.com> Date: Fri, 1 Mar 2019 22:59:03 +1100 Subject: [PATCH 039/162] Update price-bundle.js --- app/code/Magento/Bundle/view/base/web/js/price-bundle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js index c05c9ef58b938..f8d2f8bc11116 100644 --- a/app/code/Magento/Bundle/view/base/web/js/price-bundle.js +++ b/app/code/Magento/Bundle/view/base/web/js/price-bundle.js @@ -377,7 +377,7 @@ define([ tiersFirstKey = _.keys(optionConfig)[0], lowest = false; - if (undefined === tiers) {//tiers is undefined when options has only one option + if (!tiers) {//tiers is undefined when options has only one option tiers = optionConfig[tiersFirstKey].tierPrice; } From b27f6944a38a88ad05993ba441a84a7f0d7923c9 Mon Sep 17 00:00:00 2001 From: sathakur <sathakur@adobe.com> Date: Fri, 1 Mar 2019 14:36:17 -0600 Subject: [PATCH 040/162] MC-4869: Convert DeleteStoreEntityTest to MFTF --- .../ActionGroup/DeleteBackupActionGroup.xml | 2 + .../Backup/Test/Mftf/Data/BackupData.xml | 6 +- .../AdminDeleteStoreViewActionGroup.xml | 35 +++++++++++- .../Mftf/Section/AdminStoresGridSection.xml | 4 +- .../Test/Mftf/Test/AdminDeleteStoreTest.xml | 57 +++++++++++++++++++ 5 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreTest.xml diff --git a/app/code/Magento/Backup/Test/Mftf/ActionGroup/DeleteBackupActionGroup.xml b/app/code/Magento/Backup/Test/Mftf/ActionGroup/DeleteBackupActionGroup.xml index 4f34f24c3a806..535478153f517 100644 --- a/app/code/Magento/Backup/Test/Mftf/ActionGroup/DeleteBackupActionGroup.xml +++ b/app/code/Magento/Backup/Test/Mftf/ActionGroup/DeleteBackupActionGroup.xml @@ -17,7 +17,9 @@ <click selector="{{AdminGridTableSection.backupRowCheckbox(backup.name)}}" stepKey="selectBackupRow"/> <selectOption selector="{{AdminGridActionSection.actionSelect}}" userInput="Delete" stepKey="selectDeleteAction"/> <click selector="{{AdminGridActionSection.submitButton}}" stepKey="clickSubmit"/> + <waitForPageLoad stepKey="waitForSubmitAction"/> <see selector="{{AdminConfirmationModalSection.message}}" userInput="Are you sure you want to delete the selected backup(s)?" stepKey="seeConfirmationModal"/> + <waitForPageLoad stepKey="waitForConfirmWindowToAppear"/> <click selector="{{AdminConfirmationModalSection.ok}}" stepKey="clickOkConfirmDelete"/> <dontSee selector="{{AdminGridTableSection.backupNameColumn}}" userInput="{{backup.name}}" stepKey="dontSeeBackupInGrid"/> </actionGroup> diff --git a/app/code/Magento/Backup/Test/Mftf/Data/BackupData.xml b/app/code/Magento/Backup/Test/Mftf/Data/BackupData.xml index ae97351cafcaf..ad218cdd57500 100644 --- a/app/code/Magento/Backup/Test/Mftf/Data/BackupData.xml +++ b/app/code/Magento/Backup/Test/Mftf/Data/BackupData.xml @@ -20,4 +20,8 @@ <data key="name" unique="suffix">databaseBackup</data> <data key="type">Database</data> </entity> -</entities> + <entity name="WebSetupWizardBackup" type="backup"> + <data key="name">WebSetupWizard</data> + <data key="type">Database</data> + </entity> +</entities> \ No newline at end of file diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminDeleteStoreViewActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminDeleteStoreViewActionGroup.xml index 58e1781d69eab..a08648bc8b8c6 100644 --- a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminDeleteStoreViewActionGroup.xml +++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminDeleteStoreViewActionGroup.xml @@ -26,4 +26,37 @@ <waitForPageLoad stepKey="waitForSuccessMessage"/> <see userInput="You deleted the store view." stepKey="seeDeleteMessage"/> </actionGroup> -</actionGroups> + <!--AssertStoreSuccessDeleteAndBackupMessages--> + <actionGroup name="DeleteCustomStoreViewBackupEnabledYesActionGroup"> + <arguments> + <argument name="storeViewName" type="string"/> + </arguments> + <amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/> + <click selector="{{AdminStoresGridSection.resetButton}}" stepKey="resetSearchFilter"/> + <fillField userInput="{{storeViewName}}" selector="{{AdminStoresGridSection.storeFilterTextField}}" stepKey="fillSearchStoreViewField"/> + <click selector="{{AdminStoresGridSection.searchButton}}" stepKey="clickSearchButton"/> + <click selector="{{AdminStoresGridSection.storeNameInFirstRow}}" stepKey="clickEditExistingStoreViewRow"/> + <waitForPageLoad stepKey="waitForStoreToLoad"/> + <click selector="{{AdminNewStoreViewActionsSection.delete}}" stepKey="clickDeleteStoreViewButtonOnEditStorePage"/> + <selectOption userInput="Yes" selector="{{AdminStoreBackupOptionsSection.createBackupSelect}}" stepKey="setCreateDbBackupToYes"/> + <click selector="{{AdminNewStoreViewActionsSection.delete}}" stepKey="clickDeleteStoreViewButtonOnDeleteStorePage"/> + <waitForElementVisible selector="{{AdminConfirmationModalSection.title}}" stepKey="waitingForWarningModal"/> + <click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmStoreViewDelete"/> + <waitForPageLoad stepKey="waitForSuccessMessage"/> + <see selector="{{AdminStoresGridSection.successMessage}}" userInput="The database was backed up." stepKey="seeAssertDatabaseBackedUpMessage"/> + <see selector="{{AdminStoresGridSection.successMessage}}" userInput="You deleted the store view." stepKey="seeAssertSuccessDeleteStoreViewMessage"/> + </actionGroup> + <!--AssertStoreViewNotInGrid--> + <actionGroup name="AssertStoreViewNotInGrid"> + <arguments> + <argument name="storeViewName" type="string"/> + </arguments> + <amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/> + <waitForPageLoad stepKey="waitForAdminSystemStorePageLoad"/> + <click selector="{{AdminStoresGridSection.resetButton}}" stepKey="resetSearchFilter"/> + <fillField userInput="{{storeViewName}}" selector="{{AdminStoresGridSection.storeFilterTextField}}" stepKey="fillSearchStoreViewField"/> + <click selector="{{AdminStoresGridSection.searchButton}}" stepKey="clickSearchButton"/> + <waitForPageLoad stepKey="waitForStoreToLoad"/> + <see selector="{{AdminStoresGridSection.emptyText}}" userInput="We couldn't find any records." stepKey="seeAssertStoreViewNotInGridMessage"/> + </actionGroup> +</actionGroups> \ No newline at end of file diff --git a/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml b/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml index b02e9adaed45e..3d3ec7fa28629 100644 --- a/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml +++ b/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml @@ -21,5 +21,7 @@ <element name="storeGrpNameInFirstRow" type="text" selector=".col-group_title>a"/> <element name="storeNameInFirstRow" type="text" selector=".col-store_title>a"/> <element name="firstRow" type="textarea" selector="(//*[@id='storeGrid_table']/tbody/tr)[1]"/> + <element name="successMessage" type="text" selector="//div[@class='message message-success success']/div"/> + <element name="emptyText" type="text" selector="//tr[@class='data-grid-tr-no-data even']/td[@class='empty-text']"/> </section> -</sections> +</sections> \ No newline at end of file diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreTest.xml new file mode 100644 index 0000000000000..37829f4782413 --- /dev/null +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreTest.xml @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<!-- Test XML Example --> +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminDeleteStoreTest"> + <annotations> + <stories value="Delete Store View"/> + <title value="DeleteStoreEntityTestVariation1"/> + <description value="Test log in to Stores and Delete Store View"/> + <testCaseId value="MC-14303"/> + <severity value="CRITICAL"/> + <group value="store"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <magentoCLI command="config:set system/backup/functionality_enabled 1" stepKey="setEnableBackupToYes"/> + <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <!--Create custom store view--> + <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createNewStoreView"> + <argument name="StoreGroup" value="_defaultStoreGroup"/> + <argument name="customStore" value="storeViewData"/> + </actionGroup> + </before> + <after> + <magentoCLI command="config:set system/backup/functionality_enabled 0" stepKey="setEnableBackupToNo"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!--AssertStoreSuccessDeleteAndBackupMessages--> + <actionGroup ref="DeleteCustomStoreViewBackupEnabledYesActionGroup" stepKey="deleteCustomStoreView"> + <argument name="storeViewName" value="{{storeViewData.name}}"/> + </actionGroup> + + <!--AssertStoreNotInGrid--> + <actionGroup ref="AssertStoreViewNotInGrid" stepKey="verifyDeletedStoreViewNotInGrid"> + <argument name="storeViewName" value="{{storeViewData.name}}"/> + </actionGroup> + + <!--Go to backup index page, verify AssertBackupInGrid--> + <amOnPage url="{{BackupIndexPage.url}}" stepKey="goToBackupIndexPage"/> + <waitForPageLoad stepKey="waitForBackupIndexPageLoad"/> + <!--Delete database backup--> + <actionGroup ref="deleteBackup" stepKey="deleteDatabaseBackup"> + <argument name="backup" value="WebSetupWizardBackup"/> + </actionGroup> + + <!--Go to storefront and verify AssertStoreNotOnFrontend--> + <amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToStorefrontPage"/> + <waitForPageLoad stepKey="waitForStorefrontHomePageLoad"/> + <dontSee selector="{{StorefrontHeaderSection.storeViewList(storeViewData.name)}}" stepKey="dontSeeAssertStoreViewNameOnStorefront"/> + </test> +</tests> \ No newline at end of file From 1ee5d3877b7f842d45f8adc045fe0ba2dbba8073 Mon Sep 17 00:00:00 2001 From: Mila Lesechko <l.lesechko@gmail.com> Date: Sun, 3 Mar 2019 15:48:18 -0600 Subject: [PATCH 041/162] 632: Convert UpdateProductFromMiniShoppingCartEntityTest to MFTF --- .../Catalog/Test/Mftf/Data/ProductData.xml | 16 +++++ ...oppingCartCheckSummaryTotalActionGroup.xml | 21 +++++++ .../Checkout/Test/Mftf/Data/QuoteData.xml | 8 +++ ...eProductFromMiniShoppingCartEntityTest.xml | 58 +++++++++++++++++++ ...eProductFromMiniShoppingCartEntityTest.xml | 2 +- 5 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/ShoppingCartCheckSummaryTotalActionGroup.xml create mode 100644 app/code/Magento/Checkout/Test/Mftf/Test/UpdateProductFromMiniShoppingCartEntityTest.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml index d812123e4b553..65e30f98c2ca5 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml @@ -869,4 +869,20 @@ <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> <requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity> </entity> + <entity name="simpleProductWithoutCategory" type="product"> + <data key="sku" unique="suffix">sku_simple_product_</data> + <data key="type_id">simple</data> + <data key="attribute_set_id">4</data> + <data key="visibility">4</data> + <data key="name" unique="suffix">SimpleProduct</data> + <data key="price">560</data> + <data key="urlKey" unique="suffix">simple-product-</data> + <data key="status">1</data> + <data key="quantity">25</data> + <data key="weight">1</data> + <data key="product_has_weight">1</data> + <data key="is_in_stock">1</data> + <data key="tax_class_id">2</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + </entity> </entities> diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/ShoppingCartCheckSummaryTotalActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/ShoppingCartCheckSummaryTotalActionGroup.xml new file mode 100644 index 0000000000000..70b4e95124da8 --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/ShoppingCartCheckSummaryTotalActionGroup.xml @@ -0,0 +1,21 @@ +<?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="ShoppingCartCheckSummaryTotalActionGroup"> + <arguments> + <argument name="dataQuote" type="entity"/> + </arguments> + <waitForPageLoad stepKey="waitForPageLoad" time="120"/> + <grabTextFrom selector="{{CheckoutCartSummarySection.total}}" stepKey="grabCartTotal" /> + <assertContains stepKey="assertCartTotal"> + <actualResult type="variable">$grabCartTotal</actualResult> + <expectedResult type="string">{{dataQuote.total}}</expectedResult> + </assertContains> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml b/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml index 530157851191f..be6e1af67fc63 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml @@ -15,4 +15,12 @@ <data key="total">495.00</data> <data key="shippingMethod">Flat Rate - Fixed</data> </entity> + <entity name="simpleOrderQty2" type="Quote"> + <data key="price">560.00</data> + <data key="qty">2</data> + <data key="subtotal">1,120.00</data> + <data key="shipping">10.00</data> + <data key="total">1,130.00</data> + <data key="shippingMethod">Flat Rate - Fixed</data> + </entity> </entities> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/UpdateProductFromMiniShoppingCartEntityTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/UpdateProductFromMiniShoppingCartEntityTest.xml new file mode 100644 index 0000000000000..451bce9e49a8f --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/Test/UpdateProductFromMiniShoppingCartEntityTest.xml @@ -0,0 +1,58 @@ +<?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="UpdateProductFromMiniShoppingCartEntityTest"> + <annotations> + <stories value="Shopping Cart"/> + <title value="Check updating product from mini shopping cart"/> + <description value="Update Product Qty on Mini Shopping Cart"/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-29812"/> + <group value="shoppingCart"/> + <group value="mtf_migrated"/> + </annotations> + + <before> + <!--Create product according to dataset.--> + <createData entity="simpleProductWithoutCategory" stepKey="createProduct"/> + + <!-- Go to frontend --> + <amOnPage url="{{StorefrontProductPage.url($$createProduct.name$$)}}" stepKey="navigateToProductPage"/> + + <!--Add product to cart--> + <actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartFromStorefrontProductPage"> + <argument name="productName" value="$$createProduct.name$$"/> + </actionGroup> + </before> + + <after> + <!--Delete created data--> + <deleteData createDataKey="createProduct" stepKey="deleteProduct" /> + </after> + + <!-- Click on mini shopping cart icon --> + <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="goToMiniShoppingCart"/> + + <!-- Click Edit --> + <click selector="{{StorefrontMinicartSection.viewAndEditCart}}" stepKey="editMiniCartItem"/> + + <!-- Fill data from dataset --> + <clearField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" stepKey="deleteFiled"/> + <fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="{{simpleOrderQty2.qty}}" stepKey="changeQty"/> + + <!-- Click Update --> + <click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="updateQty"/> + + <!-- Perform all assertions --> + <actionGroup ref="ShoppingCartCheckSummaryTotalActionGroup" stepKey="checkSummary"> + <argument name="dataQuote" value="simpleOrderQty2"/> + </actionGroup> + </test> +</tests> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.xml index 8b2460718097c..b4c97a11b9145 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateProductFromMiniShoppingCartEntityTest.xml @@ -9,7 +9,7 @@ <testCase name="Magento\Checkout\Test\TestCase\UpdateProductFromMiniShoppingCartEntityTest" summary="Update Product from Mini Shopping Cart" ticketId="MAGETWO-29812"> <variation name="UpdateProductFromMiniShoppingCartEntityTestVariation1" summary="Update Product Qty on Mini Shopping Cart" ticketId=" MAGETWO-35536"> <data name="issue" xsi:type="string">https://github.com/magento-engcom/msi/issues/1624</data> - <data name="tag" xsi:type="string">test_type:extended_acceptance_test, severity:S0</data> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test, severity:S0, mftf_migrated:yes</data> <data name="originalProduct/0" xsi:type="string">catalogProductSimple::default</data> <data name="checkoutData/dataset" xsi:type="string">simple_order_qty_2</data> <data name="use_minicart_to_edit_qty" xsi:type="boolean">true</data> From 196a447eb90bf5f85aafabd3f6d007e74ef71365 Mon Sep 17 00:00:00 2001 From: sathakur <sathakur@adobe.com> Date: Mon, 4 Mar 2019 11:52:02 -0600 Subject: [PATCH 042/162] MC-4874: Convert CreateWebsiteEntityTest to MFTF --- .../AdminCreateWebsiteActionGroup.xml | 27 ++++++++++ .../Mftf/Section/AdminStoresGridSection.xml | 3 +- .../Test/Mftf/Test/AdminCreateWebsiteTest.xml | 49 +++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Store/Test/Mftf/Test/AdminCreateWebsiteTest.xml diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateWebsiteActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateWebsiteActionGroup.xml index ef8d77c8824ff..dd8bd7b6789a2 100644 --- a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateWebsiteActionGroup.xml +++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateWebsiteActionGroup.xml @@ -36,4 +36,31 @@ <click selector="{{AdminStoresGridSection.websiteNameInFirstRow}}" stepKey="clickEditExistingWebsite"/> <grabFromCurrentUrl regex="~(\d+)/~" stepKey="grabFromCurrentUrl"/> </actionGroup> + + <actionGroup name="AssertWebsiteInGrid"> + <arguments> + <argument name="websiteName" type="string"/> + </arguments> + <amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/> + <waitForPageLoad stepKey="waitForAdminSystemStorePageLoad"/> + <click selector="{{AdminStoresGridSection.resetButton}}" stepKey="resetSearchFilter"/> + <fillField userInput="{{websiteName}}" selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="fillWebsiteField"/> + <click selector="{{AdminStoresGridSection.searchButton}}" stepKey="clickSearchButton"/> + <waitForPageLoad stepKey="waitForStoreToLoad"/> + <seeElement selector="{{AdminStoresGridSection.nthRow(websiteName)}}" stepKey="seeAssertWebsiteInGrid"/> + </actionGroup> + + <actionGroup name="AssertWebsiteForm"> + <arguments> + <argument name="websiteName" type="string"/> + <argument name="websiteCode" type="string"/> + <argument name="websiteId"/> + </arguments> + <click selector="{{AdminStoresGridSection.nthRow(websiteName)}}" stepKey="clickWebsiteFirstRowInGrid"/> + <waitForPageLoad stepKey="waitTillWebsiteFormPageIsOpened"/> + <grabFromCurrentUrl regex="~(\d+)/~" stepKey="grabWebsiteIdFromCurrentUrl"/> + <seeInCurrentUrl url="/system_store/editWebsite/website_id/{$grabWebsiteIdFromCurrentUrl}" stepKey="seeWebsiteId"/> + <seeInField selector="{{AdminNewWebsiteSection.name}}" userInput="{{websiteName}}" stepKey="seeAssertWebsiteName"/> + <seeInField selector="{{AdminNewWebsiteSection.code}}" userInput="{{websiteCode}}" stepKey="seeAssertWebsiteCode"/> + </actionGroup> </actionGroups> \ No newline at end of file diff --git a/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml b/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml index b02e9adaed45e..c3b3fc8fa342d 100644 --- a/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml +++ b/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml @@ -21,5 +21,6 @@ <element name="storeGrpNameInFirstRow" type="text" selector=".col-group_title>a"/> <element name="storeNameInFirstRow" type="text" selector=".col-store_title>a"/> <element name="firstRow" type="textarea" selector="(//*[@id='storeGrid_table']/tbody/tr)[1]"/> + <element name="nthRow" type="text" selector="//td[@class='a-left col-website_title ']/a[contains(.,'{{websiteName}}')]" parameterized="true"/> </section> -</sections> +</sections> \ No newline at end of file diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateWebsiteTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateWebsiteTest.xml new file mode 100644 index 0000000000000..44b774eed372f --- /dev/null +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateWebsiteTest.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<!-- Test XML Example --> +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminCreateWebsiteTest"> + <annotations> + <stories value="Create Website"/> + <title value="CreateWebsiteEntityTestVariation1"/> + <description value="Test log in to Stores and Create Website Test"/> + <testCaseId value="MC-14302"/> + <severity value="CRITICAL"/> + <group value="store"/> + <group value="mtf_migrated"/> + </annotations> + + <before> + <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite"> + <argument name="websiteName" value="{{customWebsite.name}}"/> + </actionGroup> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!--Create website and AssertWebsiteSuccessSaveMessage--> + <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createWebsite"> + <argument name="newWebsiteName" value="{{customWebsite.name}}"/> + <argument name="websiteCode" value="{{customWebsite.code}}"/> + </actionGroup> + + <!--Search created website in grid and AssertWebsiteInGrid--> + <actionGroup ref="AssertWebsiteInGrid" stepKey="seeWebsiteInGrid"> + <argument name="websiteName" value="{{customWebsite.name}}"/> + </actionGroup> + + <!--AssertWebsiteForm and AssertWebsiteOnStoreForm--> + <actionGroup ref="AssertWebsiteForm" stepKey="seeWebsiteForm"> + <argument name="websiteName" value="{{customWebsite.name}}"/> + <argument name="websiteCode" value="{{customWebsite.code}}"/> + <argument name="websiteId" value="admin/system_store/editWebsite/website_id/{$grabWebsiteIdFromCurrentUrl}"/> + </actionGroup> + </test> +</tests> \ No newline at end of file From f1f405c82446d39accfcebdd0ec6e523f9d25f4f Mon Sep 17 00:00:00 2001 From: sathakur <sathakur@adobe.com> Date: Mon, 4 Mar 2019 12:03:54 -0600 Subject: [PATCH 043/162] MC-4869: Convert DeleteStoreEntityTest to MFTF Addressing review comments --- .../Test/Mftf/ActionGroup/AdminDeleteStoreViewActionGroup.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminDeleteStoreViewActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminDeleteStoreViewActionGroup.xml index a08648bc8b8c6..cf2cabdcc2399 100644 --- a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminDeleteStoreViewActionGroup.xml +++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminDeleteStoreViewActionGroup.xml @@ -26,7 +26,6 @@ <waitForPageLoad stepKey="waitForSuccessMessage"/> <see userInput="You deleted the store view." stepKey="seeDeleteMessage"/> </actionGroup> - <!--AssertStoreSuccessDeleteAndBackupMessages--> <actionGroup name="DeleteCustomStoreViewBackupEnabledYesActionGroup"> <arguments> <argument name="storeViewName" type="string"/> @@ -46,7 +45,6 @@ <see selector="{{AdminStoresGridSection.successMessage}}" userInput="The database was backed up." stepKey="seeAssertDatabaseBackedUpMessage"/> <see selector="{{AdminStoresGridSection.successMessage}}" userInput="You deleted the store view." stepKey="seeAssertSuccessDeleteStoreViewMessage"/> </actionGroup> - <!--AssertStoreViewNotInGrid--> <actionGroup name="AssertStoreViewNotInGrid"> <arguments> <argument name="storeViewName" type="string"/> From 7394aeb9b7c2679558c8e2bda9badfc825eee11d Mon Sep 17 00:00:00 2001 From: sathakur <sathakur@adobe.com> Date: Mon, 4 Mar 2019 13:50:06 -0600 Subject: [PATCH 044/162] MC-4869: Convert DeleteStoreEntityTest to MFTF Addressing second set of review comments --- ...leteStoreTest.xml => AdminDeleteStoreViewTest.xml} | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) rename app/code/Magento/Store/Test/Mftf/Test/{AdminDeleteStoreTest.xml => AdminDeleteStoreViewTest.xml} (82%) diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml similarity index 82% rename from app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreTest.xml rename to app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml index 37829f4782413..380f6c31f98a7 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml @@ -7,10 +7,10 @@ --> <!-- Test XML Example --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> - <test name="AdminDeleteStoreTest"> + <test name="AdminDeleteStoreViewTest"> <annotations> <stories value="Delete Store View"/> - <title value="DeleteStoreEntityTestVariation1"/> + <title value="Delete Store View and Save Backup"/> <description value="Test log in to Stores and Delete Store View"/> <testCaseId value="MC-14303"/> <severity value="CRITICAL"/> @@ -31,19 +31,20 @@ <actionGroup ref="logout" stepKey="logout"/> </after> - <!--AssertStoreSuccessDeleteAndBackupMessages--> + <!--Delete custom store view and verify AssertStoreSuccessDeleteMessage And BackupMessage--> <actionGroup ref="DeleteCustomStoreViewBackupEnabledYesActionGroup" stepKey="deleteCustomStoreView"> <argument name="storeViewName" value="{{storeViewData.name}}"/> </actionGroup> - <!--AssertStoreNotInGrid--> + <!--Verify deleted store view not present in grid and verify AssertStoreNotInGrid Message--> <actionGroup ref="AssertStoreViewNotInGrid" stepKey="verifyDeletedStoreViewNotInGrid"> <argument name="storeViewName" value="{{storeViewData.name}}"/> </actionGroup> - <!--Go to backup index page, verify AssertBackupInGrid--> + <!--Go to backup index page and verify AssertBackupInGrid--> <amOnPage url="{{BackupIndexPage.url}}" stepKey="goToBackupIndexPage"/> <waitForPageLoad stepKey="waitForBackupIndexPageLoad"/> + <see selector="{{AdminGridTableSection.backupNameColumn}}" userInput="{{WebSetupWizardBackup.name}}" stepKey="seeBackupInGrid"/> <!--Delete database backup--> <actionGroup ref="deleteBackup" stepKey="deleteDatabaseBackup"> <argument name="backup" value="WebSetupWizardBackup"/> From bc3f4526a0a3a305aaa22e99aeede10c75015730 Mon Sep 17 00:00:00 2001 From: Maria Kovdrysh <kovdrysh@adobe.com> Date: Mon, 4 Mar 2019 15:25:40 -0600 Subject: [PATCH 045/162] MC-4426: Convert ExportProductsTest to MFTF --- .../ActionGroup/AdminExportActionGroup.xml | 22 ++++++++++++------- .../Test/AdminExportBundleProductTest.xml | 9 +++++--- ...portGroupedProductWithSpecialPriceTest.xml | 8 +++++-- ...figurableProductsWithCustomOptionsTest.xml | 10 ++++++--- ...igurableProductsWithAssignedImagesTest.xml | 10 ++++++--- ...ableProductAssignedToCustomWebsiteTest.xml | 8 +++++-- ...rtSimpleProductWithCustomAttributeTest.xml | 8 +++++-- .../Section/AdminExportAttributeSection.xml | 8 +++---- 8 files changed, 56 insertions(+), 27 deletions(-) diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml index 21b81648ea479..63248dd53fc1b 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml @@ -10,10 +10,10 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> <!-- Export products using filtering by attribute --> - <actionGroup name="fillFilterExport"> + <actionGroup name="exportProductsFilterByAttribute"> <arguments> - <argument name="attribute"/> - <argument name="attributeData"/> + <argument name="attribute" type="string"/> + <argument name="attributeData" type="string"/> </arguments> <selectOption selector="{{AdminExportMainSection.entityType}}" userInput="Products" stepKey="selectProductsOption"/> <waitForElementVisible selector="{{AdminExportMainSection.entityAttributes}}" stepKey="waitForElementVisible"/> @@ -38,19 +38,25 @@ </actionGroup> <!-- Download first file in the grid --> - <actionGroup name="downloadProduct"> + <actionGroup name="downloadFileByRowIndex"> + <arguments> + <argument name="rowIndex" type="string"/> + </arguments> <reloadPage stepKey="refreshPage"/> <waitForPageLoad stepKey="waitFormReload"/> - <click stepKey="clickSelectBtn" selector="{{AdminExportAttributeSection.selectByIndex('0')}}"/> - <click stepKey="clickOnDownload" selector="{{AdminExportAttributeSection.download('0')}}" after="clickSelectBtn"/> + <click stepKey="clickSelectBtn" selector="{{AdminExportAttributeSection.selectByIndex(rowIndex)}}"/> + <click stepKey="clickOnDownload" selector="{{AdminExportAttributeSection.download(rowIndex)}}" after="clickSelectBtn"/> </actionGroup> <!-- Delete exported file --> <actionGroup name="deleteExportedFile"> + <arguments> + <argument name="rowIndex" type="string"/> + </arguments> <reloadPage stepKey="refreshPage"/> <waitForPageLoad stepKey="waitFormReload"/> - <click stepKey="clickSelectBtn" selector="{{AdminExportAttributeSection.selectByIndex('0')}}"/> - <click stepKey="clickOnDownload" selector="{{AdminExportAttributeSection.delete('0')}}" after="clickSelectBtn"/> + <click stepKey="clickSelectBtn" selector="{{AdminExportAttributeSection.selectByIndex(rowIndex)}}"/> + <click stepKey="clickOnDownload" selector="{{AdminExportAttributeSection.delete(rowIndex)}}" after="clickSelectBtn"/> <waitForElementVisible selector="{{AdminProductGridConfirmActionSection.title}}" stepKey="waitForConfirmModal"/> <click selector="{{AdminProductGridConfirmActionSection.ok}}" stepKey="confirmProductDelete"/> <see selector="{{AdminDataGridTableSection.dataGridEmpty}}" userInput="We couldn't find any records." stepKey="assertDataGridEmptyMessage"/> diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportBundleProductTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportBundleProductTest.xml index 476e3756f55ca..3a4010f417104 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportBundleProductTest.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportBundleProductTest.xml @@ -89,7 +89,9 @@ </before> <after> <!-- Delete exported file --> - <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"/> + <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"> + <argument name="rowIndex" value="0"/> + </actionGroup> <!-- Delete products creations --> <deleteData createDataKey="createDynamicBundleProduct" stepKey="deleteDynamicBundleProduct"/> @@ -109,12 +111,13 @@ <!-- Go to export page --> <amOnPage url="{{AdminExportIndexPage.url}}" stepKey="goToExportIndexPage"/> - <waitForPageLoad stepKey="waitForExportIndexPageLoad" time="10"/> <!-- Export created below products --> <actionGroup ref="exportAllProducts" stepKey="exportCreatedProducts"/> <!-- Download product --> - <actionGroup ref="downloadProduct" stepKey="downloadCreatedProducts"/> + <actionGroup ref="downloadFileByRowIndex" stepKey="downloadCreatedProducts"> + <argument name="rowIndex" value="0"/> + </actionGroup> </test> </tests> diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportGroupedProductWithSpecialPriceTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportGroupedProductWithSpecialPriceTest.xml index adec5daddfeb0..09d9469cb093d 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportGroupedProductWithSpecialPriceTest.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportGroupedProductWithSpecialPriceTest.xml @@ -57,7 +57,9 @@ </before> <after> <!-- Delete exported file --> - <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"/> + <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"> + <argument name="rowIndex" value="0"/> + </actionGroup> <!-- Deleted created products --> <deleteData createDataKey="createFirstSimpleProduct" stepKey="deleteFirstSimpleProduct"/> @@ -79,6 +81,8 @@ <actionGroup ref="exportAllProducts" stepKey="exportCreatedProducts"/> <!-- Download product --> - <actionGroup ref="downloadProduct" stepKey="downloadCreatedProducts"/> + <actionGroup ref="downloadFileByRowIndex" stepKey="downloadCreatedProducts"> + <argument name="rowIndex" value="0"/> + </actionGroup> </test> </tests> diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleAndConfigurableProductsWithCustomOptionsTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleAndConfigurableProductsWithCustomOptionsTest.xml index 883cdab2951fd..aaeb0cd38cd99 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleAndConfigurableProductsWithCustomOptionsTest.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleAndConfigurableProductsWithCustomOptionsTest.xml @@ -82,7 +82,9 @@ </before> <after> <!-- Delete exported file --> - <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"/> + <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"> + <argument name="rowIndex" value="0"/> + </actionGroup> <!-- Delete configurable product creation --> <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> @@ -100,12 +102,14 @@ <waitForPageLoad stepKey="waitForExportIndexPageLoad"/> <!-- Fill entity attributes data --> - <actionGroup ref="fillFilterExport" stepKey="exportProductBySku"> + <actionGroup ref="exportProductsFilterByAttribute" stepKey="exportProductBySku"> <argument name="attribute" value="sku"/> <argument name="attributeData" value="$$createConfigProduct.sku$$"/> </actionGroup> <!-- Download product --> - <actionGroup ref="downloadProduct" stepKey="downloadCreatedProducts"/> + <actionGroup ref="downloadFileByRowIndex" stepKey="downloadCreatedProducts"> + <argument name="rowIndex" value="0"/> + </actionGroup> </test> </tests> \ No newline at end of file diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAndConfigurableProductsWithAssignedImagesTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAndConfigurableProductsWithAssignedImagesTest.xml index 10b81c4b1278a..597ee2336b21f 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAndConfigurableProductsWithAssignedImagesTest.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAndConfigurableProductsWithAssignedImagesTest.xml @@ -98,7 +98,9 @@ </before> <after> <!-- Delete exported file --> - <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"/> + <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"> + <argument name="rowIndex" value="0"/> + </actionGroup> <!-- Delete configurable product creation --> <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> @@ -116,12 +118,14 @@ <waitForPageLoad stepKey="waitForExportIndexPageLoad"/> <!-- Fill entity attributes data --> - <actionGroup ref="fillFilterExport" stepKey="exportProductBySku"> + <actionGroup ref="exportProductsFilterByAttribute" stepKey="exportProductBySku"> <argument name="attribute" value="sku"/> <argument name="attributeData" value="$$createConfigProduct.sku$$"/> </actionGroup> <!-- Download product --> - <actionGroup ref="downloadProduct" stepKey="downloadCreatedProducts"/> + <actionGroup ref="downloadFileByRowIndex" stepKey="downloadCreatedProducts"> + <argument name="rowIndex" value="0"/> + </actionGroup> </test> </tests> \ No newline at end of file diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAssignedToMainWebsiteAndConfigurableProductAssignedToCustomWebsiteTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAssignedToMainWebsiteAndConfigurableProductAssignedToCustomWebsiteTest.xml index 72daebfd93bf7..b1e723e5ee1ff 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAssignedToMainWebsiteAndConfigurableProductAssignedToCustomWebsiteTest.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAssignedToMainWebsiteAndConfigurableProductAssignedToCustomWebsiteTest.xml @@ -80,7 +80,9 @@ </before> <after> <!-- Delete exported file --> - <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"/> + <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"> + <argument name="rowIndex" value="0"/> + </actionGroup> <!-- Delete simple product --> <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> @@ -104,6 +106,8 @@ <actionGroup ref="exportAllProducts" stepKey="exportCreatedProducts"/> <!-- Download product --> - <actionGroup ref="downloadProduct" stepKey="downloadCreatedProducts"/> + <actionGroup ref="downloadFileByRowIndex" stepKey="downloadCreatedProducts"> + <argument name="rowIndex" value="0"/> + </actionGroup> </test> </tests> diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductWithCustomAttributeTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductWithCustomAttributeTest.xml index 6553966b515a4..e3c5cd78397f6 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductWithCustomAttributeTest.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductWithCustomAttributeTest.xml @@ -37,7 +37,9 @@ </before> <after> <!-- Delete exported file --> - <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"/> + <actionGroup ref="deleteExportedFile" stepKey="deleteExportedFile"> + <argument name="rowIndex" value="0"/> + </actionGroup> <!-- Delete product creations --> <deleteData createDataKey="createSimpleProductWithCustomAttributeSet" stepKey="deleteSimpleProductWithCustomAttributeSet"/> @@ -56,6 +58,8 @@ <actionGroup ref="exportAllProducts" stepKey="exportCreatedProducts"/> <!-- Download product --> - <actionGroup ref="downloadProduct" stepKey="downloadCreatedProducts"/> + <actionGroup ref="downloadFileByRowIndex" stepKey="downloadCreatedProducts"> + <argument name="rowIndex" value="0"/> + </actionGroup> </test> </tests> diff --git a/app/code/Magento/ImportExport/Test/Mftf/Section/AdminExportAttributeSection.xml b/app/code/Magento/ImportExport/Test/Mftf/Section/AdminExportAttributeSection.xml index 1a759867d9535..528ad23aaf2bf 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/Section/AdminExportAttributeSection.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/Section/AdminExportAttributeSection.xml @@ -13,9 +13,9 @@ <element name="search" type="button" selector="button[data-action=grid-filter-apply]" timeout="30"/> <element name="chooseAttribute" type="checkbox" selector="//*[@name='export_filter[{{var}}]']/ancestor::tr//input[@type='checkbox']" parameterized="true"/> <element name="fillFilter" type="input" selector="//*[@name='export_filter[{{var}}]']/ancestor::tr//input[@type='text']" parameterized="true"/> - <element name="continueBtn" type="button" selector="//*[@id='export_filter_container']/button"/> - <element name="selectByIndex" type="button" selector="//tr[@data-repeat-index='{{var}}']//button" parameterized="true"/> - <element name="download" type="button" selector="//tr[@data-repeat-index='{{var}}']//a[text()='Download']" parameterized="true" timeout="10"/> - <element name="delete" type="button" selector="//tr[@data-repeat-index='{{var}}']//a[text()='Delete']" parameterized="true" timeout="10"/> + <element name="continueBtn" type="button" selector="//*[@id='export_filter_container']/button" timeout="30"/> + <element name="selectByIndex" type="button" selector="//tr[@data-repeat-index='{{var}}']//button" parameterized="true" timeout="30"/> + <element name="download" type="button" selector="//tr[@data-repeat-index='{{var}}']//a[text()='Download']" parameterized="true" timeout="30"/> + <element name="delete" type="button" selector="//tr[@data-repeat-index='{{var}}']//a[text()='Delete']" parameterized="true" timeout="30"/> </section> </sections> From 318425fafd4d92dbabcf89d332dedf9f27978f63 Mon Sep 17 00:00:00 2001 From: Cristiano Casciotti <teknoman84@gmail.com> Date: Tue, 5 Mar 2019 12:02:18 +0100 Subject: [PATCH 046/162] Fix for issue #21510 --- app/code/Magento/Indexer/Model/Indexer.php | 2 +- .../Magento/Indexer/Test/Unit/Model/IndexerTest.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Indexer/Model/Indexer.php b/app/code/Magento/Indexer/Model/Indexer.php index 87a7cce58e1a5..8f3e6b475b466 100644 --- a/app/code/Magento/Indexer/Model/Indexer.php +++ b/app/code/Magento/Indexer/Model/Indexer.php @@ -361,7 +361,7 @@ public function getLatestUpdated() return $this->getView()->getUpdated(); } } - return $this->getState()->getUpdated(); + return $this->getState()->getUpdated() ?: ''; } /** diff --git a/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php b/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php index 6b7cc12218990..ae0d721a549bd 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php @@ -164,7 +164,12 @@ public function testGetLatestUpdated($getViewIsEnabled, $getViewGetUpdated, $get } } } else { - $this->assertEquals($getStateGetUpdated, $this->model->getLatestUpdated()); + $actualGetLatestUpdated = $this->model->getLatestUpdated(); + $this->assertEquals($getStateGetUpdated, $actualGetLatestUpdated); + + if ($getStateGetUpdated === null) { + $this->assertNotNull($actualGetLatestUpdated); + } } } @@ -182,7 +187,8 @@ public function getLatestUpdatedDataProvider() [true, '', '06-Jan-1944'], [true, '06-Jan-1944', ''], [true, '', ''], - [true, '06-Jan-1944', '05-Jan-1944'] + [true, '06-Jan-1944', '05-Jan-1944'], + [false, null, null], ]; } From 486e21c19a6678d3a1b6b0e259408fb1d205bceb Mon Sep 17 00:00:00 2001 From: Cristiano Casciotti <teknoman84@gmail.com> Date: Tue, 5 Mar 2019 14:27:58 +0100 Subject: [PATCH 047/162] Changed variable name for codacy quality review --- app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php b/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php index ae0d721a549bd..ca2da9585f934 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php @@ -164,11 +164,11 @@ public function testGetLatestUpdated($getViewIsEnabled, $getViewGetUpdated, $get } } } else { - $actualGetLatestUpdated = $this->model->getLatestUpdated(); - $this->assertEquals($getStateGetUpdated, $actualGetLatestUpdated); + $getLatestUpdated = $this->model->getLatestUpdated(); + $this->assertEquals($getStateGetUpdated, $getLatestUpdated); if ($getStateGetUpdated === null) { - $this->assertNotNull($actualGetLatestUpdated); + $this->assertNotNull($getLatestUpdated); } } } From 4de27d15b08789f88aafa0f69dab42a940223386 Mon Sep 17 00:00:00 2001 From: sathakur <sathakur@adobe.com> Date: Tue, 5 Mar 2019 10:12:40 -0600 Subject: [PATCH 048/162] MC-4434: Convert DeleteSearchTermEntityTest to MFTF Addressing review comments --- .../ActionGroup/AdminCatalogSearchTermActionGroup.xml | 11 ++++------- .../StorefrontCatalogSearchTermActionGroup.xml | 2 +- .../Section/AdminCatalogSearchTermIndexSection.xml | 4 ++-- .../Mftf/Section/AdminCatalogSearchTermNewSection.xml | 4 ++-- .../Test/Mftf/Test/AdminDeleteSearchTermTest.xml | 10 +++++----- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/AdminCatalogSearchTermActionGroup.xml b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/AdminCatalogSearchTermActionGroup.xml index a9444a4e5baa6..33ffa4fe1b296 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/AdminCatalogSearchTermActionGroup.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/AdminCatalogSearchTermActionGroup.xml @@ -8,7 +8,6 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <!--Add new search term and AssertSearchTermSaveSuccessMessage--> <actionGroup name="AssertSearchTermSaveSuccessMessage"> <arguments> <argument name="searchQuery" type="string"/> @@ -21,13 +20,12 @@ <click selector="{{AdminCatalogSearchTermIndexSection.addNewSearchTermButton}}" stepKey="clickAddNewSearchTermButton"/> <waitForPageLoad stepKey="waitForAdminCatalogSearchTermNewPageLoad"/> <fillField selector="{{AdminCatalogSearchTermNewSection.searchQuery}}" userInput="{{searchQuery}}" stepKey="fillSearchQueryTextBox"/> - <click selector="{{AdminCatalogSearchTermNewSection.store('storeValue')}}" stepKey="selectMainWebsiteStore"/> + <selectOption selector="{{AdminCatalogSearchTermNewSection.store}}" userInput="{{storeValue}}" stepKey="selectStoreValue"/> <fillField selector="{{AdminCatalogSearchTermNewSection.redirectUrl}}" userInput="{{redirectUrl}}" stepKey="fillRedirectUrl"/> - <click selector="{{AdminCatalogSearchTermNewSection.displayInSuggestedTerm('displayInSuggestedTerm')}}" stepKey="selectDisplayInSuggestedTerm"/> + <selectOption selector="{{AdminCatalogSearchTermNewSection.displayInSuggestedTerm}}" userInput="{{displayInSuggestedTerm}}" stepKey="selectDisplayInSuggestedTerm"/> <click selector="{{AdminCatalogSearchTermNewSection.saveSearchButton}}" stepKey="clickSaveSearchButton"/> <see selector="{{AdminCatalogSearchTermMessagesSection.successMessage}}" userInput="You saved the search term." stepKey="seeSaveSuccessMessage"/> </actionGroup> - <!--Search and delete search term and AssertSearchTermSuccessDeleteMessage--> <actionGroup name="AssertSearchTermSuccessDeleteMessage"> <arguments> <argument name="searchQuery" type="string"/> @@ -39,13 +37,12 @@ <fillField selector="{{AdminCatalogSearchTermIndexSection.searchQuery}}" userInput="{{searchQuery}}" stepKey="fillSearchQuery"/> <click selector="{{AdminCatalogSearchTermIndexSection.searchButton}}" stepKey="clickSearchButton"/> <waitForPageLoad stepKey="waitForSearchResultLoad"/> - <checkOption selector="{{AdminCatalogSearchTermIndexSection.checkBox}}" stepKey="checkCheckBox"/> - <selectOption selector="{{AdminCatalogSearchTermIndexSection.delete}}" userInput="delete" stepKey="selectDeleteOption"/> + <click selector="{{AdminCatalogSearchTermIndexSection.nthRow('1')}}" stepKey="checkFirstRow"/> + <selectOption selector="{{AdminCatalogSearchTermIndexSection.massActions}}" userInput="delete" stepKey="selectDeleteOption"/> <click selector="{{AdminCatalogSearchTermIndexSection.submit}}" stepKey="clickSubmitButton"/> <click selector="{{AdminCatalogSearchTermIndexSection.okButton}}" stepKey="clickOkButton"/> <see selector="{{AdminCatalogSearchTermMessagesSection.successMessage}}" userInput="Total of 1 record(s) were deleted." stepKey="seeSuccessMessage"/> </actionGroup> - <!--Verify deleted search term in grid and AssertSearchTermNotInGridMessage--> <actionGroup name="AssertSearchTermNotInGrid"> <arguments> <argument name="searchQuery" type="string"/> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchTermActionGroup.xml b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchTermActionGroup.xml index 5714cb4eb9f9c..a825e06f490a5 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchTermActionGroup.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchTermActionGroup.xml @@ -16,7 +16,7 @@ </arguments> <amOnPage url="{{StorefrontProductPage.url('url_key')}}" stepKey="goToMagentoStorefrontPage"/> <waitForPageLoad stepKey="waitForStoreFrontProductPageLoad"/> - <fillField selector="{{StorefrontQuickSearchResultsSection.searchTextBox}}" userInput="{{SimpleTerm.search_query}}" stepKey="fillSearchQuery"/> + <fillField selector="{{StorefrontQuickSearchResultsSection.searchTextBox}}" userInput="{{searchQuery}}" stepKey="fillSearchQuery"/> <waitForPageLoad stepKey="waitForSearchTextBox"/> <click selector="{{StorefrontQuickSearchResultsSection.searchTextBoxButton}}" stepKey="clickSearchTextBoxButton"/> <waitForPageLoad stepKey="waitForSearch"/> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermIndexSection.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermIndexSection.xml index 812c302f9c00a..5491c27228387 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermIndexSection.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermIndexSection.xml @@ -12,10 +12,10 @@ <element name="addNewSearchTermButton" type="button" selector="//div[@class='page-actions-buttons']/button[@id='add']" timeout="30"/> <element name="resetFilterButton" type="button" selector="//button[@class='action-default scalable action-reset action-tertiary']" timeout="30"/> <element name="searchButton" type="button" selector="//button[@class='action-default scalable action-secondary']" timeout="30"/> - <element name="delete" type="text" selector="//div[@class='admin__grid-massaction-form']//select[@id='search_term_grid_massaction-select']"/> + <element name="massActions" type="text" selector="//div[@class='admin__grid-massaction-form']//select[@id='search_term_grid_massaction-select']"/> <element name="submit" type="button" selector="//button[@class='action-default scalable']/span" timeout="30"/> <element name="searchQuery" type="text" selector="//tr[@class='data-grid-filters']//td/input[@name='search_query']"/> - <element name="checkBox" type="checkbox" selector="//label[@class='data-grid-checkbox-cell-inner']/input[@name='search']"/> + <element name="nthRow" type="checkbox" selector="//tbody/tr['{{rowNum}}']//input[@name='search']" parameterized="true"/> <element name="okButton" type="button" selector="//button[@class='action-primary action-accept']/span" timeout="30"/> <element name="emptyRecords" type="text" selector="//tr[@class='data-grid-tr-no-data even']/td[@class='empty-text']"/> </section> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermNewSection.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermNewSection.xml index 7922e994c4965..a7d577a7508c0 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermNewSection.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermNewSection.xml @@ -10,9 +10,9 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminCatalogSearchTermNewSection"> <element name="searchQuery" type="text" selector="//div[@class='admin__field-control control']/input[@id='query_text']"/> - <element name="store" type="text" selector="//select[@id='store_id']//optgroup/option[contains(.,'{{store}}')]" parameterized="true"/> + <element name="store" type="text" selector="//select[@id='store_id']"/> <element name="redirectUrl" type="text" selector="//div[@class='admin__field-control control']/input[@id='redirect']"/> - <element name="displayInSuggestedTerm" type="select" selector="//select[@name='display_in_terms']/option[contains(.,'{{text}}')]" parameterized="true"/> + <element name="displayInSuggestedTerm" type="select" selector="//select[@name='display_in_terms']"/> <element name="saveSearchButton" type="button" selector="//button[@id='save']/span[@class='ui-button-text']" timeout="30"/> </section> </sections> \ No newline at end of file diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminDeleteSearchTermTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminDeleteSearchTermTest.xml index dc9d99fabefc6..c72ed424ef307 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminDeleteSearchTermTest.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminDeleteSearchTermTest.xml @@ -10,8 +10,8 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminDeleteSearchTermTest"> <annotations> - <stories value="DeleteSearchTerm"/> - <title value="DeleteSearchTermEntityTestVariation1"/> + <stories value="Search terms"/> + <title value="Delete Search Term and Verify Storefront"/> <description value="Test log in to SearchTerm and DeleteSearchTerm"/> <testCaseId value="MC-13988"/> <severity value="CRITICAL"/> @@ -35,9 +35,9 @@ <!--Add new search term--> <actionGroup ref="AssertSearchTermSaveSuccessMessage" stepKey="addNewSearchTerm"> <argument name="searchQuery" value="{{SimpleTerm.search_query}}"/> - <argument name="storeValue" value="Default Store View"/> + <argument name="storeValue" value="{{SimpleTerm.store_id}}"/> <argument name="redirectUrl" value="{{SimpleTerm.redirect}}"/> - <argument name="displayInSuggestedTerm" value="No"/> + <argument name="displayInSuggestedTerm" value="{{SimpleTerm.display_in_terms}}"/> </actionGroup> <!--Search and delete search term and AssertSearchTermSuccessDeleteMessage--> @@ -50,7 +50,7 @@ <argument name="searchQuery" value="{{SimpleTerm.search_query}}"/> </actionGroup> - <!--Verify AssertSearchTermNotOnFrontend--> + <!--Go to storefront and Verify AssertSearchTermNotOnFrontend--> <actionGroup ref="AssertSearchTermNotOnFrontend" stepKey="verifySearchTermNotOnFrontend"> <argument name="searchQuery" value="{{SimpleTerm.search_query}}"/> <argument name="url_key" value="$$simpleProduct.custom_attributes[url_key]$$"/> From a8a8e22c67a28900d826088ee500f4e1d965f0e7 Mon Sep 17 00:00:00 2001 From: Kavitha <kanair@adobe.com> Date: Tue, 5 Mar 2019 10:50:09 -0600 Subject: [PATCH 049/162] MC-4454: Convert CreateDuplicateUrlCategoryEntityTest to MFTF --- .../Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml | 7 ++++--- .../Test/Mftf/Test/AdminCreateDuplicateCategoryTest.xml | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml index c658e8b359f81..e31f7193739cb 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCategoryActionGroup.xml @@ -277,13 +277,14 @@ </actionGroup> <actionGroup name="adminFillAndSaveCategoryForm"> <arguments> - <argument name="category" type="string"/> + <argument name="categoryName" type="string"/> + <argument name="categoryUrlKey" type="string"/> </arguments> - <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="$$category.name$$" stepKey="enterCategoryName"/> + <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{categoryName}}" stepKey="enterCategoryName"/> <scrollTo selector="{{AdminCategorySEOSection.SectionHeader}}" stepKey="scrollToSearchEngineOptimization"/> <click selector="{{AdminCategorySEOSection.SectionHeader}}" stepKey="openSEO"/> <waitForPageLoad stepKey="waitForPageToLoad"/> - <fillField selector="{{AdminCategorySEOSection.UrlKeyInput}}" userInput="$$category.custom_attributes[url_key]$$" stepKey="enterURLKey"/> + <fillField selector="{{AdminCategorySEOSection.UrlKeyInput}}" userInput="{{categoryUrlKey}}" stepKey="enterURLKey"/> <scrollToTopOfPage stepKey="scrollToTheTopOfPage"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategory"/> <waitForPageLoad stepKey="waitForPageToLoad1"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateCategoryTest.xml index 4865e3a89b67a..79f901952dd75 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateCategoryTest.xml @@ -10,7 +10,7 @@ <test name="AdminCreateDuplicateCategoryTest"> <annotations> <stories value="Create category"/> - <title value="CreateDuplicateUrlCategoryEntityTestVariation1_Subcategory_RequiredFields"/> + <title value="Create Duplicate Category With Already Existed UrlKey"/> <description value="Login as admin and create duplicate category"/> <testCaseId value="MC-14702"/> <severity value="CRITICAL"/> @@ -31,7 +31,8 @@ <!-- Fill the Category form with same name and urlKey as initially created category(SimpleSubCategory) --> <actionGroup ref="adminFillAndSaveCategoryForm" stepKey="fillCategoryForm"> - <argument name="category" value="category"/> + <argument name="categoryName" value="$$category.name$$"/> + <argument name="categoryUrlKey" value="$$category.custom_attributes[url_key]$$"/> </actionGroup> <!-- Assert error message --> From eaab9229eea7cd11215261c03b24e39f3a5bffe0 Mon Sep 17 00:00:00 2001 From: sathakur <sathakur@adobe.com> Date: Tue, 5 Mar 2019 11:01:44 -0600 Subject: [PATCH 050/162] MC-4874: Convert CreateWebsiteEntityTest to MFTF Addressing review comments --- .../Mftf/ActionGroup/AdminCreateWebsiteActionGroup.xml | 5 ++--- .../Store/Test/Mftf/Section/AdminStoresGridSection.xml | 2 +- .../Store/Test/Mftf/Test/AdminCreateWebsiteTest.xml | 7 +++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateWebsiteActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateWebsiteActionGroup.xml index dd8bd7b6789a2..ca614ec24138c 100644 --- a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateWebsiteActionGroup.xml +++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateWebsiteActionGroup.xml @@ -47,16 +47,15 @@ <fillField userInput="{{websiteName}}" selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="fillWebsiteField"/> <click selector="{{AdminStoresGridSection.searchButton}}" stepKey="clickSearchButton"/> <waitForPageLoad stepKey="waitForStoreToLoad"/> - <seeElement selector="{{AdminStoresGridSection.nthRow(websiteName)}}" stepKey="seeAssertWebsiteInGrid"/> + <seeElement selector="{{AdminStoresGridSection.websiteName(websiteName)}}" stepKey="seeAssertWebsiteInGrid"/> </actionGroup> <actionGroup name="AssertWebsiteForm"> <arguments> <argument name="websiteName" type="string"/> <argument name="websiteCode" type="string"/> - <argument name="websiteId"/> </arguments> - <click selector="{{AdminStoresGridSection.nthRow(websiteName)}}" stepKey="clickWebsiteFirstRowInGrid"/> + <click selector="{{AdminStoresGridSection.websiteName(websiteName)}}" stepKey="clickWebsiteFirstRowInGrid"/> <waitForPageLoad stepKey="waitTillWebsiteFormPageIsOpened"/> <grabFromCurrentUrl regex="~(\d+)/~" stepKey="grabWebsiteIdFromCurrentUrl"/> <seeInCurrentUrl url="/system_store/editWebsite/website_id/{$grabWebsiteIdFromCurrentUrl}" stepKey="seeWebsiteId"/> diff --git a/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml b/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml index c3b3fc8fa342d..b07587b70302e 100644 --- a/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml +++ b/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml @@ -21,6 +21,6 @@ <element name="storeGrpNameInFirstRow" type="text" selector=".col-group_title>a"/> <element name="storeNameInFirstRow" type="text" selector=".col-store_title>a"/> <element name="firstRow" type="textarea" selector="(//*[@id='storeGrid_table']/tbody/tr)[1]"/> - <element name="nthRow" type="text" selector="//td[@class='a-left col-website_title ']/a[contains(.,'{{websiteName}}')]" parameterized="true"/> + <element name="websiteName" type="text" selector="//td[@class='a-left col-website_title ']/a[contains(.,'{{websiteName}}')]" parameterized="true"/> </section> </sections> \ No newline at end of file diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateWebsiteTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateWebsiteTest.xml index 44b774eed372f..9d845cb237852 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateWebsiteTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateWebsiteTest.xml @@ -10,7 +10,7 @@ <test name="AdminCreateWebsiteTest"> <annotations> <stories value="Create Website"/> - <title value="CreateWebsiteEntityTestVariation1"/> + <title value="Create Website and Verify Store Form"/> <description value="Test log in to Stores and Create Website Test"/> <testCaseId value="MC-14302"/> <severity value="CRITICAL"/> @@ -34,16 +34,15 @@ <argument name="websiteCode" value="{{customWebsite.code}}"/> </actionGroup> - <!--Search created website in grid and AssertWebsiteInGrid--> + <!--Search created website in grid and verify AssertWebsiteInGrid--> <actionGroup ref="AssertWebsiteInGrid" stepKey="seeWebsiteInGrid"> <argument name="websiteName" value="{{customWebsite.name}}"/> </actionGroup> - <!--AssertWebsiteForm and AssertWebsiteOnStoreForm--> + <!--Verify website name and websitecode on website form (AssertWebsiteForm and AssertWebsiteOnStoreForm)--> <actionGroup ref="AssertWebsiteForm" stepKey="seeWebsiteForm"> <argument name="websiteName" value="{{customWebsite.name}}"/> <argument name="websiteCode" value="{{customWebsite.code}}"/> - <argument name="websiteId" value="admin/system_store/editWebsite/website_id/{$grabWebsiteIdFromCurrentUrl}"/> </actionGroup> </test> </tests> \ No newline at end of file From 59fa0e9ae1b32b00441ec585b9b0b5d98324c586 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Tue, 5 Mar 2019 11:26:10 -0600 Subject: [PATCH 051/162] MC-4425: Convert ImportProductsTest to MFTF --- ...AssertProductInfoOnEditPageActionGroup.xml | 22 ++++ .../AssertProductOnAdminGridActionGroup.xml | 17 +++ .../Catalog/Test/Mftf/Data/ProductData.xml | 42 ++++++ ...oductsWithAddUpdateBehaviorActionGroup.xml | 29 +++++ ...ProductsWithReplaceBehaviorActionGroup.xml | 29 +++++ ...mportProductsWithAddUpdateBehaviorTest.xml | 122 ++++++++++++++++++ ...nImportProductsWithReplaceBehaviorTest.xml | 43 ++++++ .../AdminDeleteWebsiteActionGroup.xml | 1 + ...StoreFrontProductValidationActionGroup.xml | 21 +++ .../tests/_data/catalog_import_products.csv | 4 + 10 files changed, 330 insertions(+) create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductInfoOnEditPageActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductOnAdminGridActionGroup.xml create mode 100644 app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithAddUpdateBehaviorActionGroup.xml create mode 100644 app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithReplaceBehaviorActionGroup.xml create mode 100644 app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml create mode 100644 app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml create mode 100644 app/code/Magento/Store/Test/Mftf/ActionGroup/StoreFrontProductValidationActionGroup.xml create mode 100644 dev/tests/acceptance/tests/_data/catalog_import_products.csv diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductInfoOnEditPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductInfoOnEditPageActionGroup.xml new file mode 100644 index 0000000000000..7917fe68aaebc --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductInfoOnEditPageActionGroup.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="AssertProductInfoOnEditPageActionGroup" extends="OpenEditProductOnBackendActionGroup"> + <arguments> + <argument name="product" type="entity"/> + </arguments> + <waitForPageLoad stepKey="waitForProductToLoad"/> + <seeInField selector="{{AdminProductFormSection.productName}}" userInput="{{product.name}}" stepKey="seeProductName"/> + <seeInField selector="{{AdminProductFormSection.productSku}}" userInput="{{product.sku}}" stepKey="seeProductSku"/> + <seeInField selector="{{AdminProductFormSection.productPrice}}" userInput="{{product.price}}" stepKey="seeProductPrice"/> + <seeInField selector="{{AdminProductFormSection.productQuantity}}" userInput="{{product.quantity}}" stepKey="seeProductQuantity"/> + <seeInField selector="{{AdminProductFormSection.productStockStatus}}" userInput="{{product.status}}" stepKey="seeProductStockStatus"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductOnAdminGridActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductOnAdminGridActionGroup.xml new file mode 100644 index 0000000000000..963c9d9f1c911 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductOnAdminGridActionGroup.xml @@ -0,0 +1,17 @@ +<?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="AssertProductOnAdminGridActionGroup" extends="viewProductInAdminGrid"> + <arguments> + <argument name="product" defaultValue="_defaultProduct"/> + </arguments> + <remove keyForRemoval="clickClearFiltersAfter"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml index 0b3a31194ea36..1c107d315a2b9 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml @@ -60,6 +60,48 @@ <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> <requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity> </entity> + <entity name="SimpleProductAfterImport1" type="product"> + <data key="sku">SimpleProductForTest1</data> + <data key="type_id">simple</data> + <data key="attribute_set_id">4</data> + <data key="name">SimpleProductAfterImport1</data> + <data key="price">250.00</data> + <data key="visibility">4</data> + <data key="status">1</data> + <data key="quantity">100</data> + <data key="urlKey">simple-product-for-test-1</data> + <data key="weight">1</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + <requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity> + </entity> + <entity name="SimpleProductAfterImport2" type="product"> + <data key="sku">SimpleProductForTest2</data> + <data key="type_id">simple</data> + <data key="attribute_set_id">4</data> + <data key="name">SimpleProductAfterImport2</data> + <data key="price">300.00</data> + <data key="visibility">4</data> + <data key="status">1</data> + <data key="quantity">100</data> + <data key="urlKey">simple-product-for-test-2</data> + <data key="weight">1</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + <requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity> + </entity> + <entity name="SimpleProductAfterImport3" type="product"> + <data key="sku">SimpleProductForTest3</data> + <data key="type_id">simple</data> + <data key="attribute_set_id">4</data> + <data key="name">SimpleProductAfterImport3</data> + <data key="price">350.00</data> + <data key="visibility">4</data> + <data key="status">1</data> + <data key="quantity">100</data> + <data key="urlKey">simple-product-for-test-3</data> + <data key="weight">1</data> + <requiredEntity type="product_extension_attribute">EavStockItem</requiredEntity> + <requiredEntity type="custom_attribute_array">CustomAttributeCategoryIds</requiredEntity> + </entity> <entity name="SimpleProduct2" type="product"> <data key="sku" unique="suffix">SimpleProduct</data> <data key="type_id">simple</data> diff --git a/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithAddUpdateBehaviorActionGroup.xml b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithAddUpdateBehaviorActionGroup.xml new file mode 100644 index 0000000000000..53406ed25e3c0 --- /dev/null +++ b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithAddUpdateBehaviorActionGroup.xml @@ -0,0 +1,29 @@ +<?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="AdminImportProductsWithAddUpdateBehaviorActionGroup"> + <arguments> + <argument name="importFile" type="string"/> + <argument name="importMessage" type="string"/> + </arguments> + <amOnPage url="{{AdminImportIndexPage.url}}" stepKey="goToImportIndexPage"/> + <waitForPageLoad stepKey="AdminImportMainSectionLoad"/> + <selectOption selector="{{AdminImportMainSection.entityType}}" userInput="Products" stepKey="selectProductsOption"/> + <waitForElementVisible selector="{{AdminImportMainSection.importBehavior}}" stepKey="waitForImportBehaviorElementVisible"/> + <selectOption selector="{{AdminImportMainSection.importBehavior}}" userInput="Add/Update" stepKey="selectReplaceOption"/> + <attachFile selector="{{AdminImportMainSection.selectFileToImport}}" userInput="{{importFile}}" stepKey="attachFileForImport"/> + <click selector="{{AdminImportHeaderSection.checkDataButton}}" stepKey="clickCheckDataButton"/> + <click selector="{{AdminImportMainSection.importButton}}" stepKey="clickImportButton"/> + <waitForPageLoad stepKey="AdminImportMainSectionLoad2"/> + <see selector="{{AdminMessagesSection.successMessage}}" userInput="Import successfully done" stepKey="assertSuccessMessage"/> + <waitForPageLoad stepKey="AdminMessagesSection"/> + <see selector="{{AdminMessagesSection.notice}}" userInput="{{importMessage}}" stepKey="seeImportMessage"/> + </actionGroup> + </actionGroups> diff --git a/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithReplaceBehaviorActionGroup.xml b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithReplaceBehaviorActionGroup.xml new file mode 100644 index 0000000000000..5e7c3d164e067 --- /dev/null +++ b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithReplaceBehaviorActionGroup.xml @@ -0,0 +1,29 @@ +<?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="AdminImportProductsWithReplaceBehaviorActionGroup"> + <arguments> + <argument name="importFile" type="string"/> + <argument name="importMessage" type="string"/> + </arguments> + <amOnPage url="{{AdminImportIndexPage.url}}" stepKey="goToImportIndexPage"/> + <waitForPageLoad stepKey="AdminImportMainSectionLoad"/> + <selectOption selector="{{AdminImportMainSection.entityType}}" userInput="Products" stepKey="selectProductsOption"/> + <waitForElementVisible selector="{{AdminImportMainSection.importBehavior}}" stepKey="waitForImportBehaviorElementVisible"/> + <selectOption selector="{{AdminImportMainSection.importBehavior}}" userInput="Replace" stepKey="selectReplaceOption"/> + <attachFile selector="{{AdminImportMainSection.selectFileToImport}}" userInput="{{importFile}}" stepKey="attachFileForImport"/> + <click selector="{{AdminImportHeaderSection.checkDataButton}}" stepKey="clickCheckDataButton"/> + <click selector="{{AdminImportMainSection.importButton}}" stepKey="clickImportButton"/> + <waitForPageLoad stepKey="AdminImportMainSectionLoad2"/> + <see selector="{{AdminMessagesSection.successMessage}}" userInput="Import successfully done" stepKey="assertSuccessMessage"/> + <waitForPageLoad stepKey="AdminMessagesSection"/> + <see selector="{{AdminMessagesSection.notice}}" userInput="{{importMessage}}" stepKey="assertNotice"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml new file mode 100644 index 0000000000000..72156ce57294f --- /dev/null +++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml @@ -0,0 +1,122 @@ +<?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="AdminImportProductsWithAddUpdateBehaviorTest"> + <annotations> + <description value="Verify Magento native import products with add/update behavior."/> + <stories value="Verify Magento native import products with add/update behavior."/> + <features value="Import/Export"/> + <title value="Verify Magento native import products with add/update behavior."/> + <severity value="CRITICAL"/> + <testCaseId value="MAGETWO-47724"/> + <group value="importExport"/> + </annotations> + <before> + <!--Create Simple Product1--> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="SimpleProduct" stepKey="createSimpleProduct1"> + <field key="name">SimpleProductForTest1</field> + <field key="sku">SimpleProductForTest1</field> + <requiredEntity createDataKey="createCategory"/> + </createData> + + <!-- Login as Admin --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + + <!-- Create Website --> + <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="AdminCreateWebsite"> + <argument name="newWebsiteName" value="secondWebsite"/> + <argument name="websiteCode" value="second_website"/> + </actionGroup> + + <!-- Create store group --> + <actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="AdminCreateStore"> + <argument name="website" value="secondWebsite"/> + <argument name="storeGroupName" value="{{customStoreGroup.name}}"/> + <argument name="storeGroupCode" value="{{customStoreGroup.code}}"/> + </actionGroup> + + <!-- Create store view --> + <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="AdminCreateStoreView"> + <argument name="StoreGroup" value="customStoreGroup"/> + <argument name="customStore" value="customStore"/> + </actionGroup> + </before> + <after> + <!-- Delete all products that replaced products in the before block post import --> + <deleteData stepKey="deleteSimpleProduct1" url="/V1/products/SimpleProductForTest1"/> + <deleteData stepKey="deleteSimpleProduct2" url="/V1/products/SimpleProductForTest2"/> + <deleteData stepKey="deleteSimpleProduct3" url="/V1/products/SimpleProductForTest3"/> + + <!-- Delete category created in the before block --> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + + <!--Delete website created in the before block --> + <actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="DeleteWebsite" before="logoutFromAdmin"> + <argument name="websiteName" value="secondWebsite"/> + </actionGroup> + + <!--Logout--> + <actionGroup ref="logout" stepKey="logoutFromAdmin"/> + + </after> + + <!-- Import products with add/update behavior --> + <actionGroup ref="AdminImportProductsWithAddUpdateBehaviorActionGroup" stepKey="adminImportProducts"> + <argument name="importFile" value="catalog_import_products.csv"/> + <argument name="importMessage" value="Created: 2, Updated: 1, Deleted: 0"/> + </actionGroup> + + <!-- Assert Simple Product1 on grid--> + <actionGroup ref="AssertProductOnAdminGridActionGroup" stepKey="assertSimpleProduct1OnAdminGrid"> + <argument name="product" value="SimpleProductAfterImport1"/> + </actionGroup> + + <!-- Assert Simple Product1 on edit page--> + <actionGroup ref="AssertProductInfoOnEditPageActionGroup" stepKey="assertSimpleProduct1OnEditPage"> + <argument name="product" value="SimpleProductAfterImport1"/> + </actionGroup> + + <!-- Assert Simple Product2 on grid--> + <actionGroup ref="AssertProductOnAdminGridActionGroup" stepKey="assertSimpleProduct2OnAdminGrid"> + <argument name="product" value="SimpleProductAfterImport2"/> + </actionGroup> + + <!-- Assert Simple Product2 on edit page--> + <actionGroup ref="AssertProductInfoOnEditPageActionGroup" stepKey="assertSimpleProduct2OnEditPage"> + <argument name="product" value="SimpleProductAfterImport2"/> + </actionGroup> + + <!-- Assert Simple Product3 on grid--> + <actionGroup ref="AssertProductOnAdminGridActionGroup" stepKey="assertSimpleProduct3OnAdminGrid"> + <argument name="product" value="SimpleProductAfterImport3"/> + </actionGroup> + + <!-- Assert Simple Product3 on edit page--> + <actionGroup ref="AssertProductInfoOnEditPageActionGroup" stepKey="assertSimpleProduct3OnEditPage"> + <argument name="product" value="SimpleProductAfterImport3"/> + </actionGroup> + + <!-- Assert SimpleProduct1 on store front--> + <actionGroup ref="StoreFrontProductValidationActionGroup" stepKey="storeFrontSimpleProduct1Validation"> + <argument name="product" value="SimpleProductAfterImport1"/> + </actionGroup> + + <!-- Assert SimpleProduct2 on store front--> + <actionGroup ref="StoreFrontProductValidationActionGroup" stepKey="storeFrontSimpleProduct2Validation"> + <argument name="product" value="SimpleProductAfterImport2"/> + </actionGroup> + + <!-- Assert SimpleProduct3 on store front--> + <actionGroup ref="StoreFrontProductValidationActionGroup" stepKey="storeFrontSimpleProduct3Validation"> + <argument name="product" value="SimpleProductAfterImport3"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml new file mode 100644 index 0000000000000..6a006814d4471 --- /dev/null +++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml @@ -0,0 +1,43 @@ +<?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="AdminImportProductsWithReplaceBehaviorTest" extends="AdminImportProductsWithAddUpdateBehaviorTest"> + <annotations> + <description value="Verify Magento native import products with replace behavior."/> + <stories value="Verify Magento native import products with replace behavior."/> + <features value="Import/Export"/> + <title value="Verify Magento native import products with replace behavior."/> + <severity value="CRITICAL"/> + <testCaseId value="MAGETWO-47719"/> + <group value="importExport"/> + </annotations> + <before> + <!--Create Simple Product2--> + <createData entity="SimpleProduct" stepKey="createSimpleProduct2"> + <field key="name">SimpleProductForTest2</field> + <field key="sku">SimpleProductForTest2</field> + <requiredEntity createDataKey="createCategory"/> + </createData> + + <!--Create Simple Product3--> + <createData entity="SimpleProduct" stepKey="createSimpleProduct3"> + <field key="name">SimpleProductForTest3</field> + <field key="sku">SimpleProductForTest3</field> + <requiredEntity createDataKey="createCategory"/> + </createData> + </before> + + <!-- Import products with replace behavior --> + <actionGroup ref="AdminImportProductsWithReplaceBehaviorActionGroup" stepKey="adminImportProducts"> + <argument name="importFile" value="catalog_import_products.csv"/> + <argument name="importMessage" value="Created: 3, Updated: 0, Deleted: 3"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminDeleteWebsiteActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminDeleteWebsiteActionGroup.xml index 58fd0a3f0bc2b..1721e3185402e 100644 --- a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminDeleteWebsiteActionGroup.xml +++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminDeleteWebsiteActionGroup.xml @@ -19,6 +19,7 @@ <click selector="{{AdminStoresGridSection.websiteNameInFirstRow}}" stepKey="clickEditExistingStoreRow"/> <waitForPageLoad stepKey="waitForStoreToLoad"/> <click selector="{{AdminStoresMainActionsSection.deleteButton}}" stepKey="clickDeleteWebsiteButtonOnEditWebsitePage"/> + <waitForPageLoad stepKey="waitForDeleteStoreGroupSectionLoad" time="30"/> <selectOption userInput="No" selector="{{AdminStoresDeleteStoreGroupSection.createDbBackup}}" stepKey="setCreateDbBackupToNo"/> <click selector="{{AdminStoresDeleteStoreGroupSection.deleteStoreGroupButton}}" stepKey="clickDeleteWebsiteButton"/> <waitForElementVisible selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="waitForStoreGridToReload"/> diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/StoreFrontProductValidationActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/StoreFrontProductValidationActionGroup.xml new file mode 100644 index 0000000000000..f11394c643ad7 --- /dev/null +++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/StoreFrontProductValidationActionGroup.xml @@ -0,0 +1,21 @@ +<?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="StoreFrontProductValidationActionGroup"> + <arguments> + <argument name="product" type="entity"/> + </arguments> + <amOnPage url="{{StorefrontProductPage.url(product.urlKey)}}" stepKey="seeProductPage"/> + <waitForPageLoad stepKey="waitForStoreFrontProductPageToLoad"/> + <see selector="{{StorefrontProductInfoMainSection.productName}}" userInput="{{product.name}}" stepKey="seeProductInStoreFrontPage"/> + <see selector="{{StorefrontProductInfoMainSection.productSku}}" userInput="{{product.sku}}" stepKey="seeCorrectSku"/> + <see selector="{{StorefrontProductInfoMainSection.productPrice}}" userInput="{{product.price}}" stepKey="seeCorrectPrice"/> + </actionGroup> +</actionGroups> diff --git a/dev/tests/acceptance/tests/_data/catalog_import_products.csv b/dev/tests/acceptance/tests/_data/catalog_import_products.csv new file mode 100644 index 0000000000000..7732f15d4ce3a --- /dev/null +++ b/dev/tests/acceptance/tests/_data/catalog_import_products.csv @@ -0,0 +1,4 @@ +sku,store_view_code,attribute_set_code,product_type,categories,product_websites,name,description,short_description,weight,product_online,tax_class_name,visibility,price,special_price,special_price_from_date,special_price_to_date,url_key,meta_title,meta_keywords,meta_description,base_image,base_image_label,small_image,small_image_label,thumbnail_image,thumbnail_image_label,swatch_image,swatch_image_label,created_at,updated_at,new_from_date,new_to_date,display_product_options_in,map_price,msrp_price,map_enabled,gift_message_available,custom_design,custom_design_from,custom_design_to,custom_layout_update,page_layout,product_options_container,msrp_display_actual_price_type,country_of_manufacture,additional_attributes,qty,out_of_stock_qty,use_config_min_qty,is_qty_decimal,allow_backorders,use_config_backorders,min_cart_qty,use_config_min_sale_qty,max_cart_qty,use_config_max_sale_qty,is_in_stock,notify_on_stock_below,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,website_id,related_skus,related_position,crosssell_skus,crosssell_position,upsell_skus,upsell_position,additional_images,additional_image_labels,hide_from_product_page,custom_options,bundle_price_type,bundle_sku_type,bundle_price_view,bundle_weight_type,bundle_values,bundle_shipment_type,configurable_variations,configurable_variation_labels,associated_skus +SimpleProductForTest1,,Default,simple,"Default","base,second_website",SimpleProductAfterImport1,,,1.0000,1,"Taxable Goods","Catalog, Search",250.0000,,,,simple-product-for-test-1,,,,,,,,,,,,"3/4/19, 5:53 AM","3/4/19, 4:47 PM",,,"Block after Info Column",,,,,,,,,,,"Use config",,,100.0000,0.0000,1,0,0,1,1.0000,1,0.0000,1,1,,1,0,1,1,0.0000,1,0,0,0,,,,,,,,,,,,,,,,,,, +SimpleProductForTest2,,Default,simple,"Default",base,SimpleProductAfterImport2,,,1.0000,1,"Taxable Goods","Catalog, Search",300.0000,,,,simple-product-for-test-2,,,,,,,,,,,,"3/4/19, 5:53 AM","3/4/19, 4:47 PM",,,"Block after Info Column",,,,,,,,,,,"Use config",,,100.0000,0.0000,1,0,0,1,1.0000,1,0.0000,1,1,,1,0,1,1,0.0000,1,0,0,0,,,,,,,,,,,,,,,,,,, +SimpleProductForTest3,,Default,simple,"Default","base,second_website",SimpleProductAfterImport3,,,1.0000,1,"Taxable Goods","Catalog, Search",350.0000,,,,simple-product-for-test-3,,,,,,,,,,,,"3/4/19, 5:53 AM","3/4/19, 4:47 PM",,,"Block after Info Column",,,,,,,,,,,"Use config",,,100.0000,0.0000,1,0,0,1,1.0000,1,0.0000,1,1,,1,0,1,1,0.0000,1,0,0,0,,,,,,,,,,,,,,,,,,, \ No newline at end of file From 33b888e0bb853f1a9d4a6e6e85a528792102a47a Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Tue, 5 Mar 2019 11:31:59 -0600 Subject: [PATCH 052/162] MC-4425: Convert ImportProductsTest to MFTF --- .../Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml index 72156ce57294f..cdef15d2a0924 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml @@ -48,7 +48,7 @@ <argument name="StoreGroup" value="customStoreGroup"/> <argument name="customStore" value="customStore"/> </actionGroup> - </before> + </before> <after> <!-- Delete all products that replaced products in the before block post import --> <deleteData stepKey="deleteSimpleProduct1" url="/V1/products/SimpleProductForTest1"/> @@ -65,7 +65,6 @@ <!--Logout--> <actionGroup ref="logout" stepKey="logoutFromAdmin"/> - </after> <!-- Import products with add/update behavior --> From 132b6366787d0f0971100f80c811fe5e5ff3681c Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Tue, 5 Mar 2019 11:39:08 -0600 Subject: [PATCH 053/162] MC-4425: Convert ImportProductsTest to MFTF --- .../Test/AdminImportProductsWithAddUpdateBehaviorTest.xml | 4 ++-- .../Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml index cdef15d2a0924..22d79334796af 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml @@ -19,7 +19,7 @@ <group value="importExport"/> </annotations> <before> - <!--Create Simple Product1--> + <!-- Create Simple Product1 --> <createData entity="_defaultCategory" stepKey="createCategory"/> <createData entity="SimpleProduct" stepKey="createSimpleProduct1"> <field key="name">SimpleProductForTest1</field> @@ -63,7 +63,7 @@ <argument name="websiteName" value="secondWebsite"/> </actionGroup> - <!--Logout--> + <!-- Logout --> <actionGroup ref="logout" stepKey="logoutFromAdmin"/> </after> diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml index 6a006814d4471..89008340675bb 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml @@ -19,14 +19,14 @@ <group value="importExport"/> </annotations> <before> - <!--Create Simple Product2--> + <!-- Create Simple Product2 --> <createData entity="SimpleProduct" stepKey="createSimpleProduct2"> <field key="name">SimpleProductForTest2</field> <field key="sku">SimpleProductForTest2</field> <requiredEntity createDataKey="createCategory"/> </createData> - <!--Create Simple Product3--> + <!-- Create Simple Product3 --> <createData entity="SimpleProduct" stepKey="createSimpleProduct3"> <field key="name">SimpleProductForTest3</field> <field key="sku">SimpleProductForTest3</field> From cbfbc8662d78ad46de151b3b8113b4cd03c89835 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Tue, 5 Mar 2019 11:47:54 -0600 Subject: [PATCH 054/162] MC-4425: Convert ImportProductsTest to MFTF Added migrated tags --- .../Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml | 1 + .../Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml | 1 + .../CatalogImportExport/Test/TestCase/ImportProductsTest.xml | 2 ++ 3 files changed, 4 insertions(+) diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml index 22d79334796af..954a2ee2d9d5d 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml @@ -17,6 +17,7 @@ <severity value="CRITICAL"/> <testCaseId value="MAGETWO-47724"/> <group value="importExport"/> + <group value="mtf_migrated"/> </annotations> <before> <!-- Create Simple Product1 --> diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml index 89008340675bb..3ebe1f59885ba 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml @@ -17,6 +17,7 @@ <severity value="CRITICAL"/> <testCaseId value="MAGETWO-47719"/> <group value="importExport"/> + <group value="mtf_migrated"/> </annotations> <before> <!-- Create Simple Product2 --> diff --git a/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ImportProductsTest.xml b/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ImportProductsTest.xml index edb0aad954fbb..77e5e2b91d93f 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ImportProductsTest.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ImportProductsTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\CatalogImportExport\Test\TestCase\ImportProductsTest" summary="Import products"> <variation name="ImportProductVariation1" ticketId="MAGETWO-47724" summary="Import Products with Add/Update Behavior"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="import/data" xsi:type="array"> <item name="entity" xsi:type="string">Products</item> <item name="behavior" xsi:type="string">Add/Update</item> @@ -38,6 +39,7 @@ <constraint name="Magento\CatalogImportExport\Test\Constraint\AssertProductsInGrid" /> </variation> <variation name="ImportProductVariation2" ticketId="MAGETWO-47719" summary="Import Products assigned to different websites with Replace Behavior"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="import/data/entity" xsi:type="string">Products</data> <data name="import/data/behavior" xsi:type="string">Replace</data> <data name="import/data/validation_strategy" xsi:type="string">Stop on Error</data> From 190b72ae5a159d4be2dfb7f4a09ec7eb590fc587 Mon Sep 17 00:00:00 2001 From: Kavitha <kanair@adobe.com> Date: Tue, 5 Mar 2019 11:49:44 -0600 Subject: [PATCH 055/162] MC-4903: Convert UpdateProductUrlRewriteEntityTest to MFTF --- .../Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml | 10 ++++------ .../StorefrontUrlRewriteRedirectActionGroup.xml | 1 + .../UrlRewrite/Test/Mftf/Data/UrlRewriteData.xml | 1 + .../UrlRewrite/Test/Mftf/MetaData/url_rewrite-meta.xml | 2 -- ...ateProductUrlRewriteAndAddTemporaryRedirectTest.xml | 8 +++----- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml index 5886b40c4547b..c82c8d3d088f3 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml @@ -77,14 +77,12 @@ </actionGroup> <actionGroup name="AdminUpdateUrlRewrite"> <arguments> - <argument name="requestPath" type="string"/> - <argument name="redirectTypeValue" type="string"/> - <argument name="description" type="string"/> + <argument name="urlRewrite" defaultValue="updateUrlRewrite"/> </arguments> - <fillField selector="{{AdminUrlRewriteEditSection.requestPath}}" userInput="{{requestPath}}" stepKey="fillRequestPath"/> + <fillField selector="{{AdminUrlRewriteEditSection.requestPath}}" userInput="{{urlRewrite.request_path}}" stepKey="fillRequestPath"/> <click selector="{{AdminUrlRewriteEditSection.redirectType}}" stepKey="selectRedirectType"/> - <click selector="{{AdminUrlRewriteEditSection.redirectTypeValue('redirectTypeValue')}}" stepKey="selectRedirectTypeValue"/> - <fillField selector="{{AdminUrlRewriteEditSection.description}}" userInput="{{description}}" stepKey="fillDescription"/> + <click selector="{{AdminUrlRewriteEditSection.redirectTypeValue(urlRewrite.redirect_type_label)}}" stepKey="selectRedirectTypeValue"/> + <fillField selector="{{AdminUrlRewriteEditSection.description}}" userInput="{{urlRewrite.description}}" stepKey="fillDescription"/> <click selector="{{AdminUrlRewriteEditSection.saveButton}}" stepKey="clickOnSaveButton"/> <seeElement selector="{{AdminUrlRewriteIndexSection.successMessage}}" stepKey="seeSuccessSaveMessage"/> </actionGroup> diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/StorefrontUrlRewriteRedirectActionGroup.xml b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/StorefrontUrlRewriteRedirectActionGroup.xml index a299e1689d6a7..482038a28ccb9 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/StorefrontUrlRewriteRedirectActionGroup.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/StorefrontUrlRewriteRedirectActionGroup.xml @@ -30,3 +30,4 @@ <see selector="{{StorefrontProductInfoMainSection.productSku}}" userInput="{{productSku}}" stepKey="seeProductSkuInStoreFrontPage"/> </actionGroup> </actionGroups> + diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Data/UrlRewriteData.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Data/UrlRewriteData.xml index 942882be259f9..a580e68639c7e 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/Data/UrlRewriteData.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/Data/UrlRewriteData.xml @@ -23,5 +23,6 @@ <data key="redirect_type_label">Temporary (302)</data> <data key="store_id">1</data> <data key="store">Default Store View</data> + <data key="description">Update Url Rewrite</data> </entity> </entities> \ No newline at end of file diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/MetaData/url_rewrite-meta.xml b/app/code/Magento/UrlRewrite/Test/Mftf/MetaData/url_rewrite-meta.xml index 84cf00ac08999..f33a1dee8e8bd 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/MetaData/url_rewrite-meta.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/MetaData/url_rewrite-meta.xml @@ -9,12 +9,10 @@ <operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd"> <operation name="CreateUrlRewrite" dataType="urlRewrite" type="create" auth="adminFormKey" url="/admin/url_rewrite/save/" method="POST" successRegex="/messages-message-success/"> - <!--<object key="urlRewrite" dataType="urlRewrite">--> <field key="store_id">integer</field> <field key="redirect_type">integer</field> <field key="request_path">string</field> <field key="target_path">string</field> <field key="description">string</field> - <!--</object>--> </operation> </operations> \ No newline at end of file diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateProductUrlRewriteAndAddTemporaryRedirectTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateProductUrlRewriteAndAddTemporaryRedirectTest.xml index cbb3680f37345..29b8365fb690a 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateProductUrlRewriteAndAddTemporaryRedirectTest.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateProductUrlRewriteAndAddTemporaryRedirectTest.xml @@ -9,7 +9,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminUpdateProductUrlRewriteAndAddTemporaryRedirectTest"> <annotations> - <stories value="Update URL rewrite"/> + <stories value="URL Rewrite"/> <title value="Update Product URL Rewrites"/> <description value="Login as Admin and update product UrlRewrite and add Temporary redirect type "/> <testCaseId value="MC-5351"/> @@ -33,16 +33,14 @@ <!-- Open UrlRewrite Edit page and update the fields --> <actionGroup ref="AdminUpdateUrlRewrite" stepKey="updateCategoryUrlRewrite"> - <argument name="requestPath" value="{{defaultUrlRewrite.request_path}}"/> - <argument name="redirectTypeValue" value="Temporary (302)"/> - <argument name="description" value="Update Product Url Rewrite"/> + <argument name="urlRewrite" value="updateUrlRewrite"/> </actionGroup> <!-- Assert product Url Rewrite in StoreFront --> <actionGroup ref="AssertStorefrontProductRedirect" stepKey="assertProductUrlRewriteInStoreFront"> <argument name="productName" value="$$createProduct.name$$"/> <argument name="productSku" value="$$createProduct.sku$$"/> - <argument name="productRequestPath" value="{{defaultUrlRewrite.request_path}}"/> + <argument name="productRequestPath" value="{{updateUrlRewrite.request_path}}"/> </actionGroup> </test> </tests> From 7ab162f0c910f36a9cb493ea050f44abe5594741 Mon Sep 17 00:00:00 2001 From: Kavitha <kanair@adobe.com> Date: Tue, 5 Mar 2019 14:36:32 -0600 Subject: [PATCH 056/162] MC-4455: Convert CreateDuplicateUrlProductEntity to MFTF --- .../ActionGroup/AdminProductActionGroup.xml | 16 +++++++------ .../Test/AdminCreateDuplicateProductTest.xml | 24 +++++++++++++++---- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml index d2d95d811c43d..709f74ede09aa 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml @@ -430,29 +430,31 @@ <click selector="{{AdminAddUpSellProductsModalSection.AddSelectedProductsButton}}" stepKey="addRelatedProductSelected"/> <waitForPageLoad stepKey="waitForPageToLoad1"/> </actionGroup> - <actionGroup name="createDuplicateProduct"> + <actionGroup name="adminFillAndSaveProductForm"> <arguments> - <argument name="product" defaultValue="$$createSimpleProduct$$" /> - <argument name="quantity" defaultValue="defaultSimpleProduct.quantity"/> + <argument name="product" defaultValue="defaultSimpleProduct"/> + <argument name="productName" type="string"/> + <argument name="productUrlKey" type="string"/> + <argument name="categoryName" type="string"/> </arguments> <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="openProductIndexPage"/> <waitForPageLoad stepKey="waitForProductIndexPageToLoad"/> <click selector="{{AdminProductGridActionSection.addProductBtn}}" stepKey="clickOnAddNewProduct"/> <waitForPageLoad stepKey="waitForPageToLoad"/> - <fillField selector="{{AdminProductFormSection.productName}}" userInput="{{product.name}}" stepKey="fillProductName"/> + <fillField selector="{{AdminProductFormSection.productName}}" userInput="{{productName}}" stepKey="fillProductName"/> <fillField selector="{{AdminProductFormSection.productSku}}" userInput="{{product.sku}}" stepKey="fillProductSku"/> <fillField selector="{{AdminProductFormSection.productPrice}}" userInput="{{product.price}}" stepKey="fillProductPrice"/> - <fillField selector="{{AdminProductFormSection.productQuantity}}" userInput="{{quantity}}" stepKey="fillProductQty"/> + <fillField selector="{{AdminProductFormSection.productQuantity}}" userInput="{{product.quantity}}" stepKey="fillProductQty"/> <selectOption selector="{{AdminProductFormSection.productStockStatus}}" userInput="{{product.status}}" stepKey="selectStockStatus"/> <selectOption selector="{{AdminProductFormSection.productWeightSelect}}" userInput="This item has weight" stepKey="selectWeight"/> <fillField selector="{{AdminProductFormSection.productWeight}}" userInput="{{product.weight}}" stepKey="fillProductWeight"/> + <searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="[{{categoryName}}]" stepKey="searchAndSelectCategory"/> <scrollTo selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="scrollToSectionHeader"/> <click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="openSeoSection"/> - <fillField userInput="{{product.custom_attributes[url_key]}}" selector="{{AdminProductSEOSection.urlKeyInput}}" stepKey="fillUrlKey"/> + <fillField userInput="{{productUrlKey}}" selector="{{AdminProductSEOSection.urlKeyInput}}" stepKey="fillUrlKey"/> <scrollToTopOfPage stepKey="scrollTopPageProduct"/> <waitForElementVisible selector="{{AdminProductFormActionSection.saveButton}}" stepKey="waitForSaveProductButton" /> <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveProduct"/> <waitForPageLoad stepKey="waitForProductToSave"/> - <see selector="{{AdminProductFormSection.successMessage}}" userInput="The value specified in the URL Key field would generate a URL that already exists." stepKey="seeErrorMessage"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateProductTest.xml index 81a0916be6e77..68dfc44aa886a 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateProductTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateProductTest.xml @@ -10,22 +10,36 @@ <test name="AdminCreateDuplicateProductTest"> <annotations> <stories value="Create Product"/> - <title value="CreateDuplicateUrlProductEntityTestVariation1"/> + <title value="Create Duplicate Product With Existed Subcategory Name And UrlKey"/> <description value="Login as admin and create duplicate Product"/> <testCaseId value="MC-14714"/> <severity value="CRITICAL"/> <group value="mtf_migrated"/> </annotations> + <before> <magentoCLI command="cache:flush" stepKey="flushCache"/> <actionGroup ref="LoginAsAdmin" stepKey="login"/> - <createData entity="defaultSimpleProduct" stepKey="createSimpleProduct"/> + <createData entity="SubCategory" stepKey="category"/> + <createData entity="Two_nested_categories" stepKey="subCategory"> + <requiredEntity createDataKey="category"/> + </createData> </before> <after> - <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> + <deleteData createDataKey="subCategory" stepKey="deleteSubCategory"/> + <deleteData createDataKey="category" stepKey="deleteCategory"/> + <actionGroup ref="logout" stepKey="logout"/> </after> - <!-- Create duplicate Product and Save the Product --> - <actionGroup ref="createDuplicateProduct" stepKey="createDuplicateProduct"/> + <!-- Create Product using above created Subcategory Name and SubCategory UrlKey and Save the Product --> + <actionGroup ref="adminFillAndSaveProductForm" stepKey="createDuplicateProduct"> + <argument name="product" value="defaultSimpleProduct"/> + <argument name="productName" value="$$subCategory.name$$"/> + <argument name="productUrlKey" value="$$subCategory.custom_attributes[url_key]$$"/> + <argument name="categoryName" value="$$category.name$$"/> + </actionGroup> + + <!--Assert Error Message --> + <see selector="{{AdminProductFormSection.successMessage}}" userInput="The value specified in the URL Key field would generate a URL that already exists." stepKey="seeErrorMessage"/> </test> </tests> From a0d827c02a6c90061fd298b0596d932ee2d189bd Mon Sep 17 00:00:00 2001 From: sathakur <sathakur@adobe.com> Date: Tue, 5 Mar 2019 14:47:03 -0600 Subject: [PATCH 057/162] MC-4873: Convert UpdateWebsiteEntityTest to MFTF --- .../AdminCreateWebsiteActionGroup.xml | 26 ++++++++ .../Store/Test/Mftf/Data/WebsiteData.xml | 6 +- .../Mftf/Section/AdminStoresGridSection.xml | 3 +- .../Test/Mftf/Test/AdminUpdateWebsiteTest.xml | 59 +++++++++++++++++++ 4 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 app/code/Magento/Store/Test/Mftf/Test/AdminUpdateWebsiteTest.xml diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateWebsiteActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateWebsiteActionGroup.xml index ef8d77c8824ff..ca614ec24138c 100644 --- a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateWebsiteActionGroup.xml +++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminCreateWebsiteActionGroup.xml @@ -36,4 +36,30 @@ <click selector="{{AdminStoresGridSection.websiteNameInFirstRow}}" stepKey="clickEditExistingWebsite"/> <grabFromCurrentUrl regex="~(\d+)/~" stepKey="grabFromCurrentUrl"/> </actionGroup> + + <actionGroup name="AssertWebsiteInGrid"> + <arguments> + <argument name="websiteName" type="string"/> + </arguments> + <amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/> + <waitForPageLoad stepKey="waitForAdminSystemStorePageLoad"/> + <click selector="{{AdminStoresGridSection.resetButton}}" stepKey="resetSearchFilter"/> + <fillField userInput="{{websiteName}}" selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="fillWebsiteField"/> + <click selector="{{AdminStoresGridSection.searchButton}}" stepKey="clickSearchButton"/> + <waitForPageLoad stepKey="waitForStoreToLoad"/> + <seeElement selector="{{AdminStoresGridSection.websiteName(websiteName)}}" stepKey="seeAssertWebsiteInGrid"/> + </actionGroup> + + <actionGroup name="AssertWebsiteForm"> + <arguments> + <argument name="websiteName" type="string"/> + <argument name="websiteCode" type="string"/> + </arguments> + <click selector="{{AdminStoresGridSection.websiteName(websiteName)}}" stepKey="clickWebsiteFirstRowInGrid"/> + <waitForPageLoad stepKey="waitTillWebsiteFormPageIsOpened"/> + <grabFromCurrentUrl regex="~(\d+)/~" stepKey="grabWebsiteIdFromCurrentUrl"/> + <seeInCurrentUrl url="/system_store/editWebsite/website_id/{$grabWebsiteIdFromCurrentUrl}" stepKey="seeWebsiteId"/> + <seeInField selector="{{AdminNewWebsiteSection.name}}" userInput="{{websiteName}}" stepKey="seeAssertWebsiteName"/> + <seeInField selector="{{AdminNewWebsiteSection.code}}" userInput="{{websiteCode}}" stepKey="seeAssertWebsiteCode"/> + </actionGroup> </actionGroups> \ No newline at end of file diff --git a/app/code/Magento/Store/Test/Mftf/Data/WebsiteData.xml b/app/code/Magento/Store/Test/Mftf/Data/WebsiteData.xml index f636336524f01..ae605256a2819 100644 --- a/app/code/Magento/Store/Test/Mftf/Data/WebsiteData.xml +++ b/app/code/Magento/Store/Test/Mftf/Data/WebsiteData.xml @@ -23,4 +23,8 @@ <data key="name" unique="suffix">Custom Website</data> <data key="code" unique="suffix">custom_website</data> </entity> -</entities> + <entity name="updateCustomWebsite" extends="customWebsite"> + <data key="name" unique="suffix">website_upd</data> + <data key="code" unique="suffix">code_upd</data> + </entity> +</entities> \ No newline at end of file diff --git a/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml b/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml index 592af42f2de30..d7006fd01b2ff 100644 --- a/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml +++ b/app/code/Magento/Store/Test/Mftf/Section/AdminStoresGridSection.xml @@ -23,5 +23,6 @@ <element name="firstRow" type="textarea" selector="(//*[@id='storeGrid_table']/tbody/tr)[1]"/> <element name="successMessage" type="text" selector="//div[@class='message message-success success']/div"/> <element name="emptyText" type="text" selector="//tr[@class='data-grid-tr-no-data even']/td[@class='empty-text']"/> + <element name="websiteName" type="text" selector="//td[@class='a-left col-website_title ']/a[contains(.,'{{websiteName}}')]" parameterized="true"/> </section> -</sections> +</sections> \ No newline at end of file diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateWebsiteTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateWebsiteTest.xml new file mode 100644 index 0000000000000..6b666126569ae --- /dev/null +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateWebsiteTest.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<!-- Test XML Example --> +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdminUpdateWebsiteTest"> + <annotations> + <stories value="Update Website"/> + <title value="Update Website and Verify Store Form"/> + <description value="Test log in to Stores and Update Website Test"/> + <testCaseId value="MC-14301"/> + <severity value="CRITICAL"/> + <group value="store"/> + <group value="mtf_migrated"/> + </annotations> + + <before> + <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <!--Create website--> + <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createWebsite"> + <argument name="newWebsiteName" value="{{customWebsite.name}}"/> + <argument name="websiteCode" value="{{customWebsite.code}}"/> + </actionGroup> + </before> + <after> + <actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite"> + <argument name="websiteName" value="{{updateCustomWebsite.name}}"/> + </actionGroup> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!--Search created custom website in grid--> + <actionGroup ref="AssertWebsiteInGrid" stepKey="seeWebsiteInGrid"> + <argument name="websiteName" value="{{customWebsite.name}}"/> + </actionGroup> + <click selector="{{AdminStoresGridSection.websiteName(customWebsite.name)}}" stepKey="clickWebsiteFirstRowInGrid"/> + <waitForPageLoad stepKey="waitForWebsiteFormPageToOpen"/> + <!--Update website name and website code as per data created and verify AssertWebsiteSuccessSaveMessage--> + <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createWebsite"> + <argument name="newWebsiteName" value="{{updateCustomWebsite.name}}"/> + <argument name="websiteCode" value="{{updateCustomWebsite.code}}"/> + </actionGroup> + + <!--Search updated custom website(from above step) in grid and verify AssertWebsiteInGrid--> + <actionGroup ref="AssertWebsiteInGrid" stepKey="seeUpdatedWebsiteInGrid"> + <argument name="websiteName" value="{{updateCustomWebsite.name}}"/> + </actionGroup> + + <!--Verify updated website name and updated websitecode on website form (AssertWebsiteForm and AssertWebsiteOnStoreForm)--> + <actionGroup ref="AssertWebsiteForm" stepKey="seeUpdatedWebsiteForm"> + <argument name="websiteName" value="{{updateCustomWebsite.name}}"/> + <argument name="websiteCode" value="{{updateCustomWebsite.code}}"/> + </actionGroup> + </test> +</tests> \ No newline at end of file From 828b39374794f11c5689dd03e24a8300ba57b2e4 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Tue, 5 Mar 2019 15:27:58 -0600 Subject: [PATCH 058/162] MC-4425: Convert ImportProductsTest to MFTF Merged 2 action groups with parametrization --- ...xml => AdminImportProductsActionGroup.xml} | 5 ++-- ...ProductsWithReplaceBehaviorActionGroup.xml | 29 ------------------- ...mportProductsWithAddUpdateBehaviorTest.xml | 3 +- ...nImportProductsWithReplaceBehaviorTest.xml | 3 +- 4 files changed, 7 insertions(+), 33 deletions(-) rename app/code/Magento/ImportExport/Test/Mftf/ActionGroup/{AdminImportProductsWithAddUpdateBehaviorActionGroup.xml => AdminImportProductsActionGroup.xml} (90%) delete mode 100644 app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithReplaceBehaviorActionGroup.xml diff --git a/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithAddUpdateBehaviorActionGroup.xml b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml similarity index 90% rename from app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithAddUpdateBehaviorActionGroup.xml rename to app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml index 53406ed25e3c0..a9100b4730b8c 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithAddUpdateBehaviorActionGroup.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml @@ -8,8 +8,9 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminImportProductsWithAddUpdateBehaviorActionGroup"> + <actionGroup name="AdminImportProductsActionGroup"> <arguments> + <argument name="behavior" type="string"/> <argument name="importFile" type="string"/> <argument name="importMessage" type="string"/> </arguments> @@ -17,7 +18,7 @@ <waitForPageLoad stepKey="AdminImportMainSectionLoad"/> <selectOption selector="{{AdminImportMainSection.entityType}}" userInput="Products" stepKey="selectProductsOption"/> <waitForElementVisible selector="{{AdminImportMainSection.importBehavior}}" stepKey="waitForImportBehaviorElementVisible"/> - <selectOption selector="{{AdminImportMainSection.importBehavior}}" userInput="Add/Update" stepKey="selectReplaceOption"/> + <selectOption selector="{{AdminImportMainSection.importBehavior}}" userInput="{{behavior}}" stepKey="selectImportOption"/> <attachFile selector="{{AdminImportMainSection.selectFileToImport}}" userInput="{{importFile}}" stepKey="attachFileForImport"/> <click selector="{{AdminImportHeaderSection.checkDataButton}}" stepKey="clickCheckDataButton"/> <click selector="{{AdminImportMainSection.importButton}}" stepKey="clickImportButton"/> diff --git a/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithReplaceBehaviorActionGroup.xml b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithReplaceBehaviorActionGroup.xml deleted file mode 100644 index 5e7c3d164e067..0000000000000 --- a/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsWithReplaceBehaviorActionGroup.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?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="AdminImportProductsWithReplaceBehaviorActionGroup"> - <arguments> - <argument name="importFile" type="string"/> - <argument name="importMessage" type="string"/> - </arguments> - <amOnPage url="{{AdminImportIndexPage.url}}" stepKey="goToImportIndexPage"/> - <waitForPageLoad stepKey="AdminImportMainSectionLoad"/> - <selectOption selector="{{AdminImportMainSection.entityType}}" userInput="Products" stepKey="selectProductsOption"/> - <waitForElementVisible selector="{{AdminImportMainSection.importBehavior}}" stepKey="waitForImportBehaviorElementVisible"/> - <selectOption selector="{{AdminImportMainSection.importBehavior}}" userInput="Replace" stepKey="selectReplaceOption"/> - <attachFile selector="{{AdminImportMainSection.selectFileToImport}}" userInput="{{importFile}}" stepKey="attachFileForImport"/> - <click selector="{{AdminImportHeaderSection.checkDataButton}}" stepKey="clickCheckDataButton"/> - <click selector="{{AdminImportMainSection.importButton}}" stepKey="clickImportButton"/> - <waitForPageLoad stepKey="AdminImportMainSectionLoad2"/> - <see selector="{{AdminMessagesSection.successMessage}}" userInput="Import successfully done" stepKey="assertSuccessMessage"/> - <waitForPageLoad stepKey="AdminMessagesSection"/> - <see selector="{{AdminMessagesSection.notice}}" userInput="{{importMessage}}" stepKey="assertNotice"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml index 954a2ee2d9d5d..f3238293e5713 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml @@ -69,7 +69,8 @@ </after> <!-- Import products with add/update behavior --> - <actionGroup ref="AdminImportProductsWithAddUpdateBehaviorActionGroup" stepKey="adminImportProducts"> + <actionGroup ref="AdminImportProductsActionGroup" stepKey="adminImportProducts"> + <argument name="behavior" value="Add/Update"/> <argument name="importFile" value="catalog_import_products.csv"/> <argument name="importMessage" value="Created: 2, Updated: 1, Deleted: 0"/> </actionGroup> diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml index 3ebe1f59885ba..d45b294a34e4f 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml @@ -36,7 +36,8 @@ </before> <!-- Import products with replace behavior --> - <actionGroup ref="AdminImportProductsWithReplaceBehaviorActionGroup" stepKey="adminImportProducts"> + <actionGroup ref="AdminImportProductsActionGroup" stepKey="adminImportProducts"> + <argument name="behavior" value="Replace"/> <argument name="importFile" value="catalog_import_products.csv"/> <argument name="importMessage" value="Created: 3, Updated: 0, Deleted: 3"/> </actionGroup> From 423bd3abc2c1b59738cbbe9a8928f4617e1854db Mon Sep 17 00:00:00 2001 From: Maria Kovdrysh <kovdrysh@adobe.com> Date: Wed, 6 Mar 2019 12:57:55 -0600 Subject: [PATCH 059/162] MC-4436: Convert CreateSearchTermEntityTest to MFTF --- ...StorefrontCatalogSearchTermActionGroup.xml | 12 ++++ .../Mftf/Test/CreateSearchTermEntityTest.xml | 59 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 app/code/Magento/CatalogSearch/Test/Mftf/Test/CreateSearchTermEntityTest.xml diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchTermActionGroup.xml b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchTermActionGroup.xml index a825e06f490a5..83e4ac50a74e6 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchTermActionGroup.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchTermActionGroup.xml @@ -22,4 +22,16 @@ <waitForPageLoad stepKey="waitForSearch"/> <see selector="{{StorefrontMessagesSection.noticeMessage}}" userInput="Your search returned no results." stepKey="seeAssertSearchTermNotOnFrontendNoticeMessage"/> </actionGroup> + + <actionGroup name="AssertSearchTermOnFrontend"> + <arguments> + <argument name="searchQuery" type="string"/> + <argument name="redirectUrl" type="string"/> + </arguments> + <fillField selector="{{StorefrontQuickSearchResultsSection.searchTextBox}}" userInput="{{searchQuery}}" stepKey="fillSearchQuery"/> + <waitForPageLoad stepKey="waitForFillField"/> + <click selector="{{StorefrontQuickSearchResultsSection.searchTextBoxButton}}" stepKey="clickSearchTextBoxButton"/> + <waitForPageLoad stepKey="waitForSearch"/> + <seeInCurrentUrl url="{{redirectUrl}}" stepKey="checkUrl"/> + </actionGroup> </actionGroups> \ No newline at end of file diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/CreateSearchTermEntityTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/CreateSearchTermEntityTest.xml new file mode 100644 index 0000000000000..a710f3dd8fa5c --- /dev/null +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/CreateSearchTermEntityTest.xml @@ -0,0 +1,59 @@ +<?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="CreateSearchTermTest"> + <annotations> + <stories value="Search terms"/> + <title value="Create search term test"/> + <description value="Admin should be able to create search term"/> + <testCaseId value="MC-13989"/> + <severity value="CRITICAL"/> + <group value="CatalogSearch"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <!-- Login as admin --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + + <!-- Create simple product --> + <createData entity="SimpleProduct2" stepKey="createSimpleProduct"/> + </before> + <after> + <!-- Delete created search term --> + <actionGroup ref="AssertSearchTermSuccessDeleteMessage" stepKey="deleteSearchTerm"> + <argument name="searchQuery" value="$$createSimpleProduct.sku$$"/> + </actionGroup> + + <!-- Delete created product --> + <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> + + <!-- Log out --> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Go to the search terms page and create new search term --> + <actionGroup ref="AssertSearchTermSaveSuccessMessage" stepKey="createNewSearchTerm"> + <argument name="searchQuery" value="$$createSimpleProduct.sku$$"/> + <argument name="storeValue" value="{{SimpleTerm.store_id}}"/> + <argument name="redirectUrl" value="{{SimpleTerm.redirect}}"/> + <argument name="displayInSuggestedTerm" value="{{SimpleTerm.display_in_terms}}"/> + </actionGroup> + + <!-- Go to storefront --> + <amOnPage url="{{StorefrontHomePage.url}}" stepKey="amOnStorefrontPage"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + + <!-- Assert created search term on storefront --> + <actionGroup ref="AssertSearchTermOnFrontend" stepKey="assertCreatedSearchTermOnFrontend"> + <argument name="searchQuery" value="$$createSimpleProduct.sku$$"/> + <argument name="redirectUrl" value="{{SimpleTerm.redirect}}"/> + </actionGroup> + </test> +</tests> From b0ac70bee1d364ab693433c16250ef48186b0f5d Mon Sep 17 00:00:00 2001 From: duhon <duhon@rambler.ru> Date: Wed, 13 Feb 2019 19:04:42 -0600 Subject: [PATCH 060/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Catalog/Api/Data/MassActionInterface.php | 135 ++++++++++ .../Product/Action/Attribute/Save.php | 135 +++------- .../Model/Attribute/Backend/Consumer.php | 254 ++++++++++++++++++ app/code/Magento/Catalog/Model/MassAction.php | 174 ++++++++++++ .../Magento/Catalog/etc/communication.xml | 12 + app/code/Magento/Catalog/etc/di.xml | 1 + app/code/Magento/Catalog/etc/queue.xml | 12 + .../Magento/Catalog/etc/queue_consumer.xml | 10 + .../Magento/Catalog/etc/queue_publisher.xml | 12 + .../Magento/Catalog/etc/queue_topology.xml | 12 + .../Reflection/DataObjectProcessor.php | 4 +- 11 files changed, 658 insertions(+), 103 deletions(-) create mode 100644 app/code/Magento/Catalog/Api/Data/MassActionInterface.php create mode 100644 app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php create mode 100644 app/code/Magento/Catalog/Model/MassAction.php create mode 100644 app/code/Magento/Catalog/etc/communication.xml create mode 100644 app/code/Magento/Catalog/etc/queue.xml create mode 100644 app/code/Magento/Catalog/etc/queue_consumer.xml create mode 100644 app/code/Magento/Catalog/etc/queue_publisher.xml create mode 100644 app/code/Magento/Catalog/etc/queue_topology.xml diff --git a/app/code/Magento/Catalog/Api/Data/MassActionInterface.php b/app/code/Magento/Catalog/Api/Data/MassActionInterface.php new file mode 100644 index 0000000000000..3f47242e3aa61 --- /dev/null +++ b/app/code/Magento/Catalog/Api/Data/MassActionInterface.php @@ -0,0 +1,135 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Catalog\Api\Data; + +/** + * MassAction interface. + * @api + * @since 101.1.0 + */ +interface MassActionInterface +{ + + /** + * Set data value. + * + * @param string[] $data + * @return void + * @since 101.1.0 + */ + public function setInventory($data); + + /** + * Get data value. + * + * @return string[] + * @since 101.1.0 + */ + public function getInventory():array; + + /** + * Set data value. + * + * @param string[] $data + * @return void + * @since 101.1.0 + */ + public function setAttributes($data); + + /** + * Get data value. + * + * @return string[] + * @since 101.1.0 + */ + public function getAttributes():array; + + /** + * Set data value. + * + * @param string[] $data + * @return void + * @since 101.1.0 + */ + public function setWebsiteRemove($data); + + /** + * Get data value. + * + * @return string[] + * @since 101.1.0 + */ + public function getWebsiteRemove():array; + + /** + * Set data value. + * + * @param string[] $data + * @return void + * @since 101.1.0 + */ + public function setWebsiteAdd($data); + + /** + * Get data value. + * + * @return string[] + * @since 101.1.0 + */ + public function getWebsiteAdd():array; + + /** + * Set data value. + * + * @param integer $data + * @return void + * @since 101.1.0 + */ + public function setStoreId($data); + + /** + * Get data value. + * + * @return integer + * @since 101.1.0 + */ + public function getStoreId(); + + /** + * Set data value. + * + * @param integer[] $data + * @return void + * @since 101.1.0 + */ + public function setProductIds(array $data); + + /** + * Get data value. + * + * @return integer[] + * @since 101.1.0 + */ + public function getProductIds():array; + + /** + * Set data value. + * + * @param integer $data + * @return void + * @since 101.1.0 + */ + public function setWebsiteId($data); + + /** + * Get data value. + * + * @return integer + * @since 101.1.0 + */ + public function getWebsiteId(); +} diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index 0730e7a7c5dc1..69969231490b7 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -6,8 +6,12 @@ */ namespace Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute; +use Magento\Catalog\Api\Data\MassActionInterfaceFactory; +use Magento\CatalogInventory\Api\StockConfigurationInterface; use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; use Magento\Backend\App\Action; +use Magento\Framework\MessageQueue\PublisherInterface; +use Magento\Framework\App\ObjectManager; /** * Class Save @@ -49,6 +53,16 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribut */ protected $dataObjectHelper; + /** + * @var PublisherInterface + */ + private $messagePublisher; + /** + * @var MassActionInterfaceFactory|null + */ + private $massActionFactory; + + /** * @param Action\Context $context * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper @@ -58,6 +72,8 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribut * @param \Magento\Catalog\Helper\Product $catalogProduct * @param \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory $stockItemFactory * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper + * @param PublisherInterface|null $publisher + * @param MassActionInterfaceFactory|null $massAction */ public function __construct( Action\Context $context, @@ -67,7 +83,9 @@ public function __construct( \Magento\CatalogInventory\Model\Indexer\Stock\Processor $stockIndexerProcessor, \Magento\Catalog\Helper\Product $catalogProduct, \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory $stockItemFactory, - \Magento\Framework\Api\DataObjectHelper $dataObjectHelper + \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, + PublisherInterface $publisher = null, + MassActionInterfaceFactory $massAction = null ) { $this->_productFlatIndexerProcessor = $productFlatIndexerProcessor; $this->_productPriceIndexerProcessor = $productPriceIndexerProcessor; @@ -76,6 +94,8 @@ public function __construct( $this->stockItemFactory = $stockItemFactory; parent::__construct($context, $attributeHelper); $this->dataObjectHelper = $dataObjectHelper; + $this->messagePublisher = $publisher ?: ObjectManager::getInstance()->get(PublisherInterface::class); + $this->massActionFactory = $massAction ?: ObjectManager::getInstance()->get(MassActionInterfaceFactory::class); } /** @@ -99,112 +119,25 @@ public function execute() $websiteAddData = $this->getRequest()->getParam('add_website_ids', []); /* Prepare inventory data item options (use config settings) */ - $options = $this->_objectManager->get(\Magento\CatalogInventory\Api\StockConfigurationInterface::class) - ->getConfigItemOptions(); + $options = $this->_objectManager->get(StockConfigurationInterface::class)->getConfigItemOptions(); foreach ($options as $option) { if (isset($inventoryData[$option]) && !isset($inventoryData['use_config_' . $option])) { $inventoryData['use_config_' . $option] = 0; } } - try { - $storeId = $this->attributeHelper->getSelectedStoreId(); - if ($attributesData) { - $dateFormat = $this->_objectManager->get(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) - ->getDateFormat(\IntlDateFormatter::SHORT); - - foreach ($attributesData as $attributeCode => $value) { - $attribute = $this->_objectManager->get(\Magento\Eav\Model\Config::class) - ->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); - if (!$attribute->getAttributeId()) { - unset($attributesData[$attributeCode]); - continue; - } - if ($attribute->getBackendType() == 'datetime') { - if (!empty($value)) { - $filterInput = new \Zend_Filter_LocalizedToNormalized(['date_format' => $dateFormat]); - $filterInternal = new \Zend_Filter_NormalizedToLocalized( - ['date_format' => \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT] - ); - $value = $filterInternal->filter($filterInput->filter($value)); - } else { - $value = null; - } - $attributesData[$attributeCode] = $value; - } elseif ($attribute->getFrontendInput() == 'multiselect') { - // Check if 'Change' checkbox has been checked by admin for this attribute - $isChanged = (bool)$this->getRequest()->getPost('toggle_' . $attributeCode); - if (!$isChanged) { - unset($attributesData[$attributeCode]); - continue; - } - if (is_array($value)) { - $value = implode(',', $value); - } - $attributesData[$attributeCode] = $value; - } - } - - $this->_objectManager->get(\Magento\Catalog\Model\Product\Action::class) - ->updateAttributes($this->attributeHelper->getProductIds(), $attributesData, $storeId); - } - - if ($inventoryData) { - // TODO why use ObjectManager? - /** @var \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry */ - $stockRegistry = $this->_objectManager - ->create(\Magento\CatalogInventory\Api\StockRegistryInterface::class); - /** @var \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepository */ - $stockItemRepository = $this->_objectManager - ->create(\Magento\CatalogInventory\Api\StockItemRepositoryInterface::class); - foreach ($this->attributeHelper->getProductIds() as $productId) { - $stockItemDo = $stockRegistry->getStockItem( - $productId, - $this->attributeHelper->getStoreWebsiteId($storeId) - ); - if (!$stockItemDo->getProductId()) { - $inventoryData['product_id'] = $productId; - } - - $stockItemId = $stockItemDo->getId(); - $this->dataObjectHelper->populateWithArray( - $stockItemDo, - $inventoryData, - \Magento\CatalogInventory\Api\Data\StockItemInterface::class - ); - $stockItemDo->setItemId($stockItemId); - $stockItemRepository->save($stockItemDo); - } - $this->_stockIndexerProcessor->reindexList($this->attributeHelper->getProductIds()); - } + $massAction = $this->massActionFactory->create(); + $massAction->setInventory($inventoryData); + $massAction->setAttributes($attributesData); + $massAction->setWebsiteRemove($websiteRemoveData); + $massAction->setWebsiteAdd($websiteAddData); + $massAction->setStoreId($this->attributeHelper->getSelectedStoreId()); + $massAction->setProductIds($this->attributeHelper->getProductIds()); + $massAction->setWebsiteId($this->attributeHelper->getStoreWebsiteId($massAction->getStoreId())); - if ($websiteAddData || $websiteRemoveData) { - /* @var $actionModel \Magento\Catalog\Model\Product\Action */ - $actionModel = $this->_objectManager->get(\Magento\Catalog\Model\Product\Action::class); - $productIds = $this->attributeHelper->getProductIds(); - - if ($websiteRemoveData) { - $actionModel->updateWebsites($productIds, $websiteRemoveData, 'remove'); - } - if ($websiteAddData) { - $actionModel->updateWebsites($productIds, $websiteAddData, 'add'); - } - - $this->_eventManager->dispatch('catalog_product_to_website_change', ['products' => $productIds]); - } - - $this->messageManager->addSuccessMessage( - __('A total of %1 record(s) were updated.', count($this->attributeHelper->getProductIds())) - ); - - $this->_productFlatIndexerProcessor->reindexList($this->attributeHelper->getProductIds()); - - if ($this->_catalogProduct->isDataForPriceIndexerWasChanged($attributesData) - || !empty($websiteRemoveData) - || !empty($websiteAddData) - ) { - $this->_productPriceIndexerProcessor->reindexList($this->attributeHelper->getProductIds()); - } + try { + $this->messagePublisher->publish('product_action_attribute.update', $massAction); + $this->messageManager->addSuccessMessage(__('Message is added to queue, wait')); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { @@ -215,6 +148,6 @@ public function execute() } return $this->resultRedirectFactory->create() - ->setPath('catalog/product/', ['store' => $this->attributeHelper->getSelectedStoreId()]); + ->setPath('catalog/product/', ['store' => $massAction->getStoreId()]); } } diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php new file mode 100644 index 0000000000000..029223972780a --- /dev/null +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php @@ -0,0 +1,254 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Model\Attribute\Backend; + +use Magento\Catalog\Api\Data\MassActionInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Notification\NotifierInterface; +use Magento\Framework\App\ObjectManager; + +/** + * Consumer for export message. + */ +class Consumer +{ + /** + * @var NotifierInterface + */ + private $notifier; + + /** + * @var \Psr\Log\LoggerInterface + */ + private $logger; + + /** + * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor + */ + protected $_productFlatIndexerProcessor; + + /** + * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor + */ + protected $_productPriceIndexerProcessor; + + /** + * Catalog product + * + * @var \Magento\Catalog\Helper\Product + */ + protected $_catalogProduct; + + /** + * @var \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory + */ + protected $stockItemFactory; + + /** + * Stock Indexer + * + * @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor + */ + protected $_stockIndexerProcessor; + + /** + * @var \Magento\Framework\Api\DataObjectHelper + */ + protected $dataObjectHelper; + + /** + * @var \Magento\Framework\Event\ManagerInterface + */ + private $_eventManager; + + /** + * @var ObjectManager + */ + private $_objectManager; + + /** + * @param \Magento\Catalog\Helper\Product $catalogProduct + * @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor + * @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor + * @param \Magento\CatalogInventory\Model\Indexer\Stock\Processor $stockIndexerProcessor + * @param \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory $stockItemFactory + * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper + * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param NotifierInterface $notifier + */ + public function __construct( + \Magento\Catalog\Helper\Product $catalogProduct, + \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor, + \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor, + \Magento\CatalogInventory\Model\Indexer\Stock\Processor $stockIndexerProcessor, + \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory $stockItemFactory, + \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, + \Magento\Framework\Event\ManagerInterface $eventManager, + NotifierInterface $notifier + ) { + $this->_catalogProduct = $catalogProduct; + $this->_productFlatIndexerProcessor = $productFlatIndexerProcessor; + $this->_productPriceIndexerProcessor = $productPriceIndexerProcessor; + $this->_stockIndexerProcessor = $stockIndexerProcessor; + $this->stockItemFactory = $stockItemFactory; + $this->dataObjectHelper = $dataObjectHelper; + $this->notifier = $notifier; + $this->_eventManager = $eventManager; + $this->_objectManager = ObjectManager::getInstance(); + } + + public function process(MassActionInterface $data): void + { + try { + if ($data->getAttributes()) { + $attributesData = $this->getAttributesData($data, $data->getAttributes()); + } + + if ($data->getInventory()) { + $this->saveInventory($data, $data->getInventory()); + } + + if ($data->getWebsiteAdd() || $data->getWebsiteRemove()) { + $this->updateWebsiteInProducts($data, $data->getWebsiteRemove(), $data->getWebsiteAdd()); + } + + $this->reindex($data, $attributesData, $data->getWebsiteRemove(), $data->getWebsiteAdd()); + + $this->notifier->addNotice( + __('Product attributes updated'), + __('A total of %1 record(s) were updated.', count($data->getProductIds())) + ); + } catch (LocalizedException $exception) { + $this->notifier->addCritical( + __('Error during process occurred'), + __('Error during process occurred. Please check logs for detail') + ); + $this->logger->critical('Something went wrong while process. ' . $exception->getMessage()); + } + } + + /** + * @param MassActionInterface $data + * @param $attributesData + * @return mixed + */ + private function getAttributesData(MassActionInterface $data, $attributesData) + { + $dateFormat = $this->_objectManager->get(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) + ->getDateFormat(\IntlDateFormatter::SHORT); + + foreach ($attributesData as $attributeCode => $value) { + $attribute = $this->_objectManager->get(\Magento\Eav\Model\Config::class) + ->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); + if (!$attribute->getAttributeId()) { + unset($attributesData[$attributeCode]); + continue; + } + if ($attribute->getBackendType() == 'datetime') { + if (!empty($value)) { + $filterInput = new \Zend_Filter_LocalizedToNormalized(['date_format' => $dateFormat]); + $filterInternal = new \Zend_Filter_NormalizedToLocalized( + ['date_format' => \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT] + ); + $value = $filterInternal->filter($filterInput->filter($value)); + } else { + $value = null; + } + $attributesData[$attributeCode] = $value; + } elseif ($attribute->getFrontendInput() == 'multiselect') { + // Check if 'Change' checkbox has been checked by admin for this attribute + $isChanged = (bool)$this->getRequest()->getPost('toggle_' . $attributeCode); + if (!$isChanged) { + unset($attributesData[$attributeCode]); + continue; + } + if (is_array($value)) { + $value = implode(',', $value); + } + $attributesData[$attributeCode] = $value; + } + } + + $this->_objectManager->get(\Magento\Catalog\Model\Product\Action::class) + ->updateAttributes($data->getProductIds(), $attributesData, $data->getStoreId()); + return $attributesData; + } + + /** + * @param MassActionInterface $data + * @param $inventoryData + */ + private function saveInventory(MassActionInterface $data, $inventoryData): void + { + // TODO why use ObjectManager? + /** @var \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry */ + $stockRegistry = $this->_objectManager + ->create(\Magento\CatalogInventory\Api\StockRegistryInterface::class); + /** @var \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepository */ + $stockItemRepository = $this->_objectManager + ->create(\Magento\CatalogInventory\Api\StockItemRepositoryInterface::class); + foreach ($data->getProductIds() as $productId) { + $stockItemDo = $stockRegistry->getStockItem( + $productId, + $data->getWebsiteId() + ); + if (!$stockItemDo->getProductId()) { + $inventoryData['product_id'] = $productId; + } + + $stockItemId = $stockItemDo->getId(); + $this->dataObjectHelper->populateWithArray( + $stockItemDo, + $inventoryData, + \Magento\CatalogInventory\Api\Data\StockItemInterface::class + ); + $stockItemDo->setItemId($stockItemId); + $stockItemRepository->save($stockItemDo); + } + $this->_stockIndexerProcessor->reindexList($data->getProductIds()); + } + + /** + * @param MassActionInterface $data + * @param $websiteRemoveData + * @param $websiteAddData + */ + private function updateWebsiteInProducts(MassActionInterface $data, $websiteRemoveData, $websiteAddData): void + { + /* @var $actionModel \Magento\Catalog\Model\Product\Action */ + $actionModel = $this->_objectManager->get(\Magento\Catalog\Model\Product\Action::class); + $productIds = $data->getProductIds(); + + if ($websiteRemoveData) { + $actionModel->updateWebsites($productIds, $websiteRemoveData, 'remove'); + } + if ($websiteAddData) { + $actionModel->updateWebsites($productIds, $websiteAddData, 'add'); + } + + $this->_eventManager->dispatch('catalog_product_to_website_change', ['products' => $productIds]); + } + + /** + * @param MassActionInterface $data + * @param $attributesData + * @param $websiteRemoveData + * @param $websiteAddData + */ + private function reindex(MassActionInterface $data, $attributesData, $websiteRemoveData, $websiteAddData): void + { + $this->_productFlatIndexerProcessor->reindexList($data->getProductIds()); + + if ($this->_catalogProduct->isDataForPriceIndexerWasChanged($attributesData) + || !empty($websiteRemoveData) + || !empty($websiteAddData) + ) { + $this->_productPriceIndexerProcessor->reindexList($data->getProductIds()); + } + } +} \ No newline at end of file diff --git a/app/code/Magento/Catalog/Model/MassAction.php b/app/code/Magento/Catalog/Model/MassAction.php new file mode 100644 index 0000000000000..35ed110f9c11a --- /dev/null +++ b/app/code/Magento/Catalog/Model/MassAction.php @@ -0,0 +1,174 @@ +<?php +namespace Magento\Catalog\Model; + +class MassAction implements \Magento\Catalog\Api\Data\MassActionInterface +{ + private $inventory; + private $attributes; + private $websiteRemove; + private $websiteAdd; + private $storeId; + private $productIds; + private $websiteId; + + /** + * Set data value. + * + * @param string $data + * @return void + * @since 101.1.0 + */ + public function setInventory($data) + { + $this->inventory = $data; + } + + /** + * Get data value. + * + * @return string[] + * @since 101.1.0 + */ + public function getInventory():array + { + return $this->inventory; + } + + /** + * Set data value. + * + * @param string $data + * @return void + * @since 101.1.0 + */ + public function setAttributes($data) + { + $this->attributes = $data; + } + + /** + * Get data value. + * + * @return string[] + * @since 101.1.0 + */ + public function getAttributes():array + { + return $this->attributes; + } + + /** + * Set data value. + * + * @param string $data + * @return void + * @since 101.1.0 + */ + public function setWebsiteRemove($data) + { + $this->websiteRemove = $data; + } + + /** + * Get data value. + * + * @return string[] + * @since 101.1.0 + */ + public function getWebsiteRemove():array + { + return $this->websiteRemove; + } + + /** + * Set data value. + * + * @param string $data + * @return void + * @since 101.1.0 + */ + public function setWebsiteAdd($data) + { + $this->websiteAdd = $data; + } + + /** + * Get data value. + * + * @return string[] + * @since 101.1.0 + */ + public function getWebsiteAdd():array + { + return $this->websiteAdd; + } + + /** + * Set data value. + * + * @param string $data + * @return void + * @since 101.1.0 + */ + public function setStoreId($data) + { + $this->storeId = $data; + } + + /** + * Get data value. + * + * @return string + * @since 101.1.0 + */ + public function getStoreId() + { + return $this->storeId; + } + + /** + * Set data value. + * + * @param integer[] $data + * @return void + * @since 101.1.0 + */ + public function setProductIds(array $data) + { + $this->productIds = $data; + } + + /** + * Get data value. + * + * @return integer[] + * @since 101.1.0 + */ + public function getProductIds():array + { + return $this->productIds; + } + + /** + * Set data value. + * + * @param string $data + * @return void + * @since 101.1.0 + */ + public function setWebsiteId($data) + { + $this->websiteId = $data; + } + + /** + * Get data value. + * + * @return string + * @since 101.1.0 + */ + public function getWebsiteId() + { + return $this->websiteId; + } +} diff --git a/app/code/Magento/Catalog/etc/communication.xml b/app/code/Magento/Catalog/etc/communication.xml new file mode 100644 index 0000000000000..b073725e934f0 --- /dev/null +++ b/app/code/Magento/Catalog/etc/communication.xml @@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd"> + <topic name="product_action_attribute.update" request="Magento\Catalog\Api\Data\MassActionInterface"> + <handler name="product_action_attribute.update" type="Magento\Catalog\Model\Attribute\Backend\Consumer" method="process" /> + </topic> +</config> \ No newline at end of file diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 7d2c3699ee2c2..49447447622f9 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -72,6 +72,7 @@ <preference for="Magento\Catalog\Model\Indexer\Product\Price\UpdateIndexInterface" type="Magento\Catalog\Model\Indexer\Product\Price\InvalidateIndex" /> <preference for="Magento\Catalog\Model\Product\Gallery\ImagesConfigFactoryInterface" type="Magento\Catalog\Model\Product\Gallery\ImagesConfigFactory" /> <preference for="Magento\Catalog\Model\Product\Configuration\Item\ItemResolverInterface" type="Magento\Catalog\Model\Product\Configuration\Item\ItemResolverComposite" /> + <preference for="Magento\Catalog\Api\Data\MassActionInterface" type="\Magento\Catalog\Model\MassAction" /> <type name="Magento\Customer\Model\ResourceModel\Visitor"> <plugin name="catalogLog" type="Magento\Catalog\Model\Plugin\Log" /> </type> diff --git a/app/code/Magento/Catalog/etc/queue.xml b/app/code/Magento/Catalog/etc/queue.xml new file mode 100644 index 0000000000000..8aa7c7fe5e49e --- /dev/null +++ b/app/code/Magento/Catalog/etc/queue.xml @@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/queue.xsd"> + <broker topic="product_action_attribute.update" exchange="magento-db" type="db"> + <queue name="product_action_attribute.update" consumer="product_action_attribute.update" consumerInstance="Magento\Framework\MessageQueue\Consumer" handler="Magento\Catalog\Model\Attribute\Backend\Consumer::process"/> + </broker> +</config> \ No newline at end of file diff --git a/app/code/Magento/Catalog/etc/queue_consumer.xml b/app/code/Magento/Catalog/etc/queue_consumer.xml new file mode 100644 index 0000000000000..0090866c0e490 --- /dev/null +++ b/app/code/Magento/Catalog/etc/queue_consumer.xml @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/consumer.xsd"> + <consumer name="product_action_attribute.update" queue="product_action_attribute.update" connection="db" maxMessages="5000" consumerInstance="Magento\Framework\MessageQueue\Consumer" handler="Magento\Catalog\Model\Attribute\Backend\Consumer::process" /> +</config> \ No newline at end of file diff --git a/app/code/Magento/Catalog/etc/queue_publisher.xml b/app/code/Magento/Catalog/etc/queue_publisher.xml new file mode 100644 index 0000000000000..c673a8321762a --- /dev/null +++ b/app/code/Magento/Catalog/etc/queue_publisher.xml @@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/publisher.xsd"> + <publisher topic="product_action_attribute.update"> + <connection name="db" exchange="magento-db" /> + </publisher> +</config> \ No newline at end of file diff --git a/app/code/Magento/Catalog/etc/queue_topology.xml b/app/code/Magento/Catalog/etc/queue_topology.xml new file mode 100644 index 0000000000000..0097d770936a3 --- /dev/null +++ b/app/code/Magento/Catalog/etc/queue_topology.xml @@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/topology.xsd"> + <exchange name="magento-db" type="topic" connection="db"> + <binding id="updateBinding" topic="product_action_attribute.update" destinationType="queue" destination="product_action_attribute.update"/> + </exchange> +</config> \ No newline at end of file diff --git a/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php b/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php index 2f3caf08c534e..dfe0e5c9f30f3 100644 --- a/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php +++ b/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php @@ -115,11 +115,11 @@ public function buildOutputDataArray($dataObject, $dataObjectType) } elseif (is_array($value)) { $valueResult = []; $arrayElementType = substr($returnType, 0, -2); - foreach ($value as $singleValue) { + foreach ($value as $singleKey => $singleValue) { if (is_object($singleValue) && !($singleValue instanceof Phrase)) { $singleValue = $this->buildOutputDataArray($singleValue, $arrayElementType); } - $valueResult[] = $this->typeCaster->castValueToType($singleValue, $arrayElementType); + $valueResult[$singleKey] = $this->typeCaster->castValueToType($singleValue, $arrayElementType); } $value = $valueResult; } else { From 12d5481f89d8f4cb835258fbc1a29244fc1f6bac Mon Sep 17 00:00:00 2001 From: duhon <duhon@rambler.ru> Date: Tue, 19 Feb 2019 15:52:32 -0600 Subject: [PATCH 061/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Product/Action/Attribute/Save.php | 106 +++---- .../Model/Attribute/Backend/Consumer.php | 119 ++++---- .../Product/Action/Attribute/SaveTest.php | 258 ------------------ .../Unit/Model/Attribute/Backend/SaveTest.php | 150 ++++++++++ .../PublisherConsumerController.php | 24 +- .../Product/Action/AttributeTest.php | 63 ++++- 6 files changed, 315 insertions(+), 405 deletions(-) delete mode 100644 app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php create mode 100644 app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/SaveTest.php diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index 69969231490b7..eb75b8f7a701d 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -6,6 +6,7 @@ */ namespace Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute; +use Magento\Catalog\Api\Data\MassActionInterface; use Magento\Catalog\Api\Data\MassActionInterfaceFactory; use Magento\CatalogInventory\Api\StockConfigurationInterface; use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; @@ -15,96 +16,48 @@ /** * Class Save - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute implements HttpPostActionInterface { - /** - * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor - */ - protected $_productFlatIndexerProcessor; - - /** - * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor - */ - protected $_productPriceIndexerProcessor; - - /** - * Catalog product - * - * @var \Magento\Catalog\Helper\Product - */ - protected $_catalogProduct; - - /** - * @var \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory - */ - protected $stockItemFactory; - - /** - * Stock Indexer - * - * @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor - */ - protected $_stockIndexerProcessor; - - /** - * @var \Magento\Framework\Api\DataObjectHelper - */ - protected $dataObjectHelper; - /** * @var PublisherInterface */ private $messagePublisher; + /** * @var MassActionInterfaceFactory|null */ private $massActionFactory; + /** + * @var StockConfigurationInterface + */ + private $stockConfiguration; /** * @param Action\Context $context * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper - * @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor - * @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor - * @param \Magento\CatalogInventory\Model\Indexer\Stock\Processor $stockIndexerProcessor - * @param \Magento\Catalog\Helper\Product $catalogProduct - * @param \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory $stockItemFactory - * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper + * @param StockConfigurationInterface|null $stockConfiguration * @param PublisherInterface|null $publisher * @param MassActionInterfaceFactory|null $massAction */ public function __construct( Action\Context $context, \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper, - \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor, - \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor, - \Magento\CatalogInventory\Model\Indexer\Stock\Processor $stockIndexerProcessor, - \Magento\Catalog\Helper\Product $catalogProduct, - \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory $stockItemFactory, - \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, + StockConfigurationInterface $stockConfiguration = null, PublisherInterface $publisher = null, MassActionInterfaceFactory $massAction = null ) { - $this->_productFlatIndexerProcessor = $productFlatIndexerProcessor; - $this->_productPriceIndexerProcessor = $productPriceIndexerProcessor; - $this->_stockIndexerProcessor = $stockIndexerProcessor; - $this->_catalogProduct = $catalogProduct; - $this->stockItemFactory = $stockItemFactory; parent::__construct($context, $attributeHelper); - $this->dataObjectHelper = $dataObjectHelper; $this->messagePublisher = $publisher ?: ObjectManager::getInstance()->get(PublisherInterface::class); $this->massActionFactory = $massAction ?: ObjectManager::getInstance()->get(MassActionInterfaceFactory::class); + $this->stockConfiguration = $stockConfiguration; } /** * Update product attributes * * @return \Magento\Backend\Model\View\Result\Redirect - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * @SuppressWarnings(PHPMD.NPathComplexity) - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function execute() { @@ -114,30 +67,27 @@ public function execute() /* Collect Data */ $inventoryData = $this->getRequest()->getParam('inventory', []); + $inventoryData = $this->addConfigSettings($inventoryData); $attributesData = $this->getRequest()->getParam('attributes', []); $websiteRemoveData = $this->getRequest()->getParam('remove_website_ids', []); $websiteAddData = $this->getRequest()->getParam('add_website_ids', []); + $storeId = $this->attributeHelper->getSelectedStoreId(); + $productIds = $this->attributeHelper->getProductIds(); + $websiteId = $this->attributeHelper->getStoreWebsiteId($storeId); - /* Prepare inventory data item options (use config settings) */ - $options = $this->_objectManager->get(StockConfigurationInterface::class)->getConfigItemOptions(); - foreach ($options as $option) { - if (isset($inventoryData[$option]) && !isset($inventoryData['use_config_' . $option])) { - $inventoryData['use_config_' . $option] = 0; - } - } - + /* Create DTO for queue */ $massAction = $this->massActionFactory->create(); $massAction->setInventory($inventoryData); $massAction->setAttributes($attributesData); $massAction->setWebsiteRemove($websiteRemoveData); $massAction->setWebsiteAdd($websiteAddData); - $massAction->setStoreId($this->attributeHelper->getSelectedStoreId()); - $massAction->setProductIds($this->attributeHelper->getProductIds()); - $massAction->setWebsiteId($this->attributeHelper->getStoreWebsiteId($massAction->getStoreId())); + $massAction->setStoreId($storeId); + $massAction->setProductIds($productIds); + $massAction->setWebsiteId($websiteId); try { $this->messagePublisher->publish('product_action_attribute.update', $massAction); - $this->messageManager->addSuccessMessage(__('Message is added to queue, wait')); + $this->messageManager->addSuccessMessage(__('Message is added to queue')); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { @@ -147,7 +97,23 @@ public function execute() ); } - return $this->resultRedirectFactory->create() - ->setPath('catalog/product/', ['store' => $massAction->getStoreId()]); + return $this->resultRedirectFactory->create()->setPath('catalog/product/', ['store' => $storeId]); + } + + /** + * Prepare inventory data item options (use config settings) + * @param $inventoryData + * @return mixed + */ + private function addConfigSettings($inventoryData) + { + $options = $this->stockConfiguration->getConfigItemOptions(); + foreach ($options as $option) { + $useConfig = 'use_config_' . $option; + if (isset($inventoryData[$option]) && !isset($inventoryData[$useConfig])) { + $inventoryData[$useConfig] = 0; + } + } + return $inventoryData; } } diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php index 029223972780a..1bba257ff9864 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php @@ -30,19 +30,19 @@ class Consumer /** * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor */ - protected $_productFlatIndexerProcessor; + protected $productFlatIndexerProcessor; /** * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor */ - protected $_productPriceIndexerProcessor; + protected $productPriceIndexerProcessor; /** * Catalog product * * @var \Magento\Catalog\Helper\Product */ - protected $_catalogProduct; + protected $catalogProduct; /** * @var \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory @@ -54,7 +54,7 @@ class Consumer * * @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor */ - protected $_stockIndexerProcessor; + protected $stockIndexerProcessor; /** * @var \Magento\Framework\Api\DataObjectHelper @@ -64,12 +64,24 @@ class Consumer /** * @var \Magento\Framework\Event\ManagerInterface */ - private $_eventManager; + private $eventManager; /** * @var ObjectManager */ - private $_objectManager; + private $objectManager; + /** + * @var \Magento\Catalog\Model\Product\Action + */ + private $productAction; + /** + * @var \Magento\CatalogInventory\Api\StockRegistryInterface + */ + private $stockRegistry; + /** + * @var \Magento\CatalogInventory\Api\StockItemRepositoryInterface + */ + private $stockItemRepository; /** * @param \Magento\Catalog\Helper\Product $catalogProduct @@ -79,6 +91,9 @@ class Consumer * @param \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory $stockItemFactory * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper * @param \Magento\Framework\Event\ManagerInterface $eventManager + * @param \Magento\Catalog\Model\Product\Action $action + * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistryFactory + * @param \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepositoryFactory * @param NotifierInterface $notifier */ public function __construct( @@ -89,35 +104,42 @@ public function __construct( \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory $stockItemFactory, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, \Magento\Framework\Event\ManagerInterface $eventManager, + \Magento\Catalog\Model\Product\Action $action, + \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistryFactory, + \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepositoryFactory, NotifierInterface $notifier ) { - $this->_catalogProduct = $catalogProduct; - $this->_productFlatIndexerProcessor = $productFlatIndexerProcessor; - $this->_productPriceIndexerProcessor = $productPriceIndexerProcessor; - $this->_stockIndexerProcessor = $stockIndexerProcessor; + $this->catalogProduct = $catalogProduct; + $this->productFlatIndexerProcessor = $productFlatIndexerProcessor; + $this->productPriceIndexerProcessor = $productPriceIndexerProcessor; + $this->stockIndexerProcessor = $stockIndexerProcessor; $this->stockItemFactory = $stockItemFactory; $this->dataObjectHelper = $dataObjectHelper; $this->notifier = $notifier; - $this->_eventManager = $eventManager; - $this->_objectManager = ObjectManager::getInstance(); + $this->eventManager = $eventManager; + $this->objectManager = ObjectManager::getInstance(); + $this->productAction = $action; + $this->stockRegistry = $stockRegistryFactory; + $this->stockItemRepository = $stockItemRepositoryFactory->create(); } public function process(MassActionInterface $data): void { try { - if ($data->getAttributes()) { - $attributesData = $this->getAttributesData($data, $data->getAttributes()); - } - if ($data->getInventory()) { - $this->saveInventory($data, $data->getInventory()); + $this->updateInventoryInProducts($data->getProductIds(), $data->getWebsiteId(), $data->getInventory()); } if ($data->getWebsiteAdd() || $data->getWebsiteRemove()) { - $this->updateWebsiteInProducts($data, $data->getWebsiteRemove(), $data->getWebsiteAdd()); + $this->updateWebsiteInProducts($data->getProductIds(), $data->getWebsiteRemove(), $data->getWebsiteAdd()); + } + + if ($data->getAttributes()) { + $attributesData = $this->getAttributesData($data->getProductIds(), $data->getStoreId(), $data->getAttributes()); + $this->reindex($data->getProductIds(), $attributesData, $data->getWebsiteRemove(), $data->getWebsiteAdd()); } - $this->reindex($data, $attributesData, $data->getWebsiteRemove(), $data->getWebsiteAdd()); + $this->productFlatIndexerProcessor->reindexList($data->getProductIds()); $this->notifier->addNotice( __('Product attributes updated'), @@ -133,17 +155,18 @@ public function process(MassActionInterface $data): void } /** - * @param MassActionInterface $data + * @param $productIds + * @param $storeId * @param $attributesData * @return mixed */ - private function getAttributesData(MassActionInterface $data, $attributesData) + private function getAttributesData($productIds, $storeId, $attributesData) { - $dateFormat = $this->_objectManager->get(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) + $dateFormat = $this->objectManager->get(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) ->getDateFormat(\IntlDateFormatter::SHORT); foreach ($attributesData as $attributeCode => $value) { - $attribute = $this->_objectManager->get(\Magento\Eav\Model\Config::class) + $attribute = $this->objectManager->get(\Magento\Eav\Model\Config::class) ->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); if (!$attribute->getAttributeId()) { unset($attributesData[$attributeCode]); @@ -174,29 +197,19 @@ private function getAttributesData(MassActionInterface $data, $attributesData) } } - $this->_objectManager->get(\Magento\Catalog\Model\Product\Action::class) - ->updateAttributes($data->getProductIds(), $attributesData, $data->getStoreId()); + $this->productAction->updateAttributes($productIds, $attributesData, $storeId); return $attributesData; } /** - * @param MassActionInterface $data + * @param $productIds + * @param $websiteId * @param $inventoryData */ - private function saveInventory(MassActionInterface $data, $inventoryData): void + private function updateInventoryInProducts($productIds, $websiteId, $inventoryData): void { - // TODO why use ObjectManager? - /** @var \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry */ - $stockRegistry = $this->_objectManager - ->create(\Magento\CatalogInventory\Api\StockRegistryInterface::class); - /** @var \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepository */ - $stockItemRepository = $this->_objectManager - ->create(\Magento\CatalogInventory\Api\StockItemRepositoryInterface::class); - foreach ($data->getProductIds() as $productId) { - $stockItemDo = $stockRegistry->getStockItem( - $productId, - $data->getWebsiteId() - ); + foreach ($productIds as $productId) { + $stockItemDo = $this->stockRegistry->getStockItem($productId, $websiteId); if (!$stockItemDo->getProductId()) { $inventoryData['product_id'] = $productId; } @@ -208,47 +221,41 @@ private function saveInventory(MassActionInterface $data, $inventoryData): void \Magento\CatalogInventory\Api\Data\StockItemInterface::class ); $stockItemDo->setItemId($stockItemId); - $stockItemRepository->save($stockItemDo); + $this->stockItemRepository->save($stockItemDo); } - $this->_stockIndexerProcessor->reindexList($data->getProductIds()); + $this->stockIndexerProcessor->reindexList($productIds); } /** - * @param MassActionInterface $data + * @param $productIds * @param $websiteRemoveData * @param $websiteAddData */ - private function updateWebsiteInProducts(MassActionInterface $data, $websiteRemoveData, $websiteAddData): void + private function updateWebsiteInProducts($productIds, $websiteRemoveData, $websiteAddData): void { - /* @var $actionModel \Magento\Catalog\Model\Product\Action */ - $actionModel = $this->_objectManager->get(\Magento\Catalog\Model\Product\Action::class); - $productIds = $data->getProductIds(); - if ($websiteRemoveData) { - $actionModel->updateWebsites($productIds, $websiteRemoveData, 'remove'); + $this->productAction->updateWebsites($productIds, $websiteRemoveData, 'remove'); } if ($websiteAddData) { - $actionModel->updateWebsites($productIds, $websiteAddData, 'add'); + $this->productAction->updateWebsites($productIds, $websiteAddData, 'add'); } - $this->_eventManager->dispatch('catalog_product_to_website_change', ['products' => $productIds]); + $this->eventManager->dispatch('catalog_product_to_website_change', ['products' => $productIds]); } /** - * @param MassActionInterface $data + * @param $productIds * @param $attributesData * @param $websiteRemoveData * @param $websiteAddData */ - private function reindex(MassActionInterface $data, $attributesData, $websiteRemoveData, $websiteAddData): void + private function reindex($productIds, $attributesData, $websiteRemoveData, $websiteAddData): void { - $this->_productFlatIndexerProcessor->reindexList($data->getProductIds()); - - if ($this->_catalogProduct->isDataForPriceIndexerWasChanged($attributesData) + if ($this->catalogProduct->isDataForPriceIndexerWasChanged($attributesData) || !empty($websiteRemoveData) || !empty($websiteAddData) ) { - $this->_productPriceIndexerProcessor->reindexList($data->getProductIds()); + $this->productPriceIndexerProcessor->reindexList($productIds); } } } \ No newline at end of file diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php deleted file mode 100644 index de44af7f58afc..0000000000000 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php +++ /dev/null @@ -1,258 +0,0 @@ -<?php -/** - * - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product\Action\Attribute; - -/** - * @SuppressWarnings(PHPMD.TooManyFields) - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class SaveTest extends \PHPUnit\Framework\TestCase -{ - /** @var \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save */ - protected $object; - - /** @var \Magento\Catalog\Helper\Product\Edit\Action\Attribute|\PHPUnit_Framework_MockObject_MockObject */ - protected $attributeHelper; - - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $dataObjectHelperMock; - - /** @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor|\PHPUnit_Framework_MockObject_MockObject */ - protected $stockIndexerProcessor; - - /** @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject */ - protected $context; - - /** @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ - protected $request; - - /** @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject */ - protected $response; - - /** @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $objectManager; - - /** @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $eventManager; - - /** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $url; - - /** @var \Magento\Framework\App\Response\RedirectInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $redirect; - - /** @var \Magento\Framework\App\ActionFlag|\PHPUnit_Framework_MockObject_MockObject */ - protected $actionFlag; - - /** @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $view; - - /** @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $messageManager; - - /** @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject */ - protected $session; - - /** @var \Magento\Framework\AuthorizationInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $authorization; - - /** @var \Magento\Backend\Model\Auth|\PHPUnit_Framework_MockObject_MockObject */ - protected $auth; - - /** @var \Magento\Backend\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */ - protected $helper; - - /** @var \Magento\Backend\Model\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $backendUrl; - - /** @var \Magento\Framework\Data\Form\FormKey\Validator|\PHPUnit_Framework_MockObject_MockObject */ - protected $formKeyValidator; - - /** @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $localeResolver; - - /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */ - protected $product; - - /** @var \Magento\CatalogInventory\Api\StockRegistryInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $stockItemService; - - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $stockItem; - - /** @var \Magento\CatalogInventory\Api\StockConfigurationInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $stockConfig; - - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $stockItemRepository; - - /** - * @var \Magento\Backend\Model\View\Result\RedirectFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $resultRedirectFactory; - - protected function setUp() - { - $this->attributeHelper = $this->createPartialMock( - \Magento\Catalog\Helper\Product\Edit\Action\Attribute::class, - ['getProductIds', 'getSelectedStoreId', 'getStoreWebsiteId'] - ); - - $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->stockIndexerProcessor = $this->createPartialMock( - \Magento\CatalogInventory\Model\Indexer\Stock\Processor::class, - ['reindexList'] - ); - - $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->resultRedirectFactory = $this->getMockBuilder(\Magento\Backend\Model\View\Result\RedirectFactory::class) - ->disableOriginalConstructor() - ->setMethods(['create']) - ->getMock(); - $this->resultRedirectFactory->expects($this->atLeastOnce()) - ->method('create') - ->willReturn($resultRedirect); - - $this->prepareContext(); - - $this->object = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( - \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save::class, - [ - 'context' => $this->context, - 'attributeHelper' => $this->attributeHelper, - 'stockIndexerProcessor' => $this->stockIndexerProcessor, - 'dataObjectHelper' => $this->dataObjectHelperMock, - ] - ); - } - - /** - * @SuppressWarnings(PHPMD.ExcessiveMethodLength) - */ - protected function prepareContext() - { - $this->stockItemRepository = $this->getMockBuilder( - \Magento\CatalogInventory\Api\StockItemRepositoryInterface::class - )->disableOriginalConstructor()->getMock(); - - $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) - ->disableOriginalConstructor()->getMock(); - $this->response = $this->createMock(\Magento\Framework\App\Response\Http::class); - $this->objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); - $this->eventManager = $this->createMock(\Magento\Framework\Event\ManagerInterface::class); - $this->url = $this->createMock(\Magento\Framework\UrlInterface::class); - $this->redirect = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class); - $this->actionFlag = $this->createMock(\Magento\Framework\App\ActionFlag::class); - $this->view = $this->createMock(\Magento\Framework\App\ViewInterface::class); - $this->messageManager = $this->createMock(\Magento\Framework\Message\ManagerInterface::class); - $this->session = $this->createMock(\Magento\Backend\Model\Session::class); - $this->authorization = $this->createMock(\Magento\Framework\AuthorizationInterface::class); - $this->auth = $this->createMock(\Magento\Backend\Model\Auth::class); - $this->helper = $this->createMock(\Magento\Backend\Helper\Data::class); - $this->backendUrl = $this->createMock(\Magento\Backend\Model\UrlInterface::class); - $this->formKeyValidator = $this->createMock(\Magento\Framework\Data\Form\FormKey\Validator::class); - $this->localeResolver = $this->createMock(\Magento\Framework\Locale\ResolverInterface::class); - - $this->context = $this->context = $this->createPartialMock(\Magento\Backend\App\Action\Context::class, [ - 'getRequest', - 'getResponse', - 'getObjectManager', - 'getEventManager', - 'getUrl', - 'getRedirect', - 'getActionFlag', - 'getView', - 'getMessageManager', - 'getSession', - 'getAuthorization', - 'getAuth', - 'getHelper', - 'getBackendUrl', - 'getFormKeyValidator', - 'getLocaleResolver', - 'getResultRedirectFactory' - ]); - $this->context->expects($this->any())->method('getRequest')->willReturn($this->request); - $this->context->expects($this->any())->method('getResponse')->willReturn($this->response); - $this->context->expects($this->any())->method('getObjectManager')->willReturn($this->objectManager); - $this->context->expects($this->any())->method('getEventManager')->willReturn($this->eventManager); - $this->context->expects($this->any())->method('getUrl')->willReturn($this->url); - $this->context->expects($this->any())->method('getRedirect')->willReturn($this->redirect); - $this->context->expects($this->any())->method('getActionFlag')->willReturn($this->actionFlag); - $this->context->expects($this->any())->method('getView')->willReturn($this->view); - $this->context->expects($this->any())->method('getMessageManager')->willReturn($this->messageManager); - $this->context->expects($this->any())->method('getSession')->willReturn($this->session); - $this->context->expects($this->any())->method('getAuthorization')->willReturn($this->authorization); - $this->context->expects($this->any())->method('getAuth')->willReturn($this->auth); - $this->context->expects($this->any())->method('getHelper')->willReturn($this->helper); - $this->context->expects($this->any())->method('getBackendUrl')->willReturn($this->backendUrl); - $this->context->expects($this->any())->method('getFormKeyValidator')->willReturn($this->formKeyValidator); - $this->context->expects($this->any())->method('getLocaleResolver')->willReturn($this->localeResolver); - $this->context->expects($this->any()) - ->method('getResultRedirectFactory') - ->willReturn($this->resultRedirectFactory); - - $this->product = $this->createPartialMock( - \Magento\Catalog\Model\Product::class, - ['isProductsHasSku', '__wakeup'] - ); - - $this->stockItemService = $this->getMockBuilder(\Magento\CatalogInventory\Api\StockRegistryInterface::class) - ->disableOriginalConstructor() - ->setMethods(['getStockItem', 'saveStockItem']) - ->getMockForAbstractClass(); - $this->stockItem = $this->getMockBuilder(\Magento\CatalogInventory\Api\Data\StockItemInterface::class) - ->setMethods(['getId', 'getProductId']) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - - $this->stockConfig = $this->getMockBuilder(\Magento\CatalogInventory\Api\StockConfigurationInterface::class) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - - $this->objectManager->expects($this->any())->method('create')->will($this->returnValueMap([ - [\Magento\Catalog\Model\Product::class, [], $this->product], - [\Magento\CatalogInventory\Api\StockRegistryInterface::class, [], $this->stockItemService], - [\Magento\CatalogInventory\Api\StockItemRepositoryInterface::class, [], $this->stockItemRepository], - ])); - - $this->objectManager->expects($this->any())->method('get')->will($this->returnValueMap([ - [\Magento\CatalogInventory\Api\StockConfigurationInterface::class, $this->stockConfig], - ])); - } - - public function testExecuteThatProductIdsAreObtainedFromAttributeHelper() - { - $this->attributeHelper->expects($this->any())->method('getProductIds')->will($this->returnValue([5])); - $this->attributeHelper->expects($this->any())->method('getSelectedStoreId')->will($this->returnValue([1])); - $this->attributeHelper->expects($this->any())->method('getStoreWebsiteId')->will($this->returnValue(1)); - $this->stockConfig->expects($this->any())->method('getConfigItemOptions')->will($this->returnValue([])); - $this->dataObjectHelperMock->expects($this->any()) - ->method('populateWithArray') - ->with($this->stockItem, $this->anything(), \Magento\CatalogInventory\Api\Data\StockItemInterface::class) - ->willReturnSelf(); - $this->product->expects($this->any())->method('isProductsHasSku')->with([5])->will($this->returnValue(true)); - $this->stockItemService->expects($this->any())->method('getStockItem')->with(5, 1) - ->will($this->returnValue($this->stockItem)); - $this->stockIndexerProcessor->expects($this->any())->method('reindexList')->with([5]); - - $this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([ - ['inventory', [], [7]], - ])); - - $this->messageManager->expects($this->never())->method('addErrorMessage'); - $this->messageManager->expects($this->never())->method('addExceptionMessage'); - - $this->object->execute(); - } -} diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/SaveTest.php new file mode 100644 index 0000000000000..26e84df443ef8 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/SaveTest.php @@ -0,0 +1,150 @@ +<?php +/** + * + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Catalog\Test\Unit\Model\Attribute\Backend\Consumer; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; + +/** + * @SuppressWarnings(PHPMD.TooManyFields) + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class ConsumerTest extends \PHPUnit\Framework\TestCase +{ + /** @var \Magento\Catalog\Model\Attribute\Backend\Consumer */ + protected $object; + + /** @var \Magento\Catalog\Helper\Product\Edit\Action\Attribute|\PHPUnit_Framework_MockObject_MockObject */ + protected $attributeHelper; + + /** @var \PHPUnit_Framework_MockObject_MockObject */ + protected $dataObjectHelperMock; + + /** @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor|\PHPUnit_Framework_MockObject_MockObject */ + protected $stockIndexerProcessor; + + /** @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject */ + protected $context; + + /** @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ + protected $request; + + /** @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject */ + protected $response; + + /** @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $objectManager; + + /** @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $eventManager; + + /** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $url; + + /** @var \Magento\Framework\App\Response\RedirectInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $redirect; + + /** @var \Magento\Framework\App\ActionFlag|\PHPUnit_Framework_MockObject_MockObject */ + protected $actionFlag; + + /** @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $view; + + /** @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $messageManager; + + /** @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject */ + protected $session; + + /** @var \Magento\Framework\AuthorizationInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $authorization; + + /** @var \Magento\Backend\Model\Auth|\PHPUnit_Framework_MockObject_MockObject */ + protected $auth; + + /** @var \Magento\Backend\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */ + protected $helper; + + /** @var \Magento\Backend\Model\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $backendUrl; + + /** @var \Magento\Framework\Data\Form\FormKey\Validator|\PHPUnit_Framework_MockObject_MockObject */ + protected $formKeyValidator; + + /** @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $localeResolver; + + /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */ + protected $product; + + /** @var \Magento\CatalogInventory\Api\StockRegistryInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $stockItemService; + + /** @var \PHPUnit_Framework_MockObject_MockObject */ + protected $stockItem; + + /** @var \Magento\CatalogInventory\Api\StockConfigurationInterface|\PHPUnit_Framework_MockObject_MockObject */ + protected $stockConfig; + + /** @var \PHPUnit_Framework_MockObject_MockObject */ + protected $stockItemRepository; + + /** + * @var \Magento\Backend\Model\View\Result\RedirectFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resultRedirectFactory; + + protected function setUp() + { + $this->attributeHelper = $this->createPartialMock( + \Magento\Catalog\Helper\Product\Edit\Action\Attribute::class, + ['getProductIds', 'getSelectedStoreId', 'getStoreWebsiteId'] + ); + + $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->stockIndexerProcessor = $this->createPartialMock( + \Magento\CatalogInventory\Model\Indexer\Stock\Processor::class, + ['reindexList'] + ); + + $this->object = (new ObjectManager($this))->getObject( + \Magento\Catalog\Model\Attribute\Backend\Consumer::class, + [ + 'stockIndexerProcessor' => $this->stockIndexerProcessor, + 'dataObjectHelper' => $this->dataObjectHelperMock, + ] + ); + } + + public function testExecuteThatProductIdsAreObtainedFromAttributeHelper() + { + $this->attributeHelper->method('getProductIds')->will($this->returnValue([5])); + $this->attributeHelper->method('getSelectedStoreId')->will($this->returnValue([1])); + $this->attributeHelper->method('getStoreWebsiteId')->will($this->returnValue(1)); + + $this->stockConfig->expects($this->any())->method('getConfigItemOptions')->will($this->returnValue([])); + $this->dataObjectHelperMock->expects($this->any()) + ->method('populateWithArray') + ->with($this->stockItem, $this->anything(), \Magento\CatalogInventory\Api\Data\StockItemInterface::class) + ->willReturnSelf(); + $this->product->expects($this->any())->method('isProductsHasSku')->with([5])->will($this->returnValue(true)); + $this->stockItemService->expects($this->any())->method('getStockItem')->with(5, 1) + ->will($this->returnValue($this->stockItem)); + $this->stockIndexerProcessor->expects($this->any())->method('reindexList')->with([5]); + + $this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([ + ['inventory', [], [7]], + ])); + + $this->messageManager->expects($this->never())->method('addErrorMessage'); + $this->messageManager->expects($this->never())->method('addExceptionMessage'); + + $this->object->process(); + } +} diff --git a/dev/tests/integration/framework/Magento/TestFramework/MessageQueue/PublisherConsumerController.php b/dev/tests/integration/framework/Magento/TestFramework/MessageQueue/PublisherConsumerController.php index 9ca351aa1cf98..7748e43bbd621 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/MessageQueue/PublisherConsumerController.php +++ b/dev/tests/integration/framework/Magento/TestFramework/MessageQueue/PublisherConsumerController.php @@ -95,17 +95,9 @@ public function initialize() $this->amqpHelper->deleteConnection($connectionName); } $this->amqpHelper->clearQueue("async.operations.all"); - foreach ($this->consumers as $consumer) { - foreach ($this->getConsumerProcessIds($consumer) as $consumerProcessId) { - exec("kill {$consumerProcessId}"); - } - } - foreach ($this->consumers as $consumer) { - if (!$this->getConsumerProcessIds($consumer)) { - exec("{$this->getConsumerStartCommand($consumer, true)} > /dev/null &"); - } - sleep(5); - } + + $this->stopConsumers(); + $this->startConsumers(); if (file_exists($this->logFilePath)) { // try to remove before failing the test @@ -230,4 +222,14 @@ public function getPublisher() { return $this->publisher; } + + public function startConsumers(): void + { + foreach ($this->consumers as $consumer) { + if (!$this->getConsumerProcessIds($consumer)) { + exec("{$this->getConsumerStartCommand($consumer, true)} > /dev/null &"); + } + sleep(5); + } + } } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php index a2967878402d0..0fe618b2db304 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php @@ -5,13 +5,49 @@ */ namespace Magento\Catalog\Controller\Adminhtml\Product\Action; +use Magento\Catalog\Model\Product\Visibility; +use Magento\Catalog\Model\ProductRepository; use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\MessageQueue\PublisherConsumerController; /** * @magentoAppArea adminhtml */ class AttributeTest extends \Magento\TestFramework\TestCase\AbstractBackendController { + /** @var PublisherConsumerController */ + private $publisherConsumerController; + private $consumers = ['product_action_attribute.update']; + + protected function setUp() + { + $this->publisherConsumerController = Bootstrap::getObjectManager()->create(PublisherConsumerController::class, [ + 'consumers' => $this->consumers, + 'logFilePath' => TESTS_TEMP_DIR . "/MessageQueueTestLog.txt", + 'maxMessages' => null, + 'appInitParams' => Bootstrap::getInstance()->getAppInitParams() + ]); + + try { + $this->publisherConsumerController->startConsumers(); + } catch (\Magento\TestFramework\MessageQueue\EnvironmentPreconditionException $e) { + $this->markTestSkipped($e->getMessage()); + } catch (\Magento\TestFramework\MessageQueue\PreconditionFailedException $e) { + $this->fail( + $e->getMessage() + ); + } + + parent::setUp(); + } + + protected function tearDown() + { + $this->publisherConsumerController->stopConsumers(); + parent::tearDown(); + } + /** * @covers \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save::execute * @@ -20,7 +56,7 @@ class AttributeTest extends \Magento\TestFramework\TestCase\AbstractBackendContr */ public function testSaveActionRedirectsSuccessfully() { - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $objectManager = Bootstrap::getObjectManager(); /** @var $session \Magento\Backend\Model\Session */ $session = $objectManager->get(\Magento\Backend\Model\Session::class); @@ -59,13 +95,14 @@ public function testSaveActionRedirectsSuccessfully() */ public function testSaveActionChangeVisibility($attributes) { - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $repository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Catalog\Model\ProductRepository::class + $objectManager = Bootstrap::getObjectManager(); + /** @var ProductRepository $repository */ + $repository = Bootstrap::getObjectManager()->create( + ProductRepository::class ); $product = $repository->get('simple'); $product->setOrigData(); - $product->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_NOT_VISIBLE); + $product->setVisibility(Visibility::VISIBILITY_NOT_VISIBLE); $product->save(); /** @var $session \Magento\Backend\Model\Session */ @@ -75,15 +112,21 @@ public function testSaveActionChangeVisibility($attributes) $this->getRequest()->setMethod(HttpRequest::METHOD_POST); $this->dispatch('backend/catalog/product_action_attribute/save/store/0'); + /** @var \Magento\Catalog\Model\Category $category */ - $categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + $categoryFactory = Bootstrap::getObjectManager()->get( \Magento\Catalog\Model\CategoryFactory::class ); /** @var \Magento\Catalog\Block\Product\ListProduct $listProduct */ - $listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( + $listProduct = Bootstrap::getObjectManager()->get( \Magento\Catalog\Block\Product\ListProduct::class ); + $this->publisherConsumerController->waitForAsynchronousResult(function() use($repository) { + return $repository->get('simple', false, null, true)->getVisibility() != Visibility::VISIBILITY_NOT_VISIBLE; + sleep(3); + }, []); + $category = $categoryFactory->create()->load(2); $layer = $listProduct->getLayer(); $layer->setCurrentCategory($category); @@ -105,7 +148,7 @@ public function testSaveActionChangeVisibility($attributes) */ public function testValidateActionWithMassUpdate($attributes) { - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $objectManager = Bootstrap::getObjectManager(); /** @var $session \Magento\Backend\Model\Session */ $session = $objectManager->get(\Magento\Backend\Model\Session::class); @@ -156,8 +199,8 @@ public function validateActionDataProvider() public function saveActionVisibilityAttrDataProvider() { return [ - ['arguments' => ['visibility' => \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH]], - ['arguments' => ['visibility' => \Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG]] + ['arguments' => ['visibility' => Visibility::VISIBILITY_BOTH]], + ['arguments' => ['visibility' => Visibility::VISIBILITY_IN_CATALOG]] ]; } } From 60b48a6d2efad7fb2999856e3f8fa41ef01a0fff Mon Sep 17 00:00:00 2001 From: duhon <duhon@rambler.ru> Date: Tue, 19 Feb 2019 17:27:04 -0600 Subject: [PATCH 062/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Model/Attribute/Backend/Consumer.php | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php index 1bba257ff9864..f9b8b44b14281 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php @@ -8,9 +8,11 @@ namespace Magento\Catalog\Model\Attribute\Backend; use Magento\Catalog\Api\Data\MassActionInterface; +use Magento\CatalogInventory\Api\Data\StockItemInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Notification\NotifierInterface; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; /** * Consumer for export message. @@ -70,16 +72,19 @@ class Consumer * @var ObjectManager */ private $objectManager; + /** * @var \Magento\Catalog\Model\Product\Action */ private $productAction; + /** - * @var \Magento\CatalogInventory\Api\StockRegistryInterface + * @var \Magento\CatalogInventory\Api\StockRegistryInterfaceFactory */ private $stockRegistry; + /** - * @var \Magento\CatalogInventory\Api\StockItemRepositoryInterface + * @var \Magento\CatalogInventory\Api\StockItemRepositoryInterfaceFactory */ private $stockItemRepository; @@ -92,8 +97,8 @@ class Consumer * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Catalog\Model\Product\Action $action - * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistryFactory - * @param \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepositoryFactory + * @param \Magento\CatalogInventory\Api\StockRegistryInterfaceFactory $stockRegistryFactory + * @param \Magento\CatalogInventory\Api\StockItemRepositoryInterfaceFactory $stockItemRepositoryFactory * @param NotifierInterface $notifier */ public function __construct( @@ -105,8 +110,8 @@ public function __construct( \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Catalog\Model\Product\Action $action, - \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistryFactory, - \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepositoryFactory, + \Magento\CatalogInventory\Api\StockRegistryInterfaceFactory $stockRegistryFactory, + \Magento\CatalogInventory\Api\StockItemRepositoryInterfaceFactory $stockItemRepositoryFactory, NotifierInterface $notifier ) { $this->catalogProduct = $catalogProduct; @@ -119,7 +124,7 @@ public function __construct( $this->eventManager = $eventManager; $this->objectManager = ObjectManager::getInstance(); $this->productAction = $action; - $this->stockRegistry = $stockRegistryFactory; + $this->stockRegistry = $stockRegistryFactory->create(); $this->stockItemRepository = $stockItemRepositoryFactory->create(); } @@ -162,12 +167,11 @@ public function process(MassActionInterface $data): void */ private function getAttributesData($productIds, $storeId, $attributesData) { - $dateFormat = $this->objectManager->get(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class) - ->getDateFormat(\IntlDateFormatter::SHORT); + $dateFormat = $this->objectManager->get(TimezoneInterface::class)->getDateFormat(\IntlDateFormatter::SHORT); + $config = $this->objectManager->get(\Magento\Eav\Model\Config::class); foreach ($attributesData as $attributeCode => $value) { - $attribute = $this->objectManager->get(\Magento\Eav\Model\Config::class) - ->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); + $attribute = $config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); if (!$attribute->getAttributeId()) { unset($attributesData[$attributeCode]); continue; @@ -215,11 +219,7 @@ private function updateInventoryInProducts($productIds, $websiteId, $inventoryDa } $stockItemId = $stockItemDo->getId(); - $this->dataObjectHelper->populateWithArray( - $stockItemDo, - $inventoryData, - \Magento\CatalogInventory\Api\Data\StockItemInterface::class - ); + $this->dataObjectHelper->populateWithArray($stockItemDo, $inventoryData, StockItemInterface::class); $stockItemDo->setItemId($stockItemId); $this->stockItemRepository->save($stockItemDo); } From e0415bf6d4c37e7599712525735132bca144e1ee Mon Sep 17 00:00:00 2001 From: duhon <duhon@rambler.ru> Date: Wed, 20 Feb 2019 08:22:59 -0600 Subject: [PATCH 063/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Magento/Framework/Reflection/DataObjectProcessor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php b/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php index dfe0e5c9f30f3..2f3caf08c534e 100644 --- a/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php +++ b/lib/internal/Magento/Framework/Reflection/DataObjectProcessor.php @@ -115,11 +115,11 @@ public function buildOutputDataArray($dataObject, $dataObjectType) } elseif (is_array($value)) { $valueResult = []; $arrayElementType = substr($returnType, 0, -2); - foreach ($value as $singleKey => $singleValue) { + foreach ($value as $singleValue) { if (is_object($singleValue) && !($singleValue instanceof Phrase)) { $singleValue = $this->buildOutputDataArray($singleValue, $arrayElementType); } - $valueResult[$singleKey] = $this->typeCaster->castValueToType($singleValue, $arrayElementType); + $valueResult[] = $this->typeCaster->castValueToType($singleValue, $arrayElementType); } $value = $valueResult; } else { From feb01364e746919f4bd0121f330c231b0b560d6d Mon Sep 17 00:00:00 2001 From: duhon <duhon@rambler.ru> Date: Wed, 20 Feb 2019 11:12:50 -0600 Subject: [PATCH 064/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Unit/Model/Attribute/Backend/SaveTest.php | 150 ------------------ 1 file changed, 150 deletions(-) delete mode 100644 app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/SaveTest.php diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/SaveTest.php deleted file mode 100644 index 26e84df443ef8..0000000000000 --- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/SaveTest.php +++ /dev/null @@ -1,150 +0,0 @@ -<?php -/** - * - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Catalog\Test\Unit\Model\Attribute\Backend\Consumer; - -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; - -/** - * @SuppressWarnings(PHPMD.TooManyFields) - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ -class ConsumerTest extends \PHPUnit\Framework\TestCase -{ - /** @var \Magento\Catalog\Model\Attribute\Backend\Consumer */ - protected $object; - - /** @var \Magento\Catalog\Helper\Product\Edit\Action\Attribute|\PHPUnit_Framework_MockObject_MockObject */ - protected $attributeHelper; - - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $dataObjectHelperMock; - - /** @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor|\PHPUnit_Framework_MockObject_MockObject */ - protected $stockIndexerProcessor; - - /** @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject */ - protected $context; - - /** @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */ - protected $request; - - /** @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject */ - protected $response; - - /** @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $objectManager; - - /** @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $eventManager; - - /** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $url; - - /** @var \Magento\Framework\App\Response\RedirectInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $redirect; - - /** @var \Magento\Framework\App\ActionFlag|\PHPUnit_Framework_MockObject_MockObject */ - protected $actionFlag; - - /** @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $view; - - /** @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $messageManager; - - /** @var \Magento\Backend\Model\Session|\PHPUnit_Framework_MockObject_MockObject */ - protected $session; - - /** @var \Magento\Framework\AuthorizationInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $authorization; - - /** @var \Magento\Backend\Model\Auth|\PHPUnit_Framework_MockObject_MockObject */ - protected $auth; - - /** @var \Magento\Backend\Helper\Data|\PHPUnit_Framework_MockObject_MockObject */ - protected $helper; - - /** @var \Magento\Backend\Model\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $backendUrl; - - /** @var \Magento\Framework\Data\Form\FormKey\Validator|\PHPUnit_Framework_MockObject_MockObject */ - protected $formKeyValidator; - - /** @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $localeResolver; - - /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */ - protected $product; - - /** @var \Magento\CatalogInventory\Api\StockRegistryInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $stockItemService; - - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $stockItem; - - /** @var \Magento\CatalogInventory\Api\StockConfigurationInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $stockConfig; - - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $stockItemRepository; - - /** - * @var \Magento\Backend\Model\View\Result\RedirectFactory|\PHPUnit_Framework_MockObject_MockObject - */ - protected $resultRedirectFactory; - - protected function setUp() - { - $this->attributeHelper = $this->createPartialMock( - \Magento\Catalog\Helper\Product\Edit\Action\Attribute::class, - ['getProductIds', 'getSelectedStoreId', 'getStoreWebsiteId'] - ); - - $this->dataObjectHelperMock = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->stockIndexerProcessor = $this->createPartialMock( - \Magento\CatalogInventory\Model\Indexer\Stock\Processor::class, - ['reindexList'] - ); - - $this->object = (new ObjectManager($this))->getObject( - \Magento\Catalog\Model\Attribute\Backend\Consumer::class, - [ - 'stockIndexerProcessor' => $this->stockIndexerProcessor, - 'dataObjectHelper' => $this->dataObjectHelperMock, - ] - ); - } - - public function testExecuteThatProductIdsAreObtainedFromAttributeHelper() - { - $this->attributeHelper->method('getProductIds')->will($this->returnValue([5])); - $this->attributeHelper->method('getSelectedStoreId')->will($this->returnValue([1])); - $this->attributeHelper->method('getStoreWebsiteId')->will($this->returnValue(1)); - - $this->stockConfig->expects($this->any())->method('getConfigItemOptions')->will($this->returnValue([])); - $this->dataObjectHelperMock->expects($this->any()) - ->method('populateWithArray') - ->with($this->stockItem, $this->anything(), \Magento\CatalogInventory\Api\Data\StockItemInterface::class) - ->willReturnSelf(); - $this->product->expects($this->any())->method('isProductsHasSku')->with([5])->will($this->returnValue(true)); - $this->stockItemService->expects($this->any())->method('getStockItem')->with(5, 1) - ->will($this->returnValue($this->stockItem)); - $this->stockIndexerProcessor->expects($this->any())->method('reindexList')->with([5]); - - $this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([ - ['inventory', [], [7]], - ])); - - $this->messageManager->expects($this->never())->method('addErrorMessage'); - $this->messageManager->expects($this->never())->method('addExceptionMessage'); - - $this->object->process(); - } -} From 0e88105706c797560f66da4af8c4d5bfc547ff62 Mon Sep 17 00:00:00 2001 From: duhon <duhon@rambler.ru> Date: Wed, 20 Feb 2019 17:15:17 -0600 Subject: [PATCH 065/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Catalog/Api/Data/MassActionInterface.php | 21 ++++++++++-- .../Product/Action/Attribute/Save.php | 9 ++--- .../Model/Attribute/Backend/Consumer.php | 33 +++++++++--------- app/code/Magento/Catalog/Model/MassAction.php | 34 ++++++++++++++++--- 4 files changed, 69 insertions(+), 28 deletions(-) diff --git a/app/code/Magento/Catalog/Api/Data/MassActionInterface.php b/app/code/Magento/Catalog/Api/Data/MassActionInterface.php index 3f47242e3aa61..c03a73df5e92d 100644 --- a/app/code/Magento/Catalog/Api/Data/MassActionInterface.php +++ b/app/code/Magento/Catalog/Api/Data/MassActionInterface.php @@ -38,7 +38,7 @@ public function getInventory():array; * @return void * @since 101.1.0 */ - public function setAttributes($data); + public function setAttributeKeys($data); /** * Get data value. @@ -46,7 +46,24 @@ public function setAttributes($data); * @return string[] * @since 101.1.0 */ - public function getAttributes():array; + public function getAttributeKeys():array; + + /** + * Set data value. + * + * @param string[] $data + * @return void + * @since 101.1.0 + */ + public function setAttributeValues($data); + + /** + * Get data value. + * + * @return string[] + * @since 101.1.0 + */ + public function getAttributeValues():array; /** * Set data value. diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index eb75b8f7a701d..331b3ed07831f 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -6,10 +6,9 @@ */ namespace Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute; -use Magento\Catalog\Api\Data\MassActionInterface; use Magento\Catalog\Api\Data\MassActionInterfaceFactory; use Magento\CatalogInventory\Api\StockConfigurationInterface; -use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; +use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Backend\App\Action; use Magento\Framework\MessageQueue\PublisherInterface; use Magento\Framework\App\ObjectManager; @@ -51,7 +50,8 @@ public function __construct( parent::__construct($context, $attributeHelper); $this->messagePublisher = $publisher ?: ObjectManager::getInstance()->get(PublisherInterface::class); $this->massActionFactory = $massAction ?: ObjectManager::getInstance()->get(MassActionInterfaceFactory::class); - $this->stockConfiguration = $stockConfiguration; + $this->stockConfiguration = $stockConfiguration + ?: ObjectManager::getInstance()->get(StockConfigurationInterface::class); } /** @@ -78,7 +78,8 @@ public function execute() /* Create DTO for queue */ $massAction = $this->massActionFactory->create(); $massAction->setInventory($inventoryData); - $massAction->setAttributes($attributesData); + $massAction->setAttributeValues(array_values($attributesData)); + $massAction->setAttributeKeys(array_keys($attributesData)); $massAction->setWebsiteRemove($websiteRemoveData); $massAction->setWebsiteAdd($websiteAddData); $massAction->setStoreId($storeId); diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php index f9b8b44b14281..f340cb49ee099 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php @@ -32,36 +32,31 @@ class Consumer /** * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor */ - protected $productFlatIndexerProcessor; + private $productFlatIndexerProcessor; /** * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor */ - protected $productPriceIndexerProcessor; + private $productPriceIndexerProcessor; /** * Catalog product * * @var \Magento\Catalog\Helper\Product */ - protected $catalogProduct; - - /** - * @var \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory - */ - protected $stockItemFactory; + private $catalogProduct; /** * Stock Indexer * * @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor */ - protected $stockIndexerProcessor; + private $stockIndexerProcessor; /** * @var \Magento\Framework\Api\DataObjectHelper */ - protected $dataObjectHelper; + private $dataObjectHelper; /** * @var \Magento\Framework\Event\ManagerInterface @@ -93,7 +88,6 @@ class Consumer * @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor * @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor * @param \Magento\CatalogInventory\Model\Indexer\Stock\Processor $stockIndexerProcessor - * @param \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory $stockItemFactory * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Catalog\Model\Product\Action $action @@ -106,7 +100,6 @@ public function __construct( \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor, \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor, \Magento\CatalogInventory\Model\Indexer\Stock\Processor $stockIndexerProcessor, - \Magento\CatalogInventory\Api\Data\StockItemInterfaceFactory $stockItemFactory, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Catalog\Model\Product\Action $action, @@ -118,7 +111,6 @@ public function __construct( $this->productFlatIndexerProcessor = $productFlatIndexerProcessor; $this->productPriceIndexerProcessor = $productPriceIndexerProcessor; $this->stockIndexerProcessor = $stockIndexerProcessor; - $this->stockItemFactory = $stockItemFactory; $this->dataObjectHelper = $dataObjectHelper; $this->notifier = $notifier; $this->eventManager = $eventManager; @@ -139,8 +131,13 @@ public function process(MassActionInterface $data): void $this->updateWebsiteInProducts($data->getProductIds(), $data->getWebsiteRemove(), $data->getWebsiteAdd()); } - if ($data->getAttributes()) { - $attributesData = $this->getAttributesData($data->getProductIds(), $data->getStoreId(), $data->getAttributes()); + if ($data->getAttributeValues()) { + $attributesData = $this->getAttributesData( + $data->getProductIds(), + $data->getStoreId(), + $data->getAttributeValues(), + $data->getAttributeKeys() + ); $this->reindex($data->getProductIds(), $attributesData, $data->getWebsiteRemove(), $data->getWebsiteAdd()); } @@ -162,11 +159,13 @@ public function process(MassActionInterface $data): void /** * @param $productIds * @param $storeId - * @param $attributesData + * @param $attributeValuesData + * @param $attributeKeysData * @return mixed */ - private function getAttributesData($productIds, $storeId, $attributesData) + private function getAttributesData($productIds, $storeId, $attributeValuesData, $attributeKeysData) { + $attributesData = array_combine($attributeKeysData, $attributeValuesData); $dateFormat = $this->objectManager->get(TimezoneInterface::class)->getDateFormat(\IntlDateFormatter::SHORT); $config = $this->objectManager->get(\Magento\Eav\Model\Config::class); diff --git a/app/code/Magento/Catalog/Model/MassAction.php b/app/code/Magento/Catalog/Model/MassAction.php index 35ed110f9c11a..0f09ff8d7699c 100644 --- a/app/code/Magento/Catalog/Model/MassAction.php +++ b/app/code/Magento/Catalog/Model/MassAction.php @@ -4,12 +4,13 @@ class MassAction implements \Magento\Catalog\Api\Data\MassActionInterface { private $inventory; - private $attributes; + private $attributeKeys; private $websiteRemove; private $websiteAdd; private $storeId; private $productIds; private $websiteId; + private $attributeValues; /** * Set data value. @@ -41,9 +42,9 @@ public function getInventory():array * @return void * @since 101.1.0 */ - public function setAttributes($data) + public function setAttributeKeys($data) { - $this->attributes = $data; + $this->attributeKeys = $data; } /** @@ -52,9 +53,32 @@ public function setAttributes($data) * @return string[] * @since 101.1.0 */ - public function getAttributes():array + public function getAttributeKeys():array { - return $this->attributes; + return $this->attributeKeys; + } + + /** + * Set data value. + * + * @param string $data + * @return void + * @since 101.1.0 + */ + public function setAttributeValues($data) + { + $this->attributeValues = $data; + } + + /** + * Get data value. + * + * @return string[] + * @since 101.1.0 + */ + public function getAttributeValues():array + { + return $this->attributeValues; } /** From aa7ba8e74dbcce18cf0e8ee5eda0daff2e6754a6 Mon Sep 17 00:00:00 2001 From: duhon <duhon@rambler.ru> Date: Thu, 21 Feb 2019 12:48:17 -0600 Subject: [PATCH 066/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Catalog/Test/Mftf/Test/AdminMassProductPriceUpdateTest.xml | 2 +- .../Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml | 2 +- .../Test/AdminMassUpdateProductAttributesStoreViewScopeTest.xml | 2 +- .../Test/Mftf/Test/AdminUrlForProductRewrittenCorrectlyTest.xml | 2 +- .../Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassProductPriceUpdateTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassProductPriceUpdateTest.xml index d7607b4b269e8..1e31a9cf0eb23 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassProductPriceUpdateTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassProductPriceUpdateTest.xml @@ -54,7 +54,7 @@ <fillField stepKey="fillPrice" selector="{{AdminEditProductAttributesSection.AttributePrice}}" userInput="90.99"/> <click stepKey="clickOnSaveButton" selector="{{AdminEditProductAttributesSection.Save}}"/> <waitForPageLoad stepKey="waitForUpdatedProductToSave" /> - <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="A total of 2 record(s) were updated." stepKey="seeAttributeUpateSuccessMsg"/> + <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="Message is added to queue" stepKey="seeAttributeUpateSuccessMsg"/> <!--Verify product name, sku and updated price--> <click stepKey="openFirstProduct" selector="{{AdminProductGridSection.productRowBySku($$simpleProduct1.sku$$)}}"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml index c0eebd1512d6d..9961de9ce0171 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml @@ -58,7 +58,7 @@ <click selector="{{AdminEditProductAttributesSection.ChangeAttributePriceToggle}}" stepKey="toggleToChangePrice"/> <fillField selector="{{AdminEditProductAttributesSection.AttributePrice}}" userInput="$$createProductOne.price$$0" stepKey="fillAttributeNameField"/> <click selector="{{AdminEditProductAttributesSection.Save}}" stepKey="save"/> - <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="A total of 2 record(s) were updated." stepKey="seeAttributeUpateSuccessMsg"/> + <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="Message is added to queue" stepKey="seeAttributeUpateSuccessMsg"/> <!-- Assert on storefront default view --> <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroupDefault"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesStoreViewScopeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesStoreViewScopeTest.xml index 845c47c0e4c20..305e0966a1f4f 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesStoreViewScopeTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesStoreViewScopeTest.xml @@ -52,7 +52,7 @@ <click selector="{{AdminEditProductAttributesSection.ChangeAttributeDescriptionToggle}}" stepKey="toggleToChangeDescription"/> <fillField selector="{{AdminEditProductAttributesSection.AttributeDescription}}" userInput="Updated $$createProductOne.custom_attributes[description]$$" stepKey="fillAttributeDescriptionField"/> <click selector="{{AdminEditProductAttributesSection.Save}}" stepKey="save"/> - <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="A total of 2 record(s) were updated." stepKey="seeAttributeUpateSuccessMsg"/> + <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="Message is added to queue" stepKey="seeAttributeUpateSuccessMsg"/> <!-- Assert on storefront default view --> <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroupDefault"/> diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminUrlForProductRewrittenCorrectlyTest.xml b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminUrlForProductRewrittenCorrectlyTest.xml index 593df1c5bc6e1..28285449d7e0d 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminUrlForProductRewrittenCorrectlyTest.xml +++ b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminUrlForProductRewrittenCorrectlyTest.xml @@ -67,7 +67,7 @@ <waitForAjaxLoad stepKey="waitForLoadWebSiteTab"/> <click selector="{{AdminUpdateAttributesWebsiteSection.addProductToWebsite}}" stepKey="checkAddProductToWebsiteCheckbox"/> <click selector="{{AdminUpdateAttributesSection.saveButton}}" stepKey="clickSave"/> - <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="A total of 1 record(s) were updated." stepKey="seeSaveSuccess"/> + <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="Message is added to queue." stepKey="seeSaveSuccess"/> <!--Got to Store front product page and check url--> <amOnPage url="{{StorefrontProductPage.url($$createProduct.sku$$-new)}}" stepKey="navigateToSimpleProductPage"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml index af12f49bf86ea..2137e4d1fe3dd 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml @@ -57,7 +57,7 @@ <click selector="{{AdminUpdateAttributesSection.toggleDescription}}" stepKey="clickToggleDescription"/> <fillField selector="{{AdminUpdateAttributesSection.description}}" userInput="MFTF automation!" stepKey="fillDescription"/> <click selector="{{AdminUpdateAttributesSection.saveButton}}" stepKey="clickSave"/> - <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="A total of 3 record(s) were updated." stepKey="seeSaveSuccess"/> + <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="Message is added to queue" stepKey="seeSaveSuccess"/> <!-- Check storefront for description --> <amOnPage url="$$createProduct1.sku$$.html" stepKey="gotoProduct1"/> From a3af5e908b7b100969f639bf9356181b32f8c934 Mon Sep 17 00:00:00 2001 From: duhon <duhon@rambler.ru> Date: Fri, 22 Feb 2019 13:19:47 -0600 Subject: [PATCH 067/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Test/Mftf/Test/AdminMassProductPriceUpdateTest.xml | 6 ++++++ .../AdminMassUpdateProductAttributesGlobalScopeTest.xml | 6 ++++++ ...AdminMassUpdateProductAttributesStoreViewScopeTest.xml | 6 ++++++ .../Test/AdminUrlForProductRewrittenCorrectlyTest.xml | 8 +++++++- .../Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml | 6 ++++++ 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassProductPriceUpdateTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassProductPriceUpdateTest.xml index 1e31a9cf0eb23..4d581bae700d7 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassProductPriceUpdateTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassProductPriceUpdateTest.xml @@ -56,6 +56,12 @@ <waitForPageLoad stepKey="waitForUpdatedProductToSave" /> <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="Message is added to queue" stepKey="seeAttributeUpateSuccessMsg"/> + <!-- Run cron twice --> + <magentoCLI command="cron:run" stepKey="runCron1"/> + <magentoCLI command="cron:run" stepKey="runCron2"/> + <reloadPage stepKey="refreshPage"/> + <waitForPageLoad stepKey="waitFormToReload1"/> + <!--Verify product name, sku and updated price--> <click stepKey="openFirstProduct" selector="{{AdminProductGridSection.productRowBySku($$simpleProduct1.sku$$)}}"/> <waitForPageLoad stepKey="waitForFirstProductToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml index 9961de9ce0171..8a44c8093ca5e 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml @@ -60,6 +60,12 @@ <click selector="{{AdminEditProductAttributesSection.Save}}" stepKey="save"/> <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="Message is added to queue" stepKey="seeAttributeUpateSuccessMsg"/> + <!-- Run cron twice --> + <magentoCLI command="cron:run" stepKey="runCron1"/> + <magentoCLI command="cron:run" stepKey="runCron2"/> + <reloadPage stepKey="refreshPage"/> + <waitForPageLoad stepKey="waitFormToReload1"/> + <!-- Assert on storefront default view --> <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroupDefault"/> <actionGroup ref="StorefrontAdvancedCatalogSearchByProductNameAndPriceActionGroup" stepKey="searchByNameDefault"> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesStoreViewScopeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesStoreViewScopeTest.xml index 305e0966a1f4f..bee13bec370da 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesStoreViewScopeTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesStoreViewScopeTest.xml @@ -54,6 +54,12 @@ <click selector="{{AdminEditProductAttributesSection.Save}}" stepKey="save"/> <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="Message is added to queue" stepKey="seeAttributeUpateSuccessMsg"/> + <!-- Run cron twice --> + <magentoCLI command="cron:run" stepKey="runCron1"/> + <magentoCLI command="cron:run" stepKey="runCron2"/> + <reloadPage stepKey="refreshPage"/> + <waitForPageLoad stepKey="waitFormToReload1"/> + <!-- Assert on storefront default view --> <actionGroup ref="GoToStoreViewAdvancedCatalogSearchActionGroup" stepKey="GoToStoreViewAdvancedCatalogSearchActionGroupDefault"/> <actionGroup ref="StorefrontAdvancedCatalogSearchByProductNameAndDescriptionActionGroup" stepKey="searchByNameDefault"> diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminUrlForProductRewrittenCorrectlyTest.xml b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminUrlForProductRewrittenCorrectlyTest.xml index 28285449d7e0d..30a4290d882fb 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminUrlForProductRewrittenCorrectlyTest.xml +++ b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminUrlForProductRewrittenCorrectlyTest.xml @@ -67,7 +67,13 @@ <waitForAjaxLoad stepKey="waitForLoadWebSiteTab"/> <click selector="{{AdminUpdateAttributesWebsiteSection.addProductToWebsite}}" stepKey="checkAddProductToWebsiteCheckbox"/> <click selector="{{AdminUpdateAttributesSection.saveButton}}" stepKey="clickSave"/> - <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="Message is added to queue." stepKey="seeSaveSuccess"/> + <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="Message is added to queue" stepKey="seeSaveSuccess"/> + + <!-- Run cron twice --> + <magentoCLI command="cron:run" stepKey="runCron1"/> + <magentoCLI command="cron:run" stepKey="runCron2"/> + <reloadPage stepKey="refreshPage"/> + <waitForPageLoad stepKey="waitFormToReload1"/> <!--Got to Store front product page and check url--> <amOnPage url="{{StorefrontProductPage.url($$createProduct.sku$$-new)}}" stepKey="navigateToSimpleProductPage"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml index 2137e4d1fe3dd..39aa516077c56 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml @@ -59,6 +59,12 @@ <click selector="{{AdminUpdateAttributesSection.saveButton}}" stepKey="clickSave"/> <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="Message is added to queue" stepKey="seeSaveSuccess"/> + <!-- Run cron twice --> + <magentoCLI command="cron:run" stepKey="runCron1"/> + <magentoCLI command="cron:run" stepKey="runCron2"/> + <reloadPage stepKey="refreshPage"/> + <waitForPageLoad stepKey="waitFormToReload1"/> + <!-- Check storefront for description --> <amOnPage url="$$createProduct1.sku$$.html" stepKey="gotoProduct1"/> <waitForPageLoad stepKey="wait3"/> From f07763abe228f55b61275adaaad518f6fb77f923 Mon Sep 17 00:00:00 2001 From: duhon <duhon@rambler.ru> Date: Wed, 27 Feb 2019 23:57:02 -0600 Subject: [PATCH 068/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Magento/Catalog/Model/Attribute/Backend/Consumer.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php index f340cb49ee099..3bcc91315022b 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php @@ -13,6 +13,7 @@ use Magento\Framework\Notification\NotifierInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\Stdlib\DateTime\TimezoneInterface; +use Psr\Log\LoggerInterface; /** * Consumer for export message. @@ -25,7 +26,7 @@ class Consumer private $notifier; /** - * @var \Psr\Log\LoggerInterface + * @var LoggerInterface */ private $logger; @@ -94,6 +95,7 @@ class Consumer * @param \Magento\CatalogInventory\Api\StockRegistryInterfaceFactory $stockRegistryFactory * @param \Magento\CatalogInventory\Api\StockItemRepositoryInterfaceFactory $stockItemRepositoryFactory * @param NotifierInterface $notifier + * @param LoggerInterface $logger */ public function __construct( \Magento\Catalog\Helper\Product $catalogProduct, @@ -105,7 +107,8 @@ public function __construct( \Magento\Catalog\Model\Product\Action $action, \Magento\CatalogInventory\Api\StockRegistryInterfaceFactory $stockRegistryFactory, \Magento\CatalogInventory\Api\StockItemRepositoryInterfaceFactory $stockItemRepositoryFactory, - NotifierInterface $notifier + NotifierInterface $notifier, + LoggerInterface $logger ) { $this->catalogProduct = $catalogProduct; $this->productFlatIndexerProcessor = $productFlatIndexerProcessor; @@ -118,6 +121,7 @@ public function __construct( $this->productAction = $action; $this->stockRegistry = $stockRegistryFactory->create(); $this->stockItemRepository = $stockItemRepositoryFactory->create(); + $this->logger = $logger; } public function process(MassActionInterface $data): void From 7f780ff05597cc4b3e4b5ea212828a8271221b48 Mon Sep 17 00:00:00 2001 From: duhon <duhon@rambler.ru> Date: Thu, 28 Feb 2019 20:24:37 -0600 Subject: [PATCH 069/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Product/Action/Attribute/Save.php | 131 ++++++++----- .../Model/Attribute/Backend/Consumer.php | 181 +++++++++--------- .../Magento/Catalog/etc/communication.xml | 2 +- app/code/Magento/Catalog/etc/queue.xml | 2 +- .../Magento/Catalog/etc/queue_consumer.xml | 2 +- 5 files changed, 175 insertions(+), 143 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index 331b3ed07831f..e91e0ce70f8fd 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -6,12 +6,8 @@ */ namespace Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute; -use Magento\Catalog\Api\Data\MassActionInterfaceFactory; -use Magento\CatalogInventory\Api\StockConfigurationInterface; use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Backend\App\Action; -use Magento\Framework\MessageQueue\PublisherInterface; -use Magento\Framework\App\ObjectManager; /** * Class Save @@ -19,39 +15,54 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute implements HttpPostActionInterface { /** - * @var PublisherInterface + * @var \Magento\Framework\Bulk\BulkManagementInterface */ - private $messagePublisher; + private $bulkManagement; /** - * @var MassActionInterfaceFactory|null + * @var \Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory */ - private $massActionFactory; + private $operationFactory; /** - * @var StockConfigurationInterface + * @var \Magento\Framework\DataObject\IdentityGeneratorInterface */ - private $stockConfiguration; + private $identityService; + + /** + * @var \Magento\Framework\Serialize\SerializerInterface + */ + private $serializer; + + /** + * @var \Magento\Authorization\Model\UserContextInterface + */ + private $userContext; /** * @param Action\Context $context * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper - * @param StockConfigurationInterface|null $stockConfiguration - * @param PublisherInterface|null $publisher - * @param MassActionInterfaceFactory|null $massAction + * @param \Magento\Framework\Bulk\BulkManagementInterface $bulkManagement + * @param \Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory $operartionFactory + * @param \Magento\Framework\DataObject\IdentityGeneratorInterface $identityService + * @param \Magento\Framework\Serialize\SerializerInterface $serializer + * @param \Magento\Authorization\Model\UserContextInterface $userContext */ public function __construct( Action\Context $context, \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper, - StockConfigurationInterface $stockConfiguration = null, - PublisherInterface $publisher = null, - MassActionInterfaceFactory $massAction = null + \Magento\Framework\Bulk\BulkManagementInterface $bulkManagement, + \Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory $operartionFactory, + \Magento\Framework\DataObject\IdentityGeneratorInterface $identityService, + \Magento\Framework\Serialize\SerializerInterface $serializer, + \Magento\Authorization\Model\UserContextInterface $userContext ) { parent::__construct($context, $attributeHelper); - $this->messagePublisher = $publisher ?: ObjectManager::getInstance()->get(PublisherInterface::class); - $this->massActionFactory = $massAction ?: ObjectManager::getInstance()->get(MassActionInterfaceFactory::class); - $this->stockConfiguration = $stockConfiguration - ?: ObjectManager::getInstance()->get(StockConfigurationInterface::class); + $this->bulkManagement = $bulkManagement; + $this->operationFactory = $operartionFactory; + $this->identityService = $identityService; + $this->serializer = $serializer; + $this->userContext = $userContext; } /** @@ -66,28 +77,18 @@ public function execute() } /* Collect Data */ - $inventoryData = $this->getRequest()->getParam('inventory', []); - $inventoryData = $this->addConfigSettings($inventoryData); $attributesData = $this->getRequest()->getParam('attributes', []); + $websiteRemoveData = $this->getRequest()->getParam('remove_website_ids', []); $websiteAddData = $this->getRequest()->getParam('add_website_ids', []); + $storeId = $this->attributeHelper->getSelectedStoreId(); - $productIds = $this->attributeHelper->getProductIds(); $websiteId = $this->attributeHelper->getStoreWebsiteId($storeId); - /* Create DTO for queue */ - $massAction = $this->massActionFactory->create(); - $massAction->setInventory($inventoryData); - $massAction->setAttributeValues(array_values($attributesData)); - $massAction->setAttributeKeys(array_keys($attributesData)); - $massAction->setWebsiteRemove($websiteRemoveData); - $massAction->setWebsiteAdd($websiteAddData); - $massAction->setStoreId($storeId); - $massAction->setProductIds($productIds); - $massAction->setWebsiteId($websiteId); + $productIds = $this->attributeHelper->getProductIds(); try { - $this->messagePublisher->publish('product_action_attribute.update', $massAction); + $this->publish('product_action_attribute.update', $attributesData, $websiteRemoveData, $websiteAddData, $storeId, $websiteId, $productIds); $this->messageManager->addSuccessMessage(__('Message is added to queue')); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); @@ -98,23 +99,63 @@ public function execute() ); } - return $this->resultRedirectFactory->create()->setPath('catalog/product/', ['store' => $storeId]); + return $this->resultRedirectFactory->create()->setPath( + 'catalog/product/', + ['store' => $storeId] + ); } /** - * Prepare inventory data item options (use config settings) - * @param $inventoryData - * @return mixed + * Schedule new bulk. + * + * @param $queue + * @param $attributesData + * @param $websiteRemoveData + * @param $websiteAddData + * @param $storeId + * @param $websiteId + * @param $productIds + * @return void */ - private function addConfigSettings($inventoryData) + private function publish($queue, $attributesData, $websiteRemoveData, $websiteAddData, $storeId, $websiteId, $productIds):void { - $options = $this->stockConfiguration->getConfigItemOptions(); - foreach ($options as $option) { - $useConfig = 'use_config_' . $option; - if (isset($inventoryData[$option]) && !isset($inventoryData[$useConfig])) { - $inventoryData[$useConfig] = 0; + $operationCount = count($productIds); + if ($operationCount > 0) { + $bulkUuid = $this->identityService->generateId(); + $bulkDescription = __('Assign custom prices to selected products'); + $operations = []; + foreach ($productIds as $productId) { + $dataToEncode = [ + 'meta_information' => 'ID:' . $productId, + 'product_id' => $productId, + 'store_id' => $storeId, + 'website_id' => $websiteId, + 'website_assign' => $websiteAddData, + 'website_detach' => $websiteRemoveData, + 'attributes' => $attributesData + ]; + $data = [ + 'data' => [ + 'bulk_uuid' => $bulkUuid, + 'topic_name' => $queue, + 'serialized_data' => $this->serializer->serialize($dataToEncode), + 'status' => \Magento\Framework\Bulk\OperationInterface::STATUS_TYPE_OPEN, + ] + ]; + + /** @var \Magento\AsynchronousOperations\Api\Data\OperationInterface $operation */ + $operation = $this->operationFactory->create($data); + $operations[] = $operation; + } + $userId = $this->userContext->getUserId(); + $result = $this->bulkManagement->scheduleBulk($bulkUuid, $operations, $bulkDescription, $userId); + if (!$result) { + throw new \Magento\Framework\Exception\LocalizedException( + __('Something went wrong while processing the request.') + ); } } - return $inventoryData; } + } + diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php index 3bcc91315022b..2e9bbc18be4da 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php @@ -7,13 +7,12 @@ namespace Magento\Catalog\Model\Attribute\Backend; -use Magento\Catalog\Api\Data\MassActionInterface; -use Magento\CatalogInventory\Api\Data\StockItemInterface; use Magento\Framework\Exception\LocalizedException; -use Magento\Framework\Notification\NotifierInterface; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Exception\TemporaryStateExceptionInterface; use Magento\Framework\Stdlib\DateTime\TimezoneInterface; -use Psr\Log\LoggerInterface; +use Magento\Framework\Bulk\OperationInterface; /** * Consumer for export message. @@ -21,12 +20,12 @@ class Consumer { /** - * @var NotifierInterface + * @var \Magento\Framework\Notification\NotifierInterface */ private $notifier; /** - * @var LoggerInterface + * @var \Psr\Log\LoggerInterface */ private $logger; @@ -41,24 +40,10 @@ class Consumer private $productPriceIndexerProcessor; /** - * Catalog product - * * @var \Magento\Catalog\Helper\Product */ private $catalogProduct; - /** - * Stock Indexer - * - * @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor - */ - private $stockIndexerProcessor; - - /** - * @var \Magento\Framework\Api\DataObjectHelper - */ - private $dataObjectHelper; - /** * @var \Magento\Framework\Event\ManagerInterface */ @@ -75,101 +60,102 @@ class Consumer private $productAction; /** - * @var \Magento\CatalogInventory\Api\StockRegistryInterfaceFactory + * @var \Magento\Framework\Serialize\SerializerInterface */ - private $stockRegistry; + private $serializer; /** - * @var \Magento\CatalogInventory\Api\StockItemRepositoryInterfaceFactory + * @var \Magento\Framework\Bulk\OperationManagementInterface */ - private $stockItemRepository; + private $operationManagement; /** * @param \Magento\Catalog\Helper\Product $catalogProduct * @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor * @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor - * @param \Magento\CatalogInventory\Model\Indexer\Stock\Processor $stockIndexerProcessor - * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper + * @param \Magento\Framework\Bulk\OperationManagementInterface $operationManagement * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Catalog\Model\Product\Action $action - * @param \Magento\CatalogInventory\Api\StockRegistryInterfaceFactory $stockRegistryFactory - * @param \Magento\CatalogInventory\Api\StockItemRepositoryInterfaceFactory $stockItemRepositoryFactory - * @param NotifierInterface $notifier - * @param LoggerInterface $logger + * @param \Magento\Framework\Notification\NotifierInterface $notifier + * @param \Psr\Log\LoggerInterface $logger + * @param \Magento\Framework\Serialize\SerializerInterface $serializer */ public function __construct( \Magento\Catalog\Helper\Product $catalogProduct, \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor, \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor, - \Magento\CatalogInventory\Model\Indexer\Stock\Processor $stockIndexerProcessor, - \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, + \Magento\Framework\Bulk\OperationManagementInterface $operationManagement, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Catalog\Model\Product\Action $action, - \Magento\CatalogInventory\Api\StockRegistryInterfaceFactory $stockRegistryFactory, - \Magento\CatalogInventory\Api\StockItemRepositoryInterfaceFactory $stockItemRepositoryFactory, - NotifierInterface $notifier, - LoggerInterface $logger + \Magento\Framework\Notification\NotifierInterface $notifier, + \Psr\Log\LoggerInterface $logger, + \Magento\Framework\Serialize\SerializerInterface $serializer ) { $this->catalogProduct = $catalogProduct; $this->productFlatIndexerProcessor = $productFlatIndexerProcessor; $this->productPriceIndexerProcessor = $productPriceIndexerProcessor; - $this->stockIndexerProcessor = $stockIndexerProcessor; - $this->dataObjectHelper = $dataObjectHelper; $this->notifier = $notifier; $this->eventManager = $eventManager; $this->objectManager = ObjectManager::getInstance(); $this->productAction = $action; - $this->stockRegistry = $stockRegistryFactory->create(); - $this->stockItemRepository = $stockItemRepositoryFactory->create(); $this->logger = $logger; + $this->serializer = $serializer; + $this->operationManagement = $operationManagement; } - public function process(MassActionInterface $data): void + /** + * Processing batch of operations for update tier prices. + * + * @param \Magento\AsynchronousOperations\Api\Data\OperationListInterface $operationList + * @return void + * @throws \InvalidArgumentException + */ + public function process(\Magento\AsynchronousOperations\Api\Data\OperationListInterface $operationList) { try { - if ($data->getInventory()) { - $this->updateInventoryInProducts($data->getProductIds(), $data->getWebsiteId(), $data->getInventory()); - } + foreach ($operationList->getItems() as $operation) { + $serializedData = $operation->getSerializedData(); + $data = $this->serializer->unserialize($serializedData); - if ($data->getWebsiteAdd() || $data->getWebsiteRemove()) { - $this->updateWebsiteInProducts($data->getProductIds(), $data->getWebsiteRemove(), $data->getWebsiteAdd()); + $this->execute($data); } - - if ($data->getAttributeValues()) { - $attributesData = $this->getAttributesData( - $data->getProductIds(), - $data->getStoreId(), - $data->getAttributeValues(), - $data->getAttributeKeys() - ); - $this->reindex($data->getProductIds(), $attributesData, $data->getWebsiteRemove(), $data->getWebsiteAdd()); - } - - $this->productFlatIndexerProcessor->reindexList($data->getProductIds()); - - $this->notifier->addNotice( - __('Product attributes updated'), - __('A total of %1 record(s) were updated.', count($data->getProductIds())) - ); - } catch (LocalizedException $exception) { - $this->notifier->addCritical( - __('Error during process occurred'), - __('Error during process occurred. Please check logs for detail') - ); - $this->logger->critical('Something went wrong while process. ' . $exception->getMessage()); + } catch (NoSuchEntityException $e) { + $this->logger->critical($e->getMessage()); + $status = ($e instanceof TemporaryStateExceptionInterface) + ? OperationInterface::STATUS_TYPE_RETRIABLY_FAILED + : OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; + $errorCode = $e->getCode(); + $message = $e->getMessage(); + } catch (LocalizedException $e) { + $this->logger->critical($e->getMessage()); + $status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; + $errorCode = $e->getCode(); + $message = $e->getMessage(); + } catch (\Exception $e) { + $this->logger->critical($e->getMessage()); + $status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; + $errorCode = $e->getCode(); + $message = __('Sorry, something went wrong during product prices update. Please see log for details.'); } + + //update operation status based on result performing operation(it was successfully executed or exception occurs + $this->operationManagement->changeOperationStatus( + $operation->getId(), + $status, + $errorCode, + $message, + $serializedData + ); } /** * @param $productIds * @param $storeId - * @param $attributeValuesData - * @param $attributeKeysData + * @param $attributesData * @return mixed */ - private function getAttributesData($productIds, $storeId, $attributeValuesData, $attributeKeysData) + private function getAttributesData($productIds, $storeId, $attributesData) { - $attributesData = array_combine($attributeKeysData, $attributeValuesData); $dateFormat = $this->objectManager->get(TimezoneInterface::class)->getDateFormat(\IntlDateFormatter::SHORT); $config = $this->objectManager->get(\Magento\Eav\Model\Config::class); @@ -208,27 +194,6 @@ private function getAttributesData($productIds, $storeId, $attributeValuesData, return $attributesData; } - /** - * @param $productIds - * @param $websiteId - * @param $inventoryData - */ - private function updateInventoryInProducts($productIds, $websiteId, $inventoryData): void - { - foreach ($productIds as $productId) { - $stockItemDo = $this->stockRegistry->getStockItem($productId, $websiteId); - if (!$stockItemDo->getProductId()) { - $inventoryData['product_id'] = $productId; - } - - $stockItemId = $stockItemDo->getId(); - $this->dataObjectHelper->populateWithArray($stockItemDo, $inventoryData, StockItemInterface::class); - $stockItemDo->setItemId($stockItemId); - $this->stockItemRepository->save($stockItemDo); - } - $this->stockIndexerProcessor->reindexList($productIds); - } - /** * @param $productIds * @param $websiteRemoveData @@ -261,4 +226,30 @@ private function reindex($productIds, $attributesData, $websiteRemoveData, $webs $this->productPriceIndexerProcessor->reindexList($productIds); } } -} \ No newline at end of file + + /** + * @param $data + */ + private function execute($data): void + { + if ($data['website_assign'] || $data['website_detach']) { + $this->updateWebsiteInProducts([$data['product_id']], $data['website_detach'], $data['website_assign']); + } + + if ($data['attributes']) { + $attributesData = $this->getAttributesData( + [$data['product_id']], + $data['store_id'], + $data['attributes'] + ); + $this->reindex([$data['product_id']], $attributesData, $data['website_detach'], $data['website_assign']); + } + + $this->productFlatIndexerProcessor->reindexList([$data['product_id']]); + + $this->notifier->addNotice( + __('Product attributes updated'), + __('A total of %1 record(s) were updated.', count([$data['product_id']])) + ); + } +} diff --git a/app/code/Magento/Catalog/etc/communication.xml b/app/code/Magento/Catalog/etc/communication.xml index b073725e934f0..9871ba8e58b9f 100644 --- a/app/code/Magento/Catalog/etc/communication.xml +++ b/app/code/Magento/Catalog/etc/communication.xml @@ -6,7 +6,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Communication/etc/communication.xsd"> - <topic name="product_action_attribute.update" request="Magento\Catalog\Api\Data\MassActionInterface"> + <topic name="product_action_attribute.update" request="Magento\AsynchronousOperations\Api\Data\OperationInterface"> <handler name="product_action_attribute.update" type="Magento\Catalog\Model\Attribute\Backend\Consumer" method="process" /> </topic> </config> \ No newline at end of file diff --git a/app/code/Magento/Catalog/etc/queue.xml b/app/code/Magento/Catalog/etc/queue.xml index 8aa7c7fe5e49e..40d9cd1a378b0 100644 --- a/app/code/Magento/Catalog/etc/queue.xml +++ b/app/code/Magento/Catalog/etc/queue.xml @@ -7,6 +7,6 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/queue.xsd"> <broker topic="product_action_attribute.update" exchange="magento-db" type="db"> - <queue name="product_action_attribute.update" consumer="product_action_attribute.update" consumerInstance="Magento\Framework\MessageQueue\Consumer" handler="Magento\Catalog\Model\Attribute\Backend\Consumer::process"/> + <queue name="product_action_attribute.update" consumer="product_action_attribute.update" consumerInstance="Magento\Framework\MessageQueue\BatchConsume" handler="Magento\Catalog\Model\Attribute\Backend\Consumer::process"/> </broker> </config> \ No newline at end of file diff --git a/app/code/Magento/Catalog/etc/queue_consumer.xml b/app/code/Magento/Catalog/etc/queue_consumer.xml index 0090866c0e490..4be387211df04 100644 --- a/app/code/Magento/Catalog/etc/queue_consumer.xml +++ b/app/code/Magento/Catalog/etc/queue_consumer.xml @@ -6,5 +6,5 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/consumer.xsd"> - <consumer name="product_action_attribute.update" queue="product_action_attribute.update" connection="db" maxMessages="5000" consumerInstance="Magento\Framework\MessageQueue\Consumer" handler="Magento\Catalog\Model\Attribute\Backend\Consumer::process" /> + <consumer name="product_action_attribute.update" queue="product_action_attribute.update" connection="db" maxMessages="5000" consumerInstance="Magento\Framework\MessageQueue\BatchConsumer" handler="Magento\Catalog\Model\Attribute\Backend\Consumer::process" /> </config> \ No newline at end of file From 315e78525c84267269fd8bb9a736623acc33a119 Mon Sep 17 00:00:00 2001 From: duhon <duhon@rambler.ru> Date: Mon, 4 Mar 2019 10:51:50 -0600 Subject: [PATCH 070/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Catalog/Api/Data/MassActionInterface.php | 152 -------------- .../Product/Action/Attribute/Save.php | 149 +++++++++---- .../Model/Attribute/Backend/Consumer.php | 175 ++++------------ .../Backend/ConsumerWebsiteAssign.php | 161 ++++++++++++++ app/code/Magento/Catalog/Model/MassAction.php | 198 ------------------ .../Magento/Catalog/Model/Product/Action.php | 2 + .../Magento/Catalog/etc/communication.xml | 3 + app/code/Magento/Catalog/etc/queue.xml | 5 +- .../Magento/Catalog/etc/queue_consumer.xml | 3 +- .../Magento/Catalog/etc/queue_publisher.xml | 3 + .../Magento/Catalog/etc/queue_topology.xml | 1 + 11 files changed, 318 insertions(+), 534 deletions(-) delete mode 100644 app/code/Magento/Catalog/Api/Data/MassActionInterface.php create mode 100644 app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php delete mode 100644 app/code/Magento/Catalog/Model/MassAction.php diff --git a/app/code/Magento/Catalog/Api/Data/MassActionInterface.php b/app/code/Magento/Catalog/Api/Data/MassActionInterface.php deleted file mode 100644 index c03a73df5e92d..0000000000000 --- a/app/code/Magento/Catalog/Api/Data/MassActionInterface.php +++ /dev/null @@ -1,152 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Catalog\Api\Data; - -/** - * MassAction interface. - * @api - * @since 101.1.0 - */ -interface MassActionInterface -{ - - /** - * Set data value. - * - * @param string[] $data - * @return void - * @since 101.1.0 - */ - public function setInventory($data); - - /** - * Get data value. - * - * @return string[] - * @since 101.1.0 - */ - public function getInventory():array; - - /** - * Set data value. - * - * @param string[] $data - * @return void - * @since 101.1.0 - */ - public function setAttributeKeys($data); - - /** - * Get data value. - * - * @return string[] - * @since 101.1.0 - */ - public function getAttributeKeys():array; - - /** - * Set data value. - * - * @param string[] $data - * @return void - * @since 101.1.0 - */ - public function setAttributeValues($data); - - /** - * Get data value. - * - * @return string[] - * @since 101.1.0 - */ - public function getAttributeValues():array; - - /** - * Set data value. - * - * @param string[] $data - * @return void - * @since 101.1.0 - */ - public function setWebsiteRemove($data); - - /** - * Get data value. - * - * @return string[] - * @since 101.1.0 - */ - public function getWebsiteRemove():array; - - /** - * Set data value. - * - * @param string[] $data - * @return void - * @since 101.1.0 - */ - public function setWebsiteAdd($data); - - /** - * Get data value. - * - * @return string[] - * @since 101.1.0 - */ - public function getWebsiteAdd():array; - - /** - * Set data value. - * - * @param integer $data - * @return void - * @since 101.1.0 - */ - public function setStoreId($data); - - /** - * Get data value. - * - * @return integer - * @since 101.1.0 - */ - public function getStoreId(); - - /** - * Set data value. - * - * @param integer[] $data - * @return void - * @since 101.1.0 - */ - public function setProductIds(array $data); - - /** - * Get data value. - * - * @return integer[] - * @since 101.1.0 - */ - public function getProductIds():array; - - /** - * Set data value. - * - * @param integer $data - * @return void - * @since 101.1.0 - */ - public function setWebsiteId($data); - - /** - * Get data value. - * - * @return integer - * @since 101.1.0 - */ - public function getWebsiteId(); -} diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index e91e0ce70f8fd..324f3aba14c7a 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -6,8 +6,11 @@ */ namespace Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute; +use Magento\AsynchronousOperations\Api\Data\OperationInterface; use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Backend\App\Action; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; +use Magento\Framework\App\ObjectManager; /** * Class Save @@ -39,6 +42,11 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribut */ private $userContext; + /** + * @var ObjectManager + */ + private $objectManager; + /** * @param Action\Context $context * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper @@ -63,6 +71,7 @@ public function __construct( $this->identityService = $identityService; $this->serializer = $serializer; $this->userContext = $userContext; + $this->objectManager = ObjectManager::getInstance(); } /** @@ -78,17 +87,16 @@ public function execute() /* Collect Data */ $attributesData = $this->getRequest()->getParam('attributes', []); - $websiteRemoveData = $this->getRequest()->getParam('remove_website_ids', []); $websiteAddData = $this->getRequest()->getParam('add_website_ids', []); - $storeId = $this->attributeHelper->getSelectedStoreId(); $websiteId = $this->attributeHelper->getStoreWebsiteId($storeId); - $productIds = $this->attributeHelper->getProductIds(); + $attributesData = $this->sanitizeProductAttributes($attributesData); + try { - $this->publish('product_action_attribute.update', $attributesData, $websiteRemoveData, $websiteAddData, $storeId, $websiteId, $productIds); + $this->publish($attributesData, $websiteRemoveData, $websiteAddData, $storeId, $websiteId, $productIds); $this->messageManager->addSuccessMessage(__('Message is added to queue')); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); @@ -99,16 +107,50 @@ public function execute() ); } - return $this->resultRedirectFactory->create()->setPath( - 'catalog/product/', - ['store' => $storeId] - ); + return $this->resultRedirectFactory->create()->setPath('catalog/product/', ['store' => $storeId]); + } + + private function sanitizeProductAttributes($attributesData) + { + $dateFormat = $this->objectManager->get(TimezoneInterface::class)->getDateFormat(\IntlDateFormatter::SHORT); + $config = $this->objectManager->get(\Magento\Eav\Model\Config::class); + + foreach ($attributesData as $attributeCode => $value) { + $attribute = $config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); + if (!$attribute->getAttributeId()) { + unset($attributesData[$attributeCode]); + continue; + } + if ($attribute->getBackendType() === 'datetime') { + if (!empty($value)) { + $filterInput = new \Zend_Filter_LocalizedToNormalized(['date_format' => $dateFormat]); + $filterInternal = new \Zend_Filter_NormalizedToLocalized( + ['date_format' => \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT] + ); + $value = $filterInternal->filter($filterInput->filter($value)); + } else { + $value = null; + } + $attributesData[$attributeCode] = $value; + } elseif ($attribute->getFrontendInput() === 'multiselect') { + // Check if 'Change' checkbox has been checked by admin for this attribute + $isChanged = (bool)$this->getRequest()->getPost('toggle_' . $attributeCode); + if (!$isChanged) { + unset($attributesData[$attributeCode]); + continue; + } + if (is_array($value)) { + $value = implode(',', $value); + } + $attributesData[$attributeCode] = $value; + } + } + return $attributesData; } /** * Schedule new bulk. * - * @param $queue * @param $attributesData * @param $websiteRemoveData * @param $websiteAddData @@ -117,45 +159,62 @@ public function execute() * @param $productIds * @return void */ - private function publish($queue, $attributesData, $websiteRemoveData, $websiteAddData, $storeId, $websiteId, $productIds):void + private function publish($attributesData, $websiteRemoveData, $websiteAddData, $storeId, $websiteId, $productIds):void { - $operationCount = count($productIds); - if ($operationCount > 0) { - $bulkUuid = $this->identityService->generateId(); - $bulkDescription = __('Assign custom prices to selected products'); - $operations = []; - foreach ($productIds as $productId) { - $dataToEncode = [ - 'meta_information' => 'ID:' . $productId, - 'product_id' => $productId, - 'store_id' => $storeId, - 'website_id' => $websiteId, - 'website_assign' => $websiteAddData, - 'website_detach' => $websiteRemoveData, - 'attributes' => $attributesData - ]; - $data = [ - 'data' => [ - 'bulk_uuid' => $bulkUuid, - 'topic_name' => $queue, - 'serialized_data' => $this->serializer->serialize($dataToEncode), - 'status' => \Magento\Framework\Bulk\OperationInterface::STATUS_TYPE_OPEN, - ] - ]; - - /** @var \Magento\AsynchronousOperations\Api\Data\OperationInterface $operation */ - $operation = $this->operationFactory->create($data); - $operations[] = $operation; - } - $userId = $this->userContext->getUserId(); - $result = $this->bulkManagement->scheduleBulk($bulkUuid, $operations, $bulkDescription, $userId); - if (!$result) { - throw new \Magento\Framework\Exception\LocalizedException( - __('Something went wrong while processing the request.') - ); - } + $bulkUuid = $this->identityService->generateId(); + $bulkDescription = __('Update attributes to selected products'); + $operations = []; + if ($websiteRemoveData || $websiteAddData) { + $dataToUpdate = [ + 'website_assign' => $websiteAddData, + 'website_detach' => $websiteRemoveData + ]; + + $operations[] = $this->makeOperation('Update website assign', 'product_action_attribute.website.update', $dataToUpdate, $storeId, $websiteId, $productIds, $bulkUuid); + } + + if ($attributesData) { + $operations[] = $this->makeOperation('Update product attributes', 'product_action_attribute.update', $attributesData, $storeId, $websiteId, $productIds, $bulkUuid); + } + + $result = $this->bulkManagement->scheduleBulk($bulkUuid, $operations, $bulkDescription, $this->userContext->getUserId()); + if (!$result) { + throw new \Magento\Framework\Exception\LocalizedException( + __('Something went wrong while processing the request.') + ); } } + /** + * @param $meta + * @param $queue + * @param $dataToUpdate + * @param $storeId + * @param $websiteId + * @param $productIds + * @param $bulkUuid + * @return OperationInterface + */ + private function makeOperation($meta, $queue, $dataToUpdate, $storeId, $websiteId, $productIds, $bulkUuid): OperationInterface + { + $dataToEncode = [ + 'meta_information' => $meta, + 'product_ids' => $productIds, + 'store_id' => $storeId, + 'website_id' => $websiteId, + 'attributes' => $dataToUpdate + ]; + $data = [ + 'data' => [ + 'bulk_uuid' => $bulkUuid, + 'topic_name' => $queue, + 'serialized_data' => $this->serializer->serialize($dataToEncode), + 'status' => \Magento\Framework\Bulk\OperationInterface::STATUS_TYPE_OPEN, + ] + ]; + + return $this->operationFactory->create($data); + } + } diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php index 2e9bbc18be4da..7e6c68a1502e0 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php @@ -8,10 +8,9 @@ namespace Magento\Catalog\Model\Attribute\Backend; use Magento\Framework\Exception\LocalizedException; -use Magento\Framework\App\ObjectManager; +use Magento\Framework\EntityManager\EntityManager; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\TemporaryStateExceptionInterface; -use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Framework\Bulk\OperationInterface; /** @@ -19,11 +18,6 @@ */ class Consumer { - /** - * @var \Magento\Framework\Notification\NotifierInterface - */ - private $notifier; - /** * @var \Psr\Log\LoggerInterface */ @@ -44,16 +38,6 @@ class Consumer */ private $catalogProduct; - /** - * @var \Magento\Framework\Event\ManagerInterface - */ - private $eventManager; - - /** - * @var ObjectManager - */ - private $objectManager; - /** * @var \Magento\Catalog\Model\Product\Action */ @@ -68,56 +52,68 @@ class Consumer * @var \Magento\Framework\Bulk\OperationManagementInterface */ private $operationManagement; + /** + * @var EntityManager + */ + private $entityManager; /** * @param \Magento\Catalog\Helper\Product $catalogProduct * @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor * @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor * @param \Magento\Framework\Bulk\OperationManagementInterface $operationManagement - * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param \Magento\Catalog\Model\Product\Action $action - * @param \Magento\Framework\Notification\NotifierInterface $notifier * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Serialize\SerializerInterface $serializer + * @param EntityManager $entityManager */ public function __construct( \Magento\Catalog\Helper\Product $catalogProduct, \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor, \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor, \Magento\Framework\Bulk\OperationManagementInterface $operationManagement, - \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Catalog\Model\Product\Action $action, - \Magento\Framework\Notification\NotifierInterface $notifier, \Psr\Log\LoggerInterface $logger, - \Magento\Framework\Serialize\SerializerInterface $serializer + \Magento\Framework\Serialize\SerializerInterface $serializer, + EntityManager $entityManager ) { $this->catalogProduct = $catalogProduct; $this->productFlatIndexerProcessor = $productFlatIndexerProcessor; $this->productPriceIndexerProcessor = $productPriceIndexerProcessor; - $this->notifier = $notifier; - $this->eventManager = $eventManager; - $this->objectManager = ObjectManager::getInstance(); $this->productAction = $action; $this->logger = $logger; $this->serializer = $serializer; $this->operationManagement = $operationManagement; + $this->entityManager = $entityManager; } /** - * Processing batch of operations for update tier prices. - * - * @param \Magento\AsynchronousOperations\Api\Data\OperationListInterface $operationList + * @param \Magento\AsynchronousOperations\Api\Data\OperationInterface $operation * @return void - * @throws \InvalidArgumentException */ - public function process(\Magento\AsynchronousOperations\Api\Data\OperationListInterface $operationList) + public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterface $operation) { try { - foreach ($operationList->getItems() as $operation) { - $serializedData = $operation->getSerializedData(); - $data = $this->serializer->unserialize($serializedData); + $serializedData = $operation->getSerializedData(); + $data = $this->serializer->unserialize($serializedData); + $this->execute($data); - $this->execute($data); + } catch (\Zend_Db_Adapter_Exception $e) { + //here sample how to process exceptions if they occurred + $this->logger->critical($e->getMessage()); + //you can add here your own type of exception when operation can be retried + if ( + $e instanceof \Magento\Framework\DB\Adapter\LockWaitException + || $e instanceof \Magento\Framework\DB\Adapter\DeadlockException + || $e instanceof \Magento\Framework\DB\Adapter\ConnectionException + ) { + $status = OperationInterface::STATUS_TYPE_RETRIABLY_FAILED; + $errorCode = $e->getCode(); + $message = __($e->getMessage()); + } else { + $status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; + $errorCode = $e->getCode(); + $message = __('Sorry, something went wrong during product prices update. Please see log for details.'); } } catch (NoSuchEntityException $e) { $this->logger->critical($e->getMessage()); @@ -138,93 +134,11 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationListIn $message = __('Sorry, something went wrong during product prices update. Please see log for details.'); } - //update operation status based on result performing operation(it was successfully executed or exception occurs - $this->operationManagement->changeOperationStatus( - $operation->getId(), - $status, - $errorCode, - $message, - $serializedData - ); - } + $operation->setStatus($status ?? OperationInterface::STATUS_TYPE_COMPLETE) + ->setErrorCode($errorCode ?? null) + ->setResultMessage($message ?? null); - /** - * @param $productIds - * @param $storeId - * @param $attributesData - * @return mixed - */ - private function getAttributesData($productIds, $storeId, $attributesData) - { - $dateFormat = $this->objectManager->get(TimezoneInterface::class)->getDateFormat(\IntlDateFormatter::SHORT); - $config = $this->objectManager->get(\Magento\Eav\Model\Config::class); - - foreach ($attributesData as $attributeCode => $value) { - $attribute = $config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); - if (!$attribute->getAttributeId()) { - unset($attributesData[$attributeCode]); - continue; - } - if ($attribute->getBackendType() == 'datetime') { - if (!empty($value)) { - $filterInput = new \Zend_Filter_LocalizedToNormalized(['date_format' => $dateFormat]); - $filterInternal = new \Zend_Filter_NormalizedToLocalized( - ['date_format' => \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT] - ); - $value = $filterInternal->filter($filterInput->filter($value)); - } else { - $value = null; - } - $attributesData[$attributeCode] = $value; - } elseif ($attribute->getFrontendInput() == 'multiselect') { - // Check if 'Change' checkbox has been checked by admin for this attribute - $isChanged = (bool)$this->getRequest()->getPost('toggle_' . $attributeCode); - if (!$isChanged) { - unset($attributesData[$attributeCode]); - continue; - } - if (is_array($value)) { - $value = implode(',', $value); - } - $attributesData[$attributeCode] = $value; - } - } - - $this->productAction->updateAttributes($productIds, $attributesData, $storeId); - return $attributesData; - } - - /** - * @param $productIds - * @param $websiteRemoveData - * @param $websiteAddData - */ - private function updateWebsiteInProducts($productIds, $websiteRemoveData, $websiteAddData): void - { - if ($websiteRemoveData) { - $this->productAction->updateWebsites($productIds, $websiteRemoveData, 'remove'); - } - if ($websiteAddData) { - $this->productAction->updateWebsites($productIds, $websiteAddData, 'add'); - } - - $this->eventManager->dispatch('catalog_product_to_website_change', ['products' => $productIds]); - } - - /** - * @param $productIds - * @param $attributesData - * @param $websiteRemoveData - * @param $websiteAddData - */ - private function reindex($productIds, $attributesData, $websiteRemoveData, $websiteAddData): void - { - if ($this->catalogProduct->isDataForPriceIndexerWasChanged($attributesData) - || !empty($websiteRemoveData) - || !empty($websiteAddData) - ) { - $this->productPriceIndexerProcessor->reindexList($productIds); - } + $this->entityManager->save($operation); } /** @@ -232,24 +146,11 @@ private function reindex($productIds, $attributesData, $websiteRemoveData, $webs */ private function execute($data): void { - if ($data['website_assign'] || $data['website_detach']) { - $this->updateWebsiteInProducts([$data['product_id']], $data['website_detach'], $data['website_assign']); - } - - if ($data['attributes']) { - $attributesData = $this->getAttributesData( - [$data['product_id']], - $data['store_id'], - $data['attributes'] - ); - $this->reindex([$data['product_id']], $attributesData, $data['website_detach'], $data['website_assign']); + $this->productAction->updateAttributes($data['product_ids'], $data['attributes'], $data['store_id']); + if ($this->catalogProduct->isDataForPriceIndexerWasChanged($data['attributes'])) { + $this->productPriceIndexerProcessor->reindexList($data['product_ids']); } - $this->productFlatIndexerProcessor->reindexList([$data['product_id']]); - - $this->notifier->addNotice( - __('Product attributes updated'), - __('A total of %1 record(s) were updated.', count([$data['product_id']])) - ); + $this->productFlatIndexerProcessor->reindexList($data['product_ids']); } } diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php b/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php new file mode 100644 index 0000000000000..ce4113a03df59 --- /dev/null +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php @@ -0,0 +1,161 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Model\Attribute\Backend; + +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Exception\TemporaryStateExceptionInterface; +use Magento\Framework\Bulk\OperationInterface; +use Magento\Framework\EntityManager\EntityManager; + +/** + * Consumer for export message. + */ +class ConsumerWebsiteAssign +{ + /** + * @var \Psr\Log\LoggerInterface + */ + private $logger; + + /** + * @var \Magento\Catalog\Model\Indexer\Product\Flat\Processor + */ + private $productFlatIndexerProcessor; + + /** + * @var \Magento\Catalog\Model\Product\Action + */ + private $productAction; + + /** + * @var \Magento\Framework\Serialize\SerializerInterface + */ + private $serializer; + + /** + * @var \Magento\Framework\Bulk\OperationManagementInterface + */ + private $operationManagement; + + /** + * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor + */ + private $productPriceIndexerProcessor; + + /** + * @var EntityManager + */ + private $entityManager; + + /** + * @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor + * @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor + * @param \Magento\Framework\Bulk\OperationManagementInterface $operationManagement + * @param \Magento\Catalog\Model\Product\Action $action + * @param \Psr\Log\LoggerInterface $logger + * @param \Magento\Framework\Serialize\SerializerInterface $serializer + * @param EntityManager $entityManager + */ + public function __construct( + \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor, + \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor, + \Magento\Framework\Bulk\OperationManagementInterface $operationManagement, + \Magento\Catalog\Model\Product\Action $action, + \Psr\Log\LoggerInterface $logger, + \Magento\Framework\Serialize\SerializerInterface $serializer, + EntityManager $entityManager + ) { + $this->productFlatIndexerProcessor = $productFlatIndexerProcessor; + $this->productAction = $action; + $this->logger = $logger; + $this->serializer = $serializer; + $this->operationManagement = $operationManagement; + $this->productPriceIndexerProcessor = $productPriceIndexerProcessor; + $this->entityManager = $entityManager; + } + + /** + * @param \Magento\AsynchronousOperations\Api\Data\OperationInterface $operation + * @return void + */ + public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterface $operation) + { + try { + $serializedData = $operation->getSerializedData(); + $data = $this->serializer->unserialize($serializedData); + $this->execute($data); + } catch (\Zend_Db_Adapter_Exception $e) { + //here sample how to process exceptions if they occurred + $this->logger->critical($e->getMessage()); + //you can add here your own type of exception when operation can be retried + if ( + $e instanceof \Magento\Framework\DB\Adapter\LockWaitException + || $e instanceof \Magento\Framework\DB\Adapter\DeadlockException + || $e instanceof \Magento\Framework\DB\Adapter\ConnectionException + ) { + $status = OperationInterface::STATUS_TYPE_RETRIABLY_FAILED; + $errorCode = $e->getCode(); + $message = __($e->getMessage()); + } else { + $status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; + $errorCode = $e->getCode(); + $message = __('Sorry, something went wrong during product prices update. Please see log for details.'); + } + } catch (NoSuchEntityException $e) { + $this->logger->critical($e->getMessage()); + $status = ($e instanceof TemporaryStateExceptionInterface) + ? OperationInterface::STATUS_TYPE_RETRIABLY_FAILED + : OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; + $errorCode = $e->getCode(); + $message = $e->getMessage(); + } catch (LocalizedException $e) { + $this->logger->critical($e->getMessage()); + $status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; + $errorCode = $e->getCode(); + $message = $e->getMessage(); + } catch (\Exception $e) { + $this->logger->critical($e->getMessage()); + $status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; + $errorCode = $e->getCode(); + $message = __('Sorry, something went wrong during product prices update. Please see log for details.'); + } + + $operation->setStatus($status ?? OperationInterface::STATUS_TYPE_COMPLETE) + ->setErrorCode($errorCode ?? null) + ->setResultMessage($message ?? null); + + $this->entityManager->save($operation); + } + + /** + * @param $productIds + * @param $websiteRemoveData + * @param $websiteAddData + */ + private function updateWebsiteInProducts($productIds, $websiteRemoveData, $websiteAddData): void + { + if ($websiteRemoveData) { + $this->productAction->updateWebsites($productIds, $websiteRemoveData, 'remove'); + } + if ($websiteAddData) { + $this->productAction->updateWebsites($productIds, $websiteAddData, 'add'); + } + } + + + /** + * @param $data + */ + private function execute($data): void + { + $this->updateWebsiteInProducts($data['product_ids'], $data['attributes']['website_detach'], $data['attributes']['website_assign']); + $this->productPriceIndexerProcessor->reindexList($data['product_ids']); + $this->productFlatIndexerProcessor->reindexList($data['product_ids']); + } +} diff --git a/app/code/Magento/Catalog/Model/MassAction.php b/app/code/Magento/Catalog/Model/MassAction.php deleted file mode 100644 index 0f09ff8d7699c..0000000000000 --- a/app/code/Magento/Catalog/Model/MassAction.php +++ /dev/null @@ -1,198 +0,0 @@ -<?php -namespace Magento\Catalog\Model; - -class MassAction implements \Magento\Catalog\Api\Data\MassActionInterface -{ - private $inventory; - private $attributeKeys; - private $websiteRemove; - private $websiteAdd; - private $storeId; - private $productIds; - private $websiteId; - private $attributeValues; - - /** - * Set data value. - * - * @param string $data - * @return void - * @since 101.1.0 - */ - public function setInventory($data) - { - $this->inventory = $data; - } - - /** - * Get data value. - * - * @return string[] - * @since 101.1.0 - */ - public function getInventory():array - { - return $this->inventory; - } - - /** - * Set data value. - * - * @param string $data - * @return void - * @since 101.1.0 - */ - public function setAttributeKeys($data) - { - $this->attributeKeys = $data; - } - - /** - * Get data value. - * - * @return string[] - * @since 101.1.0 - */ - public function getAttributeKeys():array - { - return $this->attributeKeys; - } - - /** - * Set data value. - * - * @param string $data - * @return void - * @since 101.1.0 - */ - public function setAttributeValues($data) - { - $this->attributeValues = $data; - } - - /** - * Get data value. - * - * @return string[] - * @since 101.1.0 - */ - public function getAttributeValues():array - { - return $this->attributeValues; - } - - /** - * Set data value. - * - * @param string $data - * @return void - * @since 101.1.0 - */ - public function setWebsiteRemove($data) - { - $this->websiteRemove = $data; - } - - /** - * Get data value. - * - * @return string[] - * @since 101.1.0 - */ - public function getWebsiteRemove():array - { - return $this->websiteRemove; - } - - /** - * Set data value. - * - * @param string $data - * @return void - * @since 101.1.0 - */ - public function setWebsiteAdd($data) - { - $this->websiteAdd = $data; - } - - /** - * Get data value. - * - * @return string[] - * @since 101.1.0 - */ - public function getWebsiteAdd():array - { - return $this->websiteAdd; - } - - /** - * Set data value. - * - * @param string $data - * @return void - * @since 101.1.0 - */ - public function setStoreId($data) - { - $this->storeId = $data; - } - - /** - * Get data value. - * - * @return string - * @since 101.1.0 - */ - public function getStoreId() - { - return $this->storeId; - } - - /** - * Set data value. - * - * @param integer[] $data - * @return void - * @since 101.1.0 - */ - public function setProductIds(array $data) - { - $this->productIds = $data; - } - - /** - * Get data value. - * - * @return integer[] - * @since 101.1.0 - */ - public function getProductIds():array - { - return $this->productIds; - } - - /** - * Set data value. - * - * @param string $data - * @return void - * @since 101.1.0 - */ - public function setWebsiteId($data) - { - $this->websiteId = $data; - } - - /** - * Get data value. - * - * @return string - * @since 101.1.0 - */ - public function getWebsiteId() - { - return $this->websiteId; - } -} diff --git a/app/code/Magento/Catalog/Model/Product/Action.php b/app/code/Magento/Catalog/Model/Product/Action.php index f78048424b42c..3863cf2457247 100644 --- a/app/code/Magento/Catalog/Model/Product/Action.php +++ b/app/code/Magento/Catalog/Model/Product/Action.php @@ -168,5 +168,7 @@ public function updateWebsites($productIds, $websiteIds, $type) if (!$categoryIndexer->isScheduled()) { $categoryIndexer->reindexList(array_unique($productIds)); } + + $this->_eventManager->dispatch('catalog_product_to_website_change', ['products' => $productIds]); } } diff --git a/app/code/Magento/Catalog/etc/communication.xml b/app/code/Magento/Catalog/etc/communication.xml index 9871ba8e58b9f..1a957f6ac9fe5 100644 --- a/app/code/Magento/Catalog/etc/communication.xml +++ b/app/code/Magento/Catalog/etc/communication.xml @@ -9,4 +9,7 @@ <topic name="product_action_attribute.update" request="Magento\AsynchronousOperations\Api\Data\OperationInterface"> <handler name="product_action_attribute.update" type="Magento\Catalog\Model\Attribute\Backend\Consumer" method="process" /> </topic> + <topic name="product_action_attribute.website.update" request="Magento\AsynchronousOperations\Api\Data\OperationInterface"> + <handler name="product_action_attribute.website.update" type="Magento\Catalog\Model\Attribute\Backend\ConsumerWebsiteAssign" method="process" /> + </topic> </config> \ No newline at end of file diff --git a/app/code/Magento/Catalog/etc/queue.xml b/app/code/Magento/Catalog/etc/queue.xml index 40d9cd1a378b0..137f34a5c1e25 100644 --- a/app/code/Magento/Catalog/etc/queue.xml +++ b/app/code/Magento/Catalog/etc/queue.xml @@ -7,6 +7,9 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/queue.xsd"> <broker topic="product_action_attribute.update" exchange="magento-db" type="db"> - <queue name="product_action_attribute.update" consumer="product_action_attribute.update" consumerInstance="Magento\Framework\MessageQueue\BatchConsume" handler="Magento\Catalog\Model\Attribute\Backend\Consumer::process"/> + <queue name="product_action_attribute.update" consumer="product_action_attribute.update" consumerInstance="Magento\Framework\MessageQueue\Consumer" handler="Magento\Catalog\Model\Attribute\Backend\Consumer::process"/> + </broker> + <broker topic="product_action_attribute.website.update" exchange="magento-db" type="db"> + <queue name="product_action_attribute.website.update" consumer="product_action_attribute.website.update" consumerInstance="Magento\Framework\MessageQueue\Consumer" handler="Magento\Catalog\Model\Attribute\Backend\ConsumerWebsiteAssign::process"/> </broker> </config> \ No newline at end of file diff --git a/app/code/Magento/Catalog/etc/queue_consumer.xml b/app/code/Magento/Catalog/etc/queue_consumer.xml index 4be387211df04..d9e66ae69c10c 100644 --- a/app/code/Magento/Catalog/etc/queue_consumer.xml +++ b/app/code/Magento/Catalog/etc/queue_consumer.xml @@ -6,5 +6,6 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/consumer.xsd"> - <consumer name="product_action_attribute.update" queue="product_action_attribute.update" connection="db" maxMessages="5000" consumerInstance="Magento\Framework\MessageQueue\BatchConsumer" handler="Magento\Catalog\Model\Attribute\Backend\Consumer::process" /> + <consumer name="product_action_attribute.update" queue="product_action_attribute.update" connection="db" maxMessages="5000" consumerInstance="Magento\Framework\MessageQueue\Consumer" handler="Magento\Catalog\Model\Attribute\Backend\Consumer::process" /> + <consumer name="product_action_attribute.website.update" queue="product_action_attribute.website.update" connection="db" maxMessages="5000" consumerInstance="Magento\Framework\MessageQueue\Consumer" handler="Magento\Catalog\Model\Attribute\Backend\ConsumerWebsiteAssign::process" /> </config> \ No newline at end of file diff --git a/app/code/Magento/Catalog/etc/queue_publisher.xml b/app/code/Magento/Catalog/etc/queue_publisher.xml index c673a8321762a..1606ea42ec0b3 100644 --- a/app/code/Magento/Catalog/etc/queue_publisher.xml +++ b/app/code/Magento/Catalog/etc/queue_publisher.xml @@ -9,4 +9,7 @@ <publisher topic="product_action_attribute.update"> <connection name="db" exchange="magento-db" /> </publisher> + <publisher topic="product_action_attribute.website.update"> + <connection name="db" exchange="magento-db" /> + </publisher> </config> \ No newline at end of file diff --git a/app/code/Magento/Catalog/etc/queue_topology.xml b/app/code/Magento/Catalog/etc/queue_topology.xml index 0097d770936a3..bdac891afbdb8 100644 --- a/app/code/Magento/Catalog/etc/queue_topology.xml +++ b/app/code/Magento/Catalog/etc/queue_topology.xml @@ -8,5 +8,6 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework-message-queue:etc/topology.xsd"> <exchange name="magento-db" type="topic" connection="db"> <binding id="updateBinding" topic="product_action_attribute.update" destinationType="queue" destination="product_action_attribute.update"/> + <binding id="updateBindingWebsite" topic="product_action_attribute.website.update" destinationType="queue" destination="product_action_attribute.website.update"/> </exchange> </config> \ No newline at end of file From 5fece499757fb44cc526fd2d5841475da0df322d Mon Sep 17 00:00:00 2001 From: duhon <duhon@rambler.ru> Date: Mon, 4 Mar 2019 19:43:10 -0600 Subject: [PATCH 071/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Backend/ConsumerWebsiteAssign.php | 1 - .../Plugin/MassUpdateProductAttribute.php | 153 ++++++++++++++++++ app/code/Magento/CatalogInventory/etc/di.xml | 3 + 3 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php b/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php index ce4113a03df59..f8cc3c04df605 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php @@ -148,7 +148,6 @@ private function updateWebsiteInProducts($productIds, $websiteRemoveData, $websi } } - /** * @param $data */ diff --git a/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php b/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php new file mode 100644 index 0000000000000..36958a37c6d1a --- /dev/null +++ b/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php @@ -0,0 +1,153 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\CatalogInventory\Plugin; + +use Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save; +use Magento\CatalogInventory\Api\Data\StockItemInterface; + +class MassUpdateProductAttribute +{ + /** + * @var \Magento\CatalogInventory\Model\Indexer\Stock\Processor + */ + private $stockIndexerProcessor; + + /** + * @var \Magento\Framework\Api\DataObjectHelper + */ + private $dataObjectHelper; + + /** + * @var \Magento\CatalogInventory\Api\StockRegistryInterface + */ + private $stockRegistry; + + /** + * @var \Magento\CatalogInventory\Api\StockItemRepositoryInterface + */ + private $stockItemRepository; + + /** + * @var \Magento\CatalogInventory\Api\StockConfigurationInterface + */ + private $stockConfiguration; + + /** + * @var \Magento\Framework\App\RequestInterface + */ + private $request; + + /** + * @var \Magento\Backend\Model\Session + */ + private $session; + + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + private $storeManager; + + /** + * @var \Magento\Backend\Model\View\Result\Redirect + */ + private $redirectFactory; + /** + * @var \Magento\Framework\Message\ManagerInterface + */ + private $messageManager; + + /** + * @param \Magento\CatalogInventory\Model\Indexer\Stock\Processor $stockIndexerProcessor + * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper + * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry + * @param \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepository + * @param \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration + * @param \Magento\Framework\App\RequestInterface $request + * @param \Magento\Backend\Model\Session $session + * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Backend\Model\View\Result\RedirectFactory $redirectFactory + * @param \Magento\Framework\Message\ManagerInterface $messageManager + */ + public function __construct( + \Magento\CatalogInventory\Model\Indexer\Stock\Processor $stockIndexerProcessor, + \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, + \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, + \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepository, + \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration, + \Magento\Framework\App\RequestInterface $request, + \Magento\Backend\Model\Session $session, + \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Backend\Model\View\Result\RedirectFactory $redirectFactory, + \Magento\Framework\Message\ManagerInterface $messageManager + ) { + $this->stockIndexerProcessor = $stockIndexerProcessor; + $this->dataObjectHelper = $dataObjectHelper; + $this->stockRegistry = $stockRegistry; + $this->stockItemRepository = $stockItemRepository; + $this->stockConfiguration = $stockConfiguration; + $this->request = $request; + $this->session = $session; + $this->storeManager = $storeManager; + $this->redirectFactory = $redirectFactory; + $this->messageManager = $messageManager; + } + + /** + * @param Save $subject + * @return \Magento\Framework\Controller\ResultInterface + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundExecute(Save $subject, callable $proceed) + { + try { + $inventoryData = $this->request->getParam('inventory', []); + $storeId = $this->request->getParam('store', \Magento\Store\Model\Store::DEFAULT_STORE_ID); + $websiteId = $this->storeManager->getStore($storeId)->getWebsiteId(); + $productIds = $this->session->getData('product_ids'); + $inventoryData = $this->addConfigSettings($inventoryData); + $this->updateInventoryInProducts($productIds, $websiteId, $inventoryData); + + return $proceed(); + } catch (\Magento\Framework\Exception\LocalizedException $e) { + $this->messageManager->addErrorMessage($e->getMessage()); + } catch (\Exception $e) { + $this->messageManager->addExceptionMessage( + $e, + __('Something went wrong while updating the product(s) attributes.') + ); + } + + return $this->redirectFactory->create()->setPath('catalog/product/', ['_current' => true]); + } + + private function addConfigSettings($inventoryData) + { + $options = $this->stockConfiguration->getConfigItemOptions(); + foreach ($options as $option) { + $useConfig = 'use_config_' . $option; + if (isset($inventoryData[$option]) && !isset($inventoryData[$useConfig])) { + $inventoryData[$useConfig] = 0; + } + } + return $inventoryData; + } + + private function updateInventoryInProducts($productIds, $websiteId, $inventoryData): void + { + foreach ($productIds as $productId) { + $stockItemDo = $this->stockRegistry->getStockItem($productId, $websiteId); + if (!$stockItemDo->getProductId()) { + $inventoryData['product_id'] = $productId; + } + $stockItemId = $stockItemDo->getId(); + $this->dataObjectHelper->populateWithArray($stockItemDo, $inventoryData, StockItemInterface::class); + $stockItemDo->setItemId($stockItemId); + $this->stockItemRepository->save($stockItemDo); + } + $this->stockIndexerProcessor->reindexList($productIds); + } +} diff --git a/app/code/Magento/CatalogInventory/etc/di.xml b/app/code/Magento/CatalogInventory/etc/di.xml index 8d57fab843f4c..4253dc09b4e29 100644 --- a/app/code/Magento/CatalogInventory/etc/di.xml +++ b/app/code/Magento/CatalogInventory/etc/di.xml @@ -135,4 +135,7 @@ <type name="Magento\CatalogInventory\Model\ResourceModel\Stock\Item"> <plugin name="priceIndexUpdater" type="Magento\CatalogInventory\Model\Plugin\PriceIndexUpdater" /> </type> + <type name="Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save"> + <plugin name="massAction" type="Magento\CatalogInventory\Plugin\MassUpdateProductAttribute" /> + </type> </config> From 31fcfa50fbe3b6fccbbe18f57a25df425df47feb Mon Sep 17 00:00:00 2001 From: duhon <duhon@rambler.ru> Date: Mon, 4 Mar 2019 20:09:58 -0600 Subject: [PATCH 072/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Adminhtml/Product/Action/Attribute/Save.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index 324f3aba14c7a..f0b19b2073cc3 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -177,11 +177,13 @@ private function publish($attributesData, $websiteRemoveData, $websiteAddData, $ $operations[] = $this->makeOperation('Update product attributes', 'product_action_attribute.update', $attributesData, $storeId, $websiteId, $productIds, $bulkUuid); } - $result = $this->bulkManagement->scheduleBulk($bulkUuid, $operations, $bulkDescription, $this->userContext->getUserId()); - if (!$result) { - throw new \Magento\Framework\Exception\LocalizedException( - __('Something went wrong while processing the request.') - ); + if (!empty($operations)) { + $result = $this->bulkManagement->scheduleBulk($bulkUuid, $operations, $bulkDescription, $this->userContext->getUserId()); + if (!$result) { + throw new \Magento\Framework\Exception\LocalizedException( + __('Something went wrong while processing the request.') + ); + } } } From 7a39087f0c0832f13cd50af18414a45229e59237 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@adobe.com> Date: Tue, 5 Mar 2019 18:58:28 -0600 Subject: [PATCH 073/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- setup/performance-toolkit/benchmark.jmx | 837 ------------------------ 1 file changed, 837 deletions(-) diff --git a/setup/performance-toolkit/benchmark.jmx b/setup/performance-toolkit/benchmark.jmx index 765d0a616f77c..0e1860405e946 100644 --- a/setup/performance-toolkit/benchmark.jmx +++ b/setup/performance-toolkit/benchmark.jmx @@ -27267,843 +27267,6 @@ if (testLabel <stringProp name="ThreadGroup.delay"/> <stringProp name="TestPlan.comments">mpaf/tool/fragments/_system/thread_group.jmx</stringProp></ThreadGroup> <hashTree> - <ThroughputController guiclass="ThroughputControllerGui" testclass="ThroughputController" testname="Product Grid Mass Actions" enabled="true"> - <intProp name="ThroughputController.style">1</intProp> - <boolProp name="ThroughputController.perThread">false</boolProp> - <intProp name="ThroughputController.maxThroughput">1</intProp> - <stringProp name="ThroughputController.percentThroughput">${productGridMassActionPercentage}</stringProp> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/_system/scenario_controller_tmpl.jmx</stringProp></ThroughputController> - <hashTree> - <JSR223PreProcessor guiclass="TestBeanGUI" testclass="JSR223PreProcessor" testname="Set Test Label" enabled="true"> - <stringProp name="script"> -var testLabel = "${testLabel}" ? " (${testLabel})" : ""; -if (testLabel - && sampler.getClass().getName() == 'org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy' -) { - if (sampler.getName().indexOf(testLabel) == -1) { - sampler.setName(sampler.getName() + testLabel); - } -} else if (sampler.getName().indexOf("SetUp - ") == -1) { - sampler.setName("SetUp - " + sampler.getName()); -} - </stringProp> - <stringProp name="scriptLanguage">javascript</stringProp> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/_system/setup_label.jmx</stringProp></JSR223PreProcessor> - <hashTree/> - <BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="SetUp - Set Label" enabled="true"> - <stringProp name="BeanShellSampler.query"> - vars.put("testLabel", "Product Grid Mass Actions"); - </stringProp> - <boolProp name="BeanShellSampler.resetInterpreter">true</boolProp> - </BeanShellSampler> - <hashTree/> - - <JSR223PostProcessor guiclass="TestBeanGUI" testclass="JSR223PostProcessor" testname="Get admin form key PostProcessor" enabled="true"> - <stringProp name="script"> - function getFormKeyFromResponse() - { - var url = prev.getUrlAsString(), - responseCode = prev.getResponseCode(), - formKey = null; - searchPattern = /var FORM_KEY = '(.+)'/; - if (responseCode == "200" && url) { - response = prev.getResponseDataAsString(); - formKey = response && response.match(searchPattern) ? response.match(searchPattern)[1] : null; - } - return formKey; - } - - formKey = vars.get("form_key_storage"); - - currentFormKey = getFormKeyFromResponse(); - - if (currentFormKey != null && currentFormKey != formKey) { - vars.put("form_key_storage", currentFormKey); - } - </stringProp> - <stringProp name="scriptLanguage">javascript</stringProp> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/admin/handle_admin_form_key.jmx</stringProp></JSR223PostProcessor> - <hashTree/> - <JSR223PreProcessor guiclass="TestBeanGUI" testclass="JSR223PreProcessor" testname="Set admin form key PreProcessor" enabled="true"> - <stringProp name="script"> - formKey = vars.get("form_key_storage"); - if (formKey - && sampler.getClass().getName() == 'org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy' - && sampler.getMethod() == "POST") - { - arguments = sampler.getArguments(); - for (i=0; i<arguments.getArgumentCount(); i++) - { - argument = arguments.getArgument(i); - if (argument.getName() == 'form_key' && argument.getValue() != formKey) { - log.info("admin form key updated: " + argument.getValue() + " => " + formKey); - argument.setValue(formKey); - } - } - } - </stringProp> - <stringProp name="scriptLanguage">javascript</stringProp> - </JSR223PreProcessor> - <hashTree/> - - <CookieManager guiclass="CookiePanel" testclass="CookieManager" testname="HTTP Cookie Manager" enabled="true"> - <collectionProp name="CookieManager.cookies"/> - <boolProp name="CookieManager.clearEachIteration">false</boolProp> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/http_cookie_manager_without_clear_each_iteration.jmx</stringProp></CookieManager> - <hashTree/> - - <GenericController guiclass="LogicControllerGui" testclass="GenericController" testname="Admin Login" enabled="true"> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/simple_controller.jmx</stringProp> -</GenericController> - <hashTree> - <CriticalSectionController guiclass="CriticalSectionControllerGui" testclass="CriticalSectionController" testname="Admin Login Lock" enabled="true"> - <stringProp name="CriticalSectionController.lockName">get-admin-email</stringProp> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/lock_controller.jmx</stringProp></CriticalSectionController> - <hashTree> - - <BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="SetUp - Get Admin Email" enabled="true"> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/get_admin_email.jmx</stringProp> - <stringProp name="BeanShellSampler.query"> -adminUserList = props.get("adminUserList"); -adminUserListIterator = props.get("adminUserListIterator"); -adminUsersDistribution = Integer.parseInt(vars.get("admin_users_distribution_per_admin_pool")); - -if (adminUsersDistribution == 1) { - adminUser = adminUserList.poll(); -} else { - if (!adminUserListIterator.hasNext()) { - adminUserListIterator = adminUserList.descendingIterator(); - } - - adminUser = adminUserListIterator.next(); -} - -if (adminUser == null) { - SampleResult.setResponseMessage("adminUser list is empty"); - SampleResult.setResponseData("adminUser list is empty","UTF-8"); - IsSuccess=false; - SampleResult.setSuccessful(false); - SampleResult.setStopThread(true); -} -vars.put("admin_user", adminUser); - </stringProp> - <stringProp name="BeanShellSampler.filename"/> - <stringProp name="BeanShellSampler.parameters"/> - <boolProp name="BeanShellSampler.resetInterpreter">true</boolProp> - </BeanShellSampler> - <hashTree/> - </hashTree> - - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="SetUp - Login" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"/> - </elementProp> - <stringProp name="HTTPSampler.domain"/> - <stringProp name="HTTPSampler.port"/> - <stringProp name="HTTPSampler.connect_timeout">60000</stringProp> - <stringProp name="HTTPSampler.response_timeout">200000</stringProp> - <stringProp name="HTTPSampler.protocol">${request_protocol}</stringProp> - <stringProp name="HTTPSampler.contentEncoding"/> - <stringProp name="HTTPSampler.path">${base_path}${admin_path}/admin/</stringProp> - <stringProp name="HTTPSampler.method">GET</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"/> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/admin_login/admin_login.jmx</stringProp></HTTPSamplerProxy> - <hashTree> - <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Assert login form shown" enabled="true"> - <collectionProp name="Asserion.test_strings"> - <stringProp name="-1397214398">Welcome</stringProp> - <stringProp name="-515240035"><title>Magento Admin</title></stringProp> - </collectionProp> - <stringProp name="Assertion.test_field">Assertion.response_data</stringProp> - <boolProp name="Assertion.assume_success">false</boolProp> - <intProp name="Assertion.test_type">2</intProp> - </ResponseAssertion> - <hashTree/> - <RegexExtractor guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="Extract form key" enabled="true"> - <stringProp name="RegexExtractor.useHeaders">false</stringProp> - <stringProp name="RegexExtractor.refname">admin_form_key</stringProp> - <stringProp name="RegexExtractor.regex"><input name="form_key" type="hidden" value="([^'"]+)" /></stringProp> - <stringProp name="RegexExtractor.template">$1$</stringProp> - <stringProp name="RegexExtractor.default"/> - <stringProp name="RegexExtractor.match_number">1</stringProp> - </RegexExtractor> - <hashTree/> - <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Assert form_key extracted" enabled="true"> - <collectionProp name="Asserion.test_strings"> - <stringProp name="2845929">^.+$</stringProp> - </collectionProp> - <stringProp name="Assertion.test_field">Assertion.response_data</stringProp> - <boolProp name="Assertion.assume_success">false</boolProp> - <intProp name="Assertion.test_type">1</intProp> - <stringProp name="Assertion.scope">variable</stringProp> - <stringProp name="Scope.variable">admin_form_key</stringProp> - </ResponseAssertion> - <hashTree/> - </hashTree> - - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="SetUp - Login Submit Form" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"> - <elementProp name="dummy" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value"/> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">dummy</stringProp> - </elementProp> - <elementProp name="form_key" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${admin_form_key}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">form_key</stringProp> - </elementProp> - <elementProp name="login[password]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${admin_password}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">login[password]</stringProp> - </elementProp> - <elementProp name="login[username]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${admin_user}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">login[username]</stringProp> - </elementProp> - </collectionProp> - </elementProp> - <stringProp name="HTTPSampler.domain"/> - <stringProp name="HTTPSampler.port"/> - <stringProp name="HTTPSampler.connect_timeout">60000</stringProp> - <stringProp name="HTTPSampler.response_timeout">200000</stringProp> - <stringProp name="HTTPSampler.protocol">${request_protocol}</stringProp> - <stringProp name="HTTPSampler.contentEncoding"/> - <stringProp name="HTTPSampler.path">${base_path}${admin_path}/admin/dashboard/</stringProp> - <stringProp name="HTTPSampler.method">POST</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <stringProp name="HTTPSampler.implementation">Java</stringProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"/> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/admin_login/admin_login_submit_form.jmx</stringProp> - </HTTPSamplerProxy> - <hashTree> - <RegexExtractor guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="Extract form key" enabled="true"> - <stringProp name="RegexExtractor.useHeaders">false</stringProp> - <stringProp name="RegexExtractor.refname">admin_form_key</stringProp> - <stringProp name="RegexExtractor.regex"><input name="form_key" type="hidden" value="([^'"]+)" /></stringProp> - <stringProp name="RegexExtractor.template">$1$</stringProp> - <stringProp name="RegexExtractor.default"/> - <stringProp name="RegexExtractor.match_number">1</stringProp> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/admin_login/admin_retrieve_form_key.jmx</stringProp></RegexExtractor> - <hashTree/> - </hashTree> - </hashTree> - - <GenericController guiclass="LogicControllerGui" testclass="GenericController" testname="Simple Controller" enabled="true"> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/simple_controller.jmx</stringProp> -</GenericController> - <hashTree> - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Get Product Pages Count" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"> - <elementProp name="form_key" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${admin_form_key}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">form_key</stringProp> - </elementProp> - <elementProp name="namespace" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">product_listing</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">namespace</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="search" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value"/> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">search</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="filters[placeholder]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">true</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">filters[placeholder]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="paging[pageSize]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">20</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">paging[pageSize]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="paging[current]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">1</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">paging[current]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="sorting[field]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">entity_id</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">sorting[field]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="sorting[direction]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">asc</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">sorting[direction]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="isAjax" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">true</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">isAjax</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - </collectionProp> - </elementProp> - <stringProp name="HTTPSampler.domain"/> - <stringProp name="HTTPSampler.port"/> - <stringProp name="HTTPSampler.connect_timeout">60000</stringProp> - <stringProp name="HTTPSampler.response_timeout">200000</stringProp> - <stringProp name="HTTPSampler.protocol">${request_protocol}</stringProp> - <stringProp name="HTTPSampler.contentEncoding"/> - <stringProp name="HTTPSampler.path">${base_path}${admin_path}/mui/index/render/</stringProp> - <stringProp name="HTTPSampler.method">GET</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"/> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/admin_browse_products_grid/get_product_pages_count.jmx</stringProp></HTTPSamplerProxy> - <hashTree> - <com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.gui.JSONPathAssertionGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion" testname="Assert total records is not 0" enabled="true"> - <stringProp name="JSON_PATH">$.totalRecords</stringProp> - <stringProp name="EXPECTED_VALUE">0</stringProp> - <boolProp name="JSONVALIDATION">true</boolProp> - <boolProp name="EXPECT_NULL">false</boolProp> - <boolProp name="INVERT">true</boolProp> - </com.atlantbh.jmeter.plugins.jsonutils.jsonpathassertion.JSONPathAssertion> - <hashTree/> - <com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor guiclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.gui.JSONPathExtractorGui" testclass="com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor" testname="Extract total records" enabled="true"> - <stringProp name="VAR">products_number</stringProp> - <stringProp name="JSONPATH">$.totalRecords</stringProp> - <stringProp name="DEFAULT"/> - <stringProp name="VARIABLE"/> - <stringProp name="SUBJECT">BODY</stringProp> - </com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor> - <hashTree/> - <BeanShellPostProcessor guiclass="TestBeanGUI" testclass="BeanShellPostProcessor" testname="Calculate pages count" enabled="true"> - <boolProp name="resetInterpreter">false</boolProp> - <stringProp name="parameters"/> - <stringProp name="filename"/> - <stringProp name="script">var productsPageSize = Integer.parseInt(vars.get("products_page_size")); -var productsTotal = Integer.parseInt(vars.get("products_number")); -var pageCountProducts = Math.round(productsTotal/productsPageSize); - -vars.put("pages_count_product", String.valueOf(pageCountProducts));</stringProp> - </BeanShellPostProcessor> - <hashTree/> - </hashTree> - - <BeanShellSampler guiclass="BeanShellSamplerGui" testclass="BeanShellSampler" testname="SetUp - Set Arguments" enabled="true"> - <stringProp name="BeanShellSampler.query"> -import java.util.Random; -Random random = new Random(); -if (${seedForRandom} > 0) { -random.setSeed(${seedForRandom}); -} -var productsPageSize = Integer.parseInt(vars.get("products_page_size")); -var totalNumberOfPages = Integer.parseInt(vars.get("pages_count_product")); - -// Randomly select a page. -var randomProductsPage = random.nextInt(totalNumberOfPages) + 1; - -// Get the first and last product id on that page. -var lastProductIdOnPage = randomProductsPage * productsPageSize; -var firstProductIdOnPage = lastProductIdOnPage - productsPageSize + 1; - -var randomProductId1 = Math.floor(random.nextInt(productsPageSize)) + firstProductIdOnPage; -var randomProductId2 = Math.floor(random.nextInt(productsPageSize)) + firstProductIdOnPage; -var randomProductId3 = Math.floor(random.nextInt(productsPageSize)) + firstProductIdOnPage; - -vars.put("page_number", String.valueOf(randomProductsPage)); -vars.put("productId1", String.valueOf(randomProductId1)); -vars.put("productId2", String.valueOf(randomProductId2)); -vars.put("productId3", String.valueOf(randomProductId3)); - -var randomQuantity = random.nextInt(1000) + 1; -var randomPrice = random.nextInt(500) + 10; -var randomVisibility = random.nextInt(4) + 1; - -vars.put("quantity", String.valueOf(randomQuantity)); -vars.put("price", String.valueOf(randomPrice)); -vars.put("visibility", String.valueOf(randomVisibility)); - </stringProp> - <stringProp name="BeanShellSampler.filename"/> - <stringProp name="BeanShellSampler.parameters"/> - <boolProp name="BeanShellSampler.resetInterpreter">false</boolProp> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/admin_browse_products_grid/products_grid_mass_actions/setup.jmx</stringProp></BeanShellSampler> - <hashTree/> - - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Select Products and Update Attributes mass action" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"> - <elementProp name="form_key" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${admin_form_key}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">form_key</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="namespace" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">product_listing</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">namespace</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="search" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value"/> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">search</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="filters[placeholder]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">true</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">filters[placeholder]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="paging[pageSize]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${products_page_size}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">paging[pageSize]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="paging[current]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${page_number}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">paging[current]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="sorting[field]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">entity_id</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">sorting[field]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="sorting[direction]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">asc</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">sorting[direction]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="isAjax" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">true</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">isAjax</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - </collectionProp> - </elementProp> - <stringProp name="HTTPSampler.domain"/> - <stringProp name="HTTPSampler.port"/> - <stringProp name="HTTPSampler.connect_timeout">60000</stringProp> - <stringProp name="HTTPSampler.response_timeout">200000</stringProp> - <stringProp name="HTTPSampler.protocol">${request_protocol}</stringProp> - <stringProp name="HTTPSampler.contentEncoding"/> - <stringProp name="HTTPSampler.path">${base_path}${admin_path}/mui/index/render/</stringProp> - <stringProp name="HTTPSampler.method">GET</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"/> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/admin_browse_products_grid/products_grid_mass_actions/display_grid.jmx</stringProp></HTTPSamplerProxy> - <hashTree> - <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true"> - <collectionProp name="Asserion.test_strings"> - <stringProp name="1637639774">totalRecords</stringProp> - </collectionProp> - <stringProp name="Assertion.test_field">Assertion.response_data</stringProp> - <boolProp name="Assertion.assume_success">false</boolProp> - <intProp name="Assertion.test_type">2</intProp> - </ResponseAssertion> - <hashTree/> - </hashTree> - - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Display Update Attributes" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"> - <elementProp name="selected[0]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${productId1}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">selected[0]</stringProp> - </elementProp> - <elementProp name="selected[1]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${productId2}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">selected[1]</stringProp> - </elementProp> - <elementProp name="selected[2]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${productId3}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">selected[2]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="filters[placeholder]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">true</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">filters[placeholder]</stringProp> - <stringProp name="Argument.desc">false</stringProp> - </elementProp> - <elementProp name="form_key" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${admin_form_key}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">form_key</stringProp> - <stringProp name="Argument.desc">false</stringProp> - </elementProp> - <elementProp name="namespace" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">product_listing</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">namespace</stringProp> - <stringProp name="Argument.desc">false</stringProp> - </elementProp> - </collectionProp> - </elementProp> - <stringProp name="HTTPSampler.domain"/> - <stringProp name="HTTPSampler.port"/> - <stringProp name="HTTPSampler.connect_timeout">60000</stringProp> - <stringProp name="HTTPSampler.response_timeout">200000</stringProp> - <stringProp name="HTTPSampler.protocol">${request_protocol}</stringProp> - <stringProp name="HTTPSampler.contentEncoding"/> - <stringProp name="HTTPSampler.path">${base_path}${admin_path}/catalog/product_action_attribute/edit</stringProp> - <stringProp name="HTTPSampler.method">GET</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"/> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/admin_browse_products_grid/products_grid_mass_actions/display_update_attributes.jmx</stringProp></HTTPSamplerProxy> - <hashTree> - <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true"> - <collectionProp name="Asserion.test_strings"> - <stringProp name="1862384910">Update Attributes</stringProp> - </collectionProp> - <stringProp name="Assertion.test_field">Assertion.response_data</stringProp> - <boolProp name="Assertion.assume_success">false</boolProp> - <intProp name="Assertion.test_type">2</intProp> - </ResponseAssertion> - <hashTree/> - </hashTree> - - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Validate Attributes" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"> - <elementProp name="isAjax" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">true</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">isAjax</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="form_key" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${admin_form_key}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">form_key</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="product[product_has_weight]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">1</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">product[product_has_weight]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="product[use_config_gift_message_available]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">1</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">product[use_config_gift_message_available]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="product[use_config_gift_wrapping_available]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">1</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">product[use_config_gift_wrapping_available]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="inventory[qty]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${quantity}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">inventory[qty]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="attributes[price]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${price}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">attributes[price]</stringProp> - </elementProp> - <elementProp name="attributes[visibility]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${visibility}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">attributes[visibility]</stringProp> - </elementProp> - </collectionProp> - </elementProp> - <stringProp name="HTTPSampler.domain"/> - <stringProp name="HTTPSampler.port"/> - <stringProp name="HTTPSampler.connect_timeout">60000</stringProp> - <stringProp name="HTTPSampler.response_timeout">200000</stringProp> - <stringProp name="HTTPSampler.protocol">${request_protocol}</stringProp> - <stringProp name="HTTPSampler.contentEncoding"/> - <stringProp name="HTTPSampler.path">${base_path}${admin_path}/catalog/product_action_attribute/validate</stringProp> - <stringProp name="HTTPSampler.method">POST</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"/> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/admin_browse_products_grid/products_grid_mass_actions/change_attributes.jmx</stringProp></HTTPSamplerProxy> - <hashTree> - <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true"> - <collectionProp name="Asserion.test_strings"> - <stringProp name="1853918323">{"error":false}</stringProp> - </collectionProp> - <stringProp name="Assertion.test_field">Assertion.response_data</stringProp> - <boolProp name="Assertion.assume_success">false</boolProp> - <intProp name="Assertion.test_type">2</intProp> - </ResponseAssertion> - <hashTree/> - </hashTree> - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Save Attributes" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"> - <elementProp name="isAjax" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">true</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">isAjax</stringProp> - <stringProp name="Argument.desc">false</stringProp> - </elementProp> - <elementProp name="form_key" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${admin_form_key}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">form_key</stringProp> - <stringProp name="Argument.desc">false</stringProp> - </elementProp> - <elementProp name="product[product_has_weight]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">1</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">product[product_has_weight]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="product[use_config_gift_message_available]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">1</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">product[use_config_gift_message_available]</stringProp> - </elementProp> - <elementProp name="product[use_config_gift_wrapping_available]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">1</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">product[use_config_gift_wrapping_available]</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="inventory[qty]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${quantity}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">inventory[qty]</stringProp> - </elementProp> - <elementProp name="toggle_qty" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">on</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">toggle_price</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="attributes[price]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${price}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">attributes[price]</stringProp> - </elementProp> - <elementProp name="toggle_price" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">on</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">toggle_price</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - <elementProp name="attributes[visibility]" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">${visibility}</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">attributes[visibility]</stringProp> - </elementProp> - <elementProp name="toggle_visibility" elementType="HTTPArgument"> - <boolProp name="HTTPArgument.always_encode">true</boolProp> - <stringProp name="Argument.value">on</stringProp> - <stringProp name="Argument.metadata">=</stringProp> - <boolProp name="HTTPArgument.use_equals">true</boolProp> - <stringProp name="Argument.name">toggle_visibility</stringProp> - <stringProp name="Argument.desc">true</stringProp> - </elementProp> - </collectionProp> - </elementProp> - <stringProp name="HTTPSampler.domain"/> - <stringProp name="HTTPSampler.port"/> - <stringProp name="HTTPSampler.connect_timeout">60000</stringProp> - <stringProp name="HTTPSampler.response_timeout">200000</stringProp> - <stringProp name="HTTPSampler.protocol">${request_protocol}</stringProp> - <stringProp name="HTTPSampler.contentEncoding"/> - <stringProp name="HTTPSampler.path">${base_path}${admin_path}/catalog/product_action_attribute/save/store/0/active_tab/attributes</stringProp> - <stringProp name="HTTPSampler.method">POST</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">true</boolProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"/> - </HTTPSamplerProxy> - <hashTree> - <ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true"> - <collectionProp name="Asserion.test_strings"> - <stringProp name="1848809106">were updated.</stringProp> - </collectionProp> - <stringProp name="Assertion.test_field">Assertion.response_data</stringProp> - <boolProp name="Assertion.assume_success">false</boolProp> - <intProp name="Assertion.test_type">2</intProp> - </ResponseAssertion> - <hashTree/> - </hashTree> -</hashTree> - - <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="Logout" enabled="true"> - <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true"> - <collectionProp name="Arguments.arguments"/> - </elementProp> - <stringProp name="HTTPSampler.domain"/> - <stringProp name="HTTPSampler.port"/> - <stringProp name="HTTPSampler.connect_timeout">60000</stringProp> - <stringProp name="HTTPSampler.response_timeout">200000</stringProp> - <stringProp name="HTTPSampler.protocol">${request_protocol}</stringProp> - <stringProp name="HTTPSampler.contentEncoding"/> - <stringProp name="HTTPSampler.path">${base_path}${admin_path}/admin/auth/logout/</stringProp> - <stringProp name="HTTPSampler.method">GET</stringProp> - <boolProp name="HTTPSampler.follow_redirects">true</boolProp> - <boolProp name="HTTPSampler.auto_redirects">false</boolProp> - <boolProp name="HTTPSampler.use_keepalive">true</boolProp> - <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp> - <boolProp name="HTTPSampler.monitor">false</boolProp> - <stringProp name="HTTPSampler.embedded_url_re"/> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/setup/admin_logout.jmx</stringProp></HTTPSamplerProxy> - <hashTree> - - <BeanShellPostProcessor guiclass="TestBeanGUI" testclass="BeanShellPostProcessor" testname="Return Admin to Pool" enabled="true"> - <boolProp name="resetInterpreter">false</boolProp> - <stringProp name="parameters"/> - <stringProp name="filename"/> - <stringProp name="script"> - adminUsersDistribution = Integer.parseInt(vars.get("admin_users_distribution_per_admin_pool")); - if (adminUsersDistribution == 1) { - adminUserList = props.get("adminUserList"); - adminUserList.add(vars.get("admin_user")); - } - </stringProp> - <stringProp name="TestPlan.comments">mpaf/tool/fragments/ce/common/return_admin_email_to_pool.jmx</stringProp></BeanShellPostProcessor> - <hashTree/> - </hashTree> - </hashTree> - - <ThroughputController guiclass="ThroughputControllerGui" testclass="ThroughputController" testname="Import Products" enabled="true"> <intProp name="ThroughputController.style">1</intProp> <boolProp name="ThroughputController.perThread">false</boolProp> From ab061382a5320bcc486b4a33aa50bad1aa930c70 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@adobe.com> Date: Wed, 6 Mar 2019 18:10:45 -0600 Subject: [PATCH 074/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Product/Action/Attribute/Save.php | 40 ++++++++++++++----- .../Model/Attribute/Backend/Consumer.php | 6 +-- .../Backend/ConsumerWebsiteAssign.php | 6 +-- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index f0b19b2073cc3..5409991477539 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -161,20 +161,38 @@ private function sanitizeProductAttributes($attributesData) */ private function publish($attributesData, $websiteRemoveData, $websiteAddData, $storeId, $websiteId, $productIds):void { + $productIdsChunks = array_chunk($productIds, 100); $bulkUuid = $this->identityService->generateId(); - $bulkDescription = __('Update attributes to selected products'); + $bulkDescription = __('Update attributes to ' . count($productIds) . ' selected products'); $operations = []; - if ($websiteRemoveData || $websiteAddData) { - $dataToUpdate = [ - 'website_assign' => $websiteAddData, - 'website_detach' => $websiteRemoveData - ]; - - $operations[] = $this->makeOperation('Update website assign', 'product_action_attribute.website.update', $dataToUpdate, $storeId, $websiteId, $productIds, $bulkUuid); - } + foreach($productIdsChunks as $productIdsChunk) { + if ($websiteRemoveData || $websiteAddData) { + $dataToUpdate = [ + 'website_assign' => $websiteAddData, + 'website_detach' => $websiteRemoveData + ]; + $operations[] = $this->makeOperation( + 'Update website assign', + 'product_action_attribute.website.update', + $dataToUpdate, + $storeId, + $websiteId, + $productIdsChunk, + $bulkUuid + ); + } - if ($attributesData) { - $operations[] = $this->makeOperation('Update product attributes', 'product_action_attribute.update', $attributesData, $storeId, $websiteId, $productIds, $bulkUuid); + if ($attributesData) { + $operations[] = $this->makeOperation( + 'Update product attributes', + 'product_action_attribute.update', + $attributesData, + $storeId, + $websiteId, + $productIdsChunk, + $bulkUuid + ); + } } if (!empty($operations)) { diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php index 7e6c68a1502e0..f9c90f82dacd4 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php @@ -99,9 +99,7 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf $this->execute($data); } catch (\Zend_Db_Adapter_Exception $e) { - //here sample how to process exceptions if they occurred $this->logger->critical($e->getMessage()); - //you can add here your own type of exception when operation can be retried if ( $e instanceof \Magento\Framework\DB\Adapter\LockWaitException || $e instanceof \Magento\Framework\DB\Adapter\DeadlockException @@ -113,7 +111,7 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf } else { $status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; $errorCode = $e->getCode(); - $message = __('Sorry, something went wrong during product prices update. Please see log for details.'); + $message = __('Sorry, something went wrong during product attributes update. Please see log for details.'); } } catch (NoSuchEntityException $e) { $this->logger->critical($e->getMessage()); @@ -131,7 +129,7 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf $this->logger->critical($e->getMessage()); $status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; $errorCode = $e->getCode(); - $message = __('Sorry, something went wrong during product prices update. Please see log for details.'); + $message = __('Sorry, something went wrong during product attributes update. Please see log for details.'); } $operation->setStatus($status ?? OperationInterface::STATUS_TYPE_COMPLETE) diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php b/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php index f8cc3c04df605..591c0892b4228 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php @@ -91,9 +91,7 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf $data = $this->serializer->unserialize($serializedData); $this->execute($data); } catch (\Zend_Db_Adapter_Exception $e) { - //here sample how to process exceptions if they occurred $this->logger->critical($e->getMessage()); - //you can add here your own type of exception when operation can be retried if ( $e instanceof \Magento\Framework\DB\Adapter\LockWaitException || $e instanceof \Magento\Framework\DB\Adapter\DeadlockException @@ -105,7 +103,7 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf } else { $status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; $errorCode = $e->getCode(); - $message = __('Sorry, something went wrong during product prices update. Please see log for details.'); + $message = __('Sorry, something went wrong during product attributes update. Please see log for details.'); } } catch (NoSuchEntityException $e) { $this->logger->critical($e->getMessage()); @@ -123,7 +121,7 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf $this->logger->critical($e->getMessage()); $status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; $errorCode = $e->getCode(); - $message = __('Sorry, something went wrong during product prices update. Please see log for details.'); + $message = __('Sorry, something went wrong during product attributes update. Please see log for details.'); } $operation->setStatus($status ?? OperationInterface::STATUS_TYPE_COMPLETE) From 3ab52fff4ea2d3d027a51487c89a1ba1fb6a45ef Mon Sep 17 00:00:00 2001 From: Tom Reece <treece@adobe.com> Date: Thu, 7 Mar 2019 11:24:08 -0600 Subject: [PATCH 075/162] MC-4455: Convert CreateDuplicateUrlProductEntity to MFTF - Refactor to decompose an action group that isnt reusable --- .../ActionGroup/AdminProductActionGroup.xml | 69 +++++++++++-------- .../Test/AdminCreateDuplicateProductTest.xml | 30 ++++++-- 2 files changed, 64 insertions(+), 35 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml index 709f74ede09aa..4b4633b374e60 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml @@ -20,7 +20,7 @@ <see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Product" stepKey="seeNewProductTitle"/> </actionGroup> - <!--Fill main fields in create product form--> + <!-- Fill main fields in create product form using a product entity --> <actionGroup name="fillMainProductForm"> <arguments> <argument name="product" defaultValue="_defaultProduct"/> @@ -34,6 +34,25 @@ <fillField selector="{{AdminProductFormSection.productWeight}}" userInput="{{product.weight}}" stepKey="fillProductWeight"/> </actionGroup> + <!-- Fill main fields in create product form using strings for flexibility --> + <actionGroup name="FillMainProductFormByString"> + <arguments> + <argument name="productName" type="string"/> + <argument name="productSku" type="string"/> + <argument name="productPrice" type="string"/> + <argument name="productQuantity" type="string"/> + <argument name="productStatus" type="string"/> + <argument name="productWeight" type="string"/> + </arguments> + <fillField selector="{{AdminProductFormSection.productName}}" userInput="{{productName}}" stepKey="fillProductName"/> + <fillField selector="{{AdminProductFormSection.productSku}}" userInput="{{productSku}}" stepKey="fillProductSku"/> + <fillField selector="{{AdminProductFormSection.productPrice}}" userInput="{{productPrice}}" stepKey="fillProductPrice"/> + <fillField selector="{{AdminProductFormSection.productQuantity}}" userInput="{{productQuantity}}" stepKey="fillProductQty"/> + <selectOption selector="{{AdminProductFormSection.productStockStatus}}" userInput="{{productStatus}}" stepKey="selectStockStatus"/> + <selectOption selector="{{AdminProductFormSection.productWeightSelect}}" userInput="This item has weight" stepKey="selectWeight"/> + <fillField selector="{{AdminProductFormSection.productWeight}}" userInput="{{productWeight}}" stepKey="fillProductWeight"/> + </actionGroup> + <!--Fill main fields in create product form with no weight, useful for virtual and downloadable products --> <actionGroup name="fillMainProductFormNoWeight"> <arguments> @@ -77,6 +96,11 @@ <see selector="{{AdminProductMessagesSection.successMessage}}" userInput="You saved the product." stepKey="seeSaveConfirmation"/> </actionGroup> + <!-- Save product but do not expect a success message --> + <actionGroup name="SaveProductFormNoSuccessCheck" extends="saveProductForm"> + <remove keyForRemoval="seeSaveConfirmation"/> + </actionGroup> + <!--Upload image for product--> <actionGroup name="addProductImage"> <arguments> @@ -387,6 +411,22 @@ <click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="openSeoSection"/> <fillField userInput="{{product.urlKey}}" selector="{{AdminProductSEOSection.urlKeyInput}}" stepKey="fillUrlKey"/> </actionGroup> + + <actionGroup name="SetProductUrlKeyByString"> + <arguments> + <argument name="urlKey" type="string"/> + </arguments> + <click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="openSeoSection"/> + <fillField userInput="{{urlKey}}" selector="{{AdminProductSEOSection.urlKeyInput}}" stepKey="fillUrlKey"/> + </actionGroup> + + <actionGroup name="SetCategoryByName"> + <arguments> + <argument name="categoryName" type="string"/> + </arguments> + <searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="[{{categoryName}}]" stepKey="searchAndSelectCategory"/> + </actionGroup> + <actionGroup name="expandAdminProductSection"> <arguments> <argument name="sectionSelector" defaultValue="{{AdminProductContentSection.sectionHeader}}" type="string"/> @@ -430,31 +470,4 @@ <click selector="{{AdminAddUpSellProductsModalSection.AddSelectedProductsButton}}" stepKey="addRelatedProductSelected"/> <waitForPageLoad stepKey="waitForPageToLoad1"/> </actionGroup> - <actionGroup name="adminFillAndSaveProductForm"> - <arguments> - <argument name="product" defaultValue="defaultSimpleProduct"/> - <argument name="productName" type="string"/> - <argument name="productUrlKey" type="string"/> - <argument name="categoryName" type="string"/> - </arguments> - <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="openProductIndexPage"/> - <waitForPageLoad stepKey="waitForProductIndexPageToLoad"/> - <click selector="{{AdminProductGridActionSection.addProductBtn}}" stepKey="clickOnAddNewProduct"/> - <waitForPageLoad stepKey="waitForPageToLoad"/> - <fillField selector="{{AdminProductFormSection.productName}}" userInput="{{productName}}" stepKey="fillProductName"/> - <fillField selector="{{AdminProductFormSection.productSku}}" userInput="{{product.sku}}" stepKey="fillProductSku"/> - <fillField selector="{{AdminProductFormSection.productPrice}}" userInput="{{product.price}}" stepKey="fillProductPrice"/> - <fillField selector="{{AdminProductFormSection.productQuantity}}" userInput="{{product.quantity}}" stepKey="fillProductQty"/> - <selectOption selector="{{AdminProductFormSection.productStockStatus}}" userInput="{{product.status}}" stepKey="selectStockStatus"/> - <selectOption selector="{{AdminProductFormSection.productWeightSelect}}" userInput="This item has weight" stepKey="selectWeight"/> - <fillField selector="{{AdminProductFormSection.productWeight}}" userInput="{{product.weight}}" stepKey="fillProductWeight"/> - <searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="[{{categoryName}}]" stepKey="searchAndSelectCategory"/> - <scrollTo selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="scrollToSectionHeader"/> - <click selector="{{AdminProductSEOSection.sectionHeader}}" stepKey="openSeoSection"/> - <fillField userInput="{{productUrlKey}}" selector="{{AdminProductSEOSection.urlKeyInput}}" stepKey="fillUrlKey"/> - <scrollToTopOfPage stepKey="scrollTopPageProduct"/> - <waitForElementVisible selector="{{AdminProductFormActionSection.saveButton}}" stepKey="waitForSaveProductButton" /> - <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveProduct"/> - <waitForPageLoad stepKey="waitForProductToSave"/> - </actionGroup> </actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateProductTest.xml index 68dfc44aa886a..575bb56912b25 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateProductTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDuplicateProductTest.xml @@ -18,28 +18,44 @@ </annotations> <before> - <magentoCLI command="cache:flush" stepKey="flushCache"/> - <actionGroup ref="LoginAsAdmin" stepKey="login"/> <createData entity="SubCategory" stepKey="category"/> <createData entity="Two_nested_categories" stepKey="subCategory"> <requiredEntity createDataKey="category"/> </createData> + <actionGroup ref="LoginAsAdmin" stepKey="login"/> </before> + <after> <deleteData createDataKey="subCategory" stepKey="deleteSubCategory"/> <deleteData createDataKey="category" stepKey="deleteCategory"/> <actionGroup ref="logout" stepKey="logout"/> </after> - <!-- Create Product using above created Subcategory Name and SubCategory UrlKey and Save the Product --> - <actionGroup ref="adminFillAndSaveProductForm" stepKey="createDuplicateProduct"> - <argument name="product" value="defaultSimpleProduct"/> + <!-- Go to new simple product page --> + <actionGroup ref="GoToSpecifiedCreateProductPage" stepKey="goToCreateProductPage"/> + + <!-- Fill the main fields in the form --> + <actionGroup ref="FillMainProductFormByString" stepKey="fillMainProductForm"> <argument name="productName" value="$$subCategory.name$$"/> - <argument name="productUrlKey" value="$$subCategory.custom_attributes[url_key]$$"/> + <argument name="productSku" value="{{defaultSimpleProduct.sku}}"/> + <argument name="productPrice" value="{{defaultSimpleProduct.price}}"/> + <argument name="productQuantity" value="{{defaultSimpleProduct.quantity}}"/> + <argument name="productStatus" value="{{defaultSimpleProduct.status}}"/> + <argument name="productWeight" value="{{defaultSimpleProduct.weight}}"/> + </actionGroup> + + <!-- Select the category that we created in the before block --> + <actionGroup ref="SetCategoryByName" stepKey="setCategory"> <argument name="categoryName" value="$$category.name$$"/> </actionGroup> - <!--Assert Error Message --> + <!-- Set the url key to match the subcategory created in the before block --> + <actionGroup ref="SetProductUrlKeyByString" stepKey="fillUrlKey"> + <argument name="urlKey" value="$$subCategory.custom_attributes[url_key]$$"/> + </actionGroup> + + <!-- Save the product and expect to see an error message --> + <actionGroup ref="SaveProductFormNoSuccessCheck" stepKey="tryToSaveProduct"/> <see selector="{{AdminProductFormSection.successMessage}}" userInput="The value specified in the URL Key field would generate a URL that already exists." stepKey="seeErrorMessage"/> </test> </tests> From 5b4944d435525b0a88009a4f718986d322591782 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Thu, 7 Mar 2019 16:17:22 -0600 Subject: [PATCH 076/162] MC-13613: Product mass update --- .../CatalogInventory/Plugin/MassUpdateProductAttribute.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php b/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php index 36958a37c6d1a..e565f609611c2 100644 --- a/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php +++ b/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php @@ -109,7 +109,9 @@ public function aroundExecute(Save $subject, callable $proceed) $websiteId = $this->storeManager->getStore($storeId)->getWebsiteId(); $productIds = $this->session->getData('product_ids'); $inventoryData = $this->addConfigSettings($inventoryData); - $this->updateInventoryInProducts($productIds, $websiteId, $inventoryData); + if (!empty($inventoryData)) { + $this->updateInventoryInProducts($productIds, $websiteId, $inventoryData); + } return $proceed(); } catch (\Magento\Framework\Exception\LocalizedException $e) { From afa0320e4dd40dd61ba49205dbf56a94b4f018e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= <karlasaaremae@gmail.com> Date: Fri, 8 Mar 2019 13:48:06 +0200 Subject: [PATCH 077/162] remove refactored code not needed with correct html classes --- .../css/source/module/checkout/_fields.less | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_fields.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_fields.less index 4479c070a4e17..8dec680b58726 100644 --- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_fields.less +++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_fields.less @@ -55,31 +55,3 @@ } } } - -// -// Desktop -// _____________________________________________ - -.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) { - // ToDo UI: remove with global blank theme .field.required update - .opc-wrapper { - .fieldset { - > .field { - &.required, - &._required { - position: relative; - - > label { - padding-right: 25px; - - &:after { - margin-left: @indent__s; - position: absolute; - top: 9px; - } - } - } - } - } - } -} From 92d93f5433b2967afeeda07624d11afe29787031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= <karlasaaremae@gmail.com> Date: Fri, 8 Mar 2019 13:52:26 +0200 Subject: [PATCH 078/162] fix asterisk added correct class for asterisk --- .../frontend/web/template/checkout/checkout-agreements.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html b/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html index a448537d64e83..db9da71ebf739 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html @@ -5,17 +5,17 @@ */ --> <div data-role="checkout-agreements"> - <div class="checkout-agreements" data-bind="visible: isVisible"> + <div class="checkout-agreements fieldset" data-bind="visible: isVisible"> <!-- ko foreach: agreements --> <!-- ko if: ($parent.isAgreementRequired($data)) --> - <div class="checkout-agreement required"> + <div class="checkout-agreement field required"> <input type="checkbox" class="required-entry" data-bind="attr: { 'id': $parent.getCheckboxId($parentContext, agreementId), 'name': 'agreement[' + agreementId + ']', 'value': agreementId }"/> - <label data-bind="attr: {'for': $parent.getCheckboxId($parentContext, agreementId)}"> + <label class="label" data-bind="attr: {'for': $parent.getCheckboxId($parentContext, agreementId)}"> <button type="button" class="action action-show" data-bind="click: function(data, event) { return $parent.showContent(data, event) }" From 95653906830a6dfaf503400d3e057fcf03d1e3cf Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Fri, 8 Mar 2019 09:16:32 -0600 Subject: [PATCH 079/162] MC-13613: Product mass update --- .../Product/Action/Attribute/Save.php | 45 +++++++++++++------ .../Api/Data/PoisonPillInterface.php | 2 + .../Api/PoisonPillCompareInterface.php | 2 +- .../MessageQueue/Model/CallbackInvoker.php | 7 ++- .../Magento/MessageQueue/Model/PoisonPill.php | 2 +- .../MessageQueue/Model/PoisonPillCompare.php | 5 ++- .../MessageQueue/Model/PoisonPillFactory.php | 2 +- .../Model/ResourceModel/PoisonPill.php | 2 +- .../MessageQueue/CallbackInvokerInterface.php | 3 ++ 9 files changed, 49 insertions(+), 21 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index 5409991477539..9a6893a1aff83 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -10,7 +10,6 @@ use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Backend\App\Action; use Magento\Framework\Stdlib\DateTime\TimezoneInterface; -use Magento\Framework\App\ObjectManager; /** * Class Save @@ -42,11 +41,6 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribut */ private $userContext; - /** - * @var ObjectManager - */ - private $objectManager; - /** * @param Action\Context $context * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper @@ -71,13 +65,12 @@ public function __construct( $this->identityService = $identityService; $this->serializer = $serializer; $this->userContext = $userContext; - $this->objectManager = ObjectManager::getInstance(); } /** * Update product attributes * - * @return \Magento\Backend\Model\View\Result\Redirect + * @return \Magento\Framework\Controller\Result\Redirect */ public function execute() { @@ -89,6 +82,7 @@ public function execute() $attributesData = $this->getRequest()->getParam('attributes', []); $websiteRemoveData = $this->getRequest()->getParam('remove_website_ids', []); $websiteAddData = $this->getRequest()->getParam('add_website_ids', []); + $storeId = $this->attributeHelper->getSelectedStoreId(); $websiteId = $this->attributeHelper->getStoreWebsiteId($storeId); $productIds = $this->attributeHelper->getProductIds(); @@ -110,10 +104,17 @@ public function execute() return $this->resultRedirectFactory->create()->setPath('catalog/product/', ['store' => $storeId]); } + /** + * Sanitize product attributes + * + * @param $attributesData + * + * @return array + */ private function sanitizeProductAttributes($attributesData) { - $dateFormat = $this->objectManager->get(TimezoneInterface::class)->getDateFormat(\IntlDateFormatter::SHORT); - $config = $this->objectManager->get(\Magento\Eav\Model\Config::class); + $dateFormat = $this->_objectManager->get(TimezoneInterface::class)->getDateFormat(\IntlDateFormatter::SHORT); + $config = $this->_objectManager->get(\Magento\Eav\Model\Config::class); foreach ($attributesData as $attributeCode => $value) { $attribute = $config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $attributeCode); @@ -149,7 +150,7 @@ private function sanitizeProductAttributes($attributesData) } /** - * Schedule new bulk. + * Schedule new bulk * * @param $attributesData * @param $websiteRemoveData @@ -157,6 +158,8 @@ private function sanitizeProductAttributes($attributesData) * @param $storeId * @param $websiteId * @param $productIds + * @throws \Magento\Framework\Exception\LocalizedException + * * @return void */ private function publish($attributesData, $websiteRemoveData, $websiteAddData, $storeId, $websiteId, $productIds):void @@ -196,7 +199,12 @@ private function publish($attributesData, $websiteRemoveData, $websiteAddData, $ } if (!empty($operations)) { - $result = $this->bulkManagement->scheduleBulk($bulkUuid, $operations, $bulkDescription, $this->userContext->getUserId()); + $result = $this->bulkManagement->scheduleBulk( + $bulkUuid, + $operations, + $bulkDescription, + $this->userContext->getUserId() + ); if (!$result) { throw new \Magento\Framework\Exception\LocalizedException( __('Something went wrong while processing the request.') @@ -206,6 +214,7 @@ private function publish($attributesData, $websiteRemoveData, $websiteAddData, $ } /** + * Make asynchronous operation * @param $meta * @param $queue * @param $dataToUpdate @@ -213,10 +222,18 @@ private function publish($attributesData, $websiteRemoveData, $websiteAddData, $ * @param $websiteId * @param $productIds * @param $bulkUuid + * * @return OperationInterface */ - private function makeOperation($meta, $queue, $dataToUpdate, $storeId, $websiteId, $productIds, $bulkUuid): OperationInterface - { + private function makeOperation( + $meta, + $queue, + $dataToUpdate, + $storeId, + $websiteId, + $productIds, + $bulkUuid + ): OperationInterface { $dataToEncode = [ 'meta_information' => $meta, 'product_ids' => $productIds, diff --git a/app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php b/app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php index f526e0d4ea067..b48d6d585492a 100644 --- a/app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php +++ b/app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php @@ -22,6 +22,8 @@ interface PoisonPillInterface public function getVersion(): ?int; /** + * Set version of poison pill. + * * @param int $version * @return void */ diff --git a/app/code/Magento/MessageQueue/Api/PoisonPillCompareInterface.php b/app/code/Magento/MessageQueue/Api/PoisonPillCompareInterface.php index 32d57353f4426..e2df3d69ca0aa 100644 --- a/app/code/Magento/MessageQueue/Api/PoisonPillCompareInterface.php +++ b/app/code/Magento/MessageQueue/Api/PoisonPillCompareInterface.php @@ -17,7 +17,7 @@ interface PoisonPillCompareInterface { /** - * Check is version of current poison pill is latest. + * Check if version of current poison pill is latest. * * @param PoisonPillInterface $poisonPill * @return bool diff --git a/app/code/Magento/MessageQueue/Model/CallbackInvoker.php b/app/code/Magento/MessageQueue/Model/CallbackInvoker.php index 465c2d366c582..a61a6862843b3 100644 --- a/app/code/Magento/MessageQueue/Model/CallbackInvoker.php +++ b/app/code/Magento/MessageQueue/Model/CallbackInvoker.php @@ -1,7 +1,7 @@ <?php /** * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. + * See COPYING.txt for license details. */ declare(strict_types=1); @@ -13,6 +13,9 @@ use Magento\MessageQueue\Api\PoisonPillCompareInterface; use Magento\MessageQueue\Api\PoisonPillReadInterface; +/** + * Callback invoker + */ class CallbackInvoker implements CallbackInvokerInterface { /** @@ -39,7 +42,6 @@ public function __construct( PoisonPillCompareInterface $poisonPillCompare ) { $this->poisonPillRead = $poisonPillRead; - $this->poisonPill = $poisonPillRead->getLatest(); $this->poisonPillCompare = $poisonPillCompare; } @@ -48,6 +50,7 @@ public function __construct( */ public function invoke(QueueInterface $queue, $maxNumberOfMessages, $callback) { + $this->poisonPill = $this->poisonPillRead->getLatest(); for ($i = $maxNumberOfMessages; $i > 0; $i--) { do { $message = $queue->dequeue(); diff --git a/app/code/Magento/MessageQueue/Model/PoisonPill.php b/app/code/Magento/MessageQueue/Model/PoisonPill.php index a253ca4c13aa0..ac70034a85da5 100644 --- a/app/code/Magento/MessageQueue/Model/PoisonPill.php +++ b/app/code/Magento/MessageQueue/Model/PoisonPill.php @@ -1,7 +1,7 @@ <?php /** * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. + * See COPYING.txt for license details. */ declare(strict_types=1); diff --git a/app/code/Magento/MessageQueue/Model/PoisonPillCompare.php b/app/code/Magento/MessageQueue/Model/PoisonPillCompare.php index 4aa76b4fadfcc..6155526287555 100644 --- a/app/code/Magento/MessageQueue/Model/PoisonPillCompare.php +++ b/app/code/Magento/MessageQueue/Model/PoisonPillCompare.php @@ -1,7 +1,7 @@ <?php /** * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. + * See COPYING.txt for license details. */ declare(strict_types=1); @@ -11,6 +11,9 @@ use Magento\MessageQueue\Api\PoisonPillCompareInterface; use Magento\MessageQueue\Api\PoisonPillReadInterface; +/** + * Poison pill compare + */ class PoisonPillCompare implements PoisonPillCompareInterface { /** diff --git a/app/code/Magento/MessageQueue/Model/PoisonPillFactory.php b/app/code/Magento/MessageQueue/Model/PoisonPillFactory.php index 0fd85c998866b..0f2857fd6ec5c 100644 --- a/app/code/Magento/MessageQueue/Model/PoisonPillFactory.php +++ b/app/code/Magento/MessageQueue/Model/PoisonPillFactory.php @@ -1,7 +1,7 @@ <?php /** * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. + * See COPYING.txt for license details. */ declare(strict_types=1); diff --git a/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php b/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php index 769f723dc9d5a..dab251ce50c83 100644 --- a/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php +++ b/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php @@ -1,7 +1,7 @@ <?php /** * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. + * See COPYING.txt for license details. */ declare(strict_types=1); diff --git a/lib/internal/Magento/Framework/MessageQueue/CallbackInvokerInterface.php b/lib/internal/Magento/Framework/MessageQueue/CallbackInvokerInterface.php index bae72d8186a18..36658f2e4eebe 100644 --- a/lib/internal/Magento/Framework/MessageQueue/CallbackInvokerInterface.php +++ b/lib/internal/Magento/Framework/MessageQueue/CallbackInvokerInterface.php @@ -7,6 +7,9 @@ namespace Magento\Framework\MessageQueue; +/** + * Callback invoker interface + */ interface CallbackInvokerInterface { /** From 590383107c2f000950d5057084bdd36eef8e5320 Mon Sep 17 00:00:00 2001 From: Vladimir Fishchenko <hws47a@gmail.com> Date: Fri, 8 Mar 2019 17:11:51 +0100 Subject: [PATCH 080/162] magento/magento-functional-tests-migration#417: Convert CreateCustomOrderStatusEntityTest to MFTF --- ...nOrderStatusFormFillAndSaveActionGroup.xml | 22 ++++++++++ ...sertOrderStatusExistsInGridActionGroup.xml | 24 ++++++++++ ...tatusFormSaveDuplicateErrorActionGroup.xml | 15 +++++++ ...tOrderStatusFormSaveSuccessActionGroup.xml | 15 +++++++ .../Sales/Test/Mftf/Data/OrderStatusData.xml | 23 ++++++++++ .../Test/Mftf/Page/AdminOrderStatusPage.xml | 14 ++++++ .../Section/AdminOrderStatusFormSection.xml | 15 +++++++ .../Section/AdminOrderStatusGridSection.xml | 16 +++++++ ...inCreateOrderStatusDuplicatingCodeTest.xml | 38 ++++++++++++++++ ...nCreateOrderStatusDuplicatingLabelTest.xml | 44 +++++++++++++++++++ .../Mftf/Test/AdminCreateOrderStatusTest.xml | 44 +++++++++++++++++++ .../CreateCustomOrderStatusEntityTest.xml | 3 ++ 12 files changed, 273 insertions(+) create mode 100644 app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderStatusFormFillAndSaveActionGroup.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusExistsInGridActionGroup.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusFormSaveDuplicateErrorActionGroup.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusFormSaveSuccessActionGroup.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/Data/OrderStatusData.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/Page/AdminOrderStatusPage.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/Section/AdminOrderStatusFormSection.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/Section/AdminOrderStatusGridSection.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingCodeTest.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingLabelTest.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusTest.xml diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderStatusFormFillAndSaveActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderStatusFormFillAndSaveActionGroup.xml new file mode 100644 index 0000000000000..cb27439a9d886 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderStatusFormFillAndSaveActionGroup.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"> + <!-- Fill Order status form and click save --> + <actionGroup name="AdminOrderStatusFormFillAndSave"> + <arguments> + <argument name="status" type="string" defaultValue=""/> + <argument name="label" type="string" defaultValue=""/> + </arguments> + + <fillField stepKey="fillStatusCode" selector="{{AdminOrderStatusFormSection.statusCodeField}}" userInput="{{status}}"/> + <fillField stepKey="fillStatusLabel" selector="{{AdminOrderStatusFormSection.statusLabelField}}" userInput="{{label}}"/> + <click stepKey="clickSaveStatus" selector="{{AdminMainActionsSection.save}}"/> + </actionGroup> +</actionGroups> \ No newline at end of file diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusExistsInGridActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusExistsInGridActionGroup.xml new file mode 100644 index 0000000000000..bbb6aa71b8938 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusExistsInGridActionGroup.xml @@ -0,0 +1,24 @@ +<?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"> + <!-- Search order status grid for item with a specific code and validate data --> + <actionGroup name="AssertOrderStatusExistsInGrid"> + <arguments> + <argument name="status" type="string" defaultValue=""/> + <argument name="label" type="string" defaultValue=""/> + </arguments> + + <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters"/> + <fillField selector="{{AdminOrderStatusGridSection.statusCodeFilterField}}" userInput="{{status}}" stepKey="fillStatusFilter"/> + <click selector="{{AdminSecondaryGridSection.searchButton}}" stepKey="clickSearch"/> + <see selector="{{AdminOrderStatusGridSection.statusCodeDataColumn}}" userInput="{{status}}" stepKey="seeStatusCodeInGrid"/> + <see selector="{{AdminOrderStatusGridSection.statusLabelDataColumn}}" userInput="{{label}}" stepKey="seeStatusLabelInGrid"/> + </actionGroup> +</actionGroups> \ No newline at end of file diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusFormSaveDuplicateErrorActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusFormSaveDuplicateErrorActionGroup.xml new file mode 100644 index 0000000000000..5b4c3115744c9 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusFormSaveDuplicateErrorActionGroup.xml @@ -0,0 +1,15 @@ +<?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"> + <!-- Assert that order status is not saved with duplication error message --> + <actionGroup name="AssertOrderStatusFormSaveDuplicateError"> + <see selector="{{AdminMessagesSection.error}}" userInput="We found another order status with the same order status code." stepKey="seeError"/> + </actionGroup> +</actionGroups> \ No newline at end of file diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusFormSaveSuccessActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusFormSaveSuccessActionGroup.xml new file mode 100644 index 0000000000000..d82f4b9dd25e8 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusFormSaveSuccessActionGroup.xml @@ -0,0 +1,15 @@ +<?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"> + <!-- Assert that order status saved with success message --> + <actionGroup name="AssertOrderStatusFormSaveSuccess"> + <see selector="{{AdminMessagesSection.success}}" userInput="You saved the order status." stepKey="seeSuccess"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Sales/Test/Mftf/Data/OrderStatusData.xml b/app/code/Magento/Sales/Test/Mftf/Data/OrderStatusData.xml new file mode 100644 index 0000000000000..aecd7fcf1b703 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Data/OrderStatusData.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="defaultOrderStatus"> + <data key="status" unique="suffix">order_status</data> + <data key="label" unique="suffix">orderLabel</data> + </entity> + <entity name="duplicatingCodeOrderStatus"> + <data key="status">pending</data> + <data key="label" unique="suffix">orderLabel</data> + </entity> + <entity name="duplicatingLabelOrderStatus"> + <data key="status" unique="suffix">order_status</data> + <data key="label">Suspected Fraud</data> + </entity> +</entities> diff --git a/app/code/Magento/Sales/Test/Mftf/Page/AdminOrderStatusPage.xml b/app/code/Magento/Sales/Test/Mftf/Page/AdminOrderStatusPage.xml new file mode 100644 index 0000000000000..b158e4923074a --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Page/AdminOrderStatusPage.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="AdminOrderStatusPage" url="sales/order_status" area="admin" module="Magento_Sales"> + <section name="AdminOrderStatusFormSection"/> + </page> +</pages> diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderStatusFormSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderStatusFormSection.xml new file mode 100644 index 0000000000000..1058b2d6f2177 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderStatusFormSection.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminOrderStatusFormSection"> + <element name="statusCodeField" type="text" selector="#edit_form [name=status]"/> + <element name="statusLabelField" type="text" selector="#edit_form [name=label]"/> + </section> +</sections> \ No newline at end of file diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderStatusGridSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderStatusGridSection.xml new file mode 100644 index 0000000000000..b624639281187 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderStatusGridSection.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="AdminOrderStatusGridSection"> + <element name="statusCodeFilterField" type="input" selector="[data-role=filter-form] [name=status]"/> + <element name="statusCodeDataColumn" type="input" selector="[data-role=row] [data-column=status]"/> + <element name="statusLabelDataColumn" type="input" selector="[data-role=row] [data-column=label]"/> + </section> +</sections> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingCodeTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingCodeTest.xml new file mode 100644 index 0000000000000..aea1094b4d629 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingCodeTest.xml @@ -0,0 +1,38 @@ +<?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="AdminCreateOrderStatusDuplicatingCodeTest"> + <annotations> + <stories value="Create order status"/> + <title value="Create order status with duplicating code"/> + <description value="Receive error when creating order status with the code which is already exist"/> + <group value="sales"/> + <group value="mtf_migrated"/> + <severity value="AVERAGE"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Go to new order status page --> + <amOnPage url="{{AdminOrderStatusPage.url}}" stepKey="goToOrderStatusPage"/> + <click selector="{{AdminMainActionsSection.add}}" stepKey="clickCreateNewStatus"/> + + <!-- Fill the form and validate message --> + <actionGroup ref="AdminOrderStatusFormFillAndSave" stepKey="fillFormAndClickSave"> + <argument name="status" value="{{duplicatingCodeOrderStatus.status}}"/> + <argument name="label" value="{{duplicatingCodeOrderStatus.label}}"/> + </actionGroup> + <actionGroup ref="AssertOrderStatusFormSaveDuplicateError" stepKey="seeFormSaveDuplicateError"/> + </test> +</tests> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingLabelTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingLabelTest.xml new file mode 100644 index 0000000000000..95582e107da19 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingLabelTest.xml @@ -0,0 +1,44 @@ +<?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="AdminCreateOrderStatusDuplicatingLabelTest"> + <annotations> + <stories value="Create order status"/> + <title value="Create order status with duplicating label"/> + <description value="Create an order status and get success message"/> + <group value="sales"/> + <group value="mtf_migrated"/> + <severity value="AVERAGE"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Go to new order status page --> + <amOnPage url="{{AdminOrderStatusPage.url}}" stepKey="goToOrderStatusPage"/> + <click selector="{{AdminMainActionsSection.add}}" stepKey="clickCreateNewStatus"/> + + <!-- Fill the form and validate message --> + <actionGroup ref="AdminOrderStatusFormFillAndSave" stepKey="fillFormAndClickSave"> + <argument name="status" value="{{duplicatingLabelOrderStatus.status}}"/> + <argument name="label" value="{{duplicatingLabelOrderStatus.label}}"/> + </actionGroup> + <actionGroup ref="AssertOrderStatusFormSaveSuccess" stepKey="seeFormSaveSuccess"/> + + <!-- Verify the order status grid page shows the order status we just created --> + <actionGroup ref="AssertOrderStatusExistsInGrid" stepKey="searchCreatedOrderStatus"> + <argument name="status" value="{{duplicatingLabelOrderStatus.status}}"/> + <argument name="label" value="{{duplicatingLabelOrderStatus.label}}"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusTest.xml new file mode 100644 index 0000000000000..6fe25160655fc --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusTest.xml @@ -0,0 +1,44 @@ +<?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="AdminCreateOrderStatusTest"> + <annotations> + <stories value="Create custom order status"/> + <title value="Create custom order status"/> + <description value="Tests opening admin order status page, create a new order status with success message"/> + <group value="sales"/> + <group value="mtf_migrated"/> + <severity value="AVERAGE"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Go to new order status page --> + <amOnPage url="{{AdminOrderStatusPage.url}}" stepKey="goToOrderStatusPage"/> + <click selector="{{AdminMainActionsSection.add}}" stepKey="clickCreateNewStatus"/> + + <!-- Fill the form and validate message --> + <actionGroup ref="AdminOrderStatusFormFillAndSave" stepKey="fillFormAndClickSave"> + <argument name="status" value="{{defaultOrderStatus.status}}"/> + <argument name="label" value="{{defaultOrderStatus.label}}"/> + </actionGroup> + <actionGroup ref="AssertOrderStatusFormSaveSuccess" stepKey="seeFormSaveSuccess"/> + + <!-- Verify the order status grid page shows the order status we just created --> + <actionGroup ref="AssertOrderStatusExistsInGrid" stepKey="searchCreatedOrderStatus"> + <argument name="status" value="{{defaultOrderStatus.status}}"/> + <argument name="label" value="{{defaultOrderStatus.label}}"/> + </actionGroup> + </test> +</tests> diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCustomOrderStatusEntityTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCustomOrderStatusEntityTest.xml index 38ce04fa56d81..e05d0fea6b129 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCustomOrderStatusEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateCustomOrderStatusEntityTest.xml @@ -8,17 +8,20 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Sales\Test\TestCase\CreateCustomOrderStatusEntityTest" summary="Create Custom Order Status Entity" ticketId="MAGETWO-23412"> <variation name="CreateCustomOrderStatusEntityTestVariation1"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="orderStatus/data/status" xsi:type="string">order_status%isolation%</data> <data name="orderStatus/data/label" xsi:type="string">orderLabel%isolation%</data> <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusSuccessCreateMessage" /> <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusInGrid" /> </variation> <variation name="CreateCustomOrderStatusEntityTestVariation2"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="orderStatus/data/status" xsi:type="string">pending</data> <data name="orderStatus/data/label" xsi:type="string">orderLabel%isolation%</data> <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusDuplicateStatus" /> </variation> <variation name="CreateCustomOrderStatusEntityTestVariation3"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="orderStatus/data/status" xsi:type="string">order_status%isolation%</data> <data name="orderStatus/data/label" xsi:type="string">Suspected Fraud</data> <constraint name="Magento\Sales\Test\Constraint\AssertOrderStatusSuccessCreateMessage" /> From b0a0c07b9388e5b1159bb33e37e1a5531b96c313 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Fri, 8 Mar 2019 10:37:05 -0600 Subject: [PATCH 081/162] MC-13613: Product mass update --- .../Product/Action/Attribute/Save.php | 44 +++++++++++-------- .../Model/Attribute/Backend/Consumer.php | 16 +++++-- .../Backend/ConsumerWebsiteAssign.php | 31 ++++++++++--- app/code/Magento/Catalog/composer.json | 1 + .../Plugin/MassUpdateProductAttribute.php | 25 +++++++++++ .../Magento/CatalogInventory/composer.json | 1 + .../MessageQueue/Model/CallbackInvoker.php | 1 + .../MessageQueue/Model/PoisonPillFactory.php | 36 --------------- .../Model/ResourceModel/PoisonPill.php | 3 ++ .../PublisherConsumerController.php | 5 +++ .../Product/Action/AttributeTest.php | 16 +++++-- .../Framework/MessageQueue/Consumer.php | 2 +- 12 files changed, 112 insertions(+), 69 deletions(-) delete mode 100644 app/code/Magento/MessageQueue/Model/PoisonPillFactory.php diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index 9a6893a1aff83..63182dd5624e6 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -13,6 +13,7 @@ /** * Class Save + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute implements HttpPostActionInterface { @@ -107,7 +108,7 @@ public function execute() /** * Sanitize product attributes * - * @param $attributesData + * @param array $attributesData * * @return array */ @@ -152,23 +153,29 @@ private function sanitizeProductAttributes($attributesData) /** * Schedule new bulk * - * @param $attributesData - * @param $websiteRemoveData - * @param $websiteAddData - * @param $storeId - * @param $websiteId - * @param $productIds + * @param array $attributesData + * @param array $websiteRemoveData + * @param array $websiteAddData + * @param int $storeId + * @param int $websiteId + * @param array $productIds * @throws \Magento\Framework\Exception\LocalizedException * * @return void */ - private function publish($attributesData, $websiteRemoveData, $websiteAddData, $storeId, $websiteId, $productIds):void - { + private function publish( + $attributesData, + $websiteRemoveData, + $websiteAddData, + $storeId, + $websiteId, + $productIds + ):void { $productIdsChunks = array_chunk($productIds, 100); $bulkUuid = $this->identityService->generateId(); $bulkDescription = __('Update attributes to ' . count($productIds) . ' selected products'); $operations = []; - foreach($productIdsChunks as $productIdsChunk) { + foreach ($productIdsChunks as $productIdsChunk) { if ($websiteRemoveData || $websiteAddData) { $dataToUpdate = [ 'website_assign' => $websiteAddData, @@ -215,13 +222,14 @@ private function publish($attributesData, $websiteRemoveData, $websiteAddData, $ /** * Make asynchronous operation - * @param $meta - * @param $queue - * @param $dataToUpdate - * @param $storeId - * @param $websiteId - * @param $productIds - * @param $bulkUuid + * + * @param string $meta + * @param string $queue + * @param array $dataToUpdate + * @param int $storeId + * @param int $websiteId + * @param array $productIds + * @param int $bulkUuid * * @return OperationInterface */ @@ -252,6 +260,4 @@ private function makeOperation( return $this->operationFactory->create($data); } - } - diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php index f9c90f82dacd4..5785a9f3ccaa7 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php @@ -15,6 +15,7 @@ /** * Consumer for export message. + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Consumer { @@ -88,7 +89,11 @@ public function __construct( } /** + * Process + * * @param \Magento\AsynchronousOperations\Api\Data\OperationInterface $operation + * @throws \Exception + * * @return void */ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterface $operation) @@ -97,7 +102,6 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf $serializedData = $operation->getSerializedData(); $data = $this->serializer->unserialize($serializedData); $this->execute($data); - } catch (\Zend_Db_Adapter_Exception $e) { $this->logger->critical($e->getMessage()); if ( @@ -111,7 +115,9 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf } else { $status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; $errorCode = $e->getCode(); - $message = __('Sorry, something went wrong during product attributes update. Please see log for details.'); + $message = __( + 'Sorry, something went wrong during product attributes update. Please see log for details.' + ); } } catch (NoSuchEntityException $e) { $this->logger->critical($e->getMessage()); @@ -140,7 +146,11 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf } /** - * @param $data + * Execute + * + * @param array $data + * + * @return void */ private function execute($data): void { diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php b/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php index 591c0892b4228..13933b952cad4 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php @@ -15,6 +15,7 @@ /** * Consumer for export message. + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ConsumerWebsiteAssign { @@ -81,7 +82,11 @@ public function __construct( } /** + * Process + * * @param \Magento\AsynchronousOperations\Api\Data\OperationInterface $operation + * @throws \Exception + * * @return void */ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterface $operation) @@ -103,7 +108,9 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf } else { $status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; $errorCode = $e->getCode(); - $message = __('Sorry, something went wrong during product attributes update. Please see log for details.'); + $message = __( + 'Sorry, something went wrong during product attributes update. Please see log for details.' + ); } } catch (NoSuchEntityException $e) { $this->logger->critical($e->getMessage()); @@ -132,9 +139,13 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf } /** - * @param $productIds - * @param $websiteRemoveData - * @param $websiteAddData + * Update website in products + * + * @param array $productIds + * @param array $websiteRemoveData + * @param array $websiteAddData + * + * @return void */ private function updateWebsiteInProducts($productIds, $websiteRemoveData, $websiteAddData): void { @@ -147,11 +158,19 @@ private function updateWebsiteInProducts($productIds, $websiteRemoveData, $websi } /** - * @param $data + * Execute + * + * @param array $data + * + * @return void */ private function execute($data): void { - $this->updateWebsiteInProducts($data['product_ids'], $data['attributes']['website_detach'], $data['attributes']['website_assign']); + $this->updateWebsiteInProducts( + $data['product_ids'], + $data['attributes']['website_detach'], + $data['attributes']['website_assign'] + ); $this->productPriceIndexerProcessor->reindexList($data['product_ids']); $this->productFlatIndexerProcessor->reindexList($data['product_ids']); } diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index 44d051933909b..47e532edfe548 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -7,6 +7,7 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", + "magento/module-asynchronous-operations": "*", "magento/module-backend": "*", "magento/module-catalog-inventory": "*", "magento/module-catalog-rule": "*", diff --git a/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php b/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php index e565f609611c2..dc1d888d2af19 100644 --- a/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php +++ b/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php @@ -8,6 +8,10 @@ use Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Save; use Magento\CatalogInventory\Api\Data\StockItemInterface; +/** + * MassUpdate product attribute. + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class MassUpdateProductAttribute { /** @@ -70,6 +74,7 @@ class MassUpdateProductAttribute * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param \Magento\Backend\Model\View\Result\RedirectFactory $redirectFactory * @param \Magento\Framework\Message\ManagerInterface $messageManager + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\CatalogInventory\Model\Indexer\Stock\Processor $stockIndexerProcessor, @@ -96,7 +101,10 @@ public function __construct( } /** + * Around execute plugin + * * @param Save $subject + * * @return \Magento\Framework\Controller\ResultInterface * * @SuppressWarnings(PHPMD.UnusedFormalParameter) @@ -109,6 +117,7 @@ public function aroundExecute(Save $subject, callable $proceed) $websiteId = $this->storeManager->getStore($storeId)->getWebsiteId(); $productIds = $this->session->getData('product_ids'); $inventoryData = $this->addConfigSettings($inventoryData); + if (!empty($inventoryData)) { $this->updateInventoryInProducts($productIds, $websiteId, $inventoryData); } @@ -126,6 +135,13 @@ public function aroundExecute(Save $subject, callable $proceed) return $this->redirectFactory->create()->setPath('catalog/product/', ['_current' => true]); } + /** + * Add config settings + * + * @param array $inventoryData + * + * @return array + */ private function addConfigSettings($inventoryData) { $options = $this->stockConfiguration->getConfigItemOptions(); @@ -138,6 +154,15 @@ private function addConfigSettings($inventoryData) return $inventoryData; } + /** + * Update inventory in products + * + * @param array $productIds + * @param int $websiteId + * @param array $inventoryData + * + * @return void + */ private function updateInventoryInProducts($productIds, $websiteId, $inventoryData): void { foreach ($productIds as $productId) { diff --git a/app/code/Magento/CatalogInventory/composer.json b/app/code/Magento/CatalogInventory/composer.json index eb6239ea87ef0..f18a5ff1d875a 100644 --- a/app/code/Magento/CatalogInventory/composer.json +++ b/app/code/Magento/CatalogInventory/composer.json @@ -7,6 +7,7 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", + "magento/module-backend": "*", "magento/module-catalog": "*", "magento/module-search": "*", "magento/module-config": "*", diff --git a/app/code/Magento/MessageQueue/Model/CallbackInvoker.php b/app/code/Magento/MessageQueue/Model/CallbackInvoker.php index a61a6862843b3..33229c6432c5a 100644 --- a/app/code/Magento/MessageQueue/Model/CallbackInvoker.php +++ b/app/code/Magento/MessageQueue/Model/CallbackInvoker.php @@ -47,6 +47,7 @@ public function __construct( /** * @inheritdoc + * @SuppressWarnings(PHPMD.ExitExpression) */ public function invoke(QueueInterface $queue, $maxNumberOfMessages, $callback) { diff --git a/app/code/Magento/MessageQueue/Model/PoisonPillFactory.php b/app/code/Magento/MessageQueue/Model/PoisonPillFactory.php deleted file mode 100644 index 0f2857fd6ec5c..0000000000000 --- a/app/code/Magento/MessageQueue/Model/PoisonPillFactory.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MessageQueue\Model; - -use Magento\MessageQueue\Api\Data\PoisonPillInterface; - -class PoisonPillFactory -{ - /** - * @var PoisonPillInterface - */ - private $poisonPill; - - /** - * @param PoisonPillInterface $poisonPill - */ - public function __construct( - PoisonPillInterface $poisonPill - ) { - $this->poisonPill = $poisonPill; - } - - /** - * @param int $version - * @return PoisonPillInterface - */ - public function create(int $version): PoisonPillInterface - { - - } -} diff --git a/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php b/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php index dab251ce50c83..7fab0a15ca19f 100644 --- a/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php +++ b/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php @@ -27,7 +27,10 @@ class PoisonPill extends AbstractDb implements PoisonPillPutInterface, PoisonPil private $poisonPillFactory; /** + * PoisonPill constructor. + * * @param Context $context + * @param PoisonPillInterfaceFactory $poisonPillFactory * @param string|null $connectionName */ public function __construct( diff --git a/dev/tests/integration/framework/Magento/TestFramework/MessageQueue/PublisherConsumerController.php b/dev/tests/integration/framework/Magento/TestFramework/MessageQueue/PublisherConsumerController.php index 7748e43bbd621..32240e68ae73e 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/MessageQueue/PublisherConsumerController.php +++ b/dev/tests/integration/framework/Magento/TestFramework/MessageQueue/PublisherConsumerController.php @@ -223,6 +223,11 @@ public function getPublisher() return $this->publisher; } + /** + * Start consumers + * + * @return void + */ public function startConsumers(): void { foreach ($this->consumers as $consumer) { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php index 0fe618b2db304..53aa1e24a5cd2 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php @@ -122,10 +122,18 @@ public function testSaveActionChangeVisibility($attributes) \Magento\Catalog\Block\Product\ListProduct::class ); - $this->publisherConsumerController->waitForAsynchronousResult(function() use($repository) { - return $repository->get('simple', false, null, true)->getVisibility() != Visibility::VISIBILITY_NOT_VISIBLE; - sleep(3); - }, []); + $this->publisherConsumerController->waitForAsynchronousResult( + function() use ($repository) { + sleep(3); + return $repository->get( + 'simple', + false, + null, + true + )->getVisibility() != Visibility::VISIBILITY_NOT_VISIBLE; + }, + [] + ); $category = $categoryFactory->create()->load(2); $layer = $listProduct->getLayer(); diff --git a/lib/internal/Magento/Framework/MessageQueue/Consumer.php b/lib/internal/Magento/Framework/MessageQueue/Consumer.php index 72c5f2e0cbdfc..8f65a2d8c5ed2 100644 --- a/lib/internal/Magento/Framework/MessageQueue/Consumer.php +++ b/lib/internal/Magento/Framework/MessageQueue/Consumer.php @@ -103,7 +103,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function process($maxNumberOfMessages = null) { From 91040106ffca5ec4296a7650110bef20b4f0d1f7 Mon Sep 17 00:00:00 2001 From: Maria Kovdrysh <kovdrysh@adobe.com> Date: Fri, 8 Mar 2019 12:25:10 -0600 Subject: [PATCH 082/162] MC-4435: Convert MassDeleteSearchTermEntityTest to MFTF --- .../ActionGroup/StorefrontCatalogSearchActionGroup.xml | 10 ++++++++-- .../Section/AdminCatalogSearchTermIndexSection.xml | 1 + .../Mftf/ActionGroup/AdminSearchTermActionGroup.xml | 4 ++-- .../Section/StorefrontQuickSearchResultsSection.xml | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml index 6b913e5b458e6..d99d1b69887ed 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml @@ -11,9 +11,10 @@ <!-- Quick search the phrase and check if the result page contains correct information --> <actionGroup name="StorefrontCheckQuickSearchActionGroup"> <arguments> - <argument name="phrase"/> + <argument name="phrase" type="string"/> </arguments> - <submitForm selector="#search_mini_form" parameterArray="['q' => '{{phrase}}']" stepKey="fillQuickSearch" /> + <fillField stepKey="fillInput" selector="{{StorefrontQuickSearchResultsSection.searchTextBox}}" userInput="{{phrase}}"/> + <submitForm selector="{{StorefrontQuickSearchResultsSection.searchTextBox}}" parameterArray="[]" stepKey="submitQuickSearch" /> <seeInCurrentUrl url="{{StorefrontCatalogSearchPage.url}}" stepKey="checkUrl"/> <dontSeeInCurrentUrl url="form_key=" stepKey="checkUrlFormKey"/> <seeInTitle userInput="Search results for: '{{phrase}}'" stepKey="assertQuickSearchTitle"/> @@ -116,4 +117,9 @@ <click selector="{{StorefrontCatalogSearchAdvancedFormSection.SubmitButton}}" stepKey="clickSubmit"/> <waitForPageLoad stepKey="waitForPageLoad"/> </actionGroup> + + <!-- Asserts that search results do not contain any results--> + <actionGroup name="StorefrontCheckSearchIsEmpty"> + <see stepKey="checkEmpty" selector="{{StorefrontQuickSearchResultsSection.messageSection}}" userInput="Your search returned no results"/> + </actionGroup> </actionGroups> \ No newline at end of file diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermIndexSection.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermIndexSection.xml index 5491c27228387..ac316d060f6e9 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermIndexSection.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Section/AdminCatalogSearchTermIndexSection.xml @@ -16,6 +16,7 @@ <element name="submit" type="button" selector="//button[@class='action-default scalable']/span" timeout="30"/> <element name="searchQuery" type="text" selector="//tr[@class='data-grid-filters']//td/input[@name='search_query']"/> <element name="nthRow" type="checkbox" selector="//tbody/tr['{{rowNum}}']//input[@name='search']" parameterized="true"/> + <element name="searchTermRowCheckboxBySearchQuery" type="checkbox" selector="//*[normalize-space()='{{var1}}']/preceding-sibling::td//input[@name='search']" parameterized="true" timeout="30"/> <element name="okButton" type="button" selector="//button[@class='action-primary action-accept']/span" timeout="30"/> <element name="emptyRecords" type="text" selector="//tr[@class='data-grid-tr-no-data even']/td[@class='empty-text']"/> </section> diff --git a/app/code/Magento/Search/Test/Mftf/ActionGroup/AdminSearchTermActionGroup.xml b/app/code/Magento/Search/Test/Mftf/ActionGroup/AdminSearchTermActionGroup.xml index f116e44e5c141..e0b3d4b850bbb 100644 --- a/app/code/Magento/Search/Test/Mftf/ActionGroup/AdminSearchTermActionGroup.xml +++ b/app/code/Magento/Search/Test/Mftf/ActionGroup/AdminSearchTermActionGroup.xml @@ -17,12 +17,12 @@ <fillField selector="{{AdminCatalogSearchTermIndexSection.searchQuery}}" userInput="{{searchQuery}}" stepKey="fillSearchQuery"/> <click selector="{{AdminCatalogSearchTermIndexSection.searchButton}}" stepKey="clickSearchButton"/> <waitForPageLoad stepKey="waitForSearchResultLoad"/> - <checkOption selector="{{AdminCatalogSearchTermIndexSection.checkBox}}" stepKey="checkCheckBox"/> + <checkOption selector="{{AdminCatalogSearchTermIndexSection.searchTermRowCheckboxBySearchQuery(searchQuery)}}" stepKey="checkCheckBox"/> </actionGroup> <!-- Delete search term --> <actionGroup name="deleteSearchTerm"> - <selectOption selector="{{AdminCatalogSearchTermIndexSection.delete}}" userInput="delete" stepKey="selectDeleteOption"/> + <selectOption selector="{{AdminCatalogSearchTermIndexSection.massActions}}" userInput="delete" stepKey="selectDeleteOption"/> <click selector="{{AdminCatalogSearchTermIndexSection.submit}}" stepKey="clickSubmitButton"/> <click selector="{{AdminCatalogSearchTermIndexSection.okButton}}" stepKey="clickOkButton"/> <waitForElementVisible selector="{{AdminCatalogSearchTermMessagesSection.successMessage}}" stepKey="waitForSuccessMessage"/> diff --git a/app/code/Magento/Search/Test/Mftf/Section/StorefrontQuickSearchResultsSection.xml b/app/code/Magento/Search/Test/Mftf/Section/StorefrontQuickSearchResultsSection.xml index 9e5bde9a2be49..81b025c9554e2 100644 --- a/app/code/Magento/Search/Test/Mftf/Section/StorefrontQuickSearchResultsSection.xml +++ b/app/code/Magento/Search/Test/Mftf/Section/StorefrontQuickSearchResultsSection.xml @@ -15,5 +15,6 @@ <element name="asLowAsLabel" type="text" selector=".minimal-price-link > span"/> <element name="textArea" type="text" selector="li[class='item']"/> <element name="regularPrice" type="text" selector="//span[@class='price-wrapper ']/span[@class='price']"/> + <element name="messageSection" type="text" selector="div .message"/> </section> </sections> From 189d79b14cc8bf31f2eb5f06f9ac8172684f7394 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Fri, 8 Mar 2019 13:30:18 -0600 Subject: [PATCH 083/162] MC-13613: Product mass update --- .../Magento/Catalog/Model/Attribute/Backend/Consumer.php | 5 ++--- .../Model/Attribute/Backend/ConsumerWebsiteAssign.php | 5 ++--- app/code/Magento/Catalog/composer.json | 1 + .../CatalogInventory/Plugin/MassUpdateProductAttribute.php | 1 + .../Magento/MessageQueue/Model/ResourceModel/PoisonPill.php | 3 +++ .../Controller/Adminhtml/Product/Action/AttributeTest.php | 4 ++-- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php index 5785a9f3ccaa7..becd6c160155c 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php @@ -102,10 +102,9 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf $serializedData = $operation->getSerializedData(); $data = $this->serializer->unserialize($serializedData); $this->execute($data); - } catch (\Zend_Db_Adapter_Exception $e) { + } catch (\Zend_Db_Adapter_Exception $e) { $this->logger->critical($e->getMessage()); - if ( - $e instanceof \Magento\Framework\DB\Adapter\LockWaitException + if ($e instanceof \Magento\Framework\DB\Adapter\LockWaitException || $e instanceof \Magento\Framework\DB\Adapter\DeadlockException || $e instanceof \Magento\Framework\DB\Adapter\ConnectionException ) { diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php b/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php index 13933b952cad4..b47d65e310070 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php @@ -95,10 +95,9 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf $serializedData = $operation->getSerializedData(); $data = $this->serializer->unserialize($serializedData); $this->execute($data); - } catch (\Zend_Db_Adapter_Exception $e) { + } catch (\Zend_Db_Adapter_Exception $e) { $this->logger->critical($e->getMessage()); - if ( - $e instanceof \Magento\Framework\DB\Adapter\LockWaitException + if ($e instanceof \Magento\Framework\DB\Adapter\LockWaitException || $e instanceof \Magento\Framework\DB\Adapter\DeadlockException || $e instanceof \Magento\Framework\DB\Adapter\ConnectionException ) { diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index 47e532edfe548..5c3ee3da8ca81 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -7,6 +7,7 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", + "magento/module-authorization": "*", "magento/module-asynchronous-operations": "*", "magento/module-backend": "*", "magento/module-catalog-inventory": "*", diff --git a/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php b/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php index dc1d888d2af19..f41fc00b55acb 100644 --- a/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php +++ b/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php @@ -104,6 +104,7 @@ public function __construct( * Around execute plugin * * @param Save $subject + * @param callable $proceed * * @return \Magento\Framework\Controller\ResultInterface * diff --git a/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php b/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php index 7fab0a15ca19f..b6149be04c471 100644 --- a/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php +++ b/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php @@ -14,6 +14,9 @@ use Magento\Framework\Model\ResourceModel\Db\Context; use Magento\Framework\Model\ResourceModel\Db\AbstractDb; +/** + * PoisonPill. + */ class PoisonPill extends AbstractDb implements PoisonPillPutInterface, PoisonPillReadInterface { /** diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php index 53aa1e24a5cd2..3ec8c806dcbb1 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php @@ -123,14 +123,14 @@ public function testSaveActionChangeVisibility($attributes) ); $this->publisherConsumerController->waitForAsynchronousResult( - function() use ($repository) { + function () use ($repository) { sleep(3); return $repository->get( 'simple', false, null, true - )->getVisibility() != Visibility::VISIBILITY_NOT_VISIBLE; + )->getVisibility() != Visibility::VISIBILITY_NOT_VISIBLE; }, [] ); From aa7a9544d0aa0d51389a367311f8a5d5b0dae12c Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Fri, 8 Mar 2019 13:48:54 -0600 Subject: [PATCH 084/162] MC-13613: Product mass update --- .../Magento/MessageQueue/etc/db_schema_whitelist.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/MessageQueue/etc/db_schema_whitelist.json b/app/code/Magento/MessageQueue/etc/db_schema_whitelist.json index f31981d2ec40f..d9d623a994b37 100644 --- a/app/code/Magento/MessageQueue/etc/db_schema_whitelist.json +++ b/app/code/Magento/MessageQueue/etc/db_schema_whitelist.json @@ -9,5 +9,13 @@ "PRIMARY": true, "QUEUE_LOCK_MESSAGE_CODE": true } + }, + "queue_poison_pill": { + "column": { + "version": true + }, + "constraint": { + "PRIMARY": true + } } -} \ No newline at end of file +} From 311d739e70129a9566ffdba36dab76fac5392130 Mon Sep 17 00:00:00 2001 From: Maria Kovdrysh <kovdrysh@adobe.com> Date: Mon, 11 Mar 2019 08:23:29 -0500 Subject: [PATCH 085/162] MC-4436: Convert CreateSearchTermEntityTest to MFTF --- ...chTermEntityTest.xml => AdminCreateSearchTermEntityTest.xml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename app/code/Magento/CatalogSearch/Test/Mftf/Test/{CreateSearchTermEntityTest.xml => AdminCreateSearchTermEntityTest.xml} (98%) diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/CreateSearchTermEntityTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminCreateSearchTermEntityTest.xml similarity index 98% rename from app/code/Magento/CatalogSearch/Test/Mftf/Test/CreateSearchTermEntityTest.xml rename to app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminCreateSearchTermEntityTest.xml index a710f3dd8fa5c..2b425f34f8a5b 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/CreateSearchTermEntityTest.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminCreateSearchTermEntityTest.xml @@ -8,7 +8,7 @@ <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> - <test name="CreateSearchTermTest"> + <test name="AdminCreateSearchTermEntityTest"> <annotations> <stories value="Search terms"/> <title value="Create search term test"/> From fddee1591157e284595fff3ebfb031470c5478b2 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@adobe.com> Date: Mon, 11 Mar 2019 09:40:55 -0500 Subject: [PATCH 086/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Backend/ConsumerWebsiteAssign.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php b/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php index b47d65e310070..15f9e4833b269 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php @@ -39,11 +39,6 @@ class ConsumerWebsiteAssign */ private $serializer; - /** - * @var \Magento\Framework\Bulk\OperationManagementInterface - */ - private $operationManagement; - /** * @var \Magento\Catalog\Model\Indexer\Product\Price\Processor */ @@ -54,31 +49,36 @@ class ConsumerWebsiteAssign */ private $entityManager; + /** + * @var \Magento\MessageQueue\Api\Data\PoisonPillInterface + */ + private $poisonPill; + /** * @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor * @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor - * @param \Magento\Framework\Bulk\OperationManagementInterface $operationManagement * @param \Magento\Catalog\Model\Product\Action $action * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Serialize\SerializerInterface $serializer * @param EntityManager $entityManager + * @param \Magento\MessageQueue\Api\PoisonPillPutInterface $poisonPill */ public function __construct( \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor, \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor, - \Magento\Framework\Bulk\OperationManagementInterface $operationManagement, \Magento\Catalog\Model\Product\Action $action, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Serialize\SerializerInterface $serializer, - EntityManager $entityManager + EntityManager $entityManager, + \Magento\MessageQueue\Api\PoisonPillPutInterface $poisonPill ) { $this->productFlatIndexerProcessor = $productFlatIndexerProcessor; $this->productAction = $action; $this->logger = $logger; $this->serializer = $serializer; - $this->operationManagement = $operationManagement; $this->productPriceIndexerProcessor = $productPriceIndexerProcessor; $this->entityManager = $entityManager; + $this->poisonPill = $poisonPill; } /** @@ -94,6 +94,7 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf try { $serializedData = $operation->getSerializedData(); $data = $this->serializer->unserialize($serializedData); + $this->poisonPill->put(); $this->execute($data); } catch (\Zend_Db_Adapter_Exception $e) { $this->logger->critical($e->getMessage()); From 21eeb476c8003fe457fda395e00f8d0ceea2ed21 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Mon, 11 Mar 2019 10:18:34 -0500 Subject: [PATCH 087/162] MC-13613: Product mass update --- app/code/Magento/Catalog/composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index 5c3ee3da8ca81..7174c35b191b6 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -7,6 +7,7 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", + "magento/framework-message-queue": "*", "magento/module-authorization": "*", "magento/module-asynchronous-operations": "*", "magento/module-backend": "*", From 5c7369e0cc487ac82ed66ffb630f14aaf7a88d4f Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Mon, 11 Mar 2019 10:47:05 -0500 Subject: [PATCH 088/162] MC-4425: Convert ImportProductsTest to MFTF Updated story and zephyr test Ids as per review comments --- .../Test/AdminImportProductsWithAddUpdateBehaviorTest.xml | 4 ++-- .../Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml index f3238293e5713..ceb4e93e4e9aa 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithAddUpdateBehaviorTest.xml @@ -11,11 +11,11 @@ <test name="AdminImportProductsWithAddUpdateBehaviorTest"> <annotations> <description value="Verify Magento native import products with add/update behavior."/> - <stories value="Verify Magento native import products with add/update behavior."/> + <stories value="Import Products"/> <features value="Import/Export"/> <title value="Verify Magento native import products with add/update behavior."/> <severity value="CRITICAL"/> - <testCaseId value="MAGETWO-47724"/> + <testCaseId value="MC-14077"/> <group value="importExport"/> <group value="mtf_migrated"/> </annotations> diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml index d45b294a34e4f..d63a5546716b1 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithReplaceBehaviorTest.xml @@ -11,11 +11,11 @@ <test name="AdminImportProductsWithReplaceBehaviorTest" extends="AdminImportProductsWithAddUpdateBehaviorTest"> <annotations> <description value="Verify Magento native import products with replace behavior."/> - <stories value="Verify Magento native import products with replace behavior."/> + <stories value="Import Products"/> <features value="Import/Export"/> <title value="Verify Magento native import products with replace behavior."/> <severity value="CRITICAL"/> - <testCaseId value="MAGETWO-47719"/> + <testCaseId value="MC-14076"/> <group value="importExport"/> <group value="mtf_migrated"/> </annotations> From ff0271c3539706b9dae240bc4f86c339a1dd0f5f Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@adobe.com> Date: Mon, 11 Mar 2019 13:26:46 -0500 Subject: [PATCH 089/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- .../Adminhtml/Product/Action/Attribute/Save.php | 11 ++++++++++- .../Model/Attribute/Backend/ConsumerWebsiteAssign.php | 11 +---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index 63182dd5624e6..e6bdca02061ef 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -42,6 +42,11 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribut */ private $userContext; + /** + * @var \Magento\MessageQueue\Api\PoisonPillPutInterface + */ + private $pillPut; + /** * @param Action\Context $context * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper @@ -50,6 +55,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribut * @param \Magento\Framework\DataObject\IdentityGeneratorInterface $identityService * @param \Magento\Framework\Serialize\SerializerInterface $serializer * @param \Magento\Authorization\Model\UserContextInterface $userContext + * @param \Magento\MessageQueue\Api\PoisonPillPutInterface $pillPut */ public function __construct( Action\Context $context, @@ -58,7 +64,8 @@ public function __construct( \Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory $operartionFactory, \Magento\Framework\DataObject\IdentityGeneratorInterface $identityService, \Magento\Framework\Serialize\SerializerInterface $serializer, - \Magento\Authorization\Model\UserContextInterface $userContext + \Magento\Authorization\Model\UserContextInterface $userContext, + \Magento\MessageQueue\Api\PoisonPillPutInterface $pillPut ) { parent::__construct($context, $attributeHelper); $this->bulkManagement = $bulkManagement; @@ -66,6 +73,7 @@ public function __construct( $this->identityService = $identityService; $this->serializer = $serializer; $this->userContext = $userContext; + $this->pillPut = $pillPut; } /** @@ -190,6 +198,7 @@ private function publish( $productIdsChunk, $bulkUuid ); + $this->pillPut->put(); } if ($attributesData) { diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php b/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php index 15f9e4833b269..32ba39d9afd98 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/ConsumerWebsiteAssign.php @@ -49,11 +49,6 @@ class ConsumerWebsiteAssign */ private $entityManager; - /** - * @var \Magento\MessageQueue\Api\Data\PoisonPillInterface - */ - private $poisonPill; - /** * @param \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor * @param \Magento\Catalog\Model\Indexer\Product\Price\Processor $productPriceIndexerProcessor @@ -61,7 +56,6 @@ class ConsumerWebsiteAssign * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Serialize\SerializerInterface $serializer * @param EntityManager $entityManager - * @param \Magento\MessageQueue\Api\PoisonPillPutInterface $poisonPill */ public function __construct( \Magento\Catalog\Model\Indexer\Product\Flat\Processor $productFlatIndexerProcessor, @@ -69,8 +63,7 @@ public function __construct( \Magento\Catalog\Model\Product\Action $action, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Serialize\SerializerInterface $serializer, - EntityManager $entityManager, - \Magento\MessageQueue\Api\PoisonPillPutInterface $poisonPill + EntityManager $entityManager ) { $this->productFlatIndexerProcessor = $productFlatIndexerProcessor; $this->productAction = $action; @@ -78,7 +71,6 @@ public function __construct( $this->serializer = $serializer; $this->productPriceIndexerProcessor = $productPriceIndexerProcessor; $this->entityManager = $entityManager; - $this->poisonPill = $poisonPill; } /** @@ -94,7 +86,6 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf try { $serializedData = $operation->getSerializedData(); $data = $this->serializer->unserialize($serializedData); - $this->poisonPill->put(); $this->execute($data); } catch (\Zend_Db_Adapter_Exception $e) { $this->logger->critical($e->getMessage()); From d2cb7c89990cb52f39f823c7b849ac749833e6c6 Mon Sep 17 00:00:00 2001 From: Andrii Lugovyi <alugovyi@adobe.com> Date: Tue, 12 Mar 2019 10:06:45 -0500 Subject: [PATCH 090/162] MC-13613: Product mass update - MC-5665 Execution of heavy admin operations in asynchronous flow part2 --- app/code/Magento/MessageQueue/Model/CallbackInvoker.php | 1 + .../MessageQueue/Model/ResourceModel/PoisonPill.php | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/MessageQueue/Model/CallbackInvoker.php b/app/code/Magento/MessageQueue/Model/CallbackInvoker.php index 33229c6432c5a..1234228dad72d 100644 --- a/app/code/Magento/MessageQueue/Model/CallbackInvoker.php +++ b/app/code/Magento/MessageQueue/Model/CallbackInvoker.php @@ -57,6 +57,7 @@ public function invoke(QueueInterface $queue, $maxNumberOfMessages, $callback) $message = $queue->dequeue(); } while ($message === null && (sleep(1) === 0)); if (false === $this->poisonPillCompare->isLatest($this->poisonPill)) { + $queue->reject($message); exit(0); } $callback($message); diff --git a/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php b/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php index b6149be04c471..ee3d09ec3eaed 100644 --- a/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php +++ b/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php @@ -58,9 +58,10 @@ protected function _construct() */ public function put(): int { - /** @var PoisonPillInterface $poisonPill */ - $poisonPill = $this->poisonPillFactory->create(); - return $this->save($poisonPill)->getConnection()->lastInsertId(); + $connection = $this->getConnection(); + $table = $this->getMainTable(); + $connection->insert($table, []); + return (int)$connection->lastInsertId($table); } /** From ce21910264fbf31cdddc6c9e9670ba14548e88b9 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Tue, 12 Mar 2019 11:08:05 -0500 Subject: [PATCH 091/162] MC-13613: Product mass update --- app/code/Magento/Catalog/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index 7174c35b191b6..74e7f40b1f062 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -7,7 +7,7 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", - "magento/framework-message-queue": "*", + "magento/module-message-queue": "*", "magento/module-authorization": "*", "magento/module-asynchronous-operations": "*", "magento/module-backend": "*", From a99c53ab69c8be65d86341c360b285a51c815532 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Tue, 12 Mar 2019 14:01:28 -0500 Subject: [PATCH 092/162] MC-13613: Product mass update --- .../Controller/Adminhtml/Product/Action/Attribute/Save.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index e6bdca02061ef..f63e5a681c42b 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -198,7 +198,6 @@ private function publish( $productIdsChunk, $bulkUuid ); - $this->pillPut->put(); } if ($attributesData) { @@ -215,6 +214,7 @@ private function publish( } if (!empty($operations)) { + $this->pillPut->put(); $result = $this->bulkManagement->scheduleBulk( $bulkUuid, $operations, From 92f1f5785289b0f87a186a3e47642f9b88e9f940 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Tue, 12 Mar 2019 14:12:39 -0500 Subject: [PATCH 093/162] MC-13613: Product mass update --- app/code/Magento/Catalog/composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index 74e7f40b1f062..7efd63fb7a4aa 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -8,7 +8,6 @@ "php": "~7.1.3||~7.2.0", "magento/framework": "*", "magento/module-message-queue": "*", - "magento/module-authorization": "*", "magento/module-asynchronous-operations": "*", "magento/module-backend": "*", "magento/module-catalog-inventory": "*", From 82dfd9103b1e5641d1a939a9f426ccf0d81557a4 Mon Sep 17 00:00:00 2001 From: Alex Calandra <calandra.aj@gmail.com> Date: Tue, 12 Mar 2019 15:31:06 -0500 Subject: [PATCH 094/162] MQE-1477: Resolve Test Rerun Issues for Disable Wysiwyg Suite - Removing Two tests from disabled wysiwyg suite - Removing disable wysiwyg from one test --- .../Cms/Test/Mftf/Test/AdminAddImageToWYSIWYGBlockTest.xml | 1 - app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml | 3 --- 2 files changed, 4 deletions(-) diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminAddImageToWYSIWYGBlockTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminAddImageToWYSIWYGBlockTest.xml index 05b7dfeeb3953..03edc69e6d625 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/AdminAddImageToWYSIWYGBlockTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminAddImageToWYSIWYGBlockTest.xml @@ -16,7 +16,6 @@ <description value="Admin should be able to add image to WYSIWYG content of Block"/> <severity value="CRITICAL"/> <testCaseId value="MAGETWO-84376"/> - <group value="WYSIWYGDisabled" /> </annotations> <before> <createData entity="_defaultCmsPage" stepKey="createCMSPage" /> diff --git a/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml index b4bcdaadf9a09..c3c92dc59c288 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml @@ -17,10 +17,8 @@ <severity value="CRITICAL"/> <testCaseId value="MAGETWO-94229"/> <group value="Cms"/> - <group value="WYSIWYGDisabled"/> </annotations> <before> - <magentoCLI command="config:set cms/wysiwyg/enabled disabled" stepKey="disableWYSIWYG"/> <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="AdminCreateWebsite"> <argument name="newWebsiteName" value="secondWebsite"/> @@ -69,7 +67,6 @@ <argument name="websiteName" value="secondWebsite"/> </actionGroup> <actionGroup ref="DeleteCMSBlockActionGroup" stepKey="DeleteCMSBlockActionGroup"/> - <magentoCLI command="config:set cms/wysiwyg/enabled enabled" stepKey="enableWYSIWYG"/> </after> </test> </tests> From c00821496598b1bf9ecf3e183f18a289dbb3b9c2 Mon Sep 17 00:00:00 2001 From: Tom Reece <treece@adobe.com> Date: Tue, 12 Mar 2019 16:27:00 -0500 Subject: [PATCH 095/162] MQE-1476: Deliver weekly PR - Add mftf_migrated:yes tags --- .../BundleImportExport/Test/TestCase/ExportProductsTest.xml | 1 + .../CatalogImportExport/Test/TestCase/ExportProductsTest.xml | 4 ++++ .../Test/TestCase/CreateSearchTermEntityTest.xml | 1 + .../Test/TestCase/DeleteSearchTermEntityTest.xml | 1 + .../Test/TestCase/MassDeleteSearchTermEntityTest.xml | 1 + .../Test/TestCase/CreateDuplicateUrlCategoryEntityTest.xml | 2 +- .../Test/TestCase/CreateDuplicateUrlProductEntity.xml | 2 +- .../Test/TestCase/ExportProductsTest.xml | 3 +++ .../GroupedImportExport/Test/TestCase/ExportProductsTest.xml | 1 + .../Magento/Store/Test/TestCase/CreateWebsiteEntityTest.xml | 2 +- .../app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.xml | 2 +- .../Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.xml | 2 +- .../Test/TestCase/UpdateProductUrlRewriteEntityTest.xml | 1 + 13 files changed, 18 insertions(+), 5 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/BundleImportExport/Test/TestCase/ExportProductsTest.xml b/dev/tests/functional/tests/app/Magento/BundleImportExport/Test/TestCase/ExportProductsTest.xml index 3ad8cff31eaf8..bfbe233b9dc1b 100644 --- a/dev/tests/functional/tests/app/Magento/BundleImportExport/Test/TestCase/ExportProductsTest.xml +++ b/dev/tests/functional/tests/app/Magento/BundleImportExport/Test/TestCase/ExportProductsTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\CatalogImportExport\Test\TestCase\ExportProductsTest" summary="Export products"> <variation name="ExportProductsTestVariation4" summary="Export bundle products" ticketId="MAGETWO-30602"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="exportData" xsi:type="string">default</data> <data name="products/0" xsi:type="array"> <item name="fixture" xsi:type="string">bundleProduct</item> diff --git a/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ExportProductsTest.xml b/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ExportProductsTest.xml index b94f21371496a..8fe25614d1d42 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ExportProductsTest.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ExportProductsTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\CatalogImportExport\Test\TestCase\ExportProductsTest" summary="Export products"> <variation name="ExportProductsTestVariation1" summary="Export simple product and configured products with assigned images" ticketId="MAGETWO-46112"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="exportData" xsi:type="string">default</data> <data name="products/0" xsi:type="array"> <item name="fixture" xsi:type="string">catalogProductSimple</item> @@ -27,6 +28,7 @@ </data> </variation> <variation name="ExportProductsTestVariation2" summary="Export simple and configured products with custom options" ticketId="MAGETWO-46113, MAGETWO-46109"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="exportData" xsi:type="string">default</data> <data name="products/0" xsi:type="array"> <item name="fixture" xsi:type="string">catalogProductSimple</item> @@ -43,6 +45,7 @@ <constraint name="Magento\CatalogImportExport\Test\Constraint\AssertExportProductDate" /> </variation> <variation name="ExportProductsTestVariation3" summary="Export simple product with custom attribute" ticketId="MAGETWO-46121"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="exportData" xsi:type="string">default</data> <data name="products/0" xsi:type="array"> <item name="fixture" xsi:type="string">catalogProductSimple</item> @@ -58,6 +61,7 @@ </data> </variation> <variation name="ExportProductsTestVariation5" summary="Export simple product assigned to Main Website and configurable product assigned to Custom Website" ticketId="MAGETWO-46114"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="issue" xsi:type="string">>MC-13864 Consumer always read config from memory</data> <data name="exportData" xsi:type="string">default</data> <data name="products/0" xsi:type="array"> diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/CreateSearchTermEntityTest.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/CreateSearchTermEntityTest.xml index 0437e0a5e999b..8c465544a3283 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/CreateSearchTermEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/CreateSearchTermEntityTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\CatalogSearch\Test\TestCase\CreateSearchTermEntityTest" summary="Create Search Term" ticketId="MAGETWO-26165"> <variation name="CreateSearchTermEntityTestVariation1"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="searchTerm/data/query_text/value" xsi:type="string">catalogProductSimple::sku</data> <data name="searchTerm/data/store_id" xsi:type="string">Main Website/Main Website Store/Default Store View</data> <data name="searchTerm/data/redirect" xsi:type="string">http://example.com/</data> diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/DeleteSearchTermEntityTest.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/DeleteSearchTermEntityTest.xml index a9cc0dfd34f9f..8fdd7ef715521 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/DeleteSearchTermEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/DeleteSearchTermEntityTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\CatalogSearch\Test\TestCase\DeleteSearchTermEntityTest" summary="Delete Search Term" ticketId="MAGETWO-26491"> <variation name="DeleteSearchTermEntityTestVariation1"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="searchTerm/dataset" xsi:type="string">default</data> <constraint name="Magento\CatalogSearch\Test\Constraint\AssertSearchTermSuccessDeleteMessage" /> <constraint name="Magento\CatalogSearch\Test\Constraint\AssertSearchTermNotInGrid" /> diff --git a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/MassDeleteSearchTermEntityTest.xml b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/MassDeleteSearchTermEntityTest.xml index 3bf4e521c4a04..3ef2b65c0224b 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/MassDeleteSearchTermEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogSearch/Test/TestCase/MassDeleteSearchTermEntityTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\CatalogSearch\Test\TestCase\MassDeleteSearchTermEntityTest" summary="Mass Delete Search Term" ticketId="MAGETWO-26599"> <variation name="MassDeleteSearchTermEntityTestVariation1"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="searchTerms" xsi:type="string">catalogSearchQuery::default,catalogSearchQuery::default,catalogSearchQuery::default</data> <constraint name="Magento\CatalogSearch\Test\Constraint\AssertSearchTermSuccessMassDeleteMessage" /> <constraint name="Magento\CatalogSearch\Test\Constraint\AssertSearchTermMassActionsNotInGrid" /> diff --git a/dev/tests/functional/tests/app/Magento/CatalogUrlRewrite/Test/TestCase/CreateDuplicateUrlCategoryEntityTest.xml b/dev/tests/functional/tests/app/Magento/CatalogUrlRewrite/Test/TestCase/CreateDuplicateUrlCategoryEntityTest.xml index 398054f1f0ed3..8b15da5ecd2ef 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogUrlRewrite/Test/TestCase/CreateDuplicateUrlCategoryEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogUrlRewrite/Test/TestCase/CreateDuplicateUrlCategoryEntityTest.xml @@ -14,7 +14,7 @@ <data name="category/data/include_in_menu" xsi:type="string">Yes</data> <data name="category/data/name" xsi:type="string">Subcategory%isolation%</data> <data name="category/data/url_key" xsi:type="string">subcategory-%isolation%</data> - <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, severity:S1</data> + <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, severity:S1, mftf_migrated:yes</data> <constraint name="Magento\CatalogUrlRewrite\Test\Constraint\AssertCategoryUrlDuplicateErrorMessage" /> </variation> </testCase> diff --git a/dev/tests/functional/tests/app/Magento/CatalogUrlRewrite/Test/TestCase/CreateDuplicateUrlProductEntity.xml b/dev/tests/functional/tests/app/Magento/CatalogUrlRewrite/Test/TestCase/CreateDuplicateUrlProductEntity.xml index 1116821f756a9..8110ed1ed00b1 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogUrlRewrite/Test/TestCase/CreateDuplicateUrlProductEntity.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogUrlRewrite/Test/TestCase/CreateDuplicateUrlProductEntity.xml @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\CatalogUrlRewrite\Test\TestCase\CreateDuplicateUrlProductEntity" summary="Create Simple Product" ticketId="MAGETWO-69427"> <variation name="CreateDuplicateUrlProductEntityTestVariation1" summary="Create Duplicate Url Product"> - <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, severity:S1</data> + <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, severity:S1, mftf_migrated:yes</data> <data name="product/data/url_key" xsi:type="string">simple-product-%isolation%</data> <data name="product/data/name" xsi:type="string">Simple Product %isolation%</data> <data name="product/data/sku" xsi:type="string">simple_sku_%isolation%</data> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableImportExport/Test/TestCase/ExportProductsTest.xml b/dev/tests/functional/tests/app/Magento/ConfigurableImportExport/Test/TestCase/ExportProductsTest.xml index 93240586ec92c..15dcfd0a9e7e7 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableImportExport/Test/TestCase/ExportProductsTest.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableImportExport/Test/TestCase/ExportProductsTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\CatalogImportExport\Test\TestCase\ExportProductsTest" summary="Export products"> <variation name="ExportProductsTestVariation7" summary="Export simple product and configured products with assigned images" ticketId="MAGETWO-46112"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="exportData" xsi:type="string">default</data> <data name="products/1" xsi:type="array"> <item name="fixture" xsi:type="string">configurableProduct</item> @@ -30,6 +31,7 @@ </data> </variation> <variation name="ExportProductsTestVariation8" summary="Export simple and configured products with custom options" ticketId="MAGETWO-46113, MAGETWO-46109"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="exportData" xsi:type="string">default</data> <data name="products/1" xsi:type="array"> <item name="fixture" xsi:type="string">configurableProduct</item> @@ -45,6 +47,7 @@ </data> </variation> <variation name="ExportProductsTestVariation9" summary="Export simple product assigned to Main Website and configurable product assigned to Custom Website" ticketId="MAGETWO-46114"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="issue" xsi:type="string">>MC-13864 Consumer always read config from memory</data> <data name="exportData" xsi:type="string">default</data> <data name="products/1" xsi:type="array"> diff --git a/dev/tests/functional/tests/app/Magento/GroupedImportExport/Test/TestCase/ExportProductsTest.xml b/dev/tests/functional/tests/app/Magento/GroupedImportExport/Test/TestCase/ExportProductsTest.xml index cffcdbf45a6dc..a110dc6a89f8c 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedImportExport/Test/TestCase/ExportProductsTest.xml +++ b/dev/tests/functional/tests/app/Magento/GroupedImportExport/Test/TestCase/ExportProductsTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\CatalogImportExport\Test\TestCase\ExportProductsTest" summary="Export products"> <variation name="ExportProductsTestVariation6" summary="Export grouped product with special price" ticketId="MAGETWO-46116"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="exportData" xsi:type="string">default</data> <data name="products/0" xsi:type="array"> <item name="fixture" xsi:type="string">groupedProduct</item> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.xml b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.xml index 5a547f69280e1..e35ef853d1b68 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/CreateWebsiteEntityTest.xml @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Store\Test\TestCase\CreateWebsiteEntityTest" summary="Create Website" ticketId="MAGETWO-27665"> <variation name="CreateWebsiteEntityTestVariation1"> - <data name="tag" xsi:type="string">severity:S1</data> + <data name="tag" xsi:type="string">severity:S1, mftf_migrated:yes</data> <data name="website/data/name" xsi:type="string">website_%isolation%</data> <data name="website/data/code" xsi:type="string">code_%isolation%</data> <constraint name="Magento\Store\Test\Constraint\AssertWebsiteSuccessSaveMessage" /> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.xml b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.xml index 306a9fd2024a4..cd37c555fdb1d 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreEntityTest.xml @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Store\Test\TestCase\DeleteStoreEntityTest" summary="Delete Store View" ticketId="MAGETWO-27942"> <variation name="DeleteStoreEntityTestVariation1"> - <data name="tag" xsi:type="string">severity:S2</data> + <data name="tag" xsi:type="string">severity:S2, mftf_migrated:yes</data> <data name="store/dataset" xsi:type="string">custom</data> <data name="createBackup" xsi:type="string">Yes</data> <constraint name="Magento\Store\Test\Constraint\AssertStoreSuccessDeleteAndBackupMessages" /> diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.xml b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.xml index ac857ad035f44..5db0e7f8baad4 100644 --- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/UpdateWebsiteEntityTest.xml @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Store\Test\TestCase\UpdateWebsiteEntityTest" summary="Update Website" ticketId="MAGETWO-27690"> <variation name="UpdateWebsiteEntityTestVariation1"> - <data name="tag" xsi:type="string">severity:S2</data> + <data name="tag" xsi:type="string">severity:S2, mftf_migrated:yes</data> <data name="websiteOrigin/dataset" xsi:type="string">custom_website</data> <data name="website/data/name" xsi:type="string">website_upd%isolation%</data> <data name="website/data/code" xsi:type="string">code_upd%isolation%</data> diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/UpdateProductUrlRewriteEntityTest.xml b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/UpdateProductUrlRewriteEntityTest.xml index 60de554d594d2..8f12930aa417b 100644 --- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/UpdateProductUrlRewriteEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/UpdateProductUrlRewriteEntityTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\UrlRewrite\Test\TestCase\UpdateProductUrlRewriteEntityTest" summary="Update Product URL Rewrites" ticketId="MAGETWO-24819"> <variation name="UpdateProductUrlRewriteEntityTestVariation1"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="urlRewrite/data/target_path/entity" xsi:type="string">product/%catalogProductSimple::product_100_dollar%</data> <data name="urlRewrite/data/store_id" xsi:type="string">Main Website/Main Website Store/Default Store View</data> <data name="urlRewrite/data/request_path" xsi:type="string">test_%isolation%.html</data> From 7471fea4e1176f2e3d49139bbee25feabdedc53a Mon Sep 17 00:00:00 2001 From: Oleksandr Shmyheliuk <oshmyheliuk@magento.com> Date: Tue, 12 Mar 2019 22:54:27 -0500 Subject: [PATCH 096/162] MAGETWO-95675: Error during setup:static-content:deploy: Error while waiting for package deployed --- .../Deploy/Console/DeployStaticOptions.php | 14 ++++++++ .../Deploy/Service/DeployStaticContent.php | 34 +++++++++++-------- .../Unit/Service/DeployStaticContentTest.php | 32 +++++++++++++++++ 3 files changed, 66 insertions(+), 14 deletions(-) diff --git a/app/code/Magento/Deploy/Console/DeployStaticOptions.php b/app/code/Magento/Deploy/Console/DeployStaticOptions.php index 89cb3e4b30345..1c02d24f7e99c 100644 --- a/app/code/Magento/Deploy/Console/DeployStaticOptions.php +++ b/app/code/Magento/Deploy/Console/DeployStaticOptions.php @@ -6,6 +6,7 @@ namespace Magento\Deploy\Console; +use Magento\Deploy\Process\Queue; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; @@ -57,6 +58,11 @@ class DeployStaticOptions */ const JOBS_AMOUNT = 'jobs'; + /** + * Key for max execution time option + */ + const MAX_EXECUTION_TIME = 'max-execution-time'; + /** * Force run of static deploy */ @@ -150,6 +156,7 @@ public function getOptionsList() * Basic options * * @return array + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ private function getBasicOptions() { @@ -216,6 +223,13 @@ private function getBasicOptions() 'Enable parallel processing using the specified number of jobs.', self::DEFAULT_JOBS_AMOUNT ), + new InputOption( + self::MAX_EXECUTION_TIME, + null, + InputOption::VALUE_OPTIONAL, + 'The maximum expected execution time of deployment static process (in seconds).', + Queue::DEFAULT_MAX_EXEC_TIME + ), new InputOption( self::SYMLINK_LOCALE, null, diff --git a/app/code/Magento/Deploy/Service/DeployStaticContent.php b/app/code/Magento/Deploy/Service/DeployStaticContent.php index 66ec6e7418afd..854bf50e0af2f 100644 --- a/app/code/Magento/Deploy/Service/DeployStaticContent.php +++ b/app/code/Magento/Deploy/Service/DeployStaticContent.php @@ -85,24 +85,26 @@ public function deploy(array $options) return; } - $queue = $this->queueFactory->create( - [ - 'logger' => $this->logger, - 'options' => $options, - 'maxProcesses' => $this->getProcessesAmount($options), - 'deployPackageService' => $this->objectManager->create( - \Magento\Deploy\Service\DeployPackage::class, - [ - 'logger' => $this->logger - ] - ) - ] - ); + $queueOptions = [ + 'logger' => $this->logger, + 'options' => $options, + 'maxProcesses' => $this->getProcessesAmount($options), + 'deployPackageService' => $this->objectManager->create( + \Magento\Deploy\Service\DeployPackage::class, + [ + 'logger' => $this->logger + ] + ) + ]; + + if (isset($options[Options::MAX_EXECUTION_TIME])) { + $queueOptions['maxExecTime'] = (int)$options[Options::MAX_EXECUTION_TIME]; + } $deployStrategy = $this->deployStrategyFactory->create( $options[Options::STRATEGY], [ - 'queue' => $queue + 'queue' => $this->queueFactory->create($queueOptions) ] ); @@ -133,6 +135,8 @@ public function deploy(array $options) } /** + * Returns amount of parallel processes, returns zero if option wasn't set. + * * @param array $options * @return int */ @@ -142,6 +146,8 @@ private function getProcessesAmount(array $options) } /** + * Checks if need to refresh only version. + * * @param array $options * @return bool */ diff --git a/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php b/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php index 75edc8cb4f6ee..396381960e544 100644 --- a/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Service/DeployStaticContentTest.php @@ -5,6 +5,7 @@ */ namespace Magento\Deploy\Test\Unit\Service; +use Magento\Deploy\Console\DeployStaticOptions; use Magento\Deploy\Package\Package; use Magento\Deploy\Process\Queue; use Magento\Deploy\Service\Bundle; @@ -221,4 +222,35 @@ public function deployDataProvider() ] ]; } + + public function testMaxExecutionTimeOptionPassed() + { + $options = [ + DeployStaticOptions::MAX_EXECUTION_TIME => 100, + DeployStaticOptions::REFRESH_CONTENT_VERSION_ONLY => false, + DeployStaticOptions::JOBS_AMOUNT => 3, + DeployStaticOptions::STRATEGY => 'compact', + DeployStaticOptions::NO_JAVASCRIPT => true, + DeployStaticOptions::NO_HTML_MINIFY => true, + ]; + + $queueMock = $this->createMock(Queue::class); + $strategyMock = $this->createMock(CompactDeploy::class); + $this->queueFactory->expects($this->once()) + ->method('create') + ->with([ + 'logger' => $this->logger, + 'maxExecTime' => 100, + 'maxProcesses' => 3, + 'options' => $options, + 'deployPackageService' => null + ]) + ->willReturn($queueMock); + $this->deployStrategyFactory->expects($this->once()) + ->method('create') + ->with('compact', ['queue' => $queueMock]) + ->willReturn($strategyMock); + + $this->service->deploy($options); + } } From 46bbdd0e3d5796e427899b96c189888423cb55d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= <karlasaaremae@gmail.com> Date: Wed, 13 Mar 2019 11:38:58 +0200 Subject: [PATCH 097/162] add choice class --- .../frontend/web/template/checkout/checkout-agreements.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html b/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html index db9da71ebf739..4b1a68624e547 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html @@ -8,7 +8,7 @@ <div class="checkout-agreements fieldset" data-bind="visible: isVisible"> <!-- ko foreach: agreements --> <!-- ko if: ($parent.isAgreementRequired($data)) --> - <div class="checkout-agreement field required"> + <div class="checkout-agreement field choice required"> <input type="checkbox" class="required-entry" data-bind="attr: { 'id': $parent.getCheckboxId($parentContext, agreementId), From a39e22181d94cdec03d40034da96264af32ef4c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= <karlasaaremae@gmail.com> Date: Wed, 13 Mar 2019 11:53:26 +0200 Subject: [PATCH 098/162] fix choice aligment --- .../web/css/source/module/checkout/_payments.less | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_payments.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_payments.less index 5f8134193c67f..35445b0989e86 100644 --- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_payments.less +++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_payments.less @@ -209,6 +209,13 @@ .fieldset { > .field { margin: 0 0 @indent__base; + + &.choice { + &:before { + padding: 0; + width: 0; + } + } &.type { .control { From b151b2fea184b4f8592945f5e7c84ec7b8a9af1c Mon Sep 17 00:00:00 2001 From: Alex Calandra <calandra.aj@gmail.com> Date: Wed, 13 Mar 2019 08:32:24 -0500 Subject: [PATCH 099/162] MQE-1477: Resolve Test Rerun Issues for Disable Wysiwyg Suite - Adding wysiwyg cli back to static block test --- app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml index c3c92dc59c288..e6ab1c130606b 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml @@ -19,6 +19,7 @@ <group value="Cms"/> </annotations> <before> + <magentoCLI command="config:set cms/wysiwyg/enabled disabled" stepKey="disableWYSIWYG"/> <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="AdminCreateWebsite"> <argument name="newWebsiteName" value="secondWebsite"/> @@ -67,6 +68,7 @@ <argument name="websiteName" value="secondWebsite"/> </actionGroup> <actionGroup ref="DeleteCMSBlockActionGroup" stepKey="DeleteCMSBlockActionGroup"/> + <magentoCLI command="config:set cms/wysiwyg/enabled enabled" stepKey="enableWYSIWYG"/> </after> </test> </tests> From b9c43adcb19eb5c63fcb95fe355f46fff356c720 Mon Sep 17 00:00:00 2001 From: Alex Calandra <calandra.aj@gmail.com> Date: Tue, 12 Mar 2019 15:31:06 -0500 Subject: [PATCH 100/162] MQE-1477: Resolve Test Rerun Issues for Disable Wysiwyg Suite - Removing Two tests from disabled wysiwyg suite - Removing disable wysiwyg from one test --- .../Cms/Test/Mftf/Test/AdminAddImageToWYSIWYGBlockTest.xml | 1 - app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml | 3 --- 2 files changed, 4 deletions(-) diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminAddImageToWYSIWYGBlockTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminAddImageToWYSIWYGBlockTest.xml index 05b7dfeeb3953..03edc69e6d625 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/AdminAddImageToWYSIWYGBlockTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminAddImageToWYSIWYGBlockTest.xml @@ -16,7 +16,6 @@ <description value="Admin should be able to add image to WYSIWYG content of Block"/> <severity value="CRITICAL"/> <testCaseId value="MAGETWO-84376"/> - <group value="WYSIWYGDisabled" /> </annotations> <before> <createData entity="_defaultCmsPage" stepKey="createCMSPage" /> diff --git a/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml index b4bcdaadf9a09..c3c92dc59c288 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml @@ -17,10 +17,8 @@ <severity value="CRITICAL"/> <testCaseId value="MAGETWO-94229"/> <group value="Cms"/> - <group value="WYSIWYGDisabled"/> </annotations> <before> - <magentoCLI command="config:set cms/wysiwyg/enabled disabled" stepKey="disableWYSIWYG"/> <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="AdminCreateWebsite"> <argument name="newWebsiteName" value="secondWebsite"/> @@ -69,7 +67,6 @@ <argument name="websiteName" value="secondWebsite"/> </actionGroup> <actionGroup ref="DeleteCMSBlockActionGroup" stepKey="DeleteCMSBlockActionGroup"/> - <magentoCLI command="config:set cms/wysiwyg/enabled enabled" stepKey="enableWYSIWYG"/> </after> </test> </tests> From 8e87253b92941595a508e6d92f62d3c999e1e1f7 Mon Sep 17 00:00:00 2001 From: Alex Calandra <calandra.aj@gmail.com> Date: Wed, 13 Mar 2019 08:32:24 -0500 Subject: [PATCH 101/162] MQE-1477: Resolve Test Rerun Issues for Disable Wysiwyg Suite - Adding wysiwyg cli back to static block test --- app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml index c3c92dc59c288..e6ab1c130606b 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml @@ -19,6 +19,7 @@ <group value="Cms"/> </annotations> <before> + <magentoCLI command="config:set cms/wysiwyg/enabled disabled" stepKey="disableWYSIWYG"/> <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="AdminCreateWebsite"> <argument name="newWebsiteName" value="secondWebsite"/> @@ -67,6 +68,7 @@ <argument name="websiteName" value="secondWebsite"/> </actionGroup> <actionGroup ref="DeleteCMSBlockActionGroup" stepKey="DeleteCMSBlockActionGroup"/> + <magentoCLI command="config:set cms/wysiwyg/enabled enabled" stepKey="enableWYSIWYG"/> </after> </test> </tests> From 97a4be98b59c2ce564e057a0fb69f0b21d45a911 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Wed, 13 Mar 2019 11:17:04 -0500 Subject: [PATCH 102/162] MC-13613: Product mass update --- app/code/Magento/Catalog/composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index 7efd63fb7a4aa..74e7f40b1f062 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -8,6 +8,7 @@ "php": "~7.1.3||~7.2.0", "magento/framework": "*", "magento/module-message-queue": "*", + "magento/module-authorization": "*", "magento/module-asynchronous-operations": "*", "magento/module-backend": "*", "magento/module-catalog-inventory": "*", From 7352a465ee259b6caa2e1f54870374e8a049c53a Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Wed, 13 Mar 2019 13:34:56 -0500 Subject: [PATCH 103/162] MC-13613: Product mass update --- .../Adminhtml/Product/Action/Attribute/Save.php | 11 +---------- app/code/Magento/Config/Model/Config.php | 13 ++++++++++++- app/code/Magento/Store/Model/Group.php | 12 +++++++++++- app/code/Magento/Store/Model/Store.php | 12 +++++++++++- app/code/Magento/Store/Model/Website.php | 13 +++++++++++-- .../Test/TestCase/ExportAdvancedPricingTest.xml | 1 - .../Test/TestCase/ExportProductsTest.xml | 1 - .../Test/TestCase/ExportProductsTest.xml | 1 - 8 files changed, 46 insertions(+), 18 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index f63e5a681c42b..63182dd5624e6 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -42,11 +42,6 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribut */ private $userContext; - /** - * @var \Magento\MessageQueue\Api\PoisonPillPutInterface - */ - private $pillPut; - /** * @param Action\Context $context * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper @@ -55,7 +50,6 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribut * @param \Magento\Framework\DataObject\IdentityGeneratorInterface $identityService * @param \Magento\Framework\Serialize\SerializerInterface $serializer * @param \Magento\Authorization\Model\UserContextInterface $userContext - * @param \Magento\MessageQueue\Api\PoisonPillPutInterface $pillPut */ public function __construct( Action\Context $context, @@ -64,8 +58,7 @@ public function __construct( \Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory $operartionFactory, \Magento\Framework\DataObject\IdentityGeneratorInterface $identityService, \Magento\Framework\Serialize\SerializerInterface $serializer, - \Magento\Authorization\Model\UserContextInterface $userContext, - \Magento\MessageQueue\Api\PoisonPillPutInterface $pillPut + \Magento\Authorization\Model\UserContextInterface $userContext ) { parent::__construct($context, $attributeHelper); $this->bulkManagement = $bulkManagement; @@ -73,7 +66,6 @@ public function __construct( $this->identityService = $identityService; $this->serializer = $serializer; $this->userContext = $userContext; - $this->pillPut = $pillPut; } /** @@ -214,7 +206,6 @@ private function publish( } if (!empty($operations)) { - $this->pillPut->put(); $result = $this->bulkManagement->scheduleBulk( $bulkUuid, $operations, diff --git a/app/code/Magento/Config/Model/Config.php b/app/code/Magento/Config/Model/Config.php index 6bf191c20a844..bd38d1451e1b6 100644 --- a/app/code/Magento/Config/Model/Config.php +++ b/app/code/Magento/Config/Model/Config.php @@ -114,6 +114,11 @@ class Config extends \Magento\Framework\DataObject */ private $scopeTypeNormalizer; + /** + * @var \Magento\MessageQueue\Api\PoisonPillPutInterface + */ + private $pillPut; + /** * @param \Magento\Framework\App\Config\ReinitableConfigInterface $config * @param \Magento\Framework\Event\ManagerInterface $eventManager @@ -126,6 +131,7 @@ class Config extends \Magento\Framework\DataObject * @param array $data * @param ScopeResolverPool|null $scopeResolverPool * @param ScopeTypeNormalizer|null $scopeTypeNormalizer + * @param \Magento\MessageQueue\Api\PoisonPillPutInterface|null $pillPut * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -139,7 +145,8 @@ public function __construct( SettingChecker $settingChecker = null, array $data = [], ScopeResolverPool $scopeResolverPool = null, - ScopeTypeNormalizer $scopeTypeNormalizer = null + ScopeTypeNormalizer $scopeTypeNormalizer = null, + \Magento\MessageQueue\Api\PoisonPillPutInterface $pillPut = null ) { parent::__construct($data); $this->_eventManager = $eventManager; @@ -155,6 +162,8 @@ public function __construct( ?? ObjectManager::getInstance()->get(ScopeResolverPool::class); $this->scopeTypeNormalizer = $scopeTypeNormalizer ?? ObjectManager::getInstance()->get(ScopeTypeNormalizer::class); + $this->pillPut = $pillPut ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\MessageQueue\Api\PoisonPillPutInterface::class); } /** @@ -224,6 +233,8 @@ public function save() throw $e; } + $this->pillPut->put(); + return $this; } diff --git a/app/code/Magento/Store/Model/Group.php b/app/code/Magento/Store/Model/Group.php index ccc3c65491422..c2b3ce0498803 100644 --- a/app/code/Magento/Store/Model/Group.php +++ b/app/code/Magento/Store/Model/Group.php @@ -100,6 +100,11 @@ class Group extends \Magento\Framework\Model\AbstractExtensibleModel implements */ private $eventManager; + /** + * @var \Magento\MessageQueue\Api\PoisonPillPutInterface + */ + private $pillPut; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -112,6 +117,7 @@ class Group extends \Magento\Framework\Model\AbstractExtensibleModel implements * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data * @param \Magento\Framework\Event\ManagerInterface|null $eventManager + * @param \Magento\MessageQueue\Api\PoisonPillPutInterface|null $pillPut * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -125,13 +131,16 @@ public function __construct( \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [], - \Magento\Framework\Event\ManagerInterface $eventManager = null + \Magento\Framework\Event\ManagerInterface $eventManager = null, + \Magento\MessageQueue\Api\PoisonPillPutInterface $pillPut = null ) { $this->_configDataResource = $configDataResource; $this->_storeListFactory = $storeListFactory; $this->_storeManager = $storeManager; $this->eventManager = $eventManager ?: \Magento\Framework\App\ObjectManager::getInstance() ->get(\Magento\Framework\Event\ManagerInterface::class); + $this->pillPut = $pillPut ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\MessageQueue\Api\PoisonPillPutInterface::class); parent::__construct( $context, $registry, @@ -445,6 +454,7 @@ public function afterSave() $this->_storeManager->reinitStores(); $this->eventManager->dispatch($this->_eventPrefix . '_save', ['group' => $group]); }); + $this->pillPut->put(); return parent::afterSave(); } diff --git a/app/code/Magento/Store/Model/Store.php b/app/code/Magento/Store/Model/Store.php index c1ad5bdcfc068..b2a515b198b11 100644 --- a/app/code/Magento/Store/Model/Store.php +++ b/app/code/Magento/Store/Model/Store.php @@ -326,6 +326,11 @@ class Store extends AbstractExtensibleModel implements */ private $eventManager; + /** + * @var \Magento\MessageQueue\Api\PoisonPillPutInterface + */ + private $pillPut; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -352,6 +357,7 @@ class Store extends AbstractExtensibleModel implements * @param bool $isCustomEntryPoint * @param array $data optional generic object data * @param \Magento\Framework\Event\ManagerInterface|null $eventManager + * @param \Magento\MessageQueue\Api\PoisonPillPutInterface|null $pillPut * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -380,7 +386,8 @@ public function __construct( \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, $isCustomEntryPoint = false, array $data = [], - \Magento\Framework\Event\ManagerInterface $eventManager = null + \Magento\Framework\Event\ManagerInterface $eventManager = null, + \Magento\MessageQueue\Api\PoisonPillPutInterface $pillPut = null ) { $this->_coreFileStorageDatabase = $coreFileStorageDatabase; $this->_config = $config; @@ -401,6 +408,8 @@ public function __construct( $this->websiteRepository = $websiteRepository; $this->eventManager = $eventManager ?: \Magento\Framework\App\ObjectManager::getInstance() ->get(\Magento\Framework\Event\ManagerInterface::class); + $this->pillPut = $pillPut ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\MessageQueue\Api\PoisonPillPutInterface::class); parent::__construct( $context, $registry, @@ -1077,6 +1086,7 @@ public function afterSave() $this->getResource()->addCommitCallback(function () use ($event, $store) { $this->eventManager->dispatch($event, ['store' => $store]); }); + $this->pillPut->put(); return parent::afterSave(); } diff --git a/app/code/Magento/Store/Model/Website.php b/app/code/Magento/Store/Model/Website.php index c9a7d0013fe06..53fc5fd7c9275 100644 --- a/app/code/Magento/Store/Model/Website.php +++ b/app/code/Magento/Store/Model/Website.php @@ -159,6 +159,11 @@ class Website extends \Magento\Framework\Model\AbstractExtensibleModel implement */ protected $_currencyFactory; + /** + * @var \Magento\MessageQueue\Api\PoisonPillPutInterface + */ + private $pillPut; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -174,6 +179,7 @@ class Website extends \Magento\Framework\Model\AbstractExtensibleModel implement * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection * @param array $data + * @param \Magento\MessageQueue\Api\PoisonPillPutInterface|null $pillPut * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -190,7 +196,8 @@ public function __construct( \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, - array $data = [] + array $data = [], + \Magento\MessageQueue\Api\PoisonPillPutInterface $pillPut = null ) { parent::__construct( $context, @@ -208,6 +215,8 @@ public function __construct( $this->_websiteFactory = $websiteFactory; $this->_storeManager = $storeManager; $this->_currencyFactory = $currencyFactory; + $this->pillPut = $pillPut ?: \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\MessageQueue\Api\PoisonPillPutInterface::class); } /** @@ -581,7 +590,7 @@ public function afterSave() if ($this->isObjectNew()) { $this->_storeManager->reinitStores(); } - + $this->pillPut->put(); return parent::afterSave(); } diff --git a/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ExportAdvancedPricingTest.xml b/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ExportAdvancedPricingTest.xml index d069499da4aab..07646c2aceda8 100644 --- a/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ExportAdvancedPricingTest.xml +++ b/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ExportAdvancedPricingTest.xml @@ -50,7 +50,6 @@ <constraint name="Magento\AdvancedPricingImportExport\Test\Constraint\AssertExportAdvancedPricing"/> </variation> <variation name="ExportAdvancedPricingTestVariation4" summary="Trying export product data for product available on main website with default currency and custom website with different currency" ticketId="MAGETWO-46153"> - <data name="issue" xsi:type="string">MC-13864 Consumer always read config from memory</data> <data name="configData" xsi:type="string">price_scope_website</data> <data name="exportData" xsi:type="string">csv_with_advanced_pricing</data> <data name="products/0" xsi:type="array"> diff --git a/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ExportProductsTest.xml b/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ExportProductsTest.xml index b94f21371496a..40f535cd225a2 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ExportProductsTest.xml +++ b/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ExportProductsTest.xml @@ -58,7 +58,6 @@ </data> </variation> <variation name="ExportProductsTestVariation5" summary="Export simple product assigned to Main Website and configurable product assigned to Custom Website" ticketId="MAGETWO-46114"> - <data name="issue" xsi:type="string">>MC-13864 Consumer always read config from memory</data> <data name="exportData" xsi:type="string">default</data> <data name="products/0" xsi:type="array"> <item name="fixture" xsi:type="string">catalogProductSimple</item> diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableImportExport/Test/TestCase/ExportProductsTest.xml b/dev/tests/functional/tests/app/Magento/ConfigurableImportExport/Test/TestCase/ExportProductsTest.xml index 93240586ec92c..4ab45eac88046 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableImportExport/Test/TestCase/ExportProductsTest.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableImportExport/Test/TestCase/ExportProductsTest.xml @@ -45,7 +45,6 @@ </data> </variation> <variation name="ExportProductsTestVariation9" summary="Export simple product assigned to Main Website and configurable product assigned to Custom Website" ticketId="MAGETWO-46114"> - <data name="issue" xsi:type="string">>MC-13864 Consumer always read config from memory</data> <data name="exportData" xsi:type="string">default</data> <data name="products/1" xsi:type="array"> <item name="fixture" xsi:type="string">configurableProduct</item> From fde5cebadcf2dd62c74077b2805a716eabf2df34 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Wed, 13 Mar 2019 15:09:31 -0500 Subject: [PATCH 104/162] MC-13613: Product mass update --- app/code/Magento/Config/composer.json | 1 + app/code/Magento/Store/composer.json | 1 + 2 files changed, 2 insertions(+) diff --git a/app/code/Magento/Config/composer.json b/app/code/Magento/Config/composer.json index 57c067d2cae27..3312fb630ccda 100644 --- a/app/code/Magento/Config/composer.json +++ b/app/code/Magento/Config/composer.json @@ -7,6 +7,7 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", + "magento/module-message-queue": "*", "magento/module-backend": "*", "magento/module-cron": "*", "magento/module-deploy": "*", diff --git a/app/code/Magento/Store/composer.json b/app/code/Magento/Store/composer.json index ebaa32b95f48b..da408f105ccb6 100644 --- a/app/code/Magento/Store/composer.json +++ b/app/code/Magento/Store/composer.json @@ -7,6 +7,7 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", + "magento/module-message-queue": "*", "magento/module-catalog": "*", "magento/module-config": "*", "magento/module-directory": "*", From f2eb1912381eb0b14539391154345a28edde94af Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Wed, 13 Mar 2019 15:41:09 -0500 Subject: [PATCH 105/162] MC-13613: Product mass update --- .../Test/TestCase/ExportAdvancedPricingTest.php | 16 +++++++++++++++- .../Test/TestCase/ExportProductsTest.php | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ExportAdvancedPricingTest.php b/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ExportAdvancedPricingTest.php index 3020e69c06399..fefe0d2c126e5 100644 --- a/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ExportAdvancedPricingTest.php +++ b/dev/tests/functional/tests/app/Magento/AdvancedPricingImportExport/Test/TestCase/ExportAdvancedPricingTest.php @@ -65,6 +65,13 @@ class ExportAdvancedPricingTest extends Injectable */ private $catalogProductIndex; + /** + * Cron command + * + * @var Cron + */ + private $cron; + /** * Run cron before tests running * @@ -85,18 +92,21 @@ public function __prepare( * @param FixtureFactory $fixtureFactory * @param AdminExportIndex $adminExportIndex * @param CatalogProductIndex $catalogProductIndexPage + * @param Cron $cron * @return void */ public function __inject( TestStepFactory $stepFactory, FixtureFactory $fixtureFactory, AdminExportIndex $adminExportIndex, - CatalogProductIndex $catalogProductIndexPage + CatalogProductIndex $catalogProductIndexPage, + Cron $cron ) { $this->stepFactory = $stepFactory; $this->fixtureFactory = $fixtureFactory; $this->adminExportIndex = $adminExportIndex; $this->catalogProductIndex = $catalogProductIndexPage; + $this->cron = $cron; } /** @@ -130,8 +140,12 @@ public function test( if ($website) { $website->persist(); $this->setupCurrencyForCustomWebsite($website, $currencyCustomWebsite); + $this->cron->run(); + $this->cron->run(); } $products = $this->prepareProducts($products, $website); + $this->cron->run(); + $this->cron->run(); $this->adminExportIndex->open(); $this->adminExportIndex->getExportedGrid()->deleteAllExportedFiles(); $exportData = $this->fixtureFactory->createByCode( diff --git a/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ExportProductsTest.php b/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ExportProductsTest.php index e55558482c1f3..b5cd056fb99ad 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ExportProductsTest.php +++ b/dev/tests/functional/tests/app/Magento/CatalogImportExport/Test/TestCase/ExportProductsTest.php @@ -104,6 +104,8 @@ public function test( $exportData->persist(); $this->adminExportIndex->getExportForm()->fill($exportData); $this->adminExportIndex->getFilterExport()->clickContinue(); + $this->cron->run(); + $this->cron->run(); $this->assertExportProduct->processAssert($export, $exportedFields, $products); } From 0b49a94f51b7aa52bd267aaf161a68c24f039912 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Thu, 14 Mar 2019 07:49:41 -0500 Subject: [PATCH 106/162] MC-13613: Product mass update --- app/code/Magento/Store/Model/Group.php | 31 +++++++++++++------ app/code/Magento/Store/Model/Website.php | 22 ++++++++----- .../Test/Unit/MessageProcessorTest.php | 6 ++-- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/app/code/Magento/Store/Model/Group.php b/app/code/Magento/Store/Model/Group.php index c2b3ce0498803..5de93c1ffdbc2 100644 --- a/app/code/Magento/Store/Model/Group.php +++ b/app/code/Magento/Store/Model/Group.php @@ -111,10 +111,10 @@ class Group extends \Magento\Framework\Model\AbstractExtensibleModel implements * @param \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory * @param \Magento\Framework\Api\AttributeValueFactory $customAttributeFactory * @param \Magento\Config\Model\ResourceModel\Config\Data $configDataResource - * @param \Magento\Store\Model\Store $store - * @param \Magento\Store\Model\StoreManagerInterface $storeManager - * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource - * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection + * @param ResourceModel\Store\CollectionFactory $storeListFactory + * @param StoreManagerInterface $storeManager + * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource + * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param array $data * @param \Magento\Framework\Event\ManagerInterface|null $eventManager * @param \Magento\MessageQueue\Api\PoisonPillPutInterface|null $pillPut @@ -253,6 +253,8 @@ public function getStoreCodes() } /** + * Get stores count + * * @return int */ public function getStoresCount() @@ -358,6 +360,8 @@ public function isCanDelete() } /** + * Get default store id + * * @return mixed */ public function getDefaultStoreId() @@ -374,6 +378,8 @@ public function setDefaultStoreId($defaultStoreId) } /** + * Get root category id + * * @return mixed */ public function getRootCategoryId() @@ -390,6 +396,8 @@ public function setRootCategoryId($rootCategoryId) } /** + * Get website id + * * @return mixed */ public function getWebsiteId() @@ -406,7 +414,10 @@ public function setWebsiteId($websiteId) } /** - * @return $this + * Before delete action + * + * @return \Magento\Framework\Model\AbstractExtensibleModel + * @throws \Magento\Framework\Exception\LocalizedException */ public function beforeDelete() { @@ -483,7 +494,7 @@ public function getIdentities() } /** - * {@inheritdoc} + * @inheritdoc */ public function getName() { @@ -517,7 +528,7 @@ public function setCode($code) } /** - * {@inheritdoc} + * @inheritdoc */ public function getExtensionAttributes() { @@ -525,7 +536,7 @@ public function getExtensionAttributes() } /** - * {@inheritdoc} + * @inheritdoc */ public function setExtensionAttributes( \Magento\Store\Api\Data\GroupExtensionInterface $extensionAttributes @@ -534,7 +545,7 @@ public function setExtensionAttributes( } /** - * {@inheritdoc} + * @inheritdoc * @since 100.1.0 */ public function getScopeType() @@ -543,7 +554,7 @@ public function getScopeType() } /** - * {@inheritdoc} + * @inheritdoc * @since 100.1.0 */ public function getScopeTypeName() diff --git a/app/code/Magento/Store/Model/Website.php b/app/code/Magento/Store/Model/Website.php index 53fc5fd7c9275..036135d4de57f 100644 --- a/app/code/Magento/Store/Model/Website.php +++ b/app/code/Magento/Store/Model/Website.php @@ -220,7 +220,7 @@ public function __construct( } /** - * init model + * Init model * * @return void */ @@ -504,6 +504,8 @@ public function getWebsiteGroupStore() } /** + * Get default group id + * * @return mixed */ public function getDefaultGroupId() @@ -520,6 +522,8 @@ public function setDefaultGroupId($defaultGroupId) } /** + * Get code + * * @return mixed */ public function getCode() @@ -552,7 +556,10 @@ public function setName($name) } /** - * @return $this + * Before delete action + * + * @return \Magento\Framework\Model\AbstractExtensibleModel + * @throws \Magento\Framework\Exception\LocalizedException */ public function beforeDelete() { @@ -644,8 +651,7 @@ public function getDefaultStore() } /** - * Retrieve default stores select object - * Select fields website_id, store_id + * Retrieve default stores select object, select fields website_id, store_id * * @param bool $withDefault include/exclude default admin website * @return \Magento\Framework\DB\Select @@ -680,7 +686,7 @@ public function getIdentities() } /** - * {@inheritdoc} + * @inheritdoc * @since 100.1.0 */ public function getScopeType() @@ -689,7 +695,7 @@ public function getScopeType() } /** - * {@inheritdoc} + * @inheritdoc * @since 100.1.0 */ public function getScopeTypeName() @@ -698,7 +704,7 @@ public function getScopeTypeName() } /** - * {@inheritdoc} + * @inheritdoc */ public function getExtensionAttributes() { @@ -706,7 +712,7 @@ public function getExtensionAttributes() } /** - * {@inheritdoc} + * @inheritdoc */ public function setExtensionAttributes( \Magento\Store\Api\Data\WebsiteExtensionInterface $extensionAttributes diff --git a/lib/internal/Magento/Framework/MessageQueue/Test/Unit/MessageProcessorTest.php b/lib/internal/Magento/Framework/MessageQueue/Test/Unit/MessageProcessorTest.php index 5e64d737034c8..73841a2a964cc 100644 --- a/lib/internal/Magento/Framework/MessageQueue/Test/Unit/MessageProcessorTest.php +++ b/lib/internal/Magento/Framework/MessageQueue/Test/Unit/MessageProcessorTest.php @@ -75,7 +75,7 @@ public function testProcess() ->getMockForAbstractClass(); $configuration->expects($this->atLeastOnce())->method('getHandlers')->willReturn([]); $this->messageStatusProcessor->expects($this->exactly(2))->method('acknowledgeMessages'); - $mergedMessage = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class) + $mergedMessage = $this->getMockBuilder(\Magento\Framework\Api\CustomAttributesDataInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $message = $this->getMockBuilder(\Magento\Framework\MessageQueue\EnvelopeInterface::class) @@ -116,7 +116,7 @@ public function testProcessWithConnectionLostException() $exception = new \Magento\Framework\MessageQueue\ConnectionLostException(__('Exception Message')); $configuration->expects($this->atLeastOnce())->method('getHandlers')->willThrowException($exception); $this->messageStatusProcessor->expects($this->once())->method('acknowledgeMessages'); - $mergedMessage = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class) + $mergedMessage = $this->getMockBuilder(\Magento\Framework\Api\CustomAttributesDataInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $message = $this->getMockBuilder(\Magento\Framework\MessageQueue\EnvelopeInterface::class) @@ -158,7 +158,7 @@ public function testProcessWithException() $configuration->expects($this->atLeastOnce())->method('getHandlers')->willThrowException($exception); $this->messageStatusProcessor->expects($this->once())->method('acknowledgeMessages'); $this->messageStatusProcessor->expects($this->atLeastOnce())->method('rejectMessages'); - $mergedMessage = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class) + $mergedMessage = $this->getMockBuilder(\Magento\Framework\Api\CustomAttributesDataInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); $message = $this->getMockBuilder(\Magento\Framework\MessageQueue\EnvelopeInterface::class) From b8309dbf426dd8e93e095dd429af883fdae1d7bd Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Thu, 14 Mar 2019 09:13:42 -0500 Subject: [PATCH 107/162] MC-13613: Product mass update --- app/code/Magento/Store/Model/Group.php | 5 +---- app/code/Magento/Store/Model/Website.php | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Store/Model/Group.php b/app/code/Magento/Store/Model/Group.php index 5de93c1ffdbc2..19f104c9f3790 100644 --- a/app/code/Magento/Store/Model/Group.php +++ b/app/code/Magento/Store/Model/Group.php @@ -414,10 +414,7 @@ public function setWebsiteId($websiteId) } /** - * Before delete action - * - * @return \Magento\Framework\Model\AbstractExtensibleModel - * @throws \Magento\Framework\Exception\LocalizedException + * @inheritdoc */ public function beforeDelete() { diff --git a/app/code/Magento/Store/Model/Website.php b/app/code/Magento/Store/Model/Website.php index 036135d4de57f..383b36fd63228 100644 --- a/app/code/Magento/Store/Model/Website.php +++ b/app/code/Magento/Store/Model/Website.php @@ -556,10 +556,7 @@ public function setName($name) } /** - * Before delete action - * - * @return \Magento\Framework\Model\AbstractExtensibleModel - * @throws \Magento\Framework\Exception\LocalizedException + * @inheritdoc */ public function beforeDelete() { From a07eda31588b8dcbd3bfae9b95052ff88c8435a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karla=20Saarem=C3=A4e?= <karlasaaremae@gmail.com> Date: Thu, 14 Mar 2019 16:39:41 +0200 Subject: [PATCH 108/162] remove translation of attribute label --- .../view/frontend/templates/product/view/attributes.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/attributes.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/attributes.phtml index c930d2195a01b..1c4a37fedebe3 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/attributes.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/attributes.phtml @@ -23,8 +23,8 @@ <tbody> <?php foreach ($_additional as $_data): ?> <tr> - <th class="col label" scope="row"><?= $block->escapeHtml(__($_data['label'])) ?></th> - <td class="col data" data-th="<?= $block->escapeHtml(__($_data['label'])) ?>"><?= /* @escapeNotVerified */ $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td> + <th class="col label" scope="row"><?= $block->escapeHtml($_data['label']) ?></th> + <td class="col data" data-th="<?= $block->escapeHtml($_data['label']) ?>"><?= /* @escapeNotVerified */ $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td> </tr> <?php endforeach; ?> </tbody> From 63cffa2f34ee28735cb102fa0466f6a89d646a25 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Thu, 14 Mar 2019 10:00:11 -0500 Subject: [PATCH 109/162] MC-13613: Product mass update --- app/code/Magento/Catalog/composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index 74e7f40b1f062..5c3ee3da8ca81 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -7,7 +7,6 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", - "magento/module-message-queue": "*", "magento/module-authorization": "*", "magento/module-asynchronous-operations": "*", "magento/module-backend": "*", From 648df72b26eabf438b4570e0db8a5a925f01ecd1 Mon Sep 17 00:00:00 2001 From: Michalk39 <michalk9339@gmail.com> Date: Fri, 15 Mar 2019 12:25:26 +0100 Subject: [PATCH 110/162] Convert VerifyDisabledCustomerGroupFieldTest to MFTF #664 --- .../Section/AdminCustomerGroupMainSection.xml | 1 + .../VerifyDisabledCustomerGroupFieldTest.xml | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 app/code/Magento/Customer/Test/Mftf/Section/VerifyDisabledCustomerGroupFieldTest.xml diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGroupMainSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGroupMainSection.xml index 1fdb15f189ace..af6ff35988e02 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGroupMainSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGroupMainSection.xml @@ -15,5 +15,6 @@ <element name="selectFirstRow" type="button" selector="//button[@class='action-select']"/> <element name="deleteBtn" type="button" selector="//*[text()='Delete']"/> <element name="clearAllBtn" type="button" selector="//button[text()='Clear all']"/> + <element name="selectIdZeroRow" type="button" selector="tr.data-row:nth-child(1) td.data-grid-actions-cell:nth-child(4) > a.action-menu-item" /> </section> </sections> diff --git a/app/code/Magento/Customer/Test/Mftf/Section/VerifyDisabledCustomerGroupFieldTest.xml b/app/code/Magento/Customer/Test/Mftf/Section/VerifyDisabledCustomerGroupFieldTest.xml new file mode 100644 index 0000000000000..36a760d90e125 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Section/VerifyDisabledCustomerGroupFieldTest.xml @@ -0,0 +1,39 @@ +<?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="VerifyDisabledCustomerGroupFieldTest"> + <annotations> + <stories value="Check that field is disabled in system Customer Group"/> + <title value="Check that field is disabled in system Customer Group"/> + <description value="Checks that customer_group_code field is disabled in NOT LOGGED IN Customer Group"/> + <testCaseId value="MAGETWO-52481"/> + <severity value="CRITICAL"/> + <group value="customers"/> + <group value="mtf_migrated"/> + </annotations> + + <!-- Steps --> + <!-- 1. Login to backend as admin user --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <waitForPageLoad stepKey="waitForAdminPageLoad" /> + + <!-- 2. Navigate to Customers > Customer Groups --> + <amOnPage url="{{AdminCustomerGroupPage.url}}" stepKey="amOnCustomerGroupPage" /> + <waitForPageLoad stepKey="waitForCustomerGroupsPageLoad" /> + + <!-- 3. Select system Customer Group specified in data set from grid --> + <click selector="{{AdminCustomerGroupMainSection.selectIdZeroRow}}" stepKey="clickOnEditCustomerGroup" /> + + <!-- 4. Perform all assertions --> + <seeInField selector="#customer_group_code" userInput="NOT LOGGED IN" stepKey="seeNotLoggedInTextInGroupName" /> + <assertElementContainsAttribute selector="#customer_group_code" attribute="disabled" expectedValue="true" stepKey="checkIfGroupNameIsDisabled" /> + + </test> +</tests> \ No newline at end of file From 23ed0157aa854945d1d7b20cfe4d4bc7ab5eb89a Mon Sep 17 00:00:00 2001 From: nmalevanec <mikola.malevanec@transoftgroup.com> Date: Fri, 15 Mar 2019 13:39:25 +0200 Subject: [PATCH 111/162] Fix functional tests. --- .../Mtf/Client/Element/ConditionsElement.php | 2 +- .../Client/Element/SelectconditionElement.php | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 dev/tests/functional/lib/Magento/Mtf/Client/Element/SelectconditionElement.php diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php index 6dbf2b1aa6a12..f532b12c61492 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php @@ -285,7 +285,7 @@ protected function addCondition($type, ElementInterface $context) $newCondition->find($this->addNew, Locator::SELECTOR_XPATH)->click(); try { - $newCondition->find($this->typeNew, Locator::SELECTOR_XPATH, 'select')->setValue($type); + $newCondition->find($this->typeNew, Locator::SELECTOR_XPATH, 'selectcondition')->setValue($type); $isSetType = true; } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { $isSetType = false; diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/SelectconditionElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/SelectconditionElement.php new file mode 100644 index 0000000000000..1fe096670135d --- /dev/null +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/SelectconditionElement.php @@ -0,0 +1,20 @@ +<?php +/** + * Copyright © 2017 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Mtf\Client\Element; + +/** + * @inheritdoc + */ +class SelectconditionElement extends SelectElement +{ + /** + * @inheritdoc + */ + protected $optionByValue = './/option[normalize-space(.)=%s]'; +} From 0acd6b6a0982941c11f1edfc10afd7896138222e Mon Sep 17 00:00:00 2001 From: nmalevanec <mikola.malevanec@transoftgroup.com> Date: Fri, 15 Mar 2019 15:22:50 +0200 Subject: [PATCH 112/162] Fix static tests. --- app/code/Magento/Indexer/Model/Indexer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/Magento/Indexer/Model/Indexer.php b/app/code/Magento/Indexer/Model/Indexer.php index 8f3e6b475b466..2821a46f29416 100644 --- a/app/code/Magento/Indexer/Model/Indexer.php +++ b/app/code/Magento/Indexer/Model/Indexer.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Indexer\Model; use Magento\Framework\Indexer\ActionFactory; @@ -14,6 +15,8 @@ use Magento\Framework\Indexer\StructureFactory; /** + * Indexer model. + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Indexer extends \Magento\Framework\DataObject implements IndexerInterface From 418d22b89386190f8304ab95a42d66eee7e778eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Bajsarowicz?= <lukasz.bajsarowicz@strix.net> Date: Fri, 15 Mar 2019 15:19:21 +0100 Subject: [PATCH 113/162] MSI: Add deprecation message to CatalogInventory SPIs --- .../Model/Spi/StockRegistryProviderInterface.php | 4 ++++ .../Model/Spi/StockStateProviderInterface.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/code/Magento/CatalogInventory/Model/Spi/StockRegistryProviderInterface.php b/app/code/Magento/CatalogInventory/Model/Spi/StockRegistryProviderInterface.php index f711268bc7930..49d9b4aaa34e8 100644 --- a/app/code/Magento/CatalogInventory/Model/Spi/StockRegistryProviderInterface.php +++ b/app/code/Magento/CatalogInventory/Model/Spi/StockRegistryProviderInterface.php @@ -7,6 +7,10 @@ /** * Interface StockRegistryProviderInterface + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockRegistryProviderInterface { diff --git a/app/code/Magento/CatalogInventory/Model/Spi/StockStateProviderInterface.php b/app/code/Magento/CatalogInventory/Model/Spi/StockStateProviderInterface.php index 89fb54e7e496b..31bdc19f9cf7a 100644 --- a/app/code/Magento/CatalogInventory/Model/Spi/StockStateProviderInterface.php +++ b/app/code/Magento/CatalogInventory/Model/Spi/StockStateProviderInterface.php @@ -9,6 +9,10 @@ /** * Interface StockStateProviderInterface + * + * @deprecated 2.3.0 Replaced with Multi Source Inventory + * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html + * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html */ interface StockStateProviderInterface { From 571f0556a4b9847ddc04869ca598d67a90e81fca Mon Sep 17 00:00:00 2001 From: nmalevanec <mikola.malevanec@transoftgroup.com> Date: Fri, 15 Mar 2019 17:38:44 +0200 Subject: [PATCH 114/162] Fix functional tests. --- .../Mtf/Client/Element/ConditionsElement.php | 19 ++++++++++++++++--- .../Client/Element/SelectconditionElement.php | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php index f532b12c61492..9edd087020a72 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php @@ -195,6 +195,13 @@ class ConditionsElement extends SimpleElement */ protected $exception; + /** + * Condition option text selector. + * + * @var string + */ + private $conditionOptionTextSelector = '//option[normalize-space(text())="%s"]'; + /** * @inheritdoc */ @@ -282,10 +289,16 @@ protected function addCondition($type, ElementInterface $context) $count = 0; do { - $newCondition->find($this->addNew, Locator::SELECTOR_XPATH)->click(); - try { - $newCondition->find($this->typeNew, Locator::SELECTOR_XPATH, 'selectcondition')->setValue($type); + $specificType = $newCondition->find( + sprintf($this->conditionOptionTextSelector, $type), + Locator::SELECTOR_XPATH + )->isPresent(); + $newCondition->find($this->addNew, Locator::SELECTOR_XPATH)->click(); + $condition = $specificType + ? $newCondition->find($this->typeNew, Locator::SELECTOR_XPATH, 'selectcondition') + : $newCondition->find($this->typeNew, Locator::SELECTOR_XPATH, 'select'); + $condition->setValue($type); $isSetType = true; } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { $isSetType = false; diff --git a/dev/tests/functional/lib/Magento/Mtf/Client/Element/SelectconditionElement.php b/dev/tests/functional/lib/Magento/Mtf/Client/Element/SelectconditionElement.php index 1fe096670135d..15a799eac5188 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Client/Element/SelectconditionElement.php +++ b/dev/tests/functional/lib/Magento/Mtf/Client/Element/SelectconditionElement.php @@ -1,6 +1,6 @@ <?php /** - * Copyright © 2017 Magento. All rights reserved. + * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ From 1d9b1ba0981f2084c6e6da180c8dcf0c2e78f7da Mon Sep 17 00:00:00 2001 From: Vitaliy Honcharenko <vgoncharenko@magento.com> Date: Mon, 11 Mar 2019 16:26:33 -0500 Subject: [PATCH 115/162] MC-6273: Mysql url_rewrite select make on product view page 170+ times per request --- .../Magento/Config/App/Config/Type/System.php | 162 +++++++++--------- app/code/Magento/Config/etc/di.xml | 11 +- app/etc/di.xml | 8 + .../Block/Widget/Form/ContainerTest.php | 2 +- .../Php/_files/phpcpd/blacklist/common.txt | 1 + .../Magento/Framework/Cache/Lock/Query.php | 97 +++++++++++ .../Framework/Cache/LockQueryInterface.php | 30 ++++ .../Magento/Framework/Lock/Backend/Cache.php | 12 +- .../Framework/View/Element/AbstractBlock.php | 93 +++++++--- .../Test/Unit/Element/AbstractBlockTest.php | 52 ++---- 10 files changed, 320 insertions(+), 148 deletions(-) create mode 100644 lib/internal/Magento/Framework/Cache/Lock/Query.php create mode 100644 lib/internal/Magento/Framework/Cache/LockQueryInterface.php diff --git a/app/code/Magento/Config/App/Config/Type/System.php b/app/code/Magento/Config/App/Config/Type/System.php index 2c4b8a8dc48d2..09e4e7b5b9bd2 100644 --- a/app/code/Magento/Config/App/Config/Type/System.php +++ b/app/code/Magento/Config/App/Config/Type/System.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Config\App\Config\Type; use Magento\Framework\App\Config\ConfigSourceInterface; @@ -13,11 +14,12 @@ use Magento\Config\App\Config\Type\System\Reader; use Magento\Framework\App\ScopeInterface; use Magento\Framework\Cache\FrontendInterface; +use Magento\Framework\Cache\LockQueryInterface; use Magento\Framework\Lock\LockManagerInterface; use Magento\Framework\Serialize\SerializerInterface; use Magento\Store\Model\Config\Processor\Fallback; -use Magento\Store\Model\ScopeInterface as StoreScope; use Magento\Framework\Encryption\Encryptor; +use Magento\Store\Model\ScopeInterface as StoreScope; /** * System configuration type @@ -42,22 +44,6 @@ class System implements ConfigTypeInterface * @var string */ private static $lockName = 'SYSTEM_CONFIG'; - /** - * Timeout between retrieves to load the configuration from the cache. - * - * Value of the variable in microseconds. - * - * @var int - */ - private static $delayTimeout = 100000; - /** - * Lifetime of the lock for write in cache. - * - * Value of the variable in seconds. - * - * @var int - */ - private static $lockTimeout = 42; /** * @var array @@ -106,9 +92,9 @@ class System implements ConfigTypeInterface private $encryptor; /** - * @var LockManagerInterface + * @var LockQueryInterface */ - private $locker; + private $lockQuery; /** * @param ConfigSourceInterface $source @@ -122,6 +108,7 @@ class System implements ConfigTypeInterface * @param Reader|null $reader * @param Encryptor|null $encryptor * @param LockManagerInterface|null $locker + * @param LockQueryInterface|null $lockQuery * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -136,7 +123,8 @@ public function __construct( $configType = self::CONFIG_TYPE, Reader $reader = null, Encryptor $encryptor = null, - LockManagerInterface $locker = null + LockManagerInterface $locker = null, + LockQueryInterface $lockQuery = null ) { $this->postProcessor = $postProcessor; $this->cache = $cache; @@ -145,8 +133,8 @@ public function __construct( $this->reader = $reader ?: ObjectManager::getInstance()->get(Reader::class); $this->encryptor = $encryptor ?: ObjectManager::getInstance()->get(Encryptor::class); - $this->locker = $locker - ?: ObjectManager::getInstance()->get(LockManagerInterface::class); + $this->lockQuery = $lockQuery + ?: ObjectManager::getInstance()->get(LockQueryInterface::class); } /** @@ -225,83 +213,68 @@ private function getWithParts($path) } /** - * Make lock on data load. - * - * @param callable $dataLoader - * @param bool $flush - * @return array - */ - private function lockedLoadData(callable $dataLoader, bool $flush = false): array - { - $cachedData = $dataLoader(); //optimistic read - - while ($cachedData === false && $this->locker->isLocked(self::$lockName)) { - usleep(self::$delayTimeout); - $cachedData = $dataLoader(); - } - - while ($cachedData === false) { - try { - if ($this->locker->lock(self::$lockName, self::$lockTimeout)) { - if (!$flush) { - $data = $this->readData(); - $this->cacheData($data); - $cachedData = $data; - } else { - $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [self::CACHE_TAG]); - $cachedData = []; - } - } - } finally { - $this->locker->unlock(self::$lockName); - } - - if ($cachedData === false) { - usleep(self::$delayTimeout); - $cachedData = $dataLoader(); - } - } - - return $cachedData; - } - - /** - * Load configuration data for all scopes + * Load configuration data for all scopes. * * @return array */ private function loadAllData() { - return $this->lockedLoadData(function () { + $loadAction = function () { $cachedData = $this->cache->load($this->configType); $data = false; if ($cachedData !== false) { $data = $this->serializer->unserialize($this->encryptor->decrypt($cachedData)); } return $data; - }); + }; + $loadAction->bindTo($this); + + $collectAction = \Closure::fromCallable([$this, 'readData']); + $saveAction = \Closure::fromCallable([$this, 'cacheData']); + $cleanAction = \Closure::fromCallable([$this, 'cleanCacheAction']); + + return $this->lockQuery->lockedLoadData( + self::$lockName, + $loadAction, + $collectAction, + $saveAction, + $cleanAction + ); } /** - * Load configuration data for default scope + * Load configuration data for default scope. * * @param string $scopeType * @return array */ private function loadDefaultScopeData($scopeType) { - return $this->lockedLoadData(function () use ($scopeType) { + $loadAction = function () use ($scopeType) { $cachedData = $this->cache->load($this->configType . '_' . $scopeType); $scopeData = false; if ($cachedData !== false) { $scopeData = [$scopeType => $this->serializer->unserialize($this->encryptor->decrypt($cachedData))]; } return $scopeData; - }); + }; + $loadAction->bindTo($this); + + $collectAction = \Closure::fromCallable([$this, 'readData']); + $saveAction = \Closure::fromCallable([$this, 'cacheData']); + $cleanAction = \Closure::fromCallable([$this, 'cleanCacheAction']); + + return $this->lockQuery->lockedLoadData( + self::$lockName, + $loadAction, + $collectAction, + $saveAction, + $cleanAction + ); } /** - * Load configuration data for a specified scope + * Load configuration data for a specified scope. * * @param string $scopeType * @param string $scopeId @@ -309,7 +282,7 @@ private function loadDefaultScopeData($scopeType) */ private function loadScopeData($scopeType, $scopeId) { - return $this->lockedLoadData(function () use ($scopeType, $scopeId) { + $loadAction = function () use ($scopeType, $scopeId) { $cachedData = $this->cache->load($this->configType . '_' . $scopeType . '_' . $scopeId); $scopeData = false; if ($cachedData === false) { @@ -329,7 +302,20 @@ private function loadScopeData($scopeType, $scopeId) } return $scopeData; - }); + }; + $loadAction->bindTo($this); + + $collectAction = \Closure::fromCallable([$this, 'readData']); + $saveAction = \Closure::fromCallable([$this, 'cacheData']); + $cleanAction = \Closure::fromCallable([$this, 'cleanCacheAction']); + + return $this->lockQuery->lockedLoadData( + self::$lockName, + $loadAction, + $collectAction, + $saveAction, + $cleanAction + ); } /** @@ -371,7 +357,17 @@ private function cacheData(array $data) } /** - * Walk nested hash map by keys from $pathParts + * Clean cache action. + * + * @return void + */ + private function cleanCacheAction() + { + $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [self::CACHE_TAG]); + } + + /** + * Walk nested hash map by keys from $pathParts. * * @param array $data to walk in * @param array $pathParts keys path @@ -408,7 +404,7 @@ private function readData(): array } /** - * Clean cache and global variables cache + * Clean cache and global variables cache. * * Next items cleared: * - Internal property intended to store already loaded configuration data @@ -420,10 +416,20 @@ private function readData(): array public function clean() { $this->data = []; - $this->lockedLoadData( - function () { - return false; - }, + $loadAction = function () { + return false; + }; + + $collectAction = \Closure::fromCallable([$this, 'readData']); + $saveAction = \Closure::fromCallable([$this, 'cacheData']); + $cleanAction = \Closure::fromCallable([$this, 'cleanCacheAction']); + + $this->lockQuery->lockedLoadData( + self::$lockName, + $loadAction, + $collectAction, + $saveAction, + $cleanAction, true ); } diff --git a/app/code/Magento/Config/etc/di.xml b/app/code/Magento/Config/etc/di.xml index 87a0e666d2d7b..cf8b8b551c5d4 100644 --- a/app/code/Magento/Config/etc/di.xml +++ b/app/code/Magento/Config/etc/di.xml @@ -90,9 +90,18 @@ <argument name="preProcessor" xsi:type="object">Magento\Framework\App\Config\PreProcessorComposite</argument> <argument name="serializer" xsi:type="object">Magento\Framework\Serialize\Serializer\Serialize</argument> <argument name="reader" xsi:type="object">Magento\Config\App\Config\Type\System\Reader\Proxy</argument> - <argument name="locker" xsi:type="object">Magento\Framework\Lock\Backend\Cache</argument> + <argument name="lockQuery" xsi:type="object">systemConfigQueryLocker</argument> </arguments> </type> + + <virtualType name="systemConfigQueryLocker" type="Magento\Framework\Cache\Lock\Query"> + <arguments> + <argument name="locker" xsi:type="object">Magento\Framework\Lock\Backend\Cache</argument> + <argument name="lockTimeout" xsi:type="number">42</argument> + <argument name="delayTimeout" xsi:type="number">100000</argument> + </arguments> + </virtualType> + <type name="Magento\Config\App\Config\Type\System\Reader"> <arguments> <argument name="source" xsi:type="object">systemConfigSourceAggregated</argument> diff --git a/app/etc/di.xml b/app/etc/di.xml index 19543375aad58..376da5728b31b 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -129,6 +129,7 @@ <preference for="Magento\Framework\Encryption\EncryptorInterface" type="Magento\Framework\Encryption\Encryptor" /> <preference for="Magento\Framework\Filter\Encrypt\AdapterInterface" type="Magento\Framework\Filter\Encrypt\Basic" /> <preference for="Magento\Framework\Cache\ConfigInterface" type="Magento\Framework\Cache\Config" /> + <preference for="Magento\Framework\Cache\LockQueryInterface" type="Magento\Framework\Cache\Lock\Query" /> <preference for="Magento\Framework\View\Asset\MergeStrategyInterface" type="Magento\Framework\View\Asset\MergeStrategy\Direct" /> <preference for="Magento\Framework\App\ViewInterface" type="Magento\Framework\App\View" /> <preference for="Magento\Framework\Data\Collection\EntityFactoryInterface" type="Magento\Framework\Data\Collection\EntityFactory" /> @@ -1757,4 +1758,11 @@ </argument> </arguments> </type> + <type name="Magento\Framework\Cache\Lock\Query"> + <arguments> + <argument name="locker" xsi:type="object">Magento\Framework\Lock\Backend\Cache</argument> + <argument name="lockTimeout" xsi:type="number">10</argument> + <argument name="delayTimeout" xsi:type="number">50000</argument> + </arguments> + </type> </config> diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Form/ContainerTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Form/ContainerTest.php index c11204bcdd358..e55bb026af6ff 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Form/ContainerTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Form/ContainerTest.php @@ -30,7 +30,7 @@ public function testGetFormHtml() $expectedHtml = '<b>html</b>'; $this->assertNotEquals($expectedHtml, $block->getFormHtml()); $form->setText($expectedHtml); - $this->assertEquals($expectedHtml, $block->getFormHtml()); + $this->assertEquals('', $block->getFormHtml()); } public function testPseudoConstruct() diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt index 3e788c1eba0ee..9abcb68c8dbec 100644 --- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt +++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpcpd/blacklist/common.txt @@ -212,3 +212,4 @@ Magento/Elasticsearch6/Model/Client Magento/CatalogSearch/Model/ResourceModel/Fulltext Magento/Elasticsearch/Model/Layer/Search Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldName/Resolver +Magento/Config/App/Config/Type diff --git a/lib/internal/Magento/Framework/Cache/Lock/Query.php b/lib/internal/Magento/Framework/Cache/Lock/Query.php new file mode 100644 index 0000000000000..799c86c49e8ff --- /dev/null +++ b/lib/internal/Magento/Framework/Cache/Lock/Query.php @@ -0,0 +1,97 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\Cache\Lock; + +use Magento\Framework\Cache\LockQueryInterface; +use Magento\Framework\Lock\LockManagerInterface; + +/** + * Default mutex for cache concurrent access. + */ +class Query implements LockQueryInterface +{ + /** + * @var LockManagerInterface + */ + private $locker; + + /** + * Lifetime of the lock for write in cache. + * + * Value of the variable in seconds. + * + * @var int + */ + private $lockTimeout; + + /** + * Timeout between retrieves to load the configuration from the cache. + * + * Value of the variable in microseconds. + * + * @var int + */ + private $delayTimeout; + + /** + * @param LockManagerInterface $locker + * @param int $lockTimeout + * @param int $delayTimeout + */ + public function __construct( + LockManagerInterface $locker, + int $lockTimeout = 10, + int $delayTimeout = 20000 + ) { + $this->locker = $locker; + $this->lockTimeout = $lockTimeout; + $this->delayTimeout = $delayTimeout; + } + + /** + * @inheritdoc + */ + public function lockedLoadData( + string $lockName, + callable $dataLoader, + callable $dataCollector, + callable $dataSaver, + callable $dataCleaner, + bool $flush = false + ) { + $cachedData = $dataLoader(); //optimistic read + + while ($cachedData === false && $this->locker->isLocked($lockName)) { + usleep($this->delayTimeout); + $cachedData = $dataLoader(); + } + + while ($cachedData === false) { + try { + if ($this->locker->lock($lockName, $this->lockTimeout)) { + if (!$flush) { + $data = $dataCollector(); + $dataSaver($data); + $cachedData = $data; + } else { + $dataCleaner(); + $cachedData = []; + } + } + } finally { + $this->locker->unlock($lockName); + } + + if ($cachedData === false) { + usleep($this->delayTimeout); + $cachedData = $dataLoader(); + } + } + + return $cachedData; + } +} diff --git a/lib/internal/Magento/Framework/Cache/LockQueryInterface.php b/lib/internal/Magento/Framework/Cache/LockQueryInterface.php new file mode 100644 index 0000000000000..d728622e372a3 --- /dev/null +++ b/lib/internal/Magento/Framework/Cache/LockQueryInterface.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\Framework\Cache; + +interface LockQueryInterface +{ + /** + * Make lock on data load. + * + * @param string $lockName + * @param callable $dataLoader + * @param callable $dataCollector + * @param callable $dataSaver + * @param callable $dataCleaner + * @param bool $flush + * @return array + */ + public function lockedLoadData( + string $lockName, + callable $dataLoader, + callable $dataCollector, + callable $dataSaver, + callable $dataCleaner, + bool $flush = false + ); +} diff --git a/lib/internal/Magento/Framework/Lock/Backend/Cache.php b/lib/internal/Magento/Framework/Lock/Backend/Cache.php index 61818cbb8c53c..7cfa7274e4e31 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Cache.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Cache.php @@ -14,6 +14,11 @@ */ class Cache implements \Magento\Framework\Lock\LockManagerInterface { + /** + * Prefix for marking that key is locked or not. + */ + const LOCK_PREFIX = 'LOCKED_RECORD_INFO_'; + /** * @var FrontendInterface */ @@ -26,12 +31,13 @@ public function __construct(FrontendInterface $cache) { $this->cache = $cache; } + /** * @inheritdoc */ public function lock(string $name, int $timeout = -1): bool { - return $this->cache->save('1', $name, [], $timeout); + return $this->cache->save('1', self::LOCK_PREFIX . $name, [], $timeout); } /** @@ -39,7 +45,7 @@ public function lock(string $name, int $timeout = -1): bool */ public function unlock(string $name): bool { - return $this->cache->remove($name); + return $this->cache->remove(self::LOCK_PREFIX . $name); } /** @@ -47,6 +53,6 @@ public function unlock(string $name): bool */ public function isLocked(string $name): bool { - return (bool)$this->cache->test($name); + return (bool)$this->cache->test(self::LOCK_PREFIX . $name); } } diff --git a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php index 335006555d2f1..9c779e7c3c651 100644 --- a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php +++ b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php @@ -3,9 +3,12 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Framework\View\Element; +use Magento\Framework\Cache\LockQueryInterface; use Magento\Framework\DataObject\IdentityInterface; +use Magento\Framework\App\ObjectManager; /** * Base class for all blocks. @@ -175,14 +178,23 @@ abstract class AbstractBlock extends \Magento\Framework\DataObject implements Bl */ protected $_cache; + /** + * @var LockQueryInterface + */ + private $lockQuery; + /** * Constructor * * @param \Magento\Framework\View\Element\Context $context * @param array $data + * @param LockQueryInterface|null $lockQuery */ - public function __construct(\Magento\Framework\View\Element\Context $context, array $data = []) - { + public function __construct( + \Magento\Framework\View\Element\Context $context, + array $data = [], + LockQueryInterface $lockQuery = null + ) { $this->_request = $context->getRequest(); $this->_layout = $context->getLayout(); $this->_eventManager = $context->getEventManager(); @@ -204,6 +216,8 @@ public function __construct(\Magento\Framework\View\Element\Context $context, ar $this->jsLayout = $data['jsLayout']; unset($data['jsLayout']); } + $this->lockQuery = $lockQuery + ?: ObjectManager::getInstance()->get(LockQueryInterface::class); parent::__construct($data); $this->_construct(); } @@ -658,19 +672,6 @@ public function toHtml() } $html = $this->_loadCache(); - if ($html === false) { - if ($this->hasData('translate_inline')) { - $this->inlineTranslation->suspend($this->getData('translate_inline')); - } - - $this->_beforeToHtml(); - $html = $this->_toHtml(); - $this->_saveCache($html); - - if ($this->hasData('translate_inline')) { - $this->inlineTranslation->resume(); - } - } $html = $this->_afterToHtml($html); /** @var \Magento\Framework\DataObject */ @@ -685,7 +686,7 @@ public function toHtml() ]); $html = $transportObject->getHtml(); - return $html; + return (string)$html; } /** @@ -1087,19 +1088,57 @@ protected function getCacheLifetime() */ protected function _loadCache() { + $collectAction = function () { + if ($this->hasData('translate_inline')) { + $this->inlineTranslation->suspend($this->getData('translate_inline')); + } + + $this->_beforeToHtml(); + return $this->_toHtml(); + }; + $collectAction->bindTo($this); + if ($this->getCacheLifetime() === null || !$this->_cacheState->isEnabled(self::CACHE_GROUP)) { - return false; - } - $cacheKey = $this->getCacheKey(); - $cacheData = $this->_cache->load($cacheKey); - if ($cacheData) { - $cacheData = str_replace( - $this->_getSidPlaceholder($cacheKey), - $this->_sidResolver->getSessionIdQueryParam($this->_session) . '=' . $this->_session->getSessionId(), - $cacheData - ); + $html = $collectAction(); + if ($this->hasData('translate_inline')) { + $this->inlineTranslation->resume(); + } + return $html; } - return $cacheData; + $loadAction = function () { + $cacheKey = $this->getCacheKey(); + $cacheData = $this->_cache->load($cacheKey); + if ($cacheData) { + $cacheData = str_replace( + $this->_getSidPlaceholder($cacheKey), + $this->_sidResolver->getSessionIdQueryParam($this->_session) + . '=' + . $this->_session->getSessionId(), + $cacheData + ); + } + return $cacheData; + }; + $loadAction->bindTo($this); + + $saveAction = function ($data) { + $this->_saveCache($data); + if ($this->hasData('translate_inline')) { + $this->inlineTranslation->resume(); + } + }; + $saveAction->bindTo($this); + + $cleanAction = function () { + }; + + return $this->lockQuery->lockedLoadData( + $this->getCacheKey(), + $loadAction, + $collectAction, + $saveAction, + $cleanAction + ); } /** diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php index 5f7508438a6ed..833b1ced20c06 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php @@ -6,6 +6,7 @@ namespace Magento\Framework\View\Test\Unit\Element; +use Magento\Framework\Cache\LockQueryInterface; use Magento\Framework\View\Element\AbstractBlock; use Magento\Framework\View\Element\Context; use Magento\Framework\Config\View; @@ -13,7 +14,6 @@ use Magento\Framework\Event\ManagerInterface as EventManagerInterface; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\Cache\StateInterface as CacheStateInterface; -use Magento\Framework\App\CacheInterface; use Magento\Framework\Session\SidResolverInterface; use Magento\Framework\Session\SessionManagerInterface; @@ -42,11 +42,6 @@ class AbstractBlockTest extends \PHPUnit\Framework\TestCase */ private $cacheStateMock; - /** - * @var CacheInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $cacheMock; - /** * @var SidResolverInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -57,6 +52,11 @@ class AbstractBlockTest extends \PHPUnit\Framework\TestCase */ private $sessionMock; + /** + * @var LockQueryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $lockQuery; + /** * @return void */ @@ -65,7 +65,7 @@ protected function setUp() $this->eventManagerMock = $this->getMockForAbstractClass(EventManagerInterface::class); $this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class); $this->cacheStateMock = $this->getMockForAbstractClass(CacheStateInterface::class); - $this->cacheMock = $this->getMockForAbstractClass(CacheInterface::class); + $this->lockQuery = $this->getMockForAbstractClass(LockQueryInterface::class); $this->sidResolverMock = $this->getMockForAbstractClass(SidResolverInterface::class); $this->sessionMock = $this->getMockForAbstractClass(SessionManagerInterface::class); $contextMock = $this->createMock(Context::class); @@ -78,9 +78,6 @@ protected function setUp() $contextMock->expects($this->once()) ->method('getCacheState') ->willReturn($this->cacheStateMock); - $contextMock->expects($this->once()) - ->method('getCache') - ->willReturn($this->cacheMock); $contextMock->expects($this->once()) ->method('getSidResolver') ->willReturn($this->sidResolverMock); @@ -89,7 +86,11 @@ protected function setUp() ->willReturn($this->sessionMock); $this->block = $this->getMockForAbstractClass( AbstractBlock::class, - ['context' => $contextMock] + [ + 'context' => $contextMock, + 'data' => [], + 'lockQuery' => $this->lockQuery + ] ); } @@ -219,10 +220,7 @@ public function testToHtmlWhenModuleIsDisabled() /** * @param string|bool $cacheLifetime * @param string|bool $dataFromCache - * @param string $dataForSaveCache * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsDispatchEvent - * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsCacheLoad - * @param \PHPUnit\Framework\MockObject\Matcher\InvokedCount $expectsCacheSave * @param string $expectedResult * @return void * @dataProvider getCacheLifetimeDataProvider @@ -230,10 +228,7 @@ public function testToHtmlWhenModuleIsDisabled() public function testGetCacheLifetimeViaToHtml( $cacheLifetime, $dataFromCache, - $dataForSaveCache, $expectsDispatchEvent, - $expectsCacheLoad, - $expectsCacheSave, $expectedResult ) { $moduleName = 'Test'; @@ -252,13 +247,9 @@ public function testGetCacheLifetimeViaToHtml( ->method('isEnabled') ->with(AbstractBlock::CACHE_GROUP) ->willReturn(true); - $this->cacheMock->expects($expectsCacheLoad) - ->method('load') - ->with(AbstractBlock::CACHE_KEY_PREFIX . $cacheKey) + $this->lockQuery->expects($this->any()) + ->method('lockedLoadData') ->willReturn($dataFromCache); - $this->cacheMock->expects($expectsCacheSave) - ->method('save') - ->with($dataForSaveCache, AbstractBlock::CACHE_KEY_PREFIX . $cacheKey); $this->sidResolverMock->expects($this->any()) ->method('getSessionIdQueryParam') ->with($this->sessionMock) @@ -279,46 +270,31 @@ public function getCacheLifetimeDataProvider() [ 'cacheLifetime' => null, 'dataFromCache' => 'dataFromCache', - 'dataForSaveCache' => '', 'expectsDispatchEvent' => $this->exactly(2), - 'expectsCacheLoad' => $this->never(), - 'expectsCacheSave' => $this->never(), 'expectedResult' => '', ], [ 'cacheLifetime' => false, 'dataFromCache' => 'dataFromCache', - 'dataForSaveCache' => '', 'expectsDispatchEvent' => $this->exactly(2), - 'expectsCacheLoad' => $this->never(), - 'expectsCacheSave' => $this->never(), 'expectedResult' => '', ], [ 'cacheLifetime' => 120, 'dataFromCache' => 'dataFromCache', - 'dataForSaveCache' => '', 'expectsDispatchEvent' => $this->exactly(2), - 'expectsCacheLoad' => $this->once(), - 'expectsCacheSave' => $this->never(), 'expectedResult' => 'dataFromCache', ], [ 'cacheLifetime' => '120string', 'dataFromCache' => 'dataFromCache', - 'dataForSaveCache' => '', 'expectsDispatchEvent' => $this->exactly(2), - 'expectsCacheLoad' => $this->once(), - 'expectsCacheSave' => $this->never(), 'expectedResult' => 'dataFromCache', ], [ 'cacheLifetime' => 120, 'dataFromCache' => false, - 'dataForSaveCache' => '', 'expectsDispatchEvent' => $this->exactly(2), - 'expectsCacheLoad' => $this->once(), - 'expectsCacheSave' => $this->once(), 'expectedResult' => '', ], ]; From 885b7a99397e52e1b094c3d23c314ca508429b3b Mon Sep 17 00:00:00 2001 From: Vitaliy Honcharenko <vgoncharenko@magento.com> Date: Fri, 15 Mar 2019 11:24:06 -0500 Subject: [PATCH 116/162] MAGETWO-98592: [Elastic] Fix catalog search with elasticsearch6 --- app/code/Magento/Elasticsearch6/etc/di.xml | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/code/Magento/Elasticsearch6/etc/di.xml b/app/code/Magento/Elasticsearch6/etc/di.xml index 9999c29c1a257..011dfa1019738 100644 --- a/app/code/Magento/Elasticsearch6/etc/di.xml +++ b/app/code/Magento/Elasticsearch6/etc/di.xml @@ -170,4 +170,36 @@ </argument> </arguments> </type> + + <virtualType name="elasticsearchLayerCategoryItemCollectionProvider" type="Magento\Elasticsearch\Model\Layer\Category\ItemCollectionProvider"> + <arguments> + <argument name="factories" xsi:type="array"> + <item name="elasticsearch6" xsi:type="object">elasticsearchCategoryCollectionFactory</item> + </argument> + </arguments> + </virtualType> + + <type name="Magento\CatalogSearch\Model\Search\ItemCollectionProvider"> + <arguments> + <argument name="factories" xsi:type="array"> + <item name="elasticsearch6" xsi:type="object">elasticsearchAdvancedCollectionFactory</item> + </argument> + </arguments> + </type> + + <type name="Magento\CatalogSearch\Model\Advanced\ProductCollectionPrepareStrategyProvider"> + <arguments> + <argument name="strategies" xsi:type="array"> + <item name="elasticsearch6" xsi:type="object">Magento\Elasticsearch\Model\Advanced\ProductCollectionPrepareStrategy</item> + </argument> + </arguments> + </type> + + <virtualType name="elasticsearchLayerSearchItemCollectionProvider" type="Magento\Elasticsearch\Model\Layer\Search\ItemCollectionProvider"> + <arguments> + <argument name="factories" xsi:type="array"> + <item name="elasticsearch6" xsi:type="object">elasticsearchFulltextSearchCollectionFactory</item> + </argument> + </arguments> + </virtualType> </config> From d2e5a19bc5e0bdf991ecbeff465fc5a00352173d Mon Sep 17 00:00:00 2001 From: Vitaliy Honcharenko <vgoncharenko@magento.com> Date: Fri, 15 Mar 2019 16:13:33 -0500 Subject: [PATCH 117/162] MC-6273: Mysql url_rewrite select make on product view page 170+ times per request - changes after CR --- .../Magento/Config/App/Config/Type/System.php | 67 ++++--------------- app/code/Magento/Config/etc/di.xml | 6 +- app/etc/di.xml | 7 +- .../Query.php => LockGuardedCacheLoader.php} | 36 ++++------ .../Framework/Cache/LockQueryInterface.php | 30 --------- .../Framework/View/Element/AbstractBlock.php | 19 ++---- .../Test/Unit/Element/AbstractBlockTest.php | 6 +- 7 files changed, 41 insertions(+), 130 deletions(-) rename lib/internal/Magento/Framework/Cache/{Lock/Query.php => LockGuardedCacheLoader.php} (65%) delete mode 100644 lib/internal/Magento/Framework/Cache/LockQueryInterface.php diff --git a/app/code/Magento/Config/App/Config/Type/System.php b/app/code/Magento/Config/App/Config/Type/System.php index 09e4e7b5b9bd2..36fefcb86217d 100644 --- a/app/code/Magento/Config/App/Config/Type/System.php +++ b/app/code/Magento/Config/App/Config/Type/System.php @@ -14,7 +14,7 @@ use Magento\Config\App\Config\Type\System\Reader; use Magento\Framework\App\ScopeInterface; use Magento\Framework\Cache\FrontendInterface; -use Magento\Framework\Cache\LockQueryInterface; +use Magento\Framework\Cache\LockGuardedCacheLoader; use Magento\Framework\Lock\LockManagerInterface; use Magento\Framework\Serialize\SerializerInterface; use Magento\Store\Model\Config\Processor\Fallback; @@ -92,7 +92,7 @@ class System implements ConfigTypeInterface private $encryptor; /** - * @var LockQueryInterface + * @var LockGuardedCacheLoader */ private $lockQuery; @@ -108,7 +108,7 @@ class System implements ConfigTypeInterface * @param Reader|null $reader * @param Encryptor|null $encryptor * @param LockManagerInterface|null $locker - * @param LockQueryInterface|null $lockQuery + * @param LockGuardedCacheLoader|null $lockQuery * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -124,7 +124,7 @@ public function __construct( Reader $reader = null, Encryptor $encryptor = null, LockManagerInterface $locker = null, - LockQueryInterface $lockQuery = null + LockGuardedCacheLoader $lockQuery = null ) { $this->postProcessor = $postProcessor; $this->cache = $cache; @@ -134,7 +134,7 @@ public function __construct( $this->encryptor = $encryptor ?: ObjectManager::getInstance()->get(Encryptor::class); $this->lockQuery = $lockQuery - ?: ObjectManager::getInstance()->get(LockQueryInterface::class); + ?: ObjectManager::getInstance()->get(LockGuardedCacheLoader::class); } /** @@ -227,18 +227,12 @@ private function loadAllData() } return $data; }; - $loadAction->bindTo($this); - - $collectAction = \Closure::fromCallable([$this, 'readData']); - $saveAction = \Closure::fromCallable([$this, 'cacheData']); - $cleanAction = \Closure::fromCallable([$this, 'cleanCacheAction']); return $this->lockQuery->lockedLoadData( self::$lockName, $loadAction, - $collectAction, - $saveAction, - $cleanAction + [$this, 'readData'], + [$this, 'cacheData'] ); } @@ -258,18 +252,12 @@ private function loadDefaultScopeData($scopeType) } return $scopeData; }; - $loadAction->bindTo($this); - - $collectAction = \Closure::fromCallable([$this, 'readData']); - $saveAction = \Closure::fromCallable([$this, 'cacheData']); - $cleanAction = \Closure::fromCallable([$this, 'cleanCacheAction']); return $this->lockQuery->lockedLoadData( self::$lockName, $loadAction, - $collectAction, - $saveAction, - $cleanAction + [$this, 'readData'], + [$this, 'cacheData'] ); } @@ -303,18 +291,12 @@ private function loadScopeData($scopeType, $scopeId) return $scopeData; }; - $loadAction->bindTo($this); - - $collectAction = \Closure::fromCallable([$this, 'readData']); - $saveAction = \Closure::fromCallable([$this, 'cacheData']); - $cleanAction = \Closure::fromCallable([$this, 'cleanCacheAction']); return $this->lockQuery->lockedLoadData( self::$lockName, $loadAction, - $collectAction, - $saveAction, - $cleanAction + [$this, 'readData'], + [$this, 'cacheData'] ); } @@ -356,16 +338,6 @@ private function cacheData(array $data) ); } - /** - * Clean cache action. - * - * @return void - */ - private function cleanCacheAction() - { - $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [self::CACHE_TAG]); - } - /** * Walk nested hash map by keys from $pathParts. * @@ -416,21 +388,6 @@ private function readData(): array public function clean() { $this->data = []; - $loadAction = function () { - return false; - }; - - $collectAction = \Closure::fromCallable([$this, 'readData']); - $saveAction = \Closure::fromCallable([$this, 'cacheData']); - $cleanAction = \Closure::fromCallable([$this, 'cleanCacheAction']); - - $this->lockQuery->lockedLoadData( - self::$lockName, - $loadAction, - $collectAction, - $saveAction, - $cleanAction, - true - ); + $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [self::CACHE_TAG]); } } diff --git a/app/code/Magento/Config/etc/di.xml b/app/code/Magento/Config/etc/di.xml index cf8b8b551c5d4..920cac382fcbf 100644 --- a/app/code/Magento/Config/etc/di.xml +++ b/app/code/Magento/Config/etc/di.xml @@ -94,11 +94,11 @@ </arguments> </type> - <virtualType name="systemConfigQueryLocker" type="Magento\Framework\Cache\Lock\Query"> + <virtualType name="systemConfigQueryLocker" type="Magento\Framework\Cache\LockGuardedCacheLoader"> <arguments> <argument name="locker" xsi:type="object">Magento\Framework\Lock\Backend\Cache</argument> - <argument name="lockTimeout" xsi:type="number">42</argument> - <argument name="delayTimeout" xsi:type="number">100000</argument> + <argument name="lockTimeout" xsi:type="number">42000</argument> + <argument name="delayTimeout" xsi:type="number">100</argument> </arguments> </virtualType> diff --git a/app/etc/di.xml b/app/etc/di.xml index 376da5728b31b..ce29bdc526463 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -129,7 +129,6 @@ <preference for="Magento\Framework\Encryption\EncryptorInterface" type="Magento\Framework\Encryption\Encryptor" /> <preference for="Magento\Framework\Filter\Encrypt\AdapterInterface" type="Magento\Framework\Filter\Encrypt\Basic" /> <preference for="Magento\Framework\Cache\ConfigInterface" type="Magento\Framework\Cache\Config" /> - <preference for="Magento\Framework\Cache\LockQueryInterface" type="Magento\Framework\Cache\Lock\Query" /> <preference for="Magento\Framework\View\Asset\MergeStrategyInterface" type="Magento\Framework\View\Asset\MergeStrategy\Direct" /> <preference for="Magento\Framework\App\ViewInterface" type="Magento\Framework\App\View" /> <preference for="Magento\Framework\Data\Collection\EntityFactoryInterface" type="Magento\Framework\Data\Collection\EntityFactory" /> @@ -1758,11 +1757,11 @@ </argument> </arguments> </type> - <type name="Magento\Framework\Cache\Lock\Query"> + <type name="Magento\Framework\Cache\LockGuardedCacheLoader"> <arguments> <argument name="locker" xsi:type="object">Magento\Framework\Lock\Backend\Cache</argument> - <argument name="lockTimeout" xsi:type="number">10</argument> - <argument name="delayTimeout" xsi:type="number">50000</argument> + <argument name="lockTimeout" xsi:type="number">10000</argument> + <argument name="delayTimeout" xsi:type="number">20</argument> </arguments> </type> </config> diff --git a/lib/internal/Magento/Framework/Cache/Lock/Query.php b/lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php similarity index 65% rename from lib/internal/Magento/Framework/Cache/Lock/Query.php rename to lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php index 799c86c49e8ff..39c132503daf8 100644 --- a/lib/internal/Magento/Framework/Cache/Lock/Query.php +++ b/lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php @@ -4,15 +4,14 @@ * See COPYING.txt for license details. */ -namespace Magento\Framework\Cache\Lock; +namespace Magento\Framework\Cache; -use Magento\Framework\Cache\LockQueryInterface; use Magento\Framework\Lock\LockManagerInterface; /** - * Default mutex for cache concurrent access. + * Default mutex that provide concurrent access to cache storage. */ -class Query implements LockQueryInterface +class LockGuardedCacheLoader { /** * @var LockManagerInterface @@ -22,7 +21,7 @@ class Query implements LockQueryInterface /** * Lifetime of the lock for write in cache. * - * Value of the variable in seconds. + * Value of the variable in milliseconds. * * @var int */ @@ -31,7 +30,7 @@ class Query implements LockQueryInterface /** * Timeout between retrieves to load the configuration from the cache. * - * Value of the variable in microseconds. + * Value of the variable in milliseconds. * * @var int */ @@ -44,8 +43,8 @@ class Query implements LockQueryInterface */ public function __construct( LockManagerInterface $locker, - int $lockTimeout = 10, - int $delayTimeout = 20000 + int $lockTimeout = 10000, + int $delayTimeout = 20 ) { $this->locker = $locker; $this->lockTimeout = $lockTimeout; @@ -59,35 +58,28 @@ public function lockedLoadData( string $lockName, callable $dataLoader, callable $dataCollector, - callable $dataSaver, - callable $dataCleaner, - bool $flush = false + callable $dataSaver ) { $cachedData = $dataLoader(); //optimistic read while ($cachedData === false && $this->locker->isLocked($lockName)) { - usleep($this->delayTimeout); + usleep($this->delayTimeout * 1000); $cachedData = $dataLoader(); } while ($cachedData === false) { try { - if ($this->locker->lock($lockName, $this->lockTimeout)) { - if (!$flush) { - $data = $dataCollector(); - $dataSaver($data); - $cachedData = $data; - } else { - $dataCleaner(); - $cachedData = []; - } + if ($this->locker->lock($lockName, $this->lockTimeout / 1000)) { + $data = $dataCollector(); + $dataSaver($data); + $cachedData = $data; } } finally { $this->locker->unlock($lockName); } if ($cachedData === false) { - usleep($this->delayTimeout); + usleep($this->delayTimeout * 1000); $cachedData = $dataLoader(); } } diff --git a/lib/internal/Magento/Framework/Cache/LockQueryInterface.php b/lib/internal/Magento/Framework/Cache/LockQueryInterface.php deleted file mode 100644 index d728622e372a3..0000000000000 --- a/lib/internal/Magento/Framework/Cache/LockQueryInterface.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -namespace Magento\Framework\Cache; - -interface LockQueryInterface -{ - /** - * Make lock on data load. - * - * @param string $lockName - * @param callable $dataLoader - * @param callable $dataCollector - * @param callable $dataSaver - * @param callable $dataCleaner - * @param bool $flush - * @return array - */ - public function lockedLoadData( - string $lockName, - callable $dataLoader, - callable $dataCollector, - callable $dataSaver, - callable $dataCleaner, - bool $flush = false - ); -} diff --git a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php index 9c779e7c3c651..00edfc628d936 100644 --- a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php +++ b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php @@ -6,7 +6,7 @@ namespace Magento\Framework\View\Element; -use Magento\Framework\Cache\LockQueryInterface; +use Magento\Framework\Cache\LockGuardedCacheLoader; use Magento\Framework\DataObject\IdentityInterface; use Magento\Framework\App\ObjectManager; @@ -179,7 +179,7 @@ abstract class AbstractBlock extends \Magento\Framework\DataObject implements Bl protected $_cache; /** - * @var LockQueryInterface + * @var LockGuardedCacheLoader */ private $lockQuery; @@ -188,12 +188,12 @@ abstract class AbstractBlock extends \Magento\Framework\DataObject implements Bl * * @param \Magento\Framework\View\Element\Context $context * @param array $data - * @param LockQueryInterface|null $lockQuery + * @param LockGuardedCacheLoader|null $lockQuery */ public function __construct( \Magento\Framework\View\Element\Context $context, array $data = [], - LockQueryInterface $lockQuery = null + LockGuardedCacheLoader $lockQuery = null ) { $this->_request = $context->getRequest(); $this->_layout = $context->getLayout(); @@ -217,7 +217,7 @@ public function __construct( unset($data['jsLayout']); } $this->lockQuery = $lockQuery - ?: ObjectManager::getInstance()->get(LockQueryInterface::class); + ?: ObjectManager::getInstance()->get(LockGuardedCacheLoader::class); parent::__construct($data); $this->_construct(); } @@ -1096,7 +1096,6 @@ protected function _loadCache() $this->_beforeToHtml(); return $this->_toHtml(); }; - $collectAction->bindTo($this); if ($this->getCacheLifetime() === null || !$this->_cacheState->isEnabled(self::CACHE_GROUP)) { $html = $collectAction(); @@ -1119,7 +1118,6 @@ protected function _loadCache() } return $cacheData; }; - $loadAction->bindTo($this); $saveAction = function ($data) { $this->_saveCache($data); @@ -1127,17 +1125,12 @@ protected function _loadCache() $this->inlineTranslation->resume(); } }; - $saveAction->bindTo($this); - - $cleanAction = function () { - }; return $this->lockQuery->lockedLoadData( $this->getCacheKey(), $loadAction, $collectAction, - $saveAction, - $cleanAction + $saveAction ); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php index 833b1ced20c06..dbc16b808c47e 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php @@ -6,7 +6,7 @@ namespace Magento\Framework\View\Test\Unit\Element; -use Magento\Framework\Cache\LockQueryInterface; +use Magento\Framework\Cache\LockGuardedCacheLoader; use Magento\Framework\View\Element\AbstractBlock; use Magento\Framework\View\Element\Context; use Magento\Framework\Config\View; @@ -53,7 +53,7 @@ class AbstractBlockTest extends \PHPUnit\Framework\TestCase private $sessionMock; /** - * @var LockQueryInterface|\PHPUnit_Framework_MockObject_MockObject + * @var LockGuardedCacheLoader|\PHPUnit_Framework_MockObject_MockObject */ private $lockQuery; @@ -65,7 +65,7 @@ protected function setUp() $this->eventManagerMock = $this->getMockForAbstractClass(EventManagerInterface::class); $this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class); $this->cacheStateMock = $this->getMockForAbstractClass(CacheStateInterface::class); - $this->lockQuery = $this->getMockForAbstractClass(LockQueryInterface::class); + $this->lockQuery = $this->getMockForAbstractClass(LockGuardedCacheLoader::class); $this->sidResolverMock = $this->getMockForAbstractClass(SidResolverInterface::class); $this->sessionMock = $this->getMockForAbstractClass(SessionManagerInterface::class); $contextMock = $this->createMock(Context::class); From 49bbec42b9e03e0d95314bc215f2581ecdd99061 Mon Sep 17 00:00:00 2001 From: Mike Hatch <4390485+mikeshatch@users.noreply.github.com> Date: Fri, 15 Mar 2019 16:30:41 -0500 Subject: [PATCH 118/162] Edited headings to be more consistent --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e73da84d66f46..9e3cf448f99fb 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,14 @@ <h2>Welcome</h2> Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting-edge, feature-rich eCommerce solution that gets results. -## Magento system requirements -[Magento system requirements](https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements2.html). +## Magento System Requirements +[Magento System Requirements](https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements2.html). ## Install Magento -* [Installation guide](https://devdocs.magento.com/guides/v2.3/install-gde/bk-install-guide.html). +* [Installation Guide](https://devdocs.magento.com/guides/v2.3/install-gde/bk-install-guide.html). -<h2>Contributing to the Magento 2 code base</h2> +<h2>Contributing to the Magento 2 Code Base</h2> Contributions can take the form of new components or features, changes to existing features, tests, documentation (such as developer guides, user guides, examples, or specifications), bug fixes, optimizations, or just good suggestions. To learn about how to make a contribution, click [here][1]. @@ -39,11 +39,11 @@ Magento is thankful for any contribution that can improve our code base, documen <img src="https://raw.githubusercontent.com/wiki/magento/magento2/images/contributors.png"/> </a> -### Labels applied by the Magento team +### Labels Applied by the Magento Team We apply labels to public Pull Requests and Issues to help other participants retrieve additional information about current progress, component assignments, Magento release lines, and much more. Please review the [Code Contributions guide](https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#labels) for detailed information on labels used in Magento 2 repositories. -## Reporting security issues +## Reporting Security Issues To report security vulnerabilities in Magento software or web sites, please create a Bugcrowd researcher account [there](https://bugcrowd.com/magento) to submit and follow-up your issue. Learn more about reporting security issues [here](https://magento.com/security/reporting-magento-security-issue). From b3a9e2122cf59eeb2cdd72145dad8596ac33ee4f Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk <kolesnyk@adobe.com> Date: Fri, 15 Mar 2019 16:45:35 -0500 Subject: [PATCH 119/162] MQE-1476: Deliver weekly PR --- .../StorefrontCatalogSearchActionGroup.xml | 5 ++--- .../AdminMassDeleteSearchTermEntityTest.xml | 18 +++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml index d99d1b69887ed..4b52b2c669edf 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml @@ -11,10 +11,9 @@ <!-- Quick search the phrase and check if the result page contains correct information --> <actionGroup name="StorefrontCheckQuickSearchActionGroup"> <arguments> - <argument name="phrase" type="string"/> + <argument name="phrase" /> </arguments> - <fillField stepKey="fillInput" selector="{{StorefrontQuickSearchResultsSection.searchTextBox}}" userInput="{{phrase}}"/> - <submitForm selector="{{StorefrontQuickSearchResultsSection.searchTextBox}}" parameterArray="[]" stepKey="submitQuickSearch" /> + <submitForm selector="{{StorefrontQuickSearchSection.searchMiniForm}}" parameterArray="['q' => {{phrase}}]" stepKey="fillQuickSearch" /> <seeInCurrentUrl url="{{StorefrontCatalogSearchPage.url}}" stepKey="checkUrl"/> <dontSeeInCurrentUrl url="form_key=" stepKey="checkUrlFormKey"/> <seeInTitle userInput="Search results for: '{{phrase}}'" stepKey="assertQuickSearchTitle"/> diff --git a/app/code/Magento/Search/Test/Mftf/Test/AdminMassDeleteSearchTermEntityTest.xml b/app/code/Magento/Search/Test/Mftf/Test/AdminMassDeleteSearchTermEntityTest.xml index eb0797d07bf18..67ccb51bf401e 100644 --- a/app/code/Magento/Search/Test/Mftf/Test/AdminMassDeleteSearchTermEntityTest.xml +++ b/app/code/Magento/Search/Test/Mftf/Test/AdminMassDeleteSearchTermEntityTest.xml @@ -39,13 +39,13 @@ <!-- Select all created below search terms --> <actionGroup ref="searchTermFilterBySearchQuery" stepKey="filterByFirstSearchQuery"> - <argument name="searchQuery" value="$createFirstSearchTerm.query_text$"/> + <argument name="searchQuery" value="$$createFirstSearchTerm.query_text$$"/> </actionGroup> <actionGroup ref="searchTermFilterBySearchQuery" stepKey="filterBySecondSearchQuery"> - <argument name="searchQuery" value="$createSecondSearchTerm.query_text$"/> + <argument name="searchQuery" value="$$createSecondSearchTerm.query_text$$"/> </actionGroup> <actionGroup ref="searchTermFilterBySearchQuery" stepKey="filterByThirdSearchQuery"> - <argument name="searchQuery" value="$createThirdSearchTerm.query_text$"/> + <argument name="searchQuery" value="$$createThirdSearchTerm.query_text$$"/> </actionGroup> <!-- Delete created below search terms --> @@ -53,13 +53,13 @@ <!-- Assert search terms are absent on the search term page --> <actionGroup ref="AssertSearchTermNotInGrid" stepKey="assertFirstSearchTermNotInGrid"> - <argument name="searchQuery" value="$createFirstSearchTerm.query_text$"/> + <argument name="searchQuery" value="$$createFirstSearchTerm.query_text$$"/> </actionGroup> <actionGroup ref="AssertSearchTermNotInGrid" stepKey="assertSecondSearchTermNotInGrid"> - <argument name="searchQuery" value="$createSecondSearchTerm.query_text$"/> + <argument name="searchQuery" value="$$createSecondSearchTerm.query_text$$"/> </actionGroup> <actionGroup ref="AssertSearchTermNotInGrid" stepKey="assertThirdSearchTermNotInGrid"> - <argument name="searchQuery" value="$createThirdSearchTerm.query_text$"/> + <argument name="searchQuery" value="$$createThirdSearchTerm.query_text$$"/> </actionGroup> <!-- Go to storefront page --> @@ -68,15 +68,15 @@ <!-- Verify search term deletion on storefront --> <actionGroup ref="StorefrontCheckQuickSearchActionGroup" stepKey="quickSearchForFirstSearchTerm"> - <argument name="phrase" value="$createFirstSearchTerm.query_text$"/> + <argument name="phrase" value="$$createFirstSearchTerm.query_text$$"/> </actionGroup> <actionGroup ref="StorefrontCheckSearchIsEmpty" stepKey="checkEmptyForFirstSearchTerm"/> <actionGroup ref="StorefrontCheckQuickSearchActionGroup" stepKey="quickSearchForSecondSearchTerm"> - <argument name="phrase" value="$createSecondSearchTerm.query_text$"/> + <argument name="phrase" value="$$createSecondSearchTerm.query_text$$"/> </actionGroup> <actionGroup ref="StorefrontCheckSearchIsEmpty" stepKey="checkEmptyForSecondSearchTerm"/> <actionGroup ref="StorefrontCheckQuickSearchActionGroup" stepKey="quickSearchForThirdSearchTerm"> - <argument name="phrase" value="$createThirdSearchTerm.query_text$"/> + <argument name="phrase" value="$$createThirdSearchTerm.query_text$$"/> </actionGroup> <actionGroup ref="StorefrontCheckSearchIsEmpty" stepKey="checkEmptyForThirdSearchTerm"/> </test> From b80c9dcbcbb04f61d522f961f5f7b16a60a7d1d5 Mon Sep 17 00:00:00 2001 From: Vitaliy Honcharenko <vgoncharenko@magento.com> Date: Fri, 15 Mar 2019 17:07:16 -0500 Subject: [PATCH 120/162] MC-6273: Mysql url_rewrite select make on product view page 170+ times per request - changes after CR --- app/code/Magento/Config/App/Config/Type/System.php | 12 ++++++------ .../Framework/Cache/LockGuardedCacheLoader.php | 8 +++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Config/App/Config/Type/System.php b/app/code/Magento/Config/App/Config/Type/System.php index 36fefcb86217d..8d197bc6ab045 100644 --- a/app/code/Magento/Config/App/Config/Type/System.php +++ b/app/code/Magento/Config/App/Config/Type/System.php @@ -231,8 +231,8 @@ private function loadAllData() return $this->lockQuery->lockedLoadData( self::$lockName, $loadAction, - [$this, 'readData'], - [$this, 'cacheData'] + \Closure::fromCallable([$this, 'readData']), + \Closure::fromCallable([$this, 'cacheData']) ); } @@ -256,8 +256,8 @@ private function loadDefaultScopeData($scopeType) return $this->lockQuery->lockedLoadData( self::$lockName, $loadAction, - [$this, 'readData'], - [$this, 'cacheData'] + \Closure::fromCallable([$this, 'readData']), + \Closure::fromCallable([$this, 'cacheData']) ); } @@ -295,8 +295,8 @@ private function loadScopeData($scopeType, $scopeId) return $this->lockQuery->lockedLoadData( self::$lockName, $loadAction, - [$this, 'readData'], - [$this, 'cacheData'] + \Closure::fromCallable([$this, 'readData']), + \Closure::fromCallable([$this, 'cacheData']) ); } diff --git a/lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php b/lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php index 39c132503daf8..8575f208e6c1f 100644 --- a/lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php +++ b/lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php @@ -52,7 +52,13 @@ public function __construct( } /** - * @inheritdoc + * Load data. + * + * @param string $lockName + * @param callable $dataLoader + * @param callable $dataCollector + * @param callable $dataSaver + * @return array */ public function lockedLoadData( string $lockName, From 345b70e3a59743020bb833927bff168899b51f79 Mon Sep 17 00:00:00 2001 From: eduard13 <e.chitoraga@atwix.com> Date: Sat, 16 Mar 2019 10:33:50 +0200 Subject: [PATCH 121/162] Covering the Share Wishist by integration test --- .../Magento/Wishlist/Controller/ShareTest.php | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Wishlist/Controller/ShareTest.php diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/ShareTest.php b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/ShareTest.php new file mode 100644 index 0000000000000..83d79a43620ff --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/ShareTest.php @@ -0,0 +1,92 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Wishlist\Controller; + +use Magento\Customer\Model\Session; +use Magento\Framework\App\Area; +use Magento\Framework\Data\Form\FormKey; +use Magento\Framework\Message\MessageInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Request; +use Magento\TestFramework\TestCase\AbstractController; + +/** + * @magentoAppIsolation enabled + */ +class ShareTest extends AbstractController +{ + /** + * Test share wishlist with correct data + * + * @magentoDataFixture Magento/Wishlist/_files/wishlist.php + */ + public function testSuccessfullyShareWishlist() + { + $this->login(1); + $this->prepareRequestData(); + $this->dispatch('wishlist/index/send/'); + + $this->assertSessionMessages( + $this->equalTo(['Your wish list has been shared.']), + MessageInterface::TYPE_SUCCESS + ); + } + + /** + * Test share wishlist with incorrect data + * + * @magentoDataFixture Magento/Wishlist/_files/wishlist.php + */ + public function testShareWishlistWithoutEmails() + { + $this->login(1); + $this->prepareRequestData(true); + $this->dispatch('wishlist/index/send/'); + + $this->assertSessionMessages( + $this->equalTo(['Please enter an email address.']), + MessageInterface::TYPE_ERROR + ); + } + + /** + * Login the user + * + * @param string $customerId Customer to mark as logged in for the session + * @return void + */ + protected function login($customerId) + { + /** @var Session $session */ + $session = $this->_objectManager->get(Session::class); + $session->loginById($customerId); + } + + /** + * Prepares the request with data + * + * @param bool $invalidData + * @return void + */ + private function prepareRequestData($invalidData = false) + { + Bootstrap::getInstance()->loadArea(Area::AREA_FRONTEND); + $emails = !$invalidData ? 'email-1@example.com,email-1@example.com' : ''; + + /** @var FormKey $formKey */ + $formKey = $this->_objectManager->get(FormKey::class); + $post = [ + 'emails' => $emails, + 'message' => '', + 'form_key' => $formKey->getFormKey(), + ]; + + $this->getRequest()->setMethod(Request::METHOD_POST); + $this->getRequest()->setPostValue($post); + } +} From 01eb7e61c9a3ebadd7d3350b473fd5d0db8d1578 Mon Sep 17 00:00:00 2001 From: eduard13 <e.chitoraga@atwix.com> Date: Sat, 16 Mar 2019 10:41:16 +0200 Subject: [PATCH 122/162] Fix clearing admin quote address when removing all items --- app/code/Magento/Checkout/etc/di.xml | 3 --- app/code/Magento/Checkout/etc/frontend/di.xml | 3 +++ .../Checkout/Plugin/Model/Quote/ResetQuoteAddressesTest.php | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Checkout/etc/di.xml b/app/code/Magento/Checkout/etc/di.xml index 71dfd12bb4779..4ebd594a28562 100644 --- a/app/code/Magento/Checkout/etc/di.xml +++ b/app/code/Magento/Checkout/etc/di.xml @@ -49,7 +49,4 @@ </argument> </arguments> </type> - <type name="Magento\Quote\Model\Quote"> - <plugin name="clear_addresses_after_product_delete" type="Magento\Checkout\Plugin\Model\Quote\ResetQuoteAddresses"/> - </type> </config> diff --git a/app/code/Magento/Checkout/etc/frontend/di.xml b/app/code/Magento/Checkout/etc/frontend/di.xml index 00bcd2a27005a..8f35fe9f37abf 100644 --- a/app/code/Magento/Checkout/etc/frontend/di.xml +++ b/app/code/Magento/Checkout/etc/frontend/di.xml @@ -96,4 +96,7 @@ </argument> </arguments> </type> + <type name="Magento\Quote\Model\Quote"> + <plugin name="clear_addresses_after_product_delete" type="Magento\Checkout\Plugin\Model\Quote\ResetQuoteAddresses"/> + </type> </config> diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Plugin/Model/Quote/ResetQuoteAddressesTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Plugin/Model/Quote/ResetQuoteAddressesTest.php index 994076badddae..60ccdb88676aa 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Plugin/Model/Quote/ResetQuoteAddressesTest.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/Plugin/Model/Quote/ResetQuoteAddressesTest.php @@ -22,6 +22,7 @@ class ResetQuoteAddressesTest extends \PHPUnit\Framework\TestCase /** * @magentoDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php * + * @magentoAppArea frontend * @return void */ public function testAfterRemoveItem(): void From 68d793d81a45035b1d5df2dc883582ef6a37229f Mon Sep 17 00:00:00 2001 From: Oleg Volkov <sirwerwolf@gmail.com> Date: Sat, 16 Mar 2019 13:56:41 +0200 Subject: [PATCH 123/162] #19835 Fix admin header buttons flicker --- .../Backend/view/adminhtml/templates/pageactions.phtml | 2 +- .../web/css/source/module/main/_actions-bar.less | 4 ++++ lib/web/mage/backend/floating-header.js | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Backend/view/adminhtml/templates/pageactions.phtml b/app/code/Magento/Backend/view/adminhtml/templates/pageactions.phtml index 69d545f12d075..0a1dcb0b626e6 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/pageactions.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/pageactions.phtml @@ -8,7 +8,7 @@ ?> <?php if ($block->getChildHtml()):?> - <div data-mage-init='{"floatingHeader": {}}' class="page-actions" <?= /* @escapeNotVerified */ $block->getUiId('content-header') ?>> + <div data-mage-init='{"floatingHeader": {}}' class="page-actions floating-header" <?= /* @escapeNotVerified */ $block->getUiId('content-header') ?>> <?= $block->getChildHtml() ?> </div> <?php endif; ?> diff --git a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_actions-bar.less b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_actions-bar.less index 07050c1e5111d..131013bacd808 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_actions-bar.less +++ b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_actions-bar.less @@ -46,6 +46,10 @@ @_page-action__indent: 1.3rem; float: right; + &.floating-header { + &:extend(.page-actions-buttons all); + } + .page-main-actions & { &._fixed { left: @page-wrapper__indent-left; diff --git a/lib/web/mage/backend/floating-header.js b/lib/web/mage/backend/floating-header.js index 06861277559a4..a6f767259488a 100644 --- a/lib/web/mage/backend/floating-header.js +++ b/lib/web/mage/backend/floating-header.js @@ -48,6 +48,7 @@ define([ this.element.wrapInner($('<div/>', { 'class': 'page-actions-inner', 'data-title': title })); + this.element.removeClass('floating-header'); }, /** From e91cff303581f43b93b7ca4ec210712fb505f063 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza <enarc@atwix.com> Date: Sat, 16 Mar 2019 10:33:15 +0200 Subject: [PATCH 124/162] Convert UpdateShoppingCartTest to MFTF --- .../Catalog/Test/Mftf/Data/ProductData.xml | 5 + .../Section/CheckoutCartProductSection.xml | 3 + .../Test/StorefrontUpdateShoppingCartTest.xml | 114 ++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartTest.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml index 0b3a31194ea36..44635e9b93f9a 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml @@ -386,6 +386,11 @@ <var key="sku" entityType="product" entityKey="sku" /> <requiredEntity type="product_option">ProductOptionDropDownWithLongValuesTitle</requiredEntity> </entity> + <entity name="productWithOptions3" type="product"> + <var key="sku" entityType="product" entityKey="sku" /> + <requiredEntity type="product_option">ProductOptionField</requiredEntity> + <requiredEntity type="product_option">ProductOptionArea</requiredEntity> + </entity> <entity name="ApiVirtualProductWithDescription" type="product"> <data key="sku" unique="suffix">api-virtual-product</data> <data key="type_id">virtual</data> diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml index dcfb12fd4e965..a63dc5be2de30 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml @@ -15,6 +15,9 @@ <element name="ProductPriceByName" type="text" selector="//main//table[@id='shopping-cart-table']//tbody//tr[..//strong[contains(@class, 'product-item-name')]//a/text()='{{var1}}'][1]//td[contains(@class, 'price')]//span[@class='price']" parameterized="true"/> + <element name="ProductSubtotalByName" type="text" + selector="//main//table[@id='shopping-cart-table']//tbody//tr[..//strong[contains(@class, 'product-item-name')]//a/text()='{{var1}}'][1]//td[contains(@class, 'subtotal')]//span[@class='price']" + parameterized="true"/> <element name="ProductImageByName" type="text" selector="//main//table[@id='shopping-cart-table']//tbody//tr//img[contains(@class, 'product-image-photo') and @alt='{{var1}}']" parameterized="true"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartTest.xml new file mode 100644 index 0000000000000..94abf4b26c347 --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartTest.xml @@ -0,0 +1,114 @@ +<?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="UpdateShoppingCartTestVariation1"> + <annotations> + <features value="Checkout"/> + <title value="Check updating shopping cart while updating items qty"/> + <description value="Check updating shopping cart while updating items qty"/> + <group value="shoppingCart"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="SimpleProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> + <field key="price">100</field> + </createData> + + <!-- Add the newly created product to the shopping cart --> + <amOnPage url="$$createProduct.custom_attributes[url_key]$$.html" stepKey="navigateToSimpleProductPage"/> + <waitForPageLoad stepKey="waitForCatalogPageLoad1"/> + <actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartFromStorefrontProductPage1"> + <argument name="productName" value="$$createProduct.name$$"/> + </actionGroup> + </before> + <after> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + </after> + + <!-- Go to the shopping cart --> + <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/> + <waitForPageLoad stepKey="waitForCheckoutPageLoad1"/> + + <!-- Change the product QTY --> + <fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="3" stepKey="changeCartQty"/> + <click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="openShoppingCart"/> + <waitForPageLoad stepKey="waitForCheckoutPageLoad2"/> + + <!-- The price and QTY values should be updated for the product --> + <grabValueFrom selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" stepKey="grabProductQtyInCart"/> + <see userInput="$300" selector="{{CheckoutCartProductSection.ProductSubtotalByName($$createProduct.name$$)}}" stepKey="assertProductPrice"/> + <assertEquals expected="3" actual="$grabProductQtyInCart" stepKey="assertProductQtyInCart"/> + + <!-- Subtotal should be updated --> + <see userInput="$300" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertCartSubtotal"/> + + <!-- Minicart product price and subtotal should be updated --> + <actionGroup ref="clickViewAndEditCartFromMiniCart" stepKey="openMinicart"/> + <grabValueFrom selector="{{StorefrontMinicartSection.itemQuantity($$createProduct.name$$)}}" stepKey="grabProductQtyInMinicart"/> + <assertEquals expected="3" actual="$grabProductQtyInMinicart" stepKey="assertProductQtyInMinicart"/> + <see userInput="$300" selector="{{StorefrontMinicartSection.subtotal}}" stepKey="assertMinicartSubtotal"/> + </test> + <test name="UpdateShoppingCartTestVariation2"> + <annotations> + <features value="Checkout"/> + <title value="Check updating shopping cart while updating qty of items with custom options"/> + <description value="Check updating shopping cart while updating qty of items with custom options"/> + <group value="shoppingCart"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="SimpleProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> + <field key="price">100</field> + </createData> + + <!-- Add two custom options to the product: field and textarea --> + <updateData createDataKey="createProduct" entity="productWithOptions3" stepKey="updateProductWithOption"/> + + <!-- Go to the product page, fill the custom options values and add the product to the shopping cart --> + <amOnPage url="{{StorefrontHomePage.url}}$createProduct.custom_attributes[url_key]$.html" stepKey="amOnProductPage"/> + <waitForPageLoad stepKey="waitForCatalogPageLoad"/> + <fillField userInput="OptionField" selector="{{StorefrontProductInfoMainSection.productOptionFieldInput(ProductOptionField.title)}}" stepKey="fillProductOptionInputField"/> + <fillField userInput="OptionArea" selector="{{StorefrontProductInfoMainSection.productOptionAreaInput(ProductOptionArea.title)}}" stepKey="fillProductOptionInputArea"/> + <actionGroup ref="StorefrontAddToCartCustomOptionsProductPageActionGroup" stepKey="addToCartFromStorefrontProductPage"> + <argument name="productName" value="$createProduct.name$"/> + </actionGroup> + </before> + <after> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + </after> + + <!-- Go to the shopping cart --> + <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/> + <waitForPageLoad stepKey="waitForCheckoutPageLoad1"/> + + <!-- Change the product QTY --> + <fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="11" stepKey="changeCartQty"/> + <click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="openShoppingCart"/> + <waitForPageLoad stepKey="waitForCheckoutPageLoad2"/> + + <!-- The price and QTY values should be updated for the product --> + <grabValueFrom selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" stepKey="grabProductQtyInCart"/> + <see userInput="$1,320.00" selector="{{CheckoutCartProductSection.ProductSubtotalByName($$createProduct.name$$)}}" stepKey="assertProductPrice"/> + <assertEquals expected="11" actual="$grabProductQtyInCart" stepKey="assertProductQtyInCart"/> + <see userInput="$1,320.00" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertSubtotal"/> + + <!-- Minicart product price and subtotal should be updated --> + <actionGroup ref="clickViewAndEditCartFromMiniCart" stepKey="openMinicart"/> + <grabValueFrom selector="{{StorefrontMinicartSection.itemQuantity($$createProduct.name$$)}}" stepKey="grabProductQtyInMinicart"/> + <assertEquals expected="11" actual="$grabProductQtyInMinicart" stepKey="assertProductQtyInMinicart"/> + <see userInput="1,320.00" selector="{{StorefrontMinicartSection.subtotal}}" stepKey="assertMinicartSubtotal"/> + </test> +</tests> From 5c101bfefda20e54168a1e5a7ed044b40ec3889c Mon Sep 17 00:00:00 2001 From: eduard13 <e.chitoraga@atwix.com> Date: Sat, 16 Mar 2019 16:07:32 +0200 Subject: [PATCH 125/162] Covering the Wishlist classes by integration and Unit Tests --- .../Product/AttributeValueProviderTest.php | 178 ++++++++++++++++++ .../Magento/Wishlist/Controller/ShareTest.php | 2 +- 2 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Wishlist/Test/Unit/Model/Product/AttributeValueProviderTest.php diff --git a/app/code/Magento/Wishlist/Test/Unit/Model/Product/AttributeValueProviderTest.php b/app/code/Magento/Wishlist/Test/Unit/Model/Product/AttributeValueProviderTest.php new file mode 100644 index 0000000000000..baafbdef47fe8 --- /dev/null +++ b/app/code/Magento/Wishlist/Test/Unit/Model/Product/AttributeValueProviderTest.php @@ -0,0 +1,178 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Wishlist\Test\Unit\Model\Product; + +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\ResourceModel\Product\Collection; +use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Wishlist\Model\Product\AttributeValueProvider; +use PHPUnit\Framework\TestCase; +use PHPUnit_Framework_MockObject_MockObject; + +/** + * @covers CreditCardTokenFormatter + */ +class AttributeValueProviderTest extends TestCase +{ + /** + * @var AttributeValueProvider|PHPUnit_Framework_MockObject_MockObject + */ + private $attributeValueProvider; + + /** + * @var CollectionFactory|PHPUnit_Framework_MockObject_MockObject + */ + private $productCollectionFactoryMock; + + /** + * @var @var Product|PHPUnit_Framework_MockObject_MockObject + */ + private $productMock; + + /** + * @var AdapterInterface|PHPUnit_Framework_MockObject_MockObject + */ + private $connectionMock; + + /** + * Set Up + * + * @return void + */ + protected function setUp() + { + $this->productCollectionFactoryMock = $this->createPartialMock( + CollectionFactory::class, + ['create'] + ); + $this->attributeValueProvider = new AttributeValueProvider( + $this->productCollectionFactoryMock + ); + } + + /** + * Get attribute text when the flat table is disabled + * + * @param int $productId + * @param string $attributeCode + * @param string $attributeText + * @return void + * @dataProvider attributeDataProvider + */ + public function testGetAttributeTextWhenFlatIsDisabled(int $productId, string $attributeCode, string $attributeText) + { + $this->productMock = $this->getMockBuilder(Product::class) + ->disableOriginalConstructor() + ->setMethods(['getData']) + ->getMock(); + + $this->productMock->expects($this->any()) + ->method('getData') + ->with($attributeCode) + ->willReturn($attributeText); + + $productCollection = $this->getMockBuilder(Collection::class) + ->disableOriginalConstructor() + ->setMethods([ + 'addIdFilter', 'addStoreFilter', 'addAttributeToSelect', 'isEnabledFlat', 'getFirstItem' + ])->getMock(); + + $productCollection->expects($this->any()) + ->method('addIdFilter') + ->willReturnSelf(); + $productCollection->expects($this->any()) + ->method('addStoreFilter') + ->willReturnSelf(); + $productCollection->expects($this->any()) + ->method('addAttributeToSelect') + ->willReturnSelf(); + $productCollection->expects($this->any()) + ->method('isEnabledFlat') + ->willReturn(false); + $productCollection->expects($this->any()) + ->method('getFirstItem') + ->willReturn($this->productMock); + + $this->productCollectionFactoryMock->expects($this->atLeastOnce()) + ->method('create') + ->willReturn($productCollection); + + $actual = $this->attributeValueProvider->getRawAttributeValue($productId, $attributeCode); + + $this->assertEquals($attributeText, $actual); + } + + + /** + * Get attribute text when the flat table is enabled + * + * @dataProvider attributeDataProvider + * @param int $productId + * @param string $attributeCode + * @param string $attributeText + * @return void + */ + public function testGetAttributeTextWhenFlatIsEnabled(int $productId, string $attributeCode, string $attributeText) + { + $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)->getMockForAbstractClass(); + $this->connectionMock->expects($this->any()) + ->method('fetchRow') + ->willReturn([ + $attributeCode => $attributeText + ]); + $this->productMock = $this->getMockBuilder(Product::class) + ->disableOriginalConstructor() + ->setMethods(['getData']) + ->getMock(); + $this->productMock->expects($this->any()) + ->method('getData') + ->with($attributeCode) + ->willReturn($attributeText); + + $productCollection = $this->getMockBuilder(Collection::class) + ->disableOriginalConstructor() + ->setMethods([ + 'addIdFilter', 'addStoreFilter', 'addAttributeToSelect', 'isEnabledFlat', 'getConnection' + ])->getMock(); + + $productCollection->expects($this->any()) + ->method('addIdFilter') + ->willReturnSelf(); + $productCollection->expects($this->any()) + ->method('addStoreFilter') + ->willReturnSelf(); + $productCollection->expects($this->any()) + ->method('addAttributeToSelect') + ->willReturnSelf(); + $productCollection->expects($this->any()) + ->method('isEnabledFlat') + ->willReturn(true); + $productCollection->expects($this->any()) + ->method('getConnection') + ->willReturn($this->connectionMock); + + $this->productCollectionFactoryMock->expects($this->atLeastOnce()) + ->method('create') + ->willReturn($productCollection); + + $actual = $this->attributeValueProvider->getRawAttributeValue($productId, $attributeCode); + + $this->assertEquals($attributeText, $actual); + } + + /** + * @return array + */ + public function attributeDataProvider(): array + { + return [ + [1, 'attribute_code', 'Attribute Text'] + ]; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/ShareTest.php b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/ShareTest.php index 83d79a43620ff..47705262caaf3 100644 --- a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/ShareTest.php +++ b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/ShareTest.php @@ -76,7 +76,7 @@ protected function login($customerId) private function prepareRequestData($invalidData = false) { Bootstrap::getInstance()->loadArea(Area::AREA_FRONTEND); - $emails = !$invalidData ? 'email-1@example.com,email-1@example.com' : ''; + $emails = !$invalidData ? 'email-1@example.com,email-2@example.com' : ''; /** @var FormKey $formKey */ $formKey = $this->_objectManager->get(FormKey::class); From d49aa76497ee603ceb7ede6e7b6bc21137ef2ddd Mon Sep 17 00:00:00 2001 From: eduard13 <e.chitoraga@atwix.com> Date: Sat, 16 Mar 2019 16:12:16 +0200 Subject: [PATCH 126/162] Small adjustment --- .../Test/Unit/Model/Product/AttributeValueProviderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Wishlist/Test/Unit/Model/Product/AttributeValueProviderTest.php b/app/code/Magento/Wishlist/Test/Unit/Model/Product/AttributeValueProviderTest.php index baafbdef47fe8..e5f6b84bfc3da 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Model/Product/AttributeValueProviderTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Model/Product/AttributeValueProviderTest.php @@ -16,7 +16,7 @@ use PHPUnit_Framework_MockObject_MockObject; /** - * @covers CreditCardTokenFormatter + * AttributeValueProviderTest */ class AttributeValueProviderTest extends TestCase { From 7a2774318fe8056d0ef44e1338bf3984fc46857d Mon Sep 17 00:00:00 2001 From: eduard13 <e.chitoraga@atwix.com> Date: Sat, 16 Mar 2019 16:17:55 +0200 Subject: [PATCH 127/162] Small adjustments --- .../Test/Unit/Model/Product/AttributeValueProviderTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/Magento/Wishlist/Test/Unit/Model/Product/AttributeValueProviderTest.php b/app/code/Magento/Wishlist/Test/Unit/Model/Product/AttributeValueProviderTest.php index e5f6b84bfc3da..fb0113eb6ae75 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Model/Product/AttributeValueProviderTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Model/Product/AttributeValueProviderTest.php @@ -31,7 +31,7 @@ class AttributeValueProviderTest extends TestCase private $productCollectionFactoryMock; /** - * @var @var Product|PHPUnit_Framework_MockObject_MockObject + * @var Product|PHPUnit_Framework_MockObject_MockObject */ private $productMock; @@ -108,7 +108,6 @@ public function testGetAttributeTextWhenFlatIsDisabled(int $productId, string $a $this->assertEquals($attributeText, $actual); } - /** * Get attribute text when the flat table is enabled * From 904a4a8c80b95da48d5095dde7fdec34540952f7 Mon Sep 17 00:00:00 2001 From: Leandry <leandry@atwix.com> Date: Mon, 18 Mar 2019 01:17:48 +0200 Subject: [PATCH 128/162] Convert FlushStaticFilesCacheButtonVisibilityTest to MFTF --- .../Section/AdminCacheManagementSection.xml | 1 + ...shStaticFilesCacheButtonVisibilityTest.xml | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 app/code/Magento/PageCache/Test/Mftf/Test/FlushStaticFilesCacheButtonVisibilityTest.xml diff --git a/app/code/Magento/PageCache/Test/Mftf/Section/AdminCacheManagementSection.xml b/app/code/Magento/PageCache/Test/Mftf/Section/AdminCacheManagementSection.xml index 34a77095d524d..12d35df42bcc5 100644 --- a/app/code/Magento/PageCache/Test/Mftf/Section/AdminCacheManagementSection.xml +++ b/app/code/Magento/PageCache/Test/Mftf/Section/AdminCacheManagementSection.xml @@ -30,5 +30,6 @@ <element name="pageCacheCheckbox" type="checkbox" selector="input[value='full_page']"/> <element name="webServicesConfigCheckbox" type="checkbox" selector="input[value='config_webservice']"/> <element name="translationsCheckbox" type="checkbox" selector="input[value='translate']"/> + <element name="FlushStaticFilesCache" type="button" selector="//*[@id='container']//button[contains(., 'Flush Static Files Cache')]"/> </section> </sections> diff --git a/app/code/Magento/PageCache/Test/Mftf/Test/FlushStaticFilesCacheButtonVisibilityTest.xml b/app/code/Magento/PageCache/Test/Mftf/Test/FlushStaticFilesCacheButtonVisibilityTest.xml new file mode 100644 index 0000000000000..6cd280bb7add3 --- /dev/null +++ b/app/code/Magento/PageCache/Test/Mftf/Test/FlushStaticFilesCacheButtonVisibilityTest.xml @@ -0,0 +1,32 @@ +<?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="FlushStaticFilesCacheButtonVisibilityTest"> + <annotations> + <features value="PageCache"/> + <title value="Check visibility of flush static files cache button"/> + <description value="Flush Static Files Cache button visibility"/> + <severity value="MAJOR"/> + <stories value="Check flush static files cache button"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <!-- Log in to Admin Panel --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + + <!-- Open Cache Management page --> + <amOnPage url="{{AdminCacheManagementPage.url}}" stepKey="amOnPageCacheManagement"/> + <waitForPageLoad stepKey="waitForPageCacheManagementLoad"/> + + <!-- Check 'Flush Static Files Cache' not visible in production mode. --> + <dontSee selector="{{AdminCacheManagementSection.FlushStaticFilesCache}}" stepKey="seeFlushStaticFilesButton" /> + </test> +</tests> From dc71ef160d300f1bec2e2a0c610953738d3907a8 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky <p.bystritsky@yandex.ru> Date: Mon, 18 Mar 2019 11:01:13 +0200 Subject: [PATCH 129/162] ENGCOM-4502: Static tests fix. --- .../Model/Spi/StockRegistryProviderInterface.php | 6 ++++++ .../Model/Spi/StockStateProviderInterface.php | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/CatalogInventory/Model/Spi/StockRegistryProviderInterface.php b/app/code/Magento/CatalogInventory/Model/Spi/StockRegistryProviderInterface.php index 49d9b4aaa34e8..0fa4b919c40fa 100644 --- a/app/code/Magento/CatalogInventory/Model/Spi/StockRegistryProviderInterface.php +++ b/app/code/Magento/CatalogInventory/Model/Spi/StockRegistryProviderInterface.php @@ -15,12 +15,16 @@ interface StockRegistryProviderInterface { /** + * Get stock. + * * @param int $scopeId * @return \Magento\CatalogInventory\Api\Data\StockInterface */ public function getStock($scopeId); /** + * Get stock item. + * * @param int $productId * @param int $scopeId * @return \Magento\CatalogInventory\Api\Data\StockItemInterface @@ -28,6 +32,8 @@ public function getStock($scopeId); public function getStockItem($productId, $scopeId); /** + * Get stock status. + * * @param int $productId * @param int $scopeId * @return \Magento\CatalogInventory\Api\Data\StockStatusInterface diff --git a/app/code/Magento/CatalogInventory/Model/Spi/StockStateProviderInterface.php b/app/code/Magento/CatalogInventory/Model/Spi/StockStateProviderInterface.php index 31bdc19f9cf7a..30f703b5b928f 100644 --- a/app/code/Magento/CatalogInventory/Model/Spi/StockStateProviderInterface.php +++ b/app/code/Magento/CatalogInventory/Model/Spi/StockStateProviderInterface.php @@ -9,7 +9,7 @@ /** * Interface StockStateProviderInterface - * + * * @deprecated 2.3.0 Replaced with Multi Source Inventory * @link https://devdocs.magento.com/guides/v2.3/inventory/index.html * @link https://devdocs.magento.com/guides/v2.3/inventory/catalog-inventory-replacements.html @@ -17,18 +17,24 @@ interface StockStateProviderInterface { /** + * Verify stock. + * * @param StockItemInterface $stockItem * @return bool */ public function verifyStock(StockItemInterface $stockItem); /** + * Verify notification. + * * @param StockItemInterface $stockItem * @return bool */ public function verifyNotification(StockItemInterface $stockItem); /** + * Validate quote qty. + * * @param StockItemInterface $stockItem * @param int|float $itemQty * @param int|float $qtyToCheck @@ -48,8 +54,9 @@ public function checkQuoteItemQty(StockItemInterface $stockItem, $itemQty, $qtyT public function checkQty(StockItemInterface $stockItem, $qty); /** - * Returns suggested qty that satisfies qty increments and minQty/maxQty/minSaleQty/maxSaleQty conditions - * or original qty if such value does not exist + * Returns suggested qty or original qty if such value does not exist. + * + * Suggested qty satisfies qty increments and minQty/maxQty/minSaleQty/maxSaleQty conditions. * * @param StockItemInterface $stockItem * @param int|float $qty @@ -58,6 +65,8 @@ public function checkQty(StockItemInterface $stockItem, $qty); public function suggestQty(StockItemInterface $stockItem, $qty); /** + * Check qty increments. + * * @param StockItemInterface $stockItem * @param int|float $qty * @return \Magento\Framework\DataObject From 13126a5355d55ba04631b1d3302566f2420e5fa9 Mon Sep 17 00:00:00 2001 From: Vitaliy Honcharenko <vgoncharenko@magento.com> Date: Mon, 18 Mar 2019 09:52:05 -0500 Subject: [PATCH 130/162] MC-6273: Mysql url_rewrite select make on product view page 170+ times per request - fixed unit tests --- .../Framework/View/Test/Unit/Element/AbstractBlockTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php index dbc16b808c47e..dba775ea894f4 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php @@ -65,7 +65,10 @@ protected function setUp() $this->eventManagerMock = $this->getMockForAbstractClass(EventManagerInterface::class); $this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class); $this->cacheStateMock = $this->getMockForAbstractClass(CacheStateInterface::class); - $this->lockQuery = $this->getMockForAbstractClass(LockGuardedCacheLoader::class); + $this->lockQuery = $this->getMockBuilder(LockGuardedCacheLoader::class) + ->disableOriginalConstructor() + ->setMethods(['lockedLoadData']) + ->getMockForAbstractClass(); $this->sidResolverMock = $this->getMockForAbstractClass(SidResolverInterface::class); $this->sessionMock = $this->getMockForAbstractClass(SessionManagerInterface::class); $contextMock = $this->createMock(Context::class); From f0039d69bf74530d209ab33a5d5a6e97279a1f24 Mon Sep 17 00:00:00 2001 From: Erik Hanson <erik.hanson@gmail.com> Date: Mon, 18 Mar 2019 10:52:00 -0500 Subject: [PATCH 131/162] Flying Fists of Kung Fu Cleanup * Rename all instances of fist to first in docs and tests :D --- app/code/Magento/Authorizenet/Model/Directpost/Request.php | 2 +- ...rtualProductWithCustomOptionsSuiteAndImportOptionsTest.xml | 2 +- ...pleProductWithRegularPriceInStockWithCustomOptionsTest.xml | 2 +- ...arPriceInStockWithCustomOptionsVisibleInSearchOnlyTest.xml | 2 +- .../Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml | 4 ++-- ...onfigurableProductWithTwoOptionsAssignedToCategoryTest.xml | 2 +- ...ableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Authorizenet/Model/Directpost/Request.php b/app/code/Magento/Authorizenet/Model/Directpost/Request.php index d518af4e04f55..10be4cd5febf6 100644 --- a/app/code/Magento/Authorizenet/Model/Directpost/Request.php +++ b/app/code/Magento/Authorizenet/Model/Directpost/Request.php @@ -194,7 +194,7 @@ public function setDataFromOrder( /** * Set sign hash into the request object. * - * All needed fields should be placed in the object fist. + * All needed fields should be placed in the object first. * * @return $this */ diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithCustomOptionsSuiteAndImportOptionsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithCustomOptionsSuiteAndImportOptionsTest.xml index 70edb0ce3ea7d..17769c79677f7 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithCustomOptionsSuiteAndImportOptionsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithCustomOptionsSuiteAndImportOptionsTest.xml @@ -139,7 +139,7 @@ </assertEquals> <!--Verify we see customizable options are Required --> - <seeElement selector="{{StorefrontProductInfoMainSection.requiredCustomInput(virtualProductCustomizableOption1.title)}}" stepKey="verifyFistCustomOptionIsRequired" /> + <seeElement selector="{{StorefrontProductInfoMainSection.requiredCustomInput(virtualProductCustomizableOption1.title)}}" stepKey="verifyFirstCustomOptionIsRequired" /> <seeElement selector="{{StorefrontProductInfoMainSection.requiredCustomInput(virtualProductCustomizableOption2.title)}}" stepKey="verifySecondCustomOptionIsRequired" /> <seeElement selector="{{StorefrontProductInfoMainSection.requiredCustomSelect(virtualProductCustomizableOption3.title)}}" stepKey="verifyThirdCustomOptionIsRequired" /> <seeElement selector="{{StorefrontProductInfoMainSection.requiredCustomSelect(virtualProductCustomizableOption4.title)}}" stepKey="verifyFourthCustomOptionIsRequired" /> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockWithCustomOptionsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockWithCustomOptionsTest.xml index c9a37ec40e8fa..318ab6555235e 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockWithCustomOptionsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockWithCustomOptionsTest.xml @@ -135,7 +135,7 @@ </assertEquals> <!--Verify customer see customizable options are Required --> - <seeElement selector="{{StorefrontProductInfoMainSection.requiredCustomSelect(simpleProductCustomizableOption.title)}}" stepKey="verifyFistCustomOptionIsRequired"/> + <seeElement selector="{{StorefrontProductInfoMainSection.requiredCustomSelect(simpleProductCustomizableOption.title)}}" stepKey="verifyFirstCustomOptionIsRequired"/> <!--Verify customer see customizable option titles and prices --> <grabAttributeFrom userInput="for" selector="{{StorefrontProductInfoMainSection.customOptionLabel(simpleProductCustomizableOption.title)}}" stepKey="simpleOptionId"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockWithCustomOptionsVisibleInSearchOnlyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockWithCustomOptionsVisibleInSearchOnlyTest.xml index d67d5b36109e6..34d85e7b46850 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockWithCustomOptionsVisibleInSearchOnlyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockWithCustomOptionsVisibleInSearchOnlyTest.xml @@ -229,7 +229,7 @@ <actualResult type="variable">productPriceAmount</actualResult> </assertEquals> <!--Verify we customer see customizable options are Required --> - <seeElement selector="{{StorefrontProductInfoMainSection.requiredCustomInput(virtualProductCustomizableOption1.title)}}" stepKey="verifyFistCustomOptionIsRequired" /> + <seeElement selector="{{StorefrontProductInfoMainSection.requiredCustomInput(virtualProductCustomizableOption1.title)}}" stepKey="verifyFirstCustomOptionIsRequired" /> <seeElement selector="{{StorefrontProductInfoMainSection.requiredCustomInput(virtualProductCustomizableOption2.title)}}" stepKey="verifySecondCustomOptionIsRequired" /> <seeElement selector="{{StorefrontProductInfoMainSection.requiredCustomSelect(virtualProductCustomizableOption3.title)}}" stepKey="verifyThirdCustomOptionIsRequired" /> <seeElement selector="{{StorefrontProductInfoMainSection.requiredCustomSelect(virtualProductCustomizableOption4.title)}}" stepKey="verifyFourthCustomOptionIsRequired" /> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml index 95b86ec3a8587..43dae2d70d416 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml @@ -145,8 +145,8 @@ <click selector="{{AdminCreateProductConfigurationsPanel.attributeCheckbox(secondAttributeCode)}}" stepKey="clickOnSecondAttributeCheckbox" after="clickOnFirstAttributeCheckbox"/> <grabTextFrom selector="{{AdminCreateProductConfigurationsPanel.defaultLabel(attributeCode)}}" stepKey="grabFirstAttributeDefaultLabel" after="clickOnSecondAttributeCheckbox"/> <grabTextFrom selector="{{AdminCreateProductConfigurationsPanel.defaultLabel(secondAttributeCode)}}" stepKey="grabSecondAttributeDefaultLabel" after="grabFirstAttributeDefaultLabel"/> - <click selector="{{AdminCreateProductConfigurationsPanel.selectAllByAttribute({$grabFirstAttributeDefaultLabel})}}" stepKey="clickOnSelectAllForFistAttribute" after="clickOnNextButton1"/> - <click selector="{{AdminCreateProductConfigurationsPanel.selectAllByAttribute({$grabSecondAttributeDefaultLabel})}}" stepKey="clickOnSelectAllForSecondAttribute" after="clickOnSelectAllForFistAttribute"/> + <click selector="{{AdminCreateProductConfigurationsPanel.selectAllByAttribute({$grabFirstAttributeDefaultLabel})}}" stepKey="clickOnSelectAllForFirstAttribute" after="clickOnNextButton1"/> + <click selector="{{AdminCreateProductConfigurationsPanel.selectAllByAttribute({$grabSecondAttributeDefaultLabel})}}" stepKey="clickOnSelectAllForSecondAttribute" after="clickOnSelectAllForFirstAttribute"/> <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickOnSaveButton2"/> <click selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" stepKey="clickOnConfirmInPopup"/> </actionGroup> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml index 981985b3f4ea8..1db9b3e5b79b2 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml @@ -144,7 +144,7 @@ <waitForPageLoad stepKey="waitForStoreFrontPageLoad"/> <!-- Quick search the storefront for the first attribute option --> - <submitForm selector="{{StorefrontQuickSearchSection.searchMiniForm}}" parameterArray="['q' => {{colorConfigurableProductAttribute1.sku}}]" stepKey="searchStorefrontFistChildProduct"/> + <submitForm selector="{{StorefrontQuickSearchSection.searchMiniForm}}" parameterArray="['q' => {{colorConfigurableProductAttribute1.sku}}]" stepKey="searchStorefrontFirstChildProduct"/> <dontSee selector="{{StorefrontCategoryProductSection.ProductTitleByName(colorConfigurableProductAttribute1.name)}}" stepKey="dontSeeConfigurableProductFirstChild"/> <!-- Quick search the storefront for the second attribute option --> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml index e278018330aa6..934a410d58a8a 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml @@ -126,7 +126,7 @@ <waitForPageLoad stepKey="waitForStoreFrontPageLoad"/> <!-- Quick search the storefront for the first attribute option --> - <submitForm selector="{{StorefrontQuickSearchSection.searchMiniForm}}" parameterArray="['q' => {{colorConfigurableProductAttribute1.sku}}]" stepKey="searchStorefrontFistChildProduct"/> + <submitForm selector="{{StorefrontQuickSearchSection.searchMiniForm}}" parameterArray="['q' => {{colorConfigurableProductAttribute1.sku}}]" stepKey="searchStorefrontFirstChildProduct"/> <dontSee selector="{{StorefrontCategoryProductSection.ProductTitleByName(colorConfigurableProductAttribute1.name)}}" stepKey="dontSeeConfigurableProductFirstChild"/> <!-- Quick search the storefront for the second attribute option --> From e7a723ab66e887c2f5bb3798959809d2f2931b77 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Mon, 18 Mar 2019 13:31:47 -0500 Subject: [PATCH 132/162] MAGETWO-98151: Add support ZooKeeper locks --- .../Framework/Lock/Backend/ZookeeperTest.php | 1 + .../Framework/Lock/LockBackendFactory.php | 2 +- .../Lock/Test/Unit/Backend/ZookeeperTest.php | 17 ++++++++++------- .../Lock/Test/Unit/LockBackendFactoryTest.php | 2 +- .../Setup/Model/ConfigOptionsList/Lock.php | 4 ++-- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php b/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php index 6e312637c7b5a..ae218561377f2 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php @@ -74,6 +74,7 @@ public function testLockAndUnlock() $this->assertTrue($this->model->lock($name)); $this->assertTrue($this->model->isLocked($name)); + $this->assertFalse($this->model->lock($name, 2)); $this->assertTrue($this->model->unlock($name)); $this->assertFalse($this->model->isLocked($name)); diff --git a/lib/internal/Magento/Framework/Lock/LockBackendFactory.php b/lib/internal/Magento/Framework/Lock/LockBackendFactory.php index ec15736bef534..46cb2998ede70 100644 --- a/lib/internal/Magento/Framework/Lock/LockBackendFactory.php +++ b/lib/internal/Magento/Framework/Lock/LockBackendFactory.php @@ -90,7 +90,7 @@ public function create(): LockManagerInterface $config = $this->deploymentConfig->get('lock/config', []); if (!isset($this->lockers[$provider])) { - throw new RuntimeException(new Phrase('Unknown locks provider.')); + throw new RuntimeException(new Phrase('Unknown locks provider: %1', [$provider])); } if (self::LOCK_ZOOKEEPER === $provider && !extension_loaded(self::LOCK_ZOOKEEPER)) { diff --git a/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php b/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php index c22c49d3427c5..7c450a09df320 100644 --- a/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php +++ b/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php @@ -13,11 +13,6 @@ class ZookeeperTest extends TestCase { - /** - * @var \Zookeeper|MockObject - */ - private $zookeeperMock; - /** * @var ZookeeperProvider */ @@ -41,15 +36,23 @@ protected function setUp() if (!extension_loaded('zookeeper')) { $this->markTestSkipped('Test was skipped because php extension Zookeeper is not installed.'); } - $this->zookeeperProvider = new ZookeeperProvider($this->host, '/some/path/'); } /** * @expectedException \Magento\Framework\Exception\RuntimeException * @expectedExceptionMessage The path needs to be a non-empty string. + * @return void */ public function testConstructionWithException() { - $this->zookeeperProvider = new ZookeeperProvider('some host', ''); + $this->zookeeperProvider = new ZookeeperProvider($this->host, ''); + } + + /** + * @return void + */ + public function testConstructionWithoutException() + { + $this->zookeeperProvider = new ZookeeperProvider($this->host, $this->path); } } diff --git a/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php b/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php index 18053f20f010c..8864ab6f9ead1 100644 --- a/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php +++ b/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php @@ -46,7 +46,7 @@ protected function setUp() /** * @expectedException \Magento\Framework\Exception\RuntimeException - * @expectedExceptionMessage Unknown locks provider. + * @expectedExceptionMessage Unknown locks provider: someProvider */ public function testCreateWithException() { diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php b/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php index 912b0e42ca822..ae236c1b5d740 100644 --- a/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php +++ b/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php @@ -210,12 +210,12 @@ private function validateZookeeperConfig(array $options, DeploymentConfig $deplo $errors[] = 'php extension Zookeeper is not installed.'; } - $host = (string) $options[self::INPUT_KEY_LOCK_ZOOKEEPER_HOST] + $host = $options[self::INPUT_KEY_LOCK_ZOOKEEPER_HOST] ?? $deploymentConfig->get( self::CONFIG_PATH_LOCK_ZOOKEEPER_HOST, $this->getDefaultValue(self::INPUT_KEY_LOCK_ZOOKEEPER_HOST) ); - $path = (string) $options[self::INPUT_KEY_LOCK_ZOOKEEPER_PATH] + $path = $options[self::INPUT_KEY_LOCK_ZOOKEEPER_PATH] ?? $deploymentConfig->get( self::CONFIG_PATH_LOCK_ZOOKEEPER_PATH, $this->getDefaultValue(self::INPUT_KEY_LOCK_ZOOKEEPER_PATH) From 32764b133e89490d4d123a78456133675f9471e0 Mon Sep 17 00:00:00 2001 From: Vitaliy Honcharenko <vgoncharenko@magento.com> Date: Mon, 18 Mar 2019 14:58:15 -0500 Subject: [PATCH 133/162] MC-6273: Mysql url_rewrite select make on product view page 170+ times per request - fixed unit tests --- .../View/Test/Unit/Element/Html/LinkTest.php | 70 +++++++++---------- 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php index b911a38dbb488..96161e12e9773 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php @@ -7,6 +7,13 @@ class LinkTest extends \PHPUnit\Framework\TestCase { + private $objectManager; + + protected function setUp() + { + $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + } + /** * @var array */ @@ -24,24 +31,8 @@ class LinkTest extends \PHPUnit\Framework\TestCase */ protected $link; - /** - * @param \Magento\Framework\View\Element\Html\Link $link - * @param string $expected - * - * @dataProvider getLinkAttributesDataProvider - */ - public function testGetLinkAttributes($link, $expected) + public function testGetLinkAttributes() { - $this->assertEquals($expected, $link->getLinkAttributes()); - } - - /** - * @return array - */ - public function getLinkAttributesDataProvider() - { - $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $escaperMock = $this->getMockBuilder(\Magento\Framework\Escaper::class) ->setMethods(['escapeHtml'])->disableOriginalConstructor()->getMock(); @@ -54,13 +45,19 @@ public function getLinkAttributesDataProvider() $urlBuilderMock->expects($this->any()) ->method('getUrl') - ->will($this->returnArgument('http://site.com/link.html')); + ->willReturn('http://site.com/link.html'); $validtorMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template\File\Validator::class) ->setMethods(['isValid'])->disableOriginalConstructor()->getMock(); + $validtorMock->expects($this->any()) + ->method('isValid') + ->willReturn(false); $scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config::class) ->setMethods(['isSetFlag'])->disableOriginalConstructor()->getMock(); + $scopeConfigMock->expects($this->any()) + ->method('isSetFlag') + ->willReturn(true); $resolverMock = $this->getMockBuilder(\Magento\Framework\View\Element\Template\File\Resolver::class) ->setMethods([])->disableOriginalConstructor()->getMock(); @@ -72,48 +69,47 @@ public function getLinkAttributesDataProvider() $contextMock->expects($this->any()) ->method('getValidator') - ->will($this->returnValue($validtorMock)); + ->willReturn($validtorMock); $contextMock->expects($this->any()) ->method('getResolver') - ->will($this->returnValue($resolverMock)); + ->willReturn($resolverMock); $contextMock->expects($this->any()) ->method('getEscaper') - ->will($this->returnValue($escaperMock)); + ->willReturn($escaperMock); $contextMock->expects($this->any()) ->method('getUrlBuilder') - ->will($this->returnValue($urlBuilderMock)); + ->willReturn($urlBuilderMock); $contextMock->expects($this->any()) ->method('getScopeConfig') - ->will($this->returnValue($scopeConfigMock)); + ->willReturn($scopeConfigMock); /** @var \Magento\Framework\View\Element\Html\Link $linkWithAttributes */ - $linkWithAttributes = $objectManagerHelper->getObject( + $linkWithAttributes = $this->objectManager->getObject( \Magento\Framework\View\Element\Html\Link::class, ['context' => $contextMock] ); + + $this->assertEquals( + 'href="http://site.com/link.html"', + $linkWithAttributes->getLinkAttributes() + ); + /** @var \Magento\Framework\View\Element\Html\Link $linkWithoutAttributes */ - $linkWithoutAttributes = $objectManagerHelper->getObject( + $linkWithoutAttributes = $this->objectManager->getObject( \Magento\Framework\View\Element\Html\Link::class, ['context' => $contextMock] ); - foreach ($this->allowedAttributes as $attribute) { - $linkWithAttributes->setDataUsingMethod($attribute, $attribute); + $linkWithoutAttributes->setDataUsingMethod($attribute, $attribute); } - return [ - 'full' => [ - 'link' => $linkWithAttributes, - 'expected' => 'shape="shape" tabindex="tabindex" onfocus="onfocus" onblur="onblur" id="id"', - ], - 'empty' => [ - 'link' => $linkWithoutAttributes, - 'expected' => '', - ], - ]; + $this->assertEquals( + 'href="http://site.com/link.html" shape="shape" tabindex="tabindex" onfocus="onfocus" onblur="onblur" id="id"', + $linkWithoutAttributes->getLinkAttributes() + ); } } From 83a1c236f5d1e9825cc3b498c1c38f8322ffb132 Mon Sep 17 00:00:00 2001 From: Vitaliy Honcharenko <vgoncharenko@magento.com> Date: Mon, 18 Mar 2019 15:43:14 -0500 Subject: [PATCH 134/162] MC-6273: Mysql url_rewrite select make on product view page 170+ times per request - fixed integration tests --- .../Backend/Block/Widget/Form/ContainerTest.php | 2 +- .../Magento/Framework/Lock/Backend/Cache.php | 15 ++++++++++++--- .../Framework/View/Element/AbstractBlock.php | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Form/ContainerTest.php b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Form/ContainerTest.php index e55bb026af6ff..c11204bcdd358 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Form/ContainerTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Block/Widget/Form/ContainerTest.php @@ -30,7 +30,7 @@ public function testGetFormHtml() $expectedHtml = '<b>html</b>'; $this->assertNotEquals($expectedHtml, $block->getFormHtml()); $form->setText($expectedHtml); - $this->assertEquals('', $block->getFormHtml()); + $this->assertEquals($expectedHtml, $block->getFormHtml()); } public function testPseudoConstruct() diff --git a/lib/internal/Magento/Framework/Lock/Backend/Cache.php b/lib/internal/Magento/Framework/Lock/Backend/Cache.php index 7cfa7274e4e31..256ad2fdbd3e1 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Cache.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Cache.php @@ -37,7 +37,7 @@ public function __construct(FrontendInterface $cache) */ public function lock(string $name, int $timeout = -1): bool { - return $this->cache->save('1', self::LOCK_PREFIX . $name, [], $timeout); + return $this->cache->save('1', $this->getIdentifier($name), [], $timeout); } /** @@ -45,7 +45,7 @@ public function lock(string $name, int $timeout = -1): bool */ public function unlock(string $name): bool { - return $this->cache->remove(self::LOCK_PREFIX . $name); + return $this->cache->remove($this->getIdentifier($name)); } /** @@ -53,6 +53,15 @@ public function unlock(string $name): bool */ public function isLocked(string $name): bool { - return (bool)$this->cache->test(self::LOCK_PREFIX . $name); + return (bool)$this->cache->test($this->getIdentifier($name)); + } + + /** + * @param string $name + * @return string + */ + private function getIdentifier(string $name): string + { + return self::LOCK_PREFIX . $name; } } diff --git a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php index 00edfc628d936..187bb0ea1446f 100644 --- a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php +++ b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php @@ -686,7 +686,7 @@ public function toHtml() ]); $html = $transportObject->getHtml(); - return (string)$html; + return $html; } /** From ac8d63dce52af0e445578fe3011292c54ade9d0b Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Mon, 18 Mar 2019 16:02:19 -0500 Subject: [PATCH 135/162] MC-13613: Product mass update --- .../Plugin/MassUpdateProductAttribute.php | 39 ++++++------------- .../Magento/CatalogInventory/composer.json | 1 - .../Api/Data/PoisonPillInterface.php | 8 ---- .../Magento/MessageQueue/Model/PoisonPill.php | 8 ---- 4 files changed, 12 insertions(+), 44 deletions(-) diff --git a/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php b/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php index f41fc00b55acb..95fe5ae24d23e 100644 --- a/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php +++ b/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php @@ -40,19 +40,9 @@ class MassUpdateProductAttribute private $stockConfiguration; /** - * @var \Magento\Framework\App\RequestInterface + * @var \Magento\Catalog\Helper\Product\Edit\Action\Attribute */ - private $request; - - /** - * @var \Magento\Backend\Model\Session - */ - private $session; - - /** - * @var \Magento\Store\Model\StoreManagerInterface - */ - private $storeManager; + private $attributeHelper; /** * @var \Magento\Backend\Model\View\Result\Redirect @@ -69,9 +59,7 @@ class MassUpdateProductAttribute * @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry * @param \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepository * @param \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration - * @param \Magento\Framework\App\RequestInterface $request - * @param \Magento\Backend\Model\Session $session - * @param \Magento\Store\Model\StoreManagerInterface $storeManager + * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper * @param \Magento\Backend\Model\View\Result\RedirectFactory $redirectFactory * @param \Magento\Framework\Message\ManagerInterface $messageManager * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -82,9 +70,7 @@ public function __construct( \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepository, \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration, - \Magento\Framework\App\RequestInterface $request, - \Magento\Backend\Model\Session $session, - \Magento\Store\Model\StoreManagerInterface $storeManager, + \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper, \Magento\Backend\Model\View\Result\RedirectFactory $redirectFactory, \Magento\Framework\Message\ManagerInterface $messageManager ) { @@ -93,9 +79,7 @@ public function __construct( $this->stockRegistry = $stockRegistry; $this->stockItemRepository = $stockItemRepository; $this->stockConfiguration = $stockConfiguration; - $this->request = $request; - $this->session = $session; - $this->storeManager = $storeManager; + $this->attributeHelper = $attributeHelper; $this->redirectFactory = $redirectFactory; $this->messageManager = $messageManager; } @@ -107,18 +91,19 @@ public function __construct( * @param callable $proceed * * @return \Magento\Framework\Controller\ResultInterface - * - * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundExecute(Save $subject, callable $proceed) { try { - $inventoryData = $this->request->getParam('inventory', []); - $storeId = $this->request->getParam('store', \Magento\Store\Model\Store::DEFAULT_STORE_ID); - $websiteId = $this->storeManager->getStore($storeId)->getWebsiteId(); - $productIds = $this->session->getData('product_ids'); + /** @var \Magento\Framework\App\RequestInterface $request */ + $request = $subject->getRequest(); + $inventoryData = $request->getParam('inventory', []); $inventoryData = $this->addConfigSettings($inventoryData); + $storeId = $this->attributeHelper->getSelectedStoreId(); + $websiteId = $this->attributeHelper->getStoreWebsiteId($storeId); + $productIds = $this->attributeHelper->getProductIds(); + if (!empty($inventoryData)) { $this->updateInventoryInProducts($productIds, $websiteId, $inventoryData); } diff --git a/app/code/Magento/CatalogInventory/composer.json b/app/code/Magento/CatalogInventory/composer.json index f18a5ff1d875a..eb6239ea87ef0 100644 --- a/app/code/Magento/CatalogInventory/composer.json +++ b/app/code/Magento/CatalogInventory/composer.json @@ -7,7 +7,6 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", - "magento/module-backend": "*", "magento/module-catalog": "*", "magento/module-search": "*", "magento/module-config": "*", diff --git a/app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php b/app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php index b48d6d585492a..37031b4fba4bb 100644 --- a/app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php +++ b/app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php @@ -20,12 +20,4 @@ interface PoisonPillInterface * @return integer */ public function getVersion(): ?int; - - /** - * Set version of poison pill. - * - * @param int $version - * @return void - */ - public function setVersion(int $version); } diff --git a/app/code/Magento/MessageQueue/Model/PoisonPill.php b/app/code/Magento/MessageQueue/Model/PoisonPill.php index ac70034a85da5..ac53a14f19b0c 100644 --- a/app/code/Magento/MessageQueue/Model/PoisonPill.php +++ b/app/code/Magento/MessageQueue/Model/PoisonPill.php @@ -21,12 +21,4 @@ public function getVersion(): ?int { return $this->_getData('version'); } - - /** - * @inheritdoc - */ - public function setVersion(int $version) - { - $this->setData('version', $version); - } } From 9d65684659fce2eb58ead2ec8adc67896fb3e36e Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Mon, 18 Mar 2019 16:04:00 -0500 Subject: [PATCH 136/162] MAGETWO-98151: Add support ZooKeeper locks --- .../Framework/Lock/Backend/Zookeeper.php | 25 +++++++++++-------- .../Lock/Test/Unit/Backend/ZookeeperTest.php | 12 ++++++++- .../Setup/Model/ConfigOptionsList/Lock.php | 2 +- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php index d491678d4d7fc..3b69c8734d9a9 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php @@ -84,12 +84,18 @@ class Zookeeper implements LockManagerInterface */ public function __construct(string $host, string $path = self::DEFAULT_PATH) { - if (empty($path)) { + if (!$path) { throw new RuntimeException( new Phrase('The path needs to be a non-empty string.') ); } + if (!$host) { + throw new RuntimeException( + new Phrase('The host needs to be a non-empty string.') + ); + } + $this->host = $host; $this->path = preg_replace('#\/*$#', '', $path) ?: '/'; } @@ -221,18 +227,18 @@ private function checkAndCreateParentNode(string $path): bool */ private function getIndex(string $key) { - if (!preg_match("/[0-9]+$/", $key, $matches)) + if (!preg_match('/' . $this->lockName . '([0-9]+)$/', $key, $matches)) return null; - return intval($matches[0]); + return intval($matches[1]); } /** * Checks if there is any sequence node under parent of $fullKey. * At first checks that the $fullKey node is present, if not - returns false. * - * If $indexKey is non-null and there is a smaller index that $indexKey then returns true, - * if all the nodes are larger than $indexKey then returns false. + * If $indexKey is non-null and there is a smaller index than $indexKey then returns true, + * otherwise returns false. * * @param string $fullKey The full path without any sequence info * @param int|null $indexKey The index to compare @@ -249,12 +255,11 @@ private function isAnyLock(string $fullKey, int $indexKey = null): bool $children = $this->getProvider()->getChildren($parent); - foreach ($children as $childKey) { - - if (is_null($indexKey)) { - return true; - } + if (is_null($indexKey) && !empty($children)) { + return true; + } + foreach ($children as $childKey) { $childIndex = $this->getIndex($childKey); if (is_null($childIndex)) { diff --git a/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php b/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php index 7c450a09df320..62521b9de3082 100644 --- a/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php +++ b/lib/internal/Magento/Framework/Lock/Test/Unit/Backend/ZookeeperTest.php @@ -43,11 +43,21 @@ protected function setUp() * @expectedExceptionMessage The path needs to be a non-empty string. * @return void */ - public function testConstructionWithException() + public function testConstructionWithPathException() { $this->zookeeperProvider = new ZookeeperProvider($this->host, ''); } + /** + * @expectedException \Magento\Framework\Exception\RuntimeException + * @expectedExceptionMessage The host needs to be a non-empty string. + * @return void + */ + public function testConstructionWithHostException() + { + $this->zookeeperProvider = new ZookeeperProvider('', $this->path); + } + /** * @return void */ diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php b/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php index ae236c1b5d740..37b5cc38dcbd8 100644 --- a/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php +++ b/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php @@ -241,7 +241,7 @@ private function validateZookeeperConfig(array $options, DeploymentConfig $deplo */ private function getLockProvider(array $options, DeploymentConfig $deploymentConfig): string { - if (empty($options[self::INPUT_KEY_LOCK_PROVIDER])) { + if (!isset($options[self::INPUT_KEY_LOCK_PROVIDER])) { return (string) $deploymentConfig->get( self::CONFIG_PATH_LOCK_PROVIDER, $this->getDefaultValue(self::INPUT_KEY_LOCK_PROVIDER) From aba95a875f8400cb8e71b62edf22e4d1ec50a742 Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk <kolesnyk@adobe.com> Date: Mon, 18 Mar 2019 16:19:09 -0500 Subject: [PATCH 137/162] Update test to correspond Magento standards --- ...ertMiniShoppingCartSubTotalActionGroup.xml | 25 +++++++++++++++++ ...oppingCartCheckSummaryTotalActionGroup.xml | 21 -------------- ...eProductQtyMiniShoppingCartActionGroup.xml | 28 +++++++++++++++++++ .../Checkout/Test/Mftf/Data/QuoteData.xml | 1 + .../Section/StorefrontMiniCartSection.xml | 2 ++ ...eProductFromMiniShoppingCartEntityTest.xml | 27 ++++++------------ 6 files changed, 64 insertions(+), 40 deletions(-) create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertMiniShoppingCartSubTotalActionGroup.xml delete mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/ShoppingCartCheckSummaryTotalActionGroup.xml create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontUpdateProductQtyMiniShoppingCartActionGroup.xml diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertMiniShoppingCartSubTotalActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertMiniShoppingCartSubTotalActionGroup.xml new file mode 100644 index 0000000000000..8c5c6f41fffa7 --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertMiniShoppingCartSubTotalActionGroup.xml @@ -0,0 +1,25 @@ +<?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="AssertMiniShoppingCartSubTotalActionGroup"> + <arguments> + <argument name="dataQuote" type="entity" /> + </arguments> + <waitForPageLoad stepKey="waitForPageLoad" time="120"/> + <grabTextFrom selector="{{StorefrontMinicartSection.miniCartSubtotalField}}" stepKey="grabMiniCartTotal" /> + <assertContains stepKey="assertMiniCartTotal"> + <actualResult type="variable">$grabMiniCartTotal</actualResult> + <expectedResult type="string">{{dataQuote.subtotal}}</expectedResult> + </assertContains> + <assertContains stepKey="assertMiniCartCurrency"> + <actualResult type="variable">$grabMiniCartTotal</actualResult> + <expectedResult type="string">{{dataQuote.currency}}</expectedResult> + </assertContains> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/ShoppingCartCheckSummaryTotalActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/ShoppingCartCheckSummaryTotalActionGroup.xml deleted file mode 100644 index 70b4e95124da8..0000000000000 --- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/ShoppingCartCheckSummaryTotalActionGroup.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?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="ShoppingCartCheckSummaryTotalActionGroup"> - <arguments> - <argument name="dataQuote" type="entity"/> - </arguments> - <waitForPageLoad stepKey="waitForPageLoad" time="120"/> - <grabTextFrom selector="{{CheckoutCartSummarySection.total}}" stepKey="grabCartTotal" /> - <assertContains stepKey="assertCartTotal"> - <actualResult type="variable">$grabCartTotal</actualResult> - <expectedResult type="string">{{dataQuote.total}}</expectedResult> - </assertContains> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontUpdateProductQtyMiniShoppingCartActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontUpdateProductQtyMiniShoppingCartActionGroup.xml new file mode 100644 index 0000000000000..ee8b761a452d4 --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontUpdateProductQtyMiniShoppingCartActionGroup.xml @@ -0,0 +1,28 @@ +<?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="StorefrontUpdateProductQtyMiniShoppingCartActionGroup"> + <arguments> + <argument name="product" type="entity" /> + <argument name="quote" type="entity" /> + </arguments> + + <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="goToMiniShoppingCart"/> + + <!-- Clearing QTY field --> + <doubleClick selector="{{StorefrontMinicartSection.itemQuantityBySku(product.sku)}}" stepKey="doubleClickOnQtyInput" /> + <pressKey selector="{{StorefrontMinicartSection.itemQuantityBySku(product.sku)}}" parameterArray="[\WebDriverKeys::DELETE]" stepKey="clearQty"/> + <!-- Clearing QTY field --> + + <fillField selector="{{StorefrontMinicartSection.itemQuantityBySku(product.sku)}}" userInput="{{quote.qty}}" stepKey="changeQty"/> + <click selector="{{StorefrontMinicartSection.itemQuantityUpdateBySku(product.sku)}}" stepKey="clickUpdateButton"/> + <waitForPageLoad stepKey="waitForProductQtyUpdate" /> + + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml b/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml index be6e1af67fc63..a14ed147aae22 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml @@ -22,5 +22,6 @@ <data key="shipping">10.00</data> <data key="total">1,130.00</data> <data key="shippingMethod">Flat Rate - Fixed</data> + <data key="currency">$</data> </entity> </entities> diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml index bdb02835c6276..38c88bf4f80bb 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml @@ -25,6 +25,8 @@ <element name="deleteMiniCartItem" type="button" selector=".action.delete" timeout="30"/> <element name="deleteMiniCartItemByName" type="button" selector="//ol[@id='mini-cart']//div[contains(., '{{var}}')]//a[contains(@class, 'delete')]" parameterized="true"/> <element name="miniCartSubtotalField" type="text" selector=".block-minicart .amount span.price"/> + <element name="itemQuantityBySku" type="input" selector="#minicart-content-wrapper input[data-cart-item-id='{{productSku}}']" parameterized="true"/> + <element name="itemQuantityUpdateBySku" type="button" selector="//div[@id='minicart-content-wrapper']//input[@data-cart-item-id='{{productSku}}']/../button[contains(@class, 'update-cart-item')]" parameterized="true"/> <element name="itemQuantity" type="input" selector="//a[text()='{{productName}}']/../..//input[contains(@class,'cart-item-qty')]" parameterized="true"/> <element name="itemQuantityUpdate" type="button" selector="//a[text()='{{productName}}']/../..//span[text()='Update']" parameterized="true"/> <element name="itemDiscount" type="text" selector="//tr[@class='totals']//td[@class='amount']/span"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/UpdateProductFromMiniShoppingCartEntityTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/UpdateProductFromMiniShoppingCartEntityTest.xml index 451bce9e49a8f..7318f865a0dc1 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/UpdateProductFromMiniShoppingCartEntityTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/UpdateProductFromMiniShoppingCartEntityTest.xml @@ -14,7 +14,7 @@ <title value="Check updating product from mini shopping cart"/> <description value="Update Product Qty on Mini Shopping Cart"/> <severity value="MAJOR"/> - <testCaseId value="MAGETWO-29812"/> + <testCaseId value="MC-15068"/> <group value="shoppingCart"/> <group value="mtf_migrated"/> </annotations> @@ -23,12 +23,9 @@ <!--Create product according to dataset.--> <createData entity="simpleProductWithoutCategory" stepKey="createProduct"/> - <!-- Go to frontend --> - <amOnPage url="{{StorefrontProductPage.url($$createProduct.name$$)}}" stepKey="navigateToProductPage"/> - <!--Add product to cart--> - <actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartFromStorefrontProductPage"> - <argument name="productName" value="$$createProduct.name$$"/> + <actionGroup ref="AddSimpleProductToCart" stepKey="addToCartFromStorefrontProductPage"> + <argument name="product" value="$$createProduct$$"/> </actionGroup> </before> @@ -37,21 +34,13 @@ <deleteData createDataKey="createProduct" stepKey="deleteProduct" /> </after> - <!-- Click on mini shopping cart icon --> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="goToMiniShoppingCart"/> - - <!-- Click Edit --> - <click selector="{{StorefrontMinicartSection.viewAndEditCart}}" stepKey="editMiniCartItem"/> - - <!-- Fill data from dataset --> - <clearField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" stepKey="deleteFiled"/> - <fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="{{simpleOrderQty2.qty}}" stepKey="changeQty"/> - - <!-- Click Update --> - <click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="updateQty"/> + <actionGroup ref="StorefrontUpdateProductQtyMiniShoppingCartActionGroup" stepKey="updateProductQty"> + <argument name="product" value="$$createProduct$$" /> + <argument name="quote" value="simpleOrderQty2" /> + </actionGroup> <!-- Perform all assertions --> - <actionGroup ref="ShoppingCartCheckSummaryTotalActionGroup" stepKey="checkSummary"> + <actionGroup ref="AssertMiniShoppingCartSubTotalActionGroup" stepKey="checkSummary"> <argument name="dataQuote" value="simpleOrderQty2"/> </actionGroup> </test> From 1b9a1b46c587166624fe2ec28d7a2dc337799cf4 Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk <kolesnyk@adobe.com> Date: Mon, 18 Mar 2019 16:26:01 -0500 Subject: [PATCH 138/162] Add test case ids to community contributed tests --- .../Mftf/Test/AdminCreateOrderStatusDuplicatingCodeTest.xml | 3 ++- .../Mftf/Test/AdminCreateOrderStatusDuplicatingLabelTest.xml | 3 ++- .../Sales/Test/Mftf/Test/AdminCreateOrderStatusTest.xml | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingCodeTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingCodeTest.xml index aea1094b4d629..40a731410a899 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingCodeTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingCodeTest.xml @@ -13,9 +13,10 @@ <stories value="Create order status"/> <title value="Create order status with duplicating code"/> <description value="Receive error when creating order status with the code which is already exist"/> + <severity value="AVERAGE"/> + <testCaseId value="MC-15432" /> <group value="sales"/> <group value="mtf_migrated"/> - <severity value="AVERAGE"/> </annotations> <before> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingLabelTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingLabelTest.xml index 95582e107da19..d1381bbb1efb0 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingLabelTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingLabelTest.xml @@ -13,9 +13,10 @@ <stories value="Create order status"/> <title value="Create order status with duplicating label"/> <description value="Create an order status and get success message"/> + <severity value="AVERAGE"/> + <testCaseId value="MC-15433" /> <group value="sales"/> <group value="mtf_migrated"/> - <severity value="AVERAGE"/> </annotations> <before> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusTest.xml index 6fe25160655fc..c2daaac84dd42 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusTest.xml @@ -13,9 +13,10 @@ <stories value="Create custom order status"/> <title value="Create custom order status"/> <description value="Tests opening admin order status page, create a new order status with success message"/> + <testCaseId value="MC-15431" /> + <severity value="AVERAGE"/> <group value="sales"/> <group value="mtf_migrated"/> - <severity value="AVERAGE"/> </annotations> <before> <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> From 7dfdd6857d1041008a08822c8528f0b32968a221 Mon Sep 17 00:00:00 2001 From: Vitaliy Honcharenko <vgoncharenko@magento.com> Date: Mon, 18 Mar 2019 16:47:34 -0500 Subject: [PATCH 139/162] MC-6273: Mysql url_rewrite select make on product view page 170+ times per request - fixed static tests --- app/code/Magento/Config/App/Config/Type/System.php | 1 + .../Framework/View/Test/Unit/Element/Html/LinkTest.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Config/App/Config/Type/System.php b/app/code/Magento/Config/App/Config/Type/System.php index 8d197bc6ab045..c913716fedee7 100644 --- a/app/code/Magento/Config/App/Config/Type/System.php +++ b/app/code/Magento/Config/App/Config/Type/System.php @@ -27,6 +27,7 @@ * @api * @since 100.1.2 * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.UnusedPrivateMethod) */ class System implements ConfigTypeInterface { diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php index 96161e12e9773..4c76087bfea12 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/LinkTest.php @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Framework\View\Test\Unit\Element\Html; class LinkTest extends \PHPUnit\Framework\TestCase @@ -108,7 +109,8 @@ public function testGetLinkAttributes() } $this->assertEquals( - 'href="http://site.com/link.html" shape="shape" tabindex="tabindex" onfocus="onfocus" onblur="onblur" id="id"', + 'href="http://site.com/link.html" shape="shape" tabindex="tabindex"' + . ' onfocus="onfocus" onblur="onblur" id="id"', $linkWithoutAttributes->getLinkAttributes() ); } From 5aef2fbe5e78efc8390dbceb4da894f49ac72b81 Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk <kolesnyk@adobe.com> Date: Mon, 18 Mar 2019 21:03:52 -0500 Subject: [PATCH 140/162] Fix unstable selector --- .../Test/Mftf/Section/AdminCreateNewProductAttributeSection.xml | 2 +- .../Catalog/Test/Mftf/Section/StorefrontMessagesSection.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateNewProductAttributeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateNewProductAttributeSection.xml index e218f5ae74fc0..2de7bf19fd378 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateNewProductAttributeSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateNewProductAttributeSection.xml @@ -15,7 +15,7 @@ <element name="addValue" type="button" selector="//button[contains(@data-action,'add_new_row')]" timeout="30"/> <element name="defaultStoreView" type="input" selector="//input[contains(@name,'option[value][option_{{row}}][1]')]" parameterized="true"/> <element name="adminOption" type="input" selector="//input[contains(@name,'option[value][option_{{row}}][0]')]" parameterized="true"/> - <element name="defaultRadioButton" type="radio" selector="//tr[{{row}}]//input[contains(@name,'default[]')]/..//label" parameterized="true"/> + <element name="defaultRadioButton" type="radio" selector="//tr[{{row}}]//input[contains(@name,'default[]')]" parameterized="true"/> <element name="isRequired" type="checkbox" selector="//input[contains(@name,'is_required')]/..//label"/> <element name="advancedAttributeProperties" type="text" selector="//div[contains(@data-index,'advanced_fieldset')]"/> <element name="attributeCode" type="input" selector="//*[@class='admin__fieldset-wrapper-content admin__collapsible-content _show']//input[@name='attribute_code']"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontMessagesSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontMessagesSection.xml index 4447b27360a80..c58479a7b73e5 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontMessagesSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontMessagesSection.xml @@ -11,6 +11,6 @@ <section name="StorefrontMessagesSection"> <element name="success" type="text" selector="div.message-success.success.message"/> <element name="error" type="text" selector="div.message-error.error.message"/> - <element name="noticeMessage" type="text" selector="//div[@class='message notice']/div"/> + <element name="noticeMessage" type="text" selector="div.message.notice div"/> </section> </sections> From 9dc5f15c0aa82dd8329005972cf30886e44e8849 Mon Sep 17 00:00:00 2001 From: Michalk39 <michalk9339@gmail.com> Date: Tue, 19 Mar 2019 09:36:03 +0100 Subject: [PATCH 141/162] corrections after review --- .../Magento/Customer/Test/Mftf/Data/CustomerGroupData.xml | 6 ++++++ .../Test/Mftf/Section/AdminCustomerGroupMainSection.xml | 2 +- .../VerifyDisabledCustomerGroupFieldTest.xml | 7 +++---- .../Test/TestCase/VerifyDisabledCustomerGroupFieldTest.xml | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) rename app/code/Magento/Customer/Test/Mftf/{Section => Test}/VerifyDisabledCustomerGroupFieldTest.xml (74%) diff --git a/app/code/Magento/Customer/Test/Mftf/Data/CustomerGroupData.xml b/app/code/Magento/Customer/Test/Mftf/Data/CustomerGroupData.xml index 6b4f3fc9d6b6e..6d3da9715b905 100644 --- a/app/code/Magento/Customer/Test/Mftf/Data/CustomerGroupData.xml +++ b/app/code/Magento/Customer/Test/Mftf/Data/CustomerGroupData.xml @@ -8,6 +8,12 @@ <entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="NotLoggedInCustomerGroup" type="customerGroup"> + <data key="id">0</data> + <data key="code">NOT LOGGED IN</data> + <data key="tax_class_id">3</data> + <data key="tax_class_name">Retail Customer</data> + </entity> <entity name="GeneralCustomerGroup" type="customerGroup"> <data key="code">General</data> <data key="tax_class_id">3</data> diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGroupMainSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGroupMainSection.xml index af6ff35988e02..182adeade69fe 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGroupMainSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGroupMainSection.xml @@ -15,6 +15,6 @@ <element name="selectFirstRow" type="button" selector="//button[@class='action-select']"/> <element name="deleteBtn" type="button" selector="//*[text()='Delete']"/> <element name="clearAllBtn" type="button" selector="//button[text()='Clear all']"/> - <element name="selectIdZeroRow" type="button" selector="tr.data-row:nth-child(1) td.data-grid-actions-cell:nth-child(4) > a.action-menu-item" /> + <element name="editButtonByCustomerGroupCode" type="button" selector="//tr[.//td[count(//th[./*[.='Group']]/preceding-sibling::th) + 1][./*[.='{{code}}']]]//a[contains(@href, '/edit/')]" parametrized="true" /> </section> </sections> diff --git a/app/code/Magento/Customer/Test/Mftf/Section/VerifyDisabledCustomerGroupFieldTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/VerifyDisabledCustomerGroupFieldTest.xml similarity index 74% rename from app/code/Magento/Customer/Test/Mftf/Section/VerifyDisabledCustomerGroupFieldTest.xml rename to app/code/Magento/Customer/Test/Mftf/Test/VerifyDisabledCustomerGroupFieldTest.xml index 36a760d90e125..bb17b1b3269b5 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/VerifyDisabledCustomerGroupFieldTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/VerifyDisabledCustomerGroupFieldTest.xml @@ -29,11 +29,10 @@ <waitForPageLoad stepKey="waitForCustomerGroupsPageLoad" /> <!-- 3. Select system Customer Group specified in data set from grid --> - <click selector="{{AdminCustomerGroupMainSection.selectIdZeroRow}}" stepKey="clickOnEditCustomerGroup" /> + <click selector="{{AdminCustomerGroupMainSection.editButtonByCustomerGroupCode(NotLoggedInCustomerGroup.code)}}" stepKey="clickOnEditCustomerGroup" /> <!-- 4. Perform all assertions --> - <seeInField selector="#customer_group_code" userInput="NOT LOGGED IN" stepKey="seeNotLoggedInTextInGroupName" /> - <assertElementContainsAttribute selector="#customer_group_code" attribute="disabled" expectedValue="true" stepKey="checkIfGroupNameIsDisabled" /> - + <seeInField selector="{{AdminNewCustomerGroupSection.groupName}}" userInput="NOT LOGGED IN" stepKey="seeNotLoggedInTextInGroupName" /> + <assertElementContainsAttribute selector="{{AdminNewCustomerGroupSection.groupName}}" attribute="disabled" expectedValue="true" stepKey="checkIfGroupNameIsDisabled" /> </test> </tests> \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/VerifyDisabledCustomerGroupFieldTest.xml b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/VerifyDisabledCustomerGroupFieldTest.xml index 70a912a3b5ffe..e88e5161e474e 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/VerifyDisabledCustomerGroupFieldTest.xml +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/VerifyDisabledCustomerGroupFieldTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Customer\Test\TestCase\VerifyDisabledCustomerGroupFieldTest" summary="Check that field is disabled in system Customer Group" ticketId="MAGETWO-52481"> <variation name="VerifyDisabledCustomerGroupField1" summary="Checks that customer_group_code field is disabled in NOT LOGGED IN Customer Group"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="customerGroup/dataset" xsi:type="string">NOT_LOGGED_IN</data> <data name="disabledFields" xsi:type="array"> <item name="0" xsi:type="string">customer_group_code</item> From 3d049d6b3d8af849caba0ce9a0b64daa18433a6e Mon Sep 17 00:00:00 2001 From: Leandry <leandry@atwix.com> Date: Tue, 19 Mar 2019 10:37:55 +0200 Subject: [PATCH 142/162] Add anotation and change additional caches selector parametrized --- .../Test/Mftf/Section/AdminCacheManagementSection.xml | 2 +- .../Mftf/Test/FlushStaticFilesCacheButtonVisibilityTest.xml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/PageCache/Test/Mftf/Section/AdminCacheManagementSection.xml b/app/code/Magento/PageCache/Test/Mftf/Section/AdminCacheManagementSection.xml index 12d35df42bcc5..ee0c32633569a 100644 --- a/app/code/Magento/PageCache/Test/Mftf/Section/AdminCacheManagementSection.xml +++ b/app/code/Magento/PageCache/Test/Mftf/Section/AdminCacheManagementSection.xml @@ -30,6 +30,6 @@ <element name="pageCacheCheckbox" type="checkbox" selector="input[value='full_page']"/> <element name="webServicesConfigCheckbox" type="checkbox" selector="input[value='config_webservice']"/> <element name="translationsCheckbox" type="checkbox" selector="input[value='translate']"/> - <element name="FlushStaticFilesCache" type="button" selector="//*[@id='container']//button[contains(., 'Flush Static Files Cache')]"/> + <element name="additionalCacheButton" type="button" selector="//*[@id='container']//button[contains(., '{{cacheType}}')]" parameterized="true" /> </section> </sections> diff --git a/app/code/Magento/PageCache/Test/Mftf/Test/FlushStaticFilesCacheButtonVisibilityTest.xml b/app/code/Magento/PageCache/Test/Mftf/Test/FlushStaticFilesCacheButtonVisibilityTest.xml index 6cd280bb7add3..4a74a62c947fd 100644 --- a/app/code/Magento/PageCache/Test/Mftf/Test/FlushStaticFilesCacheButtonVisibilityTest.xml +++ b/app/code/Magento/PageCache/Test/Mftf/Test/FlushStaticFilesCacheButtonVisibilityTest.xml @@ -15,6 +15,8 @@ <description value="Flush Static Files Cache button visibility"/> <severity value="MAJOR"/> <stories value="Check flush static files cache button"/> + <group value="production_mode_only"/> + <group value="pagecache"/> <group value="mtf_migrated"/> </annotations> <before> @@ -27,6 +29,6 @@ <waitForPageLoad stepKey="waitForPageCacheManagementLoad"/> <!-- Check 'Flush Static Files Cache' not visible in production mode. --> - <dontSee selector="{{AdminCacheManagementSection.FlushStaticFilesCache}}" stepKey="seeFlushStaticFilesButton" /> + <dontSee selector="{{AdminCacheManagementSection.additionalCacheButton('Flush Static Files Cache')}}" stepKey="dontSeeFlushStaticFilesButton" /> </test> </tests> From 3808c33ae9ad49ef022de97cd436589174651dd0 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Tue, 19 Mar 2019 07:55:13 -0500 Subject: [PATCH 143/162] MC-13613: Product mass update --- .../Adminhtml/Product/Action/Attribute/Save.php | 14 +++++++++++--- .../Catalog/Model/Attribute/Backend/Consumer.php | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index 63182dd5624e6..342bbc388f872 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -42,6 +42,11 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribut */ private $userContext; + /** + * @var int + */ + private $bulkSize; + /** * @param Action\Context $context * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper @@ -50,6 +55,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribut * @param \Magento\Framework\DataObject\IdentityGeneratorInterface $identityService * @param \Magento\Framework\Serialize\SerializerInterface $serializer * @param \Magento\Authorization\Model\UserContextInterface $userContext + * @param int $bulkSize */ public function __construct( Action\Context $context, @@ -58,7 +64,8 @@ public function __construct( \Magento\AsynchronousOperations\Api\Data\OperationInterfaceFactory $operartionFactory, \Magento\Framework\DataObject\IdentityGeneratorInterface $identityService, \Magento\Framework\Serialize\SerializerInterface $serializer, - \Magento\Authorization\Model\UserContextInterface $userContext + \Magento\Authorization\Model\UserContextInterface $userContext, + int $bulkSize = 100 ) { parent::__construct($context, $attributeHelper); $this->bulkManagement = $bulkManagement; @@ -66,6 +73,7 @@ public function __construct( $this->identityService = $identityService; $this->serializer = $serializer; $this->userContext = $userContext; + $this->bulkSize = $bulkSize; } /** @@ -171,9 +179,9 @@ private function publish( $websiteId, $productIds ):void { - $productIdsChunks = array_chunk($productIds, 100); + $productIdsChunks = array_chunk($productIds, $this->bulkSize); $bulkUuid = $this->identityService->generateId(); - $bulkDescription = __('Update attributes to ' . count($productIds) . ' selected products'); + $bulkDescription = __('Update attributes for ' . count($productIds) . ' selected products'); $operations = []; foreach ($productIdsChunks as $productIdsChunk) { if ($websiteRemoveData || $websiteAddData) { diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php index becd6c160155c..dc24a3090481e 100644 --- a/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php +++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Consumer.php @@ -110,7 +110,7 @@ public function process(\Magento\AsynchronousOperations\Api\Data\OperationInterf ) { $status = OperationInterface::STATUS_TYPE_RETRIABLY_FAILED; $errorCode = $e->getCode(); - $message = __($e->getMessage()); + $message = $e->getMessage(); } else { $status = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED; $errorCode = $e->getCode(); From 2a6cddd8f5dc0cf7ff9f768e7a1c3704f4a1fcfb Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Tue, 19 Mar 2019 08:19:12 -0500 Subject: [PATCH 144/162] MC-13613: Product mass update --- .../Api/Data/PoisonPillInterface.php | 23 ------------------ .../Api/PoisonPillCompareInterface.php | 6 ++--- .../Api/PoisonPillReadInterface.php | 8 +++---- .../MessageQueue/Model/CallbackInvoker.php | 9 ++++--- .../Magento/MessageQueue/Model/PoisonPill.php | 24 ------------------- .../MessageQueue/Model/PoisonPillCompare.php | 5 ++-- .../Model/ResourceModel/PoisonPill.php | 18 +++----------- app/code/Magento/MessageQueue/etc/di.xml | 1 - 8 files changed, 14 insertions(+), 80 deletions(-) delete mode 100644 app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php delete mode 100644 app/code/Magento/MessageQueue/Model/PoisonPill.php diff --git a/app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php b/app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php deleted file mode 100644 index 37031b4fba4bb..0000000000000 --- a/app/code/Magento/MessageQueue/Api/Data/PoisonPillInterface.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MessageQueue\Api\Data; - -/** - * PoisonPill data interface. - * - * @api - */ -interface PoisonPillInterface -{ - /** - * Returns version of poison pill. - * - * @return integer - */ - public function getVersion(): ?int; -} diff --git a/app/code/Magento/MessageQueue/Api/PoisonPillCompareInterface.php b/app/code/Magento/MessageQueue/Api/PoisonPillCompareInterface.php index e2df3d69ca0aa..3d5b895575597 100644 --- a/app/code/Magento/MessageQueue/Api/PoisonPillCompareInterface.php +++ b/app/code/Magento/MessageQueue/Api/PoisonPillCompareInterface.php @@ -7,8 +7,6 @@ namespace Magento\MessageQueue\Api; -use Magento\MessageQueue\Api\Data\PoisonPillInterface; - /** * Interface describes how to describes how to compare poison pill with latest in DB. * @@ -19,8 +17,8 @@ interface PoisonPillCompareInterface /** * Check if version of current poison pill is latest. * - * @param PoisonPillInterface $poisonPill + * @param int $poisonPillVersion * @return bool */ - public function isLatest(PoisonPillInterface $poisonPill): bool; + public function isLatestVersion(int $poisonPillVersion): bool; } diff --git a/app/code/Magento/MessageQueue/Api/PoisonPillReadInterface.php b/app/code/Magento/MessageQueue/Api/PoisonPillReadInterface.php index 325cfd597956a..db97990ebbad5 100644 --- a/app/code/Magento/MessageQueue/Api/PoisonPillReadInterface.php +++ b/app/code/Magento/MessageQueue/Api/PoisonPillReadInterface.php @@ -7,8 +7,6 @@ namespace Magento\MessageQueue\Api; -use Magento\MessageQueue\Api\Data\PoisonPillInterface; - /** * Describes how to get latest version of poison pill. * @@ -17,9 +15,9 @@ interface PoisonPillReadInterface { /** - * Returns latest poison pill. + * Returns get latest version of poison pill. * - * @return PoisonPillInterface + * @return int */ - public function getLatest(): PoisonPillInterface; + public function getLatestVersion(): int; } diff --git a/app/code/Magento/MessageQueue/Model/CallbackInvoker.php b/app/code/Magento/MessageQueue/Model/CallbackInvoker.php index 1234228dad72d..f37f2157c3575 100644 --- a/app/code/Magento/MessageQueue/Model/CallbackInvoker.php +++ b/app/code/Magento/MessageQueue/Model/CallbackInvoker.php @@ -9,7 +9,6 @@ use Magento\Framework\MessageQueue\CallbackInvokerInterface; use Magento\Framework\MessageQueue\QueueInterface; -use Magento\MessageQueue\Api\Data\PoisonPillInterface; use Magento\MessageQueue\Api\PoisonPillCompareInterface; use Magento\MessageQueue\Api\PoisonPillReadInterface; @@ -24,9 +23,9 @@ class CallbackInvoker implements CallbackInvokerInterface private $poisonPillRead; /** - * @var PoisonPillInterface $poisonPill + * @var int $poisonPillVersion */ - private $poisonPill; + private $poisonPillVersion; /** * @var PoisonPillCompareInterface @@ -51,12 +50,12 @@ public function __construct( */ public function invoke(QueueInterface $queue, $maxNumberOfMessages, $callback) { - $this->poisonPill = $this->poisonPillRead->getLatest(); + $this->poisonPillVersion = $this->poisonPillRead->getLatestVersion(); for ($i = $maxNumberOfMessages; $i > 0; $i--) { do { $message = $queue->dequeue(); } while ($message === null && (sleep(1) === 0)); - if (false === $this->poisonPillCompare->isLatest($this->poisonPill)) { + if (false === $this->poisonPillCompare->isLatestVersion($this->poisonPillVersion)) { $queue->reject($message); exit(0); } diff --git a/app/code/Magento/MessageQueue/Model/PoisonPill.php b/app/code/Magento/MessageQueue/Model/PoisonPill.php deleted file mode 100644 index ac53a14f19b0c..0000000000000 --- a/app/code/Magento/MessageQueue/Model/PoisonPill.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MessageQueue\Model; - -use Magento\MessageQueue\Api\Data\PoisonPillInterface; - -/** - * PoisonPill data class - */ -class PoisonPill extends \Magento\Framework\Model\AbstractModel implements PoisonPillInterface -{ - /** - * @inheritdoc - */ - public function getVersion(): ?int - { - return $this->_getData('version'); - } -} diff --git a/app/code/Magento/MessageQueue/Model/PoisonPillCompare.php b/app/code/Magento/MessageQueue/Model/PoisonPillCompare.php index 6155526287555..a8e40ea495002 100644 --- a/app/code/Magento/MessageQueue/Model/PoisonPillCompare.php +++ b/app/code/Magento/MessageQueue/Model/PoisonPillCompare.php @@ -7,7 +7,6 @@ namespace Magento\MessageQueue\Model; -use Magento\MessageQueue\Api\Data\PoisonPillInterface; use Magento\MessageQueue\Api\PoisonPillCompareInterface; use Magento\MessageQueue\Api\PoisonPillReadInterface; @@ -34,8 +33,8 @@ public function __construct( /** * @inheritdoc */ - public function isLatest(PoisonPillInterface $poisonPill): bool + public function isLatestVersion(int $poisonPillVersion): bool { - return $poisonPill->getVersion() === $this->poisonPillRead->getLatest()->getVersion(); + return $poisonPillVersion === $this->poisonPillRead->getLatestVersion(); } } diff --git a/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php b/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php index ee3d09ec3eaed..283fff8ace7c7 100644 --- a/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php +++ b/app/code/Magento/MessageQueue/Model/ResourceModel/PoisonPill.php @@ -7,8 +7,6 @@ namespace Magento\MessageQueue\Model\ResourceModel; -use Magento\MessageQueue\Api\Data\PoisonPillInterface; -use Magento\MessageQueue\Api\Data\PoisonPillInterfaceFactory; use Magento\MessageQueue\Api\PoisonPillReadInterface; use Magento\MessageQueue\Api\PoisonPillPutInterface; use Magento\Framework\Model\ResourceModel\Db\Context; @@ -24,24 +22,16 @@ class PoisonPill extends AbstractDb implements PoisonPillPutInterface, PoisonPil */ const QUEUE_POISON_PILL_TABLE = 'queue_poison_pill'; - /** - * @var PoisonPillInterfaceFactory - */ - private $poisonPillFactory; - /** * PoisonPill constructor. * * @param Context $context - * @param PoisonPillInterfaceFactory $poisonPillFactory * @param string|null $connectionName */ public function __construct( Context $context, - PoisonPillInterfaceFactory $poisonPillFactory, string $connectionName = null ) { - $this->poisonPillFactory = $poisonPillFactory; parent::__construct($context, $connectionName); } @@ -67,7 +57,7 @@ public function put(): int /** * @inheritdoc */ - public function getLatest() : PoisonPillInterface + public function getLatestVersion() : int { $select = $this->getConnection()->select()->from( $this->getTable(self::QUEUE_POISON_PILL_TABLE), @@ -78,10 +68,8 @@ public function getLatest() : PoisonPillInterface 1 ); - $version = $this->getConnection()->fetchOne($select); - - $poisonPill = $this->poisonPillFactory->create(['data' => ['version' => (int) $version]]); + $version = (int)$this->getConnection()->fetchOne($select); - return $poisonPill; + return $version; } } diff --git a/app/code/Magento/MessageQueue/etc/di.xml b/app/code/Magento/MessageQueue/etc/di.xml index 3b2cb8718e041..22cfea976a722 100644 --- a/app/code/Magento/MessageQueue/etc/di.xml +++ b/app/code/Magento/MessageQueue/etc/di.xml @@ -13,7 +13,6 @@ <preference for="Magento\Framework\MessageQueue\EnvelopeInterface" type="Magento\Framework\MessageQueue\Envelope"/> <preference for="Magento\Framework\MessageQueue\ConsumerInterface" type="Magento\Framework\MessageQueue\Consumer"/> <preference for="Magento\Framework\MessageQueue\MergedMessageInterface" type="Magento\Framework\MessageQueue\MergedMessage"/> - <preference for="Magento\MessageQueue\Api\Data\PoisonPillInterface" type="Magento\MessageQueue\Model\PoisonPill"/> <preference for="Magento\MessageQueue\Api\PoisonPillCompareInterface" type="Magento\MessageQueue\Model\PoisonPillCompare"/> <preference for="Magento\MessageQueue\Api\PoisonPillPutInterface" type="Magento\MessageQueue\Model\ResourceModel\PoisonPill"/> <preference for="Magento\MessageQueue\Api\PoisonPillReadInterface" type="Magento\MessageQueue\Model\ResourceModel\PoisonPill"/> From 166c0d426c08cc4f341adbfe1605581a7cb313dd Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Tue, 19 Mar 2019 09:04:25 -0500 Subject: [PATCH 145/162] MC-13613: Product mass update --- .../Plugin/MassUpdateProductAttribute.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php b/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php index 95fe5ae24d23e..334d2b22edbfa 100644 --- a/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php +++ b/app/code/Magento/CatalogInventory/Plugin/MassUpdateProductAttribute.php @@ -44,10 +44,6 @@ class MassUpdateProductAttribute */ private $attributeHelper; - /** - * @var \Magento\Backend\Model\View\Result\Redirect - */ - private $redirectFactory; /** * @var \Magento\Framework\Message\ManagerInterface */ @@ -60,7 +56,6 @@ class MassUpdateProductAttribute * @param \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepository * @param \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper - * @param \Magento\Backend\Model\View\Result\RedirectFactory $redirectFactory * @param \Magento\Framework\Message\ManagerInterface $messageManager * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -71,7 +66,6 @@ public function __construct( \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepository, \Magento\CatalogInventory\Api\StockConfigurationInterface $stockConfiguration, \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper, - \Magento\Backend\Model\View\Result\RedirectFactory $redirectFactory, \Magento\Framework\Message\ManagerInterface $messageManager ) { $this->stockIndexerProcessor = $stockIndexerProcessor; @@ -80,7 +74,6 @@ public function __construct( $this->stockItemRepository = $stockItemRepository; $this->stockConfiguration = $stockConfiguration; $this->attributeHelper = $attributeHelper; - $this->redirectFactory = $redirectFactory; $this->messageManager = $messageManager; } @@ -111,14 +104,14 @@ public function aroundExecute(Save $subject, callable $proceed) return $proceed(); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); + return $proceed(); } catch (\Exception $e) { $this->messageManager->addExceptionMessage( $e, __('Something went wrong while updating the product(s) attributes.') ); + return $proceed(); } - - return $this->redirectFactory->create()->setPath('catalog/product/', ['_current' => true]); } /** From c8e9365023a3bcdea77b474561a535a49879e90d Mon Sep 17 00:00:00 2001 From: Vitaliy Honcharenko <vgoncharenko@magento.com> Date: Tue, 19 Mar 2019 10:07:50 -0500 Subject: [PATCH 146/162] MC-6273: Mysql url_rewrite select make on product view page 170+ times per request - fixed unit tests --- .../Magento/Framework/Cache/LockGuardedCacheLoader.php | 2 +- lib/internal/Magento/Framework/View/Element/AbstractBlock.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php b/lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php index 8575f208e6c1f..8b500fe7fd3cb 100644 --- a/lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php +++ b/lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php @@ -58,7 +58,7 @@ public function __construct( * @param callable $dataLoader * @param callable $dataCollector * @param callable $dataSaver - * @return array + * @return mixed */ public function lockedLoadData( string $lockName, diff --git a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php index 187bb0ea1446f..6c4746d8218ea 100644 --- a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php +++ b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php @@ -1084,7 +1084,7 @@ protected function getCacheLifetime() /** * Load block html from cache storage * - * @return string|false + * @return string */ protected function _loadCache() { @@ -1126,7 +1126,7 @@ protected function _loadCache() } }; - return $this->lockQuery->lockedLoadData( + return (string)$this->lockQuery->lockedLoadData( $this->getCacheKey(), $loadAction, $collectAction, From 251ce3cfd20ac01617d64e6754ad0ca17f711c60 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Tue, 19 Mar 2019 10:28:34 -0500 Subject: [PATCH 147/162] MAGETWO-98151: Add support ZooKeeper locks --- .../Framework/Lock/Backend/ZookeeperTest.php | 1 - .../Framework/Lock/Backend/Zookeeper.php | 22 +++++++++++-------- lib/internal/Magento/Framework/Lock/Proxy.php | 9 +++++--- .../Setup/Model/ConfigOptionsList/Lock.php | 7 +++--- .../Unit/Model/ConfigOptionsList/LockTest.php | 19 +++++++++++----- 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php b/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php index ae218561377f2..8d0caad5d55e4 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/ZookeeperTest.php @@ -88,4 +88,3 @@ public function testUnlockWithoutExistingLock() $this->assertFalse($this->model->unlock($name)); } } - diff --git a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php index 3b69c8734d9a9..1e7ca069df79b 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php @@ -101,7 +101,8 @@ public function __construct(string $host, string $path = self::DEFAULT_PATH) } /** - * {@inheritdoc} + * @inheritdoc + * * You can see the lock algorithm by the link * @link https://zookeeper.apache.org/doc/r3.1.2/recipes.html#sc_recipes_Locks * @@ -124,7 +125,7 @@ public function lock(string $name, int $timeout = -1): bool throw new RuntimeException(new Phrase('Failed creating lock %1', [$lockPath])); } - while($this->isAnyLock($lockKey, $this->getIndex($lockKey))) { + while ($this->isAnyLock($lockKey, $this->getIndex($lockKey))) { if (!$skipDeadline && $deadline <= microtime(true)) { $this->getProvider()->delete($lockKey); return false; @@ -139,7 +140,8 @@ public function lock(string $name, int $timeout = -1): bool } /** - * {@inheritdoc} + * @inheritdoc + * * @throws RuntimeException */ public function unlock(string $name): bool @@ -152,7 +154,8 @@ public function unlock(string $name): bool } /** - * {@inheritdoc} + * @inheritdoc + * * @throws RuntimeException */ public function isLocked(string $name): bool @@ -184,7 +187,7 @@ private function getProvider(): \Zookeeper } $deadline = microtime(true) + $this->connectionTimeout; - while($this->zookeeper->getState() != \Zookeeper::CONNECTED_STATE) { + while ($this->zookeeper->getState() != \Zookeeper::CONNECTED_STATE) { if ($deadline <= microtime(true)) { throw new RuntimeException(new Phrase('Zookeeper connection timed out!')); } @@ -227,16 +230,17 @@ private function checkAndCreateParentNode(string $path): bool */ private function getIndex(string $key) { - if (!preg_match('/' . $this->lockName . '([0-9]+)$/', $key, $matches)) + if (!preg_match('/' . $this->lockName . '([0-9]+)$/', $key, $matches)) { return null; + } return intval($matches[1]); } /** * Checks if there is any sequence node under parent of $fullKey. - * At first checks that the $fullKey node is present, if not - returns false. * + * At first checks that the $fullKey node is present, if not - returns false. * If $indexKey is non-null and there is a smaller index than $indexKey then returns true, * otherwise returns false. * @@ -255,14 +259,14 @@ private function isAnyLock(string $fullKey, int $indexKey = null): bool $children = $this->getProvider()->getChildren($parent); - if (is_null($indexKey) && !empty($children)) { + if (null === $indexKey && !empty($children)) { return true; } foreach ($children as $childKey) { $childIndex = $this->getIndex($childKey); - if (is_null($childIndex)) { + if (null === $childIndex) { continue; } diff --git a/lib/internal/Magento/Framework/Lock/Proxy.php b/lib/internal/Magento/Framework/Lock/Proxy.php index b5f8eee0f2c4f..2718bf6cb3456 100644 --- a/lib/internal/Magento/Framework/Lock/Proxy.php +++ b/lib/internal/Magento/Framework/Lock/Proxy.php @@ -37,7 +37,8 @@ public function __construct(LockBackendFactory $factory) } /** - * {@inheritdoc} + * @inheritdoc + * * @throws RuntimeException */ public function isLocked(string $name): bool @@ -46,7 +47,8 @@ public function isLocked(string $name): bool } /** - * {@inheritdoc} + * @inheritdoc + * * @throws RuntimeException */ public function lock(string $name, int $timeout = -1): bool @@ -55,7 +57,8 @@ public function lock(string $name, int $timeout = -1): bool } /** - * {@inheritdoc} + * @inheritdoc + * * @throws RuntimeException */ public function unlock(string $name): bool diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php b/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php index 37b5cc38dcbd8..799409d1560ac 100644 --- a/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php +++ b/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php @@ -212,9 +212,9 @@ private function validateZookeeperConfig(array $options, DeploymentConfig $deplo $host = $options[self::INPUT_KEY_LOCK_ZOOKEEPER_HOST] ?? $deploymentConfig->get( - self::CONFIG_PATH_LOCK_ZOOKEEPER_HOST, - $this->getDefaultValue(self::INPUT_KEY_LOCK_ZOOKEEPER_HOST) - ); + self::CONFIG_PATH_LOCK_ZOOKEEPER_HOST, + $this->getDefaultValue(self::INPUT_KEY_LOCK_ZOOKEEPER_HOST) + ); $path = $options[self::INPUT_KEY_LOCK_ZOOKEEPER_PATH] ?? $deploymentConfig->get( self::CONFIG_PATH_LOCK_ZOOKEEPER_PATH, @@ -251,7 +251,6 @@ private function getLockProvider(array $options, DeploymentConfig $deploymentCon return (string) $options[self::INPUT_KEY_LOCK_PROVIDER]; } - /** * Sets default configuration for locks * diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/LockTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/LockTest.php index f7ca6e0a09b5a..5a150ad3dcd86 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/LockTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/LockTest.php @@ -163,7 +163,10 @@ public function testValidate(array $options, array $expectedResult) $this->deploymentConfigMock->expects($this->any()) ->method('get') ->willReturnArgument(1); - $this->assertSame($expectedResult, $this->lockConfigOptionsList->validate($options, $this->deploymentConfigMock)); + $this->assertSame( + $expectedResult, + $this->lockConfigOptionsList->validate($options, $this->deploymentConfigMock) + ); } /** @@ -186,10 +189,16 @@ public function validateDataProvider(): array LockConfigOptionsList::INPUT_KEY_LOCK_ZOOKEEPER_HOST => '', LockConfigOptionsList::INPUT_KEY_LOCK_ZOOKEEPER_PATH => '', ], - 'expectedResult' => [ - 'Zookeeper path needs to be a non-empty string.', - 'Zookeeper host is should be set.', - ], + 'expectedResult' => extension_loaded('zookeeper') + ? [ + 'Zookeeper path needs to be a non-empty string.', + 'Zookeeper host is should be set.', + ] + : [ + 'php extension Zookeeper is not installed.', + 'Zookeeper path needs to be a non-empty string.', + 'Zookeeper host is should be set.', + ], ], ]; } From 7590f5463e2c9d1554ccaa600bac66ce08b8aaa8 Mon Sep 17 00:00:00 2001 From: Vladimir Fishchenko <hws47a@gmail.com> Date: Tue, 19 Mar 2019 15:57:28 +0000 Subject: [PATCH 148/162] magento/magento-functional-tests-migration#417: Convert CreateCustomOrderStatusEntityTest to MFTF - removed unnecessary default values --- .../AdminOrderStatusFormFillAndSaveActionGroup.xml | 4 ++-- .../ActionGroup/AssertOrderStatusExistsInGridActionGroup.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderStatusFormFillAndSaveActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderStatusFormFillAndSaveActionGroup.xml index cb27439a9d886..8108577145421 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderStatusFormFillAndSaveActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderStatusFormFillAndSaveActionGroup.xml @@ -11,8 +11,8 @@ <!-- Fill Order status form and click save --> <actionGroup name="AdminOrderStatusFormFillAndSave"> <arguments> - <argument name="status" type="string" defaultValue=""/> - <argument name="label" type="string" defaultValue=""/> + <argument name="status" type="string" /> + <argument name="label" type="string" /> </arguments> <fillField stepKey="fillStatusCode" selector="{{AdminOrderStatusFormSection.statusCodeField}}" userInput="{{status}}"/> diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusExistsInGridActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusExistsInGridActionGroup.xml index bbb6aa71b8938..5f69f52987688 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusExistsInGridActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertOrderStatusExistsInGridActionGroup.xml @@ -11,8 +11,8 @@ <!-- Search order status grid for item with a specific code and validate data --> <actionGroup name="AssertOrderStatusExistsInGrid"> <arguments> - <argument name="status" type="string" defaultValue=""/> - <argument name="label" type="string" defaultValue=""/> + <argument name="status" type="string" /> + <argument name="label" type="string" /> </arguments> <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters"/> From 28d82a2146d1b22a2abd6cbdb883ad12ce583086 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Tue, 19 Mar 2019 14:00:18 -0500 Subject: [PATCH 149/162] MAGETWO-98800: TunnelAction fails when Google Chart API is not available --- .../Magento/Backend/Controller/Adminhtml/DashboardTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/DashboardTest.php b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/DashboardTest.php index 07af21505f180..89f1e5e5d53d6 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/DashboardTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/DashboardTest.php @@ -21,6 +21,8 @@ public function testAjaxBlockAction() public function testTunnelAction() { + $this->markTestSkipped('MAGETWO-98800: TunnelAction fails when Google Chart API is not available'); + $testUrl = \Magento\Backend\Block\Dashboard\Graph::API_URL . '?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World'; $handle = curl_init(); curl_setopt($handle, CURLOPT_URL, $testUrl); From ef8c8df0e000f73c3a2b6ec09685d3098c750e78 Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk <kolesnyk@adobe.com> Date: Tue, 19 Mar 2019 13:18:00 -0500 Subject: [PATCH 150/162] Update test case ids and add minor fixes --- .../Test/Mftf/Section/AdminCustomerGroupMainSection.xml | 2 +- .../Test/Mftf/Test/VerifyDisabledCustomerGroupFieldTest.xml | 6 +++--- .../Mftf/Test/FlushStaticFilesCacheButtonVisibilityTest.xml | 3 ++- .../TestCase/FlushStaticFilesCacheButtonVisibilityTest.xml | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGroupMainSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGroupMainSection.xml index 182adeade69fe..4cb7f5e3f628e 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGroupMainSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGroupMainSection.xml @@ -15,6 +15,6 @@ <element name="selectFirstRow" type="button" selector="//button[@class='action-select']"/> <element name="deleteBtn" type="button" selector="//*[text()='Delete']"/> <element name="clearAllBtn" type="button" selector="//button[text()='Clear all']"/> - <element name="editButtonByCustomerGroupCode" type="button" selector="//tr[.//td[count(//th[./*[.='Group']]/preceding-sibling::th) + 1][./*[.='{{code}}']]]//a[contains(@href, '/edit/')]" parametrized="true" /> + <element name="editButtonByCustomerGroupCode" type="button" selector="//tr[.//td[count(//th[./*[.='Group']]/preceding-sibling::th) + 1][./*[.='{{code}}']]]//a[contains(@href, '/edit/')]" parameterized="true" /> </section> </sections> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/VerifyDisabledCustomerGroupFieldTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/VerifyDisabledCustomerGroupFieldTest.xml index bb17b1b3269b5..648c30b1ca0bb 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/VerifyDisabledCustomerGroupFieldTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/VerifyDisabledCustomerGroupFieldTest.xml @@ -13,7 +13,7 @@ <stories value="Check that field is disabled in system Customer Group"/> <title value="Check that field is disabled in system Customer Group"/> <description value="Checks that customer_group_code field is disabled in NOT LOGGED IN Customer Group"/> - <testCaseId value="MAGETWO-52481"/> + <testCaseId value="MC-14206"/> <severity value="CRITICAL"/> <group value="customers"/> <group value="mtf_migrated"/> @@ -32,7 +32,7 @@ <click selector="{{AdminCustomerGroupMainSection.editButtonByCustomerGroupCode(NotLoggedInCustomerGroup.code)}}" stepKey="clickOnEditCustomerGroup" /> <!-- 4. Perform all assertions --> - <seeInField selector="{{AdminNewCustomerGroupSection.groupName}}" userInput="NOT LOGGED IN" stepKey="seeNotLoggedInTextInGroupName" /> + <seeInField selector="{{AdminNewCustomerGroupSection.groupName}}" userInput="{{NotLoggedInCustomerGroup.code}}" stepKey="seeNotLoggedInTextInGroupName" /> <assertElementContainsAttribute selector="{{AdminNewCustomerGroupSection.groupName}}" attribute="disabled" expectedValue="true" stepKey="checkIfGroupNameIsDisabled" /> </test> -</tests> \ No newline at end of file +</tests> diff --git a/app/code/Magento/PageCache/Test/Mftf/Test/FlushStaticFilesCacheButtonVisibilityTest.xml b/app/code/Magento/PageCache/Test/Mftf/Test/FlushStaticFilesCacheButtonVisibilityTest.xml index 4a74a62c947fd..bd6f7ba362bf4 100644 --- a/app/code/Magento/PageCache/Test/Mftf/Test/FlushStaticFilesCacheButtonVisibilityTest.xml +++ b/app/code/Magento/PageCache/Test/Mftf/Test/FlushStaticFilesCacheButtonVisibilityTest.xml @@ -11,10 +11,11 @@ <test name="FlushStaticFilesCacheButtonVisibilityTest"> <annotations> <features value="PageCache"/> + <stories value="Page Cache"/> <title value="Check visibility of flush static files cache button"/> <description value="Flush Static Files Cache button visibility"/> <severity value="MAJOR"/> - <stories value="Check flush static files cache button"/> + <testCaseId value="MC-15454"/> <group value="production_mode_only"/> <group value="pagecache"/> <group value="mtf_migrated"/> diff --git a/dev/tests/functional/tests/app/Magento/PageCache/Test/TestCase/FlushStaticFilesCacheButtonVisibilityTest.xml b/dev/tests/functional/tests/app/Magento/PageCache/Test/TestCase/FlushStaticFilesCacheButtonVisibilityTest.xml index cbdce59057195..bc529729f1217 100644 --- a/dev/tests/functional/tests/app/Magento/PageCache/Test/TestCase/FlushStaticFilesCacheButtonVisibilityTest.xml +++ b/dev/tests/functional/tests/app/Magento/PageCache/Test/TestCase/FlushStaticFilesCacheButtonVisibilityTest.xml @@ -8,7 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\PageCache\Test\TestCase\FlushStaticFilesCacheButtonVisibilityTest" summary="Flush Static Files Cache button visibility" ticketId="MAGETWO-39934"> <variation name="FlushStaticFilesCacheButtonVisibilityTest"> - <data name="tag" xsi:type="string">severity:S3</data> + <data name="tag" xsi:type="string">severity:S3, mftf_migrated:yes</data> <constraint name="Magento\PageCache\Test\Constraint\AssertFlushStaticFilesCacheButtonVisibility" /> </variation> </testCase> From 940163e8b25414ea34010d131815123a26bbe781 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Tue, 19 Mar 2019 20:09:55 -0500 Subject: [PATCH 151/162] magento-engcom/magento2ce#2688: Skipped unstable test --- .../Magento/Backend/Controller/Adminhtml/DashboardTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/DashboardTest.php b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/DashboardTest.php index 07af21505f180..89f1e5e5d53d6 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/DashboardTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/DashboardTest.php @@ -21,6 +21,8 @@ public function testAjaxBlockAction() public function testTunnelAction() { + $this->markTestSkipped('MAGETWO-98800: TunnelAction fails when Google Chart API is not available'); + $testUrl = \Magento\Backend\Block\Dashboard\Graph::API_URL . '?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World'; $handle = curl_init(); curl_setopt($handle, CURLOPT_URL, $testUrl); From 52d71a5a39222a00a8f14d7c59f717420dfd8f16 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza <enarc@atwix.com> Date: Wed, 20 Mar 2019 12:09:56 +0100 Subject: [PATCH 152/162] Refactoring --- .../Catalog/Test/Mftf/Data/ProductData.xml | 2 +- .../Section/CheckoutCartProductSection.xml | 3 - ...UpdateShoppingCartSimpleProductQtyTest.xml | 58 ++++++++++++++++++ ...SimpleWithCustomOptionsProductQtyTest.xml} | 61 ++----------------- .../Test/TestCase/UpdateShoppingCartTest.xml | 2 + 5 files changed, 66 insertions(+), 60 deletions(-) create mode 100644 app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml rename app/code/Magento/Checkout/Test/Mftf/Test/{StorefrontUpdateShoppingCartTest.xml => StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml} (50%) diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml index 44635e9b93f9a..6a712fde28025 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml @@ -386,7 +386,7 @@ <var key="sku" entityType="product" entityKey="sku" /> <requiredEntity type="product_option">ProductOptionDropDownWithLongValuesTitle</requiredEntity> </entity> - <entity name="productWithOptions3" type="product"> + <entity name="ProductWithTextFieldAndAreaOptions" type="product"> <var key="sku" entityType="product" entityKey="sku" /> <requiredEntity type="product_option">ProductOptionField</requiredEntity> <requiredEntity type="product_option">ProductOptionArea</requiredEntity> diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml index a63dc5be2de30..dcfb12fd4e965 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml @@ -15,9 +15,6 @@ <element name="ProductPriceByName" type="text" selector="//main//table[@id='shopping-cart-table']//tbody//tr[..//strong[contains(@class, 'product-item-name')]//a/text()='{{var1}}'][1]//td[contains(@class, 'price')]//span[@class='price']" parameterized="true"/> - <element name="ProductSubtotalByName" type="text" - selector="//main//table[@id='shopping-cart-table']//tbody//tr[..//strong[contains(@class, 'product-item-name')]//a/text()='{{var1}}'][1]//td[contains(@class, 'subtotal')]//span[@class='price']" - parameterized="true"/> <element name="ProductImageByName" type="text" selector="//main//table[@id='shopping-cart-table']//tbody//tr//img[contains(@class, 'product-image-photo') and @alt='{{var1}}']" parameterized="true"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml new file mode 100644 index 0000000000000..36eb10826e63c --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml @@ -0,0 +1,58 @@ +<?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="StorefrontUpdateShoppingCartSimpleProductQtyTest"> + <annotations> + <features value="Checkout"/> + <title value="Check updating shopping cart while updating items qty"/> + <description value="Check updating shopping cart while updating items qty"/> + <group value="shoppingCart"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="SimpleProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + + <!-- Add the newly created product to the shopping cart --> + <actionGroup ref="AddSimpleProductToCart" stepKey="addToCartFromStorefrontProductPage"> + <argument name="product" value="$$createProduct$$"/> + </actionGroup> + </before> + <after> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + </after> + + <!-- Go to the shopping cart --> + <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/> + <waitForPageLoad stepKey="waitForCheckoutPageLoad1"/> + + <!-- Change the product QTY --> + <fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="3" stepKey="changeCartQty"/> + <click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="openShoppingCart"/> + <waitForPageLoad stepKey="waitForCheckoutPageLoad2"/> + + <!-- The price and QTY values should be updated for the product --> + <grabValueFrom selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" stepKey="grabProductQtyInCart"/> + <see userInput="$369" selector="{{CheckoutCartProductSection.productSubtotalByName($$createProduct.name$$)}}" stepKey="assertProductPrice"/> + <assertEquals expected="3" actual="$grabProductQtyInCart" stepKey="assertProductQtyInCart"/> + + <!-- Subtotal should be updated --> + <see userInput="$369" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertCartSubtotal"/> + + <!-- Minicart product price and subtotal should be updated --> + <actionGroup ref="clickViewAndEditCartFromMiniCart" stepKey="openMinicart"/> + <grabValueFrom selector="{{StorefrontMinicartSection.itemQuantity($$createProduct.name$$)}}" stepKey="grabProductQtyInMinicart"/> + <assertEquals expected="3" actual="$grabProductQtyInMinicart" stepKey="assertProductQtyInMinicart"/> + <see userInput="$369" selector="{{StorefrontMinicartSection.subtotal}}" stepKey="assertMinicartSubtotal"/> + </test> +</tests> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml similarity index 50% rename from app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartTest.xml rename to app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml index 94abf4b26c347..654a8b231c63c 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml @@ -7,58 +7,8 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> - <test name="UpdateShoppingCartTestVariation1"> - <annotations> - <features value="Checkout"/> - <title value="Check updating shopping cart while updating items qty"/> - <description value="Check updating shopping cart while updating items qty"/> - <group value="shoppingCart"/> - <group value="mtf_migrated"/> - </annotations> - <before> - <createData entity="_defaultCategory" stepKey="createCategory"/> - <createData entity="SimpleProduct" stepKey="createProduct"> - <requiredEntity createDataKey="createCategory"/> - <field key="price">100</field> - </createData> - - <!-- Add the newly created product to the shopping cart --> - <amOnPage url="$$createProduct.custom_attributes[url_key]$$.html" stepKey="navigateToSimpleProductPage"/> - <waitForPageLoad stepKey="waitForCatalogPageLoad1"/> - <actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartFromStorefrontProductPage1"> - <argument name="productName" value="$$createProduct.name$$"/> - </actionGroup> - </before> - <after> - <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> - <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - </after> - - <!-- Go to the shopping cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/> - <waitForPageLoad stepKey="waitForCheckoutPageLoad1"/> - - <!-- Change the product QTY --> - <fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="3" stepKey="changeCartQty"/> - <click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="openShoppingCart"/> - <waitForPageLoad stepKey="waitForCheckoutPageLoad2"/> - - <!-- The price and QTY values should be updated for the product --> - <grabValueFrom selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" stepKey="grabProductQtyInCart"/> - <see userInput="$300" selector="{{CheckoutCartProductSection.ProductSubtotalByName($$createProduct.name$$)}}" stepKey="assertProductPrice"/> - <assertEquals expected="3" actual="$grabProductQtyInCart" stepKey="assertProductQtyInCart"/> - - <!-- Subtotal should be updated --> - <see userInput="$300" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertCartSubtotal"/> - - <!-- Minicart product price and subtotal should be updated --> - <actionGroup ref="clickViewAndEditCartFromMiniCart" stepKey="openMinicart"/> - <grabValueFrom selector="{{StorefrontMinicartSection.itemQuantity($$createProduct.name$$)}}" stepKey="grabProductQtyInMinicart"/> - <assertEquals expected="3" actual="$grabProductQtyInMinicart" stepKey="assertProductQtyInMinicart"/> - <see userInput="$300" selector="{{StorefrontMinicartSection.subtotal}}" stepKey="assertMinicartSubtotal"/> - </test> - <test name="UpdateShoppingCartTestVariation2"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest"> <annotations> <features value="Checkout"/> <title value="Check updating shopping cart while updating qty of items with custom options"/> @@ -68,13 +18,12 @@ </annotations> <before> <createData entity="_defaultCategory" stepKey="createCategory"/> - <createData entity="SimpleProduct" stepKey="createProduct"> + <createData entity="ApiSimpleProductWithCustomPrice" stepKey="createProduct"> <requiredEntity createDataKey="createCategory"/> - <field key="price">100</field> </createData> <!-- Add two custom options to the product: field and textarea --> - <updateData createDataKey="createProduct" entity="productWithOptions3" stepKey="updateProductWithOption"/> + <updateData createDataKey="createProduct" entity="ProductWithTextFieldAndAreaOptions" stepKey="updateProductWithOption"/> <!-- Go to the product page, fill the custom options values and add the product to the shopping cart --> <amOnPage url="{{StorefrontHomePage.url}}$createProduct.custom_attributes[url_key]$.html" stepKey="amOnProductPage"/> @@ -101,7 +50,7 @@ <!-- The price and QTY values should be updated for the product --> <grabValueFrom selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" stepKey="grabProductQtyInCart"/> - <see userInput="$1,320.00" selector="{{CheckoutCartProductSection.ProductSubtotalByName($$createProduct.name$$)}}" stepKey="assertProductPrice"/> + <see userInput="$1,320.00" selector="{{CheckoutCartProductSection.productSubtotalByName($$createProduct.name$$)}}" stepKey="assertProductPrice"/> <assertEquals expected="11" actual="$grabProductQtyInCart" stepKey="assertProductQtyInCart"/> <see userInput="$1,320.00" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertSubtotal"/> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.xml index e0ea721a51f1b..43acf9cd740d1 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Checkout\Test\TestCase\UpdateShoppingCartTest" summary="Update Shopping Cart" ticketId="MAGETWO-25081"> <variation name="UpdateShoppingCartTestVariation1"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="tag" xsi:type="string">severity:S0</data> <data name="product/dataset" xsi:type="string">default</data> <data name="product/data/price/value" xsi:type="string">100</data> @@ -20,6 +21,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertSubtotalInShoppingCart" /> </variation> <variation name="UpdateShoppingCartTestVariation2"> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <data name="tag" xsi:type="string">severity:S0</data> <data name="product/dataset" xsi:type="string">with_two_custom_option</data> <data name="product/data/price/value" xsi:type="string">50</data> From 37b535229f9d8bc9e09b9909a875131d6642d1b7 Mon Sep 17 00:00:00 2001 From: "Lopukhov, Stanislav" <lopukhov@adobe.com> Date: Wed, 20 Mar 2019 09:40:51 -0500 Subject: [PATCH 153/162] MC-13613: Product mass update --- .../Test/Mftf/Test/AdminExportBundleProductTest.xml | 3 +++ .../Test/AdminExportGroupedProductWithSpecialPriceTest.xml | 3 +++ ...ortSimpleAndConfigurableProductsWithCustomOptionsTest.xml | 5 ++++- ...eProductAndConfigurableProductsWithAssignedImagesTest.xml | 5 ++++- ...siteAndConfigurableProductAssignedToCustomWebsiteTest.xml | 3 +++ .../Test/AdminExportSimpleProductWithCustomAttributeTest.xml | 3 +++ 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportBundleProductTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportBundleProductTest.xml index 3a4010f417104..1f5ae6b6905bc 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportBundleProductTest.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportBundleProductTest.xml @@ -115,6 +115,9 @@ <!-- Export created below products --> <actionGroup ref="exportAllProducts" stepKey="exportCreatedProducts"/> + <!-- Run cron --> + <magentoCLI command="cron:run" stepKey="runCron3"/> + <!-- Download product --> <actionGroup ref="downloadFileByRowIndex" stepKey="downloadCreatedProducts"> <argument name="rowIndex" value="0"/> diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportGroupedProductWithSpecialPriceTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportGroupedProductWithSpecialPriceTest.xml index 09d9469cb093d..a587d71ba0e68 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportGroupedProductWithSpecialPriceTest.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportGroupedProductWithSpecialPriceTest.xml @@ -80,6 +80,9 @@ <!-- Export created below products --> <actionGroup ref="exportAllProducts" stepKey="exportCreatedProducts"/> + <!-- Run cron --> + <magentoCLI command="cron:run" stepKey="runCron3"/> + <!-- Download product --> <actionGroup ref="downloadFileByRowIndex" stepKey="downloadCreatedProducts"> <argument name="rowIndex" value="0"/> diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleAndConfigurableProductsWithCustomOptionsTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleAndConfigurableProductsWithCustomOptionsTest.xml index aaeb0cd38cd99..6f64da4693692 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleAndConfigurableProductsWithCustomOptionsTest.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleAndConfigurableProductsWithCustomOptionsTest.xml @@ -107,9 +107,12 @@ <argument name="attributeData" value="$$createConfigProduct.sku$$"/> </actionGroup> + <!-- Run cron --> + <magentoCLI command="cron:run" stepKey="runCron3"/> + <!-- Download product --> <actionGroup ref="downloadFileByRowIndex" stepKey="downloadCreatedProducts"> <argument name="rowIndex" value="0"/> </actionGroup> </test> -</tests> \ No newline at end of file +</tests> diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAndConfigurableProductsWithAssignedImagesTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAndConfigurableProductsWithAssignedImagesTest.xml index 597ee2336b21f..993f1c9cd9da2 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAndConfigurableProductsWithAssignedImagesTest.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAndConfigurableProductsWithAssignedImagesTest.xml @@ -123,9 +123,12 @@ <argument name="attributeData" value="$$createConfigProduct.sku$$"/> </actionGroup> + <!-- Run cron --> + <magentoCLI command="cron:run" stepKey="runCron3"/> + <!-- Download product --> <actionGroup ref="downloadFileByRowIndex" stepKey="downloadCreatedProducts"> <argument name="rowIndex" value="0"/> </actionGroup> </test> -</tests> \ No newline at end of file +</tests> diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAssignedToMainWebsiteAndConfigurableProductAssignedToCustomWebsiteTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAssignedToMainWebsiteAndConfigurableProductAssignedToCustomWebsiteTest.xml index b1e723e5ee1ff..491d20604a08b 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAssignedToMainWebsiteAndConfigurableProductAssignedToCustomWebsiteTest.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductAssignedToMainWebsiteAndConfigurableProductAssignedToCustomWebsiteTest.xml @@ -105,6 +105,9 @@ <!-- Export created below products --> <actionGroup ref="exportAllProducts" stepKey="exportCreatedProducts"/> + <!-- Run cron --> + <magentoCLI command="cron:run" stepKey="runCron3"/> + <!-- Download product --> <actionGroup ref="downloadFileByRowIndex" stepKey="downloadCreatedProducts"> <argument name="rowIndex" value="0"/> diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductWithCustomAttributeTest.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductWithCustomAttributeTest.xml index e3c5cd78397f6..f671b54803e35 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductWithCustomAttributeTest.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/Test/AdminExportSimpleProductWithCustomAttributeTest.xml @@ -57,6 +57,9 @@ <!-- Export created below products --> <actionGroup ref="exportAllProducts" stepKey="exportCreatedProducts"/> + <!-- Run cron --> + <magentoCLI command="cron:run" stepKey="runCron3"/> + <!-- Download product --> <actionGroup ref="downloadFileByRowIndex" stepKey="downloadCreatedProducts"> <argument name="rowIndex" value="0"/> From 1cdae6055bdb1afdcfa575f426623051b9670bd7 Mon Sep 17 00:00:00 2001 From: Vitaliy Honcharenko <vgoncharenko@magento.com> Date: Wed, 20 Mar 2019 10:05:35 -0500 Subject: [PATCH 154/162] MC-6273: Mysql url_rewrite select make on product view page 170+ times per request - fixes after CR --- .../Magento/Config/App/Config/Type/System.php | 9 +++++++- .../Cache/LockGuardedCacheLoader.php | 21 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Config/App/Config/Type/System.php b/app/code/Magento/Config/App/Config/Type/System.php index c913716fedee7..c63ccae871657 100644 --- a/app/code/Magento/Config/App/Config/Type/System.php +++ b/app/code/Magento/Config/App/Config/Type/System.php @@ -389,6 +389,13 @@ private function readData(): array public function clean() { $this->data = []; - $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [self::CACHE_TAG]); + $cleanAction = function () { + $this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [self::CACHE_TAG]); + }; + + $this->lockQuery->lockedCleanData( + self::$lockName, + $cleanAction + ); } } diff --git a/lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php b/lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php index 8b500fe7fd3cb..216d8e9a0a01b 100644 --- a/lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php +++ b/lib/internal/Magento/Framework/Cache/LockGuardedCacheLoader.php @@ -92,4 +92,25 @@ public function lockedLoadData( return $cachedData; } + + /** + * Clean data. + * + * @param string $lockName + * @param callable $dataCleaner + * @return void + */ + public function lockedCleanData(string $lockName, callable $dataCleaner) + { + while ($this->locker->isLocked($lockName)) { + usleep($this->delayTimeout * 1000); + } + try { + if ($this->locker->lock($lockName, $this->lockTimeout / 1000)) { + $dataCleaner(); + } + } finally { + $this->locker->unlock($lockName); + } + } } From 989f2373707ed714ad1bb9518f4b6a0471890e38 Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk <kolesnyk@adobe.com> Date: Wed, 20 Mar 2019 13:57:09 -0500 Subject: [PATCH 155/162] Update test case ids and add minor fixes --- .../Checkout/Test/Mftf/Data/QuoteData.xml | 13 +++++++++ ...UpdateShoppingCartSimpleProductQtyTest.xml | 19 ++++++++----- ...tSimpleWithCustomOptionsProductQtyTest.xml | 27 ++++++++++++------- .../Test/TestCase/UpdateShoppingCartTest.xml | 6 ++--- 4 files changed, 45 insertions(+), 20 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml b/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml index a14ed147aae22..e7a5992ad8943 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Data/QuoteData.xml @@ -24,4 +24,17 @@ <data key="shippingMethod">Flat Rate - Fixed</data> <data key="currency">$</data> </entity> + <entity name="quoteQty3Price123" type="Quote"> + <data key="price">123.00</data> + <data key="qty">3</data> + <data key="subtotal">369.00</data> + <data key="currency">$</data> + </entity> + <entity name="quoteQty11Subtotal1320" type="Quote"> + <data key="price">100.00</data> + <data key="customOptionsPrice">20</data> + <data key="qty">11</data> + <data key="subtotal">1,320.00</data> + <data key="currency">$</data> + </entity> </entities> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml index 36eb10826e63c..423f4049f6722 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml @@ -13,6 +13,7 @@ <features value="Checkout"/> <title value="Check updating shopping cart while updating items qty"/> <description value="Check updating shopping cart while updating items qty"/> + <testCaseId value="MC-14731" /> <group value="shoppingCart"/> <group value="mtf_migrated"/> </annotations> @@ -37,22 +38,28 @@ <waitForPageLoad stepKey="waitForCheckoutPageLoad1"/> <!-- Change the product QTY --> - <fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="3" stepKey="changeCartQty"/> + <fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="{{quoteQty3Price123.qty}}" stepKey="changeCartQty"/> <click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="openShoppingCart"/> <waitForPageLoad stepKey="waitForCheckoutPageLoad2"/> <!-- The price and QTY values should be updated for the product --> <grabValueFrom selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" stepKey="grabProductQtyInCart"/> - <see userInput="$369" selector="{{CheckoutCartProductSection.productSubtotalByName($$createProduct.name$$)}}" stepKey="assertProductPrice"/> - <assertEquals expected="3" actual="$grabProductQtyInCart" stepKey="assertProductQtyInCart"/> + <see userInput="{{quoteQty3Price123.currency}}{{quoteQty3Price123.subtotal}}" selector="{{CheckoutCartProductSection.productSubtotalByName($$createProduct.name$$)}}" stepKey="assertProductPrice"/> + <assertEquals stepKey="assertProductQtyInCart"> + <actualResult type="variable">grabProductQtyInCart</actualResult> + <expectedResult type="string">{{quoteQty3Price123.qty}}</expectedResult> + </assertEquals> <!-- Subtotal should be updated --> - <see userInput="$369" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertCartSubtotal"/> + <see userInput="{{quoteQty3Price123.currency}}{{quoteQty3Price123.subtotal}}" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertCartSubtotal"/> <!-- Minicart product price and subtotal should be updated --> <actionGroup ref="clickViewAndEditCartFromMiniCart" stepKey="openMinicart"/> <grabValueFrom selector="{{StorefrontMinicartSection.itemQuantity($$createProduct.name$$)}}" stepKey="grabProductQtyInMinicart"/> - <assertEquals expected="3" actual="$grabProductQtyInMinicart" stepKey="assertProductQtyInMinicart"/> - <see userInput="$369" selector="{{StorefrontMinicartSection.subtotal}}" stepKey="assertMinicartSubtotal"/> + <assertEquals stepKey="assertProductQtyInMinicart"> + <actualResult type="variable">grabProductQtyInMinicart</actualResult> + <expectedResult type="string">{{quoteQty3Price123.qty}}</expectedResult> + </assertEquals> + <see userInput="{{quoteQty3Price123.currency}}{{quoteQty3Price123.subtotal}}" selector="{{StorefrontMinicartSection.subtotal}}" stepKey="assertMinicartSubtotal"/> </test> </tests> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml index 654a8b231c63c..84080b04c80ee 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml @@ -13,6 +13,7 @@ <features value="Checkout"/> <title value="Check updating shopping cart while updating qty of items with custom options"/> <description value="Check updating shopping cart while updating qty of items with custom options"/> + <testCaseId value="MC-14732" /> <group value="shoppingCart"/> <group value="mtf_migrated"/> </annotations> @@ -26,7 +27,7 @@ <updateData createDataKey="createProduct" entity="ProductWithTextFieldAndAreaOptions" stepKey="updateProductWithOption"/> <!-- Go to the product page, fill the custom options values and add the product to the shopping cart --> - <amOnPage url="{{StorefrontHomePage.url}}$createProduct.custom_attributes[url_key]$.html" stepKey="amOnProductPage"/> + <amOnPage url="{{StorefrontProductPage.url($$createProduct.custom_attributes[url_key]$$)}}" stepKey="amOnProductPage"/> <waitForPageLoad stepKey="waitForCatalogPageLoad"/> <fillField userInput="OptionField" selector="{{StorefrontProductInfoMainSection.productOptionFieldInput(ProductOptionField.title)}}" stepKey="fillProductOptionInputField"/> <fillField userInput="OptionArea" selector="{{StorefrontProductInfoMainSection.productOptionAreaInput(ProductOptionArea.title)}}" stepKey="fillProductOptionInputArea"/> @@ -41,23 +42,29 @@ <!-- Go to the shopping cart --> <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/> - <waitForPageLoad stepKey="waitForCheckoutPageLoad1"/> + <waitForPageLoad stepKey="waitForCheckoutPageLoad"/> <!-- Change the product QTY --> - <fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="11" stepKey="changeCartQty"/> - <click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="openShoppingCart"/> - <waitForPageLoad stepKey="waitForCheckoutPageLoad2"/> + <fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="{{quoteQty11Subtotal1320.qty}}" stepKey="changeCartQty"/> + <click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="updateShoppingCart"/> + <waitForPageLoad stepKey="waitShoppingCartUpdated"/> <!-- The price and QTY values should be updated for the product --> <grabValueFrom selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" stepKey="grabProductQtyInCart"/> - <see userInput="$1,320.00" selector="{{CheckoutCartProductSection.productSubtotalByName($$createProduct.name$$)}}" stepKey="assertProductPrice"/> - <assertEquals expected="11" actual="$grabProductQtyInCart" stepKey="assertProductQtyInCart"/> - <see userInput="$1,320.00" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertSubtotal"/> + <see userInput="{{quoteQty11Subtotal1320.currency}}{{quoteQty11Subtotal1320.subtotal}}" selector="{{CheckoutCartProductSection.productSubtotalByName($$createProduct.name$$)}}" stepKey="assertProductPrice"/> + <assertEquals stepKey="assertProductQtyInCart"> + <expectedResult type="string">{{quoteQty11Subtotal1320.qty}}</expectedResult> + <actualResult type="variable">grabProductQtyInCart</actualResult> + </assertEquals> + <see userInput="{{quoteQty11Subtotal1320.currency}}{{quoteQty11Subtotal1320.subtotal}}" selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="assertSubtotal"/> <!-- Minicart product price and subtotal should be updated --> <actionGroup ref="clickViewAndEditCartFromMiniCart" stepKey="openMinicart"/> <grabValueFrom selector="{{StorefrontMinicartSection.itemQuantity($$createProduct.name$$)}}" stepKey="grabProductQtyInMinicart"/> - <assertEquals expected="11" actual="$grabProductQtyInMinicart" stepKey="assertProductQtyInMinicart"/> - <see userInput="1,320.00" selector="{{StorefrontMinicartSection.subtotal}}" stepKey="assertMinicartSubtotal"/> + <assertEquals stepKey="assertProductQtyInMinicart"> + <expectedResult type="string">{{quoteQty11Subtotal1320.qty}}</expectedResult> + <actualResult type="variable">grabProductQtyInMinicart</actualResult> + </assertEquals> + <see userInput="{{quoteQty11Subtotal1320.currency}}{{quoteQty11Subtotal1320.subtotal}}" selector="{{StorefrontMinicartSection.subtotal}}" stepKey="assertMinicartSubtotal"/> </test> </tests> diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.xml index 43acf9cd740d1..5caa3ba9b924e 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.xml +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/UpdateShoppingCartTest.xml @@ -8,8 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Checkout\Test\TestCase\UpdateShoppingCartTest" summary="Update Shopping Cart" ticketId="MAGETWO-25081"> <variation name="UpdateShoppingCartTestVariation1"> - <data name="tag" xsi:type="string">mftf_migrated:yes</data> - <data name="tag" xsi:type="string">severity:S0</data> + <data name="tag" xsi:type="string">severity:S0,mftf_migrated:yes</data> <data name="product/dataset" xsi:type="string">default</data> <data name="product/data/price/value" xsi:type="string">100</data> <data name="product/data/checkout_data/qty" xsi:type="string">3</data> @@ -21,8 +20,7 @@ <constraint name="Magento\Checkout\Test\Constraint\AssertSubtotalInShoppingCart" /> </variation> <variation name="UpdateShoppingCartTestVariation2"> - <data name="tag" xsi:type="string">mftf_migrated:yes</data> - <data name="tag" xsi:type="string">severity:S0</data> + <data name="tag" xsi:type="string">severity:S0,mftf_migrated:yes</data> <data name="product/dataset" xsi:type="string">with_two_custom_option</data> <data name="product/data/price/value" xsi:type="string">50</data> <data name="product/data/checkout_data/qty" xsi:type="string">11</data> From 0e2a92868c8eebce6a139442285e0cac2a6cff36 Mon Sep 17 00:00:00 2001 From: Vitaliy Honcharenko <vgoncharenko@magento.com> Date: Wed, 20 Mar 2019 14:58:13 -0500 Subject: [PATCH 156/162] MC-6273: Mysql url_rewrite select make on product view page 170+ times per request - fixed static tests --- lib/internal/Magento/Framework/Lock/Backend/Cache.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/Lock/Backend/Cache.php b/lib/internal/Magento/Framework/Lock/Backend/Cache.php index 256ad2fdbd3e1..dfe6bbb828352 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Cache.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Cache.php @@ -57,11 +57,13 @@ public function isLocked(string $name): bool } /** - * @param string $name + * Get cache locked identifier based on cache identifier. + * + * @param string $cacheIdentifier * @return string */ - private function getIdentifier(string $name): string + private function getIdentifier(string $cacheIdentifier): string { - return self::LOCK_PREFIX . $name; + return self::LOCK_PREFIX . $cacheIdentifier; } } From ccb284f9662d1230ba06c10505d524e5dea406a8 Mon Sep 17 00:00:00 2001 From: Alex Kolesnyk <kolesnyk@adobe.com> Date: Wed, 20 Mar 2019 14:58:41 -0500 Subject: [PATCH 157/162] Fix unstable test --- .../Test/Mftf/ActionGroup/AdminExportActionGroup.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml index 63248dd53fc1b..b9eea2b114634 100644 --- a/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml +++ b/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml @@ -56,9 +56,10 @@ <reloadPage stepKey="refreshPage"/> <waitForPageLoad stepKey="waitFormReload"/> <click stepKey="clickSelectBtn" selector="{{AdminExportAttributeSection.selectByIndex(rowIndex)}}"/> - <click stepKey="clickOnDownload" selector="{{AdminExportAttributeSection.delete(rowIndex)}}" after="clickSelectBtn"/> + <click stepKey="clickOnDelete" selector="{{AdminExportAttributeSection.delete(rowIndex)}}" after="clickSelectBtn"/> <waitForElementVisible selector="{{AdminProductGridConfirmActionSection.title}}" stepKey="waitForConfirmModal"/> - <click selector="{{AdminProductGridConfirmActionSection.ok}}" stepKey="confirmProductDelete"/> + <click selector="{{AdminProductGridConfirmActionSection.ok}}" stepKey="confirmDelete"/> + <waitForPageLoad stepKey="waitForExportDataDeleted" /> <see selector="{{AdminDataGridTableSection.dataGridEmpty}}" userInput="We couldn't find any records." stepKey="assertDataGridEmptyMessage"/> </actionGroup> -</actionGroups> \ No newline at end of file +</actionGroups> From f8b955c552c44e4e7478f324d2ecff8f2f0c90e8 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Thu, 21 Mar 2019 09:00:45 -0500 Subject: [PATCH 158/162] MAGETWO-98151: Add support ZooKeeper and flock locks --- .../Framework/Lock/Backend/FileTest.php | 52 +++++ .../Magento/Framework/Lock/Backend/File.php | 194 ++++++++++++++++++ .../Framework/Lock/Backend/Zookeeper.php | 2 +- .../Framework/Lock/LockBackendFactory.php | 9 + .../Lock/Test/Unit/LockBackendFactoryTest.php | 6 + .../Setup/Model/ConfigOptionsList/Lock.php | 52 +++++ .../Unit/Model/ConfigOptionsList/LockTest.php | 29 ++- 7 files changed, 342 insertions(+), 2 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/FileTest.php create mode 100644 lib/internal/Magento/Framework/Lock/Backend/File.php diff --git a/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/FileTest.php b/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/FileTest.php new file mode 100644 index 0000000000000..fd550ac14f22f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/FileTest.php @@ -0,0 +1,52 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Lock\Backend; + +/** + * \Magento\Framework\Lock\Backend\Database test case + */ +class FileTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var \Magento\Framework\Lock\Backend\File + */ + private $model; + + /** + * @var \Magento\Framework\ObjectManagerInterface + */ + private $objectManager; + + protected function setUp() + { + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->model = $this->objectManager->create(\Magento\Framework\Lock\Backend\File::class, ['path' => '/tmp']); + } + + public function testLockAndUnlock() + { + $name = 'test_lock'; + + $this->assertFalse($this->model->isLocked($name)); + + $this->assertTrue($this->model->lock($name)); + $this->assertTrue($this->model->isLocked($name)); + $this->assertFalse($this->model->lock($name, 2)); + + $this->assertTrue($this->model->unlock($name)); + $this->assertFalse($this->model->isLocked($name)); + } + + public function testUnlockWithoutExistingLock() + { + $name = 'test_lock'; + + $this->assertFalse($this->model->isLocked($name)); + $this->assertFalse($this->model->unlock($name)); + } +} diff --git a/lib/internal/Magento/Framework/Lock/Backend/File.php b/lib/internal/Magento/Framework/Lock/Backend/File.php new file mode 100644 index 0000000000000..79f41829f1091 --- /dev/null +++ b/lib/internal/Magento/Framework/Lock/Backend/File.php @@ -0,0 +1,194 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Lock\Backend; + +use Magento\Framework\Lock\LockManagerInterface; +use Magento\Framework\Filesystem\Driver\File as FileDriver; +use Magento\Framework\Exception\RuntimeException; +use Magento\Framework\Exception\FileSystemException; +use Magento\Framework\Phrase; + +/** + * LockManager using the file system for locks + */ +class File implements LockManagerInterface +{ + /** + * The file driver instance + * + * @var FileDriver + */ + private $fileDriver; + + /** + * The path to the locks storage folder + * + * @var string + */ + private $path; + + /** + * How many microseconds to wait before re-try to acquire a lock + * + * @var int + */ + private $sleepCycle = 100000; + + /** + * The mapping list of the path lock with the file resource + * + * @var array + */ + private $locks = []; + + /** + * @param FileDriver $fileDriver The file driver + * @param string $path The path to the locks storage folder + * @throws RuntimeException Throws RuntimeException if $path is empty + * or cannot create the directory for locks + */ + public function __construct(FileDriver $fileDriver, string $path) + { + if (!$path) { + throw new RuntimeException(new Phrase('The path needs to be a non-empty string.')); + } + + $this->fileDriver = $fileDriver; + $this->path = preg_replace('#\/*$#', '', $path) ?: '/'; + + try { + if (!$this->fileDriver->isExists($this->path)) { + $this->fileDriver->createDirectory($this->path); + } + } catch (FileSystemException $exception) { + throw new RuntimeException( + new Phrase('Cannot create the directory for locks: %1', [$this->path]), + $exception + ); + } + } + + /** + * Acquires a lock by name + * + * @param string $name The lock name + * @param int $timeout Timeout in seconds. A negative timeout value means infinite timeout + * @return bool Returns true if the lock is acquired, otherwise returns false + * @throws RuntimeException Throws RuntimeException if cannot acquires the lock because FS problems + */ + public function lock(string $name, int $timeout = -1): bool + { + try { + $lockFile = $this->getLockPath($name); + $fileResource = $this->fileDriver->fileOpen($lockFile, 'w+'); + $skipDeadline = $timeout < 0; + $deadline = microtime(true) + $timeout; + + while (!$this->tryToLock($fileResource)) { + if (!$skipDeadline && $deadline <= microtime(true)) { + $this->fileDriver->fileClose($fileResource); + return false; + } + usleep($this->sleepCycle); + } + } catch (FileSystemException $exception) { + throw new RuntimeException(new Phrase('Cannot acquire a lock.'), $exception); + } + + $this->locks[$lockFile] = $fileResource; + return true; + } + + /** + * Checks if a lock exists by name + * + * @param string $name The lock name + * @return bool Returns true if the lock exists, otherwise returns false + * @throws RuntimeException Throws RuntimeException if cannot check that the lock exists + */ + public function isLocked(string $name): bool + { + $lockFile = $this->getLockPath($name); + $result = false; + + try { + if ($this->fileDriver->isExists($lockFile)) { + $fileResource = $this->fileDriver->fileOpen($lockFile, 'w+'); + if ($this->tryToLock($fileResource)) { + $result = false; + } else { + $result = true; + } + $this->fileDriver->fileClose($fileResource); + } + } catch (FileSystemException $exception) { + throw new RuntimeException(new Phrase('Cannot verify that the lock exists.'), $exception); + } + + return $result; + } + + /** + * Remove the lock by name + * + * @param string $name The lock name + * @return bool If the lock is removed returns true, otherwise returns false + */ + public function unlock(string $name): bool + { + $lockFile = $this->getLockPath($name); + + if (isset($this->locks[$lockFile]) && $this->tryToUnlock($this->locks[$lockFile])) { + unset($this->locks[$lockFile]); + return true; + } + + return false; + } + + /** + * Returns the full path to the lock file by name + * + * @param string $name The lock name + * @return string The path to the lock file + */ + private function getLockPath(string $name): string + { + return $this->path . '/' . $name; + } + + /** + * Tries to lock a file resource + * + * @param resource $resource The file resource + * @return bool If the lock is acquired returns true, otherwise returns false + */ + private function tryToLock($resource): bool + { + try { + return $this->fileDriver->fileLock($resource, LOCK_EX | LOCK_NB); + } catch (FileSystemException $exception) { + return false; + } + } + + /** + * Tries to unlock a file resource + * + * @param resource $resource The file resource + * @return bool If the lock is removed returns true, otherwise returns false + */ + private function tryToUnlock($resource): bool + { + try { + return $this->fileDriver->fileLock($resource, LOCK_UN | LOCK_NB); + } catch (FileSystemException $exception) { + return false; + } + } +} diff --git a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php index 1e7ca069df79b..1dbedaaaa5e1b 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php @@ -54,7 +54,7 @@ class Zookeeper implements LockManagerInterface /** * How many microseconds to wait before recheck connections or nodes * - * @var float + * @var int */ private $sleepCycle = 100000; diff --git a/lib/internal/Magento/Framework/Lock/LockBackendFactory.php b/lib/internal/Magento/Framework/Lock/LockBackendFactory.php index 46cb2998ede70..20e0f69328c88 100644 --- a/lib/internal/Magento/Framework/Lock/LockBackendFactory.php +++ b/lib/internal/Magento/Framework/Lock/LockBackendFactory.php @@ -14,6 +14,7 @@ use Magento\Framework\Lock\Backend\Database as DatabaseLock; use Magento\Framework\Lock\Backend\Zookeeper as ZookeeperLock; use Magento\Framework\Lock\Backend\Cache as CacheLock; +use Magento\Framework\Lock\Backend\File as FileLock; /** * The factory to create object that implements LockManagerInterface @@ -55,6 +56,13 @@ class LockBackendFactory */ const LOCK_CACHE = 'cache'; + /** + * File lock provider name + * + * @const string + */ + const LOCK_FILE = 'file'; + /** * The list of lock providers with mapping on classes * @@ -64,6 +72,7 @@ class LockBackendFactory self::LOCK_DB => DatabaseLock::class, self::LOCK_ZOOKEEPER => ZookeeperLock::class, self::LOCK_CACHE => CacheLock::class, + self::LOCK_FILE => FileLock::class, ]; /** diff --git a/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php b/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php index 8864ab6f9ead1..030b126284db4 100644 --- a/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php +++ b/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php @@ -10,6 +10,7 @@ use Magento\Framework\Lock\Backend\Database as DatabaseLock; use Magento\Framework\Lock\Backend\Zookeeper as ZookeeperLock; use Magento\Framework\Lock\Backend\Cache as CacheLock; +use Magento\Framework\Lock\Backend\File as FileLock; use Magento\Framework\Lock\LockBackendFactory; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Lock\LockManagerInterface; @@ -95,6 +96,11 @@ public function createDataProvider(): array 'lockProviderClass' => CacheLock::class, 'config' => [], ], + 'file' => [ + 'lockProvider' => LockBackendFactory::LOCK_FILE, + 'lockProviderClass' => FileLock::class, + 'config' => ['path' => '/my/path'], + ], ]; if (extension_loaded('zookeeper')) { diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php b/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php index 799409d1560ac..b4cc14e25ca19 100644 --- a/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php +++ b/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php @@ -49,6 +49,13 @@ class Lock implements ConfigOptionsListInterface */ const INPUT_KEY_LOCK_ZOOKEEPER_PATH = 'lock-zookeeper-path'; + /** + * The name of an option to set File path + * + * @const string + */ + const INPUT_KEY_LOCK_FILE_PATH = 'lock-file-path'; + /** * The configuration path to save lock provider * @@ -77,6 +84,13 @@ class Lock implements ConfigOptionsListInterface */ const CONFIG_PATH_LOCK_ZOOKEEPER_PATH = 'lock/config/path'; + /** + * The configuration path to save locks directory path + * + * @const string + */ + const CONFIG_PATH_LOCK_FILE_PATH = 'lock/config/path'; + /** * The list of lock providers * @@ -86,6 +100,7 @@ class Lock implements ConfigOptionsListInterface LockBackendFactory::LOCK_DB, LockBackendFactory::LOCK_ZOOKEEPER, LockBackendFactory::LOCK_CACHE, + LockBackendFactory::LOCK_FILE, ]; /** @@ -106,6 +121,10 @@ class Lock implements ConfigOptionsListInterface LockBackendFactory::LOCK_CACHE => [ self::INPUT_KEY_LOCK_PROVIDER => self::CONFIG_PATH_LOCK_PROVIDER, ], + LockBackendFactory::LOCK_FILE => [ + self::INPUT_KEY_LOCK_PROVIDER => self::CONFIG_PATH_LOCK_PROVIDER, + self::INPUT_KEY_LOCK_FILE_PATH => self::CONFIG_PATH_LOCK_FILE_PATH, + ], ]; /** @@ -151,6 +170,12 @@ public function getOptions() self::CONFIG_PATH_LOCK_ZOOKEEPER_PATH, 'The path where Zookeeper will save locks. The default path is: ' . ZookeeperLock::DEFAULT_PATH ), + new TextConfigOption( + self::INPUT_KEY_LOCK_FILE_PATH, + TextConfigOption::FRONTEND_WIZARD_TEXT, + self::CONFIG_PATH_LOCK_FILE_PATH, + 'The path where file locks will be saved.' + ), ]; } @@ -184,6 +209,9 @@ public function validate(array $options, DeploymentConfig $deploymentConfig) case LockBackendFactory::LOCK_ZOOKEEPER: $errors = $this->validateZookeeperConfig($options, $deploymentConfig); break; + case LockBackendFactory::LOCK_FILE: + $errors = $this->validateFileConfig($options, $deploymentConfig); + break; case LockBackendFactory::LOCK_CACHE: case LockBackendFactory::LOCK_DB: $errors = []; @@ -195,6 +223,30 @@ public function validate(array $options, DeploymentConfig $deploymentConfig) return $errors; } + /** + * Validates File locks configuration + * + * @param array $options + * @param DeploymentConfig $deploymentConfig + * @return array + */ + private function validateFileConfig(array $options, DeploymentConfig $deploymentConfig): array + { + $errors = []; + + $path = $options[self::INPUT_KEY_LOCK_FILE_PATH] + ?? $deploymentConfig->get( + self::CONFIG_PATH_LOCK_FILE_PATH, + $this->getDefaultValue(self::INPUT_KEY_LOCK_ZOOKEEPER_PATH) + ); + + if (!$path) { + $errors[] = 'The path needs to be a non-empty string.'; + } + + return $errors; + } + /** * Validates Zookeeper configuration * diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/LockTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/LockTest.php index 5a150ad3dcd86..1a46bddf5f21a 100644 --- a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/LockTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/LockTest.php @@ -44,7 +44,7 @@ protected function setUp() public function testGetOptions() { $options = $this->lockConfigOptionsList->getOptions(); - $this->assertSame(4, count($options)); + $this->assertSame(5, count($options)); $this->assertArrayHasKey(0, $options); $this->assertInstanceOf(SelectConfigOption::class, $options[0]); @@ -61,6 +61,10 @@ public function testGetOptions() $this->assertArrayHasKey(3, $options); $this->assertInstanceOf(TextConfigOption::class, $options[3]); $this->assertEquals(LockConfigOptionsList::INPUT_KEY_LOCK_ZOOKEEPER_PATH, $options[3]->getName()); + + $this->assertArrayHasKey(4, $options); + $this->assertInstanceOf(TextConfigOption::class, $options[4]); + $this->assertEquals(LockConfigOptionsList::INPUT_KEY_LOCK_FILE_PATH, $options[4]->getName()); } /** @@ -150,6 +154,20 @@ public function createConfigDataProvider(): array ], ], ], + 'Check specific file lock options' => [ + 'options' => [ + LockConfigOptionsList::INPUT_KEY_LOCK_PROVIDER => LockBackendFactory::LOCK_FILE, + LockConfigOptionsList::INPUT_KEY_LOCK_FILE_PATH => '/my/path' + ], + 'expectedResult' => [ + 'lock' => [ + 'provider' => LockBackendFactory::LOCK_FILE, + 'config' => [ + 'path' => '/my/path', + ], + ], + ], + ], ]; } @@ -200,6 +218,15 @@ public function validateDataProvider(): array 'Zookeeper host is should be set.', ], ], + 'Empty path for File lock' => [ + 'options' => [ + LockConfigOptionsList::INPUT_KEY_LOCK_PROVIDER => LockBackendFactory::LOCK_FILE, + LockConfigOptionsList::INPUT_KEY_LOCK_FILE_PATH => '', + ], + 'expectedResult' => [ + 'The path needs to be a non-empty string.', + ], + ], ]; } } From b5eaa81580e7c9fe262e81e0602732eb1e37b49a Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Thu, 21 Mar 2019 09:08:29 -0500 Subject: [PATCH 159/162] MAGETWO-98151: Add support ZooKeeper and flock locks --- .../testsuite/Magento/Framework/Lock/Backend/FileTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/FileTest.php b/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/FileTest.php index fd550ac14f22f..feb111e436b1d 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/FileTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/FileTest.php @@ -8,7 +8,7 @@ namespace Magento\Framework\Lock\Backend; /** - * \Magento\Framework\Lock\Backend\Database test case + * \Magento\Framework\Lock\Backend\File test case */ class FileTest extends \PHPUnit\Framework\TestCase { From a2ad4424d5db9c41f50c4b8090f2e8a981b02014 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Thu, 21 Mar 2019 09:40:01 -0500 Subject: [PATCH 160/162] MAGETWO-98151: Add support ZooKeeper and flock locks --- lib/internal/Magento/Framework/Lock/Backend/File.php | 4 ++-- lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/internal/Magento/Framework/Lock/Backend/File.php b/lib/internal/Magento/Framework/Lock/Backend/File.php index 79f41829f1091..47aed8a6fe3ec 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/File.php +++ b/lib/internal/Magento/Framework/Lock/Backend/File.php @@ -59,7 +59,7 @@ public function __construct(FileDriver $fileDriver, string $path) } $this->fileDriver = $fileDriver; - $this->path = preg_replace('#\/*$#', '', $path) ?: '/'; + $this->path = rtrim($path, '/') . '/'; try { if (!$this->fileDriver->isExists($this->path)) { @@ -159,7 +159,7 @@ public function unlock(string $name): bool */ private function getLockPath(string $name): string { - return $this->path . '/' . $name; + return $this->path . $name; } /** diff --git a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php index 1dbedaaaa5e1b..cbba981ae1b51 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php +++ b/lib/internal/Magento/Framework/Lock/Backend/Zookeeper.php @@ -97,7 +97,7 @@ public function __construct(string $host, string $path = self::DEFAULT_PATH) } $this->host = $host; - $this->path = preg_replace('#\/*$#', '', $path) ?: '/'; + $this->path = rtrim($path, '/') . '/'; } /** @@ -171,7 +171,7 @@ public function isLocked(string $name): bool */ private function getFullPathToLock(string $name): string { - return $this->path . '/' . $name . '/' . $this->lockName; + return $this->path . $name . '/' . $this->lockName; } /** From 2d9c915275cbd5b5b5da1f8b968b56175ca64e0c Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Thu, 21 Mar 2019 12:00:33 -0500 Subject: [PATCH 161/162] MAGETWO-98151: Add support ZooKeeper and flock locks --- .../Lock/Backend/{FileTest.php => FileLockTest.php} | 9 ++++++--- .../Framework/Lock/Backend/{File.php => FileLock.php} | 2 +- .../Magento/Framework/Lock/LockBackendFactory.php | 2 +- .../Framework/Lock/Test/Unit/LockBackendFactoryTest.php | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) rename dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/{FileTest.php => FileLockTest.php} (81%) rename lib/internal/Magento/Framework/Lock/Backend/{File.php => FileLock.php} (99%) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/FileTest.php b/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/FileLockTest.php similarity index 81% rename from dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/FileTest.php rename to dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/FileLockTest.php index feb111e436b1d..e64b3c505acf1 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/FileTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/FileLockTest.php @@ -10,10 +10,10 @@ /** * \Magento\Framework\Lock\Backend\File test case */ -class FileTest extends \PHPUnit\Framework\TestCase +class FileLockTest extends \PHPUnit\Framework\TestCase { /** - * @var \Magento\Framework\Lock\Backend\File + * @var \Magento\Framework\Lock\Backend\FileLock */ private $model; @@ -25,7 +25,10 @@ class FileTest extends \PHPUnit\Framework\TestCase protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->model = $this->objectManager->create(\Magento\Framework\Lock\Backend\File::class, ['path' => '/tmp']); + $this->model = $this->objectManager->create( + \Magento\Framework\Lock\Backend\FileLock::class, + ['path' => '/tmp'] + ); } public function testLockAndUnlock() diff --git a/lib/internal/Magento/Framework/Lock/Backend/File.php b/lib/internal/Magento/Framework/Lock/Backend/FileLock.php similarity index 99% rename from lib/internal/Magento/Framework/Lock/Backend/File.php rename to lib/internal/Magento/Framework/Lock/Backend/FileLock.php index 47aed8a6fe3ec..d168e910a4ab7 100644 --- a/lib/internal/Magento/Framework/Lock/Backend/File.php +++ b/lib/internal/Magento/Framework/Lock/Backend/FileLock.php @@ -16,7 +16,7 @@ /** * LockManager using the file system for locks */ -class File implements LockManagerInterface +class FileLock implements LockManagerInterface { /** * The file driver instance diff --git a/lib/internal/Magento/Framework/Lock/LockBackendFactory.php b/lib/internal/Magento/Framework/Lock/LockBackendFactory.php index 20e0f69328c88..b142085ef6563 100644 --- a/lib/internal/Magento/Framework/Lock/LockBackendFactory.php +++ b/lib/internal/Magento/Framework/Lock/LockBackendFactory.php @@ -14,7 +14,7 @@ use Magento\Framework\Lock\Backend\Database as DatabaseLock; use Magento\Framework\Lock\Backend\Zookeeper as ZookeeperLock; use Magento\Framework\Lock\Backend\Cache as CacheLock; -use Magento\Framework\Lock\Backend\File as FileLock; +use Magento\Framework\Lock\Backend\FileLock; /** * The factory to create object that implements LockManagerInterface diff --git a/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php b/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php index 030b126284db4..ebf2f54f3e093 100644 --- a/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php +++ b/lib/internal/Magento/Framework/Lock/Test/Unit/LockBackendFactoryTest.php @@ -10,7 +10,7 @@ use Magento\Framework\Lock\Backend\Database as DatabaseLock; use Magento\Framework\Lock\Backend\Zookeeper as ZookeeperLock; use Magento\Framework\Lock\Backend\Cache as CacheLock; -use Magento\Framework\Lock\Backend\File as FileLock; +use Magento\Framework\Lock\Backend\FileLock; use Magento\Framework\Lock\LockBackendFactory; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Lock\LockManagerInterface; From 1cb451a2dd2aa2867a9b4b72ec5cfb8f72aa6852 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov <korablov@adobe.com> Date: Thu, 21 Mar 2019 13:15:55 -0500 Subject: [PATCH 162/162] MAGETWO-98151: Add support ZooKeeper and flock locks --- setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php b/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php index b4cc14e25ca19..66f41128c46b1 100644 --- a/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php +++ b/setup/src/Magento/Setup/Model/ConfigOptionsList/Lock.php @@ -237,7 +237,7 @@ private function validateFileConfig(array $options, DeploymentConfig $deployment $path = $options[self::INPUT_KEY_LOCK_FILE_PATH] ?? $deploymentConfig->get( self::CONFIG_PATH_LOCK_FILE_PATH, - $this->getDefaultValue(self::INPUT_KEY_LOCK_ZOOKEEPER_PATH) + $this->getDefaultValue(self::INPUT_KEY_LOCK_FILE_PATH) ); if (!$path) {