From d5693fe45f94d1d3b92d51f756d3bc5147d6060e Mon Sep 17 00:00:00 2001 From: DmitryTsymbal Date: Sun, 29 Sep 2019 10:18:10 +0300 Subject: [PATCH 001/177] Update_Integration_Entity --- ...nClickEditIntegrationEntityActionGroup.xml | 15 +++++ .../AdminCreatesNewIntegrationActionGroup.xml | 23 +++++++ ...gateToCreateIntegrationPageActionGroup.xml | 18 +++++ ...dminSearchIntegrationInGridActionGroup.xml | 23 +++++++ ...ateCreatedIntegrationEntityActionGroup.xml | 27 ++++++++ ...sageCreateIntegrationEntityActionGroup.xml | 19 ++++++ ...atedIntegrationEntityInGridActionGroup.xml | 17 +++++ .../Mftf/Section/AdminIntegrationsSection.xml | 30 +++++++++ .../Test/AdminUpdateIntegrationEntityTest.xml | 67 +++++++++++++++++++ ...grationEntityWithIncorrectPasswordTest.xml | 60 +++++++++++++++++ .../TestCase/UpdateIntegrationEntityTest.xml | 2 + 11 files changed, 301 insertions(+) create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminClickEditIntegrationEntityActionGroup.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminNavigateToCreateIntegrationPageActionGroup.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSearchIntegrationInGridActionGroup.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminMessageCreateIntegrationEntityActionGroup.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertUpdatedIntegrationEntityInGridActionGroup.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminClickEditIntegrationEntityActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminClickEditIntegrationEntityActionGroup.xml new file mode 100644 index 0000000000000..b41ac5a6cc145 --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminClickEditIntegrationEntityActionGroup.xml @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml new file mode 100644 index 0000000000000..533bbb6760573 --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminNavigateToCreateIntegrationPageActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminNavigateToCreateIntegrationPageActionGroup.xml new file mode 100644 index 0000000000000..f31102419b665 --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminNavigateToCreateIntegrationPageActionGroup.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSearchIntegrationInGridActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSearchIntegrationInGridActionGroup.xml new file mode 100644 index 0000000000000..6e0b7dc3eb9d5 --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSearchIntegrationInGridActionGroup.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml new file mode 100644 index 0000000000000..0f385776fbb67 --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminMessageCreateIntegrationEntityActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminMessageCreateIntegrationEntityActionGroup.xml new file mode 100644 index 0000000000000..e928149c7f08f --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminMessageCreateIntegrationEntityActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertUpdatedIntegrationEntityInGridActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertUpdatedIntegrationEntityInGridActionGroup.xml new file mode 100644 index 0000000000000..c825db4e94728 --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertUpdatedIntegrationEntityInGridActionGroup.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml new file mode 100644 index 0000000000000..1f0c39af31e92 --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml @@ -0,0 +1,30 @@ + + + + +
+ + + + + + + + +
+ +
+ + + + + + +
+
diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml new file mode 100644 index 0000000000000..41e05a6bbe107 --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml @@ -0,0 +1,67 @@ + + + + + + + + + + <description value="Admin Updates Created Integration"/> + <group value="integration"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <!-- Login As Admin --> + <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + <!-- Navigate To Integrations Page --> + <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToIntegrationsPage"> + <argument name="menuUiId" value="{{AdminMenuSystem.dataUiId}}"/> + <argument name="submenuUiId" value="{{AdminMenuSystemExtensionsIntegrations.dataUiId}}"/> + </actionGroup> + <!-- Click the "Add New Integration" button --> + <actionGroup ref="AdminNavigateToCreateIntegrationPageActionGroup" stepKey="clickAddNewIntegrationButton"/> + <!-- Create New Integration --> + <actionGroup ref="AdminCreatesNewIntegrationActionGroup" stepKey="createIntegration"> + <argument name="name" value="Integration1"/> + <argument name="password" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/> + </actionGroup> + </before> + <after> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- TEST BODY --> + <!-- Find Created Integration In Grid --> + <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="findCreatedIntegration"> + <argument name="name" value="Integration1"/> + </actionGroup> + <!-- Open Integration Edit Page --> + <actionGroup ref="AdminClickEditIntegrationEntityActionGroup" stepKey="clickEditButton"/> + <!-- Update Integration Entity --> + <actionGroup ref="AdminUpdateCreatedIntegrationEntityActionGroup" stepKey="updateIntegrationEntity"> + <argument name="name" value="Integration Updated"/> + <argument name="endpoint" value="https://endpoint-updated.com"/> + <argument name="linkUrl" value="https://testlink-updated.com"/> + <argument name="password" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/> + </actionGroup> + <!-- Assert Success Message --> + <actionGroup ref="AssertAdminMessageCreateIntegrationEntityActionGroup" stepKey="seeSuccessMessage"> + <argument name="message" value="The integration 'Integration Updated' has been saved."/> + <argument value="success" name="messageType"/> + </actionGroup> + <!-- Assert Updated Entity In Grid --> + <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="findDeletedIntegration"> + <argument name="name" value="Integration Updated"/> + </actionGroup> + <actionGroup ref="AssertUpdatedIntegrationEntityInGridActionGroup" stepKey="seeIntegrationEntity"> + <argument name="name" value="Integration Updated"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml new file mode 100644 index 0000000000000..941a0030f0261 --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml @@ -0,0 +1,60 @@ +<?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="AdminUpdateIntegrationEntityWithIncorrectPasswordTest"> + <annotations> + <features value="Integration"/> + <stories value="System Integration"/> + <title value="Updating System Integration Entity with Incorrect Password"/> + <description value="Admin Updates Created Integration with Incorrect Password"/> + <group value="integration"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <!-- Login As Admin --> + <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + <!-- Navigate To Integrations Page --> + <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToIntegrationsPage"> + <argument name="menuUiId" value="{{AdminMenuSystem.dataUiId}}"/> + <argument name="submenuUiId" value="{{AdminMenuSystemExtensionsIntegrations.dataUiId}}"/> + </actionGroup> + <!-- Click the "Add New Integration" button --> + <actionGroup ref="AdminNavigateToCreateIntegrationPageActionGroup" stepKey="clickAddNewIntegrationButton"/> + <!-- Create New Integration --> + <actionGroup ref="AdminCreatesNewIntegrationActionGroup" stepKey="createIntegration"> + <argument name="name" value="Integration1"/> + <argument name="password" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/> + </actionGroup> + </before> + <after> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- TEST BODY --> + <!-- Find Created Integration In Grid --> + <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="findCreatedIntegration"> + <argument name="name" value="Integration1"/> + </actionGroup> + <!-- Open Integration Edit Page --> + <actionGroup ref="AdminClickEditIntegrationEntityActionGroup" stepKey="clickEditButton"/> + <!-- Update Integration Entity --> + <actionGroup ref="AdminUpdateCreatedIntegrationEntityActionGroup" stepKey="updateIntegrationEntity"> + <argument name="name" value="Integration Updated"/> + <argument name="endpoint" value="https://endpoint-updated.com"/> + <argument name="linkUrl" value="https://testlink-updated.com"/> + <argument name="password" value="12345test"/> + </actionGroup> + <!-- Assert Error Message --> + <actionGroup ref="AssertAdminMessageCreateIntegrationEntityActionGroup" stepKey="seeErrorMessage"> + <argument name="message" value="The password entered for the current user is invalid. Verify the password and try again."/> + <argument value="error" name="messageType"/> + </actionGroup> + </test> +</tests> diff --git a/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/UpdateIntegrationEntityTest.xml b/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/UpdateIntegrationEntityTest.xml index 8ae10e1314b07..97b31c5d6502d 100644 --- a/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/UpdateIntegrationEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/UpdateIntegrationEntityTest.xml @@ -18,6 +18,7 @@ <constraint name="Magento\Integration\Test\Constraint\AssertIntegrationSuccessSaveMessage" /> <constraint name="Magento\Integration\Test\Constraint\AssertIntegrationForm" /> <constraint name="Magento\Integration\Test\Constraint\AssertIntegrationInGrid" /> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> </variation> <variation name="UpdateIntegrationEntityTestVariation2"> <data name="tag" xsi:type="string">stable:no</data> @@ -41,6 +42,7 @@ <data name="integration/data/resource_access" xsi:type="string">Custom</data> <data name="integration/data/resources" xsi:type="string">Sales</data> <constraint name="Magento\Integration\Test\Constraint\AssertIncorrectUserPassword" /> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> </variation> </testCase> </config> From cc11cf6d2e78f217575d1c22e0b1d4c027e539b2 Mon Sep 17 00:00:00 2001 From: DmitryTsymbal <d.tsymbal@atwix.com> Date: Thu, 17 Oct 2019 21:40:47 +0300 Subject: [PATCH 002/177] refactoring --- .../AdminSubmitIntegrationFormActionGroup.xml | 17 +++++++++++++++++ ...pdateCreatedIntegrationEntityActionGroup.xml | 2 -- .../Mftf/Section/AdminIntegrationsSection.xml | 12 ++++++------ ...tegrationEntityWithIncorrectPasswordTest.xml | 2 ++ 4 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSubmitIntegrationFormActionGroup.xml diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSubmitIntegrationFormActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSubmitIntegrationFormActionGroup.xml new file mode 100644 index 0000000000000..316ff84d8d21c --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSubmitIntegrationFormActionGroup.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="AdminSubmitIntegrationFormActionGroup"> + <!--Click the "Save" Button --> + <click stepKey="clickSaveButton" selector="{{AddNewIntegrationSection.save}}"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml index 0f385776fbb67..6635deff85e9a 100644 --- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml @@ -21,7 +21,5 @@ <fillField stepKey="fillEndpiontField" selector="{{AddNewIntegrationSection.endpoint}}" userInput="{{endpoint}}"/> <fillField stepKey="fillLinkUrlField" selector="{{AddNewIntegrationSection.linkUrl}}" userInput="{{linkUrl}}"/> <fillField stepKey="fillAdminPasswordField" selector="{{AddNewIntegrationSection.password}}" userInput="{{password}}"/> - <!--Click the "Save" Button --> - <click stepKey="clickSaveButton" selector="{{AddNewIntegrationSection.save}}"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml index 1f0c39af31e92..4af25b9be9714 100644 --- a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml +++ b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml @@ -9,22 +9,22 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="IntegrationsGridSection"> - <element name="add" type="button" selector=".add"/> + <element name="add" type="button" selector=".page-actions .add"/> <element name="messageByType" type="block" selector="#messages .message-{{messageType}}" parameterized="true"/> - <element name="name" type="input" selector="#integrationGrid_filter_name"/> + <element name="name" type="input" selector=".data-grid-filters #integrationGrid_filter_name"/> <element name="search" type="input" selector=".admin__filter-actions button[title=Search]"/> - <element name="remove" type="button" selector=".delete"/> + <element name="remove" type="button" selector=".data-grid .delete"/> <element name="submitButton" type="button" selector=".action-primary.action-accept" timeout="30"/> <element name="rowByIndex" type="text" selector="tr[data-role='row']:nth-of-type({{var1}})" parameterized="true" timeout="30"/> - <element name="edit" type="button" selector=".edit"/> + <element name="edit" type="button" selector=".data-grid .edit"/> </section> <section name="AddNewIntegrationSection"> <element name="name" type="input" selector="#integration_properties_name"/> <element name="password" type="input" selector="#integration_properties_current_password"/> - <element name="saveButton" type="button" selector="#save-split-button-button"/> + <element name="saveButton" type="button" selector=".page-actions #save-split-button-button"/> <element name="endpoint" type="input" selector="#integration_properties_endpoint"/> <element name="linkUrl" type="input" selector="#integration_properties_identity_link_url"/> - <element name="save" type="button" selector=".save"/> + <element name="save" type="button" selector=".page-actions-buttons .save"/> </section> </sections> diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml index 941a0030f0261..b8cc7bb19f7ea 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml @@ -51,6 +51,8 @@ <argument name="linkUrl" value="https://testlink-updated.com"/> <argument name="password" value="12345test"/> </actionGroup> + <!-- Submit The Form --> + <actionGroup ref="AdminSubmitIntegrationFormActionGroup" stepKey="submitTheForm"/> <!-- Assert Error Message --> <actionGroup ref="AssertAdminMessageCreateIntegrationEntityActionGroup" stepKey="seeErrorMessage"> <argument name="message" value="The password entered for the current user is invalid. Verify the password and try again."/> From ba791b2f60f87d10de4e2960ee4288276b04b44e Mon Sep 17 00:00:00 2001 From: DmitryTsymbal <d.tsymbal@atwix.com> Date: Thu, 17 Oct 2019 21:46:58 +0300 Subject: [PATCH 003/177] refactoring --- .../AdminUpdateCreatedIntegrationEntityActionGroup.xml | 1 + .../Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml index 6635deff85e9a..0f40bd3093ed2 100644 --- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml @@ -23,3 +23,4 @@ <fillField stepKey="fillAdminPasswordField" selector="{{AddNewIntegrationSection.password}}" userInput="{{password}}"/> </actionGroup> </actionGroups> +git \ No newline at end of file diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml index 41e05a6bbe107..589a765a215e5 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml @@ -51,6 +51,8 @@ <argument name="linkUrl" value="https://testlink-updated.com"/> <argument name="password" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/> </actionGroup> + <!-- Submit The Form --> + <actionGroup ref="AdminSubmitIntegrationFormActionGroup" stepKey="submitTheForm"/> <!-- Assert Success Message --> <actionGroup ref="AssertAdminMessageCreateIntegrationEntityActionGroup" stepKey="seeSuccessMessage"> <argument name="message" value="The integration 'Integration Updated' has been saved."/> From 04fe2bf1d455923a2ab691a2d525281de416bec9 Mon Sep 17 00:00:00 2001 From: DmitryTsymbal <d.tsymbal@atwix.com> Date: Thu, 17 Oct 2019 21:50:31 +0300 Subject: [PATCH 004/177] deleting-mistakes --- .../AdminUpdateCreatedIntegrationEntityActionGroup.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml index 0f40bd3093ed2..6635deff85e9a 100644 --- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminUpdateCreatedIntegrationEntityActionGroup.xml @@ -23,4 +23,3 @@ <fillField stepKey="fillAdminPasswordField" selector="{{AddNewIntegrationSection.password}}" userInput="{{password}}"/> </actionGroup> </actionGroups> -git \ No newline at end of file From a025364608ed5baa643221b0513e378b25dbc393 Mon Sep 17 00:00:00 2001 From: DmitryTsymbal <d.tsymbal@atwix.com> Date: Fri, 3 Jan 2020 14:35:56 +0200 Subject: [PATCH 005/177] Create Sitemap Entity --- ...arketingCreateSitemapEntityActionGroup.xml | 23 ++++++++ ...ingNavigateToNewSitemapPageActionGroup.xml | 17 ++++++ ...AdminMarketingSearchSitemapActionGroup.xml | 23 ++++++++ .../AssertAdminSitemapInGridActionGroup.xml | 17 ++++++ .../AssertAdminSitemapMessageActionGroup.xml | 19 +++++++ .../AdminMarketingSiteMapGridSection.xml | 3 ++ .../AdminMarketingSiteMapNewSection.xml | 15 ++++++ .../AdminMarketingCreateSitemapEntityTest.xml | 54 +++++++++++++++++++ ...ketingCreateSitemapFailfFolderSaveTest.xml | 47 ++++++++++++++++ ...minMarketingCreateSitemapPathErrorTest.xml | 48 +++++++++++++++++ .../Test/TestCase/CreateSitemapEntityTest.xml | 6 +-- 11 files changed, 269 insertions(+), 3 deletions(-) create mode 100644 app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingCreateSitemapEntityActionGroup.xml create mode 100644 app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingNavigateToNewSitemapPageActionGroup.xml create mode 100644 app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingSearchSitemapActionGroup.xml create mode 100644 app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapInGridActionGroup.xml create mode 100644 app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapMessageActionGroup.xml create mode 100644 app/code/Magento/Sitemap/Test/Mftf/Section/AdminMarketingSiteMapNewSection.xml create mode 100644 app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml create mode 100644 app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailfFolderSaveTest.xml create mode 100644 app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml diff --git a/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingCreateSitemapEntityActionGroup.xml b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingCreateSitemapEntityActionGroup.xml new file mode 100644 index 0000000000000..9a332c87217d1 --- /dev/null +++ b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingCreateSitemapEntityActionGroup.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"> + + <!--Fill Required Fields --> + <actionGroup name="AdminMarketingCreateSitemapEntityActionGroup"> + <arguments> + <argument name="filename" type="string"/> + <argument name="path" type="string"/> + </arguments> + <fillField stepKey="fillFilenameField" selector="{{NewSiteMapSection.filename}}" userInput="{{filename}}"/> + <fillField stepKey="fillPathField" selector="{{NewSiteMapSection.path}}" userInput="{{path}}"/> + <!--Click the "Save" Button --> + <click stepKey="clickSaveButton" selector="{{NewSiteMapSection.saveButton}}"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingNavigateToNewSitemapPageActionGroup.xml b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingNavigateToNewSitemapPageActionGroup.xml new file mode 100644 index 0000000000000..c72e43c74ae5c --- /dev/null +++ b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingNavigateToNewSitemapPageActionGroup.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"> + + <!--Click "Add New Sitemap Button" --> + <actionGroup name="AdminMarketingNavigateToNewSitemapPageActionGroup"> + <click stepKey="clickAddNewSitemapButton" selector="{{AdminMarketingSiteMapGridSection.add}}"/> + <waitForPageLoad stepKey="waitForNewNewsletterTemplatesPageLoaded"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingSearchSitemapActionGroup.xml b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingSearchSitemapActionGroup.xml new file mode 100644 index 0000000000000..76e0ddc58ea0d --- /dev/null +++ b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingSearchSitemapActionGroup.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="AdminMarketingSearchSitemapActionGroup"> + <arguments> + <argument name="name" type="string"/> + </arguments> + <!--Reset Search Filters --> + <conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/> + <!--Fill Sitemap Name Field --> + <fillField selector="{{AdminMarketingSiteMapGridSection.fileNameTextField}}" userInput="{{name}}" stepKey="filterByName"/> + <!--Click "Search" Button --> + <click selector="{{AdminMarketingSiteMapGridSection.searchButton}}" stepKey="doFilter"/> + <waitForPageLoad stepKey="waitForSitemapPageLoadedAfterFiltering"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapInGridActionGroup.xml b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapInGridActionGroup.xml new file mode 100644 index 0000000000000..c844cb9a3ca76 --- /dev/null +++ b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapInGridActionGroup.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="AssertAdminSitemapInGridActionGroup"> + <arguments> + <argument name="name" type="string"/> + </arguments> + <see userInput="{{name}}" selector="{{AdminMarketingSiteMapGridSection.rowByIndex('1')}}" stepKey="seeSitemap"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapMessageActionGroup.xml b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapMessageActionGroup.xml new file mode 100644 index 0000000000000..0180fe50f8cb4 --- /dev/null +++ b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapMessageActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AssertAdminSitemapMessageActionGroup"> + <arguments> + <argument name="message" type="string" defaultValue="You saved the sitemap."/> + <argument name="messageType" type="string" defaultValue="success"/> + </arguments> + <waitForElementVisible selector="{{AdminMarketingSiteMapGridSection.messageByType(messageType)}}" stepKey="waitForMessage"/> + <see userInput="{{message}}" selector="{{AdminMarketingSiteMapGridSection.messageByType(messageType)}}" stepKey="verifyMessage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Section/AdminMarketingSiteMapGridSection.xml b/app/code/Magento/Sitemap/Test/Mftf/Section/AdminMarketingSiteMapGridSection.xml index 50c96ae6748ce..129712b28c8b2 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Section/AdminMarketingSiteMapGridSection.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Section/AdminMarketingSiteMapGridSection.xml @@ -9,6 +9,9 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminMarketingSiteMapGridSection"> + <element name="add" type="button" selector=".page-actions-buttons .add"/> + <element name="messageByType" type="block" selector="#messages .message-{{messageType}}" parameterized="true"/> + <element name="rowByIndex" type="text" selector="tr[data-role='row']:nth-of-type({{var1}})" parameterized="true" timeout="30"/> <element name="resetButton" type="button" selector="button[title='Reset Filter']"/> <element name="searchButton" type="button" selector=".admin__filter-actions [title='Search']"/> <element name="firstSearchResult" type="text" selector="#sitemapGrid_table>tbody>tr:nth-child(1)"/> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Section/AdminMarketingSiteMapNewSection.xml b/app/code/Magento/Sitemap/Test/Mftf/Section/AdminMarketingSiteMapNewSection.xml new file mode 100644 index 0000000000000..a7908417b7ac3 --- /dev/null +++ b/app/code/Magento/Sitemap/Test/Mftf/Section/AdminMarketingSiteMapNewSection.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="NewSiteMapSection"> + <element name="filename" type="input" selector="#sitemap_filename"/> + <element name="path" type="input" selector="#sitemap_path"/> + <element name="saveButton" type="button" selector=".page-actions .save"/> + </section> +</sections> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml new file mode 100644 index 0000000000000..91ac5c093b46b --- /dev/null +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml @@ -0,0 +1,54 @@ +<?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="AdminMarketingCreateSitemapEntityTest"> + <annotations> + <features value="Sitemap"/> + <stories value="Admin Creates Sitemap Entity"/> + <title value="Sitemap Creation"/> + <description value="Sitemap Entity Creation"/> + <group value="sitemap"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + </before> + <after> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!--TEST BODY --> + <!--Navigate to Marketing->Sitemap Page --> + <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToMarketingSiteMapPage"> + <argument name="menuUiId" value="{{AdminMenuMarketing.dataUiId}}"/> + <argument name="submenuUiId" value="{{AdminMenuSEOAndSearchSiteMap.dataUiId}}"/> + </actionGroup> + <!-- Navigate to New Sitemap Creation Page --> + <actionGroup ref="AdminMarketingNavigateToNewSitemapPageActionGroup" stepKey="navigateToAddNewSitemap"/> + <!-- Create Sitemap Entity --> + <actionGroup ref="AdminMarketingCreateSitemapEntityActionGroup" stepKey="createSitemap"> + <argument name="filename" value="sitemap.xml"/> + <argument name="path" value="/"/> + </actionGroup> + <!-- Assert Success Message --> + <actionGroup ref="AssertAdminSitemapMessageActionGroup" stepKey="seeSuccessMessage"> + <argument name="message" value="You saved the sitemap."/> + <argument name="messageType" value="success"/> + </actionGroup> + <!-- Find Created Sitemap On Grid --> + <actionGroup ref="AdminMarketingSearchSitemapActionGroup" stepKey="findCreatedSitemapInGrid"> + <argument name="name" value="sitemap.xml"/> + </actionGroup> + <actionGroup ref="AssertAdminSitemapInGridActionGroup" stepKey="assertSitemapInGrid"> + <argument name="name" value="sitemap.xml"/> + </actionGroup> + <!--END TEST BODY --> + </test> +</tests> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailfFolderSaveTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailfFolderSaveTest.xml new file mode 100644 index 0000000000000..0f9fb7a51f12f --- /dev/null +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailfFolderSaveTest.xml @@ -0,0 +1,47 @@ +<?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="AdminMarketingCreateSitemapFailfFolderSaveTest"> + <annotations> + <features value="Sitemap"/> + <stories value="Admin Creates Sitemap Entity Fail Folder Save"/> + <title value="Sitemap Creation Fail Folder Save"/> + <description value="Sitemap Entity Creation Fail Folder Save"/> + <group value="sitemap"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + </before> + <after> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!--TEST BODY --> + <!--Navigate to Marketing->Sitemap Page --> + <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToMarketingSiteMapPage"> + <argument name="menuUiId" value="{{AdminMenuMarketing.dataUiId}}"/> + <argument name="submenuUiId" value="{{AdminMenuSEOAndSearchSiteMap.dataUiId}}"/> + </actionGroup> + <!-- Navigate to New Sitemap Creation Page --> + <actionGroup ref="AdminMarketingNavigateToNewSitemapPageActionGroup" stepKey="navigateToAddNewSitemap"/> + <!-- Create Sitemap Entity With Incorrect Folder--> + <actionGroup ref="AdminMarketingCreateSitemapEntityActionGroup" stepKey="createSitemap"> + <argument name="filename" value="sitemap.xml"/> + <argument name="path" value="%isolation%"/> + </actionGroup> + <!-- See Error Message--> + <actionGroup ref="AssertAdminSitemapMessageActionGroup" stepKey="seeErrorMessage"> + <argument name="message" value="Please create the specified folder "%isolation%" before saving the sitemap."/> + <argument value="error" name="messageType"/> + </actionGroup> + <!--END TEST BODY --> + </test> +</tests> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml new file mode 100644 index 0000000000000..d6fc1259e0699 --- /dev/null +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.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="AdminMarketingCreateSitemapPathErrorTest"> + <annotations> + <features value="Sitemap"/> + <stories value="Admin Creates Sitemap Entity Path Error"/> + <title value="Sitemap Creation With Path Error"/> + <description value="Sitemap Entity Creation With Path Error"/> + <group value="sitemap"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + </before> + <after> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!--TEST BODY --> + + <!--Navigate to Marketing->Sitemap Page --> + <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToMarketingSiteMapPage"> + <argument name="menuUiId" value="{{AdminMenuMarketing.dataUiId}}"/> + <argument name="submenuUiId" value="{{AdminMenuSEOAndSearchSiteMap.dataUiId}}"/> + </actionGroup> + <!-- Navigate to New Sitemap Creation Page --> + <actionGroup ref="AdminMarketingNavigateToNewSitemapPageActionGroup" stepKey="navigateToAddNewSitemap"/> + <!-- Create Sitemap Entity With Incorrect Path--> + <actionGroup ref="AdminMarketingCreateSitemapEntityActionGroup" stepKey="createSitemap"> + <argument name="filename" value="%isolation%"/> + <argument name="path" value="/"/> + </actionGroup> + <!-- See Error Message--> + <actionGroup ref="AssertAdminSitemapMessageActionGroup" stepKey="seeErrorMessage"> + <argument name="message" value="Path "/%isolation%" is not available and cannot be used."/> + <argument value="error" name="messageType"/> + </actionGroup> + <!--END TEST BODY --> + </test> +</tests> diff --git a/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/CreateSitemapEntityTest.xml b/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/CreateSitemapEntityTest.xml index d2bf309e68902..f400dba3a380d 100644 --- a/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/CreateSitemapEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/CreateSitemapEntityTest.xml @@ -8,20 +8,20 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Sitemap\Test\TestCase\CreateSitemapEntityTest" summary="Create Sitemap" ticketId="MAGETWO-23277"> <variation name="CreateSitemapEntityTestVariation1"> - <data name="tag" xsi:type="string">test_type:extended_acceptance_test, severity:S1</data> + <data name="tag" xsi:type="string">test_type:extended_acceptance_test, severity:S1,mftf_migrated:yes</data> <data name="sitemap/data/sitemap_filename" xsi:type="string">sitemap.xml</data> <data name="sitemap/data/sitemap_path" xsi:type="string">/</data> <constraint name="Magento\Sitemap\Test\Constraint\AssertSitemapSuccessSaveMessage" /> <constraint name="Magento\Sitemap\Test\Constraint\AssertSitemapInGrid" /> </variation> <variation name="CreateSitemapEntityTestVariation2"> - <data name="tag" xsi:type="string">severity:S3</data> + <data name="tag" xsi:type="string">severity:S3,mftf_migrated:yes</data> <data name="sitemap/data/sitemap_filename" xsi:type="string">%isolation%</data> <data name="sitemap/data/sitemap_path" xsi:type="string">/</data> <constraint name="Magento\Sitemap\Test\Constraint\AssertSitemapFailPathSaveMessage" /> </variation> <variation name="CreateSitemapEntityTestVariation3"> - <data name="tag" xsi:type="string">severity:S3</data> + <data name="tag" xsi:type="string">severity:S3,,mftf_migrated:yes</data> <data name="sitemap/data/sitemap_filename" xsi:type="string">sitemap.xml</data> <data name="sitemap/data/sitemap_path" xsi:type="string">/%isolation%</data> <constraint name="Magento\Sitemap\Test\Constraint\AssertSitemapFailFolderSaveMessage" /> From 252973f69865b4d845822e3959c902f0bc925121 Mon Sep 17 00:00:00 2001 From: DmitryTsymbal <d.tsymbal@atwix.com> Date: Mon, 6 Jan 2020 10:27:15 +0200 Subject: [PATCH 006/177] refactoring --- .../AssertAdminSitemapMessageActionGroup.xml | 19 ------------------- .../AdminMarketingSiteMapGridSection.xml | 1 - .../AdminMarketingCreateSitemapEntityTest.xml | 2 +- ...ketingCreateSitemapFailfFolderSaveTest.xml | 2 +- ...minMarketingCreateSitemapPathErrorTest.xml | 2 +- .../Test/TestCase/CreateSitemapEntityTest.xml | 2 +- 6 files changed, 4 insertions(+), 24 deletions(-) delete mode 100644 app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapMessageActionGroup.xml diff --git a/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapMessageActionGroup.xml b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapMessageActionGroup.xml deleted file mode 100644 index 0180fe50f8cb4..0000000000000 --- a/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapMessageActionGroup.xml +++ /dev/null @@ -1,19 +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="AssertAdminSitemapMessageActionGroup"> - <arguments> - <argument name="message" type="string" defaultValue="You saved the sitemap."/> - <argument name="messageType" type="string" defaultValue="success"/> - </arguments> - <waitForElementVisible selector="{{AdminMarketingSiteMapGridSection.messageByType(messageType)}}" stepKey="waitForMessage"/> - <see userInput="{{message}}" selector="{{AdminMarketingSiteMapGridSection.messageByType(messageType)}}" stepKey="verifyMessage"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Section/AdminMarketingSiteMapGridSection.xml b/app/code/Magento/Sitemap/Test/Mftf/Section/AdminMarketingSiteMapGridSection.xml index 129712b28c8b2..d315cc24e8f96 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Section/AdminMarketingSiteMapGridSection.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Section/AdminMarketingSiteMapGridSection.xml @@ -10,7 +10,6 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminMarketingSiteMapGridSection"> <element name="add" type="button" selector=".page-actions-buttons .add"/> - <element name="messageByType" type="block" selector="#messages .message-{{messageType}}" parameterized="true"/> <element name="rowByIndex" type="text" selector="tr[data-role='row']:nth-of-type({{var1}})" parameterized="true" timeout="30"/> <element name="resetButton" type="button" selector="button[title='Reset Filter']"/> <element name="searchButton" type="button" selector=".admin__filter-actions [title='Search']"/> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml index 91ac5c093b46b..daf3e58bca354 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml @@ -38,7 +38,7 @@ <argument name="path" value="/"/> </actionGroup> <!-- Assert Success Message --> - <actionGroup ref="AssertAdminSitemapMessageActionGroup" stepKey="seeSuccessMessage"> + <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="seeSuccessMessage"> <argument name="message" value="You saved the sitemap."/> <argument name="messageType" value="success"/> </actionGroup> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailfFolderSaveTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailfFolderSaveTest.xml index 0f9fb7a51f12f..b0669a690370e 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailfFolderSaveTest.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailfFolderSaveTest.xml @@ -38,7 +38,7 @@ <argument name="path" value="%isolation%"/> </actionGroup> <!-- See Error Message--> - <actionGroup ref="AssertAdminSitemapMessageActionGroup" stepKey="seeErrorMessage"> + <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="seeErrorMessage"> <argument name="message" value="Please create the specified folder "%isolation%" before saving the sitemap."/> <argument value="error" name="messageType"/> </actionGroup> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml index d6fc1259e0699..6451080d62025 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml @@ -39,7 +39,7 @@ <argument name="path" value="/"/> </actionGroup> <!-- See Error Message--> - <actionGroup ref="AssertAdminSitemapMessageActionGroup" stepKey="seeErrorMessage"> + <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="seeErrorMessage"> <argument name="message" value="Path "/%isolation%" is not available and cannot be used."/> <argument value="error" name="messageType"/> </actionGroup> diff --git a/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/CreateSitemapEntityTest.xml b/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/CreateSitemapEntityTest.xml index f400dba3a380d..f1da612aa6ca0 100644 --- a/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/CreateSitemapEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/CreateSitemapEntityTest.xml @@ -21,7 +21,7 @@ <constraint name="Magento\Sitemap\Test\Constraint\AssertSitemapFailPathSaveMessage" /> </variation> <variation name="CreateSitemapEntityTestVariation3"> - <data name="tag" xsi:type="string">severity:S3,,mftf_migrated:yes</data> + <data name="tag" xsi:type="string">severity:S3,mftf_migrated:yes</data> <data name="sitemap/data/sitemap_filename" xsi:type="string">sitemap.xml</data> <data name="sitemap/data/sitemap_path" xsi:type="string">/%isolation%</data> <constraint name="Magento\Sitemap\Test\Constraint\AssertSitemapFailFolderSaveMessage" /> From 9221e6e3f87c784db9f1752a9219697e033ccd8b Mon Sep 17 00:00:00 2001 From: Matheus Gontijo <matheus@matheusgontijo.com> Date: Tue, 7 Jan 2020 11:28:33 -0300 Subject: [PATCH 007/177] bugfix - customer emails are not being sent from admin if customer is assiged to store "0". "0" should be considered a valid store id --- .../Magento/Customer/Model/EmailNotification.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Customer/Model/EmailNotification.php b/app/code/Magento/Customer/Model/EmailNotification.php index 432317444f4b7..068525344d3bb 100644 --- a/app/code/Magento/Customer/Model/EmailNotification.php +++ b/app/code/Magento/Customer/Model/EmailNotification.php @@ -167,7 +167,7 @@ public function credentialsChanged( private function emailAndPasswordChanged(CustomerInterface $customer, $email) { $storeId = $customer->getStoreId(); - if (!$storeId) { + if ($storeId === null) { $storeId = $this->getWebsiteStoreId($customer); } @@ -193,7 +193,7 @@ private function emailAndPasswordChanged(CustomerInterface $customer, $email) private function emailChanged(CustomerInterface $customer, $email) { $storeId = $customer->getStoreId(); - if (!$storeId) { + if ($storeId === null) { $storeId = $this->getWebsiteStoreId($customer); } @@ -218,7 +218,7 @@ private function emailChanged(CustomerInterface $customer, $email) private function passwordReset(CustomerInterface $customer) { $storeId = $customer->getStoreId(); - if (!$storeId) { + if ($storeId === null) { $storeId = $this->getWebsiteStoreId($customer); } @@ -317,7 +317,7 @@ private function getWebsiteStoreId($customer, $defaultStoreId = null) public function passwordReminder(CustomerInterface $customer) { $storeId = $customer->getStoreId(); - if (!$storeId) { + if ($storeId === null) { $storeId = $this->getWebsiteStoreId($customer); } @@ -341,7 +341,7 @@ public function passwordReminder(CustomerInterface $customer) public function passwordResetConfirmation(CustomerInterface $customer) { $storeId = $customer->getStoreId(); - if (!$storeId) { + if ($storeId === null) { $storeId = $this->getWebsiteStoreId($customer); } @@ -382,7 +382,7 @@ public function newAccount( ); } - if (!$storeId) { + if ($storeId === null) { $storeId = $this->getWebsiteStoreId($customer, $sendemailStoreId); } From d488fd1023ccdafb48160ec62c160aafaf6575d0 Mon Sep 17 00:00:00 2001 From: DmitryTsymbal <d.tsymbal@atwix.com> Date: Wed, 8 Jan 2020 12:31:06 +0200 Subject: [PATCH 008/177] Adding Removing Action Group --- .../Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml index daf3e58bca354..7753b03716371 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml @@ -21,6 +21,9 @@ <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> </before> <after> + <actionGroup ref="AdminMarketingSiteDeleteByNameActionGroup" stepKey="deleteCreatedSitemap"> + <argument name="filename" value="sitemap.xml"/> + </actionGroup> <actionGroup ref="logout" stepKey="logout"/> </after> From be953c6f53e156f505398882718499f1dd2ec6c5 Mon Sep 17 00:00:00 2001 From: DmitryTsymbal <d.tsymbal@atwix.com> Date: Thu, 9 Jan 2020 11:13:12 +0200 Subject: [PATCH 009/177] Create Newsletter Template Entity --- ...ingCreateNewsletterTemplateActionGroup.xml | 29 +++++++++ ...ingDeleteNewsletterTemplateActionGroup.xml | 17 +++++ ...nNewsletterTemplateFromGridActionGroup.xml | 16 +++++ ...reateNewsletterTemplatePageActionGroup.xml | 17 +++++ ...rchNewsletterTemplateOnGridActionGroup.xml | 23 +++++++ ...tedNewsletterTemplateInGridActionGroup.xml | 22 +++++++ ...edNewsletterTemplateMessageActionGroup.xml | 19 ++++++ .../Test/Mftf/Data/NewsletterTemplateData.xml | 1 + .../AdminNewsletterGridMainActionsSection.xml | 20 ++++++ .../AdminNewsletterMainActionsSection.xml | 15 +++++ ...nMarketingCreateNewsletterTemplateTest.xml | 65 +++++++++++++++++++ .../CreateNewsletterTemplateEntityTest.xml | 1 + 12 files changed, 245 insertions(+) create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingCreateNewsletterTemplateActionGroup.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingDeleteNewsletterTemplateActionGroup.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingOpenNewsletterTemplateFromGridActionGroup.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminNavigateToCreateNewsletterTemplatePageActionGroup.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminSearchNewsletterTemplateOnGridActionGroup.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateInGridActionGroup.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterGridMainActionsSection.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterMainActionsSection.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingCreateNewsletterTemplateActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingCreateNewsletterTemplateActionGroup.xml new file mode 100644 index 0000000000000..f7d0c59116af2 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingCreateNewsletterTemplateActionGroup.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"> + <!--Create New Template --> + <actionGroup name="AdminMarketingCreateNewsletterTemplateActionGroup"> + <arguments> + <argument name="name" type="string"/> + <argument name="subject" type="string"/> + <argument name="senderName" type="string"/> + <argument name="senderEmail" type="string"/> + <argument name="templateContent" type="string"/> + </arguments> + <!--Filling All Required Fields--> + <fillField stepKey="fillTemplateNameField" selector="{{BasicFieldNewsletterSection.templateName}}" userInput="{{name}}"/> + <fillField stepKey="fillTemplateSubjectField" selector="{{BasicFieldNewsletterSection.templateSubject}}" userInput="{{subject}}"/> + <fillField stepKey="fillSenderNameField" selector="{{BasicFieldNewsletterSection.senderName}}" userInput="{{senderName}}"/> + <fillField stepKey="fillSenderEmailField" selector="{{BasicFieldNewsletterSection.senderEmail}}" userInput="{{senderEmail}}"/> + <fillField stepKey="fillTemplateContentField" selector="{{NewsletterWYSIWYGSection.TextArea}}" userInput="{{templateContent}}"/> + <!--Saving Created Template--> + <click stepKey="clickSaveTemplateButton" selector="{{AdminNewsletterMainActionsSection.saveTemplateButton}}"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingDeleteNewsletterTemplateActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingDeleteNewsletterTemplateActionGroup.xml new file mode 100644 index 0000000000000..fd9c372388689 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingDeleteNewsletterTemplateActionGroup.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"> + <!--Delete Newsletter Template --> + <actionGroup name="AdminMarketingDeleteNewsletterTemplateActionGroup"> + <click stepKey="clickDeleteButton" selector="{{AdminNewsletterMainActionsSection.deleteTemplateButton}}"/> + <click stepKey="confirmDelete" selector="{{AdminNewsletterMainActionsSection.confirmDelete}}"/> + <waitForPageLoad stepKey="waitForPageLoading"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingOpenNewsletterTemplateFromGridActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingOpenNewsletterTemplateFromGridActionGroup.xml new file mode 100644 index 0000000000000..4e380fe63d251 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingOpenNewsletterTemplateFromGridActionGroup.xml @@ -0,0 +1,16 @@ +<?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"> + + <!--Open Newsletter Template --> + <actionGroup name="AdminMarketingOpenNewsletterTemplateFromGridActionGroup"> + <click stepKey="openTemplate" selector="{{AdminNewsletterGridMainActionsSection.searchResultFirstRow}}"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminNavigateToCreateNewsletterTemplatePageActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminNavigateToCreateNewsletterTemplatePageActionGroup.xml new file mode 100644 index 0000000000000..c743bde60172a --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminNavigateToCreateNewsletterTemplatePageActionGroup.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"> + + <!--Click "Add New Template" button--> + <actionGroup name="AdminNavigateToCreateNewsletterTemplatePageActionGroup"> + <click stepKey="clickAddNewTemplateButton" selector="{{AdminNewsletterGridMainActionsSection.add}}"/> + <waitForPageLoad stepKey="waitForNewNewsletterTemplatesPageLoaded"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminSearchNewsletterTemplateOnGridActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminSearchNewsletterTemplateOnGridActionGroup.xml new file mode 100644 index 0000000000000..ac733a5c6ef62 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminSearchNewsletterTemplateOnGridActionGroup.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"> + + <!--Search Newsletter Template On Grid --> + <actionGroup name="AdminSearchNewsletterTemplateOnGridActionGroup"> + <arguments> + <argument name="name" type="string"/> + <argument name="subject" type="string"/> + </arguments> + <fillField userInput="{{name}}" selector="{{AdminNewsletterGridMainActionsSection.name}}" stepKey="filterName"/> + <fillField userInput="{{subject}}" selector="{{AdminNewsletterGridMainActionsSection.subject}}" stepKey="filterSubject"/> + <click stepKey="clickSearchButton" selector="{{AdminNewsletterGridMainActionsSection.search}}"/> + <waitForPageLoad stepKey="waitForNewNewsletterTemplatesPageLoadedAfterFiltering"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateInGridActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateInGridActionGroup.xml new file mode 100644 index 0000000000000..495ce1b09047b --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateInGridActionGroup.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"> + + <!--Search Newsletter Template On Grid --> + <actionGroup name="AssertAdminCreatedNewsletterTemplateInGridActionGroup"> + <arguments> + <argument name="name" type="string"/> + <argument name="subject" type="string"/> + </arguments> + + <see userInput="{{name}}" selector="{{AdminNewsletterGridMainActionsSection.newsletterGrid}}" stepKey="assertTemplatename"/> + <see userInput="{{subject}}" selector="{{AdminNewsletterGridMainActionsSection.newsletterGrid}}" stepKey="assertTemplateSubject"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml new file mode 100644 index 0000000000000..3261f33894756 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AssertAdminCreatedNewsletterTemplateMessageActionGroup"> + <arguments> + <argument name="message" type="string" defaultValue="The newsletter template has been saved."/> + <argument name="messageType" type="string" defaultValue="success"/> + </arguments> + <waitForElementVisible selector="{{AdminNewsletterGridMainActionsSection.messageByType(messageType)}}" stepKey="waitForMessage"/> + <see userInput="{{message}}" selector="{{AdminNewsletterGridMainActionsSection.messageByType(messageType)}}" stepKey="verifyMessage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Data/NewsletterTemplateData.xml b/app/code/Magento/Newsletter/Test/Mftf/Data/NewsletterTemplateData.xml index fe2deed9a279f..0305ceb0efabe 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Data/NewsletterTemplateData.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Data/NewsletterTemplateData.xml @@ -13,5 +13,6 @@ <data key="subject">Test Newsletter Subject</data> <data key="senderName">Admin</data> <data key="senderEmail">admin@magento.com</data> + <data key="textAreaContent">Some Test Content</data> </entity> </entities> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterGridMainActionsSection.xml b/app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterGridMainActionsSection.xml new file mode 100644 index 0000000000000..ed1b432f798a5 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterGridMainActionsSection.xml @@ -0,0 +1,20 @@ +<?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="AdminNewsletterGridMainActionsSection"> + <element name="newsletterGrid" type="text" selector="table.data-grid"/> + <element name="add" type="button" selector=".page-actions .page-actions-buttons .add"/> + <element name="name" type="input" selector="[id$='filter_code']"/> + <element name="subject" type="input" selector="[id$='filter_subject']"/> + <element name="search" type="button" selector=".action-default.scalable.action-secondary"/> + <element name="resetFilter" type="button" selector=".action-default.scalable.action-reset.action-tertiary"/> + <element name="searchResultFirstRow" type="text" selector=".data-grid>tbody>tr"/> + <element name="messageByType" type="block" selector="#messages .message-{{messageType}}" parameterized="true"/> + </section> +</sections> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterMainActionsSection.xml b/app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterMainActionsSection.xml new file mode 100644 index 0000000000000..d824496f8e6b8 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterMainActionsSection.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="AdminNewsletterMainActionsSection"> + <element name="saveTemplateButton" type="button" selector=".page-actions-inner .page-actions-buttons .save"/> + <element name="deleteTemplateButton" type="button" selector=".page-actions-inner .page-actions-buttons .delete"/> + <element name="confirmDelete" type="button" selector=".action-primary.action-accept" timeout="10"/> + </section> +</sections> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml new file mode 100644 index 0000000000000..c5c18ad97cc11 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml @@ -0,0 +1,65 @@ +<?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="AdminMarketingCreateNewsletterTemplateTest"> + <annotations> + <features value="Newsletter"/> + <stories value="Admin Creates Newsletter Template"/> + <title value="Newsletter Template Creation"/> + <description value="Newsletter Template Successfully Created"/> + <group value="newsletter"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + </before> + <after> + <!-- Delete Created Newsletter Template --> + <actionGroup ref="AdminSearchNewsletterTemplateOnGridActionGroup" stepKey="findCreatedNewsletterTemplateInGrid"> + <argument name="name" value="{{_defaultNewsletter.name}}"/> + <argument name="subject" value="{{_defaultNewsletter.subject}}"/> + </actionGroup> + <actionGroup ref="AdminMarketingOpenNewsletterTemplateFromGridActionGroup" stepKey="openTemplate"/> + <actionGroup ref="AdminMarketingDeleteNewsletterTemplateActionGroup" stepKey="deleteTemplate"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <!--TEST BODY --> + <!-- Navigate To MARKETING > Newsletter Template --> + <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToNewsletterTemplatePage"> + <argument name="menuUiId" value="{{AdminMenuMarketing.dataUiId}}"/> + <argument name="submenuUiId" value="{{AdminMenuMarketingCommunicationsNewsletterTemplate.dataUiId}}"/> + </actionGroup> + <!-- Navigate To Create Newsletter Template Page --> + <actionGroup ref="AdminNavigateToCreateNewsletterTemplatePageActionGroup" stepKey="navigateToCreateNewsletterPage"/> + <!-- Create Newsletter Template --> + <actionGroup ref="AdminMarketingCreateNewsletterTemplateActionGroup" stepKey="updateNewsletterTemplate"> + <argument name="name" value="{{_defaultNewsletter.name}}"/> + <argument name="subject" value="{{_defaultNewsletter.subject}}"/> + <argument name="senderName" value="{{_defaultNewsletter.senderName}}"/> + <argument name="senderEmail" value="{{_defaultNewsletter.senderEmail}}"/> + <argument name="templateContent" value="{{_defaultNewsletter.textAreaContent}}"/> + </actionGroup> + <!-- Assert Success Message --> + <actionGroup ref="AssertAdminCreatedNewsletterTemplateMessageActionGroup" stepKey="seeSuccessMessage"> + <argument name="message" value="The newsletter template has been saved."/> + </actionGroup> + <!-- Find Created Newsletter On grid --> + <actionGroup ref="AdminSearchNewsletterTemplateOnGridActionGroup" stepKey="findCreatedNewsletterTemplate"> + <argument name="name" value="{{_defaultNewsletter.name}}"/> + <argument name="subject" value="{{_defaultNewsletter.subject}}"/> + </actionGroup> + <!-- Assert Created Newsletter on Grid --> + <actionGroup ref="AssertAdminCreatedNewsletterTemplateInGridActionGroup" stepKey="assertNewsletterInGrid"> + <argument name="name" value="{{_defaultNewsletter.name}}"/> + <argument name="subject" value="{{_defaultNewsletter.subject}}"/> + </actionGroup> + <!--END TEST BODY --> + </test> +</tests> diff --git a/dev/tests/functional/tests/app/Magento/Newsletter/Test/TestCase/CreateNewsletterTemplateEntityTest.xml b/dev/tests/functional/tests/app/Magento/Newsletter/Test/TestCase/CreateNewsletterTemplateEntityTest.xml index ce91de81459f1..27d2a1ba5b3f3 100644 --- a/dev/tests/functional/tests/app/Magento/Newsletter/Test/TestCase/CreateNewsletterTemplateEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Newsletter/Test/TestCase/CreateNewsletterTemplateEntityTest.xml @@ -15,6 +15,7 @@ <data name="template/data/text" xsi:type="string">Some content %isolation%</data> <constraint name="Magento\Newsletter\Test\Constraint\AssertNewsletterSuccessCreateMessage" /> <constraint name="Magento\Newsletter\Test\Constraint\AssertNewsletterInGrid" /> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> </variation> </testCase> </config> From 4bb49dc7a16adfaec25d15f88352aa477ea7b5ae Mon Sep 17 00:00:00 2001 From: DmitryTsymbal <d.tsymbal@atwix.com> Date: Thu, 9 Jan 2020 12:45:56 +0200 Subject: [PATCH 010/177] Update Newsletter Template --- ...ingCreateNewsletterTemplateActionGroup.xml | 29 +++++++ ...ingDeleteNewsletterTemplateActionGroup.xml | 17 ++++ ...nNewsletterTemplateFromGridActionGroup.xml | 16 ++++ ...reateNewsletterTemplatePageActionGroup.xml | 17 ++++ ...rchNewsletterTemplateOnGridActionGroup.xml | 23 ++++++ ...tedNewsletterTemplateInGridActionGroup.xml | 22 +++++ ...edNewsletterTemplateMessageActionGroup.xml | 19 +++++ .../Test/Mftf/Data/NewsletterTemplateData.xml | 8 ++ .../AdminNewsletterGridMainActionsSection.xml | 20 +++++ .../AdminNewsletterMainActionsSection.xml | 15 ++++ ...nMarketingNewsletterTemplateUpdateTest.xml | 82 +++++++++++++++++++ .../TestCase/UpdateNewsletterTemplateTest.xml | 1 + 12 files changed, 269 insertions(+) create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingCreateNewsletterTemplateActionGroup.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingDeleteNewsletterTemplateActionGroup.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingOpenNewsletterTemplateFromGridActionGroup.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminNavigateToCreateNewsletterTemplatePageActionGroup.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminSearchNewsletterTemplateOnGridActionGroup.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateInGridActionGroup.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterGridMainActionsSection.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterMainActionsSection.xml create mode 100644 app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingCreateNewsletterTemplateActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingCreateNewsletterTemplateActionGroup.xml new file mode 100644 index 0000000000000..f7d0c59116af2 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingCreateNewsletterTemplateActionGroup.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"> + <!--Create New Template --> + <actionGroup name="AdminMarketingCreateNewsletterTemplateActionGroup"> + <arguments> + <argument name="name" type="string"/> + <argument name="subject" type="string"/> + <argument name="senderName" type="string"/> + <argument name="senderEmail" type="string"/> + <argument name="templateContent" type="string"/> + </arguments> + <!--Filling All Required Fields--> + <fillField stepKey="fillTemplateNameField" selector="{{BasicFieldNewsletterSection.templateName}}" userInput="{{name}}"/> + <fillField stepKey="fillTemplateSubjectField" selector="{{BasicFieldNewsletterSection.templateSubject}}" userInput="{{subject}}"/> + <fillField stepKey="fillSenderNameField" selector="{{BasicFieldNewsletterSection.senderName}}" userInput="{{senderName}}"/> + <fillField stepKey="fillSenderEmailField" selector="{{BasicFieldNewsletterSection.senderEmail}}" userInput="{{senderEmail}}"/> + <fillField stepKey="fillTemplateContentField" selector="{{NewsletterWYSIWYGSection.TextArea}}" userInput="{{templateContent}}"/> + <!--Saving Created Template--> + <click stepKey="clickSaveTemplateButton" selector="{{AdminNewsletterMainActionsSection.saveTemplateButton}}"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingDeleteNewsletterTemplateActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingDeleteNewsletterTemplateActionGroup.xml new file mode 100644 index 0000000000000..fd9c372388689 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingDeleteNewsletterTemplateActionGroup.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"> + <!--Delete Newsletter Template --> + <actionGroup name="AdminMarketingDeleteNewsletterTemplateActionGroup"> + <click stepKey="clickDeleteButton" selector="{{AdminNewsletterMainActionsSection.deleteTemplateButton}}"/> + <click stepKey="confirmDelete" selector="{{AdminNewsletterMainActionsSection.confirmDelete}}"/> + <waitForPageLoad stepKey="waitForPageLoading"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingOpenNewsletterTemplateFromGridActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingOpenNewsletterTemplateFromGridActionGroup.xml new file mode 100644 index 0000000000000..4e380fe63d251 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingOpenNewsletterTemplateFromGridActionGroup.xml @@ -0,0 +1,16 @@ +<?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"> + + <!--Open Newsletter Template --> + <actionGroup name="AdminMarketingOpenNewsletterTemplateFromGridActionGroup"> + <click stepKey="openTemplate" selector="{{AdminNewsletterGridMainActionsSection.searchResultFirstRow}}"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminNavigateToCreateNewsletterTemplatePageActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminNavigateToCreateNewsletterTemplatePageActionGroup.xml new file mode 100644 index 0000000000000..c743bde60172a --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminNavigateToCreateNewsletterTemplatePageActionGroup.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"> + + <!--Click "Add New Template" button--> + <actionGroup name="AdminNavigateToCreateNewsletterTemplatePageActionGroup"> + <click stepKey="clickAddNewTemplateButton" selector="{{AdminNewsletterGridMainActionsSection.add}}"/> + <waitForPageLoad stepKey="waitForNewNewsletterTemplatesPageLoaded"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminSearchNewsletterTemplateOnGridActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminSearchNewsletterTemplateOnGridActionGroup.xml new file mode 100644 index 0000000000000..ac733a5c6ef62 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminSearchNewsletterTemplateOnGridActionGroup.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"> + + <!--Search Newsletter Template On Grid --> + <actionGroup name="AdminSearchNewsletterTemplateOnGridActionGroup"> + <arguments> + <argument name="name" type="string"/> + <argument name="subject" type="string"/> + </arguments> + <fillField userInput="{{name}}" selector="{{AdminNewsletterGridMainActionsSection.name}}" stepKey="filterName"/> + <fillField userInput="{{subject}}" selector="{{AdminNewsletterGridMainActionsSection.subject}}" stepKey="filterSubject"/> + <click stepKey="clickSearchButton" selector="{{AdminNewsletterGridMainActionsSection.search}}"/> + <waitForPageLoad stepKey="waitForNewNewsletterTemplatesPageLoadedAfterFiltering"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateInGridActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateInGridActionGroup.xml new file mode 100644 index 0000000000000..495ce1b09047b --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateInGridActionGroup.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"> + + <!--Search Newsletter Template On Grid --> + <actionGroup name="AssertAdminCreatedNewsletterTemplateInGridActionGroup"> + <arguments> + <argument name="name" type="string"/> + <argument name="subject" type="string"/> + </arguments> + + <see userInput="{{name}}" selector="{{AdminNewsletterGridMainActionsSection.newsletterGrid}}" stepKey="assertTemplatename"/> + <see userInput="{{subject}}" selector="{{AdminNewsletterGridMainActionsSection.newsletterGrid}}" stepKey="assertTemplateSubject"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml new file mode 100644 index 0000000000000..3261f33894756 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AssertAdminCreatedNewsletterTemplateMessageActionGroup"> + <arguments> + <argument name="message" type="string" defaultValue="The newsletter template has been saved."/> + <argument name="messageType" type="string" defaultValue="success"/> + </arguments> + <waitForElementVisible selector="{{AdminNewsletterGridMainActionsSection.messageByType(messageType)}}" stepKey="waitForMessage"/> + <see userInput="{{message}}" selector="{{AdminNewsletterGridMainActionsSection.messageByType(messageType)}}" stepKey="verifyMessage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Data/NewsletterTemplateData.xml b/app/code/Magento/Newsletter/Test/Mftf/Data/NewsletterTemplateData.xml index fe2deed9a279f..8d3e87b17513d 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Data/NewsletterTemplateData.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Data/NewsletterTemplateData.xml @@ -13,5 +13,13 @@ <data key="subject">Test Newsletter Subject</data> <data key="senderName">Admin</data> <data key="senderEmail">admin@magento.com</data> + <data key="textAreaContent">Some Test Content</data> + </entity> + <entity name="updatedNewsletter" type="cms_page"> + <data key="name" unique="suffix">Updated Newsletter Template</data> + <data key="subject">Updated Newsletter Subject</data> + <data key="senderName">Admin</data> + <data key="senderEmail">admin@magento.com</data> + <data key="textAreaContent">Some Updated Test Content</data> </entity> </entities> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterGridMainActionsSection.xml b/app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterGridMainActionsSection.xml new file mode 100644 index 0000000000000..ed1b432f798a5 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterGridMainActionsSection.xml @@ -0,0 +1,20 @@ +<?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="AdminNewsletterGridMainActionsSection"> + <element name="newsletterGrid" type="text" selector="table.data-grid"/> + <element name="add" type="button" selector=".page-actions .page-actions-buttons .add"/> + <element name="name" type="input" selector="[id$='filter_code']"/> + <element name="subject" type="input" selector="[id$='filter_subject']"/> + <element name="search" type="button" selector=".action-default.scalable.action-secondary"/> + <element name="resetFilter" type="button" selector=".action-default.scalable.action-reset.action-tertiary"/> + <element name="searchResultFirstRow" type="text" selector=".data-grid>tbody>tr"/> + <element name="messageByType" type="block" selector="#messages .message-{{messageType}}" parameterized="true"/> + </section> +</sections> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterMainActionsSection.xml b/app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterMainActionsSection.xml new file mode 100644 index 0000000000000..d824496f8e6b8 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/Section/AdminNewsletterMainActionsSection.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="AdminNewsletterMainActionsSection"> + <element name="saveTemplateButton" type="button" selector=".page-actions-inner .page-actions-buttons .save"/> + <element name="deleteTemplateButton" type="button" selector=".page-actions-inner .page-actions-buttons .delete"/> + <element name="confirmDelete" type="button" selector=".action-primary.action-accept" timeout="10"/> + </section> +</sections> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml new file mode 100644 index 0000000000000..1e7f6b7524d79 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml @@ -0,0 +1,82 @@ +<?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="AdminMarketingNewsletterTemplateUpdate"> + <annotations> + <features value="Newsletter"/> + <stories value="Newsletter Updating"/> + <title value="Newsletter Updating Test"/> + <description value="Admin should be able update created Newsletter Template"/> + <group value="reports"/> + <group value="mtf_migrated"/> + </annotations> + + <before> + <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + <!-- Navigate To MARKETING > Newsletter Template --> + <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToNewsletterTemplatePage"> + <argument name="menuUiId" value="{{AdminMenuMarketing.dataUiId}}"/> + <argument name="submenuUiId" value="{{AdminMenuMarketingCommunicationsNewsletterTemplate.dataUiId}}"/> + </actionGroup> + <!-- Navigate To Create Newsletter Template Page --> + <actionGroup ref="AdminNavigateToCreateNewsletterTemplatePageActionGroup" stepKey="navigateTiCreateNewsletterTemplatePage"/> + <!-- Create Newsletter Template --> + <actionGroup ref="AdminMarketingCreateNewsletterTemplateActionGroup" stepKey="createNewsletterTemplate"> + <argument name="name" value="{{_defaultNewsletter.name}}"/> + <argument name="subject" value="{{_defaultNewsletter.subject}}"/> + <argument name="senderName" value="{{_defaultNewsletter.senderName}}"/> + <argument name="senderEmail" value="{{_defaultNewsletter.senderEmail}}"/> + <argument name="templateContent" value="{{_defaultNewsletter.textAreaContent}}"/> + </actionGroup> + <!-- Search Created Newsletter Template on Grid --> + <actionGroup ref="AdminSearchNewsletterTemplateOnGridActionGroup" stepKey="findCreatedNewsletterTemplate"> + <argument name="name" value="{{_defaultNewsletter.name}}"/> + <argument name="subject" value="{{_defaultNewsletter.subject}}"/> + </actionGroup> + <!-- Open Created Newsletter Template --> + <actionGroup ref="AdminMarketingOpenNewsletterTemplateFromGridActionGroup" stepKey="openCreatedNewsletterTemplate"/> + </before> + + <after> + <!-- Delete Created Newsletter Template --> + <actionGroup ref="AdminSearchNewsletterTemplateOnGridActionGroup" stepKey="findCreatedNewsletterTemplateInGrid"> + <argument name="name" value="{{updatedNewsletter.name}}"/> + <argument name="subject" value="{{updatedNewsletter.subject}}"/> + </actionGroup> + <actionGroup ref="AdminMarketingOpenNewsletterTemplateFromGridActionGroup" stepKey="openTemplate"/> + <actionGroup ref="AdminMarketingDeleteNewsletterTemplateActionGroup" stepKey="deleteTemplate"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <!-- TEST BODY --> + <!-- Update Created Newsletter Template --> + <actionGroup ref="AdminMarketingCreateNewsletterTemplateActionGroup" stepKey="updateNewsletterTemplate"> + <argument name="name" value="{{updatedNewsletter.name}}"/> + <argument name="subject" value="{{updatedNewsletter.subject}}"/> + <argument name="senderName" value="{{updatedNewsletter.senderName}}"/> + <argument name="senderEmail" value="{{updatedNewsletter.senderEmail}}"/> + <argument name="templateContent" value="{{updatedNewsletter.textAreaContent}}"/> + </actionGroup> + <!-- Assert Success Message --> + <actionGroup ref="AssertAdminCreatedNewsletterTemplateMessageActionGroup" stepKey="assertSuccessMessage"> + <argument name="message" value="The newsletter template has been saved."/> + </actionGroup> + <!-- Find Created Newsletter on Grid --> + <actionGroup ref="AdminSearchNewsletterTemplateOnGridActionGroup" stepKey="findCreatedNewsletterTemplate"> + <argument name="name" value="Updated Newsletter Template"/> + <argument name="subject" value="Updated Newsletter Subject"/> + </actionGroup> + <!-- Assert Created Newsletter on Grid --> + <actionGroup ref="AssertAdminCreatedNewsletterTemplateInGridActionGroup" stepKey="assertNewsletterInGrid"> + <argument name="name" value="{{updatedNewsletter.name}}"/> + <argument name="subject" value="{{updatedNewsletter.subject}}"/> + </actionGroup> + <!-- END TEST BODY --> + </test> +</tests> diff --git a/dev/tests/functional/tests/app/Magento/Newsletter/Test/TestCase/UpdateNewsletterTemplateTest.xml b/dev/tests/functional/tests/app/Magento/Newsletter/Test/TestCase/UpdateNewsletterTemplateTest.xml index 456d9a91b1171..b6b40f43cc3e3 100644 --- a/dev/tests/functional/tests/app/Magento/Newsletter/Test/TestCase/UpdateNewsletterTemplateTest.xml +++ b/dev/tests/functional/tests/app/Magento/Newsletter/Test/TestCase/UpdateNewsletterTemplateTest.xml @@ -16,6 +16,7 @@ <constraint name="Magento\Newsletter\Test\Constraint\AssertNewsletterSuccessCreateMessage" /> <constraint name="Magento\Newsletter\Test\Constraint\AssertNewsletterInGrid" /> <constraint name="Magento\Newsletter\Test\Constraint\AssertNewsletterForm" /> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> </variation> </testCase> </config> From 17ca06023089645d3d130a5fb4859fd2d4ec0c34 Mon Sep 17 00:00:00 2001 From: DmitryTsymbal <d.tsymbal@atwix.com> Date: Thu, 9 Jan 2020 16:16:32 +0200 Subject: [PATCH 011/177] Delete Sitemap Entity --- ...AdminMarketingSitemapSearchActionGroup.xml | 19 +++++++ ...sertAdminSitemapIsNotInGridActionGroup.xml | 17 +++++++ .../Sitemap/Test/Mftf/Data/SitemapData.xml | 4 ++ .../AdminMarketingDeleteSitemapEntityTest.xml | 49 +++++++++++++++++++ .../Test/TestCase/DeleteSitemapEntityTest.xml | 2 +- 5 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingSitemapSearchActionGroup.xml create mode 100644 app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapIsNotInGridActionGroup.xml create mode 100644 app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingDeleteSitemapEntityTest.xml diff --git a/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingSitemapSearchActionGroup.xml b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingSitemapSearchActionGroup.xml new file mode 100644 index 0000000000000..6784cf51848b3 --- /dev/null +++ b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AdminMarketingSitemapSearchActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminMarketingSitemapSearchActionGroup"> + <arguments> + <argument name="filename" type="string"/> + </arguments> + <click selector="{{AdminMarketingSiteMapGridSection.resetButton}}" stepKey="resetSearchFilter"/> + <fillField selector="{{AdminMarketingSiteMapGridSection.fileNameTextField}}" userInput="{{filename}}" stepKey="fillFileNameField"/> + <click selector="{{AdminMarketingSiteMapGridSection.searchButton}}" stepKey="clickSearchButton"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapIsNotInGridActionGroup.xml b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapIsNotInGridActionGroup.xml new file mode 100644 index 0000000000000..c8effb45eda7a --- /dev/null +++ b/app/code/Magento/Sitemap/Test/Mftf/ActionGroup/AssertAdminSitemapIsNotInGridActionGroup.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="AssertAdminSitemapIsNotInGridActionGroup"> + <arguments> + <argument name="filename" type="string"/> + </arguments> + <dontSee userInput="{{filename}}" selector="{{AdminMarketingSiteMapGridSection.firstSearchResult}}" stepKey="verifyThatCorrectStoreGroupFound"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Data/SitemapData.xml b/app/code/Magento/Sitemap/Test/Mftf/Data/SitemapData.xml index 0b5d5d3dcdefe..b952f829b1d96 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Data/SitemapData.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Data/SitemapData.xml @@ -12,4 +12,8 @@ <data key="filename">sitemap.xml</data> <data key="path">/</data> </entity> + <entity name="UniqueSitemapName"> + <data key="filename" unique="prefix">sitemap.xml</data> + <data key="path">/</data> + </entity> </entities> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingDeleteSitemapEntityTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingDeleteSitemapEntityTest.xml new file mode 100644 index 0000000000000..3ba13bb76b178 --- /dev/null +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingDeleteSitemapEntityTest.xml @@ -0,0 +1,49 @@ +<?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="AdminMarketingDeleteSitemapEntityTest"> + <annotations> + <features value="Sitemap"/> + <stories value="Admin Deletes Sitemap Entity Test"/> + <title value="Sitemap Deleting Test"/> + <description value="Admin Should Delete Sitemap Entity"/> + <group value="sitemap"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + <!--Navigate to Marketing->Sitemap Page --> + <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToMarketingSiteMapPage"> + <argument name="menuUiId" value="{{AdminMenuMarketing.dataUiId}}"/> + <argument name="submenuUiId" value="{{AdminMenuSEOAndSearchSiteMap.dataUiId}}"/> + </actionGroup> + <!-- Navigate To New Sitemap Page --> + <actionGroup ref="AdminMarketingSiteMapNavigateNewActionGroup" stepKey="navigateToNewSitemapPage"/> + <!-- Create Sitemap Entity --> + <actionGroup ref="AdminMarketingSiteMapFillFormActionGroup" stepKey="createSitemap"> + <argument name="sitemap" value="UniqueSitemapName"/> + </actionGroup> + </before> + <after> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <actionGroup ref="AdminMarketingSiteDeleteByNameActionGroup" stepKey="deleteCreatedSitemap"> + <argument name="filename" value="{{UniqueSitemapName.filename}}"/> + </actionGroup> + <actionGroup ref="AssertSiteMapDeleteSuccessActionGroup" stepKey="assertSuccessMessage"/> + <actionGroup ref="AdminMarketingSitemapSearchActionGroup" stepKey="searchDeletedSitemap"> + <argument name="filename" value="{{UniqueSitemapName.filename}}"/> + </actionGroup> + <actionGroup ref="AssertAdminSitemapIsNotInGridActionGroup" stepKey="dontSeeEntity"> + <argument name="filename" value="{{UniqueSitemapName.filename}}"/> + </actionGroup> + </test> +</tests> diff --git a/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/DeleteSitemapEntityTest.xml b/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/DeleteSitemapEntityTest.xml index a520fa573e1b9..eeb000bd6a803 100644 --- a/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/DeleteSitemapEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Sitemap/Test/TestCase/DeleteSitemapEntityTest.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\Sitemap\Test\TestCase\DeleteSitemapEntityTest" summary="Delete Sitemap Entity" ticketId="MAGETWO-23296"> <variation name="DeleteSitemapEntityTestVariation1"> - <data name="tag" xsi:type="string">severity:S2</data> + <data name="tag" xsi:type="string">severity:S2,mftf_migrated:yes</data> <data name="sitemap/dataset" xsi:type="string">default</data> <constraint name="Magento\Sitemap\Test\Constraint\AssertSitemapSuccessDeleteMessage" /> <constraint name="Magento\Sitemap\Test\Constraint\AssertSitemapNotInGrid" /> From 7b4da97ba6dc502708c4851571c872e9ade9125e Mon Sep 17 00:00:00 2001 From: DmitryTsymbal <d.tsymbal@atwix.com> Date: Thu, 9 Jan 2020 17:46:43 +0200 Subject: [PATCH 012/177] Refactoring --- ...edNewsletterTemplateMessageActionGroup.xml | 19 ------------------- ...nMarketingCreateNewsletterTemplateTest.xml | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-) delete mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml deleted file mode 100644 index 3261f33894756..0000000000000 --- a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml +++ /dev/null @@ -1,19 +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="AssertAdminCreatedNewsletterTemplateMessageActionGroup"> - <arguments> - <argument name="message" type="string" defaultValue="The newsletter template has been saved."/> - <argument name="messageType" type="string" defaultValue="success"/> - </arguments> - <waitForElementVisible selector="{{AdminNewsletterGridMainActionsSection.messageByType(messageType)}}" stepKey="waitForMessage"/> - <see userInput="{{message}}" selector="{{AdminNewsletterGridMainActionsSection.messageByType(messageType)}}" stepKey="verifyMessage"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml index c5c18ad97cc11..2e6947e51df10 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml @@ -47,7 +47,7 @@ <argument name="templateContent" value="{{_defaultNewsletter.textAreaContent}}"/> </actionGroup> <!-- Assert Success Message --> - <actionGroup ref="AssertAdminCreatedNewsletterTemplateMessageActionGroup" stepKey="seeSuccessMessage"> + <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="seeSuccessMessage"> <argument name="message" value="The newsletter template has been saved."/> </actionGroup> <!-- Find Created Newsletter On grid --> From fda71af352ac2bfd168fd2ce5cd8488c21843b75 Mon Sep 17 00:00:00 2001 From: Matheus Gontijo <matheus@matheusgontijo.com> Date: Tue, 14 Jan 2020 08:25:23 -0300 Subject: [PATCH 013/177] updating storeId to null --- app/code/Magento/Customer/Model/EmailNotification.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/Model/EmailNotification.php b/app/code/Magento/Customer/Model/EmailNotification.php index 068525344d3bb..5a54d92ddfef2 100644 --- a/app/code/Magento/Customer/Model/EmailNotification.php +++ b/app/code/Magento/Customer/Model/EmailNotification.php @@ -362,7 +362,7 @@ public function passwordResetConfirmation(CustomerInterface $customer) * @param CustomerInterface $customer * @param string $type * @param string $backUrl - * @param int $storeId + * @param int|null $storeId * @param string $sendemailStoreId * @return void * @throws LocalizedException @@ -371,7 +371,7 @@ public function newAccount( CustomerInterface $customer, $type = self::NEW_ACCOUNT_EMAIL_REGISTERED, $backUrl = '', - $storeId = 0, + $storeId = null, $sendemailStoreId = null ) { $types = self::TEMPLATE_TYPES; From b72972653fe19f852ec696f7f90292cf89ac840e Mon Sep 17 00:00:00 2001 From: DmitryTsymbal <d.tsymbal@atwix.com> Date: Wed, 15 Jan 2020 15:27:28 +0200 Subject: [PATCH 014/177] Adding Form Assertion --- ...AdminNewsletterTemplateFormActionGroup.xml | 26 +++++++++++++++++++ ...nMarketingNewsletterTemplateUpdateTest.xml | 24 ++++++++++++++--- 2 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminNewsletterTemplateFormActionGroup.xml diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminNewsletterTemplateFormActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminNewsletterTemplateFormActionGroup.xml new file mode 100644 index 0000000000000..a5a3bd217d135 --- /dev/null +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminNewsletterTemplateFormActionGroup.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AssertAdminNewsletterTemplateFormActionGroup"> + <arguments> + <argument name="name" type="string"/> + <argument name="subject" type="string"/> + <argument name="senderName" type="string"/> + <argument name="senderEmail" type="string"/> + <argument name="templateContent" type="string"/> + </arguments> + + <seeInField stepKey="seeTemplateNameField" userInput="{{name}}" selector="{{BasicFieldNewsletterSection.templateName}}"/> + <seeInField stepKey="seeTemplateSubjectField" userInput="{{subject}}" selector="{{BasicFieldNewsletterSection.templateSubject}}"/> + <seeInField stepKey="seeTemplateSenderNameField" userInput="{{senderName}}" selector="{{BasicFieldNewsletterSection.senderName}}"/> + <seeInField stepKey="seeTemplateSenderEmailField" userInput="{{senderEmail}}" selector="{{BasicFieldNewsletterSection.senderEmail}}"/> + <seeInField stepKey="seeTemplateContentField" userInput="{{templateContent}}" selector="{{NewsletterWYSIWYGSection.TextArea}}"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml index 1e7f6b7524d79..b236dfee4ab6b 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml @@ -43,9 +43,12 @@ <!-- Open Created Newsletter Template --> <actionGroup ref="AdminMarketingOpenNewsletterTemplateFromGridActionGroup" stepKey="openCreatedNewsletterTemplate"/> </before> - <after> - <!-- Delete Created Newsletter Template --> + <!-- Delete Updated Newsletter Template --> + <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToNewsletterGridPage"> + <argument name="menuUiId" value="{{AdminMenuMarketing.dataUiId}}"/> + <argument name="submenuUiId" value="{{AdminMenuMarketingCommunicationsNewsletterTemplate.dataUiId}}"/> + </actionGroup> <actionGroup ref="AdminSearchNewsletterTemplateOnGridActionGroup" stepKey="findCreatedNewsletterTemplateInGrid"> <argument name="name" value="{{updatedNewsletter.name}}"/> <argument name="subject" value="{{updatedNewsletter.subject}}"/> @@ -69,14 +72,27 @@ </actionGroup> <!-- Find Created Newsletter on Grid --> <actionGroup ref="AdminSearchNewsletterTemplateOnGridActionGroup" stepKey="findCreatedNewsletterTemplate"> - <argument name="name" value="Updated Newsletter Template"/> - <argument name="subject" value="Updated Newsletter Subject"/> + <argument name="name" value="{{updatedNewsletter.name}}"/> + <argument name="subject" value="{{updatedNewsletter.subject}}"/> </actionGroup> <!-- Assert Created Newsletter on Grid --> <actionGroup ref="AssertAdminCreatedNewsletterTemplateInGridActionGroup" stepKey="assertNewsletterInGrid"> <argument name="name" value="{{updatedNewsletter.name}}"/> <argument name="subject" value="{{updatedNewsletter.subject}}"/> </actionGroup> + <!-- Assert Newsletter Form --> + <actionGroup ref="AdminSearchNewsletterTemplateOnGridActionGroup" stepKey="findUpdatedNewsletterTemplate"> + <argument name="name" value="Updated Newsletter Template"/> + <argument name="subject" value="Updated Newsletter Subject"/> + </actionGroup> + <actionGroup ref="AdminMarketingOpenNewsletterTemplateFromGridActionGroup" stepKey="openTemplate"/> + <actionGroup ref="AssertAdminNewsletterTemplateFormActionGroup" stepKey="assertNewsletterForm"> + <argument name="name" value="{{updatedNewsletter.name}}"/> + <argument name="subject" value="{{updatedNewsletter.subject}}"/> + <argument name="senderName" value="{{updatedNewsletter.senderName}}"/> + <argument name="senderEmail" value="{{updatedNewsletter.senderEmail}}"/> + <argument name="templateContent" value="{{updatedNewsletter.textAreaContent}}"/> + </actionGroup> <!-- END TEST BODY --> </test> </tests> From ce5f9340e4a0f98c93d4501db9076aaae04a9e38 Mon Sep 17 00:00:00 2001 From: DmitryTsymbal <d.tsymbal@atwix.com> Date: Fri, 17 Jan 2020 17:11:47 +0200 Subject: [PATCH 015/177] Re-Authorize Tokens Integration Entity --- ...wResourcesAccessIntegrationActionGroup.xml | 16 ++++ ...nClickReauthoriseLinkOnGridActionGroup.xml | 15 ++++ ...tegrationOpenExistingEntityActionGroup.xml | 15 ++++ ...nIntegrationSaveAndActivateActionGroup.xml | 16 ++++ ...ationTokensAfterReauthorizeActionGroup.xml | 24 ++++++ .../AdminIntegrationDetailsSection.xml | 17 ++++ .../Section/AdminIntegrationsGridSection.xml | 1 + .../AdminNewIntegrationFormSection.xml | 2 + .../Section/AdminNewIntegrationSection.xml | 6 ++ ...ReAuthorizeTokensIntegrationEntityTest.xml | 77 +++++++++++++++++++ ...ReAuthorizeTokensIntegrationEntityTest.xml | 1 + 11 files changed, 190 insertions(+) create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminAllowResourcesAccessIntegrationActionGroup.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationClickReauthoriseLinkOnGridActionGroup.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationOpenExistingEntityActionGroup.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationSaveAndActivateActionGroup.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminIntegrationTokensAfterReauthorizeActionGroup.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationDetailsSection.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminAllowResourcesAccessIntegrationActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminAllowResourcesAccessIntegrationActionGroup.xml new file mode 100644 index 0000000000000..272cf130b8aec --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminAllowResourcesAccessIntegrationActionGroup.xml @@ -0,0 +1,16 @@ +<?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="AdminAllowResourcesAccessIntegrationActionGroup"> + <click stepKey="clickAllowButton" selector="{{AdminNewIntegrationSection.allow}}"/> + <waitForPageLoad stepKey="waitForLoading"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationClickReauthoriseLinkOnGridActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationClickReauthoriseLinkOnGridActionGroup.xml new file mode 100644 index 0000000000000..053dfb11ce319 --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationClickReauthoriseLinkOnGridActionGroup.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"> + <actionGroup name="AdminIntegrationClickReauthoriseLinkOnGridActionGroup"> + <click stepKey="clickReauthoriseLink" selector="{{AdminIntegrationsGridSection.activate}}"/> + <waitForPageLoad stepKey="waitForPopupLoading"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationOpenExistingEntityActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationOpenExistingEntityActionGroup.xml new file mode 100644 index 0000000000000..8d9af21c63ef6 --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationOpenExistingEntityActionGroup.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"> + + <actionGroup name="AdminIntegrationOpenExistingEntityActionGroup"> + <click stepKey="clickEditIcon" selector="{{AdminIntegrationsGridSection.edit}}"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationSaveAndActivateActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationSaveAndActivateActionGroup.xml new file mode 100644 index 0000000000000..d5e0cad99181a --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationSaveAndActivateActionGroup.xml @@ -0,0 +1,16 @@ +<?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="AdminIntegrationSaveAndActivateActionGroup"> + <click stepKey="clickIntegrationToggle" selector="{{AdminNewIntegrationFormSection.integrationToggle}}"/> + <waitForElementVisible selector="{{AdminNewIntegrationFormSection.saveAndActivate}}" stepKey="waitForSaveAndActivateButton"/> + <click stepKey="clickSaveAndActivateButton" selector="{{AdminNewIntegrationFormSection.saveAndActivate}}"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminIntegrationTokensAfterReauthorizeActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminIntegrationTokensAfterReauthorizeActionGroup.xml new file mode 100644 index 0000000000000..6976ebe9411c8 --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminIntegrationTokensAfterReauthorizeActionGroup.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"> + + <actionGroup name="AssertAdminIntegrationTokensAfterReauthoriseActionGroup"> + <arguments> + <argument name="consumerKey" type="string"/> + <argument name="consumerSecret" type="string"/> + <argument name="accessToken" type="string"/> + <argument name="accessTokenSecret" type="string"/> + </arguments> + <seeInField stepKey="seeConsumerKey" selector="{{AdminIntegrationDetailsSection.consumerKey}}" userInput="{{consumerKey}}"/> + <seeInField stepKey="seeConsumerSecret" selector="{{AdminIntegrationDetailsSection.consumerSecret}}" userInput="{{consumerSecret}}"/> + <seeInField stepKey="seeAccessToken" selector="{{AdminIntegrationDetailsSection.accessToken}}" userInput="{{accessToken}}"/> + <seeInField stepKey="seeAccessTokenSecret" selector="{{AdminIntegrationDetailsSection.accessTokenSecret}}" userInput="{{accessTokenSecret}}"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationDetailsSection.xml b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationDetailsSection.xml new file mode 100644 index 0000000000000..8b9776f0bd26c --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationDetailsSection.xml @@ -0,0 +1,17 @@ +<?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="AdminIntegrationDetailsSection"> + <element name="consumerKey" type="input" selector=".admin__field-control.control #integration_properties_consumer_key"/> + <element name="consumerSecret" type="input" selector=".admin__field-control.control #integration_properties_consumer_secret"/> + <element name="accessToken" type="input" selector=".admin__field-control.control #integration_properties_token"/> + <element name="accessTokenSecret" type="input" selector=".admin__field-control.control #integration_properties_token_secret"/> + </section> +</sections> diff --git a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsGridSection.xml b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsGridSection.xml index ae601542f3b37..7326bef963da1 100644 --- a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsGridSection.xml +++ b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsGridSection.xml @@ -17,5 +17,6 @@ <element name="submitButton" type="button" selector=".action-primary.action-accept" timeout="30"/> <element name="rowByIndex" type="text" selector="tr[data-role='row']:nth-of-type({{var1}})" parameterized="true" timeout="30"/> <element name="edit" type="button" selector=".data-grid .edit"/> + <element name="activate" type="button" selector="#integrationGrid_table>tbody>tr:nth-child(1)>td.col-activate>a"/> </section> </sections> diff --git a/app/code/Magento/Integration/Test/Mftf/Section/AdminNewIntegrationFormSection.xml b/app/code/Magento/Integration/Test/Mftf/Section/AdminNewIntegrationFormSection.xml index edb9e5dd5eb51..8a83f95e7cbba 100644 --- a/app/code/Magento/Integration/Test/Mftf/Section/AdminNewIntegrationFormSection.xml +++ b/app/code/Magento/Integration/Test/Mftf/Section/AdminNewIntegrationFormSection.xml @@ -18,5 +18,7 @@ <element name="resourceTree" type="block" selector="[data-ui-id='integration-edit-tabs-tab-content-api-section'] [data-role='resource-tree']"/> <element name="save" type="button" selector="#save-split-button-button"/> + <element name="integrationToggle" type="button" selector=".page-actions-buttons .action-toggle.primary"/> + <element name="saveAndActivate" type="button" selector="#save-split-button-activate"/> </section> </sections> diff --git a/app/code/Magento/Integration/Test/Mftf/Section/AdminNewIntegrationSection.xml b/app/code/Magento/Integration/Test/Mftf/Section/AdminNewIntegrationSection.xml index 3e7214784c2b5..5f2d1a6b8a8eb 100644 --- a/app/code/Magento/Integration/Test/Mftf/Section/AdminNewIntegrationSection.xml +++ b/app/code/Magento/Integration/Test/Mftf/Section/AdminNewIntegrationSection.xml @@ -14,5 +14,11 @@ <element name="endpoint" type="input" selector="#integration_properties_endpoint"/> <element name="linkUrl" type="input" selector="#integration_properties_identity_link_url"/> <element name="save" type="button" selector=".page-actions-buttons .save"/> + <element name="allow" type="button" selector=".page-actions-buttons .action-primary"/> + <element name="resourcesPopup" type="block" selector="#modal-content-17 #integration-popup-container"/> + <element name="consumerKey" type="input" selector=".admin__field-control.control #integration_token_consumer_key"/> + <element name="consumerSecret" type="input" selector=".admin__field-control.control #integration_token_consumer_secret"/> + <element name="accessToken" type="input" selector=".admin__field-control.control #integration_token_token"/> + <element name="accessTokenSecret" type="input" selector=".admin__field-control.control #integration_token_token_secret"/> </section> </sections> diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml new file mode 100644 index 0000000000000..2ba04757eb430 --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml @@ -0,0 +1,77 @@ +<?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="AdminReAuthorizeTokensIntegrationEntityTest"> + <annotations> + <features value="Integration"/> + <stories value="System Integration"/> + <title value="Reauthorise Integration's Tokens"/> + <description value="ReAuthorising Tokens For Created Integration"/> + <group value="integration"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <!-- Login As Admin --> + <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + <!-- Navigate To Integrations Page --> + <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToIntegrationsPage"> + <argument name="menuUiId" value="{{AdminMenuSystem.dataUiId}}"/> + <argument name="submenuUiId" value="{{AdminMenuSystemExtensionsIntegrations.dataUiId}}"/> + </actionGroup> + <!-- Click the "Add New Integration" button --> + <actionGroup ref="AdminNavigateToCreateIntegrationPageActionGroup" stepKey="clickAddNewIntegrationButton"/> + <!-- Create New Integration --> + <actionGroup ref="AdminFillIntegrationFormActionGroup" stepKey="createIntegration"> + <argument name="integration" value="defaultIntegrationData"/> + <argument name="password" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/> + </actionGroup> + <!-- Click Save And Activate Button --> + <actionGroup ref="AdminIntegrationSaveAndActivateActionGroup" stepKey="clickSaveAndActivateButton"/> + <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="allowAccess"/> + <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="clickDoneButton"/> + </before> + <after> + <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="returnToIntegrationsPage"> + <argument name="menuUiId" value="{{AdminMenuSystem.dataUiId}}"/> + <argument name="submenuUiId" value="{{AdminMenuSystemExtensionsIntegrations.dataUiId}}"/> + </actionGroup> + <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="searchForReAuthorizedIntegration"> + <argument name="name" value="{{defaultIntegrationData.name}}"/> + </actionGroup> + <actionGroup ref="AdminDeleteIntegrationEntityActionGroup" stepKey="deleteCreatedIntegration"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- TEST BODY --> + <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="findCreatedIntegration"> + <argument name="name" value="{{defaultIntegrationData.name}}"/> + </actionGroup> + <actionGroup ref="AdminIntegrationClickReauthoriseLinkOnGridActionGroup" stepKey="clickReauthoriseLink"/> + <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="clickReauthoriseButton"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.consumerKey}}" stepKey="grabConsumerKey"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.consumerSecret}}" stepKey="grabConsumerSecret"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.accessToken}}" stepKey="grabAccessToken"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.accessTokenSecret}}" stepKey="grabAccessTokenSecret"/> + <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="finishTheProcess"/> + <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="seeSuccessMessage"> + <argument name="message" value="The integration '{{defaultIntegrationData.name}}' has been re-authorized."/> + </actionGroup> + <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="findReAuthorizedIntegration"> + <argument name="name" value="{{defaultIntegrationData.name}}"/> + </actionGroup> + <actionGroup ref="AdminIntegrationOpenExistingEntityActionGroup" stepKey="openIntegrationEntity"/> + <actionGroup ref="AssertAdminIntegrationTokensAfterReauthoriseActionGroup" stepKey="assertTokens"> + <argument name="consumerKey" value="{$grabConsumerKey}"/> + <argument name="consumerSecret" value="{$grabConsumerSecret}"/> + <argument name="accessToken" value="{$grabAccessToken}"/> + <argument name="accessTokenSecret" value="{$grabAccessTokenSecret}"/> + </actionGroup> + </test> +</tests> diff --git a/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/ReAuthorizeTokensIntegrationEntityTest.xml b/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/ReAuthorizeTokensIntegrationEntityTest.xml index 739aaf3b1e1c3..bd090ad18a26f 100644 --- a/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/ReAuthorizeTokensIntegrationEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/ReAuthorizeTokensIntegrationEntityTest.xml @@ -9,6 +9,7 @@ <testCase name="Magento\Integration\Test\TestCase\ReAuthorizeTokensIntegrationEntityTest" summary="Re-Authorize Tokens for the Integration" ticketId="MAGETWO-29648"> <variation name="ReAuthorizeTokensIntegrationEntityTestVariation1"> <data name="description" xsi:type="string">Re-authorize integration</data> + <data name="tag" xsi:type="string">mftf_migrated:yes</data> <constraint name="Magento\Integration\Test\Constraint\AssertIntegrationSuccessReauthorizeMessage" /> <constraint name="Magento\Integration\Test\Constraint\AssertIntegrationTokensAfterReauthorize" /> </variation> From dbc1fce4c26c8c741850b21835d7387ed50a67b5 Mon Sep 17 00:00:00 2001 From: DmitryTsymbal <d.tsymbal@atwix.com> Date: Wed, 22 Jan 2020 15:22:04 +0200 Subject: [PATCH 016/177] Adding Tokens Comparing After Rauthorizing --- ...ationTokensAfterReauthorizeActionGroup.xml | 24 ----------------- ...ReAuthorizeTokensIntegrationEntityTest.xml | 26 ++++++++++--------- 2 files changed, 14 insertions(+), 36 deletions(-) delete mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminIntegrationTokensAfterReauthorizeActionGroup.xml diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminIntegrationTokensAfterReauthorizeActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminIntegrationTokensAfterReauthorizeActionGroup.xml deleted file mode 100644 index 6976ebe9411c8..0000000000000 --- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminIntegrationTokensAfterReauthorizeActionGroup.xml +++ /dev/null @@ -1,24 +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="AssertAdminIntegrationTokensAfterReauthoriseActionGroup"> - <arguments> - <argument name="consumerKey" type="string"/> - <argument name="consumerSecret" type="string"/> - <argument name="accessToken" type="string"/> - <argument name="accessTokenSecret" type="string"/> - </arguments> - <seeInField stepKey="seeConsumerKey" selector="{{AdminIntegrationDetailsSection.consumerKey}}" userInput="{{consumerKey}}"/> - <seeInField stepKey="seeConsumerSecret" selector="{{AdminIntegrationDetailsSection.consumerSecret}}" userInput="{{consumerSecret}}"/> - <seeInField stepKey="seeAccessToken" selector="{{AdminIntegrationDetailsSection.accessToken}}" userInput="{{accessToken}}"/> - <seeInField stepKey="seeAccessTokenSecret" selector="{{AdminIntegrationDetailsSection.accessTokenSecret}}" userInput="{{accessTokenSecret}}"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml index 2ba04757eb430..949c57e081866 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml @@ -35,7 +35,6 @@ <!-- Click Save And Activate Button --> <actionGroup ref="AdminIntegrationSaveAndActivateActionGroup" stepKey="clickSaveAndActivateButton"/> <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="allowAccess"/> - <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="clickDoneButton"/> </before> <after> <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="returnToIntegrationsPage"> @@ -48,17 +47,21 @@ <actionGroup ref="AdminDeleteIntegrationEntityActionGroup" stepKey="deleteCreatedIntegration"/> <actionGroup ref="logout" stepKey="logout"/> </after> - <!-- TEST BODY --> + <grabValueFrom selector="{{AdminNewIntegrationSection.consumerKey}}" stepKey="grabConsumerKey"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.consumerSecret}}" stepKey="grabConsumerSecret"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.accessToken}}" stepKey="grabAccessToken"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.accessTokenSecret}}" stepKey="grabAccessTokenSecret"/> + <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="clickDoneButton"/> <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="findCreatedIntegration"> <argument name="name" value="{{defaultIntegrationData.name}}"/> </actionGroup> <actionGroup ref="AdminIntegrationClickReauthoriseLinkOnGridActionGroup" stepKey="clickReauthoriseLink"/> <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="clickReauthoriseButton"/> - <grabValueFrom selector="{{AdminNewIntegrationSection.consumerKey}}" stepKey="grabConsumerKey"/> - <grabValueFrom selector="{{AdminNewIntegrationSection.consumerSecret}}" stepKey="grabConsumerSecret"/> - <grabValueFrom selector="{{AdminNewIntegrationSection.accessToken}}" stepKey="grabAccessToken"/> - <grabValueFrom selector="{{AdminNewIntegrationSection.accessTokenSecret}}" stepKey="grabAccessTokenSecret"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.consumerKey}}" stepKey="grabAfterReauthorizeConsumerKey"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.consumerSecret}}" stepKey="grabAfterReauthorizeConsumerSecret"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.accessToken}}" stepKey="grabReauthorizedAccessToken"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.accessTokenSecret}}" stepKey="grabReauthorizedAccessTokenSecret"/> <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="finishTheProcess"/> <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="seeSuccessMessage"> <argument name="message" value="The integration '{{defaultIntegrationData.name}}' has been re-authorized."/> @@ -67,11 +70,10 @@ <argument name="name" value="{{defaultIntegrationData.name}}"/> </actionGroup> <actionGroup ref="AdminIntegrationOpenExistingEntityActionGroup" stepKey="openIntegrationEntity"/> - <actionGroup ref="AssertAdminIntegrationTokensAfterReauthoriseActionGroup" stepKey="assertTokens"> - <argument name="consumerKey" value="{$grabConsumerKey}"/> - <argument name="consumerSecret" value="{$grabConsumerSecret}"/> - <argument name="accessToken" value="{$grabAccessToken}"/> - <argument name="accessTokenSecret" value="{$grabAccessTokenSecret}"/> - </actionGroup> + <!-- Compare Tokens After Reauthorizing --> + <assertEquals stepKey="assertConsumerKey" expected="($grabConsumerKey)" actual="$grabAfterReauthorizeConsumerKey" actualType="string"/> + <assertEquals stepKey="assertConsumerSecret" expected="($grabConsumerSecret)" actual="$grabAfterReauthorizeConsumerSecret" actualType="string"/> + <assertNotEquals stepKey="assertNotEqualsToken" expected="($grabAccessToken)" actual="$grabReauthorizedAccessToken" actualType="string"/> + <assertNotEquals stepKey="assertNotEqualsTokenSecret" expected="($grabAccessTokenSecret)" actual="$grabReauthorizedAccessTokenSecret" actualType="string"/> </test> </tests> From 0350be8f73f37e3a40a22319e300667caba31b6c Mon Sep 17 00:00:00 2001 From: DmitryTsymbal <d.tsymbal@atwix.com> Date: Wed, 5 Feb 2020 17:27:32 +0200 Subject: [PATCH 017/177] Refactoring --- ...edNewsletterTemplateMessageActionGroup.xml | 19 ------------------- ...nMarketingNewsletterTemplateUpdateTest.xml | 3 ++- 2 files changed, 2 insertions(+), 20 deletions(-) delete mode 100644 app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml deleted file mode 100644 index 3261f33894756..0000000000000 --- a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AssertAdminCreatedNewsletterTemplateMessageActionGroup.xml +++ /dev/null @@ -1,19 +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="AssertAdminCreatedNewsletterTemplateMessageActionGroup"> - <arguments> - <argument name="message" type="string" defaultValue="The newsletter template has been saved."/> - <argument name="messageType" type="string" defaultValue="success"/> - </arguments> - <waitForElementVisible selector="{{AdminNewsletterGridMainActionsSection.messageByType(messageType)}}" stepKey="waitForMessage"/> - <see userInput="{{message}}" selector="{{AdminNewsletterGridMainActionsSection.messageByType(messageType)}}" stepKey="verifyMessage"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml index b236dfee4ab6b..378dd71e13334 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml @@ -67,8 +67,9 @@ <argument name="templateContent" value="{{updatedNewsletter.textAreaContent}}"/> </actionGroup> <!-- Assert Success Message --> - <actionGroup ref="AssertAdminCreatedNewsletterTemplateMessageActionGroup" stepKey="assertSuccessMessage"> + <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="assertSuccessMessage"> <argument name="message" value="The newsletter template has been saved."/> + <argument name="messageType" value="success"/> </actionGroup> <!-- Find Created Newsletter on Grid --> <actionGroup ref="AdminSearchNewsletterTemplateOnGridActionGroup" stepKey="findCreatedNewsletterTemplate"> From e7faf0678b8b249c492232aaf4a6b53059683add Mon Sep 17 00:00:00 2001 From: Dmitry Tsymbal <d.tsymbal@atwix.com> Date: Mon, 16 Mar 2020 14:53:26 +0200 Subject: [PATCH 018/177] Refactoring --- ...wResourcesAccessIntegrationActionGroup.xml | 1 - ...ReAuthorizeTokensIntegrationEntityTest.xml | 64 +++++++++---------- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminAllowResourcesAccessIntegrationActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminAllowResourcesAccessIntegrationActionGroup.xml index 272cf130b8aec..bf4a9798225cc 100644 --- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminAllowResourcesAccessIntegrationActionGroup.xml +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminAllowResourcesAccessIntegrationActionGroup.xml @@ -8,7 +8,6 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminAllowResourcesAccessIntegrationActionGroup"> <click stepKey="clickAllowButton" selector="{{AdminNewIntegrationSection.allow}}"/> <waitForPageLoad stepKey="waitForLoading"/> diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml index 949c57e081866..bb61527ecab74 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml @@ -18,21 +18,16 @@ <group value="mtf_migrated"/> </annotations> <before> - <!-- Login As Admin --> - <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> - <!-- Navigate To Integrations Page --> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToIntegrationsPage"> <argument name="menuUiId" value="{{AdminMenuSystem.dataUiId}}"/> <argument name="submenuUiId" value="{{AdminMenuSystemExtensionsIntegrations.dataUiId}}"/> </actionGroup> - <!-- Click the "Add New Integration" button --> <actionGroup ref="AdminNavigateToCreateIntegrationPageActionGroup" stepKey="clickAddNewIntegrationButton"/> - <!-- Create New Integration --> <actionGroup ref="AdminFillIntegrationFormActionGroup" stepKey="createIntegration"> <argument name="integration" value="defaultIntegrationData"/> <argument name="password" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/> </actionGroup> - <!-- Click Save And Activate Button --> <actionGroup ref="AdminIntegrationSaveAndActivateActionGroup" stepKey="clickSaveAndActivateButton"/> <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="allowAccess"/> </before> @@ -45,35 +40,34 @@ <argument name="name" value="{{defaultIntegrationData.name}}"/> </actionGroup> <actionGroup ref="AdminDeleteIntegrationEntityActionGroup" stepKey="deleteCreatedIntegration"/> - <actionGroup ref="logout" stepKey="logout"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> - <!-- TEST BODY --> - <grabValueFrom selector="{{AdminNewIntegrationSection.consumerKey}}" stepKey="grabConsumerKey"/> - <grabValueFrom selector="{{AdminNewIntegrationSection.consumerSecret}}" stepKey="grabConsumerSecret"/> - <grabValueFrom selector="{{AdminNewIntegrationSection.accessToken}}" stepKey="grabAccessToken"/> - <grabValueFrom selector="{{AdminNewIntegrationSection.accessTokenSecret}}" stepKey="grabAccessTokenSecret"/> - <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="clickDoneButton"/> - <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="findCreatedIntegration"> - <argument name="name" value="{{defaultIntegrationData.name}}"/> - </actionGroup> - <actionGroup ref="AdminIntegrationClickReauthoriseLinkOnGridActionGroup" stepKey="clickReauthoriseLink"/> - <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="clickReauthoriseButton"/> - <grabValueFrom selector="{{AdminNewIntegrationSection.consumerKey}}" stepKey="grabAfterReauthorizeConsumerKey"/> - <grabValueFrom selector="{{AdminNewIntegrationSection.consumerSecret}}" stepKey="grabAfterReauthorizeConsumerSecret"/> - <grabValueFrom selector="{{AdminNewIntegrationSection.accessToken}}" stepKey="grabReauthorizedAccessToken"/> - <grabValueFrom selector="{{AdminNewIntegrationSection.accessTokenSecret}}" stepKey="grabReauthorizedAccessTokenSecret"/> - <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="finishTheProcess"/> - <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="seeSuccessMessage"> - <argument name="message" value="The integration '{{defaultIntegrationData.name}}' has been re-authorized."/> - </actionGroup> - <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="findReAuthorizedIntegration"> - <argument name="name" value="{{defaultIntegrationData.name}}"/> - </actionGroup> - <actionGroup ref="AdminIntegrationOpenExistingEntityActionGroup" stepKey="openIntegrationEntity"/> - <!-- Compare Tokens After Reauthorizing --> - <assertEquals stepKey="assertConsumerKey" expected="($grabConsumerKey)" actual="$grabAfterReauthorizeConsumerKey" actualType="string"/> - <assertEquals stepKey="assertConsumerSecret" expected="($grabConsumerSecret)" actual="$grabAfterReauthorizeConsumerSecret" actualType="string"/> - <assertNotEquals stepKey="assertNotEqualsToken" expected="($grabAccessToken)" actual="$grabReauthorizedAccessToken" actualType="string"/> - <assertNotEquals stepKey="assertNotEqualsTokenSecret" expected="($grabAccessTokenSecret)" actual="$grabReauthorizedAccessTokenSecret" actualType="string"/> + + <grabValueFrom selector="{{AdminNewIntegrationSection.consumerKey}}" stepKey="grabConsumerKey"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.consumerSecret}}" stepKey="grabConsumerSecret"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.accessToken}}" stepKey="grabAccessToken"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.accessTokenSecret}}" stepKey="grabAccessTokenSecret"/> + <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="clickDoneButton"/> + <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="findCreatedIntegration"> + <argument name="name" value="{{defaultIntegrationData.name}}"/> + </actionGroup> + <actionGroup ref="AdminIntegrationClickReauthoriseLinkOnGridActionGroup" stepKey="clickReauthoriseLink"/> + <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="clickReauthoriseButton"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.consumerKey}}" stepKey="grabAfterReauthorizeConsumerKey"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.consumerSecret}}" stepKey="grabAfterReauthorizeConsumerSecret"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.accessToken}}" stepKey="grabReauthorizedAccessToken"/> + <grabValueFrom selector="{{AdminNewIntegrationSection.accessTokenSecret}}" stepKey="grabReauthorizedAccessTokenSecret"/> + <actionGroup ref="AdminAllowResourcesAccessIntegrationActionGroup" stepKey="finishTheProcess"/> + <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="seeSuccessMessage"> + <argument name="message" value="The integration '{{defaultIntegrationData.name}}' has been re-authorized."/> + </actionGroup> + <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="findReAuthorizedIntegration"> + <argument name="name" value="{{defaultIntegrationData.name}}"/> + </actionGroup> + <actionGroup ref="AdminIntegrationOpenExistingEntityActionGroup" stepKey="openIntegrationEntity"/> + <assertEquals stepKey="assertConsumerKey" expected="($grabConsumerKey)" actual="$grabAfterReauthorizeConsumerKey" actualType="string"/> + <assertEquals stepKey="assertConsumerSecret" expected="($grabConsumerSecret)" actual="$grabAfterReauthorizeConsumerSecret" actualType="string"/> + <assertNotEquals stepKey="assertNotEqualsToken" expected="($grabAccessToken)" actual="$grabReauthorizedAccessToken" actualType="string"/> + <assertNotEquals stepKey="assertNotEqualsTokenSecret" expected="($grabAccessTokenSecret)" actual="$grabReauthorizedAccessTokenSecret" actualType="string"/> </test> </tests> From c37078cfd3d60608d4f6d653bdfbc5172fcf027e Mon Sep 17 00:00:00 2001 From: Dmitry Tsymbal <d.tsymbal@atwix.com> Date: Mon, 16 Mar 2020 15:33:49 +0200 Subject: [PATCH 019/177] Refactoring --- .../AdminMarketingDeleteSitemapEntityTest.xml | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingDeleteSitemapEntityTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingDeleteSitemapEntityTest.xml index 3ba13bb76b178..54e7ed211636e 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingDeleteSitemapEntityTest.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingDeleteSitemapEntityTest.xml @@ -18,7 +18,7 @@ <group value="mtf_migrated"/> </annotations> <before> - <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <!--Navigate to Marketing->Sitemap Page --> <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToMarketingSiteMapPage"> <argument name="menuUiId" value="{{AdminMenuMarketing.dataUiId}}"/> @@ -32,18 +32,18 @@ </actionGroup> </before> <after> - <actionGroup ref="logout" stepKey="logout"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> - <actionGroup ref="AdminMarketingSiteDeleteByNameActionGroup" stepKey="deleteCreatedSitemap"> - <argument name="filename" value="{{UniqueSitemapName.filename}}"/> - </actionGroup> - <actionGroup ref="AssertSiteMapDeleteSuccessActionGroup" stepKey="assertSuccessMessage"/> - <actionGroup ref="AdminMarketingSitemapSearchActionGroup" stepKey="searchDeletedSitemap"> - <argument name="filename" value="{{UniqueSitemapName.filename}}"/> - </actionGroup> - <actionGroup ref="AssertAdminSitemapIsNotInGridActionGroup" stepKey="dontSeeEntity"> - <argument name="filename" value="{{UniqueSitemapName.filename}}"/> - </actionGroup> + <actionGroup ref="AdminMarketingSiteDeleteByNameActionGroup" stepKey="deleteCreatedSitemap"> + <argument name="filename" value="{{UniqueSitemapName.filename}}"/> + </actionGroup> + <actionGroup ref="AssertSiteMapDeleteSuccessActionGroup" stepKey="assertSuccessMessage"/> + <actionGroup ref="AdminMarketingSitemapSearchActionGroup" stepKey="searchDeletedSitemap"> + <argument name="filename" value="{{UniqueSitemapName.filename}}"/> + </actionGroup> + <actionGroup ref="AssertAdminSitemapIsNotInGridActionGroup" stepKey="dontSeeEntity"> + <argument name="filename" value="{{UniqueSitemapName.filename}}"/> + </actionGroup> </test> </tests> From 6f0fc3497d445703aa0d8b16ab1d852b522c2cae Mon Sep 17 00:00:00 2001 From: Dmitry Tsymbal <d.tsymbal@atwix.com> Date: Mon, 16 Mar 2020 16:03:51 +0200 Subject: [PATCH 020/177] Refactoring --- ...enNewsletterTemplateFromGridActionGroup.xml | 2 -- ...CreateNewsletterTemplatePageActionGroup.xml | 2 -- ...inMarketingNewsletterTemplateUpdateTest.xml | 18 +++--------------- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingOpenNewsletterTemplateFromGridActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingOpenNewsletterTemplateFromGridActionGroup.xml index 4e380fe63d251..0341e68cf2b13 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingOpenNewsletterTemplateFromGridActionGroup.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingOpenNewsletterTemplateFromGridActionGroup.xml @@ -8,8 +8,6 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - - <!--Open Newsletter Template --> <actionGroup name="AdminMarketingOpenNewsletterTemplateFromGridActionGroup"> <click stepKey="openTemplate" selector="{{AdminNewsletterGridMainActionsSection.searchResultFirstRow}}"/> </actionGroup> diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminNavigateToCreateNewsletterTemplatePageActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminNavigateToCreateNewsletterTemplatePageActionGroup.xml index c743bde60172a..6e965279a4cb0 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminNavigateToCreateNewsletterTemplatePageActionGroup.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminNavigateToCreateNewsletterTemplatePageActionGroup.xml @@ -8,8 +8,6 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - - <!--Click "Add New Template" button--> <actionGroup name="AdminNavigateToCreateNewsletterTemplatePageActionGroup"> <click stepKey="clickAddNewTemplateButton" selector="{{AdminNewsletterGridMainActionsSection.add}}"/> <waitForPageLoad stepKey="waitForNewNewsletterTemplatesPageLoaded"/> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml index 378dd71e13334..cedb176cf909f 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml @@ -19,15 +19,12 @@ </annotations> <before> - <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> - <!-- Navigate To MARKETING > Newsletter Template --> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToNewsletterTemplatePage"> <argument name="menuUiId" value="{{AdminMenuMarketing.dataUiId}}"/> <argument name="submenuUiId" value="{{AdminMenuMarketingCommunicationsNewsletterTemplate.dataUiId}}"/> </actionGroup> - <!-- Navigate To Create Newsletter Template Page --> <actionGroup ref="AdminNavigateToCreateNewsletterTemplatePageActionGroup" stepKey="navigateTiCreateNewsletterTemplatePage"/> - <!-- Create Newsletter Template --> <actionGroup ref="AdminMarketingCreateNewsletterTemplateActionGroup" stepKey="createNewsletterTemplate"> <argument name="name" value="{{_defaultNewsletter.name}}"/> <argument name="subject" value="{{_defaultNewsletter.subject}}"/> @@ -35,16 +32,13 @@ <argument name="senderEmail" value="{{_defaultNewsletter.senderEmail}}"/> <argument name="templateContent" value="{{_defaultNewsletter.textAreaContent}}"/> </actionGroup> - <!-- Search Created Newsletter Template on Grid --> <actionGroup ref="AdminSearchNewsletterTemplateOnGridActionGroup" stepKey="findCreatedNewsletterTemplate"> <argument name="name" value="{{_defaultNewsletter.name}}"/> <argument name="subject" value="{{_defaultNewsletter.subject}}"/> </actionGroup> - <!-- Open Created Newsletter Template --> <actionGroup ref="AdminMarketingOpenNewsletterTemplateFromGridActionGroup" stepKey="openCreatedNewsletterTemplate"/> </before> <after> - <!-- Delete Updated Newsletter Template --> <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToNewsletterGridPage"> <argument name="menuUiId" value="{{AdminMenuMarketing.dataUiId}}"/> <argument name="submenuUiId" value="{{AdminMenuMarketingCommunicationsNewsletterTemplate.dataUiId}}"/> @@ -55,10 +49,9 @@ </actionGroup> <actionGroup ref="AdminMarketingOpenNewsletterTemplateFromGridActionGroup" stepKey="openTemplate"/> <actionGroup ref="AdminMarketingDeleteNewsletterTemplateActionGroup" stepKey="deleteTemplate"/> - <actionGroup ref="logout" stepKey="logout"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> - <!-- TEST BODY --> - <!-- Update Created Newsletter Template --> + <actionGroup ref="AdminMarketingCreateNewsletterTemplateActionGroup" stepKey="updateNewsletterTemplate"> <argument name="name" value="{{updatedNewsletter.name}}"/> <argument name="subject" value="{{updatedNewsletter.subject}}"/> @@ -66,22 +59,18 @@ <argument name="senderEmail" value="{{updatedNewsletter.senderEmail}}"/> <argument name="templateContent" value="{{updatedNewsletter.textAreaContent}}"/> </actionGroup> - <!-- Assert Success Message --> <actionGroup ref="AssertMessageInAdminPanelActionGroup" stepKey="assertSuccessMessage"> <argument name="message" value="The newsletter template has been saved."/> <argument name="messageType" value="success"/> </actionGroup> - <!-- Find Created Newsletter on Grid --> <actionGroup ref="AdminSearchNewsletterTemplateOnGridActionGroup" stepKey="findCreatedNewsletterTemplate"> <argument name="name" value="{{updatedNewsletter.name}}"/> <argument name="subject" value="{{updatedNewsletter.subject}}"/> </actionGroup> - <!-- Assert Created Newsletter on Grid --> <actionGroup ref="AssertAdminCreatedNewsletterTemplateInGridActionGroup" stepKey="assertNewsletterInGrid"> <argument name="name" value="{{updatedNewsletter.name}}"/> <argument name="subject" value="{{updatedNewsletter.subject}}"/> </actionGroup> - <!-- Assert Newsletter Form --> <actionGroup ref="AdminSearchNewsletterTemplateOnGridActionGroup" stepKey="findUpdatedNewsletterTemplate"> <argument name="name" value="Updated Newsletter Template"/> <argument name="subject" value="Updated Newsletter Subject"/> @@ -94,6 +83,5 @@ <argument name="senderEmail" value="{{updatedNewsletter.senderEmail}}"/> <argument name="templateContent" value="{{updatedNewsletter.textAreaContent}}"/> </actionGroup> - <!-- END TEST BODY --> </test> </tests> From 5d0c97255f83c6aead003a420a8db803a7085b2d Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Mon, 16 Mar 2020 02:53:18 +0100 Subject: [PATCH 021/177] FIX #27299 AbstractController::resetRequest(), automatically setDispatched(false) before each AbstractController::dispatch() --- .../TestCase/AbstractController.php | 36 +++++++++++++------ .../Customer/Controller/AccountTest.php | 30 ++++++++-------- 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php index feb9eca0793a2..d2a6bb7da9abd 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php +++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php @@ -7,21 +7,25 @@ /** * Abstract class for the controller tests */ + namespace Magento\TestFramework\TestCase; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\App\ResponseInterface; use Magento\Framework\Data\Form\FormKey; use Magento\Framework\Message\MessageInterface; use Magento\Framework\Stdlib\CookieManagerInterface; use Magento\Framework\View\Element\Message\InterpretationStrategyInterface; use Magento\Theme\Controller\Result\MessagePlugin; -use Magento\Framework\App\Request\Http as HttpRequest; -use Magento\Framework\App\Response\Http as HttpResponse; +use PHPUnit\Framework\TestCase; /** + * Set of methods useful for performing requests to Controllers. + * * @SuppressWarnings(PHPMD.NumberOfChildren) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -abstract class AbstractController extends \PHPUnit\Framework\TestCase +abstract class AbstractController extends TestCase { protected $_runCode = ''; @@ -30,12 +34,12 @@ abstract class AbstractController extends \PHPUnit\Framework\TestCase protected $_runOptions = []; /** - * @var \Magento\Framework\App\RequestInterface + * @var RequestInterface */ protected $_request; /** - * @var \Magento\Framework\App\ResponseInterface + * @var ResponseInterface */ protected $_response; @@ -103,8 +107,9 @@ protected function assertPostConditions() */ public function dispatch($uri) { - /** @var HttpRequest $request */ $request = $this->getRequest(); + + $request->setDispatched(false); $request->setRequestUri($uri); if ($request->isPost() && !array_key_exists('form_key', $request->getPost()) @@ -119,25 +124,36 @@ public function dispatch($uri) /** * Request getter * - * @return \Magento\Framework\App\RequestInterface|HttpRequest + * @return RequestInterface */ public function getRequest() { if (!$this->_request) { - $this->_request = $this->_objectManager->get(\Magento\Framework\App\RequestInterface::class); + $this->_request = $this->_objectManager->get(RequestInterface::class); } return $this->_request; } + /** + * Reset Request parameters + * + * @return void + */ + protected function resetRequest(): void + { + $this->_objectManager->removeSharedInstance(RequestInterface::class); + $this->_request = null; + } + /** * Response getter * - * @return \Magento\Framework\App\ResponseInterface|HttpResponse + * @return ResponseInterface */ public function getResponse() { if (!$this->_response) { - $this->_response = $this->_objectManager->get(\Magento\Framework\App\ResponseInterface::class); + $this->_response = $this->_objectManager->get(ResponseInterface::class); } return $this->_response; } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php index 9b0b53e11615f..a799c139545f4 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php @@ -188,14 +188,14 @@ public function testCreatepasswordActionInvalidToken() } /** - * @param int $customerId + * @param int $customerId * @param string|null $confirmation */ private function assertCustomerConfirmationEquals(int $customerId, string $confirmation = null) { /** @var \Magento\Customer\Model\Customer $customer */ $customer = Bootstrap::getObjectManager() - ->create(\Magento\Customer\Model\Customer::class)->load($customerId); + ->create(\Magento\Customer\Model\Customer::class)->load($customerId); $this->assertEquals($confirmation, $customer->getConfirmation()); } @@ -492,14 +492,14 @@ public function testChangePasswordEditPostAction() ->setMethod('POST') ->setPostValue( [ - 'form_key' => $this->_objectManager->get(FormKey::class)->getFormKey(), - 'firstname' => 'John', - 'lastname' => 'Doe', - 'email' => 'johndoe@email.com', - 'change_password' => 1, - 'change_email' => 1, + 'form_key' => $this->_objectManager->get(FormKey::class)->getFormKey(), + 'firstname' => 'John', + 'lastname' => 'Doe', + 'email' => 'johndoe@email.com', + 'change_password' => 1, + 'change_email' => 1, 'current_password' => 'password', - 'password' => 'new-Password1', + 'password' => 'new-Password1', 'password_confirmation' => 'new-Password1', ] ); @@ -645,6 +645,7 @@ public function testRegisterCustomerWithEmailConfirmation(): void /** @var CookieManagerInterface $cookieManager */ $cookieManager = $this->_objectManager->get(CookieManagerInterface::class); $cookieManager->deleteCookie(MessagePlugin::MESSAGES_COOKIES_NAME); + $this->_objectManager->removeSharedInstance(Http::class); $this->_objectManager->removeSharedInstance(Request::class); $this->_request = null; @@ -761,8 +762,9 @@ public function testResetPasswordWhenEmailChanged(): void $customer->setEmail($newEmail); $customerRepository->save($customer); - /* Goes through the link in a mail */ $this->resetRequest(); + + /* Goes through the link in a mail */ $this->getRequest() ->setParam('token', $token) ->setParam('id', $customerData->getId()); @@ -842,15 +844,13 @@ private function assertForgotPasswordEmailContent(string $token): void } /** - * Clear request object. - * - * @return void + * @inheritDoc */ - private function resetRequest(): void + protected function resetRequest(): void { $this->_objectManager->removeSharedInstance(Http::class); $this->_objectManager->removeSharedInstance(Request::class); - $this->_request = null; + parent::resetRequest(); } /** From b90d46caabb7855dcdffbf05d0f943ca5634f262 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Wed, 18 Mar 2020 05:26:41 +0100 Subject: [PATCH 022/177] Fix failing CMS tests due to PageBuilder conflict --- ...rontRecentlyViewedAtStoreViewLevelTest.xml | 35 ++++++++++--------- .../AdminEditCMSPageContentActionGroup.xml | 7 ++-- ...nInsertRecentlyViewedWidgetActionGroup.xml | 4 +-- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml index f8ee9e562a6a9..012e48e4eeb64 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml @@ -17,8 +17,9 @@ <group value="catalog"/> </annotations> <before> - <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> - <!--Create Simple Product and Category --> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + + <!--Create Simple Product and Category --> <createData entity="SimpleSubCategory" stepKey="createCategory"/> <createData entity="SimpleProduct" stepKey="createSimpleProduct1"> <requiredEntity createDataKey="createCategory"/> @@ -36,6 +37,9 @@ <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreViewOne"> <argument name="customStore" value="customStoreEN"/> </actionGroup> + + <magentoCron stepKey="runCronIndex" groups="index"/> + <!-- Set Stores > Configurations > Catalog > Recently Viewed/Compared Products > Show for Current = store view--> <magentoCLI command="config:set {{RecentlyViewedProductScopeStore.path}} {{RecentlyViewedProductScopeStore.value}}" stepKey="RecentlyViewedProductScopeStore"/> </before> @@ -62,28 +66,27 @@ </actionGroup> <!-- Logout Admin --> - <actionGroup ref="logout" stepKey="logout"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> <magentoCLI command="indexer:reindex" stepKey="reindex"/> <magentoCLI command="cache:flush" stepKey="flushCacheAfterDeletion"/> - </after> - <!--Create widget for recently viewed products--> + <!--Create widget for recently viewed products--> <actionGroup ref="AdminEditCMSPageContentActionGroup" stepKey="clearRecentlyViewedWidgetsFromCMSContentBefore"> - <argument name="content" value="{{CmsHomePageContent.content}}"/> - <argument name="pageId" value="{{CmsHomePageContent.page_id}}"/> + <argument name="content" value="{{CmsHomePageContent.content}}"/> + <argument name="pageId" value="{{CmsHomePageContent.page_id}}"/> </actionGroup> <amOnPage url="{{AdminCmsPageEditPage.url(CmsHomePageContent.page_id)}}" stepKey="navigateToEditHomePagePage"/> <waitForPageLoad time="50" stepKey="waitForContentPageToLoad"/> <actionGroup ref="AdminInsertRecentlyViewedWidgetActionGroup" stepKey="insertRecentlyViewedWidget"> - <argument name="attributeSelector1" value="show_attributes"/> - <argument name="attributeSelector2" value="show_buttons"/> - <argument name="productAttributeSection1" value="1"/> - <argument name="productAttributeSection2" value="4"/> - <argument name="buttonToShowSection1" value="1"/> - <argument name="buttonToShowSection2" value="3"/> + <argument name="attributeSelector1" value="show_attributes"/> + <argument name="attributeSelector2" value="show_buttons"/> + <argument name="productAttributeSection1" value="1"/> + <argument name="productAttributeSection2" value="4"/> + <argument name="buttonToShowSection1" value="1"/> + <argument name="buttonToShowSection2" value="3"/> </actionGroup> <!-- Warm up cache --> @@ -96,7 +99,7 @@ <amOnPage url="{{StorefrontHomePage.url}}" stepKey="amOnHomePage"/> <waitForPageLoad time="30" stepKey="homeWaitForPageLoad"/> - <actionGroup ref="AssertSeeProductDetailsOnStorefrontRecentlyViewedWidgetActionGroup" stepKey="assertStore1RecentlyViewedProduct2"> + <actionGroup ref="AssertSeeProductDetailsOnStorefrontRecentlyViewedWidgetActionGroup" stepKey="assertStore1RecentlyViewedProduct2"> <argument name="productName" value="$$createSimpleProduct2.name$$"/> <argument name="productPosition" value="2"/> </actionGroup> @@ -105,7 +108,7 @@ <argument name="productPosition" value="1"/> </actionGroup> - <!-- Switch store view --> + <!-- Switch store view --> <waitForPageLoad time="40" stepKey="waitForStorefrontPageLoad"/> <actionGroup ref="StorefrontSwitchStoreViewActionGroup" stepKey="switchStoreViewActionGroup"> <argument name="storeView" value="customStoreEN"/> @@ -129,7 +132,7 @@ </actionGroup> <grabTextFrom selector="{{StoreFrontRecentlyViewedProductSection.ProductName('2')}}" stepKey="grabDontSeeHomeProduct3"/> - <assertNotContains expected="$$createSimpleProduct3.name$$" actual="$grabDontSeeHomeProduct3" stepKey="assertNotSeeProduct3"/> + <assertNotContains expected="$$createSimpleProduct3.name$$" actual="$grabDontSeeHomeProduct3" stepKey="assertNotSeeProduct3"/> <actionGroup ref="StorefrontSwitchDefaultStoreViewActionGroup" stepKey="switchToDefualtStoreView"/> diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminEditCMSPageContentActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminEditCMSPageContentActionGroup.xml index b745e9705ed30..c4d832a3bedc1 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminEditCMSPageContentActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminEditCMSPageContentActionGroup.xml @@ -10,10 +10,11 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> <actionGroup name="AdminEditCMSPageContentActionGroup"> <arguments> - <argument name="content" type="string" /> - <argument name="pageId" type="string" /> + <argument name="content" type="string"/> + <argument name="pageId" type="string"/> </arguments> - <amOnPage url="{{AdminCmsPageEditPage.url(pageId)}}" stepKey="navigateToEditCMSPage"/> + + <amOnPage url="{{AdminCmsPageEditPage.url(pageId)}}" stepKey="navigateToEditCMSPage"/> <waitForPageLoad stepKey="waitForCmsPageEditPage"/> <conditionalClick selector="{{CmsNewPagePageActionsSection.contentSectionName}}" dependentSelector="{{CatalogWidgetSection.insertWidgetButton}}" visible="false" stepKey="clickShowHideEditorIfVisible"/> <waitForElementVisible selector="{{CmsNewPagePageContentSection.content}}" stepKey="waitForContentField"/> diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminInsertRecentlyViewedWidgetActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminInsertRecentlyViewedWidgetActionGroup.xml index e8c66c68348fc..8a9815e9fb86f 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminInsertRecentlyViewedWidgetActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminInsertRecentlyViewedWidgetActionGroup.xml @@ -32,9 +32,9 @@ <click selector="{{WidgetSection.InsertWidget}}" stepKey="clickInsertWidgetToSave"/> <waitForPageLoad time="30" stepKey="waitForWidgetInsertPageLoad"/> <!-- Check that widget is inserted --> - <waitForElementVisible selector="#cms_page_form_content" stepKey="checkCMSContent" time="30"/> + <waitForElementVisible selector="{{CmsNewPagePageContentSection.content}}" stepKey="checkCMSContent" time="30"/> <click selector="{{CmsNewPagePageActionsSection.saveAndContinueEdit}}" stepKey="clickNextSave"/> <waitForPageLoad stepKey="waitForPageActionSave" time="30"/> <waitForElementVisible selector="*[data-ui-id='messages-message-success']" time="60" stepKey="waitForSaveSuccess"/> </actionGroup> -</actionGroups> \ No newline at end of file +</actionGroups> From 6be5b23d7cfd7e40cc720e07abe9314c1df1cbd0 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Wed, 18 Mar 2020 05:56:42 +0100 Subject: [PATCH 023/177] Flushing cache != warming it :facepalm: --- .../Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml index 012e48e4eeb64..2cefc4d9e1b1e 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml @@ -89,7 +89,6 @@ <argument name="buttonToShowSection2" value="3"/> </actionGroup> - <!-- Warm up cache --> <magentoCLI command="cache:flush" stepKey="flushCacheAfterWidgetCreated"/> <!-- Navigate to product 3 on store front --> From ecbd22dff90683c03e9dc4d16a2b034a39f71f5e Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Wed, 18 Mar 2020 06:04:21 +0100 Subject: [PATCH 024/177] Final, working version of fix --- .../Mftf/ActionGroup/AdminEditCMSPageContentActionGroup.xml | 4 +++- .../AdminInsertRecentlyViewedWidgetActionGroup.xml | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminEditCMSPageContentActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminEditCMSPageContentActionGroup.xml index c4d832a3bedc1..df3d089407bb2 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminEditCMSPageContentActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminEditCMSPageContentActionGroup.xml @@ -16,7 +16,9 @@ <amOnPage url="{{AdminCmsPageEditPage.url(pageId)}}" stepKey="navigateToEditCMSPage"/> <waitForPageLoad stepKey="waitForCmsPageEditPage"/> - <conditionalClick selector="{{CmsNewPagePageActionsSection.contentSectionName}}" dependentSelector="{{CatalogWidgetSection.insertWidgetButton}}" visible="false" stepKey="clickShowHideEditorIfVisible"/> + <conditionalClick selector="{{CmsNewPagePageActionsSection.contentSectionName}}" dependentSelector="{{CmsNewPagePageActionsSection.showHideEditor}}" visible="false" stepKey="expandContentSectionIfNotVisible"/> + <conditionalClick selector="{{CmsNewPagePageActionsSection.showHideEditor}}" dependentSelector="{{CatalogWidgetSection.insertWidgetButton}}" visible="false" stepKey="clickNextShowHideEditorIfVisible"/> + <waitForElementVisible selector="{{CatalogWidgetSection.insertWidgetButton}}" stepKey="waitForInsertWidgetElement"/> <waitForElementVisible selector="{{CmsNewPagePageContentSection.content}}" stepKey="waitForContentField"/> <fillField selector="{{CmsNewPagePageContentSection.content}}" userInput="{{content}}" stepKey="resetCMSPageToDefaultContent"/> <click selector="{{CmsNewPagePageActionsSection.saveAndContinueEdit}}" stepKey="clickSave"/> diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminInsertRecentlyViewedWidgetActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminInsertRecentlyViewedWidgetActionGroup.xml index 8a9815e9fb86f..3c7c361462c4d 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminInsertRecentlyViewedWidgetActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminInsertRecentlyViewedWidgetActionGroup.xml @@ -16,9 +16,9 @@ <argument name="buttonToShowSection1" type="string" defaultValue="1"/> <argument name="buttonToShowSection2" type="string" defaultValue="3" /> </arguments> - <click selector="{{CmsNewPagePageActionsSection.contentSectionName}}" stepKey="expandContent"/> - <waitForPageLoad time="50" stepKey="waitForPageLoadContentSection"/> - <conditionalClick selector="{{CmsNewPagePageActionsSection.showHideEditor}}" dependentSelector="{{CmsNewPagePageActionsSection.showHideEditor}}" visible="true" stepKey="clickNextShowHideEditorIfVisible"/> + + <conditionalClick selector="{{CmsNewPagePageActionsSection.contentSectionName}}" dependentSelector="{{CmsNewPagePageActionsSection.showHideEditor}}" visible="false" stepKey="expandContentSectionIfNotVisible"/> + <conditionalClick selector="{{CmsNewPagePageActionsSection.showHideEditor}}" dependentSelector="{{CatalogWidgetSection.insertWidgetButton}}" visible="false" stepKey="clickNextShowHideEditorIfVisible"/> <waitForElementVisible selector="{{CatalogWidgetSection.insertWidgetButton}}" stepKey="waitForInsertWidgetElement"/> <click selector="{{CatalogWidgetSection.insertWidgetButton}}" stepKey="clickInsertWidget"/> <waitForElementVisible selector="{{InsertWidgetSection.widgetTypeDropDown}}" time="30" stepKey="waitForWidgetTypeDropDownVisible"/> From 5827f754c17332086eee92de078bb8903614777b Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Wed, 18 Mar 2020 11:30:37 +0100 Subject: [PATCH 025/177] Made bar expanding conditional --- .../Mftf/ActionGroup/AdminEditCMSPageContentActionGroup.xml | 4 ++-- .../AdminInsertRecentlyViewedWidgetActionGroup.xml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminEditCMSPageContentActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminEditCMSPageContentActionGroup.xml index df3d089407bb2..983e48359c3b4 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminEditCMSPageContentActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminEditCMSPageContentActionGroup.xml @@ -16,9 +16,9 @@ <amOnPage url="{{AdminCmsPageEditPage.url(pageId)}}" stepKey="navigateToEditCMSPage"/> <waitForPageLoad stepKey="waitForCmsPageEditPage"/> - <conditionalClick selector="{{CmsNewPagePageActionsSection.contentSectionName}}" dependentSelector="{{CmsNewPagePageActionsSection.showHideEditor}}" visible="false" stepKey="expandContentSectionIfNotVisible"/> + <conditionalClick selector="{{CmsNewPagePageContentSection.header}}" dependentSelector="{{CmsNewPagePageContentSection.contentHeading}}" visible="false" stepKey="expandContentTab"/> + <waitForPageLoad time="30" stepKey="waitForPageLoadContentSection"/> <conditionalClick selector="{{CmsNewPagePageActionsSection.showHideEditor}}" dependentSelector="{{CatalogWidgetSection.insertWidgetButton}}" visible="false" stepKey="clickNextShowHideEditorIfVisible"/> - <waitForElementVisible selector="{{CatalogWidgetSection.insertWidgetButton}}" stepKey="waitForInsertWidgetElement"/> <waitForElementVisible selector="{{CmsNewPagePageContentSection.content}}" stepKey="waitForContentField"/> <fillField selector="{{CmsNewPagePageContentSection.content}}" userInput="{{content}}" stepKey="resetCMSPageToDefaultContent"/> <click selector="{{CmsNewPagePageActionsSection.saveAndContinueEdit}}" stepKey="clickSave"/> diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminInsertRecentlyViewedWidgetActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminInsertRecentlyViewedWidgetActionGroup.xml index 3c7c361462c4d..781cc32834462 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminInsertRecentlyViewedWidgetActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminInsertRecentlyViewedWidgetActionGroup.xml @@ -18,6 +18,7 @@ </arguments> <conditionalClick selector="{{CmsNewPagePageActionsSection.contentSectionName}}" dependentSelector="{{CmsNewPagePageActionsSection.showHideEditor}}" visible="false" stepKey="expandContentSectionIfNotVisible"/> + <waitForPageLoad time="30" stepKey="waitForPageLoadContentSection"/> <conditionalClick selector="{{CmsNewPagePageActionsSection.showHideEditor}}" dependentSelector="{{CatalogWidgetSection.insertWidgetButton}}" visible="false" stepKey="clickNextShowHideEditorIfVisible"/> <waitForElementVisible selector="{{CatalogWidgetSection.insertWidgetButton}}" stepKey="waitForInsertWidgetElement"/> <click selector="{{CatalogWidgetSection.insertWidgetButton}}" stepKey="clickInsertWidget"/> From ba8d3669a7b498759023dc9518e5339764e0170b Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Wed, 18 Mar 2020 12:31:42 +0100 Subject: [PATCH 026/177] Add Integration Test to cover consecutive calls. --- .../Adminhtml/ConsecutiveCallTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/ConsecutiveCallTest.php diff --git a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/ConsecutiveCallTest.php b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/ConsecutiveCallTest.php new file mode 100644 index 0000000000000..aff706688dc9f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/ConsecutiveCallTest.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Backend\Controller\Adminhtml; + +use Magento\TestFramework\TestCase\AbstractBackendController; + +/** + * @magentoAppArea adminhtml + */ +class ConsecutiveCallTest extends AbstractBackendController +{ + /** + * Consecutive calls were failing due to `$request['dispatched']` not being reset before request + */ + public function testConsecutiveCallShouldNotFail() + { + $this->dispatch('backend/admin/auth/login'); + $this->dispatch('backend/admin/auth/login'); + } +} From 19b01134b56cdd300eee1f0f6f3733b84b43f633 Mon Sep 17 00:00:00 2001 From: DianaRusin <rusind95@gmail.com> Date: Tue, 24 Mar 2020 14:59:16 +0200 Subject: [PATCH 027/177] MC-32697: [2.4] AbstractSimpleObjectBuilder.php throws exception when Interceptor instance comes. --- .../Framework/Api/SortOrderBuilderTest.php | 40 +++++++++++++++++++ .../Api/AbstractSimpleObjectBuilder.php | 16 ++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Framework/Api/SortOrderBuilderTest.php diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/SortOrderBuilderTest.php b/dev/tests/integration/testsuite/Magento/Framework/Api/SortOrderBuilderTest.php new file mode 100644 index 0000000000000..20b2528eb7918 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/Api/SortOrderBuilderTest.php @@ -0,0 +1,40 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\Api; + +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test of building the Data Object + */ +class SortOrderBuilderTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var SortOrderBuilder + */ + private $interceptedBuilder; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + $this->interceptedBuilder = Bootstrap::getObjectManager()->get(SortOrderBuilder::class . '\Interceptor'); + } + + /** + * Test Builder successfully creates object when Interceptor instance is provided. + * + * @return void + */ + public function testCreate(): void + { + $this->assertEquals(SortOrder::class, get_class($this->interceptedBuilder->create())); + } +} diff --git a/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php b/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php index d9a972ac237f5..d34e5a0bf6d66 100644 --- a/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php +++ b/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php @@ -3,6 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Framework\Api; /** @@ -44,6 +46,8 @@ public function create() } /** + * Overwrite data in Object. + * * @param string $key * @param mixed $value * @@ -60,12 +64,16 @@ protected function _set($key, $value) * * @return string */ - protected function _getDataObjectType() + protected function _getDataObjectType(): string { $currentClass = get_class($this); - $builderSuffix = 'Builder'; - $dataObjectType = substr($currentClass, 0, -strlen($builderSuffix)); - return $dataObjectType; + $suffix = 'Builder'; + $interceptorSuffix = '\Interceptor'; + if (false !== strpos($currentClass, $interceptorSuffix, -strlen($interceptorSuffix))) { + $suffix .= $interceptorSuffix; + } + + return substr($currentClass, 0, -strlen($suffix)); } /** From 01307c702546605cc7d1679261404665d92e84a1 Mon Sep 17 00:00:00 2001 From: DmytroPaidych <dimonovp@gmail.com> Date: Tue, 24 Mar 2020 17:24:20 +0200 Subject: [PATCH 028/177] MC-32709: Customer configuration: Account sharing options --- .../AccountManagement/CreateAccountTest.php | 29 ++- .../Customer/Model/Config/ShareTest.php | 73 +++++-- .../Customer/Model/CustomerRegistryTest.php | 192 ++++++++++++------ .../_files/customer_for_second_website.php | 40 ++++ .../customer_for_second_website_rollback.php | 28 +++ 5 files changed, 280 insertions(+), 82 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagement/CreateAccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagement/CreateAccountTest.php index 8be3dfc10d86e..28fefd0bc4e1b 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagement/CreateAccountTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagement/CreateAccountTest.php @@ -19,6 +19,7 @@ use Magento\Framework\Encryption\EncryptorInterface; use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\State\InputMismatchException; use Magento\Framework\Math\Random; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Validator\Exception; @@ -496,9 +497,33 @@ public function testCreateNewCustomerFromClone(): void $this->assertCustomerData($customer, $expectedCustomerData); $this->accountManagement->authenticate( $customer->getEmail(), - '_aPassword1', - true + '_aPassword1' + ); + } + + /** + * Test for create customer account for second website (with existing email for default website) + * with global account scope config. + * + * @magentoConfigFixture current_store customer/account_share/scope 0 + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php + * + * @return void + */ + public function testCreateAccountInGlobalScope(): void + { + $customerEntity = $this->customerFactory->create(); + $this->dataObjectHelper->populateWithArray( + $customerEntity, + $this->defaultCustomerData, + CustomerInterface::class ); + $storeId = $this->storeManager->getStore('fixture_second_store')->getStoreId(); + $customerEntity->setStoreId($storeId); + $message = 'A customer with the same email address already exists in an associated website.'; + $this->expectExceptionObject(new InputMismatchException(__($message))); + $this->accountManagement->createAccount($customerEntity, '_aPassword1'); } /** diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Config/ShareTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/ShareTest.php index 0c35155e5f213..f8371ee959bae 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/Config/ShareTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/ShareTest.php @@ -3,43 +3,80 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Customer\Model\Config; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\ObjectManagerInterface; +use Magento\Store\Api\WebsiteRepositoryInterface; use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; /** * Test \Magento\Customer\Model\Config\Share */ -class ShareTest extends \PHPUnit\Framework\TestCase +class ShareTest extends TestCase { - public function testGetSharedWebsiteIds() + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Share */ + private $share; + + /** @var WebsiteRepositoryInterface */ + private $websiteRepository; + + /** + * @inheritdoc + */ + protected function setUp() { - /** @var Share $share */ - $share = Bootstrap::getObjectManager()->get(\Magento\Customer\Model\Config\Share::class); + parent::setUp(); - $websiteIds = $share->getSharedWebsiteIds(42); + $this->objectManager = Bootstrap::getObjectManager(); + $this->share = $this->objectManager->get(Share::class); + $this->websiteRepository = $this->objectManager->create(WebsiteRepositoryInterface::class); + } + /** + * @return void + */ + public function testGetSharedWebsiteIds(): void + { + $websiteIds = $this->share->getSharedWebsiteIds(42); $this->assertEquals([42], $websiteIds); } /** * @magentoDataFixture Magento/Store/_files/core_second_third_fixturestore.php * @magentoConfigFixture current_store customer/account_share/scope 0 + * + * @return void */ - public function testGetSharedWebsiteIdsMultipleSites() + public function testGetSharedWebsiteIdsMultipleSites(): void { - /** @var Share $share */ - $share = Bootstrap::getObjectManager()->get(\Magento\Customer\Model\Config\Share::class); - $expectedIds = [1]; - /** @var \Magento\Store\Model\Website $website */ - $website = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Store\Model\Website::class - ); - $expectedIds[] = $website->load('secondwebsite')->getId(); - $expectedIds[] = $website->load('thirdwebsite')->getId(); - - $websiteIds = $share->getSharedWebsiteIds(42); - + $expectedIds[] = $this->websiteRepository->get('base')->getId(); + $expectedIds[] = $this->websiteRepository->get('secondwebsite')->getId(); + $expectedIds[] = $this->websiteRepository->get('thirdwebsite')->getId(); + $websiteIds = $this->share->getSharedWebsiteIds(42); $this->assertEquals($expectedIds, $websiteIds); } + + /** + * @magentoConfigFixture current_store customer/account_share/scope 1 + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Customer/_files/customer_for_second_website.php + * @magentoDbIsolation enabled + * + * @return void + */ + public function testEnableGlobalAccountShareScope(): void + { + $message = 'We can\'t share customer accounts globally when the accounts share' + . ' identical email addresses on more than one website.'; + $this->expectExceptionObject(new LocalizedException(__($message))); + $this->share->setPath(Share::XML_PATH_CUSTOMER_ACCOUNT_SHARE)->setValue((string)Share::SHARE_GLOBAL) + ->beforeSave(); + } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerRegistryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerRegistryTest.php index d885d7c6f36e0..7bff71bb85bf8 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerRegistryTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerRegistryTest.php @@ -3,127 +3,195 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Customer\Model; +use Magento\Customer\Model\ResourceModel\Customer as CustomerResourceModel; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\ObjectManagerInterface; +use Magento\Store\Model\StoreManagerInterface; use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; /** * Test for \Magento\Customer\Model\CustomerRegistry + * + * @magentoDbIsolation enabled */ -class CustomerRegistryTest extends \PHPUnit\Framework\TestCase +class CustomerRegistryTest extends TestCase { /** - * @var \Magento\Customer\Model\CustomerRegistry + * @var ObjectManagerInterface */ - protected $_model; + private $objectManager; - /**#@+ - * Data set in customer fixture + /** + * @var CustomerRegistry + */ + private $model; + + /** + * @var StoreManagerInterface + */ + private $storeManager; + + /** + * @var CustomerResourceModel */ - const CUSTOMER_ID = 1; - const CUSTOMER_EMAIL = 'customer@example.com'; - const WEBSITE_ID = 1; + private $customerResourceModel; /** - * Initialize SUT + * @var int + */ + private $defaultWebsiteId; + + /** + * @inheritdoc */ protected function setUp() { - $this->_model = Bootstrap::getObjectManager() - ->create(\Magento\Customer\Model\CustomerRegistry::class); + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->model = $this->objectManager->get(CustomerRegistry::class); + $this->storeManager = $this->objectManager->get(StoreManagerInterface::class); + $this->customerResourceModel = $this->objectManager->get(CustomerResourceModel::class); + $this->defaultWebsiteId = $this->storeManager->getWebsite('base')->getWebsiteId(); } /** * @magentoDataFixture Magento/Customer/_files/customer.php + * + * @return void */ - public function testRetrieve() + public function testRetrieve(): void { - $customer = $this->_model->retrieve(self::CUSTOMER_ID); - $this->assertInstanceOf(\Magento\Customer\Model\Customer::class, $customer); - $this->assertEquals(self::CUSTOMER_ID, $customer->getId()); + $customer = $this->model->retrieve(1); + $this->assertInstanceOf(Customer::class, $customer); + $this->assertEquals(1, $customer->getId()); } /** * @magentoDataFixture Magento/Customer/_files/customer.php + * + * @return void */ - public function testRetrieveByEmail() + public function testRetrieveByEmail(): void { - $customer = $this->_model->retrieveByEmail('customer@example.com', self::WEBSITE_ID); - $this->assertInstanceOf(\Magento\Customer\Model\Customer::class, $customer); - $this->assertEquals(self::CUSTOMER_EMAIL, $customer->getEmail()); + $email = 'customer@example.com'; + $customer = $this->model->retrieveByEmail($email, $this->defaultWebsiteId); + $this->assertInstanceOf(Customer::class, $customer); + $this->assertEquals($email, $customer->getEmail()); } /** * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoAppArea adminhtml + * + * @return void */ - public function testRetrieveCached() + public function testRetrieveCached(): void { - //Setup customer in the id and email registries - $customerBeforeDeletion = $this->_model->retrieve(self::CUSTOMER_ID); - //Delete the customer from db - Bootstrap::getObjectManager()->create( - \Magento\Customer\Model\Customer::class - )->load(self::CUSTOMER_ID)->delete(); - //Verify presence of Customer in registry - $this->assertEquals($customerBeforeDeletion, $this->_model->retrieve(self::CUSTOMER_ID)); - //Verify presence of Customer in email registry - $this->assertEquals($customerBeforeDeletion, $this->_model - ->retrieveByEmail(self::CUSTOMER_EMAIL, self::WEBSITE_ID)); + $customerId = 1; + $customerBeforeDeletion = $this->model->retrieve($customerId); + $this->customerResourceModel->load($customerBeforeDeletion, $customerBeforeDeletion->getId()); + $this->customerResourceModel->delete($customerBeforeDeletion); + $this->assertEquals($customerBeforeDeletion, $this->model->retrieve($customerId)); + $this->assertEquals($customerBeforeDeletion, $this->model + ->retrieveByEmail('customer@example.com', $this->defaultWebsiteId)); } /** - * @expectedException \Magento\Framework\Exception\NoSuchEntityException - * @expectedExceptionMessage No such entity with customerId = 1 + * @return void */ - public function testRetrieveException() + public function testRetrieveException(): void { - $this->_model->retrieve(self::CUSTOMER_ID); + $customerId = 1; + $this->expectException(NoSuchEntityException::class); + $this->expectExceptionMessage(sprintf('No such entity with customerId = %s', $customerId)); + $this->model->retrieve($customerId); } - public function testRetrieveEmailException() + /** + * @return void + */ + public function testRetrieveEmailException(): void { - try { - $this->_model->retrieveByEmail(self::CUSTOMER_EMAIL, self::WEBSITE_ID); - $this->fail("NoSuchEntityException was not thrown as expected."); - } catch (NoSuchEntityException $e) { - $expectedParams = [ - 'fieldName' => 'email', - 'fieldValue' => 'customer@example.com', - 'field2Name' => 'websiteId', - 'field2Value' => 1, - ]; - $this->assertEquals($expectedParams, $e->getParameters()); - } + $email = 'customer@example.com'; + $this->expectExceptionObject( + NoSuchEntityException::doubleField('email', $email, 'websiteId', $this->defaultWebsiteId) + ); + $this->model->retrieveByEmail($email, $this->defaultWebsiteId); } /** * @magentoDataFixture Magento/Customer/_files/customer.php - * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @magentoAppArea adminhtml + * + * @return void */ - public function testRemove() + public function testRemove(): void { - $customer = $this->_model->retrieve(self::CUSTOMER_ID); - $this->assertInstanceOf(\Magento\Customer\Model\Customer::class, $customer); - $customer->delete(); - $this->_model->remove(self::CUSTOMER_ID); - $this->_model->retrieve(self::CUSTOMER_ID); + $customerId = 1; + $customer = $this->model->retrieve($customerId); + $this->assertInstanceOf(Customer::class, $customer); + $this->customerResourceModel->delete($customer); + $this->model->remove($customerId); + $this->expectException(NoSuchEntityException::class); + $this->model->retrieve($customerId); } /** * @magentoDataFixture Magento/Customer/_files/customer.php - * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @magentoAppArea adminhtml + * + * @return void + */ + public function testRemoveByEmail(): void + { + $email = 'customer@example.com'; + $customer = $this->model->retrieve(1); + $this->assertInstanceOf(Customer::class, $customer); + $this->customerResourceModel->delete($customer); + $this->model->removeByEmail($email, $this->defaultWebsiteId); + $this->expectException(NoSuchEntityException::class); + $this->model->retrieveByEmail($email, $customer->getWebsiteId()); + } + + /** + * Test customer is available for all websites with global account scope config. + * + * @magentoConfigFixture current_store customer/account_share/scope 0 + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php + * + * @return void + */ + public function testRetrieveAccountInGlobalScope(): void + { + $email = 'customer@example.com'; + $websiteId = $this->storeManager->getWebsite('test')->getWebsiteId(); + $customer = $this->model->retrieveByEmail($email, $websiteId); + $this->assertEquals($email, $customer->getEmail()); + } + + /** + * Test customer is not available for second website with account scope config per websites. + * + * @magentoConfigFixture current_store customer/account_share/scope 1 + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php + * + * @return void */ - public function testRemoveByEmail() + public function testRetrieveAccountInWebsiteScope(): void { - $customer = $this->_model->retrieve(self::CUSTOMER_ID); - $this->assertInstanceOf(\Magento\Customer\Model\Customer::class, $customer); - $customer->delete(); - $this->_model->removeByEmail(self::CUSTOMER_EMAIL, self::WEBSITE_ID); - $this->_model->retrieveByEmail(self::CUSTOMER_EMAIL, $customer->getWebsiteId()); + $email = 'customer@example.com'; + $websiteId = $this->storeManager->getWebsite('test')->getWebsiteId(); + $this->expectExceptionObject( + NoSuchEntityException::doubleField('email', $email, 'websiteId', $websiteId) + ); + $this->model->retrieveByEmail($email, $websiteId); } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website.php new file mode 100644 index 0000000000000..c4df3e9fc8137 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website.php @@ -0,0 +1,40 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Customer\Api\AccountManagementInterface; +use Magento\Customer\Api\CustomerMetadataInterface; +use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Customer\Model\Data\CustomerFactory; +use Magento\Customer\Model\GroupManagement; +use Magento\Eav\Model\AttributeRepository; +use Magento\TestFramework\Helper\Bootstrap; + +require __DIR__ . '/../../../Magento/Store/_files/second_website_with_two_stores.php'; + +$objectManager = Bootstrap::getObjectManager(); +/** @var AccountManagementInterface $accountManagment */ +$accountManagment = $objectManager->get(AccountManagementInterface::class); +/** @var CustomerFactory $customerFactory */ +$customerFactory = $objectManager->get(CustomerFactory::class); +/** @var AttributeRepository $attributeRepository */ +$attributeRepository = $objectManager->get(AttributeRepository::class); +$gender = $attributeRepository->get(CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER, CustomerInterface::GENDER) + ->getSource()->getOptionId('Male'); +$defaultGroupId = $objectManager->get(GroupManagement::class)->getDefaultGroup($store->getStoreId())->getId(); + +$customer = $customerFactory->create(); +$customer->setWebsiteId($websiteId) + ->setEmail('customer@example.com') + ->setGroupId($defaultGroupId) + ->setStoreId($store->getStoreId()) + ->setFirstname('John') + ->setLastname('Smith') + ->setDefaultBilling(1) + ->setDefaultShipping(1) + ->setGender($gender); + +$accountManagment->createAccount($customer, 'Apassword1'); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website_rollback.php new file mode 100644 index 0000000000000..2d2bd7b4587d3 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_website_rollback.php @@ -0,0 +1,28 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\TestFramework\Helper\Bootstrap; + +require __DIR__ . '/../../../Magento/Store/_files/second_website_with_two_stores_rollback.php'; + +$objectManager = Bootstrap::getObjectManager(); +/** @var CustomerRepositoryInterface $customerRepository */ +$customerRepository = $objectManager->get(CustomerRepositoryInterface::class); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +try { + $customer = $customerRepository->get('customer@example.com', $websiteId); + $customerRepository->delete($customer); +} catch (NoSuchEntityException $e) { + //customer already deleted +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); From 7be2671585e2d294c2a2f6027f0bbee8f2e6a8d2 Mon Sep 17 00:00:00 2001 From: DmytroPaidych <dimonovp@gmail.com> Date: Tue, 24 Mar 2020 17:31:19 +0200 Subject: [PATCH 029/177] MC-32713: Admin: Customer force sign in --- .../Customer/InvalidateTokenTest.php | 79 +++++++++++++++++++ .../customer_with_integration_token.php | 15 ++++ ...stomer_with_integration_token_rollback.php | 8 ++ 3 files changed, 102 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Customer/InvalidateTokenTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Integration/_files/customer_with_integration_token.php create mode 100644 dev/tests/integration/testsuite/Magento/Integration/_files/customer_with_integration_token_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Customer/InvalidateTokenTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Customer/InvalidateTokenTest.php new file mode 100644 index 0000000000000..396824b44304d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Customer/InvalidateTokenTest.php @@ -0,0 +1,79 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Customer\Controller\Adminhtml\Customer; + +use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\Escaper; +use Magento\Framework\Message\MessageInterface; +use Magento\TestFramework\TestCase\AbstractBackendController; + +/** + * Invalidate customer token tests. + * + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ +class InvalidateTokenTest extends AbstractBackendController +{ + /** @var Escaper */ + private $escaper; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + + $this->escaper = $this->_objectManager->get(Escaper::class); + } + + /** + * @magentoDataFixture Magento/Integration/_files/customer_with_integration_token.php + * + * @return void + */ + public function testInvalidateCustomerToken(): void + { + $customerId = 1; + $this->getRequest()->setParam('customer_id', $customerId)->setMethod(HttpRequest::METHOD_GET); + $this->dispatch('backend/customer/customer/invalidateToken'); + $this->assertRedirect($this->stringContains('backend/customer/index/edit/id/' . $customerId)); + $message = $this->escaper->escapeHtml('You have revoked the customer\'s tokens.'); + $this->assertSessionMessages($this->equalTo([(string)__($message)]), MessageInterface::TYPE_SUCCESS); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * + * @return void + */ + public function testInvalidateCustomerWithoutToken(): void + { + $customerId = 1; + $this->getRequest()->setParam('customer_id', $customerId)->setMethod(HttpRequest::METHOD_GET); + $this->dispatch('backend/customer/customer/invalidateToken'); + $this->assertRedirect($this->stringContains('backend/customer/index/edit/id/' . $customerId)); + $this->assertSessionMessages( + $this->equalTo([(string)__('This customer has no tokens.')]), + MessageInterface::TYPE_ERROR + ); + } + + /** + * @return void + */ + public function testInvalidateCustomerTokenWithoutParams(): void + { + $this->getRequest()->setMethod(HttpRequest::METHOD_GET); + $this->dispatch('backend/customer/customer/invalidateToken'); + $this->assertRedirect($this->stringContains('backend/customer/index/index')); + $message = $this->escaper->escapeHtml('We can\'t find a customer to revoke.'); + $this->assertSessionMessages($this->equalTo([(string)__($message)]), MessageInterface::TYPE_ERROR); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Integration/_files/customer_with_integration_token.php b/dev/tests/integration/testsuite/Magento/Integration/_files/customer_with_integration_token.php new file mode 100644 index 0000000000000..68b9a72759d3f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/_files/customer_with_integration_token.php @@ -0,0 +1,15 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Integration\Api\CustomerTokenServiceInterface; + +require __DIR__ . '/../../../Magento/Customer/_files/customer.php'; + +/** @var CustomerTokenServiceInterface $customerTokenService */ +$customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class); + +$customerTokenService->createCustomerAccessToken($customer->getEmail(), $customer->getPassword()); diff --git a/dev/tests/integration/testsuite/Magento/Integration/_files/customer_with_integration_token_rollback.php b/dev/tests/integration/testsuite/Magento/Integration/_files/customer_with_integration_token_rollback.php new file mode 100644 index 0000000000000..768b6f25cb747 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Integration/_files/customer_with_integration_token_rollback.php @@ -0,0 +1,8 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +require __DIR__ . '/../../../Magento/Customer/_files/customer_rollback.php'; From e5d980d751b04c7e3a8cd107c1be17308fee59f1 Mon Sep 17 00:00:00 2001 From: DianaRusin <rusind95@gmail.com> Date: Tue, 24 Mar 2020 18:32:34 +0200 Subject: [PATCH 030/177] MC-32697: [2.4] AbstractSimpleObjectBuilder.php throws exception when Interceptor instance comes. --- .../Magento/Framework/Api/AbstractSimpleObjectBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php b/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php index d34e5a0bf6d66..cf0a887249049 100644 --- a/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php +++ b/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php @@ -64,7 +64,7 @@ protected function _set($key, $value) * * @return string */ - protected function _getDataObjectType(): string + protected function _getDataObjectType() { $currentClass = get_class($this); $suffix = 'Builder'; From e7a9a53b2d44b9d99e102795a6cd5ae4f78902f2 Mon Sep 17 00:00:00 2001 From: DmytroPaidych <dimonovp@gmail.com> Date: Wed, 25 Mar 2020 10:31:59 +0200 Subject: [PATCH 031/177] MC-32700: Storefront: Order view in customer profile --- .../Block/Order/Creditmemo/ItemsTest.php | 243 +++++++++++++++--- .../Block/Order/Creditmemo/TotalsTest.php | 97 +++++++ .../Magento/Sales/Block/Order/HistoryTest.php | 177 +++++++++++++ .../Sales/Block/Order/Info/ButtonsTest.php | 115 +++++++++ .../Magento/Sales/Block/Order/InfoTest.php | 172 +++++++++++++ .../Sales/Block/Order/Invoice/ItemsTest.php | 239 ++++++++++++++--- .../Sales/Block/Order/Invoice/TotalsTest.php | 97 +++++++ .../Item/Renderer/DefaultRendererTest.php | 111 ++++++++ .../Magento/Sales/Block/Order/ItemsTest.php | 221 +++++++++++----- .../Magento/Sales/Block/Order/TotalsTest.php | 129 ++++++++-- .../_files/customer_order_with_two_items.php | 96 +++++++ ...customer_order_with_two_items_rollback.php | 29 +++ .../Sales/_files/invoices_for_items.php | 23 ++ .../_files/invoices_for_items_rollback.php | 8 + .../Sales/_files/refunds_for_items.php | 23 ++ .../_files/refunds_for_items_rollback.php | 8 + 16 files changed, 1631 insertions(+), 157 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Block/Order/Creditmemo/TotalsTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Block/Order/HistoryTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Block/Order/Info/ButtonsTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Block/Order/InfoTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Block/Order/Invoice/TotalsTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Block/Order/Item/Renderer/DefaultRendererTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_two_items.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_two_items_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/invoices_for_items.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/invoices_for_items_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/refunds_for_items.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/refunds_for_items_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Creditmemo/ItemsTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Creditmemo/ItemsTest.php index f130c788a65db..318a07127767d 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Creditmemo/ItemsTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Creditmemo/ItemsTest.php @@ -3,74 +3,249 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Sales\Block\Order\Creditmemo; -class ItemsTest extends \PHPUnit\Framework\TestCase +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Registry; +use Magento\Framework\View\Element\Text; +use Magento\Framework\View\LayoutInterface; +use Magento\Framework\View\Result\PageFactory; +use Magento\Sales\Api\Data\CreditmemoInterface; +use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + +/** + * Tests for view creditmemo items block. + * + * @magentoAppArea frontend + * @magentoDbIsolation enabled + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class ItemsTest extends TestCase { - /** - * @var \Magento\Framework\View\LayoutInterface - */ - protected $_layout; + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var LayoutInterface */ + private $layout; + + /** @var Items */ + private $block; + + /** @var CreditmemoInterface */ + private $creditmemo; + + /** @var Registry */ + private $registry; + + /** @var OrderInterfaceFactory */ + private $orderFactory; + + /** @var PageFactory */ + private $pageFactory; /** - * @var \Magento\Sales\Block\Order\Creditmemo\Items + * @inheritdoc */ - protected $_block; + protected function setUp() + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->layout = $this->objectManager->get(LayoutInterface::class); + $this->block = $this->layout->createBlock(Items::class, 'block'); + $this->creditmemo = $this->objectManager->get(CreditmemoInterface::class); + $this->registry = $this->objectManager->get(Registry::class); + $this->orderFactory = $this->objectManager->get(OrderInterfaceFactory::class); + $this->pageFactory = $this->objectManager->get(PageFactory::class); + } /** - * @var \Magento\Sales\Model\Order\Creditmemo + * @inheritdoc */ - protected $_creditmemo; - - protected function setUp() + protected function tearDown() { - $this->_layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - \Magento\Framework\View\LayoutInterface::class - ); - $this->_block = $this->_layout->createBlock(\Magento\Sales\Block\Order\Creditmemo\Items::class, 'block'); - $this->_creditmemo = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Sales\Model\Order\Creditmemo::class - ); + $this->registry->unregister('current_order'); + + parent::tearDown(); } /** * @magentoAppIsolation enabled + * + * @return void */ - public function testGetTotalsHtml() + public function testGetTotalsHtml(): void { - $childBlock = $this->_layout->addBlock( - \Magento\Framework\View\Element\Text::class, + $childBlock = $this->layout->addBlock( + Text::class, 'creditmemo_totals', 'block' ); - $expectedHtml = '<b>Any html</b>'; $this->assertEmpty($childBlock->getCreditmemo()); - $this->assertNotEquals($expectedHtml, $this->_block->getTotalsHtml($this->_creditmemo)); - + $this->assertNotEquals($expectedHtml, $this->block->getTotalsHtml($this->creditmemo)); $childBlock->setText($expectedHtml); - $actualHtml = $this->_block->getTotalsHtml($this->_creditmemo); - $this->assertSame($this->_creditmemo, $childBlock->getCreditmemo()); + $actualHtml = $this->block->getTotalsHtml($this->creditmemo); + $this->assertSame($this->creditmemo, $childBlock->getCreditmemo()); $this->assertEquals($expectedHtml, $actualHtml); } - public function testGetCommentsHtml() + /** + * @magentoAppIsolation enabled + * + * @return void + */ + public function testGetCommentsHtml(): void { - $childBlock = $this->_layout->addBlock( - \Magento\Framework\View\Element\Text::class, + $childBlock = $this->layout->addBlock( + Text::class, 'creditmemo_comments', 'block' ); - $expectedHtml = '<b>Any html</b>'; $this->assertEmpty($childBlock->getEntity()); $this->assertEmpty($childBlock->getTitle()); - $this->assertNotEquals($expectedHtml, $this->_block->getCommentsHtml($this->_creditmemo)); - + $this->assertNotEquals($expectedHtml, $this->block->getCommentsHtml($this->creditmemo)); $childBlock->setText($expectedHtml); - $actualHtml = $this->_block->getCommentsHtml($this->_creditmemo); - $this->assertSame($this->_creditmemo, $childBlock->getEntity()); + $actualHtml = $this->block->getCommentsHtml($this->creditmemo); + $this->assertSame($this->creditmemo, $childBlock->getEntity()); $this->assertNotEmpty($childBlock->getTitle()); $this->assertEquals($expectedHtml, $actualHtml); } + + /** + * @magentoDataFixture Magento/Sales/_files/refunds_for_items.php + * + * @return void + */ + public function testDisplayingCreditmemos(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000555'); + $this->registerOrder($order); + $blockHtml = $this->renderCreditmemoItemsBlock(); + $this->assertCreditmemosBlock($order, $blockHtml); + } + + /** + * Assert creditmemos block. + * + * @param OrderInterface $order + * @param string $blockHtml + * @return void + */ + private function assertCreditmemosBlock(OrderInterface $order, string $blockHtml): void + { + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//a[contains(@href, 'sales/order/printCreditmemo/order_id/%s')]/span[contains(text(), '%s')]", + $order->getId(), + __('Print All Refunds') + ), + $blockHtml + ), + sprintf('%s button was not found.', __('Print All Refunds')) + ); + $this->assertNotCount(0, $order->getCreditmemosCollection(), 'Creditmemos collection is empty'); + foreach ($order->getCreditmemosCollection() as $creditmemo) { + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//div[contains(@class, 'order-title')]/strong[contains(text(), '%s')]", + __('Refund #') . $creditmemo->getIncrementId() + ), + $blockHtml + ), + sprintf('Title for %s was not found.', __('Refund #') . $creditmemo->getIncrementId()) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//a[contains(@href, 'sales/order/printCreditmemo/creditmemo_id/%s')]" + . "/span[contains(text(), '%s')]", + $creditmemo->getId(), + __('Print Refund') + ), + $blockHtml + ), + sprintf('%s button for #%s was not found.', __('Print Refund'), $creditmemo->getIncrementId()) + ); + $this->assertCreditmemoItems($creditmemo, $blockHtml); + } + } + + /** + * Assert creditmemo items list. + * + * @param CreditmemoInterface $creditmemo + * @param string $html + * @return void + */ + private function assertCreditmemoItems(CreditmemoInterface $creditmemo, string $html): void + { + $this->assertNotCount(0, $creditmemo->getItemsCollection(), 'Creditmemo items collection is empty'); + $fieldsToCheck = [ + 'name' => "/td[contains(@class, 'name')]/strong[contains(text(), '%s')]", + 'sku' => "/td[contains(@class, 'sku') and contains(text(), '%s')]", + 'price' => "/td[contains(@class, 'price')]//span[contains(text(), '%01.2f')]", + 'qty' => "/td[contains(@class, 'qty') and contains(text(), '%d')]", + 'row_total' => "/td[contains(@class, 'subtotal')]//span[contains(text(), '%01.2f')]", + 'discount_amount' => "/td[contains(@class, 'discount')]/span[contains(text(), '%01.2f')]", + ]; + foreach ($creditmemo->getItemsCollection() as $item) { + $rowXpath = sprintf( + "//table[@id='my-refund-table-%s']//tr[@id='order-item-row-%s']", + $creditmemo->getId(), + $item->getId() + ); + foreach ($fieldsToCheck as $key => $xpath) { + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath(sprintf($rowXpath . $xpath, $item->getData($key)), $html), + sprintf('Item %s wasn\'t found or not equals to %s.', $key, $item->getData($key)) + ); + } + } + } + + /** + * Render creditmemo items block. + * + * @return string + */ + private function renderCreditmemoItemsBlock(): string + { + $page = $this->pageFactory->create(); + $page->addHandle([ + 'default', + 'sales_order_creditmemo', + ]); + $page->getLayout()->generateXml(); + $creditmemoItemsBlock = $page->getLayout()->getBlock('creditmemo_items')->unsetChild('creditmemo_totals'); + $creditmemoItemsBlock->getRequest()->setRouteName('sales')->setControllerName('order') + ->setActionName('creditmemo'); + + return $creditmemoItemsBlock->toHtml(); + } + + /** + * Register order in registry. + * + * @param OrderInterface $order + * @return void + */ + private function registerOrder(OrderInterface $order): void + { + $this->registry->unregister('current_order'); + $this->registry->register('current_order', $order); + } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Creditmemo/TotalsTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Creditmemo/TotalsTest.php new file mode 100644 index 0000000000000..a88b2d3a5f0df --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Creditmemo/TotalsTest.php @@ -0,0 +1,97 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Block\Order\Creditmemo; + +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\LayoutInterface; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + +/** + * Tests for view creditmemo totals block. + * + * @magentoAppArea frontend + * @magentoDbIsolation enabled + */ +class TotalsTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Totals */ + private $block; + + /** @var OrderInterfaceFactory */ + private $orderFactory; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Totals::class) + ->setTemplate('Magento_Sales::order/totals.phtml'); + $this->orderFactory = $this->objectManager->get(OrderInterfaceFactory::class); + } + + /** + * @magentoDataFixture Magento/Sales/_files/refunds_for_items.php + * + * @return void + */ + public function testCreditmemoTotalsBlock(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000555'); + $creditmemo = $order->getCreditmemosCollection()->getFirstItem(); + $this->assertNotNull($creditmemo->getId()); + $blockHtml = $this->block->setOrder($order)->setCreditmemo($creditmemo)->toHtml(); + $message = '"%s" for creditmemo wasn\'t found or not equals to %01.2f'; + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//th[contains(text(), '%s')]/following-sibling::td/span[contains(text(), '%01.2f')]", + __('Subtotal'), + $creditmemo->getSubtotal() + ), + $blockHtml + ), + sprintf($message, __('Subtotal'), $creditmemo->getSubtotal()) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//th[contains(text(), '%s')]/following-sibling::td/span[contains(text(), '%01.2f')]", + __('Shipping & Handling'), + $creditmemo->getShippingAmount() + ), + $blockHtml + ), + sprintf($message, __('Shipping & Handling'), $creditmemo->getShippingAmount()) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//tr[contains(@class, 'grand_total') and contains(.//strong, '%s')]" + . "//span[contains(text(), '%01.2f')]", + __('Grand Total'), + $creditmemo->getGrandTotal() + ), + $blockHtml + ), + sprintf($message, __('Grand Total'), $creditmemo->getGrandTotal()) + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/HistoryTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/HistoryTest.php new file mode 100644 index 0000000000000..d7e342c096dc9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/HistoryTest.php @@ -0,0 +1,177 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Block\Order; + +use Magento\Customer\Model\Session; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\LayoutInterface; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + +/** + * Tests for customer order grid. + * + * @magentoAppArea frontend + * @magentoDbIsolation enabled + */ +class HistoryTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Session */ + private $customerSession; + + /** @var History */ + private $block; + + /** @var OrderInterfaceFactory */ + private $orderFactory; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->customerSession = $this->objectManager->get(Session::class); + $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(History::class); + $this->orderFactory = $this->objectManager->get(OrderInterfaceFactory::class); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + $this->customerSession->logout(); + + parent::tearDown(); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * + * @return void + */ + public function testCustomerOrderGridWithoutOrders(): void + { + $this->customerSession->loginById(1); + $this->assertContains((string)$this->block->getEmptyOrdersMessage(), strip_tags($this->block->toHtml())); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order_with_customer.php + * + * @return void + */ + public function testCustomerOrderGridWithOrder(): void + { + $this->customerSession->loginById(1); + $this->assertCustomerOrderGrid(['100000001'], $this->block->toHtml()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Sales/_files/orders_with_customer.php + * + * @return void + */ + public function testCustomerOrderGridWithSomeOrders(): void + { + $this->customerSession->loginById(1); + $ordersToCheck = ['100000002', '100000003', '100000004', '100000005', '100000006']; + $this->assertCustomerOrderGrid($ordersToCheck, $this->block->toHtml()); + } + + /** + * Assert customer order grid. + * + * @param array $ordersToCheck + * @param string $blockHtml + * @return void + */ + private function assertCustomerOrderGrid(array $ordersToCheck, string $blockHtml): void + { + foreach ($ordersToCheck as $orderIncrementId) { + $order = $this->orderFactory->create()->loadByIncrementId($orderIncrementId); + $rowXpath = sprintf("//td[contains(@class,'id') and contains(text(), '%s')]", $order->getRealOrderId()); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + $rowXpath . "/following-sibling::td[contains(@class, 'date') and contains(text(), '%s')]", + $this->block->formatDate($order->getCreatedAt()) + ), + $blockHtml + ), + sprintf('Created date for order #%s wasn\'t found in row.', $orderIncrementId) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + $rowXpath . "/following-sibling::td[contains(@class, 'total')]/span[contains(text(), '%s')]", + $order->getTotal() + ), + $blockHtml + ), + sprintf( + 'Order Totals for order #%s wasn\'t found or not equal to "%s" in row.', + $orderIncrementId, + $order->getTotal() + ) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + $rowXpath . "/following-sibling::td[contains(@class, 'status') and contains(text(), '%s')]", + $order->getStatusLabel() + ), + $blockHtml + ), + sprintf( + 'Order status for order #%s wasn\'t found or not equal to "%s" in row.', + $orderIncrementId, + $order->getStatusLabel() + ) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + $rowXpath . "/following-sibling::td/a[contains(@href, 'sales/order/view/order_id/%s')]" + . "/span[contains(text(), '%s')]", + $order->getId(), + __('View Order') + ), + $blockHtml + ), + sprintf('View order button for order #%s wasn\'t found.', $orderIncrementId) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + $rowXpath . "/following-sibling::td/a[contains(@data-post," + . "'sales\/order\/reorder\/order_id\/%s')]/span[contains(text(), '%s')]", + $order->getId(), + __('Reorder') + ), + $blockHtml + ), + sprintf('Reorder button for order #%s wasn\'t found.', $orderIncrementId) + ); + } + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Info/ButtonsTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Info/ButtonsTest.php new file mode 100644 index 0000000000000..676415629fdc9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Info/ButtonsTest.php @@ -0,0 +1,115 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Block\Order\Info; + +use Magento\Customer\Model\Session; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Registry; +use Magento\Framework\View\LayoutInterface; +use Magento\Sales\Api\Data\OrderInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + +/** + * Test for order action buttons. + * + * @magentoAppArea frontend + * @magentoDbIsolation enabled + */ +class ButtonsTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Registry */ + private $registry; + + /** @var Session */ + private $customerSession; + + /** @var OrderInterface */ + private $order; + + /** @var Buttons */ + private $block; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->registry = $this->objectManager->get(Registry::class); + $this->customerSession = $this->objectManager->get(Session::class); + $this->order = $this->objectManager->get(OrderInterface::class); + $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Buttons::class); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + $this->registry->unregister('current_order'); + $this->customerSession->logout(); + + parent::tearDown(); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order_with_customer.php + * + * @return void + */ + public function testDisplayingOrderActionButtons(): void + { + $this->customerSession->loginById(1); + $order = $this->order->loadByIncrementId('100000001'); + $this->registerOrder($order); + $blockHtml = $this->block->toHtml(); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//a[contains(@data-post, 'sales\/order\/reorder\/order_id\/%s')]/span[contains(text(), '%s')]", + $order->getId(), + __('Reorder') + ), + $blockHtml + ), + sprintf('%s button wasn\'t found.', __('Reorder')) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//a[contains(@href, 'sales/order/print/order_id/%s')]/span[contains(text(), '%s')]", + $order->getId(), + __('Print Order') + ), + $blockHtml + ), + sprintf('%s button wasn\'t found.', __('Print Order')) + ); + } + + /** + * Register order in registry. + * + * @param OrderInterface $order + * @return void + */ + private function registerOrder(OrderInterface $order): void + { + $this->registry->unregister('current_order'); + $this->registry->register('current_order', $order); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/InfoTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/InfoTest.php new file mode 100644 index 0000000000000..1b84db76869e3 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/InfoTest.php @@ -0,0 +1,172 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Block\Order; + +use Magento\Directory\Model\CountryFactory; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Registry; +use Magento\Framework\View\LayoutInterface; +use Magento\Sales\Api\Data\OrderAddressInterface; +use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + +/** + * Tests for order info block. + * + * @magentoAppArea frontend + * @magentoDbIsolation enabled + */ +class InfoTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Registry */ + private $registry; + + /** @var LayoutInterface */ + private $layout; + + /** @var OrderInterfaceFactory */ + private $orderFactory; + + /** @var CountryFactory */ + private $countryFactory; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->registry = $this->objectManager->get(Registry::class); + $this->layout = $this->objectManager->get(LayoutInterface::class); + $this->orderFactory = $this->objectManager->get(OrderInterfaceFactory::class); + $this->countryFactory = $this->objectManager->get(CountryFactory::class); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + $this->registry->unregister('current_order'); + + parent::tearDown(); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order_with_customer.php + * + * @return void + */ + public function testOrderStatus(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $this->registerOrder($order); + $block = $this->layout->createBlock(Info::class)->setTemplate('Magento_Sales::order/order_status.phtml'); + $this->assertContains((string)__($order->getStatusLabel()), strip_tags($block->toHtml())); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order_with_customer.php + * + * @return void + */ + public function testOrderDate(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $this->registerOrder($order); + $block = $this->layout->createBlock(Info::class)->setTemplate('Magento_Sales::order/order_date.phtml'); + $this->assertContains( + (string)__('Order Date: %1', $block->formatDate($order->getCreatedAt(), \IntlDateFormatter::LONG)), + strip_tags($block->toHtml()) + ); + } + + /** + * @magentoDataFixture Magento/Sales/_files/customer_order_with_two_items.php + * + * @return void + */ + public function testOrderInformation(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000555'); + $this->registerOrder($order); + $blockHtml = $this->layout->createBlock(Info::class)->toHtml(); + $this->assertOrderAddress($order->getShippingAddress(), $blockHtml); + $this->assertOrderAddress($order->getBillingAddress(), $blockHtml); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//div[contains(@class, 'box-order-shipping-method') and contains(.//span, '%s')]" + . "//div[contains(text(), '%s')]", + __('Shipping Method'), + $order->getShippingDescription() + ), + $blockHtml + ), + 'Shipping method for order wasn\'t found.' + ); + } + + /** + * Assert order address. + * + * @param OrderAddressInterface $address + * @param string $html + * @return void + */ + private function assertOrderAddress(OrderAddressInterface $address, string $html): void + { + $addressBoxXpath = sprintf("//div[contains(@class, 'box-order-%s-address')]", $address->getAddressType()) + . "//address[contains(., '%s')]"; + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath(sprintf($addressBoxXpath, $address->getName()), $html), + sprintf('Customer name for %s address wasn\'t found.', $address->getAddressType()) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + $addressBoxXpath, + $this->countryFactory->create()->loadByCode($address->getData('country_id'))->getName() + ), + $html + ), + sprintf('Country for %s address wasn\'t found.', $address->getAddressType()) + ); + $attributes = ['company', 'street', 'city', 'region', 'postcode', 'telephone']; + foreach ($attributes as $key) { + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath(sprintf($addressBoxXpath, $address->getData($key)), $html), + sprintf('%s for %s address wasn\'t found.', $key, $address->getAddressType()) + ); + } + } + + /** + * Register order in registry. + * + * @param OrderInterface $order + * @return void + */ + private function registerOrder(OrderInterface $order): void + { + $this->registry->unregister('current_order'); + $this->registry->register('current_order', $order); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Invoice/ItemsTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Invoice/ItemsTest.php index cfb97ee4298ec..bf13d5a296eee 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Invoice/ItemsTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Invoice/ItemsTest.php @@ -3,70 +3,243 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Sales\Block\Order\Invoice; -class ItemsTest extends \PHPUnit\Framework\TestCase +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Registry; +use Magento\Framework\View\Element\Text; +use Magento\Framework\View\LayoutInterface; +use Magento\Framework\View\Result\PageFactory; +use Magento\Sales\Api\Data\InvoiceInterface; +use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\Sales\Api\Data\InvoiceInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + +/** + * Tests for view invoice items block. + * + * @magentoAppArea frontend + * @magentoDbIsolation enabled + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class ItemsTest extends TestCase { - /** - * @var \Magento\Framework\View\LayoutInterface - */ - protected $_layout; + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Registry */ + private $registry; + + /** @var LayoutInterface */ + private $layout; + + /** @var Items */ + private $block; + + /** @var InvoiceInterfaceFactory */ + private $invoiceFactory; + + /** @var OrderInterfaceFactory */ + private $orderFactory; + + /** @var PageFactory */ + private $pageFactory; /** - * @var \Magento\Sales\Block\Order\Invoice\Items + * @inheritdoc */ - protected $_block; + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + $this->registry = $this->objectManager->get(Registry::class); + $this->layout = $this->objectManager->get(LayoutInterface::class); + $this->block = $this->layout->createBlock(Items::class, 'block'); + $this->invoiceFactory = $this->objectManager->get(InvoiceInterfaceFactory::class); + $this->orderFactory = $this->objectManager->get(OrderInterfaceFactory::class); + $this->pageFactory = $this->objectManager->get(PageFactory::class); + } /** - * @var \Magento\Sales\Model\Order\Invoice + * @inheritdoc */ - protected $_invoice; - - protected function setUp() + protected function tearDown() { - $this->_layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - \Magento\Framework\View\LayoutInterface::class - ); - $this->_block = $this->_layout->createBlock(\Magento\Sales\Block\Order\Invoice\Items::class, 'block'); - $this->_invoice = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Sales\Model\Order\Invoice::class - ); + $this->registry->unregister('current_order'); + + parent::tearDown(); } /** * @magentoAppIsolation enabled + * + * @return void */ - public function testGetInvoiceTotalsHtml() + public function testGetInvoiceTotalsHtml(): void { - $childBlock = $this->_layout->addBlock(\Magento\Framework\View\Element\Text::class, 'invoice_totals', 'block'); - + $childBlock = $this->layout->addBlock(Text::class, 'invoice_totals', 'block'); $expectedHtml = '<b>Any html</b>'; $this->assertEmpty($childBlock->getInvoice()); - $this->assertNotEquals($expectedHtml, $this->_block->getInvoiceTotalsHtml($this->_invoice)); - + $invoice = $this->invoiceFactory->create(); + $this->assertNotEquals($expectedHtml, $this->block->getInvoiceTotalsHtml($invoice)); $childBlock->setText($expectedHtml); - $actualHtml = $this->_block->getInvoiceTotalsHtml($this->_invoice); - $this->assertSame($this->_invoice, $childBlock->getInvoice()); + $actualHtml = $this->block->getInvoiceTotalsHtml($invoice); + $this->assertSame($invoice, $childBlock->getInvoice()); $this->assertEquals($expectedHtml, $actualHtml); } - public function testGetInvoiceCommentsHtml() + /** + * @magentoAppIsolation enabled + * + * @return void + */ + public function testGetInvoiceCommentsHtml(): void { - $childBlock = $this->_layout->addBlock( - \Magento\Framework\View\Element\Text::class, + $childBlock = $this->layout->addBlock( + Text::class, 'invoice_comments', 'block' ); - $expectedHtml = '<b>Any html</b>'; $this->assertEmpty($childBlock->getEntity()); $this->assertEmpty($childBlock->getTitle()); - $this->assertNotEquals($expectedHtml, $this->_block->getInvoiceCommentsHtml($this->_invoice)); - + $invoice = $this->invoiceFactory->create(); + $this->assertNotEquals($expectedHtml, $this->block->getInvoiceCommentsHtml($invoice)); $childBlock->setText($expectedHtml); - $actualHtml = $this->_block->getInvoiceCommentsHtml($this->_invoice); - $this->assertSame($this->_invoice, $childBlock->getEntity()); + $actualHtml = $this->block->getInvoiceCommentsHtml($invoice); + $this->assertSame($invoice, $childBlock->getEntity()); $this->assertNotEmpty($childBlock->getTitle()); $this->assertEquals($expectedHtml, $actualHtml); } + + /** + * @magentoDataFixture Magento/Sales/_files/invoices_for_items.php + * + * @return void + */ + public function testDisplayingInvoices(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000555'); + $this->registerOrder($order); + $blockHtml = $this->renderInvoiceItemsBlock(); + $this->assertInvoicesBlock($order, $blockHtml); + } + + /** + * Assert invoices block. + * + * @param OrderInterface $order + * @param string $blockHtml + * @return void + */ + private function assertInvoicesBlock(OrderInterface $order, string $blockHtml): void + { + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//a[contains(@href, 'sales/order/printInvoice/order_id/%s')]/span[contains(text(), '%s')]", + $order->getId(), + __('Print All Invoices') + ), + $blockHtml + ), + sprintf('%s button was not found.', __('Print All Invoices')) + ); + $this->assertNotCount(0, $order->getInvoiceCollection(), 'Invoice collection is empty'); + foreach ($order->getInvoiceCollection() as $invoice) { + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//div[contains(@class, 'order-title')]/strong[contains(text(), '%s')]", + __('Invoice #') . $invoice->getIncrementId() + ), + $blockHtml + ), + sprintf('Title for %s was not found.', __('Invoice #') . $invoice->getIncrementId()) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//a[contains(@href, 'sales/order/printInvoice/invoice_id/%s')]/span[contains(text(), '%s')]", + $invoice->getId(), + __('Print Invoice') + ), + $blockHtml + ), + sprintf('%s button for #%s was not found.', __('Print Invoice'), $invoice->getIncrementId()) + ); + $this->assertInvoiceItems($invoice, $blockHtml); + } + } + + /** + * Assert invoice items list. + * + * @param InvoiceInterface $invoice + * @param string $blockHtml + * @return void + */ + private function assertInvoiceItems(InvoiceInterface $invoice, string $blockHtml): void + { + $this->assertNotCount(0, $invoice->getItemsCollection(), 'Invoice items collection is empty'); + $fieldsToCheck = [ + 'name' => "/td[contains(@class, 'name')]/strong[contains(text(), '%s')]", + 'sku' => "/td[contains(@class, 'sku') and contains(text(), '%s')]", + 'price' => "/td[contains(@class, 'price')]//span[contains(text(), '%01.2f')]", + 'qty' => "/td[contains(@class, 'qty')]/span[contains(text(), '%d')]", + 'row_total' => "/td[contains(@class, 'subtotal')]//span[contains(text(), '%01.2f')]", + ]; + foreach ($invoice->getItemsCollection() as $item) { + $itemRowXpath = sprintf( + "//table[@id='my-invoice-table-%s']//tr[@id='order-item-row-%s']", + $invoice->getId(), + $item->getId() + ); + foreach ($fieldsToCheck as $key => $xpath) { + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath(sprintf($itemRowXpath . $xpath, $item->getData($key)), $blockHtml), + sprintf('Item %s wasn\'t found or not equals to %s.', $key, $item->getData($key)) + ); + } + } + } + + /** + * Render invoice items block. + * + * @return string + */ + private function renderInvoiceItemsBlock(): string + { + $page = $this->pageFactory->create(); + $page->addHandle([ + 'default', + 'sales_order_invoice', + ]); + $page->getLayout()->generateXml(); + $invoiceItemsBlock = $page->getLayout()->getBlock('invoice_items')->unsetChild('invoice_totals'); + $invoiceItemsBlock->getRequest()->setRouteName('sales')->setControllerName('order')->setActionName('invoice'); + + return $invoiceItemsBlock->toHtml(); + } + + /** + * Register order in registry. + * + * @param OrderInterface $order + * @return void + */ + private function registerOrder(OrderInterface $order): void + { + $this->registry->unregister('current_order'); + $this->registry->register('current_order', $order); + } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Invoice/TotalsTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Invoice/TotalsTest.php new file mode 100644 index 0000000000000..1fe7e02833a2f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Invoice/TotalsTest.php @@ -0,0 +1,97 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Block\Order\Invoice; + +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\LayoutInterface; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + +/** + * Tests for view invoice totals block. + * + * @magentoAppArea frontend + * @magentoDbIsolation enabled + */ +class TotalsTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Totals */ + private $block; + + /** @var OrderInterfaceFactory */ + private $orderFactory; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Totals::class) + ->setTemplate('Magento_Sales::order/totals.phtml'); + $this->orderFactory = $this->objectManager->get(OrderInterfaceFactory::class); + } + + /** + * @magentoDataFixture Magento/Sales/_files/invoices_for_items.php + * + * @return void + */ + public function testInvoiceTotalsBlock(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000555'); + $invoice = $order->getInvoiceCollection()->getFirstItem(); + $this->assertNotNull($invoice->getId()); + $blockHtml = $this->block->setOrder($order)->setInvoice($invoice)->toHtml(); + $message = '"%s" for invoice wasn\'t found or not equals to %01.2f'; + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//th[contains(text(), '%s')]/following-sibling::td/span[contains(text(), '%01.2f')]", + __('Subtotal'), + $invoice->getSubtotal() + ), + $blockHtml + ), + sprintf($message, __('Subtotal'), $invoice->getSubtotal()) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//th[contains(text(), '%s')]/following-sibling::td/span[contains(text(), '%01.2f')]", + __('Shipping & Handling'), + $invoice->getShippingAmount() + ), + $blockHtml + ), + sprintf($message, __('Shipping & Handling'), $invoice->getShippingAmount()) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//tr[contains(@class, 'grand_total') and contains(.//strong, '%s')]" + . "//span[contains(text(), '%01.2f')]", + __('Grand Total'), + $invoice->getGrandTotal() + ), + $blockHtml + ), + sprintf($message, __('Grand Total'), $invoice->getGrandTotal()) + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Item/Renderer/DefaultRendererTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Item/Renderer/DefaultRendererTest.php new file mode 100644 index 0000000000000..147efc2cd6c78 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/Item/Renderer/DefaultRendererTest.php @@ -0,0 +1,111 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Block\Order\Item\Renderer; + +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\LayoutInterface; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + +/** + * Tests for default renderer order items. + * + * @magentoAppArea frontend + * @magentoDbIsolation enabled + */ +class DefaultRendererTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var DefaultRenderer */ + private $block; + + /** @var OrderInterfaceFactory */ + private $orderFactory; + + /** + * @inheritdoc + */ + protected function setUp() + { + $this->objectManager = Bootstrap::getObjectManager(); + $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(DefaultRenderer::class); + $this->orderFactory = $this->objectManager->get(OrderInterfaceFactory::class); + } + + /** + * @magentoDataFixture Magento/Sales/_files/shipment_for_order_with_customer.php + * + * @return void + */ + public function testDisplayingShipmentItem(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $shipment = $order->getShipmentsCollection()->getFirstItem(); + $this->assertNotNull($shipment->getId()); + $item = $shipment->getAllItems()[0] ?? null; + $this->assertNotNull($item); + $blockHtml = $this->block->setTemplate('Magento_Sales::order/shipment/items/renderer/default.phtml') + ->setItem($item)->toHtml(); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//td[contains(@class, 'name')]/strong[contains(text(), '%s')]", + $item->getName() + ), + $blockHtml + ), + sprintf('Item with name %s wasn\'t found.', $item->getName()) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//td[contains(@class, 'sku') and contains(text(), '%s')]", + $item->getSku() + ), + $blockHtml + ), + sprintf('Item with sku %s wasn\'t found.', $item->getSku()) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//td[contains(@class, 'qty') and contains(text(), '%d')]", + $item->getQty() + ), + $blockHtml + ), + sprintf( + 'Qty for item %s wasn\'t found or not equals to %s.', + $item->getName(), + $item->getQty() + ) + ); + } + + /** + * @magentoDataFixture Magento/Sales/_files/refunds_for_items.php + * + * @return void + */ + public function testCreditmemoItemTotalAmount(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000555'); + $creditmemo = $order->getCreditmemosCollection()->getFirstItem(); + $this->assertNotNull($creditmemo->getId()); + $item = $creditmemo->getItemsCollection()->getFirstItem(); + $this->assertNotNull($item->getId()); + $this->assertEquals(10.00, $this->block->getTotalAmount($item)); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/ItemsTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/ItemsTest.php index 4c7b202fc1351..cb211b343cf0d 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/ItemsTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/ItemsTest.php @@ -3,133 +3,228 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Sales\Block\Order; -class ItemsTest extends \PHPUnit\Framework\TestCase +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Registry; +use Magento\Framework\View\LayoutInterface; +use Magento\Framework\View\Result\PageFactory; +use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\Sales\Model\ResourceModel\Order\Item\Collection; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use Magento\Theme\Block\Html\Pager; +use PHPUnit\Framework\TestCase; + +/** + * Tests order items block. + * + * @magentoAppArea frontend + * @magentoDbIsolation enabled + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class ItemsTest extends TestCase { - /** - * @var \Magento\Sales\Block\Order\Items - */ - private $model; + /** @var Items */ + private $block; - /** - * @var \Magento\Framework\View\LayoutInterface - */ + /** @var LayoutInterface */ private $layout; - /** - * @var \Magento\Framework\ObjectManagerInterface - */ + /** @var ObjectManagerInterface */ private $objectManager; - /** - * @var \Magento\Framework\Registry - */ + /** @var Registry */ private $registry; + /** @var OrderInterfaceFactory */ + private $orderFactory; + + /** @var PageFactory */ + private $pageFactory; + + /** + * @inheritdoc + */ protected function setUp() { - $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->layout = $this->objectManager->get(\Magento\Framework\View\LayoutInterface::class); - $this->registry = $this->objectManager->get(\Magento\Framework\Registry::class); + $this->objectManager = Bootstrap::getObjectManager(); + $this->layout = $this->objectManager->get(LayoutInterface::class); + $this->registry = $this->objectManager->get(Registry::class); + $this->orderFactory = $this->objectManager->get(OrderInterfaceFactory::class); + $this->pageFactory = $this->objectManager->get(PageFactory::class); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + $this->registry->unregister('current_order'); + + parent::tearDown(); } /** * @magentoDataFixture Magento/Sales/_files/order.php + * + * @return void */ - public function testGetOrderItems() + public function testGetOrderItems(): void { - $this->registerOrder(); - $this->model = $this->layout->createBlock(\Magento\Sales\Block\Order\Items::class); - $this->assertTrue(count($this->model->getItems()) > 0); + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $this->registerOrder($order); + $this->block = $this->layout->createBlock(Items::class); + $this->assertCount(1, $this->block->getItems()); } /** - * @magentoAppIsolation enabled * @magentoConfigFixture default/sales/orders/items_per_page 3 * @magentoDataFixture Magento/Sales/_files/order_item_list.php + * + * @return void */ - public function testPagerIsDisplayed() + public function testPagerIsDisplayed(): void { - $this->registerOrder(); - - /** @var \Magento\Sales\Block\Order\Items model */ - $this->model = $this->layout->createBlock(\Magento\Sales\Block\Order\Items::class, 'items_block'); + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $this->registerOrder($order); + $this->block = $this->layout->createBlock(Items::class, 'items_block'); $this->layout->addBlock( - $this->objectManager->get(\Magento\Theme\Block\Html\Pager::class), + $this->objectManager->get(Pager::class), 'sales_order_item_pager', 'items_block' ); - $this->model->setLayout($this->layout); - - $this->assertTrue($this->model->isPagerDisplayed()); + $this->block->setLayout($this->layout); + $this->assertTrue($this->block->isPagerDisplayed()); } /** * @magentoDataFixture Magento/Sales/_files/order_item_list.php + * + * @return void */ - public function testPagerIsNotDisplayed() + public function testPagerIsNotDisplayed(): void { - $this->registerOrder(); - - /** @var \Magento\Sales\Block\Order\Items model */ - $this->model = $this->layout->createBlock(\Magento\Sales\Block\Order\Items::class, 'items_block'); + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $this->registerOrder($order); + $this->block = $this->layout->createBlock(Items::class, 'items_block'); $this->layout->addBlock( - $this->objectManager->get(\Magento\Theme\Block\Html\Pager::class), + $this->objectManager->get(Pager::class), 'sales_order_item_pager', 'items_block' ); - $this->model->setLayout($this->layout); - - $this->assertFalse($this->model->isPagerDisplayed()); + $this->block->setLayout($this->layout); + $this->assertFalse($this->block->isPagerDisplayed()); + $this->assertEmpty(preg_replace('/\s+/', '', strip_tags($this->block->getPagerHtml()))); } /** - * @magentoAppIsolation enabled - * @magentoAppArea frontend * @magentoConfigFixture default/sales/orders/items_per_page 3 * @magentoDataFixture Magento/Sales/_files/order_item_list.php + * + * @return void */ - public function testGetPagerHtml() + public function testGetPagerHtml(): void { - $this->registerOrder(); - - /** @var \Magento\Sales\Block\Order\Items model */ - $this->model = $this->layout->createBlock(\Magento\Sales\Block\Order\Items::class, 'items_block'); + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $this->registerOrder($order); + $this->block = $this->layout->createBlock(Items::class, 'items_block'); $this->layout->addBlock( - $this->objectManager->get(\Magento\Theme\Block\Html\Pager::class), + $this->objectManager->get(Pager::class), 'sales_order_item_pager', 'items_block' ); - $this->model->setLayout($this->layout); - - $this->assertNotEmpty($this->model->getPagerHtml()); + $this->block->setLayout($this->layout); + $this->assertNotEmpty(preg_replace('/\s+/', '', strip_tags($this->block->getPagerHtml()))); + $this->assertTrue($this->block->isPagerDisplayed()); } /** * @magentoDataFixture Magento/Sales/_files/order.php + * + * @return void + */ + public function testGetOrder(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $this->registerOrder($order); + $this->block = $this->layout->createBlock(Items::class, 'items_block'); + $this->assertEquals($order, $this->block->getOrder()); + } + + /** + * @magentoDataFixture Magento/Sales/_files/customer_order_with_two_items.php + * + * @return void + */ + public function testDisplayingOrderItems(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000555'); + $this->registerOrder($order); + $blockHtml = $this->renderOrderItemsBlock(); + $this->assertOrderItems($order->getItemsCollection(), $blockHtml); + } + + /** + * Render order items block. + * + * @return string */ - public function testGetOrder() + private function renderOrderItemsBlock(): string { - $order = $this->registerOrder(); + $page = $this->pageFactory->create(); + $page->addHandle([ + 'default', + 'sales_order_view', + ]); + $page->getLayout()->generateXml(); + $orderItemsBlock = $page->getLayout()->getBlock('order_items')->unsetChild('order_totals'); + + return $orderItemsBlock->toHtml(); + } - /** @var \Magento\Sales\Block\Order\Items model */ - $this->model = $this->layout->createBlock(\Magento\Sales\Block\Order\Items::class, 'items_block'); - $this->assertEquals($order, $this->model->getOrder()); + /** + * Assert order items list. + * + * @param Collection $orderItems + * @param string $blockHtml + * @return void + */ + private function assertOrderItems(Collection $orderItems, string $blockHtml): void + { + $this->assertNotCount(0, $orderItems, 'Order items collection is empty'); + $fieldsToCheck = [ + 'name' => "/td[contains(@class, 'name')]/strong[contains(text(), '%s')]", + 'sku' => "/td[contains(@class, 'sku') and contains(text(), '%s')]", + 'price' => "/td[contains(@class, 'price')]//span[contains(text(), '%01.2f')]", + 'qty_ordered' => "/td[contains(@class, 'qty')]//span[contains(text(), '" . __('Ordered') + . "')]/following-sibling::span[contains(text(), '%d')]", + 'row_total' => "/td[contains(@class, 'subtotal')]//span[contains(text(), '%01.2f')]", + ]; + foreach ($orderItems as $item) { + $itemRowXpath = sprintf("//tr[@id='order-item-row-%s']", $item->getItemId()); + foreach ($fieldsToCheck as $key => $xpath) { + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath(sprintf($itemRowXpath . $xpath, $item->getData($key)), $blockHtml), + sprintf('Item %s wasn\'t found or not equals to %s.', $key, $item->getData($key)) + ); + } + } } /** - * Register order in registry + * Register order in registry. * - * @return \Magento\Sales\Model\Order + * @param OrderInterface $order + * @return void */ - private function registerOrder() + private function registerOrder(OrderInterface $order): void { - /** @var \Magento\Sales\Model\Order $order */ - $order = $this->objectManager->get(\Magento\Sales\Model\Order::class); - $order->loadByIncrementId('100000001'); + $this->registry->unregister('current_order'); $this->registry->register('current_order', $order); - return $order; } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/TotalsTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/TotalsTest.php index b23e7bcc140d4..7361ddc985b21 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/TotalsTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/TotalsTest.php @@ -3,54 +3,129 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Sales\Block\Order; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\Element\Context; +use Magento\Framework\View\Element\Text; +use Magento\Framework\View\Layout; +use Magento\Framework\View\LayoutInterface; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + /** + * Tests for order totals block. + * * @magentoAppArea frontend + * @magentoDbIsolation enabled */ -class TotalsTest extends \PHPUnit\Framework\TestCase +class TotalsTest extends TestCase { - public function testToHtmlChildrenInitialized() + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Layout */ + private $layout; + + /** @var Totals */ + private $block; + + /** @var OrderInterfaceFactory */ + private $orderFactory; + + /** + * @inheritdoc + */ + protected function setUp() { - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\App\State::class) - ->setAreaCode('frontend'); + parent::setUp(); - /** @var $layout \Magento\Framework\View\Layout */ - $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - \Magento\Framework\View\LayoutInterface::class - ); - /** @var \Magento\Sales\Block\Order\Totals $block */ - $block = $layout->createBlock(\Magento\Sales\Block\Order\Totals::class, 'block'); - $block->setOrder( - \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Sales\Model\Order::class) - )->setTemplate( - 'order/totals.phtml' - ); + $this->objectManager = Bootstrap::getObjectManager(); + $this->layout = $this->objectManager->get(LayoutInterface::class); + $this->block = $this->layout->createBlock(Totals::class, 'block'); + $this->orderFactory = $this->objectManager->get(OrderInterfaceFactory::class); + } - $context = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( - \Magento\Framework\View\Element\Context::class - ); - $childOne = $this->getMockBuilder(\Magento\Framework\View\Element\Text::class) + /** + * @magentoAppIsolation enabled + * + * @return void + */ + public function testToHtmlChildrenInitialized(): void + { + $this->block->setOrder($this->orderFactory->create())->setTemplate('order/totals.phtml'); + $context = $this->objectManager->get(Context::class); + $childOne = $this->getMockBuilder(Text::class) ->setMethods(['initTotals']) ->setConstructorArgs([$context]) ->getMock(); $childOne->expects($this->once())->method('initTotals'); - $layout->addBlock($childOne, 'child1', 'block'); - - $childTwo = $this->getMockBuilder(\Magento\Framework\View\Element\Text::class) + $this->layout->addBlock($childOne, 'child1', 'block'); + $childTwo = $this->getMockBuilder(Text::class) ->setMethods(['initTotals']) ->setConstructorArgs([$context]) ->getMock(); $childTwo->expects($this->once())->method('initTotals'); - $layout->addBlock($childTwo, 'child2', 'block'); - - $childThree = $this->getMockBuilder(\Magento\Framework\View\Element\Text::class) + $this->layout->addBlock($childTwo, 'child2', 'block'); + $childThree = $this->getMockBuilder(Text::class) ->setMethods(['initTotals']) ->setConstructorArgs([$context]) ->getMock(); $childThree->expects($this->once())->method('initTotals'); - $layout->addBlock($childThree, 'child3', 'block'); + $this->layout->addBlock($childThree, 'child3', 'block'); + $this->block->toHtml(); + } - $block->toHtml(); + /** + * @magentoDataFixture Magento/Sales/_files/customer_order_with_two_items.php + * + * @return void + */ + public function testOrderTotalsBlock(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000555'); + $blockHtml = $this->block->setTemplate('Magento_Sales::order/totals.phtml')->setOrder($order)->toHtml(); + $message = '"%s" for order wasn\'t found or not equals to %01.2f'; + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//th[contains(text(), '%s')]/following-sibling::td/span[contains(text(), '%01.2f')]", + __('Subtotal'), + $order->getSubtotal() + ), + $blockHtml + ), + sprintf($message, __('Subtotal'), $order->getSubtotal()) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//th[contains(text(), '%s')]/following-sibling::td/span[contains(text(), '%01.2f')]", + __('Shipping & Handling'), + $order->getShippingAmount() + ), + $blockHtml + ), + sprintf($message, __('Shipping & Handling'), $order->getShippingAmount()) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//tr[contains(@class, 'grand_total') and contains(.//strong, '%s')]" + . "//span[contains(text(), '%01.2f')]", + __('Grand Total'), + $order->getGrandTotal() + ), + $blockHtml + ), + sprintf($message, __('Grand Total'), $order->getGrandTotal()) + ); } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_two_items.php b/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_two_items.php new file mode 100644 index 0000000000000..5270b291a56d4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_two_items.php @@ -0,0 +1,96 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Model\Product\Type; +use Magento\Sales\Api\Data\OrderAddressInterfaceFactory; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\Sales\Api\Data\OrderPaymentInterfaceFactory; +use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\Sales\Api\Data\OrderItemInterfaceFactory; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Address; + +require __DIR__ . '/../../../Magento/Customer/_files/customer_with_uk_address.php'; +require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_duplicated.php'; +require __DIR__ . '/../../../Magento/Catalog/_files/products_new.php'; + +/** @var OrderInterfaceFactory $orderFactory */ +$orderFactory = $objectManager->get(OrderInterfaceFactory::class); +/** @var OrderItemInterfaceFactory $orderItemFactory */ +$orderItemFactory = $objectManager->get(OrderItemInterfaceFactory::class); +/** @var OrderRepositoryInterface $orderRepository */ +$orderRepository = $objectManager->get(OrderRepositoryInterface::class); +/** @var OrderAddressInterfaceFactory $orderAddressFactory */ +$orderAddressFactory = $objectManager->get(OrderAddressInterfaceFactory::class); +/** @var OrderPaymentInterfaceFactory $orderPaymentFactory */ +$orderPaymentFactory = $objectManager->get(OrderPaymentInterfaceFactory::class); +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->get(ProductRepositoryInterface::class); +$productRepository->cleanCache(); + +$billingAddress = $orderAddressFactory->create(['data' => $customerAddress->getData()]); +$billingAddress->setAddressType(Address::TYPE_BILLING); + +$shippingAddress = $orderAddressFactory->create(['data' => $customerAddress->getData()]); +$shippingAddress->setAddressType(Address::TYPE_SHIPPING) + ->setStreet('street for shipping') + ->setRegion('North West') + ->setPostcode('GU16 7HF') + ->setShippingMethod('flatrate_flatrate'); + +$orderPayment = $orderPaymentFactory->create(); +$orderPayment->setMethod('checkmo') + ->setAdditionalInformation('last_trans_id', '11122') + ->setAdditionalInformation( + 'metadata', + ['type' => 'free', 'fraudulent' => false] + ); + +$firstProduct = $productRepository->get('simple-1'); +$firstOrderItem = $orderItemFactory->create(); +$firstOrderItem->setProductId($firstProduct->getId()) + ->setQtyOrdered(1) + ->setBasePrice($firstProduct->getPrice()) + ->setPrice($firstProduct->getPrice()) + ->setRowTotal($firstProduct->getPrice()) + ->setProductType(Type::TYPE_SIMPLE) + ->setName($firstProduct->getName()) + ->setSku($firstProduct->getSku()); + +$secondProduct = $productRepository->get('simple'); +$secondOrderItem = $orderItemFactory->create(); +$secondOrderItem->setProductId($secondProduct->getId()) + ->setQtyOrdered(1) + ->setBasePrice($secondProduct->getPrice()) + ->setPrice($secondProduct->getPrice()) + ->setRowTotal($secondProduct->getPrice()) + ->setProductType(Type::TYPE_SIMPLE) + ->setName($secondProduct->getName()) + ->setSku($secondProduct->getSku()); + +$order = $orderFactory->create(); +$order->setIncrementId('100000555') + ->setState(Order::STATE_PROCESSING) + ->setStatus(Order::STATE_PROCESSING) + ->setSubtotal(20) + ->setShippingAmount(10) + ->setGrandTotal(30) + ->setBaseSubtotal(20) + ->setBaseShippingAmount(10) + ->setBaseGrandTotal(30) + ->setCustomerIsGuest(false) + ->setCustomerEmail($customerDataModel->getEmail()) + ->setCustomerId($customerDataModel->getId()) + ->setBillingAddress($billingAddress) + ->setShippingAddress($shippingAddress) + ->setShippingDescription('Flat Rate - Fixed') + ->setStoreId($mainWebsite->getDefaultStore()->getId()) + ->addItem($firstOrderItem) + ->addItem($secondOrderItem) + ->setPayment($orderPayment); +$orderRepository->save($order); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_two_items_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_two_items_rollback.php new file mode 100644 index 0000000000000..a6225b247466e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_two_items_rollback.php @@ -0,0 +1,29 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\Sales\Api\OrderRepositoryInterface; + +require __DIR__ . '/../../../Magento/Customer/_files/customer_with_uk_address_rollback.php'; +require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_duplicated_rollback.php'; +require __DIR__ . '/../../../Magento/Catalog/_files/products_new_rollback.php'; + +/** @var OrderRepositoryInterface $orderRepository */ +$orderRepository = $objectManager->get(OrderRepositoryInterface::class); +/** @var OrderInterfaceFactory $orderFactory */ +$orderFactory = $objectManager->create(OrderInterfaceFactory::class); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +$order = $orderFactory->create()->loadByIncrementId('100000555'); +if ($order->getId()) { + $orderRepository->delete($order); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/invoices_for_items.php b/dev/tests/integration/testsuite/Magento/Sales/_files/invoices_for_items.php new file mode 100644 index 0000000000000..dbec254b69482 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/invoices_for_items.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Sales\Api\Data\InvoiceItemCreationInterfaceFactory; +use Magento\Sales\Api\InvoiceOrderInterface; + +require __DIR__ . '/../../../Magento/Sales/_files/customer_order_with_two_items.php'; + +/** @var InvoiceItemCreationInterfaceFactory $invoiceItemFactory */ +$invoiceItemFactory = $objectManager->get(InvoiceItemCreationInterfaceFactory::class); +/** @var InvoiceOrderInterface $invoiceOrder */ +$invoiceOrder = $objectManager->get(InvoiceOrderInterface::class); + +foreach ($order->getItems() as $orderItem) { + $invoiceItem = $invoiceItemFactory->create(); + $invoiceItem->setOrderItemId($orderItem->getItemId()); + $invoiceItem->setQty($orderItem->getQtyOrdered()); + $invoiceOrder->execute($order->getId(), false, [$invoiceItem]); +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/invoices_for_items_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/invoices_for_items_rollback.php new file mode 100644 index 0000000000000..91200f3c1b46c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/invoices_for_items_rollback.php @@ -0,0 +1,8 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +require __DIR__ . '/../../../Magento/Sales/_files/customer_order_with_two_items_rollback.php'; diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/refunds_for_items.php b/dev/tests/integration/testsuite/Magento/Sales/_files/refunds_for_items.php new file mode 100644 index 0000000000000..d8b94866adbb8 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/refunds_for_items.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Sales\Api\Data\CreditmemoItemCreationInterfaceFactory; +use Magento\Sales\Api\RefundOrderInterface; + +require __DIR__ . '/../../../Magento/Sales/_files/invoices_for_items.php'; + +/** @var CreditmemoItemCreationInterfaceFactory $creditmemoItemFactory */ +$creditmemoItemFactory = $objectManager->get(CreditmemoItemCreationInterfaceFactory::class); +/** @var RefundOrderInterface $refundOrder */ +$refundOrder = $objectManager->get(RefundOrderInterface::class); + +foreach ($order->getItems() as $item) { + $creditmemoItem = $creditmemoItemFactory->create(); + $creditmemoItem->setOrderItemId($item->getId()); + $creditmemoItem->setQty($item->getQtyOrdered()); + $refundOrder->execute($order->getId(), [$creditmemoItem]); +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/refunds_for_items_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/refunds_for_items_rollback.php new file mode 100644 index 0000000000000..67a4321c182ec --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/refunds_for_items_rollback.php @@ -0,0 +1,8 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +require __DIR__ . '/../../../Magento/Sales/_files/invoices_for_items_rollback.php'; From 8269b84b7a9ab831b6596d2331a1f1cc9b31b4d9 Mon Sep 17 00:00:00 2001 From: vagrant <eino.keskitalo@vaimo.com> Date: Thu, 26 Mar 2020 10:29:45 +0100 Subject: [PATCH 032/177] Expect email notification to send, and simplify setup a bit. --- .../Sitemap/Test/Unit/Model/ObserverTest.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php b/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php index 09f5418bbd762..543d9598553cc 100644 --- a/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php +++ b/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php @@ -64,18 +64,19 @@ class ObserverTest extends \PHPUnit\Framework\TestCase protected function setUp() { - $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class) - ->getMock(); - $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class) - ->getMock(); + $this->objectManagerMock = $this->createMock( + \Magento\Framework\ObjectManagerInterface::class + ); + $this->scopeConfigMock = $this->createMock( + \Magento\Framework\App\Config\ScopeConfigInterface::class + ); $this->collectionFactoryMock = $this->getMockBuilder( \Magento\Sitemap\Model\ResourceModel\Sitemap\CollectionFactory::class )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->sitemapCollectionMock = $this->createPartialMock( - \Magento\Sitemap\Model\ResourceModel\Sitemap\Collection::class, - ['getIterator'] + $this->sitemapCollectionMock = $this->createMock( + \Magento\Sitemap\Model\ResourceModel\Sitemap\Collection::class ); $this->sitemapMock = $this->createPartialMock( \Magento\Sitemap\Model\Sitemap::class, @@ -130,6 +131,10 @@ public function testScheduledGenerateSitemapsSendsExceptionEmail() ) ->willReturn('error-recipient@example.com'); + $this->emailNotificationMock->expects($this->once()) + ->method('sendErrors') + ->with(['Sitemap Exception']); + $this->observer->scheduledGenerateSitemaps(); } } From f0b3ab87851b2e19b0a695bf229f2260a90494ad Mon Sep 17 00:00:00 2001 From: Alexander Steshuk <grp-engcom-vendorworker-Kilo@adobe.com> Date: Thu, 26 Mar 2020 18:04:55 +0200 Subject: [PATCH 033/177] Fix Static test --- app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php b/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php index 543d9598553cc..7430213030f96 100644 --- a/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php +++ b/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php @@ -11,7 +11,7 @@ use Magento\Store\Model\App\Emulation; /** - * Class ObserverTest + * Class for ObserverTest * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ From 3b5ac1920fab0cb66898cb9da9e6ab9b05ae12e9 Mon Sep 17 00:00:00 2001 From: DianaRusin <rusind95@gmail.com> Date: Fri, 27 Mar 2020 13:51:03 +0200 Subject: [PATCH 034/177] MC-32697: [2.4] AbstractSimpleObjectBuilder.php throws exception when Interceptor instance comes. --- .../Magento/Framework/Api/AbstractSimpleObjectBuilder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php b/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php index cf0a887249049..c371887d74699 100644 --- a/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php +++ b/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php @@ -9,6 +9,7 @@ /** * Base Builder Class for simple data Objects + * @deprecated 102.0.4 * @SuppressWarnings(PHPMD.NumberOfChildren) */ abstract class AbstractSimpleObjectBuilder implements SimpleBuilderInterface From c433c024f908b1649c2e8d32b452a94237c41910 Mon Sep 17 00:00:00 2001 From: DianaRusin <rusind95@gmail.com> Date: Fri, 27 Mar 2020 16:48:50 +0200 Subject: [PATCH 035/177] MC-32697: [2.4] AbstractSimpleObjectBuilder.php throws exception when Interceptor instance comes. --- .../Magento/Framework/Api/AbstractSimpleObjectBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php b/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php index c371887d74699..cf7f7732c116c 100644 --- a/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php +++ b/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php @@ -9,7 +9,7 @@ /** * Base Builder Class for simple data Objects - * @deprecated 102.0.4 + * @deprecated Every builder should have their own implementation of \Magento\Framework\Api\SimpleBuilderInterface * @SuppressWarnings(PHPMD.NumberOfChildren) */ abstract class AbstractSimpleObjectBuilder implements SimpleBuilderInterface From c12201ea7e461ec73f765b6db18d26988a83a9d8 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Mon, 30 Mar 2020 12:31:22 +0100 Subject: [PATCH 036/177] Updated MediaGallery modules and marked as API --- .../Model/Asset/Command/GetById.php | 2 +- .../Model/Asset/Command/GetByPath.php | 6 +- .../Model/Directory/Command/CreateByPath.php | 59 ++++++++++ .../Model/Directory/Command/DeleteByPath.php | 58 ++++++++++ .../MediaGallery/Model/Directory/Excluded.php | 48 ++++++++ .../Model/File/Command/DeleteByAssetId.php | 74 +++++++++++++ .../Keyword/Command/GetAssetKeywords.php | 2 +- .../Unit/Model/Directory/ExcludedTest.php | 64 +++++++++++ .../File/Command/DeleteByAssetIdTest.php | 103 ++++++++++++++++++ app/code/Magento/MediaGallery/etc/di.xml | 14 +++ .../Api/Data/AssetInterface.php | 1 + .../Api/Data/KeywordInterface.php | 1 + .../DeleteByDirectoryPathInterface.php | 2 +- .../Asset/Command/DeleteByPathInterface.php | 2 +- .../Model/Asset/Command/GetByIdInterface.php | 2 +- .../Asset/Command/GetByPathInterface.php | 2 +- .../Model/Asset/Command/SaveInterface.php | 2 +- .../Model/DataExtractorInterface.php | 1 + .../Command/CreateByPathInterface.php | 24 ++++ .../Command/DeleteByPathInterface.php | 23 ++++ .../Model/Directory/ExcludedInterface.php | 23 ++++ .../File/Command/DeleteByAssetIdInterface.php | 24 ++++ .../Command/GetAssetKeywordsInterface.php | 2 +- .../Command/SaveAssetKeywordsInterface.php | 1 + 24 files changed, 528 insertions(+), 12 deletions(-) create mode 100644 app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php create mode 100644 app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php create mode 100644 app/code/Magento/MediaGallery/Model/Directory/Excluded.php create mode 100644 app/code/Magento/MediaGallery/Model/File/Command/DeleteByAssetId.php create mode 100644 app/code/Magento/MediaGallery/Test/Unit/Model/Directory/ExcludedTest.php create mode 100644 app/code/Magento/MediaGallery/Test/Unit/Model/File/Command/DeleteByAssetIdTest.php create mode 100644 app/code/Magento/MediaGalleryApi/Model/Directory/Command/CreateByPathInterface.php create mode 100644 app/code/Magento/MediaGalleryApi/Model/Directory/Command/DeleteByPathInterface.php create mode 100644 app/code/Magento/MediaGalleryApi/Model/Directory/ExcludedInterface.php create mode 100644 app/code/Magento/MediaGalleryApi/Model/File/Command/DeleteByAssetIdInterface.php diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php b/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php index 6be11610ac197..b6153c45dbf8c 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php @@ -28,7 +28,7 @@ class GetById implements GetByIdInterface private $resourceConnection; /** - * @var AssetInterface + * @var AssetInterfaceFactory */ private $assetFactory; diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php b/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php index db8482d3399ba..fe5fcca6cb0de 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php @@ -30,7 +30,7 @@ class GetByPath implements GetByPathInterface private $resourceConnection; /** - * @var AssetInterface + * @var AssetInterfaceFactory */ private $mediaAssetFactory; @@ -78,9 +78,7 @@ public function execute(string $mediaFilePath): AssetInterface throw new NoSuchEntityException($message); } - $mediaAssets = $this->mediaAssetFactory->create(['data' => $data]); - - return $mediaAssets; + return $this->mediaAssetFactory->create(['data' => $data]); } catch (\Exception $exception) { $this->logger->critical($exception); $message = __('An error occurred during get media asset list: %1', $exception->getMessage()); diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php new file mode 100644 index 0000000000000..6d0ea45aa02cd --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php @@ -0,0 +1,59 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model\Directory\Command; + +use Magento\Cms\Model\Wysiwyg\Images\Storage; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\MediaGalleryApi\Model\Directory\Command\CreateByPathInterface; +use Psr\Log\LoggerInterface; + +/** + * Create folder by provided path + */ +class CreateByPath implements CreateByPathInterface +{ + /** + * @var LoggerInterface + */ + private $logger; + + /** + * @var Storage + */ + private $storage; + + /** + * @param LoggerInterface $logger + * @param Storage $storage + */ + public function __construct( + LoggerInterface $logger, + Storage $storage + ) { + $this->logger = $logger; + $this->storage = $storage; + } + + /** + * Create new directory by provided path + * + * @param string $path + * @param string $name + * @throws CouldNotSaveException + */ + public function execute(string $path, string $name): void + { + try { + $this->storage->createDirectory($name, $this->storage->getCmsWysiwygImages()->getStorageRoot() . $path); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $message = __('Failed to create the folder: %error', ['error' => $exception->getMessage()]); + throw new CouldNotSaveException($message, $exception); + } + } +} diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php b/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php new file mode 100644 index 0000000000000..ee78216fafdaf --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php @@ -0,0 +1,58 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model\Directory\Command; + +use Magento\Cms\Model\Wysiwyg\Images\Storage; +use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\MediaGalleryApi\Model\Directory\Command\DeleteByPathInterface; +use Psr\Log\LoggerInterface; + +/** + * Delete folder by provided path + */ +class DeleteByPath implements DeleteByPathInterface +{ + /** + * @var LoggerInterface + */ + private $logger; + + /** + * @var Storage + */ + private $storage; + + /** + * @param LoggerInterface $logger + * @param Storage $storage + */ + public function __construct( + LoggerInterface $logger, + Storage $storage + ) { + $this->logger = $logger; + $this->storage = $storage; + } + + /** + * Deletes the existing folder + * + * @param string $path + * @throws CouldNotDeleteException + */ + public function execute(string $path): void + { + try { + $this->storage->deleteDirectory($this->storage->getCmsWysiwygImages()->getStorageRoot() . $path); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $message = __('Failed to delete the folder: %error', ['error' => $exception->getMessage()]); + throw new CouldNotDeleteException($message, $exception); + } + } +} diff --git a/app/code/Magento/MediaGallery/Model/Directory/Excluded.php b/app/code/Magento/MediaGallery/Model/Directory/Excluded.php new file mode 100644 index 0000000000000..ad8843da9e8c3 --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/Directory/Excluded.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model\Directory; + +use Magento\MediaGalleryApi\Model\Directory\ExcludedInterface; + +/** + * Directory paths that should not be included in the media gallery + */ +class Excluded implements ExcludedInterface +{ + /** + * @var array + */ + private $patterns; + + /** + * @param array $patterns + */ + public function __construct( + array $patterns + ) { + $this->patterns = $patterns; + } + + /** + * Check if the path is excluded from displaying in the media gallery + * + * @param string $path + * @return bool + */ + public function isExcluded(string $path): bool + { + foreach ($this->patterns as $pattern) { + preg_match($pattern, $path, $result); + + if ($result) { + return true; + } + } + return false; + } +} diff --git a/app/code/Magento/MediaGallery/Model/File/Command/DeleteByAssetId.php b/app/code/Magento/MediaGallery/Model/File/Command/DeleteByAssetId.php new file mode 100644 index 0000000000000..177c67280580c --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/File/Command/DeleteByAssetId.php @@ -0,0 +1,74 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model\File\Command; + +use Magento\Cms\Model\Wysiwyg\Images\Storage; +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Filesystem; +use Magento\MediaGalleryApi\Model\File\Command\DeleteByAssetIdInterface; +use Magento\MediaGalleryApi\Model\Asset\Command\GetByIdInterface; + +/** + * Load Media Asset path from database by id and delete the file + */ +class DeleteByAssetId implements DeleteByAssetIdInterface +{ + /** + * @var GetByIdInterface + */ + private $getAssetById; + + /** + * @var Storage + */ + private $imagesStorage; + + /** + * @var Filesystem + */ + private $filesystem; + + /** + * DeleteAssetById constructor. + * + * @param GetByIdInterface $getAssetById + * @param Storage $imagesStorage + * @param Filesystem $filesystem + */ + public function __construct( + GetByIdInterface $getAssetById, + Storage $imagesStorage, + Filesystem $filesystem + ) { + $this->getAssetById = $getAssetById; + $this->imagesStorage = $imagesStorage; + $this->filesystem = $filesystem; + } + + /** + * Delete image by asset ID + * + * @param int $assetId + * + * @return void + * + * @throws LocalizedException + */ + public function execute(int $assetId): void + { + $mediaFilePath = $this->getAssetById->execute($assetId)->getPath(); + $mediaDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA); + + if (!$mediaDirectory->isFile($mediaFilePath)) { + throw new LocalizedException(__('File "%1" does not exist in media directory.', $mediaFilePath)); + } + + $this->imagesStorage->deleteFile($mediaDirectory->getAbsolutePath() . $mediaFilePath); + } +} diff --git a/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php b/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php index 5b826a26e937d..ae61867884c7a 100644 --- a/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php +++ b/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php @@ -59,7 +59,7 @@ public function __construct( * * @param int $assetId * - * @return KeywordInterface[]|[] + * @return KeywordInterface[] * @throws IntegrationException */ public function execute(int $assetId): array diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/ExcludedTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/ExcludedTest.php new file mode 100644 index 0000000000000..e468bee7cc5d7 --- /dev/null +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/ExcludedTest.php @@ -0,0 +1,64 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Test\Unit\Model\File\Command; + +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use PHPUnit\Framework\TestCase; +use Magento\MediaGallery\Model\Directory\Excluded; + +/** + * Test the DeleteByAssetIdTest command model + */ +class ExcludedTest extends TestCase +{ + /** + * @var Excluded + */ + private $object; + + /** + * Initialize basic test class mocks + */ + protected function setUp(): void + { + $this->object = (new ObjectManager($this))->getObject( + Excluded::class, + [ + 'patterns' => [ + 'tmp' => '/pub\/media\/tmp/', + 'captcha' => '/pub\/media\/captcha/' + ] + ] + ); + } + + /** + * Test is directory path excluded + * + * @param string $path + * @param bool $isExcluded + * @dataProvider pathsProvider + */ + public function testIsExcluded(string $path, bool $isExcluded): void + { + $this->assertEquals($isExcluded, $this->object->isExcluded($path)); + } + + /** + * Data provider for testIsExcluded + * + * @return array + */ + public function pathsProvider() + { + return [ + ['/var/www/html/pub/media/tmp/somedir', true], + ['/var/www/html/pub/media/wysiwyg/somedir', false] + ]; + } +} diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/File/Command/DeleteByAssetIdTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/File/Command/DeleteByAssetIdTest.php new file mode 100644 index 0000000000000..de5b5d42c71e3 --- /dev/null +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/File/Command/DeleteByAssetIdTest.php @@ -0,0 +1,103 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Test\Unit\Model\File\Command; + +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\MediaGalleryApi\Api\Data\AssetInterface; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Framework\Filesystem; +use Magento\Framework\Filesystem\Directory\Read; +use Magento\Cms\Model\Wysiwyg\Images\Storage; +use Magento\MediaGalleryApi\Model\Asset\Command\GetByIdInterface; +use Magento\MediaGallery\Model\File\Command\DeleteByAssetId; + +/** + * Test the DeleteByAssetIdTest command model + */ +class DeleteByAssetIdTest extends TestCase +{ + /** + * @var MockObject|Filesystem + */ + private $filesystem; + + /** + * @var MockObject|Storage + */ + private $storage; + + /** + * @var MockObject|GetByIdInterface + */ + private $getById; + + /** + * @var DeleteByAssetId + */ + private $object; + + /** + * Initialize basic test class mocks + */ + protected function setUp(): void + { + $this->filesystem = $this->createMock(Filesystem::class); + $this->storage = $this->createMock(Storage::class); + $this->getById = $this->createMock(GetByIdInterface::class); + + $this->object = (new ObjectManager($this))->getObject( + DeleteByAssetId::class, + [ + 'filesystem' => $this->filesystem, + 'imagesStorage' => $this->storage, + 'getAssetById' => $this->getById + ] + ); + } + + /** + * Test delete file by asset id + */ + public function testExecute(): void + { + $assetId = 42; + $path = '/file1.jpg'; + $absoluteMediaPath = '/var/www/html/pub/media'; + + $asset = $this->createMock(AssetInterface::class); + $asset->expects($this->once()) + ->method('getPath') + ->willReturn($path); + + $this->getById->expects($this->once()) + ->method('execute') + ->with($assetId) + ->willReturn($asset); + + $directory = $this->createMock(Read::class); + $directory->expects($this->once()) + ->method('isFile') + ->willReturn(true); + $directory->expects($this->once()) + ->method('getAbsolutePath') + ->willReturn($absoluteMediaPath); + + $this->filesystem->expects($this->once()) + ->method('getDirectoryRead') + ->with(DirectoryList::MEDIA) + ->willReturn($directory); + + $this->storage->expects($this->once()) + ->method('deleteFile') + ->with($absoluteMediaPath . $path); + + $this->object->execute($assetId); + } +} diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index 24ed42b2b06dd..ccc8ce28a733d 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -29,4 +29,18 @@ <plugin name="media_gallery_image_remove_metadata_after_wysiwyg" type="Magento\MediaGallery\Plugin\Wysiwyg\Images\Storage" sortOrder="10" disabled="false"/> </type> + <type name="Magento\MediaGalleryUi\Model\Directory\Excluded"> + <arguments> + <argument name="patterns" xsi:type="array"> + <item name="captcha" xsi:type="string">/pub\/media\/captcha/</item> + <item name="catalog" xsi:type="string">/pub\/media\/catalog\/product/</item> + <item name="customer" xsi:type="string">/pub\/media\/customer/</item> + <item name="downloadable" xsi:type="string">/pub\/media\/downloadable/</item> + <item name="import" xsi:type="string">/pub\/media\/import/</item> + <item name="theme" xsi:type="string">/pub\/media\/theme/</item> + <item name="theme_customization" xsi:type="string">/pub\/media\/theme_customization/</item> + <item name="tmp" xsi:type="string">/pub\/media\/tmp/</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php b/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php index 0f4b78a6dc603..7cd94f90a60a0 100644 --- a/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php @@ -13,6 +13,7 @@ /** * Represents a media gallery asset which contains information about a media asset entity such * as path to the media storage, media asset title and its content type, etc. + * @api */ interface AssetInterface extends ExtensibleDataInterface { diff --git a/app/code/Magento/MediaGalleryApi/Api/Data/KeywordInterface.php b/app/code/Magento/MediaGalleryApi/Api/Data/KeywordInterface.php index ae3b7dbd76291..7f19e53d6e380 100644 --- a/app/code/Magento/MediaGalleryApi/Api/Data/KeywordInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/Data/KeywordInterface.php @@ -12,6 +12,7 @@ /** * Represents a media gallery keyword. This object contains information about a media asset keyword entity. + * @api */ interface KeywordInterface extends ExtensibleDataInterface { diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByDirectoryPathInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByDirectoryPathInterface.php index e55f7cb714f77..ee012c068a697 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByDirectoryPathInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByDirectoryPathInterface.php @@ -11,6 +11,7 @@ /** * A command represents the media gallery assets delete action. A media gallery asset is filtered by directory * path value. + * @api */ interface DeleteByDirectoryPathInterface { @@ -18,7 +19,6 @@ interface DeleteByDirectoryPathInterface * Delete media assets by directory path * * @param string $directoryPath - * * @return void */ public function execute(string $directoryPath): void; diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php index b3612a67ed536..0f04eaecf02ec 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php @@ -10,6 +10,7 @@ /** * A command represents the media gallery asset delete action. A media gallery asset is filtered by path value. + * @api */ interface DeleteByPathInterface { @@ -17,7 +18,6 @@ interface DeleteByPathInterface * Delete media asset by path * * @param string $mediaAssetPath - * * @return void */ public function execute(string $mediaAssetPath): void; diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php index ef2ceb5ffbfe6..9d0b8863baf22 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php @@ -10,6 +10,7 @@ /** * A command represents the get media gallery asset by using media gallery asset id as a filter parameter. + * @api */ interface GetByIdInterface { @@ -17,7 +18,6 @@ interface GetByIdInterface * Get media asset by id * * @param int $mediaAssetId - * * @return \Magento\MediaGalleryApi\Api\Data\AssetInterface * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\IntegrationException diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php index 547b0dc695dae..9d39b5cc692f3 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php @@ -10,6 +10,7 @@ /** * A command represents the get media gallery asset by using media gallery asset path as a filter parameter. + * @api */ interface GetByPathInterface { @@ -17,7 +18,6 @@ interface GetByPathInterface * Get media asset list * * @param string $mediaFilePath - * * @return \Magento\MediaGalleryApi\Api\Data\AssetInterface */ public function execute(string $mediaFilePath): \Magento\MediaGalleryApi\Api\Data\AssetInterface; diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php index b3e3607e6e822..6d2aae21754b8 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php @@ -12,6 +12,7 @@ /** * A command which executes the media gallery asset save operation. + * @api */ interface SaveInterface { @@ -19,7 +20,6 @@ interface SaveInterface * Save media asset * * @param \Magento\MediaGalleryApi\Api\Data\AssetInterface $mediaAsset - * * @return int * @throws \Magento\Framework\Exception\CouldNotSaveException */ diff --git a/app/code/Magento/MediaGalleryApi/Model/DataExtractorInterface.php b/app/code/Magento/MediaGalleryApi/Model/DataExtractorInterface.php index 6570cd2235412..33fd2425edc6f 100644 --- a/app/code/Magento/MediaGalleryApi/Model/DataExtractorInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/DataExtractorInterface.php @@ -9,6 +9,7 @@ /** * Extract data from an object using available getters + * @api */ interface DataExtractorInterface { diff --git a/app/code/Magento/MediaGalleryApi/Model/Directory/Command/CreateByPathInterface.php b/app/code/Magento/MediaGalleryApi/Model/Directory/Command/CreateByPathInterface.php new file mode 100644 index 0000000000000..59a371cdb823f --- /dev/null +++ b/app/code/Magento/MediaGalleryApi/Model/Directory/Command/CreateByPathInterface.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGalleryApi\Model\Directory\Command; + +/** + * Create folder by provided path + * @api + */ +interface CreateByPathInterface +{ + /** + * Create new directory by provided path + * + * @param string $path + * @param string $name + * @throws \Magento\Framework\Exception\CouldNotSaveException + */ + public function execute(string $path, string $name): void; +} diff --git a/app/code/Magento/MediaGalleryApi/Model/Directory/Command/DeleteByPathInterface.php b/app/code/Magento/MediaGalleryApi/Model/Directory/Command/DeleteByPathInterface.php new file mode 100644 index 0000000000000..d43d7199ef4f1 --- /dev/null +++ b/app/code/Magento/MediaGalleryApi/Model/Directory/Command/DeleteByPathInterface.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGalleryApi\Model\Directory\Command; + +/** + * Delete folder by provided path + * @api + */ +interface DeleteByPathInterface +{ + /** + * Deletes the existing folder + * + * @param string $path + * @throws \Magento\Framework\Exception\CouldNotDeleteException + */ + public function execute(string $path): void; +} diff --git a/app/code/Magento/MediaGalleryApi/Model/Directory/ExcludedInterface.php b/app/code/Magento/MediaGalleryApi/Model/Directory/ExcludedInterface.php new file mode 100644 index 0000000000000..159813a7094a3 --- /dev/null +++ b/app/code/Magento/MediaGalleryApi/Model/Directory/ExcludedInterface.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGalleryApi\Model\Directory; + +/** + * Directory paths that should not be included in the media gallery + * @api + */ +interface ExcludedInterface +{ + /** + * Check if the path is excluded from displaying in the media gallery + * + * @param string $path + * @return bool + */ + public function isExcluded(string $path): bool; +} diff --git a/app/code/Magento/MediaGalleryApi/Model/File/Command/DeleteByAssetIdInterface.php b/app/code/Magento/MediaGalleryApi/Model/File/Command/DeleteByAssetIdInterface.php new file mode 100644 index 0000000000000..a73a29e8de1dd --- /dev/null +++ b/app/code/Magento/MediaGalleryApi/Model/File/Command/DeleteByAssetIdInterface.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGalleryApi\Model\File\Command; + +/** + * Load Media Asset path from database by id and delete the file + * @api + */ +interface DeleteByAssetIdInterface +{ + /** + * Delete the file by asset ID + * + * @param int $assetId + * @return void + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function execute(int $assetId): void; +} diff --git a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php index d449df5684c4b..613301c0fd210 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php @@ -9,6 +9,7 @@ /** * A command represents functionality to get a media gallery asset keywords filtered by media gallery asset id. + * @api */ interface GetAssetKeywordsInterface { @@ -16,7 +17,6 @@ interface GetAssetKeywordsInterface * Get asset related keywords. * * @param int $assetId - * * @return \Magento\MediaGalleryApi\Api\Data\KeywordInterface[] */ public function execute(int $assetId): array; diff --git a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php index 9c0d89c3456f8..3c305a29296e7 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php @@ -9,6 +9,7 @@ /** * A command represents the media gallery asset keywords save operation. + * @api */ interface SaveAssetKeywordsInterface { From abb45035cf13ea8cd7734f52b2a88afd46393a06 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Mon, 30 Mar 2020 19:36:21 +0100 Subject: [PATCH 037/177] Fixed static tests --- .../MediaGallery/Model/Asset/Command/GetById.php | 2 +- .../Model/File/Command/DeleteByAssetId.php | 2 -- .../Model/Keyword/Command/GetAssetKeywords.php | 2 +- .../Test/Unit/Model/Directory/ExcludedTest.php | 4 ++-- .../Unit/Model/File/Command/DeleteByAssetIdTest.php | 10 +++++----- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php b/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php index b6153c45dbf8c..4475d5570c988 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php @@ -16,7 +16,7 @@ use Psr\Log\LoggerInterface; /** - * Class GetById + * Get media asset by id */ class GetById implements GetByIdInterface { diff --git a/app/code/Magento/MediaGallery/Model/File/Command/DeleteByAssetId.php b/app/code/Magento/MediaGallery/Model/File/Command/DeleteByAssetId.php index 177c67280580c..dff91e73c8c7a 100644 --- a/app/code/Magento/MediaGallery/Model/File/Command/DeleteByAssetId.php +++ b/app/code/Magento/MediaGallery/Model/File/Command/DeleteByAssetId.php @@ -55,9 +55,7 @@ public function __construct( * Delete image by asset ID * * @param int $assetId - * * @return void - * * @throws LocalizedException */ public function execute(int $assetId): void diff --git a/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php b/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php index ae61867884c7a..6cd8bd2463a2c 100644 --- a/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php +++ b/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php @@ -15,7 +15,7 @@ use Psr\Log\LoggerInterface; /** - * ClassGetAssetKeywords + * Retrieve keywords for the media asset */ class GetAssetKeywords implements GetAssetKeywordsInterface { diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/ExcludedTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/ExcludedTest.php index e468bee7cc5d7..ea9094b3ac1f4 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/ExcludedTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/ExcludedTest.php @@ -5,14 +5,14 @@ */ declare(strict_types=1); -namespace Magento\MediaGallery\Test\Unit\Model\File\Command; +namespace Magento\MediaGallery\Test\Unit\Model\Directory; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use PHPUnit\Framework\TestCase; use Magento\MediaGallery\Model\Directory\Excluded; /** - * Test the DeleteByAssetIdTest command model + * Test the Excluded model */ class ExcludedTest extends TestCase { diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/File/Command/DeleteByAssetIdTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/File/Command/DeleteByAssetIdTest.php index de5b5d42c71e3..903b366d0a9fd 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/File/Command/DeleteByAssetIdTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/File/Command/DeleteByAssetIdTest.php @@ -7,16 +7,16 @@ namespace Magento\MediaGallery\Test\Unit\Model\File\Command; +use Magento\Cms\Model\Wysiwyg\Images\Storage; use Magento\Framework\App\Filesystem\DirectoryList; -use Magento\MediaGalleryApi\Api\Data\AssetInterface; -use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\Filesystem; use Magento\Framework\Filesystem\Directory\Read; -use Magento\Cms\Model\Wysiwyg\Images\Storage; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\MediaGalleryApi\Api\Data\AssetInterface; use Magento\MediaGalleryApi\Model\Asset\Command\GetByIdInterface; use Magento\MediaGallery\Model\File\Command\DeleteByAssetId; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; /** * Test the DeleteByAssetIdTest command model From f905e5f602076006f7d5b0ae46729a7f50f5d47b Mon Sep 17 00:00:00 2001 From: DianaRusin <rusind95@gmail.com> Date: Tue, 31 Mar 2020 13:24:08 +0300 Subject: [PATCH 038/177] MC-32697: [2.4] AbstractSimpleObjectBuilder.php throws exception when Interceptor instance comes. --- .../Framework/Api/AbstractSimpleObjectBuilder.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php b/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php index cf7f7732c116c..029a78bf0ddf7 100644 --- a/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php +++ b/lib/internal/Magento/Framework/Api/AbstractSimpleObjectBuilder.php @@ -67,14 +67,13 @@ protected function _set($key, $value) */ protected function _getDataObjectType() { - $currentClass = get_class($this); - $suffix = 'Builder'; - $interceptorSuffix = '\Interceptor'; - if (false !== strpos($currentClass, $interceptorSuffix, -strlen($interceptorSuffix))) { - $suffix .= $interceptorSuffix; + $dataObjectType = ''; + $pattern = '/(?<data_object>.*?)Builder(\\Interceptor)?/'; + if (preg_match($pattern, get_class($this), $match)) { + $dataObjectType = $match['data_object']; } - return substr($currentClass, 0, -strlen($suffix)); + return $dataObjectType; } /** From 1ee76f0d3f9a4adfd6d64ccce92c04a969efa13f Mon Sep 17 00:00:00 2001 From: Ihor Sviziev <svizev.igor@gmail.com> Date: Tue, 31 Mar 2020 21:57:46 +0300 Subject: [PATCH 039/177] Upgrade to phpunit 8 Update unit tests in Amqp module --- .../Test/Unit/Setup/ConfigOptionsListTest.php | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Amqp/Test/Unit/Setup/ConfigOptionsListTest.php b/app/code/Magento/Amqp/Test/Unit/Setup/ConfigOptionsListTest.php index 5b19ba055d059..57d9372dc0f0d 100644 --- a/app/code/Magento/Amqp/Test/Unit/Setup/ConfigOptionsListTest.php +++ b/app/code/Magento/Amqp/Test/Unit/Setup/ConfigOptionsListTest.php @@ -6,12 +6,16 @@ namespace Magento\Amqp\Test\Unit\Setup; +use Magento\Amqp\Setup\ConnectionValidator; +use Magento\Framework\Config\Data\ConfigData; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Amqp\Setup\ConfigOptionsList; use Magento\Framework\Setup\Option\TextConfigOption; use Magento\Framework\App\DeploymentConfig; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; -class ConfigOptionsListTest extends \PHPUnit\Framework\TestCase +class ConfigOptionsListTest extends TestCase { /** * @var ObjectManager @@ -24,12 +28,12 @@ class ConfigOptionsListTest extends \PHPUnit\Framework\TestCase private $model; /** - * @var \Magento\Amqp\Setup\ConnectionValidator|\PHPUnit_Framework_MockObject_MockObject + * @var ConnectionValidator|MockObject */ private $connectionValidatorMock; /** - * @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject + * @var DeploymentConfig|MockObject */ private $deploymentConfigMock; @@ -38,7 +42,7 @@ class ConfigOptionsListTest extends \PHPUnit\Framework\TestCase */ private $options; - protected function setUp() + protected function setUp(): void { $this->options = [ ConfigOptionsList::INPUT_KEY_QUEUE_AMQP_HOST => 'host', @@ -51,18 +55,18 @@ protected function setUp() ]; $this->objectManager = new ObjectManager($this); - $this->connectionValidatorMock = $this->getMockBuilder(\Magento\Amqp\Setup\ConnectionValidator::class) + $this->connectionValidatorMock = $this->getMockBuilder(ConnectionValidator::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->deploymentConfigMock = $this->getMockBuilder(\Magento\Framework\App\DeploymentConfig::class) + $this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class) ->disableOriginalConstructor() ->setMethods([]) ->getMock(); $this->model = $this->objectManager->getObject( - \Magento\Amqp\Setup\ConfigOptionsList::class, + ConfigOptionsList::class, [ 'connectionValidator' => $this->connectionValidatorMock, ] @@ -135,9 +139,9 @@ public function testCreateConfig($options, $expectedConfigData) $result = $this->model->createConfig($options, $this->deploymentConfigMock); $this->assertInternalType('array', $result); $this->assertNotEmpty($result); - /** @var \Magento\Framework\Config\Data\ConfigData $configData */ + /** @var ConfigData $configData */ $configData = $result[0]; - $this->assertInstanceOf(\Magento\Framework\Config\Data\ConfigData::class, $configData); + $this->assertInstanceOf(ConfigData::class, $configData); $this->assertEquals($expectedConfigData, $configData->getData()); } From d88ed422fadb1cdb32ef56317d22fe53d1139299 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Wed, 1 Apr 2020 16:33:38 +0100 Subject: [PATCH 040/177] Introduced MediaContent and MediaContentApi modules --- .../Observer/MediaContent/Category.php | 56 ++++++ .../Catalog/Observer/MediaContent/Product.php | 56 ++++++ app/code/Magento/Catalog/composer.json | 1 + app/code/Magento/Catalog/etc/di.xml | 23 +++ app/code/Magento/Catalog/etc/events.xml | 6 + .../Cms/Observer/MediaContent/Block.php | 56 ++++++ .../Cms/Observer/MediaContent/Page.php | 56 ++++++ app/code/Magento/Cms/composer.json | 1 + app/code/Magento/Cms/etc/di.xml | 21 +++ app/code/Magento/Cms/etc/events.xml | 6 + app/code/Magento/MediaContent/LICENSE.txt | 48 +++++ app/code/Magento/MediaContent/LICENSE_AFL.txt | 48 +++++ .../MediaContent/Model/AssignAsset.php | 69 +++++++ .../MediaContent/Model/ContentProcessor.php | 117 ++++++++++++ .../Model/ExtractAssetFromContent.php | 91 +++++++++ .../Model/GetAssetsUsedInContent.php | 76 ++++++++ .../Model/GetContentWithAsset.php | 63 +++++++ .../MediaContent/Model/ModelProcessor.php | 54 ++++++ .../MediaContent/Model/UnassignAsset.php | 71 +++++++ app/code/Magento/MediaContent/README.md | 13 ++ .../Test/Unit/Model/AssignAssetTest.php | 177 ++++++++++++++++++ .../Unit/Model/GetAssetsusedInContentTest.php | 148 +++++++++++++++ .../Unit/Model/GetContentWithAssetTest.php | 107 +++++++++++ .../Test/Unit/Model/UnassignAssetTest.php | 171 +++++++++++++++++ app/code/Magento/MediaContent/composer.json | 24 +++ .../Magento/MediaContent/etc/db_schema.xml | 21 +++ .../MediaContent/etc/db_schema_whitelist.json | 14 ++ app/code/Magento/MediaContent/etc/di.xml | 15 ++ app/code/Magento/MediaContent/etc/module.xml | 14 ++ .../Magento/MediaContent/registration.php | 10 + .../Api/AssignAssetInterface.php | 26 +++ .../Api/ExtractAssetFromContentInterface.php | 25 +++ .../Api/GetAssetsUsedInContentInterface.php | 28 +++ .../Api/GetContentWithAssetInterface.php | 24 +++ .../Api/ModelProcessorInterface.php | 26 +++ .../Api/UnassignAssetInterface.php | 26 +++ app/code/Magento/MediaContentApi/LICENSE.txt | 48 +++++ .../Magento/MediaContentApi/LICENSE_AFL.txt | 48 +++++ app/code/Magento/MediaContentApi/README.md | 13 ++ .../Magento/MediaContentApi/composer.json | 22 +++ .../Magento/MediaContentApi/etc/module.xml | 10 + .../Magento/MediaContentApi/registration.php | 10 + 42 files changed, 1939 insertions(+) create mode 100644 app/code/Magento/Catalog/Observer/MediaContent/Category.php create mode 100644 app/code/Magento/Catalog/Observer/MediaContent/Product.php create mode 100644 app/code/Magento/Cms/Observer/MediaContent/Block.php create mode 100644 app/code/Magento/Cms/Observer/MediaContent/Page.php create mode 100644 app/code/Magento/MediaContent/LICENSE.txt create mode 100644 app/code/Magento/MediaContent/LICENSE_AFL.txt create mode 100644 app/code/Magento/MediaContent/Model/AssignAsset.php create mode 100644 app/code/Magento/MediaContent/Model/ContentProcessor.php create mode 100644 app/code/Magento/MediaContent/Model/ExtractAssetFromContent.php create mode 100644 app/code/Magento/MediaContent/Model/GetAssetsUsedInContent.php create mode 100644 app/code/Magento/MediaContent/Model/GetContentWithAsset.php create mode 100644 app/code/Magento/MediaContent/Model/ModelProcessor.php create mode 100644 app/code/Magento/MediaContent/Model/UnassignAsset.php create mode 100644 app/code/Magento/MediaContent/README.md create mode 100644 app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetTest.php create mode 100644 app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php create mode 100644 app/code/Magento/MediaContent/Test/Unit/Model/GetContentWithAssetTest.php create mode 100644 app/code/Magento/MediaContent/Test/Unit/Model/UnassignAssetTest.php create mode 100644 app/code/Magento/MediaContent/composer.json create mode 100644 app/code/Magento/MediaContent/etc/db_schema.xml create mode 100644 app/code/Magento/MediaContent/etc/db_schema_whitelist.json create mode 100644 app/code/Magento/MediaContent/etc/di.xml create mode 100644 app/code/Magento/MediaContent/etc/module.xml create mode 100644 app/code/Magento/MediaContent/registration.php create mode 100644 app/code/Magento/MediaContentApi/Api/AssignAssetInterface.php create mode 100644 app/code/Magento/MediaContentApi/Api/ExtractAssetFromContentInterface.php create mode 100644 app/code/Magento/MediaContentApi/Api/GetAssetsUsedInContentInterface.php create mode 100644 app/code/Magento/MediaContentApi/Api/GetContentWithAssetInterface.php create mode 100644 app/code/Magento/MediaContentApi/Api/ModelProcessorInterface.php create mode 100644 app/code/Magento/MediaContentApi/Api/UnassignAssetInterface.php create mode 100644 app/code/Magento/MediaContentApi/LICENSE.txt create mode 100644 app/code/Magento/MediaContentApi/LICENSE_AFL.txt create mode 100644 app/code/Magento/MediaContentApi/README.md create mode 100644 app/code/Magento/MediaContentApi/composer.json create mode 100644 app/code/Magento/MediaContentApi/etc/module.xml create mode 100644 app/code/Magento/MediaContentApi/registration.php diff --git a/app/code/Magento/Catalog/Observer/MediaContent/Category.php b/app/code/Magento/Catalog/Observer/MediaContent/Category.php new file mode 100644 index 0000000000000..0044a7301e67b --- /dev/null +++ b/app/code/Magento/Catalog/Observer/MediaContent/Category.php @@ -0,0 +1,56 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Observer\MediaContent; + +use Magento\Catalog\Model\Category as CatalogCategory; +use Magento\Framework\Event\Observer; +use Magento\Framework\Event\ObserverInterface; +use Magento\Framework\Model\AbstractModel; +use Magento\MediaContentApi\Api\ModelProcessorInterface; + +/** + * Observe the catalog_category_save_after event and run processing relation between category content and media asset. + */ +class Category implements ObserverInterface +{ + private const CONTENT_TYPE = 'catalog_category'; + + /** + * @var ModelProcessorInterface + */ + private $processor; + + /** + * @var array + */ + private $fields; + + /** + * @param ModelProcessorInterface $processor + * @param array $fields + */ + public function __construct(ModelProcessorInterface $processor, array $fields) + { + $this->processor = $processor; + $this->fields = $fields; + } + + /** + * Retrieve the saved category and pass it to the model processor to save content - asset relations + * + * @param Observer $observer + */ + public function execute(Observer $observer): void + { + /** @var CatalogCategory $model */ + $model = $observer->getEvent()->getData('category'); + if ($model instanceof AbstractModel) { + $this->processor->execute(self::CONTENT_TYPE, $model, $this->fields); + } + } +} diff --git a/app/code/Magento/Catalog/Observer/MediaContent/Product.php b/app/code/Magento/Catalog/Observer/MediaContent/Product.php new file mode 100644 index 0000000000000..bb043712a44f2 --- /dev/null +++ b/app/code/Magento/Catalog/Observer/MediaContent/Product.php @@ -0,0 +1,56 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Observer\MediaContent; + +use Magento\Catalog\Model\Product as CatalogProduct; +use Magento\Framework\Event\Observer; +use Magento\Framework\Event\ObserverInterface; +use Magento\Framework\Model\AbstractModel; +use Magento\MediaContentApi\Api\ModelProcessorInterface; + +/** + * Observe the catalog_product_save_after event and run processing relation between product content and media asset + */ +class Product implements ObserverInterface +{ + private const CONTENT_TYPE = 'catalog_product'; + + /** + * @var ModelProcessorInterface + */ + private $processor; + + /** + * @var array + */ + private $fields; + + /** + * @param ModelProcessorInterface $processor + * @param array $fields + */ + public function __construct(ModelProcessorInterface $processor, array $fields) + { + $this->processor = $processor; + $this->fields = $fields; + } + + /** + * Retrieve the saved product and pass it to the model processor to save content - asset relations + * + * @param Observer $observer + */ + public function execute(Observer $observer): void + { + /** @var CatalogProduct $model */ + $model = $observer->getEvent()->getData('product'); + if ($model instanceof AbstractModel) { + $this->processor->execute(self::CONTENT_TYPE, $model, $this->fields); + } + } +} diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index 8023634fa074d..660c496b5a8f0 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -20,6 +20,7 @@ "magento/module-directory": "*", "magento/module-eav": "*", "magento/module-indexer": "*", + "magento/module-media-content-api": "*", "magento/module-media-storage": "*", "magento/module-msrp": "*", "magento/module-page-cache": "*", diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index ff67989d337bb..5f8710fef0ac9 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1333,4 +1333,27 @@ </argument> </arguments> </type> + <type name="Magento\Catalog\Observer\MediaContent\Category"> + <arguments> + <argument name="fields" xsi:type="array"> + <item name="image" xsi:type="string">image</item> + <item name="description" xsi:type="string">description</item> + </argument> + </arguments> + </type> + <type name="Magento\Catalog\Observer\MediaContent\Product"> + <arguments> + <argument name="fields" xsi:type="array"> + <item name="description" xsi:type="string">description</item> + <item name="short_description" xsi:type="string">short_description</item> + </argument> + </arguments> + </type> + <type name="Magento\MediaContentApi\Api\ExtractAssetFromContentInterface"> + <arguments> + <argument name="searchPatterns" xsi:type="array"> + <item name="catalog_image" xsi:type="string">/^\/?media\/(.*)/</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Catalog/etc/events.xml b/app/code/Magento/Catalog/etc/events.xml index 24186146c56f0..bb28dc00b50f2 100644 --- a/app/code/Magento/Catalog/etc/events.xml +++ b/app/code/Magento/Catalog/etc/events.xml @@ -67,4 +67,10 @@ <event name="catalog_category_prepare_save"> <observer name="additional_authorization" instance="Magento\Catalog\Observer\CategoryDesignAuthorization" /> </event> + <event name="catalog_category_save_after"> + <observer name="media_content_catalog_category_save_after" instance="Magento\Catalog\Observer\MediaContent\Category" /> + </event> + <event name="catalog_product_save_after"> + <observer name="media_content_catalog_product_save_after" instance="Magento\Catalog\Observer\MediaContent\Product" /> + </event> </config> diff --git a/app/code/Magento/Cms/Observer/MediaContent/Block.php b/app/code/Magento/Cms/Observer/MediaContent/Block.php new file mode 100644 index 0000000000000..80fe854531586 --- /dev/null +++ b/app/code/Magento/Cms/Observer/MediaContent/Block.php @@ -0,0 +1,56 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Cms\Observer\MediaContent; + +use Magento\Cms\Block\Block as CmsBlock; +use Magento\Framework\Event\Observer; +use Magento\Framework\Event\ObserverInterface; +use Magento\Framework\Model\AbstractModel; +use Magento\MediaContentApi\Api\ModelProcessorInterface; + +/** + * Observe cms_block_save_after event and run processing relation between cms block content and media asset + */ +class Block implements ObserverInterface +{ + private const CONTENT_TYPE = 'cms_block'; + + /** + * @var ModelProcessorInterface + */ + private $processor; + + /** + * @var array + */ + private $fields; + + /** + * @param ModelProcessorInterface $processor + * @param array $fields + */ + public function __construct(ModelProcessorInterface $processor, array $fields) + { + $this->processor = $processor; + $this->fields = $fields; + } + + /** + * Retrieve the saved block and pass it to the model processor to save content - asset relations + * + * @param Observer $observer + */ + public function execute(Observer $observer): void + { + /** @var CmsBlock $model */ + $model = $observer->getEvent()->getData('object'); + if ($model instanceof AbstractModel) { + $this->processor->execute(self::CONTENT_TYPE, $model, $this->fields); + } + } +} diff --git a/app/code/Magento/Cms/Observer/MediaContent/Page.php b/app/code/Magento/Cms/Observer/MediaContent/Page.php new file mode 100644 index 0000000000000..cc4fe14990a86 --- /dev/null +++ b/app/code/Magento/Cms/Observer/MediaContent/Page.php @@ -0,0 +1,56 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Cms\Observer\MediaContent; + +use Magento\Cms\Model\Page as CmsPage; +use Magento\Framework\Event\Observer; +use Magento\Framework\Event\ObserverInterface; +use Magento\Framework\Model\AbstractModel; +use Magento\MediaContentApi\Api\ModelProcessorInterface; + +/** + * Observe cms_page_save_after event and run processing relation between cms page content and media asset. + */ +class Page implements ObserverInterface +{ + private const CONTENT_TYPE = 'cms_page'; + + /** + * @var ModelProcessorInterface + */ + private $processor; + + /** + * @var array + */ + private $fields; + + /** + * @param ModelProcessorInterface $processor + * @param array $fields + */ + public function __construct(ModelProcessorInterface $processor, array $fields) + { + $this->processor = $processor; + $this->fields = $fields; + } + + /** + * Retrieve the saved page and pass it to the model processor to save content - asset relations + * + * @param Observer $observer + */ + public function execute(Observer $observer): void + { + /** @var CmsPage $model */ + $model = $observer->getEvent()->getData('object'); + if ($model instanceof AbstractModel) { + $this->processor->execute(self::CONTENT_TYPE, $model, $this->fields); + } + } +} diff --git a/app/code/Magento/Cms/composer.json b/app/code/Magento/Cms/composer.json index 91036d31fdc2b..c299ba63f9a96 100644 --- a/app/code/Magento/Cms/composer.json +++ b/app/code/Magento/Cms/composer.json @@ -10,6 +10,7 @@ "magento/module-backend": "*", "magento/module-catalog": "*", "magento/module-email": "*", + "magento/module-media-content-api": "*", "magento/module-media-storage": "*", "magento/module-store": "*", "magento/module-theme": "*", diff --git a/app/code/Magento/Cms/etc/di.xml b/app/code/Magento/Cms/etc/di.xml index 7fc8268eea5e0..0f573047d098f 100644 --- a/app/code/Magento/Cms/etc/di.xml +++ b/app/code/Magento/Cms/etc/di.xml @@ -243,4 +243,25 @@ </arguments> </type> <preference for="Magento\Cms\Model\Page\CustomLayoutRepositoryInterface" type="Magento\Cms\Model\Page\CustomLayout\CustomLayoutRepository" /> + <type name="Magento\Cms\Observer\MediaContent\Block"> + <arguments> + <argument name="fields" xsi:type="array"> + <item name="content" xsi:type="string">content</item> + </argument> + </arguments> + </type> + <type name="Magento\Cms\Observer\MediaContent\Page"> + <arguments> + <argument name="fields" xsi:type="array"> + <item name="content" xsi:type="string">content</item> + </argument> + </arguments> + </type> + <type name="Magento\MediaContentApi\Api\ExtractAssetFromContentInterface"> + <arguments> + <argument name="searchPatterns" xsi:type="array"> + <item name="media_gallery" xsi:type="string">/{{media url="?(.*?)"?}}/</item> + </argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/Cms/etc/events.xml b/app/code/Magento/Cms/etc/events.xml index 1ad847e215ccc..a49e1638f0ab2 100644 --- a/app/code/Magento/Cms/etc/events.xml +++ b/app/code/Magento/Cms/etc/events.xml @@ -39,4 +39,10 @@ <event name="cms_page_prepare_save"> <observer name="validate_cms_page" instance="Magento\Cms\Observer\PageValidatorObserver" /> </event> + <event name="cms_page_save_after"> + <observer name="media_content_cms_page_save_after" instance="\Magento\Cms\Observer\MediaContent\Page" /> + </event> + <event name="cms_block_save_after"> + <observer name="media_content_cms_block_save_after" instance="\Magento\Cms\Observer\MediaContent\Block" /> + </event> </config> diff --git a/app/code/Magento/MediaContent/LICENSE.txt b/app/code/Magento/MediaContent/LICENSE.txt new file mode 100644 index 0000000000000..49525fd99da9c --- /dev/null +++ b/app/code/Magento/MediaContent/LICENSE.txt @@ -0,0 +1,48 @@ + +Open Software License ("OSL") v. 3.0 + +This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Open Software License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + 1. to reproduce the Original Work in copies, either alone or as part of a collective work; + + 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; + + 4. to perform the Original Work publicly; and + + 5. to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magento/MediaContent/LICENSE_AFL.txt b/app/code/Magento/MediaContent/LICENSE_AFL.txt new file mode 100644 index 0000000000000..f39d641b18a19 --- /dev/null +++ b/app/code/Magento/MediaContent/LICENSE_AFL.txt @@ -0,0 +1,48 @@ + +Academic Free License ("AFL") v. 3.0 + +This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Academic Free License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + 1. to reproduce the Original Work in copies, either alone or as part of a collective work; + + 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License; + + 4. to perform the Original Work publicly; and + + 5. to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. diff --git a/app/code/Magento/MediaContent/Model/AssignAsset.php b/app/code/Magento/MediaContent/Model/AssignAsset.php new file mode 100644 index 0000000000000..ada7e9adf20ef --- /dev/null +++ b/app/code/Magento/MediaContent/Model/AssignAsset.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\MediaContentApi\Api\AssignAssetInterface; +use Psr\Log\LoggerInterface; + +/** + * Used for saving relation between the media asset and media content where the media asset is used + */ +class AssignAsset implements AssignAssetInterface +{ + private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; + private const ASSET_ID = 'asset_id'; + private const TYPE = 'type'; + private const ENTITY_ID = 'entity_id'; + private const FIELD = 'field'; + + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * AssignAsset constructor. + * + * @param ResourceConnection $resourceConnection + * @param LoggerInterface $logger + */ + public function __construct(ResourceConnection $resourceConnection, LoggerInterface $logger) + { + $this->resourceConnection = $resourceConnection; + $this->logger = $logger; + } + + /** + * @inheritDoc + */ + public function execute(int $assetId, string $contentType, string $contentEntityId, string $contentField): void + { + try { + $connection = $this->resourceConnection->getConnection(); + $tableName = $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME); + $saveData = [ + self::ASSET_ID => $assetId, + self::TYPE => $contentType, + self::ENTITY_ID => $contentEntityId, + self::FIELD => $contentField + ]; + $connection->insert($tableName, $saveData); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $message = __('An error occurred while saving relation between media asset and media content.'); + throw new CouldNotSaveException($message); + } + } +} diff --git a/app/code/Magento/MediaContent/Model/ContentProcessor.php b/app/code/Magento/MediaContent/Model/ContentProcessor.php new file mode 100644 index 0000000000000..2d8fc45506e89 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/ContentProcessor.php @@ -0,0 +1,117 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\IntegrationException; +use Magento\MediaContentApi\Api\AssignAssetInterface; +use Magento\MediaContentApi\Api\GetAssetsUsedInContentInterface; +use Magento\MediaContentApi\Api\UnassignAssetInterface; +use Magento\MediaGalleryApi\Api\Data\AssetInterface; +use Psr\Log\LoggerInterface; + +/** + * Process relation managing between media asset and content: assign or unassign relation if exists. + */ +class ContentProcessor +{ + /** + * @var ExtractAssetFromContent + */ + private $extractAssetFromContent; + + /** + * @var AssignAssetInterface + */ + private $assignAsset; + + /** + * @var GetAssetsUsedInContentInterface + */ + private $getAssetsUsedInContent; + + /** + * @var UnassignAssetInterface + */ + private $unassignAsset; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * ContentProcessor constructor. + * + * @param ExtractAssetFromContent $extractAssetFromContent + * @param AssignAssetInterface $assignAsset + * @param GetAssetsUsedInContentInterface $getAssetsUsedInContent + * @param UnassignAssetInterface $unassignAsset + * @param LoggerInterface $logger + */ + public function __construct( + ExtractAssetFromContent $extractAssetFromContent, + AssignAssetInterface $assignAsset, + GetAssetsUsedInContentInterface $getAssetsUsedInContent, + UnassignAssetInterface $unassignAsset, + LoggerInterface $logger + ) { + $this->extractAssetFromContent = $extractAssetFromContent; + $this->assignAsset = $assignAsset; + $this->getAssetsUsedInContent = $getAssetsUsedInContent; + $this->unassignAsset = $unassignAsset; + $this->logger = $logger; + } + + /** + * Create new relation between media asset and content or updated existing + * + * @param string $type + * @param string $field + * @param string $entityId + * @param string $data + */ + public function execute(string $type, string $field, string $entityId, string $data): void + { + try { + $this->updateRelation($type, $field, $entityId, $data); + } catch (\Exception $exception) { + $this->logger->critical($exception); + } + } + + /** + * Records a relation for the newly added asset + * + * @param string $type + * @param string $field + * @param string $entityId + * @param string $data + * @throws CouldNotDeleteException + * @throws CouldNotSaveException + * @throws IntegrationException + */ + private function updateRelation(string $type, string $field, string $entityId, string $data) + { + $relations = $this->getAssetsUsedInContent->execute($type, $entityId, $field); + $assetsInContent = $this->extractAssetFromContent->execute($data); + /** @var AssetInterface $asset */ + foreach ($assetsInContent as $asset) { + if (!isset($relations[$asset->getId()])) { + $this->assignAsset->execute($asset->getId(), $type, $entityId, $field); + } + } + + foreach (array_keys($relations) as $assetId) { + if (!isset($assetsInContent[$assetId])) { + $this->unassignAsset->execute($assetId, $type, $entityId, $field); + } + } + } +} diff --git a/app/code/Magento/MediaContent/Model/ExtractAssetFromContent.php b/app/code/Magento/MediaContent/Model/ExtractAssetFromContent.php new file mode 100644 index 0000000000000..5f379080bc0f1 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/ExtractAssetFromContent.php @@ -0,0 +1,91 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\MediaGalleryApi\Api\Data\AssetInterface; +use Magento\MediaGalleryApi\Model\Asset\Command\GetByPathInterface; +use Psr\Log\LoggerInterface; + +/** + * Used for extracting media asset list from a media content by the search pattern. + */ +class ExtractAssetFromContent +{ + /** + * @var string + */ + private $searchPatterns; + + /** + * @var GetByPathInterface + */ + private $getMediaAssetByPath; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * @param GetByPathInterface $getMediaAssetByPath + * @param LoggerInterface $logger + * @param array $searchPatterns + */ + public function __construct( + GetByPathInterface $getMediaAssetByPath, + LoggerInterface $logger, + array $searchPatterns + ) { + $this->getMediaAssetByPath = $getMediaAssetByPath; + $this->logger = $logger; + $this->searchPatterns = $searchPatterns; + } + + /** + * Search for the media asset in content and extract it providing a list of media assets. + * + * @param string $content + * @return AssetInterface[] + */ + public function execute(string $content): array + { + $paths = []; + + foreach ($this->searchPatterns as $pattern) { + preg_match_all($pattern, $content, $matches, PREG_PATTERN_ORDER); + if (!empty($matches[1])) { + $paths += array_unique($matches[1]); + } + } + + return $this->getAssetsByPaths(array_unique($paths)); + } + + /** + * Get media assets by paths array + * + * @param array $paths + * @return AssetInterface[] + */ + private function getAssetsByPaths(array $paths): array + { + $assets = []; + + foreach ($paths as $path) { + try { + /** @var AssetInterface $asset */ + $asset = $this->getMediaAssetByPath->execute('/' . $path); + $assets[$asset->getId()] = $asset; + } catch (\Exception $exception) { + $this->logger->critical($exception); + } + } + + return $assets; + } +} diff --git a/app/code/Magento/MediaContent/Model/GetAssetsUsedInContent.php b/app/code/Magento/MediaContent/Model/GetAssetsUsedInContent.php new file mode 100644 index 0000000000000..2baa022713d8f --- /dev/null +++ b/app/code/Magento/MediaContent/Model/GetAssetsUsedInContent.php @@ -0,0 +1,76 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\Exception\IntegrationException; +use Magento\MediaContentApi\Api\GetAssetsUsedInContentInterface; +use Psr\Log\LoggerInterface; + +/** + * Used to return media asset id list which is used in the specified media content + */ +class GetAssetsUsedInContent implements GetAssetsUsedInContentInterface +{ + private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; + private const ASSET_ID = 'asset_id'; + private const TYPE = 'type'; + private const ENTITY_ID = 'entity_id'; + private const FIELD = 'field'; + + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * GetAssetsUsedInContent constructor. + * + * @param ResourceConnection $resourceConnection + * @param LoggerInterface $logger + */ + public function __construct(ResourceConnection $resourceConnection, LoggerInterface $logger) + { + $this->resourceConnection = $resourceConnection; + $this->logger = $logger; + } + + /** + * @inheritDoc + */ + public function execute(string $contentType, string $contentEntityId = null, string $contentField = null): array + { + try { + $connection = $this->resourceConnection->getConnection(); + $select = $connection->select() + ->from( + $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME), + self::ASSET_ID + )->where(self::TYPE . ' = ?', $contentType); + + if (null !== $contentEntityId) { + $select = $select->where(self::ENTITY_ID . '= ?', $contentEntityId); + } + + if (null !== $contentField) { + $select = $select->where(self::FIELD . '= ?', $contentField); + } + + return $connection->fetchAssoc($select); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $message = __('An error occurred at getting asset used in content information.'); + throw new IntegrationException($message); + } + } +} diff --git a/app/code/Magento/MediaContent/Model/GetContentWithAsset.php b/app/code/Magento/MediaContent/Model/GetContentWithAsset.php new file mode 100644 index 0000000000000..796cc890b3845 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/GetContentWithAsset.php @@ -0,0 +1,63 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\Exception\IntegrationException; +use Magento\MediaContentApi\Api\GetContentWithAssetInterface; +use Psr\Log\LoggerInterface; + +/** + * Used to return media asset list for the specified asset. + */ +class GetContentWithAsset implements GetContentWithAssetInterface +{ + private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; + private const ASSET_ID = 'asset_id'; + + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * GetAssetsUsedInContent constructor. + * + * @param ResourceConnection $resourceConnection + * @param LoggerInterface $logger + */ + public function __construct(ResourceConnection $resourceConnection, LoggerInterface $logger) + { + $this->resourceConnection = $resourceConnection; + $this->logger = $logger; + } + + /** + * @inheritDoc + */ + public function execute(int $assetId): array + { + try { + $connection = $this->resourceConnection->getConnection(); + $select = $connection->select() + ->from($this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME)) + ->where(self::ASSET_ID . '= ?', $assetId); + + return $connection->fetchAssoc($select); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $message = __('An error occurred at getting media asset to content relation by media asset id.'); + throw new IntegrationException($message); + } + } +} diff --git a/app/code/Magento/MediaContent/Model/ModelProcessor.php b/app/code/Magento/MediaContent/Model/ModelProcessor.php new file mode 100644 index 0000000000000..8e3a3ebf168d6 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/ModelProcessor.php @@ -0,0 +1,54 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\Framework\Model\AbstractModel; + +/** + * Save relations for content within an AbstractModel instance + */ +class ModelProcessor implements ModelProcessorInterface +{ + /** + * Content processor + * + * @var ContentProcessor + */ + private $contentProcessor; + + /** + * @param ContentProcessor $contentProcessor + */ + public function __construct( + ContentProcessor $contentProcessor + ) { + $this->contentProcessor = $contentProcessor; + } + + /** + * Save relations for content within an AbstractModel instance + * + * @param string $type + * @param AbstractModel $model + * @param array $fields + */ + public function execute(string $type, AbstractModel $model, array $fields): void + { + foreach ($fields as $field) { + if (!$model->dataHasChangedFor($field)) { + continue; + } + $this->contentProcessor->execute( + $type, + $field, + (string) $model->getId(), + (string) $model->getData($field) + ); + } + } +} diff --git a/app/code/Magento/MediaContent/Model/UnassignAsset.php b/app/code/Magento/MediaContent/Model/UnassignAsset.php new file mode 100644 index 0000000000000..ae5924f662403 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/UnassignAsset.php @@ -0,0 +1,71 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\MediaContentApi\Api\UnassignAssetInterface; +use Psr\Log\LoggerInterface; + +/** + * Used to unassign relation of the media asset to the media content where the media asset is used + */ +class UnassignAsset implements UnassignAssetInterface +{ + private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; + private const ASSET_ID = 'asset_id'; + private const TYPE = 'type'; + private const ENTITY_ID = 'entity_id'; + private const FIELD = 'field'; + + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * GetAssetsUsedInContent constructor. + * + * @param ResourceConnection $resourceConnection + * @param LoggerInterface $logger + */ + public function __construct(ResourceConnection $resourceConnection, LoggerInterface $logger) + { + $this->resourceConnection = $resourceConnection; + $this->logger = $logger; + } + + /** + * @inheritDoc + */ + public function execute(int $assetId, string $contentType, string $contentEntityId, string $contentField): void + { + try { + $connection = $this->resourceConnection->getConnection(); + $tableName = $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME); + $connection->delete( + $tableName, + [ + self::ASSET_ID . ' = ?' => $assetId, + self::TYPE . ' = ?' => $contentType, + self::ENTITY_ID . ' = ?' => $contentEntityId, + self::FIELD . ' = ?' => $contentField + ] + ); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $message = __('An error occurred at unassign relation between the media asset and media content.'); + throw new CouldNotDeleteException($message); + } + } +} diff --git a/app/code/Magento/MediaContent/README.md b/app/code/Magento/MediaContent/README.md new file mode 100644 index 0000000000000..b5813540acef7 --- /dev/null +++ b/app/code/Magento/MediaContent/README.md @@ -0,0 +1,13 @@ +# Magento_MediaContent module + +The Magento_MediaContent module provides implementations for managing relations between content and media files used in that content. + +## Extensibility + +Extension developers can interact with the Magento_MediaContent module. For more information about the Magento extension mechanism, see [Magento plug-ins](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html). + +[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_MediaContent module. + +## Additional information + +For information about significant changes in patch releases, see [2.3.x Release information](https://devdocs.magento.com/guides/v2.3/release-notes/bk-release-notes.html). diff --git a/app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetTest.php b/app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetTest.php new file mode 100644 index 0000000000000..98e0e8fe2606e --- /dev/null +++ b/app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetTest.php @@ -0,0 +1,177 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Test\Unit\Model; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\DB\Adapter\Pdo\Mysql; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\MediaContent\Model\AssignAsset; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; + +/** + * Tests for the AssignAsset command. + */ +class AssignAssetTest extends TestCase +{ + /** + * Media content relation data storage table name + */ + private const TABLE_MEDIA_CONTENT_ASSET = 'media_content_asset'; + + /** + * Prefixed media content relation data storage table name + */ + private const PREFIXED_TABLE_MEDIA_CONTENT_ASSET = 'prefix_' . self::TABLE_MEDIA_CONTENT_ASSET; + + /** + * Media asset id + */ + private const ASSET_ID = 'asset_id'; + + /** + * Media content type + */ + private const TYPE = 'type'; + + /** + * Media entity id + */ + private const ENTITY_ID = 'entity_id'; + + /** + * Media content field where media asset is used + */ + private const FIELD = 'field'; + + /** + * Constant for affected rows count after data insertion + */ + private const AFFECTED_ROWS = 1; + + /** + * @var ResourceConnection | MockObject + */ + private $resourceConnectionMock; + + /** + * @var AdapterInterface | MockObject + */ + private $adapterMock; + + /** + * @var LoggerInterface | MockObject + */ + private $loggerMock; + + /** + * @var AssignAsset + */ + private $assignAsset; + + /** + * Set up test mocks + */ + protected function setUp(): void + { + $this->adapterMock = $this->createMock(Mysql::class); + $this->loggerMock = $this->createMock(LoggerInterface::class); + $this->resourceConnectionMock = $this->createConfiguredMock( + ResourceConnection::class, + [ + 'getConnection' => $this->adapterMock, + 'getTableName' => self::PREFIXED_TABLE_MEDIA_CONTENT_ASSET + ] + ); + + $this->assignAsset = (new ObjectManager($this))->getObject( + AssignAsset::class, + [ + 'resourceConnection' => $this->resourceConnectionMock, + 'logger' => $this->loggerMock + ] + ); + } + + /** + * Tests successful scenario for saving relation between media asset and media content. + * + * @param int $assetId + * @param string $contentType + * @param string $contentEntityId + * @param string $contentField + * @dataProvider assignAssetDataProvider + * @return void + */ + public function testSuccessfulExecute( + int $assetId, + string $contentType, + string $contentEntityId, + string $contentField + ): void { + $saveData = [ + self::ASSET_ID => $assetId, + self::TYPE => $contentType, + self::ENTITY_ID => $contentEntityId, + self::FIELD => $contentField + ]; + $this->adapterMock + ->expects(self::once()) + ->method('insert') + ->with(self::PREFIXED_TABLE_MEDIA_CONTENT_ASSET, $saveData) + ->willReturn(self::AFFECTED_ROWS); + + $this->assignAsset->execute($assetId, $contentType, $contentEntityId, $contentField); + } + + /** + * Tests with exception scenario for saving relation between media asset and media content. + * + * @param int $assetId + * @param string $contentType + * @param string $contentEntityId + * @param string $contentField + * @dataProvider assignAssetDataProvider + */ + public function testExceptionExecute( + int $assetId, + string $contentType, + string $contentEntityId, + string $contentField + ): void { + $this->resourceConnectionMock->method('getConnection')->willThrowException((new \Exception())); + + $this->loggerMock + ->expects(self::once()) + ->method('critical') + ->willReturnSelf(); + + $this->expectException(CouldNotSaveException::class); + $this->assignAsset->execute($assetId, $contentType, $contentEntityId, $contentField); + } + + /** + * Media asset to media content relation data + * + * @return array + */ + public function assignAssetDataProvider(): array + { + return [ + [ + '18976345', + 'cms_page', + '1', + 'content' + ] + ]; + } +} diff --git a/app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php b/app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php new file mode 100644 index 0000000000000..911d9b6e6f375 --- /dev/null +++ b/app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php @@ -0,0 +1,148 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Test\Unit\Model; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\DB\Select; +use Magento\Framework\Exception\IntegrationException; +use Magento\MediaContent\Model\GetAssetsUsedInContent; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; + +/** + * Test for the GetAssetUsedInContentTest command. + */ +class GetAssetsusedInContentTest extends TestCase +{ + /** + * @var ResourceConnection | MockObject + */ + private $resourceConnectionStub; + + /** + * @var LoggerInterface | MockObject + */ + private $loggerMock; + + /** + * @var GetAssetsUsedInContent + */ + private $getAssetsUsedInContent; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + $this->resourceConnectionStub = $this->createMock(ResourceConnection::class); + $this->loggerMock = $this->createMock(LoggerInterface::class); + $this->getAssetsUsedInContent = new GetAssetsUsedInContent($this->resourceConnectionStub, $this->loggerMock); + } + + /** + * Test successful execution of the GetAssetsUsedInContent::execute. + * + * @param array $requestParameters + * @param array $expectedAssetIdList + * @dataProvider getAssetsListRelatedToContent + */ + public function testSuccessfulGetUsedAssets( + array $requestParameters, + array $expectedAssetIdList + ): void { + $this->configureResourceConnectionStub($expectedAssetIdList); + $assetList = $this->getAssetsUsedInContent->execute( + $requestParameters['type'], + $requestParameters['entity_id'], + $requestParameters['field'] + ); + + $this->assertEquals($expectedAssetIdList, $assetList); + } + + /** + * Test GetAssetsUsedInContent::execute with exception. + */ + public function testGetUsedAssetsWithException(): void + { + $this->resourceConnectionStub->method('getConnection')->willThrowException((new \Exception())); + $this->expectException(IntegrationException::class); + $this->loggerMock->expects($this->once()) + ->method('critical') + ->willReturnSelf(); + + $this->getAssetsUsedInContent->execute('cms_page', '1', 'content'); + } + + /** + * Configure resource connection for the command. Based on the current implementation. + * + * @param array $expectedAssetIdList + */ + private function configureResourceConnectionStub(array $expectedAssetIdList): void + { + $selectStub = $this->createMock(Select::class); + $selectStub->expects($this->any())->method('from')->willReturnSelf(); + $selectStub->expects($this->any())->method('where')->willReturnSelf(); + + $connectionMock = $this->getMockBuilder(AdapterInterface::class)->getMock(); + $connectionMock->expects($this->any())->method('select')->willReturn($selectStub); + $connectionMock->expects($this->any()) + ->method('fetchAssoc') + ->with($selectStub) + ->willReturn($expectedAssetIdList); + $this->resourceConnectionStub->expects($this->any()) + ->method('getConnection') + ->willReturn($connectionMock); + } + + /** + * Media asset to media content relation data + * + * @return array + */ + public function getAssetsListRelatedToContent(): array + { + return [ + [ + [ + 'type' => 'cms_page', + 'entity_id' => '1', + 'field' => 'content' + ], + [1234123] + ], + [ + [ + 'type' => 'cms_page', + 'entity_id' => null, + 'field' => 'content' + ], + [1234123, 2425168] + ], + [ + [ + 'type' => 'catalog_category', + 'entity_id' => '1', + 'field' => null + ], + [1234123] + ], + [ + [ + 'type' => 'cbm_block', + 'entity_id' => null, + 'field' => null + ], + [1234123, 2425168] + ] + ]; + } +} diff --git a/app/code/Magento/MediaContent/Test/Unit/Model/GetContentWithAssetTest.php b/app/code/Magento/MediaContent/Test/Unit/Model/GetContentWithAssetTest.php new file mode 100644 index 0000000000000..3ba98a400fcba --- /dev/null +++ b/app/code/Magento/MediaContent/Test/Unit/Model/GetContentWithAssetTest.php @@ -0,0 +1,107 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Test\Unit\Model; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\DB\Select; +use Magento\Framework\Exception\IntegrationException; +use Magento\MediaContent\Model\GetContentWithAsset; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; + +/** + * Test for the GetContentWithAsset command. + */ +class GetContentWithAssetTest extends TestCase +{ + /** + * Expected list of assets for the return statement. + */ + private const EXPECTED_LIST_OF_ASSETS = + [ + 1234123 => [ + 1234123, + 'cms_page', + '1', + 'content', + ] + ]; + + /** + * @var ResourceConnection | MockObject + */ + private $resourceConnectionStub; + + /** + * @var LoggerInterface | MockObject + */ + private $loggerMock; + + /** + * @var GetContentWithAsset + */ + private $getContentWithAsset; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + $this->resourceConnectionStub = $this->createMock(ResourceConnection::class); + $this->loggerMock = $this->createMock(LoggerInterface::class); + $this->getContentWithAsset = new GetContentWithAsset($this->resourceConnectionStub, $this->loggerMock); + } + + /** + * Test successful execution of the GetContentWithAsset::execute. + */ + public function testSuccessfulGetContentWithAsset(): void + { + $assetId = 1234123; + $this->configureResourceConnectionStub(); + $assetList = $this->getContentWithAsset->execute($assetId); + + $this->assertEquals(self::EXPECTED_LIST_OF_ASSETS, $assetList); + } + + /** + * Test GetContentWithAsset::execute with exception. + */ + public function testGetContentWithAssetWithException(): void + { + $this->resourceConnectionStub->method('getConnection')->willThrowException((new \Exception())); + $this->expectException(IntegrationException::class); + $this->loggerMock->expects($this->once()) + ->method('critical') + ->willReturnSelf(); + + $this->getContentWithAsset->execute(1); + } + + /** + * Configure resource connection for the command. Based on the current implementation. + */ + private function configureResourceConnectionStub(): void + { + $selectStub = $this->createMock(Select::class); + $selectStub->method('from')->willReturnSelf(); + $selectStub->method('where')->willReturnSelf(); + + $connectionMock = $this->getMockBuilder(AdapterInterface::class)->getMock(); + $connectionMock->expects($this->any())->method('select')->willReturn($selectStub); + $connectionMock->expects($this->any()) + ->method('fetchAssoc') + ->with($selectStub) + ->willReturn(self::EXPECTED_LIST_OF_ASSETS); + $this->resourceConnectionStub->expects($this->any()) + ->method('getConnection') + ->willReturn($connectionMock); + } +} diff --git a/app/code/Magento/MediaContent/Test/Unit/Model/UnassignAssetTest.php b/app/code/Magento/MediaContent/Test/Unit/Model/UnassignAssetTest.php new file mode 100644 index 0000000000000..ac35ef6e75dd2 --- /dev/null +++ b/app/code/Magento/MediaContent/Test/Unit/Model/UnassignAssetTest.php @@ -0,0 +1,171 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Test\Unit\Model; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\DB\Adapter\Pdo\Mysql; +use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\MediaContent\Model\UnassignAsset; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface; + +/** + * Tests for the UnassignAsset command. + */ +class UnassignAssetTest extends TestCase +{ + /** + * Media content relation data storage table name + */ + private const TABLE_MEDIA_CONTENT_ASSET = 'media_content_asset'; + + /** + * Prefixed media content relation data storage table name + */ + private const PREFIXED_TABLE_MEDIA_CONTENT_ASSET = 'prefix_' . self::TABLE_MEDIA_CONTENT_ASSET; + + /** + * Media asset id + */ + private const ASSET_ID = 'asset_id'; + + /** + * Media content type + */ + private const TYPE = 'type'; + + /** + * Media entity id + */ + private const ENTITY_ID = 'entity_id'; + + /** + * Media content field where media asset is used + */ + private const FIELD = 'field'; + + /** + * @var ResourceConnection | MockObject + */ + private $resourceConnectionMock; + + /** + * @var AdapterInterface | MockObject + */ + private $adapterMock; + + /** + * @var LoggerInterface | MockObject + */ + private $loggerMock; + + /** + * @var UnassignAsset + */ + private $unassignAsset; + + /** + * Initialize basic test class mocks + */ + protected function setUp(): void + { + $this->adapterMock = $this->createMock(Mysql::class); + $this->loggerMock = $this->createMock(LoggerInterface::class); + $this->resourceConnectionMock = $this->createConfiguredMock( + ResourceConnection::class, + [ + 'getConnection' => $this->adapterMock, + 'getTableName' => self::PREFIXED_TABLE_MEDIA_CONTENT_ASSET + ] + ); + + $this->unassignAsset = (new ObjectManager($this))->getObject( + UnassignAsset::class, + [ + 'resourceConnection' => $this->resourceConnectionMock, + 'logger' => $this->loggerMock + ] + ); + } + + /** + * Test successful scenario for deleting relation between media asset and media content. + * + * @param int $assetId + * @param string $contentType + * @param string $contentEntityId + * @param string $contentField + * @dataProvider unassignAssetDataProvider + * @return void + */ + public function testSuccessfulUnassignAsset( + int $assetId, + string $contentType, + string $contentEntityId, + string $contentField + ): void { + $this->adapterMock->expects($this->once()) + ->method('delete') + ->with( + self::PREFIXED_TABLE_MEDIA_CONTENT_ASSET, + [ + self::ASSET_ID . ' = ?' => $assetId, + self::TYPE . ' = ?' => $contentType, + self::ENTITY_ID . ' = ?' => $contentEntityId, + self::FIELD . ' = ?' => $contentField + ] + ); + + $this->unassignAsset->execute($assetId, $contentType, $contentEntityId, $contentField); + } + + /** + * Test exception scenario for deleting relation between media asset and media content. + * + * @param int $assetId + * @param string $contentType + * @param string $contentEntityId + * @param string $contentField + * @dataProvider unassignAssetDataProvider + * @return void + */ + public function testUnassignAssetWithException( + int $assetId, + string $contentType, + string $contentEntityId, + string $contentField + ): void { + $this->resourceConnectionMock->method('getConnection')->willThrowException((new \Exception())); + + $this->expectException(CouldNotDeleteException::class); + $this->loggerMock->expects($this->once()) + ->method('critical') + ->willReturnSelf(); + $this->unassignAsset->execute($assetId, $contentType, $contentEntityId, $contentField); + } + + /** + * Media asset to media content relation data + * + * @return array + */ + public function unassignAssetDataProvider(): array + { + return [ + [ + 18976345, + 'cms_page', + '1', + 'content' + ] + ]; + } +} diff --git a/app/code/Magento/MediaContent/composer.json b/app/code/Magento/MediaContent/composer.json new file mode 100644 index 0000000000000..e14c0fc1aeadd --- /dev/null +++ b/app/code/Magento/MediaContent/composer.json @@ -0,0 +1,24 @@ +{ + "name": "magento/module-media-content", + "description": "Magento module provides the implementation for managing relations between content and media files used in that content", + "require": { + "php": "~7.1.3||~7.2.0||~7.3.0", + "magento/framework": "*", + "magento/module-media-content-api": "*", + "magento/module-media-gallery-api": "*", + "magento/module-media-gallery": "*" + }, + "type": "magento2-module", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "Magento\\MediaContent\\": "" + } + } +} diff --git a/app/code/Magento/MediaContent/etc/db_schema.xml b/app/code/Magento/MediaContent/etc/db_schema.xml new file mode 100644 index 0000000000000..25c4b50098085 --- /dev/null +++ b/app/code/Magento/MediaContent/etc/db_schema.xml @@ -0,0 +1,21 @@ +<?xml version="1.0"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> + <table name="media_content_asset" resource="default" engine="innodb" comment="Relation between media content and media asset"> + <column xsi:type="int" padding="10" name="asset_id" unsigned="true" nullable="false" identity="true" comment="Entity ID"/> + <column xsi:type="varchar" length="255" name="type" nullable="false" comment="Content type"/> + <column xsi:type="varchar" length="255" name="entity_id" nullable="false" comment="Content entity id"/> + <column xsi:type="varchar" length="255" name="field" nullable="false" comment="Content field"/> + <constraint xsi:type="primary" referenceId="PRIMARY"> + <column name="asset_id"/> + <column name="type"/> + <column name="field"/> + </constraint> + <constraint xsi:type="foreign" referenceId="MEDIA_CONTENT_ASSET_ID_MEDIA_GALLERY_ASSET_ID" table="media_content_asset" column="asset_id" referenceTable="media_gallery_asset" referenceColumn="id" onDelete="CASCADE"/> + </table> +</schema> diff --git a/app/code/Magento/MediaContent/etc/db_schema_whitelist.json b/app/code/Magento/MediaContent/etc/db_schema_whitelist.json new file mode 100644 index 0000000000000..9b55f29a3b039 --- /dev/null +++ b/app/code/Magento/MediaContent/etc/db_schema_whitelist.json @@ -0,0 +1,14 @@ +{ + "media_content_asset": { + "column": { + "asset_id": true, + "type": true, + "entity_id": true, + "field": true + }, + "constraint": { + "PRIMARY": true, + "MEDIA_CONTENT_ASSET_ASSET_ID_MEDIA_GALLERY_ASSET_ID": true + } + } +} diff --git a/app/code/Magento/MediaContent/etc/di.xml b/app/code/Magento/MediaContent/etc/di.xml new file mode 100644 index 0000000000000..3a8839c3ca741 --- /dev/null +++ b/app/code/Magento/MediaContent/etc/di.xml @@ -0,0 +1,15 @@ +<?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:ObjectManager/etc/config.xsd"> + <preference for="Magento\MediaContentApi\Api\AssignAssetInterface" type="Magento\MediaContent\Model\AssignAsset"/> + <preference for="Magento\MediaContentApi\Api\UnassignAssetInterface" type="Magento\MediaContent\Model\UnassignAsset"/> + <preference for="Magento\MediaContentApi\Api\GetAssetsUsedInContentInterface" type="Magento\MediaContent\Model\GetAssetsUsedInContent"/> + <preference for="Magento\MediaContentApi\Api\GetContentWithAssetInterface" type="Magento\MediaContent\Model\GetContentWithAsset"/> + <preference for="Magento\MediaContentApi\Api\ModelProcessorInterface" type="Magento\MediaContent\Model\ModelProcessor"/> + <preference for="Magento\MediaContentApi\Api\ExtractAssetFromContentInterface" type="Magento\MediaContent\Model\ExtractAssetFromContent"/> +</config> diff --git a/app/code/Magento/MediaContent/etc/module.xml b/app/code/Magento/MediaContent/etc/module.xml new file mode 100644 index 0000000000000..ebf2a2f0d9277 --- /dev/null +++ b/app/code/Magento/MediaContent/etc/module.xml @@ -0,0 +1,14 @@ +<?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:Module/etc/module.xsd"> + <module name="Magento_MediaContent"> + <sequence> + <module name="Magento_MediaGallery"/> + </sequence> + </module> +</config> diff --git a/app/code/Magento/MediaContent/registration.php b/app/code/Magento/MediaContent/registration.php new file mode 100644 index 0000000000000..d6776f29f46df --- /dev/null +++ b/app/code/Magento/MediaContent/registration.php @@ -0,0 +1,10 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_MediaContent', __DIR__); diff --git a/app/code/Magento/MediaContentApi/Api/AssignAssetInterface.php b/app/code/Magento/MediaContentApi/Api/AssignAssetInterface.php new file mode 100644 index 0000000000000..ebe0968cc57f5 --- /dev/null +++ b/app/code/Magento/MediaContentApi/Api/AssignAssetInterface.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\MediaContentApi\Api; + +/** + * Saving data represents relation between the media asset and media content + * @api + */ +interface AssignAssetInterface +{ + /** + * @param int $assetId + * @param string $contentType + * @param string $contentEntityId + * @param string $contentField + * + * @throws \Magento\Framework\Exception\CouldNotSaveException + */ + public function execute(int $assetId, string $contentType, string $contentEntityId, string $contentField): void; +} diff --git a/app/code/Magento/MediaContentApi/Api/ExtractAssetFromContentInterface.php b/app/code/Magento/MediaContentApi/Api/ExtractAssetFromContentInterface.php new file mode 100644 index 0000000000000..4911f55e6b5f3 --- /dev/null +++ b/app/code/Magento/MediaContentApi/Api/ExtractAssetFromContentInterface.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContentApi\Api; + +use Magento\MediaGalleryApi\Api\Data\AssetInterface; + +/** + * Used for extracting media asset list from a media content by the search pattern. + * @api + */ +interface ExtractAssetFromContentInterface +{ + /** + * Search for the media asset in content and extract it providing a list of media assets. + * + * @param string $content + * @return AssetInterface[] + */ + public function execute(string $content): array; +} diff --git a/app/code/Magento/MediaContentApi/Api/GetAssetsUsedInContentInterface.php b/app/code/Magento/MediaContentApi/Api/GetAssetsUsedInContentInterface.php new file mode 100644 index 0000000000000..148acb5edadbc --- /dev/null +++ b/app/code/Magento/MediaContentApi/Api/GetAssetsUsedInContentInterface.php @@ -0,0 +1,28 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\MediaContentApi\Api; + +/** + * Get media asset ids used in the content + * @api + */ +interface GetAssetsUsedInContentInterface +{ + /** + * Get media asset ids used in the content + * + * @param string $contentType + * @param string|null $contentEntityId + * @param string|null $contentField + * + * @return int[] + * @throws \Magento\Framework\Exception\IntegrationException + */ + public function execute(string $contentType, string $contentEntityId = null, string $contentField = null): array; +} diff --git a/app/code/Magento/MediaContentApi/Api/GetContentWithAssetInterface.php b/app/code/Magento/MediaContentApi/Api/GetContentWithAssetInterface.php new file mode 100644 index 0000000000000..a10cc4a476426 --- /dev/null +++ b/app/code/Magento/MediaContentApi/Api/GetContentWithAssetInterface.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\MediaContentApi\Api; + +/** + * Get media content list which is used with the specified media asset + * @api + */ +interface GetContentWithAssetInterface +{ + /** + * @param int $assetId + * + * @return array + * @throws \Magento\Framework\Exception\IntegrationException + */ + public function execute(int $assetId): array; +} diff --git a/app/code/Magento/MediaContentApi/Api/ModelProcessorInterface.php b/app/code/Magento/MediaContentApi/Api/ModelProcessorInterface.php new file mode 100644 index 0000000000000..be395656633db --- /dev/null +++ b/app/code/Magento/MediaContentApi/Api/ModelProcessorInterface.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContentApi\Api; + +use Magento\Framework\Model\AbstractModel; + +/** + * Save relations for content within an AbstractModel instance + * @api + */ +interface ModelProcessorInterface +{ + /** + * Save relations between content and media files within an AbstractModel instance + * + * @param string $type + * @param AbstractModel $model + * @param array $fields + */ + public function execute(string $type, AbstractModel $model, array $fields): void; +} diff --git a/app/code/Magento/MediaContentApi/Api/UnassignAssetInterface.php b/app/code/Magento/MediaContentApi/Api/UnassignAssetInterface.php new file mode 100644 index 0000000000000..502fb738c8d00 --- /dev/null +++ b/app/code/Magento/MediaContentApi/Api/UnassignAssetInterface.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\MediaContentApi\Api; + +/** + * Unassign relation between the media asset and media content where the media asset is used + * @api + */ +interface UnassignAssetInterface +{ + /** + * @param int $assetId + * @param string $contentType + * @param string $contentEntityId + * @param string $contentField + * + * @throws \Magento\Framework\Exception\CouldNotDeleteException + */ + public function execute(int $assetId, string $contentType, string $contentEntityId, string $contentField): void; +} diff --git a/app/code/Magento/MediaContentApi/LICENSE.txt b/app/code/Magento/MediaContentApi/LICENSE.txt new file mode 100644 index 0000000000000..49525fd99da9c --- /dev/null +++ b/app/code/Magento/MediaContentApi/LICENSE.txt @@ -0,0 +1,48 @@ + +Open Software License ("OSL") v. 3.0 + +This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Open Software License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + 1. to reproduce the Original Work in copies, either alone or as part of a collective work; + + 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; + + 4. to perform the Original Work publicly; and + + 5. to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magento/MediaContentApi/LICENSE_AFL.txt b/app/code/Magento/MediaContentApi/LICENSE_AFL.txt new file mode 100644 index 0000000000000..f39d641b18a19 --- /dev/null +++ b/app/code/Magento/MediaContentApi/LICENSE_AFL.txt @@ -0,0 +1,48 @@ + +Academic Free License ("AFL") v. 3.0 + +This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Academic Free License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + 1. to reproduce the Original Work in copies, either alone or as part of a collective work; + + 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License; + + 4. to perform the Original Work publicly; and + + 5. to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. diff --git a/app/code/Magento/MediaContentApi/README.md b/app/code/Magento/MediaContentApi/README.md new file mode 100644 index 0000000000000..87e0d7524f59b --- /dev/null +++ b/app/code/Magento/MediaContentApi/README.md @@ -0,0 +1,13 @@ +# Magento_MediaContentApi module + +The Magento_MediaContentApi module provides interfaces for managing relations between content and media files used in that content. + +## Extensibility + +Extension developers can interact with the Magento_MediaContent module. For more information about the Magento extension mechanism, see [Magento plug-ins](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html). + +[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_MediaContent module. + +## Additional information + +For information about significant changes in patch releases, see [2.3.x Release information](https://devdocs.magento.com/guides/v2.3/release-notes/bk-release-notes.html). diff --git a/app/code/Magento/MediaContentApi/composer.json b/app/code/Magento/MediaContentApi/composer.json new file mode 100644 index 0000000000000..f8c27093280f6 --- /dev/null +++ b/app/code/Magento/MediaContentApi/composer.json @@ -0,0 +1,22 @@ +{ + "name": "magento/module-media-content-api", + "description": "Magento module provides the API interfaces for managing relations between content and media files used in that content", + "require": { + "php": "~7.1.3||~7.2.0||~7.3.0", + "magento/module-media-gallery-api": "*", + "magento/framework": "*" + }, + "type": "magento2-module", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "Magento\\MediaContentApi\\": "" + } + } +} diff --git a/app/code/Magento/MediaContentApi/etc/module.xml b/app/code/Magento/MediaContentApi/etc/module.xml new file mode 100644 index 0000000000000..3aa553170fe2a --- /dev/null +++ b/app/code/Magento/MediaContentApi/etc/module.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:Module/etc/module.xsd"> + <module name="Magento_MediaContentApi" /> +</config> diff --git a/app/code/Magento/MediaContentApi/registration.php b/app/code/Magento/MediaContentApi/registration.php new file mode 100644 index 0000000000000..fb3faefa2734f --- /dev/null +++ b/app/code/Magento/MediaContentApi/registration.php @@ -0,0 +1,10 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_MediaContentApi', __DIR__); From 49f254ab6fd3bf3f7952b9be0c7abe9861182514 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Wed, 1 Apr 2020 17:54:48 +0100 Subject: [PATCH 041/177] magento/magento2#27536: Included MediaContent modules in root composer.json --- composer.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/composer.json b/composer.json index 769885ef305bf..4b0d4d18eac2a 100644 --- a/composer.json +++ b/composer.json @@ -197,6 +197,8 @@ "magento/module-instant-purchase": "*", "magento/module-integration": "*", "magento/module-layered-navigation": "*", + "magento/module-media-content": "*", + "magento/module-media-content-api": "*", "magento/module-media-gallery": "*", "magento/module-media-gallery-api": "*", "magento/module-media-storage": "*", From be2e6958f68593c30b8e21d39d467f5e5ddfcc53 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Wed, 1 Apr 2020 20:57:00 +0100 Subject: [PATCH 042/177] magento/magento2#27499: Code review changes --- .../Model/Directory/Command/CreateByPath.php | 5 ++-- .../Model/Directory/Command/DeleteByPath.php | 7 +++--- app/code/Magento/MediaGallery/etc/di.xml | 16 ------------- .../Model/Directory/Blacklist.php} | 19 +++++++++------ ...edInterface.php => BlacklistInterface.php} | 8 +++---- .../File/Command/DeleteByAssetIdInterface.php | 4 ++-- .../Unit/Model/Directory/BlacklistTest.php} | 16 ++++++------- app/code/Magento/MediaGalleryApi/etc/di.xml | 24 +++++++++++++++++++ 8 files changed, 55 insertions(+), 44 deletions(-) rename app/code/Magento/{MediaGallery/Model/Directory/Excluded.php => MediaGalleryApi/Model/Directory/Blacklist.php} (55%) rename app/code/Magento/MediaGalleryApi/Model/Directory/{ExcludedInterface.php => BlacklistInterface.php} (51%) rename app/code/Magento/{MediaGallery/Test/Unit/Model/Directory/ExcludedTest.php => MediaGalleryApi/Test/Unit/Model/Directory/BlacklistTest.php} (72%) create mode 100644 app/code/Magento/MediaGalleryApi/etc/di.xml diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php index 6d0ea45aa02cd..c70f71df02a39 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php @@ -40,7 +40,7 @@ public function __construct( } /** - * Create new directory by provided path + * Create new directory by the provided path in the media storage * * @param string $path * @param string $name @@ -52,8 +52,7 @@ public function execute(string $path, string $name): void $this->storage->createDirectory($name, $this->storage->getCmsWysiwygImages()->getStorageRoot() . $path); } catch (\Exception $exception) { $this->logger->critical($exception); - $message = __('Failed to create the folder: %error', ['error' => $exception->getMessage()]); - throw new CouldNotSaveException($message, $exception); + throw new CouldNotSaveException(__('Failed to create the folder'), $exception); } } } diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php b/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php index ee78216fafdaf..73f0e08add751 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php @@ -13,7 +13,7 @@ use Psr\Log\LoggerInterface; /** - * Delete folder by provided path + * Delete directory from media storage by path */ class DeleteByPath implements DeleteByPathInterface { @@ -40,7 +40,7 @@ public function __construct( } /** - * Deletes the existing folder + * Removes directory and corresponding thumbnails directory from media storage if not in blacklist * * @param string $path * @throws CouldNotDeleteException @@ -51,8 +51,7 @@ public function execute(string $path): void $this->storage->deleteDirectory($this->storage->getCmsWysiwygImages()->getStorageRoot() . $path); } catch (\Exception $exception) { $this->logger->critical($exception); - $message = __('Failed to delete the folder: %error', ['error' => $exception->getMessage()]); - throw new CouldNotDeleteException($message, $exception); + throw new CouldNotDeleteException(__('Failed to delete the folder'), $exception); } } } diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index ccc8ce28a733d..2f402c30c5bc7 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -19,8 +19,6 @@ <preference for="Magento\MediaGalleryApi\Model\Keyword\Command\SaveAssetKeywordsInterface" type="Magento\MediaGallery\Model\Keyword\Command\SaveAssetKeywords"/> <preference for="Magento\MediaGalleryApi\Model\Keyword\Command\SaveAssetLinksInterface" type="Magento\MediaGallery\Model\Keyword\Command\SaveAssetLinks"/> - <preference for="Magento\MediaGalleryApi\Model\DataExtractorInterface" type="Magento\MediaGallery\Model\DataExtractor"/> - <type name="Magento\Catalog\Model\Product\Gallery\Processor"> <plugin name="media_gallery_image_remove_metadata" type="Magento\MediaGallery\Plugin\Product\Gallery\Processor" sortOrder="10" disabled="false"/> @@ -29,18 +27,4 @@ <plugin name="media_gallery_image_remove_metadata_after_wysiwyg" type="Magento\MediaGallery\Plugin\Wysiwyg\Images\Storage" sortOrder="10" disabled="false"/> </type> - <type name="Magento\MediaGalleryUi\Model\Directory\Excluded"> - <arguments> - <argument name="patterns" xsi:type="array"> - <item name="captcha" xsi:type="string">/pub\/media\/captcha/</item> - <item name="catalog" xsi:type="string">/pub\/media\/catalog\/product/</item> - <item name="customer" xsi:type="string">/pub\/media\/customer/</item> - <item name="downloadable" xsi:type="string">/pub\/media\/downloadable/</item> - <item name="import" xsi:type="string">/pub\/media\/import/</item> - <item name="theme" xsi:type="string">/pub\/media\/theme/</item> - <item name="theme_customization" xsi:type="string">/pub\/media\/theme_customization/</item> - <item name="tmp" xsi:type="string">/pub\/media\/tmp/</item> - </argument> - </arguments> - </type> </config> diff --git a/app/code/Magento/MediaGallery/Model/Directory/Excluded.php b/app/code/Magento/MediaGalleryApi/Model/Directory/Blacklist.php similarity index 55% rename from app/code/Magento/MediaGallery/Model/Directory/Excluded.php rename to app/code/Magento/MediaGalleryApi/Model/Directory/Blacklist.php index ad8843da9e8c3..fc6d73550f0fa 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Excluded.php +++ b/app/code/Magento/MediaGalleryApi/Model/Directory/Blacklist.php @@ -5,14 +5,16 @@ */ declare(strict_types=1); -namespace Magento\MediaGallery\Model\Directory; - -use Magento\MediaGalleryApi\Model\Directory\ExcludedInterface; +namespace Magento\MediaGalleryApi\Model\Directory; /** - * Directory paths that should not be included in the media gallery + * Directories blacklisted for media gallery. This class should be used for DI configuration. + * + * Please use the interface in the code (for constructor injection) instead of this implementation. + * + * @api */ -class Excluded implements ExcludedInterface +class Blacklist implements BlacklistInterface { /** * @var array @@ -29,14 +31,17 @@ public function __construct( } /** - * Check if the path is excluded from displaying in the media gallery + * Check if the directory path can be used in the media gallery operations * * @param string $path * @return bool */ - public function isExcluded(string $path): bool + public function isBlacklisted(string $path): bool { foreach ($this->patterns as $pattern) { + if (empty($pattern)) { + continue; + } preg_match($pattern, $path, $result); if ($result) { diff --git a/app/code/Magento/MediaGalleryApi/Model/Directory/ExcludedInterface.php b/app/code/Magento/MediaGalleryApi/Model/Directory/BlacklistInterface.php similarity index 51% rename from app/code/Magento/MediaGalleryApi/Model/Directory/ExcludedInterface.php rename to app/code/Magento/MediaGalleryApi/Model/Directory/BlacklistInterface.php index 159813a7094a3..f75af40fa72a7 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Directory/ExcludedInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Directory/BlacklistInterface.php @@ -8,16 +8,16 @@ namespace Magento\MediaGalleryApi\Model\Directory; /** - * Directory paths that should not be included in the media gallery + * Directory paths that are reserved by system and not be included in the media gallery * @api */ -interface ExcludedInterface +interface BlacklistInterface { /** - * Check if the path is excluded from displaying in the media gallery + * Check if the path is excluded from displaying and processing in the media gallery * * @param string $path * @return bool */ - public function isExcluded(string $path): bool; + public function isBlacklisted(string $path): bool; } diff --git a/app/code/Magento/MediaGalleryApi/Model/File/Command/DeleteByAssetIdInterface.php b/app/code/Magento/MediaGalleryApi/Model/File/Command/DeleteByAssetIdInterface.php index a73a29e8de1dd..5d973eb785abf 100644 --- a/app/code/Magento/MediaGalleryApi/Model/File/Command/DeleteByAssetIdInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/File/Command/DeleteByAssetIdInterface.php @@ -8,13 +8,13 @@ namespace Magento\MediaGalleryApi\Model\File\Command; /** - * Load Media Asset path from database by id and delete the file + * Remove the media asset file from the media storage * @api */ interface DeleteByAssetIdInterface { /** - * Delete the file by asset ID + * Remove the file of the media asset identified by the passed id from the media storage * * @param int $assetId * @return void diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/ExcludedTest.php b/app/code/Magento/MediaGalleryApi/Test/Unit/Model/Directory/BlacklistTest.php similarity index 72% rename from app/code/Magento/MediaGallery/Test/Unit/Model/Directory/ExcludedTest.php rename to app/code/Magento/MediaGalleryApi/Test/Unit/Model/Directory/BlacklistTest.php index ea9094b3ac1f4..3fe4ebd7cafcc 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/ExcludedTest.php +++ b/app/code/Magento/MediaGalleryApi/Test/Unit/Model/Directory/BlacklistTest.php @@ -5,19 +5,19 @@ */ declare(strict_types=1); -namespace Magento\MediaGallery\Test\Unit\Model\Directory; +namespace Magento\MediaGalleryApi\Test\Unit\Model\Directory; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use PHPUnit\Framework\TestCase; -use Magento\MediaGallery\Model\Directory\Excluded; +use Magento\MediaGalleryApi\Model\Directory\Blacklist; /** * Test the Excluded model */ -class ExcludedTest extends TestCase +class BlacklistTest extends TestCase { /** - * @var Excluded + * @var Blacklist */ private $object; @@ -27,7 +27,7 @@ class ExcludedTest extends TestCase protected function setUp(): void { $this->object = (new ObjectManager($this))->getObject( - Excluded::class, + Blacklist::class, [ 'patterns' => [ 'tmp' => '/pub\/media\/tmp/', @@ -38,15 +38,15 @@ protected function setUp(): void } /** - * Test is directory path excluded + * Test if the directory path is blacklisted * * @param string $path * @param bool $isExcluded * @dataProvider pathsProvider */ - public function testIsExcluded(string $path, bool $isExcluded): void + public function testIsBlacklisted(string $path, bool $isExcluded): void { - $this->assertEquals($isExcluded, $this->object->isExcluded($path)); + $this->assertEquals($isExcluded, $this->object->isBlacklisted($path)); } /** diff --git a/app/code/Magento/MediaGalleryApi/etc/di.xml b/app/code/Magento/MediaGalleryApi/etc/di.xml new file mode 100644 index 0000000000000..7a00192cdd87b --- /dev/null +++ b/app/code/Magento/MediaGalleryApi/etc/di.xml @@ -0,0 +1,24 @@ +<?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:ObjectManager/etc/config.xsd"> + <preference for="Magento\MediaGalleryApi\Model\Directory\BlacklistInterface" type="Magento\MediaGalleryApi\Model\Directory\Blacklist"/> + <type name="Magento\MediaGalleryApi\Model\Directory\Blacklist"> + <arguments> + <argument name="patterns" xsi:type="array"> + <item name="captcha" xsi:type="string">/pub\/media\/captcha/</item> + <item name="catalog" xsi:type="string">/pub\/media\/catalog\/product/</item> + <item name="customer" xsi:type="string">/pub\/media\/customer/</item> + <item name="downloadable" xsi:type="string">/pub\/media\/downloadable/</item> + <item name="import" xsi:type="string">/pub\/media\/import/</item> + <item name="theme" xsi:type="string">/pub\/media\/theme/</item> + <item name="theme_customization" xsi:type="string">/pub\/media\/theme_customization/</item> + <item name="tmp" xsi:type="string">/pub\/media\/tmp/</item> + </argument> + </arguments> + </type> +</config> From e8eb3a9c474a38b129eace62e0af6a5f80d74b70 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Wed, 1 Apr 2020 21:01:38 +0100 Subject: [PATCH 043/177] magento/magento2#27499: Corrected DI configuration --- app/code/Magento/MediaGallery/etc/di.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index 2f402c30c5bc7..67ae43e667d17 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -19,6 +19,12 @@ <preference for="Magento\MediaGalleryApi\Model\Keyword\Command\SaveAssetKeywordsInterface" type="Magento\MediaGallery\Model\Keyword\Command\SaveAssetKeywords"/> <preference for="Magento\MediaGalleryApi\Model\Keyword\Command\SaveAssetLinksInterface" type="Magento\MediaGallery\Model\Keyword\Command\SaveAssetLinks"/> + <preference for="Magento\MediaGalleryApi\Model\DataExtractorInterface" type="Magento\MediaGallery\Model\DataExtractor"/> + + <preference for="Magento\MediaGalleryApi\Model\Directory\Command\CreateByPathInterface" type="Magento\MediaGallery\Model\Directory\Command\CreateByPath"/> + <preference for="Magento\MediaGalleryApi\Model\Directory\Command\DeleteByPathInterface" type="Magento\MediaGallery\Model\Directory\Command\DeleteByPath"/> + <preference for="Magento\MediaGalleryApi\Model\File\Command\DeleteByAssetIdInterface" type="Magento\MediaGallery\Model\File\Command\DeleteByAssetId"/> + <type name="Magento\Catalog\Model\Product\Gallery\Processor"> <plugin name="media_gallery_image_remove_metadata" type="Magento\MediaGallery\Plugin\Product\Gallery\Processor" sortOrder="10" disabled="false"/> From 6cd1dac700d2a2bc691c193a69f59aecbaf6cf08 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Wed, 1 Apr 2020 21:43:19 +0100 Subject: [PATCH 044/177] magento/magento2#27536: Code review changes --- app/code/Magento/Catalog/composer.json | 1 - app/code/Magento/Catalog/etc/di.xml | 23 -- app/code/Magento/Catalog/etc/events.xml | 6 - app/code/Magento/Cms/composer.json | 1 - app/code/Magento/Cms/etc/di.xml | 21 -- app/code/Magento/Cms/etc/events.xml | 6 - ...ntentProcessor.php => UpdateRelations.php} | 12 +- app/code/Magento/MediaContent/etc/di.xml | 2 +- .../Api/ModelProcessorInterface.php | 26 -- .../Api/UpdateRelationsInterface.php | 34 ++ .../Model/ExtractAssetFromContent.php | 9 +- .../Magento/MediaContentCatalog/LICENSE.txt | 48 +++ .../MediaContentCatalog/LICENSE_AFL.txt | 48 +++ .../Observer}/Category.php | 32 +- .../Observer}/Product.php | 32 +- .../Magento/MediaContentCatalog/README.md | 13 + .../Magento/MediaContentCatalog/composer.json | 23 ++ .../Magento/MediaContentCatalog/etc/di.xml | 32 ++ .../MediaContentCatalog/etc/events.xml | 15 + .../MediaContentCatalog/etc/module.xml | 10 + .../MediaContentCatalog/registration.php | 10 + app/code/Magento/MediaContentCms/LICENSE.txt | 48 +++ .../Magento/MediaContentCms/LICENSE_AFL.txt | 48 +++ .../Observer}/Block.php | 32 +- .../Observer}/Page.php | 32 +- app/code/Magento/MediaContentCms/README.md | 13 + .../Magento/MediaContentCms/composer.json | 23 ++ app/code/Magento/MediaContentCms/etc/di.xml | 30 ++ .../Magento/MediaContentCms/etc/events.xml | 15 + .../Magento/MediaContentCms/etc/module.xml | 10 + .../Magento/MediaContentCms/registration.php | 10 + composer.json | 2 + composer.lock | 296 +++++++++--------- 33 files changed, 701 insertions(+), 262 deletions(-) rename app/code/Magento/MediaContent/Model/{ContentProcessor.php => UpdateRelations.php} (90%) delete mode 100644 app/code/Magento/MediaContentApi/Api/ModelProcessorInterface.php create mode 100644 app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php rename app/code/Magento/{MediaContent => MediaContentApi}/Model/ExtractAssetFromContent.php (88%) create mode 100644 app/code/Magento/MediaContentCatalog/LICENSE.txt create mode 100644 app/code/Magento/MediaContentCatalog/LICENSE_AFL.txt rename app/code/Magento/{Catalog/Observer/MediaContent => MediaContentCatalog/Observer}/Category.php (57%) rename app/code/Magento/{Catalog/Observer/MediaContent => MediaContentCatalog/Observer}/Product.php (57%) create mode 100644 app/code/Magento/MediaContentCatalog/README.md create mode 100644 app/code/Magento/MediaContentCatalog/composer.json create mode 100644 app/code/Magento/MediaContentCatalog/etc/di.xml create mode 100644 app/code/Magento/MediaContentCatalog/etc/events.xml create mode 100644 app/code/Magento/MediaContentCatalog/etc/module.xml create mode 100644 app/code/Magento/MediaContentCatalog/registration.php create mode 100644 app/code/Magento/MediaContentCms/LICENSE.txt create mode 100644 app/code/Magento/MediaContentCms/LICENSE_AFL.txt rename app/code/Magento/{Cms/Observer/MediaContent => MediaContentCms/Observer}/Block.php (56%) rename app/code/Magento/{Cms/Observer/MediaContent => MediaContentCms/Observer}/Page.php (56%) create mode 100644 app/code/Magento/MediaContentCms/README.md create mode 100644 app/code/Magento/MediaContentCms/composer.json create mode 100644 app/code/Magento/MediaContentCms/etc/di.xml create mode 100644 app/code/Magento/MediaContentCms/etc/events.xml create mode 100644 app/code/Magento/MediaContentCms/etc/module.xml create mode 100644 app/code/Magento/MediaContentCms/registration.php diff --git a/app/code/Magento/Catalog/composer.json b/app/code/Magento/Catalog/composer.json index 660c496b5a8f0..8023634fa074d 100644 --- a/app/code/Magento/Catalog/composer.json +++ b/app/code/Magento/Catalog/composer.json @@ -20,7 +20,6 @@ "magento/module-directory": "*", "magento/module-eav": "*", "magento/module-indexer": "*", - "magento/module-media-content-api": "*", "magento/module-media-storage": "*", "magento/module-msrp": "*", "magento/module-page-cache": "*", diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 5f8710fef0ac9..ff67989d337bb 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -1333,27 +1333,4 @@ </argument> </arguments> </type> - <type name="Magento\Catalog\Observer\MediaContent\Category"> - <arguments> - <argument name="fields" xsi:type="array"> - <item name="image" xsi:type="string">image</item> - <item name="description" xsi:type="string">description</item> - </argument> - </arguments> - </type> - <type name="Magento\Catalog\Observer\MediaContent\Product"> - <arguments> - <argument name="fields" xsi:type="array"> - <item name="description" xsi:type="string">description</item> - <item name="short_description" xsi:type="string">short_description</item> - </argument> - </arguments> - </type> - <type name="Magento\MediaContentApi\Api\ExtractAssetFromContentInterface"> - <arguments> - <argument name="searchPatterns" xsi:type="array"> - <item name="catalog_image" xsi:type="string">/^\/?media\/(.*)/</item> - </argument> - </arguments> - </type> </config> diff --git a/app/code/Magento/Catalog/etc/events.xml b/app/code/Magento/Catalog/etc/events.xml index bb28dc00b50f2..24186146c56f0 100644 --- a/app/code/Magento/Catalog/etc/events.xml +++ b/app/code/Magento/Catalog/etc/events.xml @@ -67,10 +67,4 @@ <event name="catalog_category_prepare_save"> <observer name="additional_authorization" instance="Magento\Catalog\Observer\CategoryDesignAuthorization" /> </event> - <event name="catalog_category_save_after"> - <observer name="media_content_catalog_category_save_after" instance="Magento\Catalog\Observer\MediaContent\Category" /> - </event> - <event name="catalog_product_save_after"> - <observer name="media_content_catalog_product_save_after" instance="Magento\Catalog\Observer\MediaContent\Product" /> - </event> </config> diff --git a/app/code/Magento/Cms/composer.json b/app/code/Magento/Cms/composer.json index c299ba63f9a96..91036d31fdc2b 100644 --- a/app/code/Magento/Cms/composer.json +++ b/app/code/Magento/Cms/composer.json @@ -10,7 +10,6 @@ "magento/module-backend": "*", "magento/module-catalog": "*", "magento/module-email": "*", - "magento/module-media-content-api": "*", "magento/module-media-storage": "*", "magento/module-store": "*", "magento/module-theme": "*", diff --git a/app/code/Magento/Cms/etc/di.xml b/app/code/Magento/Cms/etc/di.xml index 0f573047d098f..7fc8268eea5e0 100644 --- a/app/code/Magento/Cms/etc/di.xml +++ b/app/code/Magento/Cms/etc/di.xml @@ -243,25 +243,4 @@ </arguments> </type> <preference for="Magento\Cms\Model\Page\CustomLayoutRepositoryInterface" type="Magento\Cms\Model\Page\CustomLayout\CustomLayoutRepository" /> - <type name="Magento\Cms\Observer\MediaContent\Block"> - <arguments> - <argument name="fields" xsi:type="array"> - <item name="content" xsi:type="string">content</item> - </argument> - </arguments> - </type> - <type name="Magento\Cms\Observer\MediaContent\Page"> - <arguments> - <argument name="fields" xsi:type="array"> - <item name="content" xsi:type="string">content</item> - </argument> - </arguments> - </type> - <type name="Magento\MediaContentApi\Api\ExtractAssetFromContentInterface"> - <arguments> - <argument name="searchPatterns" xsi:type="array"> - <item name="media_gallery" xsi:type="string">/{{media url="?(.*?)"?}}/</item> - </argument> - </arguments> - </type> </config> diff --git a/app/code/Magento/Cms/etc/events.xml b/app/code/Magento/Cms/etc/events.xml index a49e1638f0ab2..1ad847e215ccc 100644 --- a/app/code/Magento/Cms/etc/events.xml +++ b/app/code/Magento/Cms/etc/events.xml @@ -39,10 +39,4 @@ <event name="cms_page_prepare_save"> <observer name="validate_cms_page" instance="Magento\Cms\Observer\PageValidatorObserver" /> </event> - <event name="cms_page_save_after"> - <observer name="media_content_cms_page_save_after" instance="\Magento\Cms\Observer\MediaContent\Page" /> - </event> - <event name="cms_block_save_after"> - <observer name="media_content_cms_block_save_after" instance="\Magento\Cms\Observer\MediaContent\Block" /> - </event> </config> diff --git a/app/code/Magento/MediaContent/Model/ContentProcessor.php b/app/code/Magento/MediaContent/Model/UpdateRelations.php similarity index 90% rename from app/code/Magento/MediaContent/Model/ContentProcessor.php rename to app/code/Magento/MediaContent/Model/UpdateRelations.php index 2d8fc45506e89..1716739434591 100644 --- a/app/code/Magento/MediaContent/Model/ContentProcessor.php +++ b/app/code/Magento/MediaContent/Model/UpdateRelations.php @@ -11,18 +11,20 @@ use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\Exception\IntegrationException; use Magento\MediaContentApi\Api\AssignAssetInterface; +use Magento\MediaContentApi\Api\ExtractAssetFromContentInterface; use Magento\MediaContentApi\Api\GetAssetsUsedInContentInterface; use Magento\MediaContentApi\Api\UnassignAssetInterface; +use Magento\MediaContentApi\Api\UpdateRelationsInterface; use Magento\MediaGalleryApi\Api\Data\AssetInterface; use Psr\Log\LoggerInterface; /** * Process relation managing between media asset and content: assign or unassign relation if exists. */ -class ContentProcessor +class UpdateRelations implements UpdateRelationsInterface { /** - * @var ExtractAssetFromContent + * @var ExtractAssetFromContentInterface */ private $extractAssetFromContent; @@ -47,16 +49,14 @@ class ContentProcessor private $logger; /** - * ContentProcessor constructor. - * - * @param ExtractAssetFromContent $extractAssetFromContent + * @param ExtractAssetFromContentInterface $extractAssetFromContent * @param AssignAssetInterface $assignAsset * @param GetAssetsUsedInContentInterface $getAssetsUsedInContent * @param UnassignAssetInterface $unassignAsset * @param LoggerInterface $logger */ public function __construct( - ExtractAssetFromContent $extractAssetFromContent, + ExtractAssetFromContentInterface $extractAssetFromContent, AssignAssetInterface $assignAsset, GetAssetsUsedInContentInterface $getAssetsUsedInContent, UnassignAssetInterface $unassignAsset, diff --git a/app/code/Magento/MediaContent/etc/di.xml b/app/code/Magento/MediaContent/etc/di.xml index 3a8839c3ca741..66be373535c6c 100644 --- a/app/code/Magento/MediaContent/etc/di.xml +++ b/app/code/Magento/MediaContent/etc/di.xml @@ -10,6 +10,6 @@ <preference for="Magento\MediaContentApi\Api\UnassignAssetInterface" type="Magento\MediaContent\Model\UnassignAsset"/> <preference for="Magento\MediaContentApi\Api\GetAssetsUsedInContentInterface" type="Magento\MediaContent\Model\GetAssetsUsedInContent"/> <preference for="Magento\MediaContentApi\Api\GetContentWithAssetInterface" type="Magento\MediaContent\Model\GetContentWithAsset"/> - <preference for="Magento\MediaContentApi\Api\ModelProcessorInterface" type="Magento\MediaContent\Model\ModelProcessor"/> <preference for="Magento\MediaContentApi\Api\ExtractAssetFromContentInterface" type="Magento\MediaContent\Model\ExtractAssetFromContent"/> + <preference for="Magento\MediaContentApi\Api\UpdateRelationsInterface" type="Magento\MediaContent\Model\UpdateRelations"/> </config> diff --git a/app/code/Magento/MediaContentApi/Api/ModelProcessorInterface.php b/app/code/Magento/MediaContentApi/Api/ModelProcessorInterface.php deleted file mode 100644 index be395656633db..0000000000000 --- a/app/code/Magento/MediaContentApi/Api/ModelProcessorInterface.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaContentApi\Api; - -use Magento\Framework\Model\AbstractModel; - -/** - * Save relations for content within an AbstractModel instance - * @api - */ -interface ModelProcessorInterface -{ - /** - * Save relations between content and media files within an AbstractModel instance - * - * @param string $type - * @param AbstractModel $model - * @param array $fields - */ - public function execute(string $type, AbstractModel $model, array $fields): void; -} diff --git a/app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php b/app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php new file mode 100644 index 0000000000000..812209a73636d --- /dev/null +++ b/app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php @@ -0,0 +1,34 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContentApi\Api; + +use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\IntegrationException; +use Magento\MediaContentApi\Api\AssignAssetInterface; +use Magento\MediaContentApi\Api\ExtractAssetFromContentInterface; +use Magento\MediaContentApi\Api\GetAssetsUsedInContentInterface; +use Magento\MediaContentApi\Api\UnassignAssetInterface; +use Magento\MediaGalleryApi\Api\Data\AssetInterface; +use Psr\Log\LoggerInterface; + +/** + * Process relation managing between media asset and content: assign or unassign relation if exists. + */ +interface UpdateRelationsInterface +{ + /** + * Create new relation between media asset and content or updated existing + * + * @param string $type + * @param string $field + * @param string $entityId + * @param string $data + */ + public function execute(string $type, string $field, string $entityId, string $data): void; +} diff --git a/app/code/Magento/MediaContent/Model/ExtractAssetFromContent.php b/app/code/Magento/MediaContentApi/Model/ExtractAssetFromContent.php similarity index 88% rename from app/code/Magento/MediaContent/Model/ExtractAssetFromContent.php rename to app/code/Magento/MediaContentApi/Model/ExtractAssetFromContent.php index 5f379080bc0f1..c307fa88a2e5e 100644 --- a/app/code/Magento/MediaContent/Model/ExtractAssetFromContent.php +++ b/app/code/Magento/MediaContentApi/Model/ExtractAssetFromContent.php @@ -5,16 +5,21 @@ */ declare(strict_types=1); -namespace Magento\MediaContent\Model; +namespace Magento\MediaContentApi\Model; +use Magento\MediaContentApi\Api\ExtractAssetFromContentInterface; use Magento\MediaGalleryApi\Api\Data\AssetInterface; use Magento\MediaGalleryApi\Model\Asset\Command\GetByPathInterface; use Psr\Log\LoggerInterface; /** * Used for extracting media asset list from a media content by the search pattern. + * + * This class should be used for DI configuration only, please use the interface in the code + * + * @api */ -class ExtractAssetFromContent +class ExtractAssetFromContent implements ExtractAssetFromContentInterface { /** * @var string diff --git a/app/code/Magento/MediaContentCatalog/LICENSE.txt b/app/code/Magento/MediaContentCatalog/LICENSE.txt new file mode 100644 index 0000000000000..49525fd99da9c --- /dev/null +++ b/app/code/Magento/MediaContentCatalog/LICENSE.txt @@ -0,0 +1,48 @@ + +Open Software License ("OSL") v. 3.0 + +This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Open Software License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + 1. to reproduce the Original Work in copies, either alone or as part of a collective work; + + 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; + + 4. to perform the Original Work publicly; and + + 5. to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magento/MediaContentCatalog/LICENSE_AFL.txt b/app/code/Magento/MediaContentCatalog/LICENSE_AFL.txt new file mode 100644 index 0000000000000..f39d641b18a19 --- /dev/null +++ b/app/code/Magento/MediaContentCatalog/LICENSE_AFL.txt @@ -0,0 +1,48 @@ + +Academic Free License ("AFL") v. 3.0 + +This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Academic Free License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + 1. to reproduce the Original Work in copies, either alone or as part of a collective work; + + 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License; + + 4. to perform the Original Work publicly; and + + 5. to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. diff --git a/app/code/Magento/Catalog/Observer/MediaContent/Category.php b/app/code/Magento/MediaContentCatalog/Observer/Category.php similarity index 57% rename from app/code/Magento/Catalog/Observer/MediaContent/Category.php rename to app/code/Magento/MediaContentCatalog/Observer/Category.php index 0044a7301e67b..83ad371426a47 100644 --- a/app/code/Magento/Catalog/Observer/MediaContent/Category.php +++ b/app/code/Magento/MediaContentCatalog/Observer/Category.php @@ -5,13 +5,13 @@ */ declare(strict_types=1); -namespace Magento\Catalog\Observer\MediaContent; +namespace Magento\MediaContentCatalog\Observer; use Magento\Catalog\Model\Category as CatalogCategory; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\Framework\Model\AbstractModel; -use Magento\MediaContentApi\Api\ModelProcessorInterface; +use Magento\MediaContentApi\Api\UpdateRelationsInterface; /** * Observe the catalog_category_save_after event and run processing relation between category content and media asset. @@ -21,7 +21,7 @@ class Category implements ObserverInterface private const CONTENT_TYPE = 'catalog_category'; /** - * @var ModelProcessorInterface + * @var UpdateRelationsInterface */ private $processor; @@ -31,10 +31,10 @@ class Category implements ObserverInterface private $fields; /** - * @param ModelProcessorInterface $processor + * @param UpdateRelationsInterface $processor * @param array $fields */ - public function __construct(ModelProcessorInterface $processor, array $fields) + public function __construct(UpdateRelationsInterface $processor, array $fields) { $this->processor = $processor; $this->fields = $fields; @@ -50,7 +50,27 @@ public function execute(Observer $observer): void /** @var CatalogCategory $model */ $model = $observer->getEvent()->getData('category'); if ($model instanceof AbstractModel) { - $this->processor->execute(self::CONTENT_TYPE, $model, $this->fields); + $this->updateRelations($model); + } + } + + /** + * Update relations for the model + * + * @param AbstractModel $model + */ + private function updateRelations(AbstractModel $model): void + { + foreach ($this->fields as $field) { + if (!$model->dataHasChangedFor($field)) { + continue; + } + $this->processor->execute( + self::CONTENT_TYPE, + $field, + (string) $model->getId(), + (string) $model->getData($field) + ); } } } diff --git a/app/code/Magento/Catalog/Observer/MediaContent/Product.php b/app/code/Magento/MediaContentCatalog/Observer/Product.php similarity index 57% rename from app/code/Magento/Catalog/Observer/MediaContent/Product.php rename to app/code/Magento/MediaContentCatalog/Observer/Product.php index bb043712a44f2..2bbcd65cd790e 100644 --- a/app/code/Magento/Catalog/Observer/MediaContent/Product.php +++ b/app/code/Magento/MediaContentCatalog/Observer/Product.php @@ -5,13 +5,13 @@ */ declare(strict_types=1); -namespace Magento\Catalog\Observer\MediaContent; +namespace Magento\MediaContentCatalog\Observer; use Magento\Catalog\Model\Product as CatalogProduct; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\Framework\Model\AbstractModel; -use Magento\MediaContentApi\Api\ModelProcessorInterface; +use Magento\MediaContentApi\Api\UpdateRelationsInterface; /** * Observe the catalog_product_save_after event and run processing relation between product content and media asset @@ -21,7 +21,7 @@ class Product implements ObserverInterface private const CONTENT_TYPE = 'catalog_product'; /** - * @var ModelProcessorInterface + * @var UpdateRelationsInterface */ private $processor; @@ -31,10 +31,10 @@ class Product implements ObserverInterface private $fields; /** - * @param ModelProcessorInterface $processor + * @param UpdateRelationsInterface $processor * @param array $fields */ - public function __construct(ModelProcessorInterface $processor, array $fields) + public function __construct(UpdateRelationsInterface $processor, array $fields) { $this->processor = $processor; $this->fields = $fields; @@ -50,7 +50,27 @@ public function execute(Observer $observer): void /** @var CatalogProduct $model */ $model = $observer->getEvent()->getData('product'); if ($model instanceof AbstractModel) { - $this->processor->execute(self::CONTENT_TYPE, $model, $this->fields); + $this->updateRelations($model); + } + } + + /** + * Update relations for the model + * + * @param AbstractModel $model + */ + private function updateRelations(AbstractModel $model): void + { + foreach ($this->fields as $field) { + if (!$model->dataHasChangedFor($field)) { + continue; + } + $this->processor->execute( + self::CONTENT_TYPE, + $field, + (string) $model->getId(), + (string) $model->getData($field) + ); } } } diff --git a/app/code/Magento/MediaContentCatalog/README.md b/app/code/Magento/MediaContentCatalog/README.md new file mode 100644 index 0000000000000..359126a8b7a13 --- /dev/null +++ b/app/code/Magento/MediaContentCatalog/README.md @@ -0,0 +1,13 @@ +# Magento_MediaContentCatalog module + +The Magento_MediaContentCatalog provides the implementation of MediaContent functionality for Magento_Catalog module + +## Extensibility + +Extension developers can interact with the Magento_MediaContent module. For more information about the Magento extension mechanism, see [Magento plug-ins](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html). + +[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_MediaContent module. + +## Additional information + +For information about significant changes in patch releases, see [2.3.x Release information](https://devdocs.magento.com/guides/v2.3/release-notes/bk-release-notes.html). diff --git a/app/code/Magento/MediaContentCatalog/composer.json b/app/code/Magento/MediaContentCatalog/composer.json new file mode 100644 index 0000000000000..9efe7aadba041 --- /dev/null +++ b/app/code/Magento/MediaContentCatalog/composer.json @@ -0,0 +1,23 @@ +{ + "name": "magento/module-media-content-catalog", + "description": "Magento module provides the implementation of MediaContent functionality for Magento_Catalog module", + "require": { + "php": "~7.1.3||~7.2.0||~7.3.0", + "magento/module-media-content-api": "*", + "magento/module-catalog": "*", + "magento/framework": "*" + }, + "type": "magento2-module", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "Magento\\MediaContentCatalog\\": "" + } + } +} diff --git a/app/code/Magento/MediaContentCatalog/etc/di.xml b/app/code/Magento/MediaContentCatalog/etc/di.xml new file mode 100644 index 0000000000000..d39adaa725b5a --- /dev/null +++ b/app/code/Magento/MediaContentCatalog/etc/di.xml @@ -0,0 +1,32 @@ +<?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:ObjectManager/etc/config.xsd"> + <type name="Magento\MediaContentCatalog\Observer\Category"> + <arguments> + <argument name="fields" xsi:type="array"> + <item name="image" xsi:type="string">image</item> + <item name="description" xsi:type="string">description</item> + </argument> + </arguments> + </type> + <type name="Magento\MediaContentCatalog\Observer\Product"> + <arguments> + <argument name="fields" xsi:type="array"> + <item name="description" xsi:type="string">description</item> + <item name="short_description" xsi:type="string">short_description</item> + </argument> + </arguments> + </type> + <type name="Magento\MediaContentApi\Api\ExtractAssetFromContent"> + <arguments> + <argument name="searchPatterns" xsi:type="array"> + <item name="catalog_image" xsi:type="string">/^\/?media\/(.*)/</item> + </argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/MediaContentCatalog/etc/events.xml b/app/code/Magento/MediaContentCatalog/etc/events.xml new file mode 100644 index 0000000000000..f68d66eb3cc40 --- /dev/null +++ b/app/code/Magento/MediaContentCatalog/etc/events.xml @@ -0,0 +1,15 @@ +<?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:Event/etc/events.xsd"> + <event name="catalog_category_save_after"> + <observer name="media_content_catalog_category_save_after" instance="Magento\MediaContentCatalog\Observer\Category" /> + </event> + <event name="catalog_product_save_after"> + <observer name="media_content_catalog_product_save_after" instance="Magento\MediaContentCatalog\Observer\Product" /> + </event> +</config> diff --git a/app/code/Magento/MediaContentCatalog/etc/module.xml b/app/code/Magento/MediaContentCatalog/etc/module.xml new file mode 100644 index 0000000000000..9b863edd57e5e --- /dev/null +++ b/app/code/Magento/MediaContentCatalog/etc/module.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:Module/etc/module.xsd"> + <module name="Magento_MediaContentCatalog" /> +</config> diff --git a/app/code/Magento/MediaContentCatalog/registration.php b/app/code/Magento/MediaContentCatalog/registration.php new file mode 100644 index 0000000000000..e954285921cba --- /dev/null +++ b/app/code/Magento/MediaContentCatalog/registration.php @@ -0,0 +1,10 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_MediaContentCatalog', __DIR__); diff --git a/app/code/Magento/MediaContentCms/LICENSE.txt b/app/code/Magento/MediaContentCms/LICENSE.txt new file mode 100644 index 0000000000000..49525fd99da9c --- /dev/null +++ b/app/code/Magento/MediaContentCms/LICENSE.txt @@ -0,0 +1,48 @@ + +Open Software License ("OSL") v. 3.0 + +This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Open Software License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + 1. to reproduce the Original Work in copies, either alone or as part of a collective work; + + 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; + + 4. to perform the Original Work publicly; and + + 5. to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magento/MediaContentCms/LICENSE_AFL.txt b/app/code/Magento/MediaContentCms/LICENSE_AFL.txt new file mode 100644 index 0000000000000..f39d641b18a19 --- /dev/null +++ b/app/code/Magento/MediaContentCms/LICENSE_AFL.txt @@ -0,0 +1,48 @@ + +Academic Free License ("AFL") v. 3.0 + +This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Academic Free License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + 1. to reproduce the Original Work in copies, either alone or as part of a collective work; + + 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License; + + 4. to perform the Original Work publicly; and + + 5. to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. diff --git a/app/code/Magento/Cms/Observer/MediaContent/Block.php b/app/code/Magento/MediaContentCms/Observer/Block.php similarity index 56% rename from app/code/Magento/Cms/Observer/MediaContent/Block.php rename to app/code/Magento/MediaContentCms/Observer/Block.php index 80fe854531586..106f42fcc0b7b 100644 --- a/app/code/Magento/Cms/Observer/MediaContent/Block.php +++ b/app/code/Magento/MediaContentCms/Observer/Block.php @@ -5,13 +5,13 @@ */ declare(strict_types=1); -namespace Magento\Cms\Observer\MediaContent; +namespace Magento\MediaContentCms\Observer; use Magento\Cms\Block\Block as CmsBlock; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\Framework\Model\AbstractModel; -use Magento\MediaContentApi\Api\ModelProcessorInterface; +use Magento\MediaContentApi\Api\UpdateRelationsInterface; /** * Observe cms_block_save_after event and run processing relation between cms block content and media asset @@ -21,7 +21,7 @@ class Block implements ObserverInterface private const CONTENT_TYPE = 'cms_block'; /** - * @var ModelProcessorInterface + * @var UpdateRelationsInterface */ private $processor; @@ -31,10 +31,10 @@ class Block implements ObserverInterface private $fields; /** - * @param ModelProcessorInterface $processor + * @param UpdateRelationsInterface $processor * @param array $fields */ - public function __construct(ModelProcessorInterface $processor, array $fields) + public function __construct(UpdateRelationsInterface $processor, array $fields) { $this->processor = $processor; $this->fields = $fields; @@ -50,7 +50,27 @@ public function execute(Observer $observer): void /** @var CmsBlock $model */ $model = $observer->getEvent()->getData('object'); if ($model instanceof AbstractModel) { - $this->processor->execute(self::CONTENT_TYPE, $model, $this->fields); + $this->updateRelations($model); + } + } + + /** + * Update relations for the model + * + * @param AbstractModel $model + */ + private function updateRelations(AbstractModel $model): void + { + foreach ($this->fields as $field) { + if (!$model->dataHasChangedFor($field)) { + continue; + } + $this->processor->execute( + self::CONTENT_TYPE, + $field, + (string) $model->getId(), + (string) $model->getData($field) + ); } } } diff --git a/app/code/Magento/Cms/Observer/MediaContent/Page.php b/app/code/Magento/MediaContentCms/Observer/Page.php similarity index 56% rename from app/code/Magento/Cms/Observer/MediaContent/Page.php rename to app/code/Magento/MediaContentCms/Observer/Page.php index cc4fe14990a86..8dd80840508a8 100644 --- a/app/code/Magento/Cms/Observer/MediaContent/Page.php +++ b/app/code/Magento/MediaContentCms/Observer/Page.php @@ -5,13 +5,13 @@ */ declare(strict_types=1); -namespace Magento\Cms\Observer\MediaContent; +namespace Magento\MediaContentCms\Observer; use Magento\Cms\Model\Page as CmsPage; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\Framework\Model\AbstractModel; -use Magento\MediaContentApi\Api\ModelProcessorInterface; +use Magento\MediaContentApi\Api\UpdateRelationsInterface; /** * Observe cms_page_save_after event and run processing relation between cms page content and media asset. @@ -21,7 +21,7 @@ class Page implements ObserverInterface private const CONTENT_TYPE = 'cms_page'; /** - * @var ModelProcessorInterface + * @var UpdateRelationsInterface */ private $processor; @@ -31,10 +31,10 @@ class Page implements ObserverInterface private $fields; /** - * @param ModelProcessorInterface $processor + * @param UpdateRelationsInterface $processor * @param array $fields */ - public function __construct(ModelProcessorInterface $processor, array $fields) + public function __construct(UpdateRelationsInterface $processor, array $fields) { $this->processor = $processor; $this->fields = $fields; @@ -50,7 +50,27 @@ public function execute(Observer $observer): void /** @var CmsPage $model */ $model = $observer->getEvent()->getData('object'); if ($model instanceof AbstractModel) { - $this->processor->execute(self::CONTENT_TYPE, $model, $this->fields); + $this->updateRelations($model); + } + } + + /** + * Update relations for the model + * + * @param AbstractModel $model + */ + private function updateRelations(AbstractModel $model): void + { + foreach ($this->fields as $field) { + if (!$model->dataHasChangedFor($field)) { + continue; + } + $this->processor->execute( + self::CONTENT_TYPE, + $field, + (string) $model->getId(), + (string) $model->getData($field) + ); } } } diff --git a/app/code/Magento/MediaContentCms/README.md b/app/code/Magento/MediaContentCms/README.md new file mode 100644 index 0000000000000..32b0fdc2bbd2f --- /dev/null +++ b/app/code/Magento/MediaContentCms/README.md @@ -0,0 +1,13 @@ +# Magento_MediaContentCms module + +The Magento_MediaContentCms provides the implementation of MediaContent functionality for Magento_Cms module + +## Extensibility + +Extension developers can interact with the Magento_MediaContent module. For more information about the Magento extension mechanism, see [Magento plug-ins](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html). + +[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_MediaContent module. + +## Additional information + +For information about significant changes in patch releases, see [2.3.x Release information](https://devdocs.magento.com/guides/v2.3/release-notes/bk-release-notes.html). diff --git a/app/code/Magento/MediaContentCms/composer.json b/app/code/Magento/MediaContentCms/composer.json new file mode 100644 index 0000000000000..318027d87a44b --- /dev/null +++ b/app/code/Magento/MediaContentCms/composer.json @@ -0,0 +1,23 @@ +{ + "name": "magento/module-media-content-cms", + "description": "Magento module provides the implementation of MediaContent functionality for Magento_Cms module", + "require": { + "php": "~7.1.3||~7.2.0||~7.3.0", + "magento/module-media-content-api": "*", + "magento/module-cms": "*", + "magento/framework": "*" + }, + "type": "magento2-module", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "Magento\\MediaContentApi\\": "" + } + } +} diff --git a/app/code/Magento/MediaContentCms/etc/di.xml b/app/code/Magento/MediaContentCms/etc/di.xml new file mode 100644 index 0000000000000..bccb8084f5050 --- /dev/null +++ b/app/code/Magento/MediaContentCms/etc/di.xml @@ -0,0 +1,30 @@ +<?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:ObjectManager/etc/config.xsd"> + <type name="Magento\MediaContentCms\Observer\Block"> + <arguments> + <argument name="fields" xsi:type="array"> + <item name="content" xsi:type="string">content</item> + </argument> + </arguments> + </type> + <type name="Magento\MediaContentCms\Observer\Page"> + <arguments> + <argument name="fields" xsi:type="array"> + <item name="content" xsi:type="string">content</item> + </argument> + </arguments> + </type> + <type name="Magento\MediaContentApi\Api\ExtractAssetFromContent"> + <arguments> + <argument name="searchPatterns" xsi:type="array"> + <item name="media_gallery" xsi:type="string">/{{media url="?(.*?)"?}}/</item> + </argument> + </arguments> + </type> +</config> diff --git a/app/code/Magento/MediaContentCms/etc/events.xml b/app/code/Magento/MediaContentCms/etc/events.xml new file mode 100644 index 0000000000000..7e9abe3bf19c4 --- /dev/null +++ b/app/code/Magento/MediaContentCms/etc/events.xml @@ -0,0 +1,15 @@ +<?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:Event/etc/events.xsd"> + <event name="cms_page_save_after"> + <observer name="media_content_cms_page_save_after" instance="Magento\MediaContentCms\Observer\Page" /> + </event> + <event name="cms_block_save_after"> + <observer name="media_content_cms_block_save_after" instance="Magento\MediaContentCms\Observer\Block" /> + </event> +</config> diff --git a/app/code/Magento/MediaContentCms/etc/module.xml b/app/code/Magento/MediaContentCms/etc/module.xml new file mode 100644 index 0000000000000..7278f82890b42 --- /dev/null +++ b/app/code/Magento/MediaContentCms/etc/module.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:Module/etc/module.xsd"> + <module name="Magento_MediaContentCms" /> +</config> diff --git a/app/code/Magento/MediaContentCms/registration.php b/app/code/Magento/MediaContentCms/registration.php new file mode 100644 index 0000000000000..b231ce3c6f3de --- /dev/null +++ b/app/code/Magento/MediaContentCms/registration.php @@ -0,0 +1,10 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_MediaContentCms', __DIR__); diff --git a/composer.json b/composer.json index 4b0d4d18eac2a..ee3af30a71219 100644 --- a/composer.json +++ b/composer.json @@ -199,6 +199,8 @@ "magento/module-layered-navigation": "*", "magento/module-media-content": "*", "magento/module-media-content-api": "*", + "magento/module-media-content-catalog": "*", + "magento/module-media-content-cms": "*", "magento/module-media-gallery": "*", "magento/module-media-gallery-api": "*", "magento/module-media-storage": "*", diff --git a/composer.lock b/composer.lock index 550de1d904aec..cf45e2feb67bf 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b801d92bd57ad3f2d51d2b264e9c37ac", + "content-hash": "66e273c5612aa97cc3f9fe747057e38b", "packages": [ { "name": "braintree/braintree_php", @@ -1243,16 +1243,16 @@ }, { "name": "laminas/laminas-db", - "version": "2.11.2", + "version": "2.11.3", "source": { "type": "git", "url": "https://github.com/laminas/laminas-db.git", - "reference": "76f9527da996c2fef32ef1f3a939e18ca5e9d962" + "reference": "6c4238918b9204db1eb8cafae2c1940d40f4c007" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-db/zipball/76f9527da996c2fef32ef1f3a939e18ca5e9d962", - "reference": "76f9527da996c2fef32ef1f3a939e18ca5e9d962", + "url": "https://api.github.com/repos/laminas/laminas-db/zipball/6c4238918b9204db1eb8cafae2c1940d40f4c007", + "reference": "6c4238918b9204db1eb8cafae2c1940d40f4c007", "shasum": "" }, "require": { @@ -1261,7 +1261,7 @@ "php": "^5.6 || ^7.0" }, "replace": { - "zendframework/zend-db": "self.version" + "zendframework/zend-db": "^2.11.0" }, "require-dev": { "laminas/laminas-coding-standard": "~1.0.0", @@ -1301,7 +1301,7 @@ "db", "laminas" ], - "time": "2020-01-14T13:07:26+00:00" + "time": "2020-03-29T12:08:51+00:00" }, { "name": "laminas/laminas-dependency-plugin", @@ -1402,16 +1402,16 @@ }, { "name": "laminas/laminas-diactoros", - "version": "1.8.7p1", + "version": "1.8.7p2", "source": { "type": "git", "url": "https://github.com/laminas/laminas-diactoros.git", - "reference": "56a9aca1f89231763d24d2ae13531b97fa5f4029" + "reference": "6991c1af7c8d2c8efee81b22ba97024781824aaa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/56a9aca1f89231763d24d2ae13531b97fa5f4029", - "reference": "56a9aca1f89231763d24d2ae13531b97fa5f4029", + "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/6991c1af7c8d2c8efee81b22ba97024781824aaa", + "reference": "6991c1af7c8d2c8efee81b22ba97024781824aaa", "shasum": "" }, "require": { @@ -1423,7 +1423,7 @@ "psr/http-message-implementation": "1.0" }, "replace": { - "zendframework/zend-diactoros": "self.version" + "zendframework/zend-diactoros": "~1.8.7.0" }, "require-dev": { "ext-dom": "*", @@ -1473,7 +1473,7 @@ "psr", "psr-7" ], - "time": "2020-01-07T19:25:17+00:00" + "time": "2020-03-23T15:28:28+00:00" }, { "name": "laminas/laminas-escaper", @@ -1584,16 +1584,16 @@ }, { "name": "laminas/laminas-feed", - "version": "2.12.1", + "version": "2.12.2", "source": { "type": "git", "url": "https://github.com/laminas/laminas-feed.git", - "reference": "c9356994eb80d0f6b46d7e12ba048d450bf0cd72" + "reference": "8a193ac96ebcb3e16b6ee754ac2a889eefacb654" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-feed/zipball/c9356994eb80d0f6b46d7e12ba048d450bf0cd72", - "reference": "c9356994eb80d0f6b46d7e12ba048d450bf0cd72", + "url": "https://api.github.com/repos/laminas/laminas-feed/zipball/8a193ac96ebcb3e16b6ee754ac2a889eefacb654", + "reference": "8a193ac96ebcb3e16b6ee754ac2a889eefacb654", "shasum": "" }, "require": { @@ -1605,7 +1605,7 @@ "php": "^5.6 || ^7.0" }, "replace": { - "zendframework/zend-feed": "self.version" + "zendframework/zend-feed": "^2.12.0" }, "require-dev": { "laminas/laminas-cache": "^2.7.2", @@ -1647,20 +1647,20 @@ "feed", "laminas" ], - "time": "2020-03-23T10:40:31+00:00" + "time": "2020-03-29T12:36:29+00:00" }, { "name": "laminas/laminas-filter", - "version": "2.9.3", + "version": "2.9.4", "source": { "type": "git", "url": "https://github.com/laminas/laminas-filter.git", - "reference": "52b5cdbef8902280996e687e7352a648a8e22f31" + "reference": "3c4476e772a062cef7531c6793377ae585d89c82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-filter/zipball/52b5cdbef8902280996e687e7352a648a8e22f31", - "reference": "52b5cdbef8902280996e687e7352a648a8e22f31", + "url": "https://api.github.com/repos/laminas/laminas-filter/zipball/3c4476e772a062cef7531c6793377ae585d89c82", + "reference": "3c4476e772a062cef7531c6793377ae585d89c82", "shasum": "" }, "require": { @@ -1672,7 +1672,7 @@ "laminas/laminas-validator": "<2.10.1" }, "replace": { - "zendframework/zend-filter": "self.version" + "zendframework/zend-filter": "^2.9.2" }, "require-dev": { "laminas/laminas-coding-standard": "~1.0.0", @@ -1716,20 +1716,20 @@ "filter", "laminas" ], - "time": "2020-01-07T20:43:53+00:00" + "time": "2020-03-29T12:41:29+00:00" }, { "name": "laminas/laminas-form", - "version": "2.14.4", + "version": "2.14.5", "source": { "type": "git", "url": "https://github.com/laminas/laminas-form.git", - "reference": "8b985f74bfe32910edb4ba9503877c4310228cd2" + "reference": "3e22e09751cf6ae031be87a44e092e7925ce5b7b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-form/zipball/8b985f74bfe32910edb4ba9503877c4310228cd2", - "reference": "8b985f74bfe32910edb4ba9503877c4310228cd2", + "url": "https://api.github.com/repos/laminas/laminas-form/zipball/3e22e09751cf6ae031be87a44e092e7925ce5b7b", + "reference": "3e22e09751cf6ae031be87a44e092e7925ce5b7b", "shasum": "" }, "require": { @@ -1740,7 +1740,7 @@ "php": "^5.6 || ^7.0" }, "replace": { - "zendframework/zend-form": "self.version" + "zendframework/zend-form": "^2.14.3" }, "require-dev": { "doctrine/annotations": "~1.0", @@ -1798,7 +1798,7 @@ "form", "laminas" ], - "time": "2020-03-18T22:38:54+00:00" + "time": "2020-03-29T12:46:16+00:00" }, { "name": "laminas/laminas-http", @@ -1924,16 +1924,16 @@ }, { "name": "laminas/laminas-i18n", - "version": "2.10.2", + "version": "2.10.3", "source": { "type": "git", "url": "https://github.com/laminas/laminas-i18n.git", - "reference": "9699c98d97d2f519def3da8d4128dfe6e6ad11bf" + "reference": "94ff957a1366f5be94f3d3a9b89b50386649e3ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-i18n/zipball/9699c98d97d2f519def3da8d4128dfe6e6ad11bf", - "reference": "9699c98d97d2f519def3da8d4128dfe6e6ad11bf", + "url": "https://api.github.com/repos/laminas/laminas-i18n/zipball/94ff957a1366f5be94f3d3a9b89b50386649e3ae", + "reference": "94ff957a1366f5be94f3d3a9b89b50386649e3ae", "shasum": "" }, "require": { @@ -1946,7 +1946,7 @@ "phpspec/prophecy": "<1.9.0" }, "replace": { - "zendframework/zend-i18n": "self.version" + "zendframework/zend-i18n": "^2.10.1" }, "require-dev": { "laminas/laminas-cache": "^2.6.1", @@ -1995,7 +1995,7 @@ "i18n", "laminas" ], - "time": "2020-03-20T11:57:14+00:00" + "time": "2020-03-29T12:51:08+00:00" }, { "name": "laminas/laminas-inputfilter", @@ -2362,16 +2362,16 @@ }, { "name": "laminas/laminas-mime", - "version": "2.7.3", + "version": "2.7.4", "source": { "type": "git", "url": "https://github.com/laminas/laminas-mime.git", - "reference": "e844abb02e868fae154207929190292ad25057cc" + "reference": "e45a7d856bf7b4a7b5bd00d6371f9961dc233add" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-mime/zipball/e844abb02e868fae154207929190292ad25057cc", - "reference": "e844abb02e868fae154207929190292ad25057cc", + "url": "https://api.github.com/repos/laminas/laminas-mime/zipball/e45a7d856bf7b4a7b5bd00d6371f9961dc233add", + "reference": "e45a7d856bf7b4a7b5bd00d6371f9961dc233add", "shasum": "" }, "require": { @@ -2380,7 +2380,7 @@ "php": "^5.6 || ^7.0" }, "replace": { - "zendframework/zend-mime": "self.version" + "zendframework/zend-mime": "^2.7.2" }, "require-dev": { "laminas/laminas-coding-standard": "~1.0.0", @@ -2412,7 +2412,7 @@ "laminas", "mime" ], - "time": "2020-03-06T08:38:03+00:00" + "time": "2020-03-29T13:12:07+00:00" }, { "name": "laminas/laminas-modulemanager", @@ -2797,16 +2797,16 @@ }, { "name": "laminas/laminas-session", - "version": "2.9.2", + "version": "2.9.3", "source": { "type": "git", "url": "https://github.com/laminas/laminas-session.git", - "reference": "fdba34c1b257235dba2fff6ed4df1844390f85f6" + "reference": "519e8966146536cd97c1cc3d59a21b095fb814d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-session/zipball/fdba34c1b257235dba2fff6ed4df1844390f85f6", - "reference": "fdba34c1b257235dba2fff6ed4df1844390f85f6", + "url": "https://api.github.com/repos/laminas/laminas-session/zipball/519e8966146536cd97c1cc3d59a21b095fb814d7", + "reference": "519e8966146536cd97c1cc3d59a21b095fb814d7", "shasum": "" }, "require": { @@ -2816,7 +2816,7 @@ "php": "^5.6 || ^7.0" }, "replace": { - "zendframework/zend-session": "self.version" + "zendframework/zend-session": "^2.9.1" }, "require-dev": { "container-interop/container-interop": "^1.1", @@ -2864,7 +2864,7 @@ "laminas", "session" ], - "time": "2020-03-06T09:44:45+00:00" + "time": "2020-03-29T13:26:04+00:00" }, { "name": "laminas/laminas-soap", @@ -3078,16 +3078,16 @@ }, { "name": "laminas/laminas-validator", - "version": "2.13.2", + "version": "2.13.4", "source": { "type": "git", "url": "https://github.com/laminas/laminas-validator.git", - "reference": "e7bf6a2eedc0508ebde0ebc66662efeb0abbcb2c" + "reference": "93593684e70b8ed1e870cacd34ca32b0c0ace185" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/e7bf6a2eedc0508ebde0ebc66662efeb0abbcb2c", - "reference": "e7bf6a2eedc0508ebde0ebc66662efeb0abbcb2c", + "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/93593684e70b8ed1e870cacd34ca32b0c0ace185", + "reference": "93593684e70b8ed1e870cacd34ca32b0c0ace185", "shasum": "" }, "require": { @@ -3097,7 +3097,7 @@ "php": "^7.1" }, "replace": { - "zendframework/zend-validator": "self.version" + "zendframework/zend-validator": "^2.13.0" }, "require-dev": { "laminas/laminas-cache": "^2.6.1", @@ -3153,7 +3153,7 @@ "laminas", "validator" ], - "time": "2020-03-16T11:38:27+00:00" + "time": "2020-03-31T18:57:01+00:00" }, { "name": "laminas/laminas-view", @@ -4198,11 +4198,6 @@ "MIT" ], "authors": [ - { - "name": "Ben Ramsey", - "email": "ben@benramsey.com", - "homepage": "https://benramsey.com" - }, { "name": "Marijn Huizendveld", "email": "marijn.huizendveld@gmail.com" @@ -4210,6 +4205,11 @@ { "name": "Thibaud Fabre", "email": "thibaud@aztech.io" + }, + { + "name": "Ben Ramsey", + "email": "ben@benramsey.com", + "homepage": "https://benramsey.com" } ], "description": "Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifiers (UUID).", @@ -4362,16 +4362,16 @@ }, { "name": "symfony/console", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "4fa15ae7be74e53f6ec8c83ed403b97e23b665e9" + "reference": "10bb3ee3c97308869d53b3e3d03f6ac23ff985f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/4fa15ae7be74e53f6ec8c83ed403b97e23b665e9", - "reference": "4fa15ae7be74e53f6ec8c83ed403b97e23b665e9", + "url": "https://api.github.com/repos/symfony/console/zipball/10bb3ee3c97308869d53b3e3d03f6ac23ff985f7", + "reference": "10bb3ee3c97308869d53b3e3d03f6ac23ff985f7", "shasum": "" }, "require": { @@ -4434,20 +4434,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2020-02-24T13:10:00+00:00" + "time": "2020-03-30T11:41:10+00:00" }, { "name": "symfony/css-selector", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "d0a6dd288fa8848dcc3d1f58b94de6a7cc5d2d22" + "reference": "afc26133a6fbdd4f8842e38893e0ee4685c7c94b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/d0a6dd288fa8848dcc3d1f58b94de6a7cc5d2d22", - "reference": "d0a6dd288fa8848dcc3d1f58b94de6a7cc5d2d22", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/afc26133a6fbdd4f8842e38893e0ee4685c7c94b", + "reference": "afc26133a6fbdd4f8842e38893e0ee4685c7c94b", "shasum": "" }, "require": { @@ -4487,20 +4487,20 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2020-02-04T09:01:01+00:00" + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "4ad8e149799d3128621a3a1f70e92b9897a8930d" + "reference": "abc8e3618bfdb55e44c8c6a00abd333f831bbfed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4ad8e149799d3128621a3a1f70e92b9897a8930d", - "reference": "4ad8e149799d3128621a3a1f70e92b9897a8930d", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/abc8e3618bfdb55e44c8c6a00abd333f831bbfed", + "reference": "abc8e3618bfdb55e44c8c6a00abd333f831bbfed", "shasum": "" }, "require": { @@ -4557,7 +4557,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2020-02-04T09:32:40+00:00" + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -4619,16 +4619,16 @@ }, { "name": "symfony/filesystem", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "266c9540b475f26122b61ef8b23dd9198f5d1cfd" + "reference": "fe297193bf2e6866ed900ed2d5869362768df6a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/266c9540b475f26122b61ef8b23dd9198f5d1cfd", - "reference": "266c9540b475f26122b61ef8b23dd9198f5d1cfd", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/fe297193bf2e6866ed900ed2d5869362768df6a7", + "reference": "fe297193bf2e6866ed900ed2d5869362768df6a7", "shasum": "" }, "require": { @@ -4665,20 +4665,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2020-01-21T08:20:44+00:00" + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/finder", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "ea69c129aed9fdeca781d4b77eb20b62cf5d5357" + "reference": "5729f943f9854c5781984ed4907bbb817735776b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ea69c129aed9fdeca781d4b77eb20b62cf5d5357", - "reference": "ea69c129aed9fdeca781d4b77eb20b62cf5d5357", + "url": "https://api.github.com/repos/symfony/finder/zipball/5729f943f9854c5781984ed4907bbb817735776b", + "reference": "5729f943f9854c5781984ed4907bbb817735776b", "shasum": "" }, "require": { @@ -4714,7 +4714,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2020-02-14T07:42:58+00:00" + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4893,16 +4893,16 @@ }, { "name": "symfony/process", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "bf9166bac906c9e69fb7a11d94875e7ced97bcd7" + "reference": "3e40e87a20eaf83a1db825e1fa5097ae89042db3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/bf9166bac906c9e69fb7a11d94875e7ced97bcd7", - "reference": "bf9166bac906c9e69fb7a11d94875e7ced97bcd7", + "url": "https://api.github.com/repos/symfony/process/zipball/3e40e87a20eaf83a1db825e1fa5097ae89042db3", + "reference": "3e40e87a20eaf83a1db825e1fa5097ae89042db3", "shasum": "" }, "require": { @@ -4938,7 +4938,7 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2020-02-07T20:06:44+00:00" + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/service-contracts", @@ -5414,16 +5414,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.133.45", + "version": "3.134.1", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "928a23e2ee7e195a66f93d0758895e26958c3b7d" + "reference": "aefab57896b558634d24342bdc3c6814e8e533f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/928a23e2ee7e195a66f93d0758895e26958c3b7d", - "reference": "928a23e2ee7e195a66f93d0758895e26958c3b7d", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/aefab57896b558634d24342bdc3c6814e8e533f6", + "reference": "aefab57896b558634d24342bdc3c6814e8e533f6", "shasum": "" }, "require": { @@ -5494,7 +5494,7 @@ "s3", "sdk" ], - "time": "2020-03-26T18:12:15+00:00" + "time": "2020-04-01T18:14:23+00:00" }, { "name": "behat/gherkin", @@ -8970,16 +8970,16 @@ }, { "name": "symfony/browser-kit", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "090ce406505149d6852a7c03b0346dec3b8cf612" + "reference": "e4b0dc1b100bf75b5717c5b451397f230a618a42" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/090ce406505149d6852a7c03b0346dec3b8cf612", - "reference": "090ce406505149d6852a7c03b0346dec3b8cf612", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/e4b0dc1b100bf75b5717c5b451397f230a618a42", + "reference": "e4b0dc1b100bf75b5717c5b451397f230a618a42", "shasum": "" }, "require": { @@ -9025,20 +9025,20 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", - "time": "2020-02-23T10:00:59+00:00" + "time": "2020-03-28T10:15:50+00:00" }, { "name": "symfony/config", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "cbfef5ae91ccd3b06621c18d58cd355c68c87ae9" + "reference": "3f4a3de1af498ed0ea653d4dc2317794144e6ca4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/cbfef5ae91ccd3b06621c18d58cd355c68c87ae9", - "reference": "cbfef5ae91ccd3b06621c18d58cd355c68c87ae9", + "url": "https://api.github.com/repos/symfony/config/zipball/3f4a3de1af498ed0ea653d4dc2317794144e6ca4", + "reference": "3f4a3de1af498ed0ea653d4dc2317794144e6ca4", "shasum": "" }, "require": { @@ -9089,20 +9089,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2020-02-04T09:32:40+00:00" + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/dependency-injection", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "ebb2e882e8c9e2eb990aa61ddcd389848466e342" + "reference": "755b18859be26b90f4bf63753432d3387458bf31" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/ebb2e882e8c9e2eb990aa61ddcd389848466e342", - "reference": "ebb2e882e8c9e2eb990aa61ddcd389848466e342", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/755b18859be26b90f4bf63753432d3387458bf31", + "reference": "755b18859be26b90f4bf63753432d3387458bf31", "shasum": "" }, "require": { @@ -9162,20 +9162,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2020-02-29T09:50:10+00:00" + "time": "2020-03-30T10:09:30+00:00" }, { "name": "symfony/dom-crawler", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "11dcf08f12f29981bf770f097a5d64d65bce5929" + "reference": "4d0fb3374324071ecdd94898367a3fa4b5563162" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/11dcf08f12f29981bf770f097a5d64d65bce5929", - "reference": "11dcf08f12f29981bf770f097a5d64d65bce5929", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/4d0fb3374324071ecdd94898367a3fa4b5563162", + "reference": "4d0fb3374324071ecdd94898367a3fa4b5563162", "shasum": "" }, "require": { @@ -9223,20 +9223,20 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2020-02-29T10:05:28+00:00" + "time": "2020-03-29T19:12:22+00:00" }, { "name": "symfony/http-foundation", - "version": "v5.0.5", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "6f9c2ba72f4295d7ce6cf9f79dbb18036291d335" + "reference": "26fb006a2c7b6cdd23d52157b05f8414ffa417b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/6f9c2ba72f4295d7ce6cf9f79dbb18036291d335", - "reference": "6f9c2ba72f4295d7ce6cf9f79dbb18036291d335", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/26fb006a2c7b6cdd23d52157b05f8414ffa417b6", + "reference": "26fb006a2c7b6cdd23d52157b05f8414ffa417b6", "shasum": "" }, "require": { @@ -9278,20 +9278,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2020-02-14T07:43:07+00:00" + "time": "2020-03-30T14:14:32+00:00" }, { "name": "symfony/mime", - "version": "v5.0.5", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "9b3e5b5e58c56bbd76628c952d2b78556d305f3c" + "reference": "481b7d6da88922fb1e0d86a943987722b08f3955" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/9b3e5b5e58c56bbd76628c952d2b78556d305f3c", - "reference": "9b3e5b5e58c56bbd76628c952d2b78556d305f3c", + "url": "https://api.github.com/repos/symfony/mime/zipball/481b7d6da88922fb1e0d86a943987722b08f3955", + "reference": "481b7d6da88922fb1e0d86a943987722b08f3955", "shasum": "" }, "require": { @@ -9340,20 +9340,20 @@ "mime", "mime-type" ], - "time": "2020-02-04T09:41:09+00:00" + "time": "2020-03-27T16:56:45+00:00" }, { "name": "symfony/options-resolver", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "9a02d6662660fe7bfadad63b5f0b0718d4c8b6b0" + "reference": "9072131b5e6e21203db3249c7db26b52897bc73e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/9a02d6662660fe7bfadad63b5f0b0718d4c8b6b0", - "reference": "9a02d6662660fe7bfadad63b5f0b0718d4c8b6b0", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/9072131b5e6e21203db3249c7db26b52897bc73e", + "reference": "9072131b5e6e21203db3249c7db26b52897bc73e", "shasum": "" }, "require": { @@ -9394,7 +9394,7 @@ "configuration", "options" ], - "time": "2020-01-04T13:00:46+00:00" + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/polyfill-intl-idn", @@ -9574,16 +9574,16 @@ }, { "name": "symfony/stopwatch", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "abc08d7c48987829bac301347faa10f7e8bbf4fb" + "reference": "e0324d3560e4128270e3f08617480d9233d81cfc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/abc08d7c48987829bac301347faa10f7e8bbf4fb", - "reference": "abc08d7c48987829bac301347faa10f7e8bbf4fb", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/e0324d3560e4128270e3f08617480d9233d81cfc", + "reference": "e0324d3560e4128270e3f08617480d9233d81cfc", "shasum": "" }, "require": { @@ -9620,20 +9620,20 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2020-01-04T13:00:46+00:00" + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/yaml", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "94d005c176db2080e98825d98e01e8b311a97a88" + "reference": "ef166890d821518106da3560086bfcbeb4fadfec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/94d005c176db2080e98825d98e01e8b311a97a88", - "reference": "94d005c176db2080e98825d98e01e8b311a97a88", + "url": "https://api.github.com/repos/symfony/yaml/zipball/ef166890d821518106da3560086bfcbeb4fadfec", + "reference": "ef166890d821518106da3560086bfcbeb4fadfec", "shasum": "" }, "require": { @@ -9679,7 +9679,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2020-02-03T10:46:43+00:00" + "time": "2020-03-30T11:41:10+00:00" }, { "name": "theseer/fdomdocument", @@ -9763,16 +9763,16 @@ }, { "name": "vlucas/phpdotenv", - "version": "v2.6.1", + "version": "v2.6.2", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "2a7dcf7e3e02dc5e701004e51a6f304b713107d5" + "reference": "c4a653ed3f1ff900baa15b4130c8770b57285b62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/2a7dcf7e3e02dc5e701004e51a6f304b713107d5", - "reference": "2a7dcf7e3e02dc5e701004e51a6f304b713107d5", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/c4a653ed3f1ff900baa15b4130c8770b57285b62", + "reference": "c4a653ed3f1ff900baa15b4130c8770b57285b62", "shasum": "" }, "require": { @@ -9780,8 +9780,14 @@ "symfony/polyfill-ctype": "^1.9" }, "require-dev": { + "ext-filter": "*", + "ext-pcre": "*", "phpunit/phpunit": "^4.8.35 || ^5.0" }, + "suggest": { + "ext-filter": "Required to use the boolean validator.", + "ext-pcre": "Required to use most of the library." + }, "type": "library", "extra": { "branch-alias": { @@ -9810,7 +9816,7 @@ "env", "environment" ], - "time": "2019-01-29T11:11:52+00:00" + "time": "2020-03-27T23:16:19+00:00" }, { "name": "webmozart/assert", From b6e79cf870273936cb70ffc05add1fa73a9e3334 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Wed, 1 Apr 2020 21:48:25 +0100 Subject: [PATCH 045/177] magento/magento2#27536: Code review changes --- .../MediaContent/Model/ModelProcessor.php | 54 ------------------- .../Model/ExtractAssetFromContent.php | 5 ++ 2 files changed, 5 insertions(+), 54 deletions(-) delete mode 100644 app/code/Magento/MediaContent/Model/ModelProcessor.php diff --git a/app/code/Magento/MediaContent/Model/ModelProcessor.php b/app/code/Magento/MediaContent/Model/ModelProcessor.php deleted file mode 100644 index 8e3a3ebf168d6..0000000000000 --- a/app/code/Magento/MediaContent/Model/ModelProcessor.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaContent\Model; - -use Magento\Framework\Model\AbstractModel; - -/** - * Save relations for content within an AbstractModel instance - */ -class ModelProcessor implements ModelProcessorInterface -{ - /** - * Content processor - * - * @var ContentProcessor - */ - private $contentProcessor; - - /** - * @param ContentProcessor $contentProcessor - */ - public function __construct( - ContentProcessor $contentProcessor - ) { - $this->contentProcessor = $contentProcessor; - } - - /** - * Save relations for content within an AbstractModel instance - * - * @param string $type - * @param AbstractModel $model - * @param array $fields - */ - public function execute(string $type, AbstractModel $model, array $fields): void - { - foreach ($fields as $field) { - if (!$model->dataHasChangedFor($field)) { - continue; - } - $this->contentProcessor->execute( - $type, - $field, - (string) $model->getId(), - (string) $model->getData($field) - ); - } - } -} diff --git a/app/code/Magento/MediaContentApi/Model/ExtractAssetFromContent.php b/app/code/Magento/MediaContentApi/Model/ExtractAssetFromContent.php index c307fa88a2e5e..57cef519f1f2a 100644 --- a/app/code/Magento/MediaContentApi/Model/ExtractAssetFromContent.php +++ b/app/code/Magento/MediaContentApi/Model/ExtractAssetFromContent.php @@ -62,7 +62,12 @@ public function execute(string $content): array $paths = []; foreach ($this->searchPatterns as $pattern) { + if (empty($pattern)) { + continue; + } + preg_match_all($pattern, $content, $matches, PREG_PATTERN_ORDER); + if (!empty($matches[1])) { $paths += array_unique($matches[1]); } From 45c8564a6264c37ee7c43a7862abd0f3b5216570 Mon Sep 17 00:00:00 2001 From: Ihor Sviziev <ihor-sviziev@users.noreply.github.com> Date: Thu, 2 Apr 2020 12:17:57 +0300 Subject: [PATCH 046/177] Fix static tests --- .../Framework/TestFramework/Unit/Listener/GarbageCleanup.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/TestFramework/Unit/Listener/GarbageCleanup.php b/lib/internal/Magento/Framework/TestFramework/Unit/Listener/GarbageCleanup.php index 483bc7148a7c7..34a8963c198cc 100644 --- a/lib/internal/Magento/Framework/TestFramework/Unit/Listener/GarbageCleanup.php +++ b/lib/internal/Magento/Framework/TestFramework/Unit/Listener/GarbageCleanup.php @@ -17,7 +17,8 @@ class GarbageCleanup implements TestListener use \PHPUnit\Framework\TestListenerDefaultImplementation; /** - * {@inheritdoc} + * @inheritdoc + * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function endTestSuite(TestSuite $suite): void From cd544f4e59f744a199db07754f1e3b415b135354 Mon Sep 17 00:00:00 2001 From: Marcus Pettersen Irgens <marcus.irgens@visma.com> Date: Thu, 2 Apr 2020 14:21:17 +0200 Subject: [PATCH 047/177] Fix type hint for Select::where --- lib/internal/Magento/Framework/DB/Select.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/DB/Select.php b/lib/internal/Magento/Framework/DB/Select.php index ceeed40787123..075aa6b24faa7 100644 --- a/lib/internal/Magento/Framework/DB/Select.php +++ b/lib/internal/Magento/Framework/DB/Select.php @@ -91,6 +91,12 @@ public function __construct( * $select->where('id = :id'); * </code> * + * You may also construct IN statements: + * + * <code> + * $select->where('entity_id IN (?)', ['1', '2', '3']); + * </code> + * * Note that it is more correct to use named bindings in your * queries for values other than strings. When you use named * bindings, don't forget to pass the values when actually @@ -101,7 +107,7 @@ public function __construct( * </code> * * @param string $cond The WHERE condition. - * @param string $value OPTIONAL A single value to quote into the condition. + * @param string|array|null $value OPTIONAL An optional single or array value to quote into the condition. * @param string|int|null $type OPTIONAL The type of the given value * @return \Magento\Framework\DB\Select */ From 96d56b29047990417ae2a487e8cc8866790a9d27 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Thu, 2 Apr 2020 17:21:24 +0200 Subject: [PATCH 048/177] Fix issue with loading mask still visible before choosing Shipping Methods --- .../Mftf/ActionGroup/OrderSelectFlatRateShippingActionGroup.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/OrderSelectFlatRateShippingActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/OrderSelectFlatRateShippingActionGroup.xml index b85dc21e0b1b5..aca3ee0fdfef6 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/OrderSelectFlatRateShippingActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/OrderSelectFlatRateShippingActionGroup.xml @@ -14,7 +14,7 @@ </annotations> <click selector="{{AdminOrderFormPaymentSection.header}}" stepKey="unfocus"/> - <waitForPageLoad stepKey="waitForJavascriptToFinish"/> + <waitForLoadingMaskToDisappear stepKey="waitForJavascriptToFinish"/> <click selector="{{AdminOrderFormPaymentSection.getShippingMethods}}" stepKey="clickShippingMethods"/> <waitForElementVisible selector="{{AdminOrderFormPaymentSection.flatRateOption}}" stepKey="waitForShippingOptions"/> <selectOption selector="{{AdminOrderFormPaymentSection.flatRateOption}}" userInput="flatrate_flatrate" stepKey="checkFlatRate"/> From 23fb9143030cce13af7e7302c529f806200c0464 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Thu, 2 Apr 2020 16:18:15 -0500 Subject: [PATCH 049/177] magento/magento2#27536: Review fixes --- .../MediaContentCatalog/Observer/Category.php | 30 ++++++------------ .../MediaContentCatalog/Observer/Product.php | 31 +++++++------------ .../MediaContentCms/Observer/Block.php | 30 ++++++------------ .../Magento/MediaContentCms/Observer/Page.php | 30 ++++++------------ 4 files changed, 41 insertions(+), 80 deletions(-) diff --git a/app/code/Magento/MediaContentCatalog/Observer/Category.php b/app/code/Magento/MediaContentCatalog/Observer/Category.php index 83ad371426a47..58efd114f5782 100644 --- a/app/code/Magento/MediaContentCatalog/Observer/Category.php +++ b/app/code/Magento/MediaContentCatalog/Observer/Category.php @@ -50,27 +50,17 @@ public function execute(Observer $observer): void /** @var CatalogCategory $model */ $model = $observer->getEvent()->getData('category'); if ($model instanceof AbstractModel) { - $this->updateRelations($model); - } - } - - /** - * Update relations for the model - * - * @param AbstractModel $model - */ - private function updateRelations(AbstractModel $model): void - { - foreach ($this->fields as $field) { - if (!$model->dataHasChangedFor($field)) { - continue; + foreach ($this->fields as $field) { + if (!$model->dataHasChangedFor($field)) { + continue; + } + $this->processor->execute( + self::CONTENT_TYPE, + $field, + (string) $model->getId(), + (string) $model->getData($field) + ); } - $this->processor->execute( - self::CONTENT_TYPE, - $field, - (string) $model->getId(), - (string) $model->getData($field) - ); } } } diff --git a/app/code/Magento/MediaContentCatalog/Observer/Product.php b/app/code/Magento/MediaContentCatalog/Observer/Product.php index 2bbcd65cd790e..9349d5ff90be0 100644 --- a/app/code/Magento/MediaContentCatalog/Observer/Product.php +++ b/app/code/Magento/MediaContentCatalog/Observer/Product.php @@ -49,28 +49,19 @@ public function execute(Observer $observer): void { /** @var CatalogProduct $model */ $model = $observer->getEvent()->getData('product'); - if ($model instanceof AbstractModel) { - $this->updateRelations($model); - } - } - /** - * Update relations for the model - * - * @param AbstractModel $model - */ - private function updateRelations(AbstractModel $model): void - { - foreach ($this->fields as $field) { - if (!$model->dataHasChangedFor($field)) { - continue; + if ($model instanceof AbstractModel) { + foreach ($this->fields as $field) { + if (!$model->dataHasChangedFor($field)) { + continue; + } + $this->processor->execute( + self::CONTENT_TYPE, + $field, + (string) $model->getId(), + (string) $model->getData($field) + ); } - $this->processor->execute( - self::CONTENT_TYPE, - $field, - (string) $model->getId(), - (string) $model->getData($field) - ); } } } diff --git a/app/code/Magento/MediaContentCms/Observer/Block.php b/app/code/Magento/MediaContentCms/Observer/Block.php index 106f42fcc0b7b..9d5d24d422a78 100644 --- a/app/code/Magento/MediaContentCms/Observer/Block.php +++ b/app/code/Magento/MediaContentCms/Observer/Block.php @@ -50,27 +50,17 @@ public function execute(Observer $observer): void /** @var CmsBlock $model */ $model = $observer->getEvent()->getData('object'); if ($model instanceof AbstractModel) { - $this->updateRelations($model); - } - } - - /** - * Update relations for the model - * - * @param AbstractModel $model - */ - private function updateRelations(AbstractModel $model): void - { - foreach ($this->fields as $field) { - if (!$model->dataHasChangedFor($field)) { - continue; + foreach ($this->fields as $field) { + if (!$model->dataHasChangedFor($field)) { + continue; + } + $this->processor->execute( + self::CONTENT_TYPE, + $field, + (string) $model->getId(), + (string) $model->getData($field) + ); } - $this->processor->execute( - self::CONTENT_TYPE, - $field, - (string) $model->getId(), - (string) $model->getData($field) - ); } } } diff --git a/app/code/Magento/MediaContentCms/Observer/Page.php b/app/code/Magento/MediaContentCms/Observer/Page.php index 8dd80840508a8..111b4478a9888 100644 --- a/app/code/Magento/MediaContentCms/Observer/Page.php +++ b/app/code/Magento/MediaContentCms/Observer/Page.php @@ -50,27 +50,17 @@ public function execute(Observer $observer): void /** @var CmsPage $model */ $model = $observer->getEvent()->getData('object'); if ($model instanceof AbstractModel) { - $this->updateRelations($model); - } - } - - /** - * Update relations for the model - * - * @param AbstractModel $model - */ - private function updateRelations(AbstractModel $model): void - { - foreach ($this->fields as $field) { - if (!$model->dataHasChangedFor($field)) { - continue; + foreach ($this->fields as $field) { + if (!$model->dataHasChangedFor($field)) { + continue; + } + $this->processor->execute( + self::CONTENT_TYPE, + $field, + (string) $model->getId(), + (string) $model->getData($field) + ); } - $this->processor->execute( - self::CONTENT_TYPE, - $field, - (string) $model->getId(), - (string) $model->getData($field) - ); } } } From f250d88ed34b55382e56afcffd954384b8537051 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Thu, 2 Apr 2020 21:17:18 -0500 Subject: [PATCH 050/177] magento/magento2#27536: Correct modules dependencies --- app/code/Magento/Cms/etc/module.xml | 1 + app/code/Magento/MediaContentCatalog/etc/di.xml | 2 +- app/code/Magento/MediaContentCms/etc/di.xml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Cms/etc/module.xml b/app/code/Magento/Cms/etc/module.xml index d3fc2846217d9..ff378a0312e56 100644 --- a/app/code/Magento/Cms/etc/module.xml +++ b/app/code/Magento/Cms/etc/module.xml @@ -11,6 +11,7 @@ <module name="Magento_Store"/> <module name="Magento_Theme"/> <module name="Magento_Variable"/> + <module name="Magento_MediaContent"/> </sequence> </module> </config> diff --git a/app/code/Magento/MediaContentCatalog/etc/di.xml b/app/code/Magento/MediaContentCatalog/etc/di.xml index d39adaa725b5a..a9cd9ac8bd796 100644 --- a/app/code/Magento/MediaContentCatalog/etc/di.xml +++ b/app/code/Magento/MediaContentCatalog/etc/di.xml @@ -22,7 +22,7 @@ </argument> </arguments> </type> - <type name="Magento\MediaContentApi\Api\ExtractAssetFromContent"> + <type name="Magento\MediaContentApi\Model\ExtractAssetFromContent"> <arguments> <argument name="searchPatterns" xsi:type="array"> <item name="catalog_image" xsi:type="string">/^\/?media\/(.*)/</item> diff --git a/app/code/Magento/MediaContentCms/etc/di.xml b/app/code/Magento/MediaContentCms/etc/di.xml index bccb8084f5050..165c295c28208 100644 --- a/app/code/Magento/MediaContentCms/etc/di.xml +++ b/app/code/Magento/MediaContentCms/etc/di.xml @@ -20,7 +20,7 @@ </argument> </arguments> </type> - <type name="Magento\MediaContentApi\Api\ExtractAssetFromContent"> + <type name="Magento\MediaContentApi\Model\ExtractAssetFromContent"> <arguments> <argument name="searchPatterns" xsi:type="array"> <item name="media_gallery" xsi:type="string">/{{media url="?(.*?)"?}}/</item> From ef94acbaf0010f6cc7c7a189730e9fc85d87aa99 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Thu, 2 Apr 2020 21:18:29 -0500 Subject: [PATCH 051/177] magento/magento2#27536: Correct interface preference --- app/code/Magento/MediaContent/etc/di.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/MediaContent/etc/di.xml b/app/code/Magento/MediaContent/etc/di.xml index 66be373535c6c..98031f32211d4 100644 --- a/app/code/Magento/MediaContent/etc/di.xml +++ b/app/code/Magento/MediaContent/etc/di.xml @@ -10,6 +10,6 @@ <preference for="Magento\MediaContentApi\Api\UnassignAssetInterface" type="Magento\MediaContent\Model\UnassignAsset"/> <preference for="Magento\MediaContentApi\Api\GetAssetsUsedInContentInterface" type="Magento\MediaContent\Model\GetAssetsUsedInContent"/> <preference for="Magento\MediaContentApi\Api\GetContentWithAssetInterface" type="Magento\MediaContent\Model\GetContentWithAsset"/> - <preference for="Magento\MediaContentApi\Api\ExtractAssetFromContentInterface" type="Magento\MediaContent\Model\ExtractAssetFromContent"/> + <preference for="Magento\MediaContentApi\Api\ExtractAssetFromContentInterface" type="Magento\MediaContentApi\Model\ExtractAssetFromContent"/> <preference for="Magento\MediaContentApi\Api\UpdateRelationsInterface" type="Magento\MediaContent\Model\UpdateRelations"/> </config> From e671db30c6d593301b8817f34840d0c9e20672e2 Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets <vzaets@magento.com> Date: Thu, 2 Apr 2020 21:36:45 -0500 Subject: [PATCH 052/177] - Rename interface - Refactoring - Test coverage --- .../Model/Directory/IsBlacklisted.php} | 8 +- .../Model/Directory/IsBlacklistedTest.php} | 14 ++-- app/code/Magento/MediaGallery/etc/di.xml | 17 ++++ ...terface.php => IsBlacklistedInterface.php} | 4 +- app/code/Magento/MediaGalleryApi/etc/di.xml | 24 ------ .../Directory/Command/DeleteByPathTest.php | 83 +++++++++++++++++++ 6 files changed, 114 insertions(+), 36 deletions(-) rename app/code/Magento/{MediaGalleryApi/Model/Directory/Blacklist.php => MediaGallery/Model/Directory/IsBlacklisted.php} (82%) rename app/code/Magento/{MediaGalleryApi/Test/Unit/Model/Directory/BlacklistTest.php => MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php} (75%) rename app/code/Magento/MediaGalleryApi/Model/Directory/{BlacklistInterface.php => IsBlacklistedInterface.php} (84%) delete mode 100644 app/code/Magento/MediaGalleryApi/etc/di.xml create mode 100644 dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php diff --git a/app/code/Magento/MediaGalleryApi/Model/Directory/Blacklist.php b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php similarity index 82% rename from app/code/Magento/MediaGalleryApi/Model/Directory/Blacklist.php rename to app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php index fc6d73550f0fa..312d5ab3dcf8a 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Directory/Blacklist.php +++ b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php @@ -5,7 +5,9 @@ */ declare(strict_types=1); -namespace Magento\MediaGalleryApi\Model\Directory; +namespace Magento\MediaGallery\Model\Directory; + +use Magento\MediaGalleryApi\Model\Directory\IsBlacklistedInterface; /** * Directories blacklisted for media gallery. This class should be used for DI configuration. @@ -14,7 +16,7 @@ * * @api */ -class Blacklist implements BlacklistInterface +class IsBlacklisted implements IsBlacklistedInterface { /** * @var array @@ -36,7 +38,7 @@ public function __construct( * @param string $path * @return bool */ - public function isBlacklisted(string $path): bool + public function execute(string $path): bool { foreach ($this->patterns as $pattern) { if (empty($pattern)) { diff --git a/app/code/Magento/MediaGalleryApi/Test/Unit/Model/Directory/BlacklistTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php similarity index 75% rename from app/code/Magento/MediaGalleryApi/Test/Unit/Model/Directory/BlacklistTest.php rename to app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php index 3fe4ebd7cafcc..4742db34cfcab 100644 --- a/app/code/Magento/MediaGalleryApi/Test/Unit/Model/Directory/BlacklistTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php @@ -5,19 +5,19 @@ */ declare(strict_types=1); -namespace Magento\MediaGalleryApi\Test\Unit\Model\Directory; +namespace Magento\MediaGallery\Test\Unit\Model\Directory; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use PHPUnit\Framework\TestCase; -use Magento\MediaGalleryApi\Model\Directory\Blacklist; +use Magento\MediaGallery\Model\Directory\IsBlacklisted; /** * Test the Excluded model */ -class BlacklistTest extends TestCase +class IsBlacklistedTest extends TestCase { /** - * @var Blacklist + * @var */ private $object; @@ -27,7 +27,7 @@ class BlacklistTest extends TestCase protected function setUp(): void { $this->object = (new ObjectManager($this))->getObject( - Blacklist::class, + IsBlacklisted::class, [ 'patterns' => [ 'tmp' => '/pub\/media\/tmp/', @@ -44,9 +44,9 @@ protected function setUp(): void * @param bool $isExcluded * @dataProvider pathsProvider */ - public function testIsBlacklisted(string $path, bool $isExcluded): void + public function testExecute(string $path, bool $isExcluded): void { - $this->assertEquals($isExcluded, $this->object->isBlacklisted($path)); + $this->assertEquals($isExcluded, $this->object->execute($path)); } /** diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index 67ae43e667d17..ea05da9498607 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -23,8 +23,25 @@ <preference for="Magento\MediaGalleryApi\Model\Directory\Command\CreateByPathInterface" type="Magento\MediaGallery\Model\Directory\Command\CreateByPath"/> <preference for="Magento\MediaGalleryApi\Model\Directory\Command\DeleteByPathInterface" type="Magento\MediaGallery\Model\Directory\Command\DeleteByPath"/> + + <preference for="Magento\MediaGalleryApi\Model\Directory\IsBlacklistedInterface" type="Magento\MediaGallery\Model\Directory\IsBlacklisted"/> + <preference for="Magento\MediaGalleryApi\Model\File\Command\DeleteByAssetIdInterface" type="Magento\MediaGallery\Model\File\Command\DeleteByAssetId"/> + <type name="Magento\MediaGallery\Model\Directory\IsBlacklisted"> + <arguments> + <argument name="patterns" xsi:type="array"> + <item name="captcha" xsi:type="string">/pub\/media\/captcha/</item> + <item name="catalog" xsi:type="string">/pub\/media\/catalog\/product/</item> + <item name="customer" xsi:type="string">/pub\/media\/customer/</item> + <item name="downloadable" xsi:type="string">/pub\/media\/downloadable/</item> + <item name="import" xsi:type="string">/pub\/media\/import/</item> + <item name="theme" xsi:type="string">/pub\/media\/theme/</item> + <item name="theme_customization" xsi:type="string">/pub\/media\/theme_customization/</item> + <item name="tmp" xsi:type="string">/pub\/media\/tmp/</item> + </argument> + </arguments> + </type> <type name="Magento\Catalog\Model\Product\Gallery\Processor"> <plugin name="media_gallery_image_remove_metadata" type="Magento\MediaGallery\Plugin\Product\Gallery\Processor" sortOrder="10" disabled="false"/> diff --git a/app/code/Magento/MediaGalleryApi/Model/Directory/BlacklistInterface.php b/app/code/Magento/MediaGalleryApi/Model/Directory/IsBlacklistedInterface.php similarity index 84% rename from app/code/Magento/MediaGalleryApi/Model/Directory/BlacklistInterface.php rename to app/code/Magento/MediaGalleryApi/Model/Directory/IsBlacklistedInterface.php index f75af40fa72a7..bc01bcdc77912 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Directory/BlacklistInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Directory/IsBlacklistedInterface.php @@ -11,7 +11,7 @@ * Directory paths that are reserved by system and not be included in the media gallery * @api */ -interface BlacklistInterface +interface IsBlacklistedInterface { /** * Check if the path is excluded from displaying and processing in the media gallery @@ -19,5 +19,5 @@ interface BlacklistInterface * @param string $path * @return bool */ - public function isBlacklisted(string $path): bool; + public function execute(string $path): bool; } diff --git a/app/code/Magento/MediaGalleryApi/etc/di.xml b/app/code/Magento/MediaGalleryApi/etc/di.xml deleted file mode 100644 index 7a00192cdd87b..0000000000000 --- a/app/code/Magento/MediaGalleryApi/etc/di.xml +++ /dev/null @@ -1,24 +0,0 @@ -<?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:ObjectManager/etc/config.xsd"> - <preference for="Magento\MediaGalleryApi\Model\Directory\BlacklistInterface" type="Magento\MediaGalleryApi\Model\Directory\Blacklist"/> - <type name="Magento\MediaGalleryApi\Model\Directory\Blacklist"> - <arguments> - <argument name="patterns" xsi:type="array"> - <item name="captcha" xsi:type="string">/pub\/media\/captcha/</item> - <item name="catalog" xsi:type="string">/pub\/media\/catalog\/product/</item> - <item name="customer" xsi:type="string">/pub\/media\/customer/</item> - <item name="downloadable" xsi:type="string">/pub\/media\/downloadable/</item> - <item name="import" xsi:type="string">/pub\/media\/import/</item> - <item name="theme" xsi:type="string">/pub\/media\/theme/</item> - <item name="theme_customization" xsi:type="string">/pub\/media\/theme_customization/</item> - <item name="tmp" xsi:type="string">/pub\/media\/tmp/</item> - </argument> - </arguments> - </type> -</config> diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php new file mode 100644 index 0000000000000..27da09e38889d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php @@ -0,0 +1,83 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + * + */ +namespace Magento\MediaGallery\Model\Directory\Command; + +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Filesystem; +use Magento\MediaGalleryApi\Model\Directory\Command\DeleteByPathInterface; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test methods of class DeleteByPath + */ +class DeleteByPathTest extends \PHPUnit\Framework\TestCase +{ + /** + * Test directory name + */ + private CONST TEST_DIRECTORY_NAME = 'testDeleteDirectory'; + + /** + * Absolute path to the media direcrory + */ + private static $_mediaPath; + + /** + * @var DeleteByPathInterface + */ + private $deleteByPath; + + /** + * @inheritdoc + */ + public static function setUpBeforeClass() + { + self::$_mediaPath = Bootstrap::getObjectManager()->get(Filesystem::class) + ->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath(); + mkdir(self::$_mediaPath . self::TEST_DIRECTORY_NAME); + } + + /** + * @inheritdoc + */ + public function setUp() + { + $this->deleteByPath = Bootstrap::getObjectManager()->create(DeleteByPathInterface::class); + } + + /** + * @return void + * @throws \Magento\Framework\Exception\CouldNotDeleteException + */ + public function testDeleteDirectoryWithExistingDirectoryAndCorrectAbsolutePath(): void + { + $fullPath = self::$_mediaPath . self::TEST_DIRECTORY_NAME; + $this->assertFileExists($fullPath); + $this->deleteByPath->execute(self::TEST_DIRECTORY_NAME); + $this->assertFileNotExists($fullPath); + } + + /** + * @return void + * @throws \Magento\Framework\Exception\CouldNotDeleteException + * @expectedException \Magento\Framework\Exception\CouldNotDeleteException + */ + public function testDeleteDirectoryWithRelativePathUnderMediaFolder(): void + { + $this->deleteByPath->execute('../../pub/media'); + } + + /** + * @return void + * @throws \Magento\Framework\Exception\CouldNotDeleteException + * @expectedException \Magento\Framework\Exception\CouldNotDeleteException + */ + public function testDeleteDirectoryThatIsNotAllowed(): void + { + $this->deleteByPath->execute('theme'); + } +} From ad24d872b562871825db16bd1f545331f8f4f37d Mon Sep 17 00:00:00 2001 From: Slava Mankivski <mankivsk@adobe.com> Date: Fri, 3 Apr 2020 00:29:11 -0500 Subject: [PATCH 053/177] Updated sequence for CMS --- app/code/Magento/Cms/etc/module.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Cms/etc/module.xml b/app/code/Magento/Cms/etc/module.xml index ff378a0312e56..880ce5b7075e6 100644 --- a/app/code/Magento/Cms/etc/module.xml +++ b/app/code/Magento/Cms/etc/module.xml @@ -12,6 +12,7 @@ <module name="Magento_Theme"/> <module name="Magento_Variable"/> <module name="Magento_MediaContent"/> + <module name="Magento_MediaContentApi"/> </sequence> </module> </config> From 83e7e37e2e2bef0bfffa67814adbb7bd3557805d Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets <vzaets@magento.com> Date: Fri, 3 Apr 2020 03:13:00 -0500 Subject: [PATCH 054/177] Test coverage --- .../Directory/Command/CreateByPathTest.php | 95 ++++++++++++++++++ .../Directory/Command/DeleteByPathTest.php | 21 +++- .../File/Command/DeleteByAssertIdTest.php | 99 +++++++++++++++++++ .../MediaGallery/_files/media_asset.php | 29 ++++++ 4 files changed, 241 insertions(+), 3 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php create mode 100644 dev/tests/integration/testsuite/Magento/MediaGallery/Model/File/Command/DeleteByAssertIdTest.php create mode 100644 dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php new file mode 100644 index 0000000000000..84861a5375713 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php @@ -0,0 +1,95 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + * + */ +namespace Magento\MediaGallery\Model\Directory\Command; + +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Filesystem; +use Magento\MediaGalleryApi\Model\Directory\Command\CreateByPathInterface; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Test methods of class CreateByPath + */ +class CreateByPathTest extends \PHPUnit\Framework\TestCase +{ + /** + * Test directory name + */ + private CONST TEST_DIRECTORY_NAME = 'testCreateDirectory'; + + /** + * Absolute path to the media direcrory + */ + private static $_mediaPath; + + /** + * @var CreateByPathInterface + */ + private $createByPath; + + /** + * @inheritdoc + */ + public static function setUpBeforeClass() + { + self::$_mediaPath = Bootstrap::getObjectManager()->get(Filesystem::class) + ->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath(); + } + + /** + * @inheritdoc + */ + public function setUp() + { + $this->createByPath = Bootstrap::getObjectManager()->create(CreateByPathInterface::class); + } + + /** + * @return void + * @throws \Magento\Framework\Exception\CouldNotSaveException + */ + public function testCreateDirectory(): void + { + $fullPath = self::$_mediaPath . self::TEST_DIRECTORY_NAME; + $this->createByPath->execute('', self::TEST_DIRECTORY_NAME); + $this->assertFileExists($fullPath); + } + + /** + * @return void + * @throws \Magento\Framework\Exception\CouldNotSaveException + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + */ + public function testCreateDirectoryThatAlreadyExist(): void + { + $this->createByPath->execute('', self::TEST_DIRECTORY_NAME); + } + + /** + * @return void + * @throws \Magento\Framework\Exception\CouldNotSaveException + * @expectedException \Magento\Framework\Exception\CouldNotSaveException + */ + public function testCreateDirectoryWithRelativePath(): void + { + $this->createByPath->execute('../../pub/', self::TEST_DIRECTORY_NAME); + } + + /** + * @throws \Magento\Framework\Exception\FileSystemException + */ + public static function tearDownAfterClass() + { + $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Framework\Filesystem::class); + /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $directory */ + $directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); + if ($directory->isExist(self::TEST_DIRECTORY_NAME)) { + $directory->delete(self::TEST_DIRECTORY_NAME); + } + } +} diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php index 27da09e38889d..282dbe2ed11d0 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php @@ -36,9 +36,10 @@ class DeleteByPathTest extends \PHPUnit\Framework\TestCase */ public static function setUpBeforeClass() { - self::$_mediaPath = Bootstrap::getObjectManager()->get(Filesystem::class) - ->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath(); - mkdir(self::$_mediaPath . self::TEST_DIRECTORY_NAME); + /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $directory */ + $directory = Bootstrap::getObjectManager()->get(Filesystem::class)->getDirectoryWrite(DirectoryList::MEDIA); + self::$_mediaPath = $directory->getAbsolutePath(); + $directory->create(self::TEST_DIRECTORY_NAME); } /** @@ -80,4 +81,18 @@ public function testDeleteDirectoryThatIsNotAllowed(): void { $this->deleteByPath->execute('theme'); } + + /** + * @throws \Magento\Framework\Exception\FileSystemException + */ + public static function tearDownAfterClass() + { + $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Framework\Filesystem::class); + /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $directory */ + $directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); + if ($directory->isExist(self::TEST_DIRECTORY_NAME)) { + $directory->delete(self::TEST_DIRECTORY_NAME); + } + } } diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/File/Command/DeleteByAssertIdTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/File/Command/DeleteByAssertIdTest.php new file mode 100644 index 0000000000000..7eb0d7a886e92 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/File/Command/DeleteByAssertIdTest.php @@ -0,0 +1,99 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + * + */ +namespace Magento\MediaGallery\Model\Directory\Command; + +use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Filesystem; +use Magento\MediaGallery\Model\File\Command\DeleteByAssetId; +use Magento\MediaGalleryApi\Model\File\Command\DeleteByAssetIdInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\MediaGalleryApi\Model\Asset\Command\GetByIdInterface; + +/** + * Test methods of class DeleteByPath + */ +class DeleteByAssertIdTest extends \PHPUnit\Framework\TestCase +{ + /** + * Test directory name + */ + private CONST TEST_DIRECTORY_NAME = 'testDirectory'; + + /** + * Absolute path to the media direcrory + */ + private static $_mediaPath; + + /** + * @var DeleteByAssetId + */ + private $deleteByAssetId; + + /** + * @inheritdoc + */ + public static function setUpBeforeClass() + { + /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $directory */ + $directory = Bootstrap::getObjectManager()->get(Filesystem::class)->getDirectoryWrite(DirectoryList::MEDIA); + self::$_mediaPath = $directory->getAbsolutePath(); + $directory->create(self::TEST_DIRECTORY_NAME); + $directory->touch(self::TEST_DIRECTORY_NAME . '/path.jpg'); + } + + /** + * @inheritdoc + */ + public function setUp() + { + $this->deleteByAssetId = Bootstrap::getObjectManager()->create(DeleteByAssetIdInterface::class); + } + + /** + * @magentoDataFixture Magento/MediaGallery/_files/media_asset.php + * @return void + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function testDeleteByAssetIdWithExistingAsset(): void + { + $fullPath = self::$_mediaPath . self::TEST_DIRECTORY_NAME . '/path.jpg'; + $getById = Bootstrap::getObjectManager()->get(GetByIdInterface::class); + $this->assertFileExists($fullPath); + $this->assertEquals(1, $getById->execute(1)->getId()); + $this->deleteByAssetId->execute(1); + $this->assertFileNotExists($fullPath); + $this->expectException(\Magento\Framework\Exception\NoSuchEntityException::class); + $getById->execute(1); + } + + /** + * @magentoDataFixture Magento/MediaGallery/_files/media_asset.php + * @return void + * @throws \Magento\Framework\Exception\LocalizedException + * @expectedException \Magento\Framework\Exception\LocalizedException + */ + public function testDeleteByAssetIdWithoutAsset(): void + { + $fullPath = self::$_mediaPath . self::TEST_DIRECTORY_NAME . '/path.jpg'; + $this->assertFileNotExists($fullPath); + $this->deleteByAssetId->execute(1); + } + + /** + * @throws \Magento\Framework\Exception\FileSystemException + */ + public static function tearDownAfterClass() + { + $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->get(\Magento\Framework\Filesystem::class); + /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $directory */ + $directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); + if ($directory->isExist(self::TEST_DIRECTORY_NAME)) { + $directory->delete(self::TEST_DIRECTORY_NAME); + } + } +} diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php new file mode 100644 index 0000000000000..c0a6691e54852 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php @@ -0,0 +1,29 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +use Magento\MediaGalleryApi\Api\Data\AssetInterface; +use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory; +use Magento\MediaGalleryApi\Model\Asset\Command\SaveInterface; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +/** @var AssetInterfaceFactory $mediaAssetFactory */ +$mediaAssetFactory = $objectManager->get(AssetInterfaceFactory::class); +/** @var AssetInterface $mediaAsset */ +$mediaAsset = $mediaAssetFactory->create( + [ + 'data' => [ + 'id' => 1, + 'path' => 'testDirectory/path.jpg' + ] + ] +); +/** @var SaveInterface $mediaSave */ +$mediaSave = $objectManager->get(SaveInterface::class); +$mediaId = $mediaSave->execute($mediaAsset); + From 3784f92befdc78d8db72f3a9755948bf63f6f921 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Fri, 3 Apr 2020 14:12:20 +0100 Subject: [PATCH 055/177] magento/magento2#27499: Removed DataExtractor in favour to DataObjectProcessor --- .../MediaGallery/Model/Asset/Command/Save.php | 17 +- .../MediaGallery/Model/DataExtractor.php | 48 ------ .../Unit/Model/Asset/Command/SaveTest.php | 21 +-- .../Test/Unit/Model/DataExtractorTest.php | 161 ------------------ app/code/Magento/MediaGallery/etc/di.xml | 2 - .../Model/DataExtractorInterface.php | 24 --- 6 files changed, 21 insertions(+), 252 deletions(-) delete mode 100644 app/code/Magento/MediaGallery/Model/DataExtractor.php delete mode 100644 app/code/Magento/MediaGallery/Test/Unit/Model/DataExtractorTest.php delete mode 100644 app/code/Magento/MediaGalleryApi/Model/DataExtractorInterface.php diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php index 7cb2f73169642..e017c4c58eb63 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php @@ -7,11 +7,11 @@ namespace Magento\MediaGallery\Model\Asset\Command; -use Magento\MediaGalleryApi\Model\DataExtractorInterface; use Magento\MediaGalleryApi\Api\Data\AssetInterface; use Magento\MediaGalleryApi\Model\Asset\Command\SaveInterface; use Magento\Framework\App\ResourceConnection; use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Reflection\DataObjectProcessor; use Psr\Log\LoggerInterface; /** @@ -27,9 +27,9 @@ class Save implements SaveInterface private $resourceConnection; /** - * @var DataExtractorInterface + * @var DataObjectProcessor */ - private $extractor; + private $objectProcessor; /** * @var LoggerInterface @@ -40,16 +40,16 @@ class Save implements SaveInterface * Save constructor. * * @param ResourceConnection $resourceConnection - * @param DataExtractorInterface $extractor + * @param DataObjectProcessor $objectProcessor * @param LoggerInterface $logger */ public function __construct( ResourceConnection $resourceConnection, - DataExtractorInterface $extractor, + DataObjectProcessor $objectProcessor, LoggerInterface $logger ) { $this->resourceConnection = $resourceConnection; - $this->extractor = $extractor; + $this->objectProcessor = $objectProcessor; $this->logger = $logger; } @@ -68,7 +68,10 @@ public function execute(AssetInterface $mediaAsset): int $connection = $this->resourceConnection->getConnection(); $tableName = $this->resourceConnection->getTableName(self::TABLE_MEDIA_GALLERY_ASSET); - $connection->insertOnDuplicate($tableName, $this->extractor->extract($mediaAsset, AssetInterface::class)); + $connection->insertOnDuplicate( + $tableName, + array_filter($this->objectProcessor->buildOutputDataArray($mediaAsset, AssetInterface::class)) + ); return (int) $connection->lastInsertId($tableName); } catch (\Exception $exception) { $this->logger->critical($exception); diff --git a/app/code/Magento/MediaGallery/Model/DataExtractor.php b/app/code/Magento/MediaGallery/Model/DataExtractor.php deleted file mode 100644 index 92cf237022c28..0000000000000 --- a/app/code/Magento/MediaGallery/Model/DataExtractor.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaGallery\Model; - -use Magento\MediaGalleryApi\Model\DataExtractorInterface; - -/** - * Extract data from an object using available getters - */ -class DataExtractor implements DataExtractorInterface -{ - /** - * Extract data from an object using available getters (does not process extension attributes) - * - * @param object $object - * @param string|null $interface - * - * @return array - * @throws \ReflectionException - */ - public function extract($object, string $interface = null): array - { - $data = []; - - $reflectionClass = new \ReflectionClass($interface ?? $object); - - foreach ($reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) { - $methodName = $method->getName(); - if (strpos($methodName, 'get') !== 0 - || !empty($method->getParameters()) - || strpos($methodName, 'getExtensionAttributes') !== false - ) { - continue; - } - $value = $object->$methodName(); - if (!empty($value)) { - $key = strtolower(preg_replace("/([a-z])([A-Z])/", "$1_$2", substr($methodName, 3))); - $data[$key] = $value; - } - } - return $data; - } -} diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php index 2f736fb832eac..8af26f0c64b16 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php @@ -7,9 +7,9 @@ namespace Magento\MediaGallery\Test\Unit\Model\Asset\Command; +use Magento\Eav\Helper\Data; use Magento\MediaGallery\Model\Asset\Command\Save; use Magento\MediaGalleryApi\Api\Data\AssetInterface; -use Magento\MediaGalleryApi\Model\DataExtractorInterface; use Magento\Framework\App\ResourceConnection; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\DB\Adapter\Pdo\Mysql; @@ -17,6 +17,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +use Magento\Framework\Reflection\DataObjectProcessor; use Psr\Log\LoggerInterface; /** @@ -63,14 +64,14 @@ class SaveTest extends TestCase private $resourceConnectionMock; /** - * @var MockObject | DataExtractorInterface + * @var MockObject | LoggerInterface */ private $loggerMock; /** - * @var MockObject | LoggerInterface + * @var MockObject | DataObjectProcessor */ - private $extractorMock; + private $objectProcessor; /** * @var MockObject | AdapterInterface @@ -97,7 +98,7 @@ protected function setUp(): void $this->mediaAssetMock = $this->createMock(AssetInterface::class); /* Save constructor mocks */ - $this->extractorMock = $this->createMock(DataExtractorInterface::class); + $this->objectProcessor = $this->createMock(DataObjectProcessor::class); $this->loggerMock = $this->createMock(LoggerInterface::class); $this->resourceConnectionMock = $this->createConfiguredMock( ResourceConnection::class, @@ -112,7 +113,7 @@ protected function setUp(): void Save::class, [ 'resourceConnection' => $this->resourceConnectionMock, - 'extractor' => $this->extractorMock, + 'objectProcessor' => $this->objectProcessor, 'logger' => $this->loggerMock ] ); @@ -126,9 +127,9 @@ public function testSuccessfulExecute(): void $this->resourceConnectionMock->expects(self::once())->method('getConnection'); $this->resourceConnectionMock->expects(self::once())->method('getTableName'); - $this->extractorMock + $this->objectProcessor ->expects(self::once()) - ->method('extract') + ->method('buildOutputDataArray') ->with($this->mediaAssetMock, AssetInterface::class) ->willReturn(self::IMAGE_DATA); @@ -155,9 +156,9 @@ public function testExceptionExecute(): void $this->resourceConnectionMock->expects(self::once())->method('getConnection'); $this->resourceConnectionMock->expects(self::once())->method('getTableName'); - $this->extractorMock + $this->objectProcessor ->expects(self::once()) - ->method('extract') + ->method('buildOutputDataArray') ->with($this->mediaAssetMock, AssetInterface::class) ->willReturn(self::IMAGE_DATA); diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/DataExtractorTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/DataExtractorTest.php deleted file mode 100644 index f70e4ccdae22c..0000000000000 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/DataExtractorTest.php +++ /dev/null @@ -1,161 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaGallery\Test\Unit\Model; - -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\MediaGallery\Model\Asset; -use Magento\MediaGallery\Model\DataExtractor; -use Magento\MediaGallery\Model\Keyword; -use Magento\MediaGalleryApi\Api\Data\AssetInterface; -use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; - -class DataExtractorTest extends TestCase -{ - /** - * @var DataExtractor|MockObject - */ - private $dataExtractor; - - /** - * Initialize basic test class mocks - */ - protected function setUp(): void - { - $this->dataExtractor = new DataExtractor(); - } - - /** - * Test extract object data by interface - * - * @dataProvider assetProvider - * - * @param string $class - * @param string|null $interfaceClass - * @param array $expectedData - * - * @throws \ReflectionException - */ - public function testExtractData(string $class, $interfaceClass, array $expectedData): void - { - $data = []; - foreach ($expectedData as $expectedDataKey => $expectedDataItem) { - $data[$expectedDataKey] = $expectedDataItem['value']; - } - $model = (new ObjectManager($this))->getObject( - $class, - [ - 'data' => $data, - ] - ); - if ($interfaceClass) { - $receivedData = $this->dataExtractor->extract($model, $interfaceClass); - $this->checkAssetValues($expectedData, $receivedData, $model); - } else { - $receivedData = $this->dataExtractor->extract($model); - $this->checkKeyWordValues($expectedData, $receivedData, $model); - } - } - - /** - * @param array $expectedData - * @param array $data - * @param object $model - */ - private function checkAssetValues(array $expectedData, array $data, $model) - { - foreach ($expectedData as $expectedDataKey => $expectedDataItem) { - $this->assertEquals($data[$expectedDataKey] ?? null, $model->{$expectedDataItem['method']}()); - $this->assertEquals($data[$expectedDataKey] ?? null, $expectedDataItem['value']); - } - $this->assertEquals(array_keys($expectedData), array_keys($data)); - } - - /** - * @param array $expectedData - * @param array $data - * @param object $model - */ - private function checkKeyWordValues(array $expectedData, array $data, $model) - { - foreach ($expectedData as $expectedDataKey => $expectedDataItem) { - $this->assertEquals($data[$expectedDataKey] ?? null, $model->{$expectedDataItem['method']}()); - $this->assertEquals($data[$expectedDataKey] ?? null, $expectedDataItem['value']); - } - $this->assertEquals(array_keys($expectedData), array_keys(array_slice($data, 0, 2))); - } - - /** - * @return array - */ - public function assetProvider() - { - return [ - 'Asset conversion with interface' => [ - Asset::class, - AssetInterface::class, - [ - 'id' => [ - 'value' => 2, - 'method' => 'getId', - ], - 'path' => [ - 'value' => 'path', - 'method' => 'getPath', - ], - 'title' => [ - 'value' => 'title', - 'method' => 'getTitle', - ], - 'source' => [ - 'value' => 'source', - 'method' => 'getSource', - ], - 'content_type' => [ - 'value' => 'content_type', - 'method' => 'getContentType', - ], - 'height' => [ - 'value' => 4, - 'method' => 'getHeight', - ], - 'width' => [ - 'value' => 3, - 'method' => 'getWidth', - ], - 'size' => [ - 'value' => 300, - 'method' => 'getSize', - ], - 'created_at' => [ - 'value' => '2019-11-28 10:40:09', - 'method' => 'getCreatedAt', - ], - 'updated_at' => [ - 'value' => '2019-11-28 10:41:08', - 'method' => 'getUpdatedAt', - ], - ], - ], - 'Keyword conversion without interface' => [ - Keyword::class, - '', - [ - 'id' => [ - 'value' => 2, - 'method' => 'getId', - ], - 'keyword' => [ - 'value' => 'keyword', - 'method' => 'getKeyword', - ], - ], - ] - ]; - } -} diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index ea05da9498607..c993d82342326 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -19,8 +19,6 @@ <preference for="Magento\MediaGalleryApi\Model\Keyword\Command\SaveAssetKeywordsInterface" type="Magento\MediaGallery\Model\Keyword\Command\SaveAssetKeywords"/> <preference for="Magento\MediaGalleryApi\Model\Keyword\Command\SaveAssetLinksInterface" type="Magento\MediaGallery\Model\Keyword\Command\SaveAssetLinks"/> - <preference for="Magento\MediaGalleryApi\Model\DataExtractorInterface" type="Magento\MediaGallery\Model\DataExtractor"/> - <preference for="Magento\MediaGalleryApi\Model\Directory\Command\CreateByPathInterface" type="Magento\MediaGallery\Model\Directory\Command\CreateByPath"/> <preference for="Magento\MediaGalleryApi\Model\Directory\Command\DeleteByPathInterface" type="Magento\MediaGallery\Model\Directory\Command\DeleteByPath"/> diff --git a/app/code/Magento/MediaGalleryApi/Model/DataExtractorInterface.php b/app/code/Magento/MediaGalleryApi/Model/DataExtractorInterface.php deleted file mode 100644 index 33fd2425edc6f..0000000000000 --- a/app/code/Magento/MediaGalleryApi/Model/DataExtractorInterface.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\MediaGalleryApi\Model; - -/** - * Extract data from an object using available getters - * @api - */ -interface DataExtractorInterface -{ - /** - * Extract data from an object using available getters (does not process extension attributes) - * - * @param object $object - * @param string|null $interface - * @return array - */ - public function extract($object, string $interface = null): array; -} From b77e66d290f0ffc800f3725817cfdf6a18cef615 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Fri, 3 Apr 2020 14:23:27 +0100 Subject: [PATCH 056/177] magento/magento2#27499: Code review changes --- .../MediaGallery/Model/Asset/Command/GetByPath.php | 8 ++++---- .../Magento/MediaGalleryApi/Api/Data/AssetInterface.php | 2 +- .../Model/Asset/Command/GetByPathInterface.php | 4 ++-- .../MediaGalleryApi/Model/Asset/Command/SaveInterface.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php b/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php index fe5fcca6cb0de..32c7323c3a511 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php @@ -59,22 +59,22 @@ public function __construct( /** * Return media asset asset list * - * @param string $mediaFilePath + * @param string $path * * @return AssetInterface * @throws IntegrationException */ - public function execute(string $mediaFilePath): AssetInterface + public function execute(string $path): AssetInterface { try { $connection = $this->resourceConnection->getConnection(); $select = $connection->select() ->from($this->resourceConnection->getTableName(self::TABLE_MEDIA_GALLERY_ASSET)) - ->where(self::MEDIA_GALLERY_ASSET_PATH . ' = ?', $mediaFilePath); + ->where(self::MEDIA_GALLERY_ASSET_PATH . ' = ?', $path); $data = $connection->query($select)->fetch(); if (empty($data)) { - $message = __('There is no such media asset with path "%1"', $mediaFilePath); + $message = __('There is no such media asset with path "%1"', $path); throw new NoSuchEntityException($message); } diff --git a/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php b/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php index 7cd94f90a60a0..c3454400b2995 100644 --- a/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php @@ -39,7 +39,7 @@ public function getPath(): string; public function getTitle(): ?string; /** - * Get source of the file + * Get the name of the channel/stock/integration file was retrieved from. null if not identified. * * @return string|null */ diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php index 9d39b5cc692f3..aa3f76f721374 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php @@ -17,8 +17,8 @@ interface GetByPathInterface /** * Get media asset list * - * @param string $mediaFilePath + * @param string $path * @return \Magento\MediaGalleryApi\Api\Data\AssetInterface */ - public function execute(string $mediaFilePath): \Magento\MediaGalleryApi\Api\Data\AssetInterface; + public function execute(string $path): \Magento\MediaGalleryApi\Api\Data\AssetInterface; } diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php index 6d2aae21754b8..77f8fcf8b2c2e 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php @@ -17,7 +17,7 @@ interface SaveInterface { /** - * Save media asset + * Save media asset and return the media asset id * * @param \Magento\MediaGalleryApi\Api\Data\AssetInterface $mediaAsset * @return int From 0d887662aa0e81a40c44a354d3e3a1abaf91fb29 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk <grp-engcom-vendorworker-Kilo@adobe.com> Date: Fri, 3 Apr 2020 16:26:04 +0300 Subject: [PATCH 057/177] Format code. --- app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php b/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php index 7430213030f96..8ab8cbfb6122b 100644 --- a/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php +++ b/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php @@ -133,7 +133,7 @@ public function testScheduledGenerateSitemapsSendsExceptionEmail() $this->emailNotificationMock->expects($this->once()) ->method('sendErrors') - ->with(['Sitemap Exception']); + ->with([$exception]); $this->observer->scheduledGenerateSitemaps(); } From e66c9a906fa262f2e9a6c4de8c63ad603a7f8c86 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Fri, 3 Apr 2020 10:54:38 -0500 Subject: [PATCH 058/177] magento/magento2#27536: Remove dependency to the MediaGallery module --- ...MediaGalleryAssetDeleteByDirectoryPath.php | 84 +++++++++++++++++++ .../Plugin/MediaGalleryAssetDeleteByPath.php | 84 +++++++++++++++++++ app/code/Magento/MediaContent/composer.json | 3 +- .../Magento/MediaContent/etc/db_schema.xml | 1 - app/code/Magento/MediaContent/etc/di.xml | 6 ++ .../Api/AssignAssetInterface.php | 2 + .../Api/GetContentWithAssetInterface.php | 2 + .../Api/UnassignAssetInterface.php | 2 + 8 files changed, 181 insertions(+), 3 deletions(-) create mode 100644 app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php create mode 100644 app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByPath.php diff --git a/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php b/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php new file mode 100644 index 0000000000000..569798be356ca --- /dev/null +++ b/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php @@ -0,0 +1,84 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\MediaContent\Model\Plugin; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\MediaGalleryApi\Model\Asset\Command\DeleteByDirectoryPathInterface; +use Psr\Log\LoggerInterface; + +/** + * Remove media content record after media gallery asset removal. + */ +class MediaGalleryAssetDeleteByDirectoryPath +{ + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * DeleteById constructor. + * + * @param ResourceConnection $resourceConnection + * @param LoggerInterface $logger + */ + public function __construct( + ResourceConnection $resourceConnection, + LoggerInterface $logger + ) { + $this->resourceConnection = $resourceConnection; + $this->logger = $logger; + } + + /** + * @param DeleteByDirectoryPathInterface $subject + * @param \Closure $proceed + * @param string $directoryPath + * @throws CouldNotDeleteException + * @return void + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundExecute( + DeleteByDirectoryPathInterface $subject, + \Closure $proceed, + string $directoryPath + ) : void { + /** @var AdapterInterface $connection */ + $connection = $this->resourceConnection->getConnection(); + $galleryAssetTableName = $this->resourceConnection->getTableName('media_gallery_asset'); + $mediaContentAssetTableName = $this->resourceConnection->getTableName('media_content_asset'); + + $select = $connection->select(); + $select->from($galleryAssetTableName, ['id']); + $select->where('path LIKE ?', $directoryPath); + $galleryAssetIds = $connection->fetchCol($select); + + $proceed(); + + try { + $connection->delete( + $mediaContentAssetTableName, + ['asset_id IN(?)' => implode(', ', $galleryAssetIds)] + ); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $message = __( + 'Could not delete media content assets for media gallery asset with path %path: %error', + ['path' => $directoryPath, 'error' => $exception->getMessage()] + ); + throw new CouldNotDeleteException($message, $exception); + } + } +} diff --git a/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByPath.php b/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByPath.php new file mode 100644 index 0000000000000..b5bf39cb70b69 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByPath.php @@ -0,0 +1,84 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\MediaContent\Model\Plugin; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface; +use Psr\Log\LoggerInterface; + +/** + * Remove media content record after media gallery asset removal. + */ +class MediaGalleryAssetDeleteByPath +{ + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * DeleteById constructor. + * + * @param ResourceConnection $resourceConnection + * @param LoggerInterface $logger + */ + public function __construct( + ResourceConnection $resourceConnection, + LoggerInterface $logger + ) { + $this->resourceConnection = $resourceConnection; + $this->logger = $logger; + } + + /** + * @param DeleteByPathInterface $subject + * @param \Closure $proceed + * @param string $mediaAssetPath + * @throws CouldNotDeleteException + * @return void + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function aroundExecute( + DeleteByPathInterface $subject, + \Closure $proceed, + string $mediaAssetPath + ) : void { + /** @var AdapterInterface $connection */ + $connection = $this->resourceConnection->getConnection(); + $galleryAssetTableName = $this->resourceConnection->getTableName('media_gallery_asset'); + $mediaContentAssetTableName = $this->resourceConnection->getTableName('media_content_asset'); + + $select = $connection->select(); + $select->from($galleryAssetTableName, ['id']); + $select->where('path = ?', $mediaAssetPath); + $galleryAssetIds = $connection->fetchCol($select); + + $proceed(); + + try { + $connection->delete( + $mediaContentAssetTableName, + ['asset_id IN(?)' => implode(', ', $galleryAssetIds)] + ); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $message = __( + 'Could not delete media content assets for media gallery asset with path %path: %error', + ['path' => $mediaAssetPath, 'error' => $exception->getMessage()] + ); + throw new CouldNotDeleteException($message, $exception); + } + } +} diff --git a/app/code/Magento/MediaContent/composer.json b/app/code/Magento/MediaContent/composer.json index e14c0fc1aeadd..6734c1a300810 100644 --- a/app/code/Magento/MediaContent/composer.json +++ b/app/code/Magento/MediaContent/composer.json @@ -5,8 +5,7 @@ "php": "~7.1.3||~7.2.0||~7.3.0", "magento/framework": "*", "magento/module-media-content-api": "*", - "magento/module-media-gallery-api": "*", - "magento/module-media-gallery": "*" + "magento/module-media-gallery-api": "*" }, "type": "magento2-module", "license": [ diff --git a/app/code/Magento/MediaContent/etc/db_schema.xml b/app/code/Magento/MediaContent/etc/db_schema.xml index 25c4b50098085..2cd917070cf0b 100644 --- a/app/code/Magento/MediaContent/etc/db_schema.xml +++ b/app/code/Magento/MediaContent/etc/db_schema.xml @@ -16,6 +16,5 @@ <column name="type"/> <column name="field"/> </constraint> - <constraint xsi:type="foreign" referenceId="MEDIA_CONTENT_ASSET_ID_MEDIA_GALLERY_ASSET_ID" table="media_content_asset" column="asset_id" referenceTable="media_gallery_asset" referenceColumn="id" onDelete="CASCADE"/> </table> </schema> diff --git a/app/code/Magento/MediaContent/etc/di.xml b/app/code/Magento/MediaContent/etc/di.xml index 98031f32211d4..15fa68bce99a0 100644 --- a/app/code/Magento/MediaContent/etc/di.xml +++ b/app/code/Magento/MediaContent/etc/di.xml @@ -12,4 +12,10 @@ <preference for="Magento\MediaContentApi\Api\GetContentWithAssetInterface" type="Magento\MediaContent\Model\GetContentWithAsset"/> <preference for="Magento\MediaContentApi\Api\ExtractAssetFromContentInterface" type="Magento\MediaContentApi\Model\ExtractAssetFromContent"/> <preference for="Magento\MediaContentApi\Api\UpdateRelationsInterface" type="Magento\MediaContent\Model\UpdateRelations"/> + <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface"> + <plugin name="remove_media_content_after_asset_is_removed_by_path" type="Magento\MediaContent\Model\Plugin\MediaGalleryAssetDeleteByPath" /> + </type> + <type name="\Magento\MediaGalleryApi\Model\Asset\Command\DeleteByDirectoryPathInterface"> + <plugin name="remove_media_content_after_asset_is_removed_by_directory_path" type="Magento\MediaContent\Model\Plugin\MediaGalleryAssetDeleteByDirectoryPath" /> + </type> </config> diff --git a/app/code/Magento/MediaContentApi/Api/AssignAssetInterface.php b/app/code/Magento/MediaContentApi/Api/AssignAssetInterface.php index ebe0968cc57f5..a0436b57e01af 100644 --- a/app/code/Magento/MediaContentApi/Api/AssignAssetInterface.php +++ b/app/code/Magento/MediaContentApi/Api/AssignAssetInterface.php @@ -15,6 +15,8 @@ interface AssignAssetInterface { /** + * Save relation between media asset and media content. + * * @param int $assetId * @param string $contentType * @param string $contentEntityId diff --git a/app/code/Magento/MediaContentApi/Api/GetContentWithAssetInterface.php b/app/code/Magento/MediaContentApi/Api/GetContentWithAssetInterface.php index a10cc4a476426..ab8347098da82 100644 --- a/app/code/Magento/MediaContentApi/Api/GetContentWithAssetInterface.php +++ b/app/code/Magento/MediaContentApi/Api/GetContentWithAssetInterface.php @@ -15,6 +15,8 @@ interface GetContentWithAssetInterface { /** + * Get media asset to content relation by media asset id. + * * @param int $assetId * * @return array diff --git a/app/code/Magento/MediaContentApi/Api/UnassignAssetInterface.php b/app/code/Magento/MediaContentApi/Api/UnassignAssetInterface.php index 502fb738c8d00..831275de8a78e 100644 --- a/app/code/Magento/MediaContentApi/Api/UnassignAssetInterface.php +++ b/app/code/Magento/MediaContentApi/Api/UnassignAssetInterface.php @@ -15,6 +15,8 @@ interface UnassignAssetInterface { /** + * Remove relation between the media asset and media content. + * * @param int $assetId * @param string $contentType * @param string $contentEntityId From d5cdd0b4da6c7b2cb06f6f7b7ca681ec277a3a38 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Fri, 3 Apr 2020 21:53:49 +0100 Subject: [PATCH 059/177] magento/magento2#27536: Introduced ContentIdentity --- app/code/Magento/Cms/etc/module.xml | 2 - .../{AssignAsset.php => AssignAssets.php} | 28 ++++---- .../MediaContent/Model/ContentIdentity.php | 45 ++++++++++++ ...ntent.php => GetAssetIdsUsedInContent.php} | 28 ++++---- ...WithAsset.php => GetContentWithAssets.php} | 36 +++++++--- .../{UnassignAsset.php => UnassignAssets.php} | 22 +++--- .../MediaContent/Model/UpdateRelations.php | 63 ++++++++--------- ...signAssetTest.php => AssignAssetsTest.php} | 68 +++++++++++++------ .../Unit/Model/GetAssetsusedInContentTest.php | 68 ++++++++++--------- ...tTest.php => GetContentWithAssetsTest.php} | 57 +++++++++------- .../Test/Unit/Model/UnassignAssetTest.php | 68 +++++++++++++------ .../MediaContent/etc/db_schema_whitelist.json | 3 +- app/code/Magento/MediaContent/etc/di.xml | 13 ++-- app/code/Magento/MediaContent/etc/module.xml | 6 +- ...nterface.php => AssignAssetsInterface.php} | 13 ++-- .../Api/Data/ContentIdentityInterface.php | 37 ++++++++++ ... => ExtractAssetsFromContentInterface.php} | 2 +- ... => GetAssetIdsUsedInContentInterface.php} | 11 ++- ....php => GetContentWithAssetsInterface.php} | 13 ++-- ...erface.php => UnassignAssetsInterface.php} | 13 ++-- .../Api/UpdateRelationsInterface.php | 18 ++--- ...ntent.php => ExtractAssetsFromContent.php} | 4 +- .../MediaContentCatalog/Observer/Category.php | 35 +++++++--- .../MediaContentCatalog/Observer/Product.php | 34 +++++++--- .../Magento/MediaContentCatalog/etc/di.xml | 2 +- .../MediaContentCms/Observer/Block.php | 35 +++++++--- .../Magento/MediaContentCms/Observer/Page.php | 35 +++++++--- app/code/Magento/MediaContentCms/etc/di.xml | 2 +- 28 files changed, 494 insertions(+), 267 deletions(-) rename app/code/Magento/MediaContent/Model/{AssignAsset.php => AssignAssets.php} (68%) create mode 100644 app/code/Magento/MediaContent/Model/ContentIdentity.php rename app/code/Magento/MediaContent/Model/{GetAssetsUsedInContent.php => GetAssetIdsUsedInContent.php} (71%) rename app/code/Magento/MediaContent/Model/{GetContentWithAsset.php => GetContentWithAssets.php} (52%) rename app/code/Magento/MediaContent/Model/{UnassignAsset.php => UnassignAssets.php} (67%) rename app/code/Magento/MediaContent/Test/Unit/Model/{AssignAssetTest.php => AssignAssetsTest.php} (70%) rename app/code/Magento/MediaContent/Test/Unit/Model/{GetContentWithAssetTest.php => GetContentWithAssetsTest.php} (62%) rename app/code/Magento/MediaContentApi/Api/{AssignAssetInterface.php => AssignAssetsInterface.php} (59%) create mode 100644 app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php rename app/code/Magento/MediaContentApi/Api/{ExtractAssetFromContentInterface.php => ExtractAssetsFromContentInterface.php} (92%) rename app/code/Magento/MediaContentApi/Api/{GetAssetsUsedInContentInterface.php => GetAssetIdsUsedInContentInterface.php} (57%) rename app/code/Magento/MediaContentApi/Api/{GetContentWithAssetInterface.php => GetContentWithAssetsInterface.php} (54%) rename app/code/Magento/MediaContentApi/Api/{UnassignAssetInterface.php => UnassignAssetsInterface.php} (60%) rename app/code/Magento/MediaContentApi/Model/{ExtractAssetFromContent.php => ExtractAssetsFromContent.php} (94%) diff --git a/app/code/Magento/Cms/etc/module.xml b/app/code/Magento/Cms/etc/module.xml index 880ce5b7075e6..d3fc2846217d9 100644 --- a/app/code/Magento/Cms/etc/module.xml +++ b/app/code/Magento/Cms/etc/module.xml @@ -11,8 +11,6 @@ <module name="Magento_Store"/> <module name="Magento_Theme"/> <module name="Magento_Variable"/> - <module name="Magento_MediaContent"/> - <module name="Magento_MediaContentApi"/> </sequence> </module> </config> diff --git a/app/code/Magento/MediaContent/Model/AssignAsset.php b/app/code/Magento/MediaContent/Model/AssignAssets.php similarity index 68% rename from app/code/Magento/MediaContent/Model/AssignAsset.php rename to app/code/Magento/MediaContent/Model/AssignAssets.php index ada7e9adf20ef..7184e8b9914fa 100644 --- a/app/code/Magento/MediaContent/Model/AssignAsset.php +++ b/app/code/Magento/MediaContent/Model/AssignAssets.php @@ -9,13 +9,14 @@ use Magento\Framework\App\ResourceConnection; use Magento\Framework\Exception\CouldNotSaveException; -use Magento\MediaContentApi\Api\AssignAssetInterface; +use Magento\MediaContentApi\Api\AssignAssetsInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; use Psr\Log\LoggerInterface; /** * Used for saving relation between the media asset and media content where the media asset is used */ -class AssignAsset implements AssignAssetInterface +class AssignAssets implements AssignAssetsInterface { private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; private const ASSET_ID = 'asset_id'; @@ -34,8 +35,6 @@ class AssignAsset implements AssignAssetInterface private $logger; /** - * AssignAsset constructor. - * * @param ResourceConnection $resourceConnection * @param LoggerInterface $logger */ @@ -46,20 +45,23 @@ public function __construct(ResourceConnection $resourceConnection, LoggerInterf } /** - * @inheritDoc + * @inheritdoc */ - public function execute(int $assetId, string $contentType, string $contentEntityId, string $contentField): void + public function execute(ContentIdentityInterface $contentIdentity, array $assetIds): void { try { $connection = $this->resourceConnection->getConnection(); $tableName = $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME); - $saveData = [ - self::ASSET_ID => $assetId, - self::TYPE => $contentType, - self::ENTITY_ID => $contentEntityId, - self::FIELD => $contentField - ]; - $connection->insert($tableName, $saveData); + $data = []; + foreach ($assetIds as $assetId) { + $data[] = [ + self::ASSET_ID => $assetId, + self::TYPE => $contentIdentity->getEntityType(), + self::ENTITY_ID => $contentIdentity->getEntityId(), + self::FIELD => $contentIdentity->getField() + ]; + } + $connection->insertMultiple($tableName, $data); } catch (\Exception $exception) { $this->logger->critical($exception); $message = __('An error occurred while saving relation between media asset and media content.'); diff --git a/app/code/Magento/MediaContent/Model/ContentIdentity.php b/app/code/Magento/MediaContent/Model/ContentIdentity.php new file mode 100644 index 0000000000000..2af8dd043680d --- /dev/null +++ b/app/code/Magento/MediaContent/Model/ContentIdentity.php @@ -0,0 +1,45 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\Framework\Model\AbstractExtensibleModel; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; + +/** + * @inheritdoc + */ +class ContentIdentity extends AbstractExtensibleModel implements ContentIdentityInterface +{ + private const TYPE = 'entity_type'; + private const ENTITY_ID = 'entity_id'; + private const FIELD = 'field'; + + /** + * @inheritdoc + */ + public function getEntityType(): string + { + return (string) $this->getData(self::TYPE); + } + + /** + * @inheritdoc + */ + public function getEntityId(): string + { + return (string) $this->getData(self::ENTITY_ID); + } + + /** + * @inheritdoc + */ + public function getField(): string + { + return (string) $this->getData(self::FIELD); + } +} diff --git a/app/code/Magento/MediaContent/Model/GetAssetsUsedInContent.php b/app/code/Magento/MediaContent/Model/GetAssetIdsUsedInContent.php similarity index 71% rename from app/code/Magento/MediaContent/Model/GetAssetsUsedInContent.php rename to app/code/Magento/MediaContent/Model/GetAssetIdsUsedInContent.php index 2baa022713d8f..4da0898525887 100644 --- a/app/code/Magento/MediaContent/Model/GetAssetsUsedInContent.php +++ b/app/code/Magento/MediaContent/Model/GetAssetIdsUsedInContent.php @@ -9,13 +9,14 @@ use Magento\Framework\App\ResourceConnection; use Magento\Framework\Exception\IntegrationException; -use Magento\MediaContentApi\Api\GetAssetsUsedInContentInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; +use Magento\MediaContentApi\Api\GetAssetIdsUsedInContentInterface; use Psr\Log\LoggerInterface; /** * Used to return media asset id list which is used in the specified media content */ -class GetAssetsUsedInContent implements GetAssetsUsedInContentInterface +class GetAssetIdsUsedInContent implements GetAssetIdsUsedInContentInterface { private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; private const ASSET_ID = 'asset_id'; @@ -46,9 +47,9 @@ public function __construct(ResourceConnection $resourceConnection, LoggerInterf } /** - * @inheritDoc + * @inheritdoc */ - public function execute(string $contentType, string $contentEntityId = null, string $contentField = null): array + public function execute(ContentIdentityInterface $contentIdentity): array { try { $connection = $this->resourceConnection->getConnection(); @@ -56,15 +57,16 @@ public function execute(string $contentType, string $contentEntityId = null, str ->from( $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME), self::ASSET_ID - )->where(self::TYPE . ' = ?', $contentType); - - if (null !== $contentEntityId) { - $select = $select->where(self::ENTITY_ID . '= ?', $contentEntityId); - } - - if (null !== $contentField) { - $select = $select->where(self::FIELD . '= ?', $contentField); - } + )->where( + self::TYPE . ' = ?', + $contentIdentity->getEntityType() + )->where( + self::ENTITY_ID . '= ?', + $contentIdentity->getEntityId() + )->where( + self::FIELD . '= ?', + $contentIdentity->getField() + ); return $connection->fetchAssoc($select); } catch (\Exception $exception) { diff --git a/app/code/Magento/MediaContent/Model/GetContentWithAsset.php b/app/code/Magento/MediaContent/Model/GetContentWithAssets.php similarity index 52% rename from app/code/Magento/MediaContent/Model/GetContentWithAsset.php rename to app/code/Magento/MediaContent/Model/GetContentWithAssets.php index 796cc890b3845..8f014ee77e680 100644 --- a/app/code/Magento/MediaContent/Model/GetContentWithAsset.php +++ b/app/code/Magento/MediaContent/Model/GetContentWithAssets.php @@ -9,13 +9,14 @@ use Magento\Framework\App\ResourceConnection; use Magento\Framework\Exception\IntegrationException; -use Magento\MediaContentApi\Api\GetContentWithAssetInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory; +use Magento\MediaContentApi\Api\GetContentWithAssetsInterface; use Psr\Log\LoggerInterface; /** * Used to return media asset list for the specified asset. */ -class GetContentWithAsset implements GetContentWithAssetInterface +class GetContentWithAssets implements GetContentWithAssetsInterface { private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; private const ASSET_ID = 'asset_id'; @@ -31,13 +32,21 @@ class GetContentWithAsset implements GetContentWithAssetInterface private $logger; /** - * GetAssetsUsedInContent constructor. - * + * @var ContentIdentityInterfaceFactory + */ + private $factory; + + /** + * @param ContentIdentityInterfaceFactory $factory * @param ResourceConnection $resourceConnection * @param LoggerInterface $logger */ - public function __construct(ResourceConnection $resourceConnection, LoggerInterface $logger) - { + public function __construct( + ContentIdentityInterfaceFactory $factory, + ResourceConnection $resourceConnection, + LoggerInterface $logger + ) { + $this->factory = $factory; $this->resourceConnection = $resourceConnection; $this->logger = $logger; } @@ -45,19 +54,24 @@ public function __construct(ResourceConnection $resourceConnection, LoggerInterf /** * @inheritDoc */ - public function execute(int $assetId): array + public function execute(array $assetIds): array { try { $connection = $this->resourceConnection->getConnection(); $select = $connection->select() ->from($this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME)) - ->where(self::ASSET_ID . '= ?', $assetId); + ->where(self::ASSET_ID . 'IN (?)', $assetIds); - return $connection->fetchAssoc($select); + $contentIdentities = []; + foreach ($connection->fetchAssoc($select) as $contentIdentityData) { + $contentIdentities[] = $this->factory->create(['data' => $contentIdentityData]); + } + return $contentIdentities; } catch (\Exception $exception) { $this->logger->critical($exception); - $message = __('An error occurred at getting media asset to content relation by media asset id.'); - throw new IntegrationException($message); + throw new IntegrationException( + __('An error occurred at getting media asset to content relation by media asset id.') + ); } } } diff --git a/app/code/Magento/MediaContent/Model/UnassignAsset.php b/app/code/Magento/MediaContent/Model/UnassignAssets.php similarity index 67% rename from app/code/Magento/MediaContent/Model/UnassignAsset.php rename to app/code/Magento/MediaContent/Model/UnassignAssets.php index ae5924f662403..3236538ff181c 100644 --- a/app/code/Magento/MediaContent/Model/UnassignAsset.php +++ b/app/code/Magento/MediaContent/Model/UnassignAssets.php @@ -9,13 +9,14 @@ use Magento\Framework\App\ResourceConnection; use Magento\Framework\Exception\CouldNotDeleteException; -use Magento\MediaContentApi\Api\UnassignAssetInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; +use Magento\MediaContentApi\Api\UnassignAssetsInterface; use Psr\Log\LoggerInterface; /** * Used to unassign relation of the media asset to the media content where the media asset is used */ -class UnassignAsset implements UnassignAssetInterface +class UnassignAssets implements UnassignAssetsInterface { private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; private const ASSET_ID = 'asset_id'; @@ -46,9 +47,9 @@ public function __construct(ResourceConnection $resourceConnection, LoggerInterf } /** - * @inheritDoc + * @inheritdoc */ - public function execute(int $assetId, string $contentType, string $contentEntityId, string $contentField): void + public function execute(ContentIdentityInterface $contentIdentity, array $assetIds): void { try { $connection = $this->resourceConnection->getConnection(); @@ -56,16 +57,17 @@ public function execute(int $assetId, string $contentType, string $contentEntity $connection->delete( $tableName, [ - self::ASSET_ID . ' = ?' => $assetId, - self::TYPE . ' = ?' => $contentType, - self::ENTITY_ID . ' = ?' => $contentEntityId, - self::FIELD . ' = ?' => $contentField + self::ASSET_ID . ' IN (?)' => $assetIds, + self::TYPE . ' = ?' => $contentIdentity->getEntityType(), + self::ENTITY_ID . ' = ?' => $contentIdentity->getEntityId(), + self::FIELD . ' = ?' => $contentIdentity->getField() ] ); } catch (\Exception $exception) { $this->logger->critical($exception); - $message = __('An error occurred at unassign relation between the media asset and media content.'); - throw new CouldNotDeleteException($message); + throw new CouldNotDeleteException( + __('An error occurred at unassign relation between the media asset and media content.') + ); } } } diff --git a/app/code/Magento/MediaContent/Model/UpdateRelations.php b/app/code/Magento/MediaContent/Model/UpdateRelations.php index 1716739434591..c3ae928ead364 100644 --- a/app/code/Magento/MediaContent/Model/UpdateRelations.php +++ b/app/code/Magento/MediaContent/Model/UpdateRelations.php @@ -10,10 +10,11 @@ use Magento\Framework\Exception\CouldNotDeleteException; use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\Exception\IntegrationException; -use Magento\MediaContentApi\Api\AssignAssetInterface; -use Magento\MediaContentApi\Api\ExtractAssetFromContentInterface; -use Magento\MediaContentApi\Api\GetAssetsUsedInContentInterface; -use Magento\MediaContentApi\Api\UnassignAssetInterface; +use Magento\MediaContentApi\Api\AssignAssetsInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; +use Magento\MediaContentApi\Api\ExtractAssetsFromContentInterface; +use Magento\MediaContentApi\Api\GetAssetIdsUsedInContentInterface; +use Magento\MediaContentApi\Api\UnassignAssetsInterface; use Magento\MediaContentApi\Api\UpdateRelationsInterface; use Magento\MediaGalleryApi\Api\Data\AssetInterface; use Psr\Log\LoggerInterface; @@ -24,22 +25,22 @@ class UpdateRelations implements UpdateRelationsInterface { /** - * @var ExtractAssetFromContentInterface + * @var ExtractAssetsFromContentInterface */ private $extractAssetFromContent; /** - * @var AssignAssetInterface + * @var AssignAssetsInterface */ private $assignAsset; /** - * @var GetAssetsUsedInContentInterface + * @var GetAssetIdsUsedInContentInterface */ private $getAssetsUsedInContent; /** - * @var UnassignAssetInterface + * @var UnassignAssetsInterface */ private $unassignAsset; @@ -49,17 +50,17 @@ class UpdateRelations implements UpdateRelationsInterface private $logger; /** - * @param ExtractAssetFromContentInterface $extractAssetFromContent - * @param AssignAssetInterface $assignAsset - * @param GetAssetsUsedInContentInterface $getAssetsUsedInContent - * @param UnassignAssetInterface $unassignAsset + * @param ExtractAssetsFromContentInterface $extractAssetFromContent + * @param AssignAssetsInterface $assignAsset + * @param GetAssetIdsUsedInContentInterface $getAssetsUsedInContent + * @param UnassignAssetsInterface $unassignAsset * @param LoggerInterface $logger */ public function __construct( - ExtractAssetFromContentInterface $extractAssetFromContent, - AssignAssetInterface $assignAsset, - GetAssetsUsedInContentInterface $getAssetsUsedInContent, - UnassignAssetInterface $unassignAsset, + ExtractAssetsFromContentInterface $extractAssetFromContent, + UnassignAssetsInterface $assignAsset, + GetAssetIdsUsedInContentInterface $getAssetsUsedInContent, + UnassignAssetsInterface $unassignAsset, LoggerInterface $logger ) { $this->extractAssetFromContent = $extractAssetFromContent; @@ -72,15 +73,13 @@ public function __construct( /** * Create new relation between media asset and content or updated existing * - * @param string $type - * @param string $field - * @param string $entityId + * @param ContentIdentityInterface $contentIdentity * @param string $data */ - public function execute(string $type, string $field, string $entityId, string $data): void + public function execute(ContentIdentityInterface $contentIdentity, string $data): void { try { - $this->updateRelation($type, $field, $entityId, $data); + $this->updateRelation($contentIdentity, $data); } catch (\Exception $exception) { $this->logger->critical($exception); } @@ -89,28 +88,26 @@ public function execute(string $type, string $field, string $entityId, string $d /** * Records a relation for the newly added asset * - * @param string $type - * @param string $field - * @param string $entityId + * @param ContentIdentityInterface $contentIdentity * @param string $data * @throws CouldNotDeleteException * @throws CouldNotSaveException * @throws IntegrationException */ - private function updateRelation(string $type, string $field, string $entityId, string $data) + private function updateRelation(ContentIdentityInterface $contentIdentity, string $data) { - $relations = $this->getAssetsUsedInContent->execute($type, $entityId, $field); - $assetsInContent = $this->extractAssetFromContent->execute($data); + $existingAssetIds = $this->getAssetsUsedInContent->execute($contentIdentity); + $currentAssets = $this->extractAssetFromContent->execute($data); /** @var AssetInterface $asset */ - foreach ($assetsInContent as $asset) { - if (!isset($relations[$asset->getId()])) { - $this->assignAsset->execute($asset->getId(), $type, $entityId, $field); + foreach ($currentAssets as $asset) { + if (!in_array($asset->getId(), $existingAssetIds)) { + $this->assignAsset->execute($contentIdentity, [$asset->getId()]); } } - foreach (array_keys($relations) as $assetId) { - if (!isset($assetsInContent[$assetId])) { - $this->unassignAsset->execute($assetId, $type, $entityId, $field); + foreach ($existingAssetIds as $assetId) { + if (!isset($currentAssets[$assetId])) { + $this->unassignAsset->execute($contentIdentity, [$assetId]); } } } diff --git a/app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetTest.php b/app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetsTest.php similarity index 70% rename from app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetTest.php rename to app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetsTest.php index 98e0e8fe2606e..d2bb1ca5c59b7 100644 --- a/app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetTest.php +++ b/app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetsTest.php @@ -12,7 +12,8 @@ use Magento\Framework\DB\Adapter\Pdo\Mysql; use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\MediaContent\Model\AssignAsset; +use Magento\MediaContent\Model\AssignAssets; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; @@ -20,7 +21,7 @@ /** * Tests for the AssignAsset command. */ -class AssignAssetTest extends TestCase +class AssignAssetsTest extends TestCase { /** * Media content relation data storage table name @@ -73,7 +74,7 @@ class AssignAssetTest extends TestCase private $loggerMock; /** - * @var AssignAsset + * @var AssignAssets */ private $assignAsset; @@ -93,7 +94,7 @@ protected function setUp(): void ); $this->assignAsset = (new ObjectManager($this))->getObject( - AssignAsset::class, + AssignAssets::class, [ 'resourceConnection' => $this->resourceConnectionMock, 'logger' => $this->loggerMock @@ -125,29 +126,24 @@ public function testSuccessfulExecute( ]; $this->adapterMock ->expects(self::once()) - ->method('insert') - ->with(self::PREFIXED_TABLE_MEDIA_CONTENT_ASSET, $saveData) + ->method('insertMultiple') + ->with(self::PREFIXED_TABLE_MEDIA_CONTENT_ASSET, [$saveData]) ->willReturn(self::AFFECTED_ROWS); - $this->assignAsset->execute($assetId, $contentType, $contentEntityId, $contentField); + $this->assignAsset->execute( + $this->getContentIdentity($contentType, $contentField, $contentEntityId), + [ + $assetId + ] + ); } /** * Tests with exception scenario for saving relation between media asset and media content. - * - * @param int $assetId - * @param string $contentType - * @param string $contentEntityId - * @param string $contentField - * @dataProvider assignAssetDataProvider */ - public function testExceptionExecute( - int $assetId, - string $contentType, - string $contentEntityId, - string $contentField - ): void { - $this->resourceConnectionMock->method('getConnection')->willThrowException((new \Exception())); + public function testExceptionExecute(): void { + $this->resourceConnectionMock->method('getConnection') + ->willThrowException((new \Exception())); $this->loggerMock ->expects(self::once()) @@ -155,7 +151,36 @@ public function testExceptionExecute( ->willReturnSelf(); $this->expectException(CouldNotSaveException::class); - $this->assignAsset->execute($assetId, $contentType, $contentEntityId, $contentField); + $this->assignAsset->execute( + $this->createMock(ContentIdentityInterface::class), + [ + '42' + ] + ); + } + + /** + * Get content identity mock + * + * @param string $type + * @param string $field + * @param string $id + * @return MockObject|ContentIdentityInterface + */ + private function getContentIdentity(string $type, string $field, string $id): MockObject + { + $contentIdentity = $this->createMock(ContentIdentityInterface::class); + $contentIdentity->expects($this->once()) + ->method('getEntityId') + ->willReturn($id); + $contentIdentity->expects($this->once()) + ->method('getField') + ->willReturn($field); + $contentIdentity->expects($this->once()) + ->method('getEntityType') + ->willReturn($type); + + return $contentIdentity; } /** @@ -165,6 +190,7 @@ public function testExceptionExecute( */ public function assignAssetDataProvider(): array { + return [ [ '18976345', diff --git a/app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php b/app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php index 911d9b6e6f375..5b5cf2b277ee5 100644 --- a/app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php +++ b/app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php @@ -11,7 +11,8 @@ use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\DB\Select; use Magento\Framework\Exception\IntegrationException; -use Magento\MediaContent\Model\GetAssetsUsedInContent; +use Magento\MediaContent\Model\GetAssetIdsUsedInContent; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; @@ -32,7 +33,7 @@ class GetAssetsusedInContentTest extends TestCase private $loggerMock; /** - * @var GetAssetsUsedInContent + * @var GetAssetIdsUsedInContent */ private $getAssetsUsedInContent; @@ -43,7 +44,10 @@ protected function setUp(): void { $this->resourceConnectionStub = $this->createMock(ResourceConnection::class); $this->loggerMock = $this->createMock(LoggerInterface::class); - $this->getAssetsUsedInContent = new GetAssetsUsedInContent($this->resourceConnectionStub, $this->loggerMock); + $this->getAssetsUsedInContent = new GetAssetIdsUsedInContent( + $this->resourceConnectionStub, + $this->loggerMock + ); } /** @@ -59,9 +63,11 @@ public function testSuccessfulGetUsedAssets( ): void { $this->configureResourceConnectionStub($expectedAssetIdList); $assetList = $this->getAssetsUsedInContent->execute( - $requestParameters['type'], - $requestParameters['entity_id'], - $requestParameters['field'] + $this->getContentIdentity( + $requestParameters['type'], + $requestParameters['field'], + $requestParameters['entity_id'] + ) ); $this->assertEquals($expectedAssetIdList, $assetList); @@ -78,7 +84,7 @@ public function testGetUsedAssetsWithException(): void ->method('critical') ->willReturnSelf(); - $this->getAssetsUsedInContent->execute('cms_page', '1', 'content'); + $this->getAssetsUsedInContent->execute($this->createMock(ContentIdentityInterface::class)); } /** @@ -103,6 +109,30 @@ private function configureResourceConnectionStub(array $expectedAssetIdList): vo ->willReturn($connectionMock); } + /** + * Get content identity mock + * + * @param string $type + * @param string $field + * @param string $id + * @return MockObject|ContentIdentityInterface + */ + private function getContentIdentity(string $type, string $field, string $id): MockObject + { + $contentIdentity = $this->createMock(ContentIdentityInterface::class); + $contentIdentity->expects($this->once()) + ->method('getEntityId') + ->willReturn($id); + $contentIdentity->expects($this->once()) + ->method('getField') + ->willReturn($field); + $contentIdentity->expects($this->once()) + ->method('getEntityType') + ->willReturn($type); + + return $contentIdentity; + } + /** * Media asset to media content relation data * @@ -118,30 +148,6 @@ public function getAssetsListRelatedToContent(): array 'field' => 'content' ], [1234123] - ], - [ - [ - 'type' => 'cms_page', - 'entity_id' => null, - 'field' => 'content' - ], - [1234123, 2425168] - ], - [ - [ - 'type' => 'catalog_category', - 'entity_id' => '1', - 'field' => null - ], - [1234123] - ], - [ - [ - 'type' => 'cbm_block', - 'entity_id' => null, - 'field' => null - ], - [1234123, 2425168] ] ]; } diff --git a/app/code/Magento/MediaContent/Test/Unit/Model/GetContentWithAssetTest.php b/app/code/Magento/MediaContent/Test/Unit/Model/GetContentWithAssetsTest.php similarity index 62% rename from app/code/Magento/MediaContent/Test/Unit/Model/GetContentWithAssetTest.php rename to app/code/Magento/MediaContent/Test/Unit/Model/GetContentWithAssetsTest.php index 3ba98a400fcba..f2958d0a378ed 100644 --- a/app/code/Magento/MediaContent/Test/Unit/Model/GetContentWithAssetTest.php +++ b/app/code/Magento/MediaContent/Test/Unit/Model/GetContentWithAssetsTest.php @@ -11,7 +11,9 @@ use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\DB\Select; use Magento\Framework\Exception\IntegrationException; -use Magento\MediaContent\Model\GetContentWithAsset; +use Magento\MediaContent\Model\GetContentWithAssets; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; @@ -19,21 +21,8 @@ /** * Test for the GetContentWithAsset command. */ -class GetContentWithAssetTest extends TestCase +class GetContentWithAssetsTest extends TestCase { - /** - * Expected list of assets for the return statement. - */ - private const EXPECTED_LIST_OF_ASSETS = - [ - 1234123 => [ - 1234123, - 'cms_page', - '1', - 'content', - ] - ]; - /** * @var ResourceConnection | MockObject */ @@ -45,10 +34,15 @@ class GetContentWithAssetTest extends TestCase private $loggerMock; /** - * @var GetContentWithAsset + * @var GetContentWithAssets */ private $getContentWithAsset; + /** + * @var ContentIdentityInterfaceFactory + */ + private $factory; + /** * @inheritdoc */ @@ -56,7 +50,12 @@ protected function setUp(): void { $this->resourceConnectionStub = $this->createMock(ResourceConnection::class); $this->loggerMock = $this->createMock(LoggerInterface::class); - $this->getContentWithAsset = new GetContentWithAsset($this->resourceConnectionStub, $this->loggerMock); + $this->factory = $this->createMock(ContentIdentityInterfaceFactory::class); + $this->getContentWithAsset = new GetContentWithAssets( + $this->factory, + $this->resourceConnectionStub, + $this->loggerMock + ); } /** @@ -65,10 +64,20 @@ protected function setUp(): void public function testSuccessfulGetContentWithAsset(): void { $assetId = 1234123; - $this->configureResourceConnectionStub(); - $assetList = $this->getContentWithAsset->execute($assetId); + $contentIdentityData = [ + 'entity_type' => 'catalog_product', + 'entity_id' => 42, + 'field' => 'desctiption' + ]; + $this->configureResourceConnectionStub($contentIdentityData); + + $contentIdentity = $this->createMock(ContentIdentityInterface::class); + $this->factory->expects($this->once()) + ->method('create') + ->with(['data' => $contentIdentityData]) + ->willReturn($contentIdentity); - $this->assertEquals(self::EXPECTED_LIST_OF_ASSETS, $assetList); + $this->assertEquals([$contentIdentity], $this->getContentWithAsset->execute([$assetId])); } /** @@ -82,13 +91,15 @@ public function testGetContentWithAssetWithException(): void ->method('critical') ->willReturnSelf(); - $this->getContentWithAsset->execute(1); + $this->getContentWithAsset->execute([1]); } /** * Configure resource connection for the command. Based on the current implementation. + * + * @param array $contentIdentityData */ - private function configureResourceConnectionStub(): void + private function configureResourceConnectionStub(array $contentIdentityData): void { $selectStub = $this->createMock(Select::class); $selectStub->method('from')->willReturnSelf(); @@ -99,7 +110,7 @@ private function configureResourceConnectionStub(): void $connectionMock->expects($this->any()) ->method('fetchAssoc') ->with($selectStub) - ->willReturn(self::EXPECTED_LIST_OF_ASSETS); + ->willReturn([$contentIdentityData]); $this->resourceConnectionStub->expects($this->any()) ->method('getConnection') ->willReturn($connectionMock); diff --git a/app/code/Magento/MediaContent/Test/Unit/Model/UnassignAssetTest.php b/app/code/Magento/MediaContent/Test/Unit/Model/UnassignAssetTest.php index ac35ef6e75dd2..5b5fc41cb29fa 100644 --- a/app/code/Magento/MediaContent/Test/Unit/Model/UnassignAssetTest.php +++ b/app/code/Magento/MediaContent/Test/Unit/Model/UnassignAssetTest.php @@ -12,7 +12,8 @@ use Magento\Framework\DB\Adapter\Pdo\Mysql; use Magento\Framework\Exception\CouldNotDeleteException; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\MediaContent\Model\UnassignAsset; +use Magento\MediaContent\Model\UnassignAssets; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; @@ -68,7 +69,7 @@ class UnassignAssetTest extends TestCase private $loggerMock; /** - * @var UnassignAsset + * @var UnassignAssets */ private $unassignAsset; @@ -88,7 +89,7 @@ protected function setUp(): void ); $this->unassignAsset = (new ObjectManager($this))->getObject( - UnassignAsset::class, + UnassignAssets::class, [ 'resourceConnection' => $this->resourceConnectionMock, 'logger' => $this->loggerMock @@ -117,39 +118,66 @@ public function testSuccessfulUnassignAsset( ->with( self::PREFIXED_TABLE_MEDIA_CONTENT_ASSET, [ - self::ASSET_ID . ' = ?' => $assetId, + self::ASSET_ID . ' IN (?)' => [$assetId], self::TYPE . ' = ?' => $contentType, self::ENTITY_ID . ' = ?' => $contentEntityId, self::FIELD . ' = ?' => $contentField ] ); - $this->unassignAsset->execute($assetId, $contentType, $contentEntityId, $contentField); + $this->unassignAsset->execute( + $this->getContentIdentity( + $contentType, + $contentField, + $contentEntityId + ), + [ + $assetId + ] + ); } /** * Test exception scenario for deleting relation between media asset and media content. - * - * @param int $assetId - * @param string $contentType - * @param string $contentEntityId - * @param string $contentField - * @dataProvider unassignAssetDataProvider - * @return void */ - public function testUnassignAssetWithException( - int $assetId, - string $contentType, - string $contentEntityId, - string $contentField - ): void { - $this->resourceConnectionMock->method('getConnection')->willThrowException((new \Exception())); + public function testUnassignAssetWithException(): void { + $this->resourceConnectionMock->method('getConnection') + ->willThrowException((new \Exception())); $this->expectException(CouldNotDeleteException::class); $this->loggerMock->expects($this->once()) ->method('critical') ->willReturnSelf(); - $this->unassignAsset->execute($assetId, $contentType, $contentEntityId, $contentField); + $this->unassignAsset->execute( + $this->createMock(ContentIdentityInterface::class), + [ + '42' + ] + ); + } + + /** + * Get content identity mock + * + * @param string $type + * @param string $field + * @param string $id + * @return MockObject|ContentIdentityInterface + */ + private function getContentIdentity(string $type, string $field, string $id): MockObject + { + $contentIdentity = $this->createMock(ContentIdentityInterface::class); + $contentIdentity->expects($this->once()) + ->method('getEntityId') + ->willReturn($id); + $contentIdentity->expects($this->once()) + ->method('getField') + ->willReturn($field); + $contentIdentity->expects($this->once()) + ->method('getEntityType') + ->willReturn($type); + + return $contentIdentity; } /** diff --git a/app/code/Magento/MediaContent/etc/db_schema_whitelist.json b/app/code/Magento/MediaContent/etc/db_schema_whitelist.json index 9b55f29a3b039..071dc72b3a467 100644 --- a/app/code/Magento/MediaContent/etc/db_schema_whitelist.json +++ b/app/code/Magento/MediaContent/etc/db_schema_whitelist.json @@ -7,8 +7,7 @@ "field": true }, "constraint": { - "PRIMARY": true, - "MEDIA_CONTENT_ASSET_ASSET_ID_MEDIA_GALLERY_ASSET_ID": true + "PRIMARY": true } } } diff --git a/app/code/Magento/MediaContent/etc/di.xml b/app/code/Magento/MediaContent/etc/di.xml index 15fa68bce99a0..ef3262ea09a79 100644 --- a/app/code/Magento/MediaContent/etc/di.xml +++ b/app/code/Magento/MediaContent/etc/di.xml @@ -6,16 +6,17 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> - <preference for="Magento\MediaContentApi\Api\AssignAssetInterface" type="Magento\MediaContent\Model\AssignAsset"/> - <preference for="Magento\MediaContentApi\Api\UnassignAssetInterface" type="Magento\MediaContent\Model\UnassignAsset"/> - <preference for="Magento\MediaContentApi\Api\GetAssetsUsedInContentInterface" type="Magento\MediaContent\Model\GetAssetsUsedInContent"/> - <preference for="Magento\MediaContentApi\Api\GetContentWithAssetInterface" type="Magento\MediaContent\Model\GetContentWithAsset"/> - <preference for="Magento\MediaContentApi\Api\ExtractAssetFromContentInterface" type="Magento\MediaContentApi\Model\ExtractAssetFromContent"/> + <preference for="Magento\MediaContentApi\Api\AssignAssetsInterface" type="Magento\MediaContent\Model\AssignAssets"/> + <preference for="Magento\MediaContentApi\Api\UnassignAssetsInterface" type="Magento\MediaContent\Model\UnassignAssets"/> + <preference for="Magento\MediaContentApi\Api\GetAssetIdsUsedInContentInterface" type="Magento\MediaContent\Model\GetAssetIdsUsedInContent"/> + <preference for="Magento\MediaContentApi\Api\GetContentWithAssetsInterface" type="Magento\MediaContent\Model\GetContentWithAssets"/> + <preference for="Magento\MediaContentApi\Api\ExtractAssetsFromContentInterface" type="Magento\MediaContentApi\Model\ExtractAssetsFromContent"/> <preference for="Magento\MediaContentApi\Api\UpdateRelationsInterface" type="Magento\MediaContent\Model\UpdateRelations"/> + <preference for="Magento\MediaContentApi\Api\Data\ContentIdentityInterface" type="Magento\MediaContent\Model\Content"/> <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface"> <plugin name="remove_media_content_after_asset_is_removed_by_path" type="Magento\MediaContent\Model\Plugin\MediaGalleryAssetDeleteByPath" /> </type> - <type name="\Magento\MediaGalleryApi\Model\Asset\Command\DeleteByDirectoryPathInterface"> + <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByDirectoryPathInterface"> <plugin name="remove_media_content_after_asset_is_removed_by_directory_path" type="Magento\MediaContent\Model\Plugin\MediaGalleryAssetDeleteByDirectoryPath" /> </type> </config> diff --git a/app/code/Magento/MediaContent/etc/module.xml b/app/code/Magento/MediaContent/etc/module.xml index ebf2a2f0d9277..58cff2aabf3a6 100644 --- a/app/code/Magento/MediaContent/etc/module.xml +++ b/app/code/Magento/MediaContent/etc/module.xml @@ -6,9 +6,5 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="Magento_MediaContent"> - <sequence> - <module name="Magento_MediaGallery"/> - </sequence> - </module> + <module name="Magento_MediaContent"/> </config> diff --git a/app/code/Magento/MediaContentApi/Api/AssignAssetInterface.php b/app/code/Magento/MediaContentApi/Api/AssignAssetsInterface.php similarity index 59% rename from app/code/Magento/MediaContentApi/Api/AssignAssetInterface.php rename to app/code/Magento/MediaContentApi/Api/AssignAssetsInterface.php index a0436b57e01af..21ab0b08e15c5 100644 --- a/app/code/Magento/MediaContentApi/Api/AssignAssetInterface.php +++ b/app/code/Magento/MediaContentApi/Api/AssignAssetsInterface.php @@ -8,21 +8,20 @@ namespace Magento\MediaContentApi\Api; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; + /** * Saving data represents relation between the media asset and media content * @api */ -interface AssignAssetInterface +interface AssignAssetsInterface { /** * Save relation between media asset and media content. * - * @param int $assetId - * @param string $contentType - * @param string $contentEntityId - * @param string $contentField - * + * @param ContentIdentityInterface $contentIdentity + * @param int[] $assetIds * @throws \Magento\Framework\Exception\CouldNotSaveException */ - public function execute(int $assetId, string $contentType, string $contentEntityId, string $contentField): void; + public function execute(ContentIdentityInterface $contentIdentity, array $assetIds): void; } diff --git a/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php b/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php new file mode 100644 index 0000000000000..c107a9cd124db --- /dev/null +++ b/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php @@ -0,0 +1,37 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\MediaContentApi\Api\Data; + +/** + * Data interface representing the identificator of content. I.e. short description field of product entity with id 42 + * @api + */ +interface ContentIdentityInterface +{ + /** + * Type of entity that can have a content with media. I.e. catalog_product or cms_page + * + * @return string + */ + public function getEntityType(): string; + + /** + * Id of the entity containing content with media + * + * @return string + */ + public function getEntityId(): string; + + /** + * Field of the entity where the content can be stored. I.e. short_description for product + * + * @return string + */ + public function getField(): string; +} diff --git a/app/code/Magento/MediaContentApi/Api/ExtractAssetFromContentInterface.php b/app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentInterface.php similarity index 92% rename from app/code/Magento/MediaContentApi/Api/ExtractAssetFromContentInterface.php rename to app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentInterface.php index 4911f55e6b5f3..8f1b438361501 100644 --- a/app/code/Magento/MediaContentApi/Api/ExtractAssetFromContentInterface.php +++ b/app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentInterface.php @@ -13,7 +13,7 @@ * Used for extracting media asset list from a media content by the search pattern. * @api */ -interface ExtractAssetFromContentInterface +interface ExtractAssetsFromContentInterface { /** * Search for the media asset in content and extract it providing a list of media assets. diff --git a/app/code/Magento/MediaContentApi/Api/GetAssetsUsedInContentInterface.php b/app/code/Magento/MediaContentApi/Api/GetAssetIdsUsedInContentInterface.php similarity index 57% rename from app/code/Magento/MediaContentApi/Api/GetAssetsUsedInContentInterface.php rename to app/code/Magento/MediaContentApi/Api/GetAssetIdsUsedInContentInterface.php index 148acb5edadbc..ef6b98ba1505c 100644 --- a/app/code/Magento/MediaContentApi/Api/GetAssetsUsedInContentInterface.php +++ b/app/code/Magento/MediaContentApi/Api/GetAssetIdsUsedInContentInterface.php @@ -8,21 +8,20 @@ namespace Magento\MediaContentApi\Api; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; + /** * Get media asset ids used in the content * @api */ -interface GetAssetsUsedInContentInterface +interface GetAssetIdsUsedInContentInterface { /** * Get media asset ids used in the content * - * @param string $contentType - * @param string|null $contentEntityId - * @param string|null $contentField - * + * @param ContentIdentityInterface $contentIdentity * @return int[] * @throws \Magento\Framework\Exception\IntegrationException */ - public function execute(string $contentType, string $contentEntityId = null, string $contentField = null): array; + public function execute(ContentIdentityInterface $contentIdentity): array; } diff --git a/app/code/Magento/MediaContentApi/Api/GetContentWithAssetInterface.php b/app/code/Magento/MediaContentApi/Api/GetContentWithAssetsInterface.php similarity index 54% rename from app/code/Magento/MediaContentApi/Api/GetContentWithAssetInterface.php rename to app/code/Magento/MediaContentApi/Api/GetContentWithAssetsInterface.php index ab8347098da82..abfc3f94fa6b0 100644 --- a/app/code/Magento/MediaContentApi/Api/GetContentWithAssetInterface.php +++ b/app/code/Magento/MediaContentApi/Api/GetContentWithAssetsInterface.php @@ -8,19 +8,20 @@ namespace Magento\MediaContentApi\Api; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; + /** * Get media content list which is used with the specified media asset * @api */ -interface GetContentWithAssetInterface +interface GetContentWithAssetsInterface { /** - * Get media asset to content relation by media asset id. - * - * @param int $assetId + * Get media asset to content relations by media asset id. * - * @return array + * @param int[] $assetIds + * @return ContentIdentityInterface[] * @throws \Magento\Framework\Exception\IntegrationException */ - public function execute(int $assetId): array; + public function execute(array $assetIds): array; } diff --git a/app/code/Magento/MediaContentApi/Api/UnassignAssetInterface.php b/app/code/Magento/MediaContentApi/Api/UnassignAssetsInterface.php similarity index 60% rename from app/code/Magento/MediaContentApi/Api/UnassignAssetInterface.php rename to app/code/Magento/MediaContentApi/Api/UnassignAssetsInterface.php index 831275de8a78e..348d213fd9074 100644 --- a/app/code/Magento/MediaContentApi/Api/UnassignAssetInterface.php +++ b/app/code/Magento/MediaContentApi/Api/UnassignAssetsInterface.php @@ -8,21 +8,20 @@ namespace Magento\MediaContentApi\Api; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; + /** * Unassign relation between the media asset and media content where the media asset is used * @api */ -interface UnassignAssetInterface +interface UnassignAssetsInterface { /** * Remove relation between the media asset and media content. * - * @param int $assetId - * @param string $contentType - * @param string $contentEntityId - * @param string $contentField - * + * @param int[] $assetIds + * @param ContentIdentityInterface $contentIdentity * @throws \Magento\Framework\Exception\CouldNotDeleteException */ - public function execute(int $assetId, string $contentType, string $contentEntityId, string $contentField): void; + public function execute(ContentIdentityInterface $contentIdentity, array $assetIds): void; } diff --git a/app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php b/app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php index 812209a73636d..7faab00846495 100644 --- a/app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php +++ b/app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php @@ -7,15 +7,7 @@ namespace Magento\MediaContentApi\Api; -use Magento\Framework\Exception\CouldNotDeleteException; -use Magento\Framework\Exception\CouldNotSaveException; -use Magento\Framework\Exception\IntegrationException; -use Magento\MediaContentApi\Api\AssignAssetInterface; -use Magento\MediaContentApi\Api\ExtractAssetFromContentInterface; -use Magento\MediaContentApi\Api\GetAssetsUsedInContentInterface; -use Magento\MediaContentApi\Api\UnassignAssetInterface; -use Magento\MediaGalleryApi\Api\Data\AssetInterface; -use Psr\Log\LoggerInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; /** * Process relation managing between media asset and content: assign or unassign relation if exists. @@ -25,10 +17,8 @@ interface UpdateRelationsInterface /** * Create new relation between media asset and content or updated existing * - * @param string $type - * @param string $field - * @param string $entityId - * @param string $data + * @param ContentIdentityInterface $contentIdentity + * @param string $content */ - public function execute(string $type, string $field, string $entityId, string $data): void; + public function execute(ContentIdentityInterface $contentIdentity, string $content): void; } diff --git a/app/code/Magento/MediaContentApi/Model/ExtractAssetFromContent.php b/app/code/Magento/MediaContentApi/Model/ExtractAssetsFromContent.php similarity index 94% rename from app/code/Magento/MediaContentApi/Model/ExtractAssetFromContent.php rename to app/code/Magento/MediaContentApi/Model/ExtractAssetsFromContent.php index 57cef519f1f2a..7db389a0558f1 100644 --- a/app/code/Magento/MediaContentApi/Model/ExtractAssetFromContent.php +++ b/app/code/Magento/MediaContentApi/Model/ExtractAssetsFromContent.php @@ -7,7 +7,7 @@ namespace Magento\MediaContentApi\Model; -use Magento\MediaContentApi\Api\ExtractAssetFromContentInterface; +use Magento\MediaContentApi\Api\ExtractAssetsFromContentInterface; use Magento\MediaGalleryApi\Api\Data\AssetInterface; use Magento\MediaGalleryApi\Model\Asset\Command\GetByPathInterface; use Psr\Log\LoggerInterface; @@ -19,7 +19,7 @@ * * @api */ -class ExtractAssetFromContent implements ExtractAssetFromContentInterface +class ExtractAssetsFromContent implements ExtractAssetsFromContentInterface { /** * @var string diff --git a/app/code/Magento/MediaContentCatalog/Observer/Category.php b/app/code/Magento/MediaContentCatalog/Observer/Category.php index 58efd114f5782..e1a262b5193c6 100644 --- a/app/code/Magento/MediaContentCatalog/Observer/Category.php +++ b/app/code/Magento/MediaContentCatalog/Observer/Category.php @@ -10,8 +10,8 @@ use Magento\Catalog\Model\Category as CatalogCategory; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; -use Magento\Framework\Model\AbstractModel; use Magento\MediaContentApi\Api\UpdateRelationsInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory; /** * Observe the catalog_category_save_after event and run processing relation between category content and media asset. @@ -19,6 +19,9 @@ class Category implements ObserverInterface { private const CONTENT_TYPE = 'catalog_category'; + private const TYPE = 'entity_type'; + private const ENTITY_ID = 'entity_id'; + private const FIELD = 'field'; /** * @var UpdateRelationsInterface @@ -31,11 +34,21 @@ class Category implements ObserverInterface private $fields; /** + * @var ContentIdentityInterfaceFactory + */ + private $contentIdentityFactory; + + /** + * @param ContentIdentityInterfaceFactory $contentIdentityFactory * @param UpdateRelationsInterface $processor * @param array $fields */ - public function __construct(UpdateRelationsInterface $processor, array $fields) - { + public function __construct( + ContentIdentityInterfaceFactory $contentIdentityFactory, + UpdateRelationsInterface $processor, + array $fields + ) { + $this->contentIdentityFactory = $contentIdentityFactory; $this->processor = $processor; $this->fields = $fields; } @@ -47,17 +60,23 @@ public function __construct(UpdateRelationsInterface $processor, array $fields) */ public function execute(Observer $observer): void { - /** @var CatalogCategory $model */ $model = $observer->getEvent()->getData('category'); - if ($model instanceof AbstractModel) { + + if ($model instanceof CatalogCategory) { foreach ($this->fields as $field) { if (!$model->dataHasChangedFor($field)) { continue; } $this->processor->execute( - self::CONTENT_TYPE, - $field, - (string) $model->getId(), + $this->contentIdentityFactory->create( + [ + 'data' => [ + self::TYPE => self::CONTENT_TYPE, + self::FIELD => $field, + self::ENTITY_ID => (string) $model->getId(), + ] + ] + ), (string) $model->getData($field) ); } diff --git a/app/code/Magento/MediaContentCatalog/Observer/Product.php b/app/code/Magento/MediaContentCatalog/Observer/Product.php index 9349d5ff90be0..d250a02498da5 100644 --- a/app/code/Magento/MediaContentCatalog/Observer/Product.php +++ b/app/code/Magento/MediaContentCatalog/Observer/Product.php @@ -10,8 +10,8 @@ use Magento\Catalog\Model\Product as CatalogProduct; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; -use Magento\Framework\Model\AbstractModel; use Magento\MediaContentApi\Api\UpdateRelationsInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory; /** * Observe the catalog_product_save_after event and run processing relation between product content and media asset @@ -19,6 +19,9 @@ class Product implements ObserverInterface { private const CONTENT_TYPE = 'catalog_product'; + private const TYPE = 'entity_type'; + private const ENTITY_ID = 'entity_id'; + private const FIELD = 'field'; /** * @var UpdateRelationsInterface @@ -31,11 +34,21 @@ class Product implements ObserverInterface private $fields; /** + * @var ContentIdentityInterfaceFactory + */ + private $contentIdentityFactory; + + /** + * @param ContentIdentityInterfaceFactory $contentIdentityFactory * @param UpdateRelationsInterface $processor * @param array $fields */ - public function __construct(UpdateRelationsInterface $processor, array $fields) - { + public function __construct( + ContentIdentityInterfaceFactory $contentIdentityFactory, + UpdateRelationsInterface $processor, + array $fields + ) { + $this->contentIdentityFactory = $contentIdentityFactory; $this->processor = $processor; $this->fields = $fields; } @@ -47,18 +60,23 @@ public function __construct(UpdateRelationsInterface $processor, array $fields) */ public function execute(Observer $observer): void { - /** @var CatalogProduct $model */ $model = $observer->getEvent()->getData('product'); - if ($model instanceof AbstractModel) { + if ($model instanceof CatalogProduct) { foreach ($this->fields as $field) { if (!$model->dataHasChangedFor($field)) { continue; } $this->processor->execute( - self::CONTENT_TYPE, - $field, - (string) $model->getId(), + $this->contentIdentityFactory->create( + [ + 'data' => [ + self::TYPE => self::CONTENT_TYPE, + self::FIELD => $field, + self::ENTITY_ID => (string) $model->getId(), + ] + ] + ), (string) $model->getData($field) ); } diff --git a/app/code/Magento/MediaContentCatalog/etc/di.xml b/app/code/Magento/MediaContentCatalog/etc/di.xml index a9cd9ac8bd796..88c92f6028b02 100644 --- a/app/code/Magento/MediaContentCatalog/etc/di.xml +++ b/app/code/Magento/MediaContentCatalog/etc/di.xml @@ -22,7 +22,7 @@ </argument> </arguments> </type> - <type name="Magento\MediaContentApi\Model\ExtractAssetFromContent"> + <type name="Magento\MediaContentApi\Model\ExtractAssetsFromContent"> <arguments> <argument name="searchPatterns" xsi:type="array"> <item name="catalog_image" xsi:type="string">/^\/?media\/(.*)/</item> diff --git a/app/code/Magento/MediaContentCms/Observer/Block.php b/app/code/Magento/MediaContentCms/Observer/Block.php index 9d5d24d422a78..17bf5bd88acac 100644 --- a/app/code/Magento/MediaContentCms/Observer/Block.php +++ b/app/code/Magento/MediaContentCms/Observer/Block.php @@ -10,8 +10,8 @@ use Magento\Cms\Block\Block as CmsBlock; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; -use Magento\Framework\Model\AbstractModel; use Magento\MediaContentApi\Api\UpdateRelationsInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory; /** * Observe cms_block_save_after event and run processing relation between cms block content and media asset @@ -19,6 +19,9 @@ class Block implements ObserverInterface { private const CONTENT_TYPE = 'cms_block'; + private const TYPE = 'entity_type'; + private const ENTITY_ID = 'entity_id'; + private const FIELD = 'field'; /** * @var UpdateRelationsInterface @@ -31,11 +34,21 @@ class Block implements ObserverInterface private $fields; /** + * @var ContentIdentityInterfaceFactory + */ + private $contentIdentityFactory; + + /** + * @param ContentIdentityInterfaceFactory $contentIdentityFactory * @param UpdateRelationsInterface $processor * @param array $fields */ - public function __construct(UpdateRelationsInterface $processor, array $fields) - { + public function __construct( + ContentIdentityInterfaceFactory $contentIdentityFactory, + UpdateRelationsInterface $processor, + array $fields + ) { + $this->contentIdentityFactory = $contentIdentityFactory; $this->processor = $processor; $this->fields = $fields; } @@ -47,17 +60,23 @@ public function __construct(UpdateRelationsInterface $processor, array $fields) */ public function execute(Observer $observer): void { - /** @var CmsBlock $model */ $model = $observer->getEvent()->getData('object'); - if ($model instanceof AbstractModel) { + + if ($model instanceof CmsBlock) { foreach ($this->fields as $field) { if (!$model->dataHasChangedFor($field)) { continue; } $this->processor->execute( - self::CONTENT_TYPE, - $field, - (string) $model->getId(), + $this->contentIdentityFactory->create( + [ + 'data' => [ + self::TYPE => self::CONTENT_TYPE, + self::FIELD => $field, + self::ENTITY_ID => (string) $model->getId(), + ] + ] + ), (string) $model->getData($field) ); } diff --git a/app/code/Magento/MediaContentCms/Observer/Page.php b/app/code/Magento/MediaContentCms/Observer/Page.php index 111b4478a9888..727efe3dc2ef0 100644 --- a/app/code/Magento/MediaContentCms/Observer/Page.php +++ b/app/code/Magento/MediaContentCms/Observer/Page.php @@ -10,8 +10,8 @@ use Magento\Cms\Model\Page as CmsPage; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; -use Magento\Framework\Model\AbstractModel; use Magento\MediaContentApi\Api\UpdateRelationsInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory; /** * Observe cms_page_save_after event and run processing relation between cms page content and media asset. @@ -19,6 +19,9 @@ class Page implements ObserverInterface { private const CONTENT_TYPE = 'cms_page'; + private const TYPE = 'entity_type'; + private const ENTITY_ID = 'entity_id'; + private const FIELD = 'field'; /** * @var UpdateRelationsInterface @@ -31,11 +34,21 @@ class Page implements ObserverInterface private $fields; /** + * @var ContentIdentityInterfaceFactory + */ + private $contentIdentityFactory; + + /** + * @param ContentIdentityInterfaceFactory $contentIdentityFactory * @param UpdateRelationsInterface $processor * @param array $fields */ - public function __construct(UpdateRelationsInterface $processor, array $fields) - { + public function __construct( + ContentIdentityInterfaceFactory $contentIdentityFactory, + UpdateRelationsInterface $processor, + array $fields + ) { + $this->contentIdentityFactory = $contentIdentityFactory; $this->processor = $processor; $this->fields = $fields; } @@ -47,17 +60,23 @@ public function __construct(UpdateRelationsInterface $processor, array $fields) */ public function execute(Observer $observer): void { - /** @var CmsPage $model */ $model = $observer->getEvent()->getData('object'); - if ($model instanceof AbstractModel) { + + if ($model instanceof CmsPage) { foreach ($this->fields as $field) { if (!$model->dataHasChangedFor($field)) { continue; } $this->processor->execute( - self::CONTENT_TYPE, - $field, - (string) $model->getId(), + $this->contentIdentityFactory->create( + [ + 'data' => [ + self::TYPE => self::CONTENT_TYPE, + self::FIELD => $field, + self::ENTITY_ID => (string) $model->getId(), + ] + ] + ), (string) $model->getData($field) ); } diff --git a/app/code/Magento/MediaContentCms/etc/di.xml b/app/code/Magento/MediaContentCms/etc/di.xml index 165c295c28208..e1f94ec753c7b 100644 --- a/app/code/Magento/MediaContentCms/etc/di.xml +++ b/app/code/Magento/MediaContentCms/etc/di.xml @@ -20,7 +20,7 @@ </argument> </arguments> </type> - <type name="Magento\MediaContentApi\Model\ExtractAssetFromContent"> + <type name="Magento\MediaContentApi\Model\ExtractAssetsFromContent"> <arguments> <argument name="searchPatterns" xsi:type="array"> <item name="media_gallery" xsi:type="string">/{{media url="?(.*?)"?}}/</item> From 909ea3f184eaeeb3caff92178722ec02a48a813d Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Sat, 4 Apr 2020 17:28:17 +0100 Subject: [PATCH 060/177] agento/magento2#27499: Updated blacklist patterns --- app/code/Magento/MediaGallery/etc/di.xml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index c993d82342326..8910a2261005c 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -29,14 +29,15 @@ <type name="Magento\MediaGallery\Model\Directory\IsBlacklisted"> <arguments> <argument name="patterns" xsi:type="array"> - <item name="captcha" xsi:type="string">/pub\/media\/captcha/</item> - <item name="catalog" xsi:type="string">/pub\/media\/catalog\/product/</item> - <item name="customer" xsi:type="string">/pub\/media\/customer/</item> - <item name="downloadable" xsi:type="string">/pub\/media\/downloadable/</item> - <item name="import" xsi:type="string">/pub\/media\/import/</item> - <item name="theme" xsi:type="string">/pub\/media\/theme/</item> - <item name="theme_customization" xsi:type="string">/pub\/media\/theme_customization/</item> - <item name="tmp" xsi:type="string">/pub\/media\/tmp/</item> + <item name="captcha" xsi:type="string">/^captcha/</item> + <item name="catalog" xsi:type="string">/^catalog\/product/</item> + <item name="customer" xsi:type="string">/^customer/</item> + <item name="downloadable" xsi:type="string">/^downloadable/</item> + <item name="import" xsi:type="string">/^import/</item> + <item name="theme" xsi:type="string">/^theme/</item> + <item name="theme_customization" xsi:type="string">/^theme_customization/</item> + <item name="tmp" xsi:type="string">/^tmp/</item> + <item name="directories-with-dots" xsi:type="string">/^\./</item> </argument> </arguments> </type> From 1ac923d3487a7ce8f65db2bd1191a9349a77c99d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Tylek?= <pawel.tylek@creativestyle.pl> Date: Sat, 4 Apr 2020 19:28:42 +0200 Subject: [PATCH 061/177] Use the same greeting as in other Magento Customer emails --- .../Magento/Customer/view/frontend/email/change_email.html | 7 +++---- .../view/frontend/email/change_email_and_password.html | 7 +++---- .../Customer/view/frontend/email/password_reset.html | 7 +++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Customer/view/frontend/email/change_email.html b/app/code/Magento/Customer/view/frontend/email/change_email.html index 4853adf638066..bd961ad99ec40 100644 --- a/app/code/Magento/Customer/view/frontend/email/change_email.html +++ b/app/code/Magento/Customer/view/frontend/email/change_email.html @@ -8,13 +8,12 @@ <!--@vars { "var store.frontend_name":"Store Name", "var store_email":"Store Email", -"var store_phone":"Store Phone" +"var store_phone":"Store Phone", +"var customer.name":"Customer Name" } @--> {{template config_path="design/email/header_template"}} -<p class="greeting">{{trans "Hello,"}}</p> -<br> - +<p class="greeting">{{trans "%name," name=$customer.name}}</p> <p> {{trans "We have received a request to change the following information associated with your account at %store_name: email." store_name=$store.frontend_name}} {{trans 'If you have not authorized this action, please contact us immediately at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}. diff --git a/app/code/Magento/Customer/view/frontend/email/change_email_and_password.html b/app/code/Magento/Customer/view/frontend/email/change_email_and_password.html index 49867bdedc9e0..4f5c85b2381f3 100644 --- a/app/code/Magento/Customer/view/frontend/email/change_email_and_password.html +++ b/app/code/Magento/Customer/view/frontend/email/change_email_and_password.html @@ -8,13 +8,12 @@ <!--@vars { "var store.frontend_name":"Store Name", "var store_email":"Store Email", -"var store_phone":"Store Phone" +"var store_phone":"Store Phone", +"var customer.name":"Customer Name" } @--> {{template config_path="design/email/header_template"}} -<p class="greeting">{{trans "Hello,"}}</p> -<br> - +<p class="greeting">{{trans "%name," name=$customer.name}}</p> <p> {{trans "We have received a request to change the following information associated with your account at %store_name: email, password." store_name=$store.frontend_name}} {{trans 'If you have not authorized this action, please contact us immediately at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}. diff --git a/app/code/Magento/Customer/view/frontend/email/password_reset.html b/app/code/Magento/Customer/view/frontend/email/password_reset.html index 79015117c2280..cab05a89227b6 100644 --- a/app/code/Magento/Customer/view/frontend/email/password_reset.html +++ b/app/code/Magento/Customer/view/frontend/email/password_reset.html @@ -9,13 +9,12 @@ "var customer.name":"Customer Name", "var store.frontend_name":"Store Name", "var store_email":"Store Email", -"var store_phone":"Store Phone" +"var store_phone":"Store Phone", +"var customer.name":"Customer Name" } @--> {{template config_path="design/email/header_template"}} -<p class="greeting">{{trans "Hello,"}}</p> -<br> - +<p class="greeting">{{trans "%name," name=$customer.name}}</p> <p> {{trans "We have received a request to change the following information associated with your account at %store_name: password." store_name=$store.frontend_name}} {{trans 'If you have not authorized this action, please contact us immediately at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}. From 60b7d4f313eb754e1afbfc4bc7d1739f52992534 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Sat, 4 Apr 2020 15:10:58 -0500 Subject: [PATCH 062/177] MQE-2066: [MTF-to-MFTF] Update Created Integration Entity #751 split files as per MFTF3.0.0 req and added test case ID --- .../Mftf/Section/AdminIntegrationsSection.xml | 30 ------------------- .../Test/AdminUpdateIntegrationEntityTest.xml | 1 + 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml diff --git a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml deleted file mode 100644 index 4af25b9be9714..0000000000000 --- a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?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="IntegrationsGridSection"> - <element name="add" type="button" selector=".page-actions .add"/> - <element name="messageByType" type="block" selector="#messages .message-{{messageType}}" parameterized="true"/> - <element name="name" type="input" selector=".data-grid-filters #integrationGrid_filter_name"/> - <element name="search" type="input" selector=".admin__filter-actions button[title=Search]"/> - <element name="remove" type="button" selector=".data-grid .delete"/> - <element name="submitButton" type="button" selector=".action-primary.action-accept" timeout="30"/> - <element name="rowByIndex" type="text" selector="tr[data-role='row']:nth-of-type({{var1}})" parameterized="true" timeout="30"/> - <element name="edit" type="button" selector=".data-grid .edit"/> - </section> - - <section name="AddNewIntegrationSection"> - <element name="name" type="input" selector="#integration_properties_name"/> - <element name="password" type="input" selector="#integration_properties_current_password"/> - <element name="saveButton" type="button" selector=".page-actions #save-split-button-button"/> - <element name="endpoint" type="input" selector="#integration_properties_endpoint"/> - <element name="linkUrl" type="input" selector="#integration_properties_identity_link_url"/> - <element name="save" type="button" selector=".page-actions-buttons .save"/> - </section> -</sections> diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml index 589a765a215e5..182ec2181e5be 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml @@ -15,6 +15,7 @@ <title value="Updating System Integration Entity"/> <description value="Admin Updates Created Integration"/> <group value="integration"/> + <testCaseId value="MC-4624"/> <group value="mtf_migrated"/> </annotations> <before> From 3443766ffdf8da626e894132ed57dc5af92691c7 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Sat, 4 Apr 2020 15:18:57 -0500 Subject: [PATCH 063/177] MQE-2066: [MTF-to-MFTF] Update Created Integration Entity #751 split files as per MFTF3.0.0 req and added test case ID --- .../AddNewIntegrationSection.xml | 18 +++++++++++++++++ .../IntegrationsGridSection.xml | 20 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection/AddNewIntegrationSection.xml create mode 100644 app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection/IntegrationsGridSection.xml diff --git a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection/AddNewIntegrationSection.xml b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection/AddNewIntegrationSection.xml new file mode 100644 index 0000000000000..2326b924bde8e --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection/AddNewIntegrationSection.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="AddNewIntegrationSection"> + <element name="name" type="input" selector="#integration_properties_name"/> + <element name="password" type="input" selector="#integration_properties_current_password"/> + <element name="saveButton" type="button" selector=".page-actions #save-split-button-button"/> + <element name="endpoint" type="input" selector="#integration_properties_endpoint"/> + <element name="linkUrl" type="input" selector="#integration_properties_identity_link_url"/> + <element name="save" type="button" selector=".page-actions-buttons .save"/> + </section> +</sections> diff --git a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection/IntegrationsGridSection.xml b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection/IntegrationsGridSection.xml new file mode 100644 index 0000000000000..613dec8a9474e --- /dev/null +++ b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection/IntegrationsGridSection.xml @@ -0,0 +1,20 @@ +<?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="IntegrationsGridSection"> + <element name="add" type="button" selector=".page-actions .add"/> + <element name="messageByType" type="block" selector="#messages .message-{{messageType}}" parameterized="true"/> + <element name="name" type="input" selector=".data-grid-filters #integrationGrid_filter_name"/> + <element name="search" type="input" selector=".admin__filter-actions button[title=Search]"/> + <element name="remove" type="button" selector=".data-grid .delete"/> + <element name="submitButton" type="button" selector=".action-primary.action-accept" timeout="30"/> + <element name="rowByIndex" type="text" selector="tr[data-role='row']:nth-of-type({{var1}})" parameterized="true" timeout="30"/> + <element name="edit" type="button" selector=".data-grid .edit"/> + </section> +</sections> From d1e749bd1688bca170bf94025a6da7e17fae5d28 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Sat, 4 Apr 2020 16:04:14 -0500 Subject: [PATCH 064/177] MQE-2066: [MTF-to-MFTF] Update Created Integration Entity #751 updated test case IDs --- .../Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml | 2 +- .../AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml index 182ec2181e5be..ab01f69308715 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml @@ -15,7 +15,7 @@ <title value="Updating System Integration Entity"/> <description value="Admin Updates Created Integration"/> <group value="integration"/> - <testCaseId value="MC-4624"/> + <testCaseId value="MC-14398"/> <group value="mtf_migrated"/> </annotations> <before> diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml index b8cc7bb19f7ea..59d70da4f9762 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml @@ -15,6 +15,7 @@ <title value="Updating System Integration Entity with Incorrect Password"/> <description value="Admin Updates Created Integration with Incorrect Password"/> <group value="integration"/> + <testCaseId value="MC-14399"/> <group value="mtf_migrated"/> </annotations> <before> From b24e329603abb5514c94964a15a38d509aaaf31d Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Sat, 4 Apr 2020 16:34:22 -0500 Subject: [PATCH 065/177] MQE-2067: [MTF-to-MFTF] [MTF-to-MFTF] Create Sitemap Entity #759 added test case ID --- .../Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml | 1 + ...t.xml => AdminMarketingCreateSitemapFailFolderSaveTest.xml} | 3 ++- .../Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) rename app/code/Magento/Sitemap/Test/Mftf/Test/{AdminMarketingCreateSitemapFailfFolderSaveTest.xml => AdminMarketingCreateSitemapFailFolderSaveTest.xml} (95%) diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml index 7753b03716371..edd20737eb0a7 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml @@ -14,6 +14,7 @@ <stories value="Admin Creates Sitemap Entity"/> <title value="Sitemap Creation"/> <description value="Sitemap Entity Creation"/> + <testCaseId value="MC-14312"/> <group value="sitemap"/> <group value="mtf_migrated"/> </annotations> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailfFolderSaveTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailFolderSaveTest.xml similarity index 95% rename from app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailfFolderSaveTest.xml rename to app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailFolderSaveTest.xml index b0669a690370e..530e813ae440a 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailfFolderSaveTest.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailFolderSaveTest.xml @@ -8,12 +8,13 @@ <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> - <test name="AdminMarketingCreateSitemapFailfFolderSaveTest"> + <test name="AdminMarketingCreateSitemapFailFolderSaveTest"> <annotations> <features value="Sitemap"/> <stories value="Admin Creates Sitemap Entity Fail Folder Save"/> <title value="Sitemap Creation Fail Folder Save"/> <description value="Sitemap Entity Creation Fail Folder Save"/> + <testCaseId value="MC-14314"/> <group value="sitemap"/> <group value="mtf_migrated"/> </annotations> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml index 6451080d62025..656502e09ad63 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml @@ -14,6 +14,7 @@ <stories value="Admin Creates Sitemap Entity Path Error"/> <title value="Sitemap Creation With Path Error"/> <description value="Sitemap Entity Creation With Path Error"/> + <testCaseId value="MC-14313"/> <group value="sitemap"/> <group value="mtf_migrated"/> </annotations> From 2ef17de8e92dbc2b0c3f884900058c9fb33dea3c Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Sat, 4 Apr 2020 16:59:41 -0500 Subject: [PATCH 066/177] MQE-2068: [MTF-to-MFTF] [MTF-to-MFTF] Convert Delete Sitemap Entity Test #764 added test case ID and merged mainline --- .../Test/Mftf/Test/AdminMarketingDeleteSitemapEntityTest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingDeleteSitemapEntityTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingDeleteSitemapEntityTest.xml index 54e7ed211636e..44698b7a6bb56 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingDeleteSitemapEntityTest.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingDeleteSitemapEntityTest.xml @@ -14,6 +14,7 @@ <stories value="Admin Deletes Sitemap Entity Test"/> <title value="Sitemap Deleting Test"/> <description value="Admin Should Delete Sitemap Entity"/> + <testCaseId value="MC-14315"/> <group value="sitemap"/> <group value="mtf_migrated"/> </annotations> From 0d1d42c362eafe7052e3863f1d5285dc1c6ca6e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Tylek?= <pawel.tylek@creativestyle.pl> Date: Sun, 5 Apr 2020 00:05:45 +0200 Subject: [PATCH 067/177] #27506 Fix zoom on search input --- .../blank/Magento_CatalogSearch/web/css/source/_module.less | 1 + .../luma/Magento_CatalogSearch/web/css/source/_module.less | 1 + 2 files changed, 2 insertions(+) diff --git a/app/design/frontend/Magento/blank/Magento_CatalogSearch/web/css/source/_module.less b/app/design/frontend/Magento/blank/Magento_CatalogSearch/web/css/source/_module.less index daed96db717c7..780abd250301a 100644 --- a/app/design/frontend/Magento/blank/Magento_CatalogSearch/web/css/source/_module.less +++ b/app/design/frontend/Magento/blank/Magento_CatalogSearch/web/css/source/_module.less @@ -65,6 +65,7 @@ } input { + font-size: 16px; left: -300%; margin: 15px 0; position: absolute; diff --git a/app/design/frontend/Magento/luma/Magento_CatalogSearch/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_CatalogSearch/web/css/source/_module.less index 2176fcd241916..9a85e3a02712c 100644 --- a/app/design/frontend/Magento/luma/Magento_CatalogSearch/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_CatalogSearch/web/css/source/_module.less @@ -80,6 +80,7 @@ } input { + font-size: 16px; left: -300%; margin: 15px 0; position: absolute; From 2ed8b4dd5bdda29aed539f2a9b1b5565ef829640 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Sat, 4 Apr 2020 18:43:38 -0500 Subject: [PATCH 068/177] MQE-2069: [MTF-to-MFTF] Create Newsletter Template Entity #761 updated test case id --- .../Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml index 2e6947e51df10..deabe4d611cb7 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml @@ -16,6 +16,7 @@ <description value="Newsletter Template Successfully Created"/> <group value="newsletter"/> <group value="mtf_migrated"/> + <testCaseId value="MC-14315"/> </annotations> <before> <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> From b7467022b7e934f7cd3045dc1697331db8e3e97c Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Sat, 4 Apr 2020 18:49:55 -0500 Subject: [PATCH 069/177] MQE-2069: [MTF-to-MFTF] Create Newsletter Template Entity #761 updated test case id --- .../Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml index deabe4d611cb7..525fd70d03f8e 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml @@ -16,7 +16,7 @@ <description value="Newsletter Template Successfully Created"/> <group value="newsletter"/> <group value="mtf_migrated"/> - <testCaseId value="MC-14315"/> + <testCaseId value="MC-29809"/> </annotations> <before> <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> From b35f446931cac2a1023bf188717f02dcd10d87db Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Sat, 4 Apr 2020 19:35:26 -0500 Subject: [PATCH 070/177] Merge remote-tracking branch 'origin/PR-762' into migration-pr # Conflicts: # app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminMarketingOpenNewsletterTemplateFromGridActionGroup.xml # app/code/Magento/Newsletter/Test/Mftf/ActionGroup/AdminNavigateToCreateNewsletterTemplatePageActionGroup.xml # app/code/Magento/Newsletter/Test/Mftf/Data/NewsletterTemplateData.xml --- ...ReAuthorizeTokensIntegrationEntityTest.xml | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml index bb61527ecab74..3387f1137adc8 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml @@ -65,9 +65,21 @@ <argument name="name" value="{{defaultIntegrationData.name}}"/> </actionGroup> <actionGroup ref="AdminIntegrationOpenExistingEntityActionGroup" stepKey="openIntegrationEntity"/> - <assertEquals stepKey="assertConsumerKey" expected="($grabConsumerKey)" actual="$grabAfterReauthorizeConsumerKey" actualType="string"/> - <assertEquals stepKey="assertConsumerSecret" expected="($grabConsumerSecret)" actual="$grabAfterReauthorizeConsumerSecret" actualType="string"/> - <assertNotEquals stepKey="assertNotEqualsToken" expected="($grabAccessToken)" actual="$grabReauthorizedAccessToken" actualType="string"/> - <assertNotEquals stepKey="assertNotEqualsTokenSecret" expected="($grabAccessTokenSecret)" actual="$grabReauthorizedAccessTokenSecret" actualType="string"/> + <assertEquals stepKey="assertConsumerKey"> + <actualResult type="string">$grabAfterReauthorizeConsumerKey</actualResult> + <expectedResult type="const">($grabConsumerKey)</expectedResult> + </assertEquals> + <assertEquals stepKey="assertConsumerSecret"> + <actualResult type="string">$grabAfterReauthorizeConsumerSecret</actualResult> + <expectedResult type="const">($grabConsumerSecret)</expectedResult> + </assertEquals> + <assertNotEquals stepKey="assertNotEqualsToken"> + <actualResult type="string">$grabReauthorizedAccessToken</actualResult> + <expectedResult type="const">($grabAccessToken)</expectedResult> + </assertNotEquals> + <assertNotEquals stepKey="assertNotEqualsTokenSecret"> + <actualResult type="string">$grabReauthorizedAccessTokenSecret</actualResult> + <expectedResult type="const">($grabAccessTokenSecret)</expectedResult> + </assertNotEquals> </test> </tests> From 787777659f75a89da019abc9dca92eb0d33b4ca4 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Sat, 4 Apr 2020 19:40:10 -0500 Subject: [PATCH 071/177] MQE-2071: [MTF-to-MFTF] Re-Authorize Tokens Integration Entity #765 Added test case Id --- .../Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml index 3387f1137adc8..480cc4b8861d3 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminReAuthorizeTokensIntegrationEntityTest.xml @@ -16,6 +16,7 @@ <description value="ReAuthorising Tokens For Created Integration"/> <group value="integration"/> <group value="mtf_migrated"/> + <testCaseId value="MC-14397"/> </annotations> <before> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> From 16cb18d7edaf504e7de2899f6935d33f8fcc42d9 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Sun, 5 Apr 2020 03:35:23 +0200 Subject: [PATCH 072/177] magento/magento2#27589 Cover with Integration Tests the template changes. --- .../Controller/Account/EmailTemplateTest.php | 199 ++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Controller/Account/EmailTemplateTest.php diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Account/EmailTemplateTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Account/EmailTemplateTest.php new file mode 100644 index 0000000000000..a2edf0f0f40da --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Account/EmailTemplateTest.php @@ -0,0 +1,199 @@ +<?php +declare(strict_types=1); + +namespace Magento\Customer\Controller\Account; + +use Magento\Customer\Model\Session; +use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\Data\Form\FormKey; +use Magento\Framework\Mail\EmailMessage; +use Magento\Framework\Message\MessageInterface; +use Magento\TestFramework\Mail\Template\TransportBuilderMock; +use Magento\TestFramework\TestCase\AbstractController; + +/** + * Set of tests to verify e-mail templates delivered to Customers + * + * @magentoAppArea frontend + */ +class EmailTemplateTest extends AbstractController +{ + private const FIXTURE_CUSTOMER_EMAIL = 'customer@example.com'; + private const FIXTURE_CUSTOMER_FIRSTNAME = 'John'; + private const FIXTURE_CUSTOMER_LASTNAME = 'Smith'; + private const FIXTURE_CUSTOMER_ID = 1; + private const FIXTURE_CUSTOMER_PASSWORD = 'password'; + private const EXPECTED_GREETING = self::FIXTURE_CUSTOMER_FIRSTNAME . ' ' . self::FIXTURE_CUSTOMER_LASTNAME . ','; + + /** + * @var TransportBuilderMock + */ + private $transportBuilderMock; + + /** + * @var Session + */ + private $session; + + /** + * @var FormKey + */ + private $formKey; + + protected function setUp() + { + parent::setUp(); + $this->transportBuilderMock = $this->_objectManager->get(TransportBuilderMock::class); + $this->session = $this->_objectManager->get(Session::class); + $this->formKey = $this->_objectManager->get(FormKey::class); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoConfigFixture current_store customer/captcha/enable 0 + */ + public function testForgotPasswordEmailTemplateGreeting() + { + $this->getRequest()->setMethod(HttpRequest::METHOD_POST) + ->setPostValue(['email' => self::FIXTURE_CUSTOMER_EMAIL]); + $this->dispatch('customer/account/forgotPasswordPost'); + + $this->assertSameGreeting(self::EXPECTED_GREETING, $this->transportBuilderMock->getSentMessage()); + } + + /** + * @covers Magento_Customer::view/frontend/email/change_email.html + * + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoConfigFixture current_store customer/captcha/enable 0 + */ + public function testCustomerEmailChangeNotificationTemplateGreeting() + { + $this->loginByCustomerId(self::FIXTURE_CUSTOMER_ID); + + $this->sendAccountEditRequest([ + 'email' => 'new.email@example.com', + 'change_email' => 1, + ]); + + $this->assertRedirect($this->stringContains('customer/account/')); + $this->assertSessionMessages( + $this->equalTo(['You saved the account information.']), + MessageInterface::TYPE_SUCCESS + ); + + $this->assertSameGreeting(self::EXPECTED_GREETING, $this->transportBuilderMock->getSentMessage()); + } + + /** + * @covers Magento_Customer::view/frontend/email/change_email_and_password.html + * + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoConfigFixture current_store customer/captcha/enable 0 + */ + public function testCustomerEmailAndPasswordChangeNotificationTemplateGreeting() + { + $this->loginByCustomerId(self::FIXTURE_CUSTOMER_ID); + + $this->sendAccountEditRequest([ + 'email' => 'new.email@example.com', + 'change_email' => 1, + 'change_password' => 1, + 'password' => 'new-Password1', + 'password_confirmation' => 'new-Password1', + ]); + + $this->assertRedirect($this->stringContains('customer/account/')); + $this->assertSessionMessages( + $this->equalTo(['You saved the account information.']), + MessageInterface::TYPE_SUCCESS + ); + + $this->assertSameGreeting(self::EXPECTED_GREETING, $this->transportBuilderMock->getSentMessage()); + } + + /** + * @covers Magento_Customer::view/frontend/email/change_password.html + * + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoConfigFixture current_store customer/captcha/enable 0 + */ + public function testCustomerPasswordChangeNotificationTemplateGreeting() + { + $this->loginByCustomerId(self::FIXTURE_CUSTOMER_ID); + + $this->sendAccountEditRequest([ + 'change_password' => 1, + 'password' => 'new-Password1', + 'password_confirmation' => 'new-Password1', + ]); + + $this->assertRedirect($this->stringContains('customer/account/')); + $this->assertSessionMessages( + $this->equalTo(['You saved the account information.']), + MessageInterface::TYPE_SUCCESS + ); + + $this->assertSameGreeting(self::EXPECTED_GREETING, $this->transportBuilderMock->getSentMessage()); + } + + /** + * Wraps Customer Edit POST request + * + * @param array $customData + */ + private function sendAccountEditRequest(array $customData): void + { + $basicData = [ + 'form_key' => $this->formKey->getFormKey(), + 'firstname' => self::FIXTURE_CUSTOMER_FIRSTNAME, + 'lastname' => self::FIXTURE_CUSTOMER_LASTNAME, + 'current_password' => self::FIXTURE_CUSTOMER_PASSWORD + ]; + + $this->getRequest()->setMethod(HttpRequest::METHOD_POST) + ->setPostValue(array_merge($basicData, $customData)); + + $this->dispatch('customer/account/editPost'); + } + + /** + * Verifies if `<p class="greeting"/>` text contents equals the expected one. + * + * @param string $expectedGreeting + * @param EmailMessage $message + */ + private function assertSameGreeting(string $expectedGreeting, EmailMessage $message) + { + $messageContent = $this->getMessageRawContent($message); + $emailDom = new \DOMDocument(); + $emailDom->loadHTML($messageContent); + + $emailXpath = new \DOMXPath($emailDom); + $greeting = $emailXpath->query('//p[@class="greeting"]')->item(0); + + $this->assertSame($expectedGreeting, $greeting->textContent); + } + + /** + * Returns raw content of provided message + * + * @param EmailMessage $message + * @return string + */ + private function getMessageRawContent(EmailMessage $message): string + { + $emailParts = $message->getBody()->getParts(); + return current($emailParts)->getRawContent(); + } + + /** + * Performs Customer log in + * + * @param int $customerId + */ + private function loginByCustomerId(int $customerId): void + { + $this->session->loginById($customerId); + } +} From f882122a3280f3b60706f87d9428f75b11a80112 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Sun, 5 Apr 2020 04:00:49 +0200 Subject: [PATCH 073/177] magento/magento2#27589 Expect exactly one greeting in the Template --- .../Customer/Controller/Account/EmailTemplateTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Account/EmailTemplateTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Account/EmailTemplateTest.php index a2edf0f0f40da..6aa1e49174313 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Account/EmailTemplateTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Account/EmailTemplateTest.php @@ -170,9 +170,10 @@ private function assertSameGreeting(string $expectedGreeting, EmailMessage $mess $emailDom->loadHTML($messageContent); $emailXpath = new \DOMXPath($emailDom); - $greeting = $emailXpath->query('//p[@class="greeting"]')->item(0); + $greeting = $emailXpath->query('//p[@class="greeting"]'); - $this->assertSame($expectedGreeting, $greeting->textContent); + $this->assertSame(1, $greeting->length); + $this->assertSame($expectedGreeting, $greeting->item(0)->textContent); } /** From 82224a62f63955d1c070e2509298e27acc52cdd4 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Sun, 5 Apr 2020 04:36:22 +0200 Subject: [PATCH 074/177] magento/magento2#27589 Fix Static Tests --- .../Customer/Controller/Account/EmailTemplateTest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Account/EmailTemplateTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Account/EmailTemplateTest.php index 6aa1e49174313..ac12dc4df8d64 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Account/EmailTemplateTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Account/EmailTemplateTest.php @@ -1,4 +1,8 @@ <?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ declare(strict_types=1); namespace Magento\Customer\Controller\Account; @@ -62,7 +66,7 @@ public function testForgotPasswordEmailTemplateGreeting() } /** - * @covers Magento_Customer::view/frontend/email/change_email.html + * Covers Magento_Customer::view/frontend/email/change_email.html * * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoConfigFixture current_store customer/captcha/enable 0 @@ -86,7 +90,7 @@ public function testCustomerEmailChangeNotificationTemplateGreeting() } /** - * @covers Magento_Customer::view/frontend/email/change_email_and_password.html + * Covers Magento_Customer::view/frontend/email/change_email_and_password.html * * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoConfigFixture current_store customer/captcha/enable 0 @@ -113,7 +117,7 @@ public function testCustomerEmailAndPasswordChangeNotificationTemplateGreeting() } /** - * @covers Magento_Customer::view/frontend/email/change_password.html + * Covers Magento_Customer::view/frontend/email/change_password.html * * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoConfigFixture current_store customer/captcha/enable 0 From b90be0bb3094cd6a08a0a37aecb0f3b01c615c4b Mon Sep 17 00:00:00 2001 From: engcom-Echo <engcom-vendorworker-echo@adobe.com> Date: Mon, 6 Apr 2020 14:15:12 +0300 Subject: [PATCH 075/177] Coverage unit test --- .../Test/Unit/Model/EmailNotificationTest.php | 266 +++++++++++------- 1 file changed, 162 insertions(+), 104 deletions(-) diff --git a/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php b/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php index ff83ef62c6aa7..c09edcb40a6e3 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php @@ -3,88 +3,99 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Customer\Test\Unit\Model; use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Customer\Helper\View; +use Magento\Customer\Model\CustomerRegistry; +use Magento\Customer\Model\Data\CustomerSecure; use Magento\Customer\Model\EmailNotification; use Magento\Framework\App\Area; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\Helper\Context; use Magento\Framework\Mail\Template\SenderResolverInterface; +use Magento\Framework\Mail\Template\TransportBuilder; +use Magento\Framework\Mail\TransportInterface; +use Magento\Framework\Reflection\DataObjectProcessor; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Store\Model\ScopeInterface; +use Magento\Store\Model\Store; +use Magento\Store\Model\StoreManagerInterface; +use Magento\Store\Model\Website; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; /** - * Class EmailNotificationTest + * Verify EmailNotificationTest * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class EmailNotificationTest extends \PHPUnit\Framework\TestCase +class EmailNotificationTest extends TestCase { /** - * @var \Magento\Customer\Model\CustomerRegistry|\PHPUnit_Framework_MockObject_MockObject + * @var CustomerRegistry|MockObject */ private $customerRegistryMock; /** - * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var StoreManagerInterface|MockObject */ private $storeManagerMock; /** - * @var \Magento\Framework\Mail\Template\TransportBuilder|\PHPUnit_Framework_MockObject_MockObject + * @var TransportBuilder|MockObject */ private $transportBuilderMock; /** - * @var \Magento\Customer\Helper\View|\PHPUnit_Framework_MockObject_MockObject + * @var View|MockObject */ private $customerViewHelperMock; /** - * @var \Magento\Framework\Reflection\DataObjectProcessor|\PHPUnit_Framework_MockObject_MockObject + * @var DataObjectProcessor|MockObject */ private $dataProcessorMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Customer\Model\Data\CustomerSecure + * @var CustomerSecure|MockObject */ private $customerSecureMock; /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + * @var ScopeConfigInterface|MockObject */ private $scopeConfigMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\Store + * @var Store|MockObject */ private $storeMock; /** - * @var \Magento\Customer\Model\EmailNotification + * @var SenderResolverInterface|MockObject */ - private $model; + private $senderResolverMock; /** - * @var SenderResolverInterface|\PHPUnit_Framework_MockObject_MockObject + * @var EmailNotification */ - private $senderResolverMock; + private $model; public function setUp() { - $this->customerRegistryMock = $this->createMock(\Magento\Customer\Model\CustomerRegistry::class); - - $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->customerRegistryMock = $this->createMock(CustomerRegistry::class); + $this->storeManagerMock = $this->createMock(StoreManagerInterface::class); + $this->transportBuilderMock = $this->createMock(TransportBuilder::class); + $this->customerViewHelperMock = $this->createMock(View::class); + $this->dataProcessorMock = $this->createMock(DataObjectProcessor::class); - $this->transportBuilderMock = $this->createMock(\Magento\Framework\Mail\Template\TransportBuilder::class); - - $this->customerViewHelperMock = $this->createMock(\Magento\Customer\Helper\View::class); - - $this->dataProcessorMock = $this->createMock(\Magento\Framework\Reflection\DataObjectProcessor::class); - - $contextMock = $this->createPartialMock(\Magento\Framework\App\Helper\Context::class, ['getScopeConfig']); + $contextMock = $this->createPartialMock(Context::class, ['getScopeConfig']); $this->scopeConfigMock = $this->createPartialMock( - \Magento\Framework\App\Config\ScopeConfigInterface::class, + ScopeConfigInterface::class, ['getValue', 'isSetFlag'] ); @@ -92,16 +103,16 @@ public function setUp() ->method('getScopeConfig') ->willReturn($this->scopeConfigMock); - $this->customerSecureMock = $this->createMock(\Magento\Customer\Model\Data\CustomerSecure::class); + $this->customerSecureMock = $this->createMock(CustomerSecure::class); - $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class); + $this->storeMock = $this->createMock(Store::class); $this->senderResolverMock = $this->getMockBuilder(SenderResolverInterface::class) ->setMethods(['resolve']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $objectManager = new ObjectManager($this); $this->model = $objectManager->getObject( EmailNotification::class, @@ -119,6 +130,7 @@ public function setUp() /** * @param int $testNumber + * @param int $customerStoreId * @param string $oldEmail * @param string $newEmail * @param bool $isPasswordChanged @@ -126,11 +138,9 @@ public function setUp() * @dataProvider sendNotificationEmailsDataProvider * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPasswordChanged) + public function testCredentialsChanged($testNumber, $customerStoreId, $oldEmail, $newEmail, $isPasswordChanged) { $customerId = 1; - $customerStoreId = 2; - $customerWebsiteId = 1; $customerData = ['key' => 'value']; $customerName = 'Customer Name'; $templateIdentifier = 'Template Identifier'; @@ -145,7 +155,7 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas $expects = $this->once(); break; case 2: - $xmlPathTemplate = \Magento\Customer\Model\EmailNotification::XML_PATH_CHANGE_EMAIL_TEMPLATE; + $xmlPathTemplate = EmailNotification::XML_PATH_CHANGE_EMAIL_TEMPLATE; $expects = $this->exactly(2); break; case 3: @@ -160,19 +170,18 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas ->with($sender, $customerStoreId) ->willReturn($senderValues); - /** @var \PHPUnit_Framework_MockObject_MockObject $origCustomer */ - $origCustomer = $this->createMock(CustomerInterface::class); - $origCustomer->expects($this->any()) + /** @var MockObject $origCustomerMock */ + $origCustomerMock = $this->createMock(CustomerInterface::class); + $origCustomerMock->expects($this->any()) ->method('getStoreId') - ->willReturn(0); - $origCustomer->expects($this->any()) + ->willReturn($customerStoreId); + $origCustomerMock->expects($this->any()) ->method('getId') ->willReturn($customerId); - $origCustomer->expects($this->any()) - ->method('getWebsiteId') - ->willReturn($customerWebsiteId); + $origCustomerMock->expects($this->never()) + ->method('getWebsiteId'); - $storeMock = $this->createMock(\Magento\Store\Model\Store::class); + $storeMock = $this->createMock(Store::class); $storeMock->expects($this->any()) ->method('getId') ->willReturn($customerStoreId); @@ -181,17 +190,12 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas ->method('getStore') ->willReturn($storeMock); - $websiteMock = $this->createPartialMock(\Magento\Store\Model\Website::class, ['getStoreIds']); + $websiteMock = $this->createPartialMock(Website::class, ['getStoreIds']); $websiteMock->expects($this->any()) ->method('getStoreIds') ->willReturn([$customerStoreId]); - $this->storeManagerMock->expects(clone $expects) - ->method('getWebsite') - ->with($customerWebsiteId) - ->willReturn($websiteMock); - - $customerSecureMock = $this->createMock(\Magento\Customer\Model\Data\CustomerSecure::class); + $customerSecureMock = $this->createMock(CustomerSecure::class); $this->customerRegistryMock->expects(clone $expects) ->method('retrieveSecureData') ->with($customerId) @@ -199,12 +203,12 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas $this->dataProcessorMock->expects(clone $expects) ->method('buildOutputDataArray') - ->with($origCustomer, CustomerInterface::class) + ->with($origCustomerMock, CustomerInterface::class) ->willReturn($customerData); $this->customerViewHelperMock->expects($this->any()) ->method('getCustomerName') - ->with($origCustomer) + ->with($origCustomerMock) ->willReturn($customerName); $customerSecureMock->expects(clone $expects) @@ -216,30 +220,30 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas ->with('name', $customerName) ->willReturnSelf(); - /** @var CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $savedCustomer */ - $savedCustomer = clone $origCustomer; + /** @var CustomerInterface|MockObject $savedCustomerMock */ + $savedCustomerMock = clone $origCustomerMock; - $origCustomer->expects($this->any()) + $origCustomerMock->expects($this->any()) ->method('getEmail') ->willReturn($oldEmail); - $savedCustomer->expects($this->any()) + $savedCustomerMock->expects($this->any()) ->method('getEmail') ->willReturn($newEmail); $this->scopeConfigMock->expects($this->any()) ->method('getValue') ->withConsecutive( - [$xmlPathTemplate, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $customerStoreId], + [$xmlPathTemplate, ScopeInterface::SCOPE_STORE, $customerStoreId], [ - \Magento\Customer\Model\EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, + ScopeInterface::SCOPE_STORE, $customerStoreId ], - [$xmlPathTemplate, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $customerStoreId], + [$xmlPathTemplate, ScopeInterface::SCOPE_STORE, $customerStoreId], [ - \Magento\Customer\Model\EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, + ScopeInterface::SCOPE_STORE, $customerStoreId ] ) @@ -251,7 +255,7 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas ->willReturnSelf(); $this->transportBuilderMock->expects(clone $expects) ->method('setTemplateOptions') - ->with(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $customerStoreId]) + ->with(['area' => Area::AREA_FRONTEND, 'store' => $customerStoreId]) ->willReturnSelf(); $this->transportBuilderMock->expects(clone $expects) ->method('setTemplateVars') @@ -267,7 +271,7 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas ->withConsecutive([$oldEmail, $customerName], [$newEmail, $customerName]) ->willReturnSelf(); - $transport = $this->createMock(\Magento\Framework\Mail\TransportInterface::class); + $transport = $this->createMock(TransportInterface::class); $this->transportBuilderMock->expects(clone $expects) ->method('getTransport') @@ -276,7 +280,7 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas $transport->expects(clone $expects) ->method('sendMessage'); - $this->model->credentialsChanged($savedCustomer, $oldEmail, $isPasswordChanged); + $this->model->credentialsChanged($savedCustomerMock, $oldEmail, $isPasswordChanged); } /** @@ -287,18 +291,42 @@ public function sendNotificationEmailsDataProvider() return [ [ 'test_number' => 1, + 'customerStoreId' => 0, + 'old_email' => 'test@example.com', + 'new_email' => 'test@example.com', + 'is_password_changed' => true + ], + [ + 'test_number' => 1, + 'customerStoreId' => 2, 'old_email' => 'test@example.com', 'new_email' => 'test@example.com', 'is_password_changed' => true ], [ 'test_number' => 2, + 'customerStoreId' => 0, + 'old_email' => 'test1@example.com', + 'new_email' => 'test2@example.com', + 'is_password_changed' => false + ], + [ + 'test_number' => 2, + 'customerStoreId' => 2, 'old_email' => 'test1@example.com', 'new_email' => 'test2@example.com', 'is_password_changed' => false ], [ 'test_number' => 3, + 'customerStoreId' => 0, + 'old_email' => 'test1@example.com', + 'new_email' => 'test2@example.com', + 'is_password_changed' => true + ], + [ + 'test_number' => 3, + 'customerStoreId' => 2, 'old_email' => 'test1@example.com', 'new_email' => 'test2@example.com', 'is_password_changed' => true @@ -307,13 +335,15 @@ public function sendNotificationEmailsDataProvider() } /** + * @param int $customerStoreId + * @dataProvider customerStoreIdDataProvider + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testPasswordReminder() + public function testPasswordReminder($customerStoreId):void { $customerId = 1; $customerWebsiteId = 1; - $customerStoreId = 2; $customerEmail = 'email@email.com'; $customerData = ['key' => 'value']; $customerName = 'Customer Name'; @@ -328,18 +358,17 @@ public function testPasswordReminder() ->with($sender, $customerStoreId) ->willReturn($senderValues); - /** @var CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customer */ - $customer = $this->createMock(CustomerInterface::class); - $customer->expects($this->any()) - ->method('getWebsiteId') - ->willReturn($customerWebsiteId); - $customer->expects($this->any()) + /** @var CustomerInterface|MockObject $customerMock */ + $customerMock = $this->createMock(CustomerInterface::class); + $customerMock->expects($this->never()) + ->method('getWebsiteId'); + $customerMock->expects($this->any()) ->method('getStoreId') ->willReturn($customerStoreId); - $customer->expects($this->any()) + $customerMock->expects($this->any()) ->method('getId') ->willReturn($customerId); - $customer->expects($this->any()) + $customerMock->expects($this->any()) ->method('getEmail') ->willReturn($customerEmail); @@ -351,7 +380,10 @@ public function testPasswordReminder() ->method('getStore') ->willReturn($this->storeMock); - $websiteMock = $this->createPartialMock(\Magento\Store\Model\Website::class, ['getStoreIds']); + $websiteMock = $this->createPartialMock( + Website::class, + ['getStoreIds'] + ); $websiteMock->expects($this->any()) ->method('getStoreIds') ->willReturn($storeIds); @@ -368,12 +400,12 @@ public function testPasswordReminder() $this->dataProcessorMock->expects($this->once()) ->method('buildOutputDataArray') - ->with($customer, CustomerInterface::class) + ->with($customerMock, CustomerInterface::class) ->willReturn($customerData); $this->customerViewHelperMock->expects($this->any()) ->method('getCustomerName') - ->with($customer) + ->with($customerMock) ->willReturn($customerName); $this->customerSecureMock->expects($this->once()) @@ -403,13 +435,14 @@ public function testPasswordReminder() ['customer' => $this->customerSecureMock, 'store' => $this->storeMock] ); - $this->model->passwordReminder($customer); + $this->model->passwordReminder($customerMock); } /** + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testPasswordReminderCustomerWithoutStoreId() + public function testPasswordReminderCustomerWithoutStoreId():void { $customerId = 1; $customerWebsiteId = 1; @@ -427,18 +460,18 @@ public function testPasswordReminderCustomerWithoutStoreId() ->method('resolve') ->with($sender, $defaultStoreId) ->willReturn($senderValues); - /** @var CustomerInterface | \PHPUnit_Framework_MockObject_MockObject $customer */ - $customer = $this->createMock(CustomerInterface::class); - $customer->expects($this->any()) + /** @var CustomerInterface | MockObject $customerMock */ + $customerMock = $this->createMock(CustomerInterface::class); + $customerMock->expects($this->any()) ->method('getWebsiteId') ->willReturn($customerWebsiteId); - $customer->expects($this->any()) + $customerMock->expects($this->any()) ->method('getStoreId') ->willReturn($customerStoreId); - $customer->expects($this->any()) + $customerMock->expects($this->any()) ->method('getId') ->willReturn($customerId); - $customer->expects($this->any()) + $customerMock->expects($this->any()) ->method('getEmail') ->willReturn($customerEmail); $this->storeMock->expects($this->any()) @@ -451,7 +484,7 @@ public function testPasswordReminderCustomerWithoutStoreId() ->method('getStore') ->with($defaultStoreId) ->willReturn($this->storeMock); - $websiteMock = $this->createPartialMock(\Magento\Store\Model\Website::class, ['getStoreIds']); + $websiteMock = $this->createPartialMock(Website::class, ['getStoreIds']); $websiteMock->expects($this->any()) ->method('getStoreIds') ->willReturn($storeIds); @@ -466,11 +499,11 @@ public function testPasswordReminderCustomerWithoutStoreId() ->willReturn($this->customerSecureMock); $this->dataProcessorMock->expects($this->once()) ->method('buildOutputDataArray') - ->with($customer, CustomerInterface::class) + ->with($customerMock, CustomerInterface::class) ->willReturn($customerData); $this->customerViewHelperMock->expects($this->any()) ->method('getCustomerName') - ->with($customer) + ->with($customerMock) ->willReturn($customerName); $this->customerSecureMock->expects($this->once()) ->method('addData') @@ -496,16 +529,18 @@ public function testPasswordReminderCustomerWithoutStoreId() $customerName, ['customer' => $this->customerSecureMock, 'store' => $this->storeMock] ); - $this->model->passwordReminder($customer); + $this->model->passwordReminder($customerMock); } /** + * @dataProvider customerStoreIdDataProvider + * @param int $customerStoreId + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testPasswordResetConfirmation() + public function testPasswordResetConfirmation($customerStoreId):void { $customerId = 1; - $customerStoreId = 2; $customerEmail = 'email@email.com'; $customerData = ['key' => 'value']; $customerName = 'Customer Name'; @@ -519,15 +554,19 @@ public function testPasswordResetConfirmation() ->with($sender, $customerStoreId) ->willReturn($senderValues); - /** @var CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customer */ - $customer = $this->createMock(CustomerInterface::class); - $customer->expects($this->once()) + /** @var CustomerInterface|MockObject $customerMock */ + $customerMock = $this->createMock(CustomerInterface::class); + + $customerMock->expects($this->never()) + ->method('getWebsiteId'); + + $customerMock->expects($this->once()) ->method('getStoreId') ->willReturn($customerStoreId); - $customer->expects($this->any()) + $customerMock->expects($this->any()) ->method('getId') ->willReturn($customerId); - $customer->expects($this->any()) + $customerMock->expects($this->any()) ->method('getEmail') ->willReturn($customerEmail); @@ -546,12 +585,12 @@ public function testPasswordResetConfirmation() $this->dataProcessorMock->expects($this->once()) ->method('buildOutputDataArray') - ->with($customer, CustomerInterface::class) + ->with($customerMock, CustomerInterface::class) ->willReturn($customerData); $this->customerViewHelperMock->expects($this->any()) ->method('getCustomerName') - ->with($customer) + ->with($customerMock) ->willReturn($customerName); $this->customerSecureMock->expects($this->once()) @@ -581,16 +620,18 @@ public function testPasswordResetConfirmation() ['customer' => $this->customerSecureMock, 'store' => $this->storeMock] ); - $this->model->passwordResetConfirmation($customer); + $this->model->passwordResetConfirmation($customerMock); } /** + * @dataProvider customerStoreIdDataProvider + * @param int $customerStoreId + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testNewAccount() + public function testNewAccount($customerStoreId):void { $customerId = 1; - $customerStoreId = 2; $customerEmail = 'email@email.com'; $customerData = ['key' => 'value']; $customerName = 'Customer Name'; @@ -604,8 +645,12 @@ public function testNewAccount() ->with($sender, $customerStoreId) ->willReturn($senderValues); - /** @var CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customer */ + /** @var CustomerInterface|MockObject $customer */ $customer = $this->createMock(CustomerInterface::class); + + $customer->expects($this->never()) + ->method('getWebsiteId'); + $customer->expects($this->any()) ->method('getStoreId') ->willReturn($customerStoreId); @@ -670,6 +715,19 @@ public function testNewAccount() $this->model->newAccount($customer, EmailNotification::NEW_ACCOUNT_EMAIL_REGISTERED, '', $customerStoreId); } + /** + * DataProvider customer store + * + * @return array + */ + public function customerStoreIdDataProvider():array + { + return [ + ['customerStoreId' => 0], + ['customerStoreId' => 2] + ]; + } + /** * Create default mock for $this->transportBuilderMock. * @@ -690,7 +748,7 @@ private function mockDefaultTransportBuilder( string $customerName, array $templateVars = [] ): void { - $transport = $this->createMock(\Magento\Framework\Mail\TransportInterface::class); + $transportMock = $this->createMock(TransportInterface::class); $this->transportBuilderMock->expects($this->once()) ->method('setTemplateIdentifier') @@ -714,9 +772,9 @@ private function mockDefaultTransportBuilder( ->willReturnSelf(); $this->transportBuilderMock->expects($this->once()) ->method('getTransport') - ->willReturn($transport); + ->willReturn($transportMock); - $transport->expects($this->once()) + $transportMock->expects($this->once()) ->method('sendMessage'); } } From 0941297845e67161f338fc03be48932bde1bfbe6 Mon Sep 17 00:00:00 2001 From: Viktor Petryk <victor.petryk@transoftgroup.com> Date: Mon, 6 Apr 2020 15:50:33 +0300 Subject: [PATCH 076/177] MC-24186: Inline translation doesn't work on frontend --- .../Magento/Translation/Model/FileManager.php | 39 +++++++--- .../Translation/Model/Inline/CacheManager.php | 5 +- .../Translation/Model/Inline/Renderer.php | 24 ++++++ .../AdminTranslateElementActionGroup.xml | 6 +- ...tFillCustomTranslationFieldActionGroup.xml | 22 ++++++ ...tOpenInlineTranslationPopupActionGroup.xml | 24 ++++++ ...SubmitInlineTranslationFormActionGroup.xml | 20 +++++ ...StorefrontButtonsInlineTranslationTest.xml | 53 ++++++------- app/code/Magento/Translation/etc/di.xml | 12 +++ .../Translation/Model/Js/DataProviderTest.php | 74 +++++++++++++++++++ 10 files changed, 234 insertions(+), 45 deletions(-) create mode 100644 app/code/Magento/Translation/Model/Inline/Renderer.php create mode 100644 app/code/Magento/Translation/Test/Mftf/ActionGroup/StorefrontFillCustomTranslationFieldActionGroup.xml create mode 100644 app/code/Magento/Translation/Test/Mftf/ActionGroup/StorefrontOpenInlineTranslationPopupActionGroup.xml create mode 100644 app/code/Magento/Translation/Test/Mftf/ActionGroup/StorefrontSubmitInlineTranslationFormActionGroup.xml create mode 100644 dev/tests/integration/testsuite/Magento/Translation/Model/Js/DataProviderTest.php diff --git a/app/code/Magento/Translation/Model/FileManager.php b/app/code/Magento/Translation/Model/FileManager.php index 95fb3f2a5d4e9..4690fae763bfa 100644 --- a/app/code/Magento/Translation/Model/FileManager.php +++ b/app/code/Magento/Translation/Model/FileManager.php @@ -9,10 +9,11 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Filesystem\Driver\File; +use Magento\Framework\Serialize\Serializer\Json; use Magento\Framework\View\Asset\Repository; /** - * A service for handling Translation config files + * A service for handling Translation config files. */ class FileManager { @@ -36,23 +37,31 @@ class FileManager */ private $driverFile; + /** + * @var Json + */ + private $serializer; + /** * @param Repository $assetRepo * @param DirectoryList $directoryList * @param File $driverFile + * @param Json $serializer */ public function __construct( Repository $assetRepo, DirectoryList $directoryList, - File $driverFile + File $driverFile, + Json $serializer ) { $this->assetRepo = $assetRepo; $this->directoryList = $directoryList; $this->driverFile = $driverFile; + $this->serializer = $serializer; } /** - * Create a view asset representing the requirejs config.config property for inline translation + * Create a view asset representing the RequireJS config.config property for inline translation. * * @return \Magento\Framework\View\Asset\File */ @@ -65,7 +74,7 @@ public function createTranslateConfigAsset() } /** - * Gets current js-translation.json timestamp + * Get current js-translation.json timestamp. * * @return string|void */ @@ -81,7 +90,7 @@ public function getTranslationFileTimestamp() } /** - * Retrieve full path for translation file + * Retrieve full path for translation file. * * @return string */ @@ -95,7 +104,7 @@ protected function getTranslationFileFullPath() } /** - * Retrieve path for translation file + * Retrieve path for translation file. * * @return string */ @@ -105,10 +114,9 @@ public function getTranslationFilePath() } /** - * Update translation file with content - * - * @param string $content + * Update translation file with content. * + * @param array $content * @return void */ public function updateTranslationFileContent($content) @@ -119,9 +127,18 @@ public function updateTranslationFileContent($content) if (!$this->driverFile->isExists($this->getTranslationFileFullPath())) { $this->driverFile->createDirectory($translationDir); + $originalFileContent = ''; + } else { + $originalFileContent = $this->driverFile->fileGetContents($this->getTranslationFileFullPath()); } - - $this->driverFile->filePutContents($this->getTranslationFileFullPath(), $content); + $originalFileTranslationPhrases = !empty($originalFileContent) + ? $this->serializer->unserialize($originalFileContent) + : []; + $updatedTranslationPhrases = array_merge($originalFileTranslationPhrases, $content); + $this->driverFile->filePutContents( + $this->getTranslationFileFullPath(), + $this->serializer->serialize($updatedTranslationPhrases) + ); } /** diff --git a/app/code/Magento/Translation/Model/Inline/CacheManager.php b/app/code/Magento/Translation/Model/Inline/CacheManager.php index 712787498b96d..2002e9a73ec38 100644 --- a/app/code/Magento/Translation/Model/Inline/CacheManager.php +++ b/app/code/Magento/Translation/Model/Inline/CacheManager.php @@ -52,7 +52,7 @@ public function __construct( } /** - * Clears cache and updates translations file + * Clear cache and update translations file. * * @return array */ @@ -60,7 +60,8 @@ public function updateAndGetTranslations() { $this->eventManager->dispatch('adminhtml_cache_flush_system'); $translations = $this->translateResource->getTranslationArray(null, $this->localeResolver->getLocale()); - $this->fileManager->updateTranslationFileContent(json_encode($translations)); + $this->fileManager->updateTranslationFileContent($translations); + return $translations; } } diff --git a/app/code/Magento/Translation/Model/Inline/Renderer.php b/app/code/Magento/Translation/Model/Inline/Renderer.php new file mode 100644 index 0000000000000..b4ef2647ea352 --- /dev/null +++ b/app/code/Magento/Translation/Model/Inline/Renderer.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Translation\Model\Inline; + +use Magento\Framework\Phrase\RendererInterface; + +/** + * Inline Translate phrase renderer for DataProvider. + */ +class Renderer implements RendererInterface +{ + /** + * @inheritdoc + */ + public function render(array $source, array $arguments) + { + return end($source); + } +} diff --git a/app/code/Magento/Translation/Test/Mftf/ActionGroup/AdminTranslateElementActionGroup.xml b/app/code/Magento/Translation/Test/Mftf/ActionGroup/AdminTranslateElementActionGroup.xml index ed6b0c6b91b26..6db6e10dcce0d 100644 --- a/app/code/Magento/Translation/Test/Mftf/ActionGroup/AdminTranslateElementActionGroup.xml +++ b/app/code/Magento/Translation/Test/Mftf/ActionGroup/AdminTranslateElementActionGroup.xml @@ -8,12 +8,12 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminTranslateElementActionGroup"> + <actionGroup name="AdminTranslateElementActionGroup" deprecated="Avoid using super-ActionGroups. Use StorefrontOpenInlineTranslationPopupActionGroup, StorefrontFillCustomTranslationFieldActionGroup and StorefrontSubmitInlineTranslationFormActionGroup"> <arguments> <argument name="elementSelector" type="string"/> <argument name="translateText" type="string"/> </arguments> - + <executeJS function="jQuery('{{elementSelector}}').mousemove()" stepKey="moveMouseOverSelector"/> <executeJS function="jQuery('{{InlineTranslationModeSection.bookIcon}}').click()" stepKey="clickBookIcon"/> <waitForPageLoad stepKey="waitForLoadWindow"/> @@ -23,4 +23,4 @@ <fillField userInput="{{translateText}}" selector="{{InlineTranslationModeSection.inputCustomTranslate}}" stepKey="addTranslate"/> <click selector="{{InlineTranslationModeSection.buttonSubmit}}" stepKey="clickSubmitButton"/> </actionGroup> -</actionGroups> \ No newline at end of file +</actionGroups> diff --git a/app/code/Magento/Translation/Test/Mftf/ActionGroup/StorefrontFillCustomTranslationFieldActionGroup.xml b/app/code/Magento/Translation/Test/Mftf/ActionGroup/StorefrontFillCustomTranslationFieldActionGroup.xml new file mode 100644 index 0000000000000..e0e7072c2172a --- /dev/null +++ b/app/code/Magento/Translation/Test/Mftf/ActionGroup/StorefrontFillCustomTranslationFieldActionGroup.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="StorefrontFillCustomTranslationFieldActionGroup"> + <annotations> + <description>Fill the field in the Inline Translation form by provided text on Storefront.</description> + </annotations> + <arguments> + <argument name="translateText" type="string" defaultValue="Translated"/> + </arguments> + + <clearField selector="{{InlineTranslationModeSection.inputCustomTranslate}}" stepKey="clearCustomTranslateField"/> + <fillField selector="{{InlineTranslationModeSection.inputCustomTranslate}}" userInput="{{translateText}}" stepKey="fillCustomTranslateField"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Translation/Test/Mftf/ActionGroup/StorefrontOpenInlineTranslationPopupActionGroup.xml b/app/code/Magento/Translation/Test/Mftf/ActionGroup/StorefrontOpenInlineTranslationPopupActionGroup.xml new file mode 100644 index 0000000000000..aa92fba7a8722 --- /dev/null +++ b/app/code/Magento/Translation/Test/Mftf/ActionGroup/StorefrontOpenInlineTranslationPopupActionGroup.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"> + <actionGroup name="StorefrontOpenInlineTranslationPopupActionGroup"> + <annotations> + <description>Open the Inline Translation popup for provided element on Storefront.</description> + </annotations> + <arguments> + <argument name="elementSelector" type="string" defaultValue="{{StorefrontHeaderSection.welcomeMessage}}"/> + </arguments> + + <executeJS function="jQuery('{{elementSelector}}').mousemove()" stepKey="moveMouseOverSelector"/> + <executeJS function="jQuery('{{InlineTranslationModeSection.bookIcon}}').click()" stepKey="clickBookIcon"/> + <waitForElementVisible selector="{{InlineTranslationModeSection.popUpTranslate}}" stepKey="waitForTranslationPopupAppear"/> + <seeElement selector="{{InlineTranslationModeSection.popUpTranslate}}" stepKey="seeTranslateForm"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Translation/Test/Mftf/ActionGroup/StorefrontSubmitInlineTranslationFormActionGroup.xml b/app/code/Magento/Translation/Test/Mftf/ActionGroup/StorefrontSubmitInlineTranslationFormActionGroup.xml new file mode 100644 index 0000000000000..280e356d87bcc --- /dev/null +++ b/app/code/Magento/Translation/Test/Mftf/ActionGroup/StorefrontSubmitInlineTranslationFormActionGroup.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="StorefrontSubmitInlineTranslationFormActionGroup"> + <annotations> + <description>Click on the Inline Translation form submit button on Storefront.</description> + </annotations> + + <click selector="{{InlineTranslationModeSection.buttonSubmit}}" stepKey="clickSubmitButton"/> + <waitForElementNotVisible selector="{{InlineTranslationModeSection.popUpTranslate}}" stepKey="waitForTranslationPopupDisappear"/> + <dontSeeElement selector="{{InlineTranslationModeSection.popUpTranslate}}" stepKey="dontSeeTranslateForm"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Translation/Test/Mftf/Test/StorefrontButtonsInlineTranslationTest.xml b/app/code/Magento/Translation/Test/Mftf/Test/StorefrontButtonsInlineTranslationTest.xml index d87d3635fa07c..1ba3236185148 100644 --- a/app/code/Magento/Translation/Test/Mftf/Test/StorefrontButtonsInlineTranslationTest.xml +++ b/app/code/Magento/Translation/Test/Mftf/Test/StorefrontButtonsInlineTranslationTest.xml @@ -12,57 +12,52 @@ <annotations> <features value="Translation"/> <stories value="Inline Translation"/> - <title value="[Inline Translation] Buttons inline translation"/> - <description value="[Inline Translation] Buttons inline translation"/> + <title value="Buttons inline translation"/> + <description value="A merchant should be able to translate buttons by an inline translation tool"/> <severity value="CRITICAL"/> - <testCaseId value="MC-12735"/> + <testCaseId value="MC-27118"/> + <useCaseId value="MC-24186"/> <group value="translation"/> - <skip> - <issueId value="MC-20127"/> - </skip> + <group value="catalog"/> + <group value="developer_mode_only"/> </annotations> <before> + <!-- Enable Translate Inline For Storefront --> + <magentoCLI command="config:set {{EnableTranslateInlineForStorefront.path}} {{EnableTranslateInlineForStorefront.value}}" stepKey="enableTranslateInlineForStorefront"/> + <!-- Create Category --> + <createData entity="ApiCategory" stepKey="createCategory"/> <!-- Create Simple Product --> - <createData entity="SimpleProduct2" stepKey="createProduct"/> - <!-- Enable Translate Inline For Storefront--> - <magentoCLI - command="config:set {{EnableTranslateInlineForStorefront.path}} {{EnableTranslateInlineForStorefront.value}}" - stepKey="enableTranslateInlineForStorefront"/> - <!-- Set developer mode --> - <magentoCLI command="deploy:mode:set developer" stepKey="setDeveloperMode"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> + <createData entity="ApiSimpleProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> </before> <after> <!-- Disable Translate Inline For Storefront --> - <magentoCLI - command="config:set {{DisableTranslateInlineForStorefront.path}} {{DisableTranslateInlineForStorefront.value}}" - stepKey="disableTranslateInlineForStorefront"/> - <!-- Set production mode --> - <magentoCLI command="deploy:mode:set production" stepKey="setProductionMode"/> - + <magentoCLI command="config:set {{DisableTranslateInlineForStorefront.path}} {{DisableTranslateInlineForStorefront.value}}" stepKey="disableTranslateInlineForStorefront"/> <!-- Delete Simple Product --> <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <!-- Delete Category --> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> </after> <!-- Add product to cart on storefront --> - <actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="addProductToCart"> - <argument name="product" value="$$createProduct$$"/> + <amOnPage url="{{StorefrontCategoryPage.url($createCategory.custom_attributes[url_key]$)}}" stepKey="goToCategoryPage"/> + <waitForPageLoad stepKey="waitForCategoryPageLoad"/> + <actionGroup ref="StorefrontAddProductToCartFromCategoryActionGroup" stepKey="addProductToCart"> + <argument name="productName" value="$createProduct.name$"/> </actionGroup> - <!-- Click on cart button on the top --> - <click selector="{{StorefrontMiniCartSection.show}}" stepKey="showMiniCart"/> - - <!-- Small cart popup appeared. --> - <waitForElementVisible selector="{{StorefrontMinicartSection.productName}}" stepKey="seeProductNameAppeared"/> + <!-- Open Mini Cart --> + <actionGroup ref="StorefrontOpenMiniCartActionGroup" stepKey="openMiniCart"/> <!-- Check button "Proceed to Checkout". There must be red borders and "book" icons on labels that can be translated. --> <actionGroup ref="AssertElementInTranslateInlineModeActionGroup" stepKey="assertRedBordersAndBookIcon"> <argument name="elementSelector" value="{{StorefrontMinicartSection.goToCheckout}}"/> </actionGroup> - <actionGroup ref="AdminTranslateElementActionGroup" stepKey="translateProceedToCheckoutButtonText"> + <!-- Open Inline Translation popup --> + <actionGroup ref="StorefrontOpenInlineTranslationPopupActionGroup" stepKey="openInlineTranslationPopup"> <argument name="elementSelector" value="{{StorefrontMinicartSection.goToCheckout}}"/> - <argument name="translateText" value="Proceed to Checkout Translated"/> </actionGroup> </test> </tests> diff --git a/app/code/Magento/Translation/etc/di.xml b/app/code/Magento/Translation/etc/di.xml index 783384fe64fa9..f19eebd29ae11 100644 --- a/app/code/Magento/Translation/etc/di.xml +++ b/app/code/Magento/Translation/etc/di.xml @@ -49,6 +49,18 @@ </argument> </arguments> </type> + <virtualType name="dataProviderCompositeRenderer" type="Magento\Framework\Phrase\Renderer\Composite"> + <arguments> + <argument name="renderers" xsi:type="array"> + <item name="inline" xsi:type="object">Magento\Translation\Model\Inline\Renderer</item> + </argument> + </arguments> + </virtualType> + <type name="Magento\Translation\Model\Js\DataProvider"> + <arguments> + <argument name="translate" xsi:type="object">dataProviderCompositeRenderer</argument> + </arguments> + </type> <type name="Magento\Framework\Phrase\Renderer\Translate"> <arguments> <argument name="translator" xsi:type="object">Magento\Framework\Translate</argument> diff --git a/dev/tests/integration/testsuite/Magento/Translation/Model/Js/DataProviderTest.php b/dev/tests/integration/testsuite/Magento/Translation/Model/Js/DataProviderTest.php new file mode 100644 index 0000000000000..305beae5b9562 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Translation/Model/Js/DataProviderTest.php @@ -0,0 +1,74 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Translation\Model\Js; + +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\TranslateInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\Translation\Model\ResourceModel\StringUtils; +use PHPUnit\Framework\TestCase; + +/** + * Integration tests for \Magento\Translation\Model\Js\DataProvider class. + */ +class DataProviderTest extends TestCase +{ + /** + * @var StringUtils + */ + private $stringUtils; + + /** + * @var TranslateInterface + */ + private $translate; + + /** + * @var DataProviderInterface + */ + private $translationDataProvider; + + /** + * @inheritdoc + */ + protected function setUp() + { + $objectManager = Bootstrap::getObjectManager(); + $this->stringUtils = $objectManager->get(StringUtils::class); + $this->translate = $objectManager->get(TranslateInterface::class); + $this->translationDataProvider = $objectManager->get(DataProviderInterface::class); + } + + /** + * Test translation data. + * + * @magentoAppArea frontend + * @magentoConfigFixture default_store dev/translate_inline/active 1 + */ + public function testGetData() + { + $expectedDictionary = ['Proceed to Checkout' => 'Proceed to Checkout - Translated']; + + $this->stringUtils->saveTranslate('Proceed to Checkout', 'Proceed to Checkout - Translated'); + $this->translate->setLocale('en_US')->loadData('frontend', true); + $dictionary = $this->translationDataProvider->getData('Magento/luma'); + $this->assertEquals($expectedDictionary, $dictionary); + } + + /** + * @inheritdoc + */ + public function tearDown() + { + try { + $this->stringUtils->deleteTranslate('Proceed to Checkout'); + } catch (NoSuchEntityException $exception) { + // translate already deleted + } + } +} From 2b5975c83701fa1039c84b8034b19c719dd10c7a Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Mon, 6 Apr 2020 14:19:21 +0100 Subject: [PATCH 077/177] magento/magento2#27536: Improved interfaces comments and introduced MediaContentCms sequence --- app/code/Magento/Cms/etc/module.xml | 1 + .../Magento/MediaContentApi/Api/AssignAssetsInterface.php | 4 ++-- .../MediaContentApi/Api/ExtractAssetsFromContentInterface.php | 4 ++-- .../MediaContentApi/Api/GetAssetIdsUsedInContentInterface.php | 4 ++-- .../MediaContentApi/Api/GetContentWithAssetsInterface.php | 4 ++-- .../Magento/MediaContentApi/Api/UnassignAssetsInterface.php | 4 ++-- .../Magento/MediaContentApi/Api/UpdateRelationsInterface.php | 4 ++-- app/code/Magento/MediaContentCms/etc/module.xml | 4 +++- 8 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/code/Magento/Cms/etc/module.xml b/app/code/Magento/Cms/etc/module.xml index d3fc2846217d9..4c2e91ad5e172 100644 --- a/app/code/Magento/Cms/etc/module.xml +++ b/app/code/Magento/Cms/etc/module.xml @@ -11,6 +11,7 @@ <module name="Magento_Store"/> <module name="Magento_Theme"/> <module name="Magento_Variable"/> + <module name="Magento_MediaContentCms"/> </sequence> </module> </config> diff --git a/app/code/Magento/MediaContentApi/Api/AssignAssetsInterface.php b/app/code/Magento/MediaContentApi/Api/AssignAssetsInterface.php index 21ab0b08e15c5..6a7ba1abbff6e 100644 --- a/app/code/Magento/MediaContentApi/Api/AssignAssetsInterface.php +++ b/app/code/Magento/MediaContentApi/Api/AssignAssetsInterface.php @@ -11,13 +11,13 @@ use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; /** - * Saving data represents relation between the media asset and media content + * Assign a media asset to the piece of content. Should be executed when media assets is added to the content * @api */ interface AssignAssetsInterface { /** - * Save relation between media asset and media content. + * Assign a media asset to the piece of content. Should be executed when media assets is added to the content * * @param ContentIdentityInterface $contentIdentity * @param int[] $assetIds diff --git a/app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentInterface.php b/app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentInterface.php index 8f1b438361501..4f95571f30ffd 100644 --- a/app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentInterface.php +++ b/app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentInterface.php @@ -10,13 +10,13 @@ use Magento\MediaGalleryApi\Api\Data\AssetInterface; /** - * Used for extracting media asset list from a media content by the search pattern. + * Parse the content string for references to media assets and return the list of identified media assets * @api */ interface ExtractAssetsFromContentInterface { /** - * Search for the media asset in content and extract it providing a list of media assets. + * Parse the content string for references to media assets and return the list of identified media assets * * @param string $content * @return AssetInterface[] diff --git a/app/code/Magento/MediaContentApi/Api/GetAssetIdsUsedInContentInterface.php b/app/code/Magento/MediaContentApi/Api/GetAssetIdsUsedInContentInterface.php index ef6b98ba1505c..91faa6b7646fc 100644 --- a/app/code/Magento/MediaContentApi/Api/GetAssetIdsUsedInContentInterface.php +++ b/app/code/Magento/MediaContentApi/Api/GetAssetIdsUsedInContentInterface.php @@ -11,13 +11,13 @@ use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; /** - * Get media asset ids used in the content + * Get media asset ids that are used in the piece of content identified by the specified content identity * @api */ interface GetAssetIdsUsedInContentInterface { /** - * Get media asset ids used in the content + * Get media asset ids that are used in the piece of content identified by the specified content identity * * @param ContentIdentityInterface $contentIdentity * @return int[] diff --git a/app/code/Magento/MediaContentApi/Api/GetContentWithAssetsInterface.php b/app/code/Magento/MediaContentApi/Api/GetContentWithAssetsInterface.php index abfc3f94fa6b0..ec940829ce6fc 100644 --- a/app/code/Magento/MediaContentApi/Api/GetContentWithAssetsInterface.php +++ b/app/code/Magento/MediaContentApi/Api/GetContentWithAssetsInterface.php @@ -11,13 +11,13 @@ use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; /** - * Get media content list which is used with the specified media asset + * Get list of content identifiers for pieces of content that include the specified media asset * @api */ interface GetContentWithAssetsInterface { /** - * Get media asset to content relations by media asset id. + * Get list of content identifiers for pieces of content that include the specified media asset * * @param int[] $assetIds * @return ContentIdentityInterface[] diff --git a/app/code/Magento/MediaContentApi/Api/UnassignAssetsInterface.php b/app/code/Magento/MediaContentApi/Api/UnassignAssetsInterface.php index 348d213fd9074..462d1c188a168 100644 --- a/app/code/Magento/MediaContentApi/Api/UnassignAssetsInterface.php +++ b/app/code/Magento/MediaContentApi/Api/UnassignAssetsInterface.php @@ -11,13 +11,13 @@ use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; /** - * Unassign relation between the media asset and media content where the media asset is used + * Remove the relation between media asset and the piece of content. I.e media asset no longer part of the content * @api */ interface UnassignAssetsInterface { /** - * Remove relation between the media asset and media content. + * Remove relation between the media asset and the content. I.e media asset no longer part of the content * * @param int[] $assetIds * @param ContentIdentityInterface $contentIdentity diff --git a/app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php b/app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php index 7faab00846495..d9ccdb5759e6b 100644 --- a/app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php +++ b/app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php @@ -10,12 +10,12 @@ use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; /** - * Process relation managing between media asset and content: assign or unassign relation if exists. + * Update the media assets to content relations. Assign new media assets and unassign media assets no longer used */ interface UpdateRelationsInterface { /** - * Create new relation between media asset and content or updated existing + * Update the media assets to content relations. Assign new media assets and unassign media assets no longer used * * @param ContentIdentityInterface $contentIdentity * @param string $content diff --git a/app/code/Magento/MediaContentCms/etc/module.xml b/app/code/Magento/MediaContentCms/etc/module.xml index 7278f82890b42..e273636359b5b 100644 --- a/app/code/Magento/MediaContentCms/etc/module.xml +++ b/app/code/Magento/MediaContentCms/etc/module.xml @@ -6,5 +6,7 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="Magento_MediaContentCms" /> + <module name="Magento_MediaContentCms"> + <module name="Magento_MediaContent"/> + </module> </config> From 1aff699d53257a3018b8f7d51ff65656cfc47638 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Mon, 6 Apr 2020 18:28:39 -0500 Subject: [PATCH 078/177] MQE-2069: [MTF-to-MFTF] Create Newsletter Template Entity #761 --- .../AdminCreatesNewIntegrationActionGroup.xml | 2 -- ...ntegrationEntityWithDuplicatedNameTest.xml | 14 ++++++++++--- .../Test/AdminDeleteIntegrationEntityTest.xml | 12 +++++------ .../Test/AdminUpdateIntegrationEntityTest.xml | 20 +++++++++++++------ ...grationEntityWithIncorrectPasswordTest.xml | 1 + ...nMarketingCreateNewsletterTemplateTest.xml | 2 ++ ...nMarketingNewsletterTemplateUpdateTest.xml | 3 ++- 7 files changed, 35 insertions(+), 19 deletions(-) diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml index d605c1639cc69..3623dbd70f816 100644 --- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml @@ -17,8 +17,6 @@ </arguments> <fillField stepKey="fillNameField" selector="{{AdminNewIntegrationSection.name}}" userInput="{{name}}"/> <fillField stepKey="fillAdminPasswordField" selector="{{AdminNewIntegrationSection.password}}" userInput="{{password}}"/> - <!--Click the "Save" Button --> - <click stepKey="clickSaveButton" selector="{{AdminNewIntegrationSection.saveButton}}"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminCreateIntegrationEntityWithDuplicatedNameTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminCreateIntegrationEntityWithDuplicatedNameTest.xml index f55e4e37585ba..7bc1c9b5a274f 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminCreateIntegrationEntityWithDuplicatedNameTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminCreateIntegrationEntityWithDuplicatedNameTest.xml @@ -23,6 +23,14 @@ <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> </before> <after> + <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="returnToIntegrationsPage"> + <argument name="menuUiId" value="{{AdminMenuSystem.dataUiId}}"/> + <argument name="submenuUiId" value="{{AdminMenuSystemExtensionsIntegrations.dataUiId}}"/> + </actionGroup> + <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="searchForIntegration"> + <argument name="name" value="{{defaultIntegrationData.name}}"/> + </actionGroup> + <actionGroup ref="AdminDeleteIntegrationEntityActionGroup" stepKey="deleteCreatedIntegration"/> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> @@ -32,18 +40,18 @@ </actionGroup> <actionGroup ref="AdminNavigateToCreateIntegrationPageActionGroup" stepKey="clickAddNewIntegrationButton"/> <actionGroup ref="AdminCreatesNewIntegrationActionGroup" stepKey="createNewIntegration"> - <argument name="name" value="Integration1"/> + <argument name="name" value="{{defaultIntegrationData.name}}"/> <argument name="password" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/> </actionGroup> <actionGroup ref="AdminSubmitNewIntegrationFormActionGroup" stepKey="submitTheForm"/> <actionGroup ref="AdminNavigateToCreateIntegrationPageActionGroup" stepKey="clickAddNewIntegrationButtonSecondTime"/> <actionGroup ref="AdminCreatesNewIntegrationActionGroup" stepKey="createNewIntegrationWithDuplicatedName"> - <argument name="name" value="Integration1"/> + <argument name="name" value="{{defaultIntegrationData.name}}"/> <argument name="password" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/> </actionGroup> <actionGroup ref="AdminSubmitNewIntegrationFormActionGroup" stepKey="submitTheFormWithDuplicatedName"/> <actionGroup ref="AssertAdminMessageCreateIntegrationEntityActionGroup" stepKey="seeErrorMessage"> - <argument name="message" value="The integration with name "Integration1" exists."/> + <argument name="message" value="The integration with name "{{defaultIntegrationData.name}}" exists."/> <argument value="error" name="messageType"/> </actionGroup> </test> diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml index eb6c946a03bb5..0148278ac7aaa 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml @@ -31,34 +31,32 @@ <actionGroup ref="AdminNavigateToCreateIntegrationPageActionGroup" stepKey="clickAddNewIntegrationButton"/> <!-- Create New Integration --> <actionGroup ref="AdminCreatesNewIntegrationActionGroup" stepKey="createIntegration"> - <argument name="name" value="Integration1"/> + <argument name="name" value="{{defaultIntegrationData.name}}"/> <argument name="password" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/> </actionGroup> - <!-- Submit The Form --> <actionGroup ref="AdminSubmitNewIntegrationFormActionGroup" stepKey="submitTheForm"/> </before> <after> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> - <!-- TEST BODY --> <!-- Find Created Integration In Grid --> <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="findCreatedIntegration"> - <argument name="name" value="Integration1"/> + <argument name="name" value="{{defaultIntegrationData.name}}"/> </actionGroup> <!-- Delete Created Integration Entity --> <actionGroup ref="AdminDeleteIntegrationEntityActionGroup" stepKey="deleteIntegration"/> <!-- Assert Success Message --> <actionGroup ref="AssertAdminMessageCreateIntegrationEntityActionGroup" stepKey="seeSuccessMessage"> - <argument name="message" value="The integration 'Integration1' has been deleted."/> + <argument name="message" value="The integration '{{defaultIntegrationData.name}}' has been deleted."/> <argument value="success" name="messageType"/> </actionGroup> <!-- Assert Deleted Integration Is Not In Grid --> <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="findDeletedIntegration"> - <argument name="name" value="Integration1"/> + <argument name="name" value="{{defaultIntegrationData.name}}"/> </actionGroup> <actionGroup ref="AssertDeletedIntegrationIsNotInGridActionGroup" stepKey="dontSeeIntegration"> - <argument name="name" value="Integration1"/> + <argument name="name" value="{{defaultIntegrationData.name}}"/> </actionGroup> <!-- END TEST BODY --> </test> diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml index ab01f69308715..41efc72c35fb4 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml @@ -30,24 +30,32 @@ <actionGroup ref="AdminNavigateToCreateIntegrationPageActionGroup" stepKey="clickAddNewIntegrationButton"/> <!-- Create New Integration --> <actionGroup ref="AdminCreatesNewIntegrationActionGroup" stepKey="createIntegration"> - <argument name="name" value="Integration1"/> + <argument name="name" value="{{defaultIntegrationData.name}}"/> <argument name="password" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/> </actionGroup> + <actionGroup ref="AdminSubmitNewIntegrationFormActionGroup" stepKey="submitTheForm"/> </before> <after> + <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="returnToIntegrationsPage"> + <argument name="menuUiId" value="{{AdminMenuSystem.dataUiId}}"/> + <argument name="submenuUiId" value="{{AdminMenuSystemExtensionsIntegrations.dataUiId}}"/> + </actionGroup> + <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="searchForIntegration"> + <argument name="name" value="{{defaultIntegrationData.name}} Updated"/> + </actionGroup> <actionGroup ref="logout" stepKey="logout"/> </after> <!-- TEST BODY --> <!-- Find Created Integration In Grid --> <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="findCreatedIntegration"> - <argument name="name" value="Integration1"/> + <argument name="name" value="{{defaultIntegrationData.name}}"/> </actionGroup> <!-- Open Integration Edit Page --> <actionGroup ref="AdminClickEditIntegrationEntityActionGroup" stepKey="clickEditButton"/> <!-- Update Integration Entity --> <actionGroup ref="AdminUpdateCreatedIntegrationEntityActionGroup" stepKey="updateIntegrationEntity"> - <argument name="name" value="Integration Updated"/> + <argument name="name" value="{{defaultIntegrationData.name}} Updated"/> <argument name="endpoint" value="https://endpoint-updated.com"/> <argument name="linkUrl" value="https://testlink-updated.com"/> <argument name="password" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/> @@ -56,15 +64,15 @@ <actionGroup ref="AdminSubmitIntegrationFormActionGroup" stepKey="submitTheForm"/> <!-- Assert Success Message --> <actionGroup ref="AssertAdminMessageCreateIntegrationEntityActionGroup" stepKey="seeSuccessMessage"> - <argument name="message" value="The integration 'Integration Updated' has been saved."/> + <argument name="message" value="The integration '{{defaultIntegrationData.name}} Updated' has been saved."/> <argument value="success" name="messageType"/> </actionGroup> <!-- Assert Updated Entity In Grid --> <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="findDeletedIntegration"> - <argument name="name" value="Integration Updated"/> + <argument name="name" value="{{defaultIntegrationData.name}} Updated"/> </actionGroup> <actionGroup ref="AssertUpdatedIntegrationEntityInGridActionGroup" stepKey="seeIntegrationEntity"> - <argument name="name" value="Integration Updated"/> + <argument name="name" value="{{defaultIntegrationData.name}} Updated"/> </actionGroup> </test> </tests> diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml index 59d70da4f9762..403e886ea8209 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml @@ -33,6 +33,7 @@ <argument name="name" value="Integration1"/> <argument name="password" value="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/> </actionGroup> + <actionGroup ref="AdminSubmitNewIntegrationFormActionGroup" stepKey="submitTheForm"/> </before> <after> <actionGroup ref="logout" stepKey="logout"/> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml index 525fd70d03f8e..16bd135163307 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml @@ -16,7 +16,9 @@ <description value="Newsletter Template Successfully Created"/> <group value="newsletter"/> <group value="mtf_migrated"/> + <severity value="CRITICAL"/> <testCaseId value="MC-29809"/> + <group value="WYSIWYGDisabled"/> </annotations> <before> <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml index cedb176cf909f..82b6e1833a753 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingNewsletterTemplateUpdateTest.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="AdminMarketingNewsletterTemplateUpdate"> + <test name="AdminMarketingNewsletterTemplateUpdateTest"> <annotations> <features value="Newsletter"/> <stories value="Newsletter Updating"/> @@ -16,6 +16,7 @@ <description value="Admin should be able update created Newsletter Template"/> <group value="reports"/> <group value="mtf_migrated"/> + <group value="WYSIWYGDisabled"/> </annotations> <before> From 52bccaa36bd189068201543cfc5af7ae6070f89f Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Mon, 6 Apr 2020 21:07:47 -0500 Subject: [PATCH 079/177] MQE-2069: [MTF-to-MFTF] Create Newsletter Template Entity #761 removed extra line --- .../Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml index 3623dbd70f816..c039a70293269 100644 --- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml @@ -17,6 +17,5 @@ </arguments> <fillField stepKey="fillNameField" selector="{{AdminNewIntegrationSection.name}}" userInput="{{name}}"/> <fillField stepKey="fillAdminPasswordField" selector="{{AdminNewIntegrationSection.password}}" userInput="{{password}}"/> - </actionGroup> </actionGroups> From 0a57486892d9cdf9b4bdb26e50e69906fb3ed2fc Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets <vzaets@magento.com> Date: Tue, 7 Apr 2020 00:36:20 -0500 Subject: [PATCH 080/177] Add configuration for MediaGallery/Directory --- .../MediaGallery/Model/Directory/Config.php | 40 ++++++++++++ .../Model/Directory/Config/Converter.php | 57 ++++++++++++++++ .../Model/Directory/Config/Reader.php | 65 +++++++++++++++++++ .../Model/Directory/Config/SchemaLocator.php | 48 ++++++++++++++ .../Model/Directory/IsBlacklisted.php | 14 ++-- app/code/Magento/MediaGallery/etc/di.xml | 32 +++++---- .../Magento/MediaGallery/etc/directory.xml | 22 +++++++ .../Magento/MediaGallery/etc/directory.xsd | 38 +++++++++++ 8 files changed, 294 insertions(+), 22 deletions(-) create mode 100644 app/code/Magento/MediaGallery/Model/Directory/Config.php create mode 100644 app/code/Magento/MediaGallery/Model/Directory/Config/Converter.php create mode 100644 app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php create mode 100644 app/code/Magento/MediaGallery/Model/Directory/Config/SchemaLocator.php create mode 100644 app/code/Magento/MediaGallery/etc/directory.xml create mode 100644 app/code/Magento/MediaGallery/etc/directory.xsd diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config.php b/app/code/Magento/MediaGallery/Model/Directory/Config.php new file mode 100644 index 0000000000000..59b37cb4bbd25 --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/Directory/Config.php @@ -0,0 +1,40 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\MediaGallery\Model\Directory; + +use Magento\Framework\Config\DataInterface; + +/** + * Config of Magento Media Gallery Directory. + */ +class Config +{ + /** + * @var DataInterface + */ + private $data; + + /** + * @param DataInterface $data + */ + public function __construct(DataInterface $data) + { + $this->data = $data; + } + + /** + * Get config value by key. + * + * @param string|null $key + * @param string|null $default + * @return array + */ + public function get($key = null, $default = null) + { + return $this->data->get($key, $default); + } +} diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config/Converter.php b/app/code/Magento/MediaGallery/Model/Directory/Config/Converter.php new file mode 100644 index 0000000000000..564512935a3c4 --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/Directory/Config/Converter.php @@ -0,0 +1,57 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\MediaGallery\Model\Directory\Config; + +use Magento\Framework\Config\ConverterInterface; + +/** + * Class Converter + */ +class Converter implements ConverterInterface +{ + /** + * Blacklist tag name + */ + private CONST BLACKLIST_TAG_NAME = 'blacklist'; + + /** + * Patterns tag name + */ + private CONST PATTERNS_TAG_NAME = 'patterns'; + + /** + * Pattern tag name + */ + private CONST PATTERN_TAG_NAME = 'pattern'; + + /** + * Convert dom node to array + * + * @param \DOMDocument $source + * @return array + */ + public function convert($source) : array + { + $result = []; + + if (!$source instanceof \DOMDocument) { + return $result; + } + + foreach ($source->getElementsByTagName(self::BLACKLIST_TAG_NAME) as $blacklist) { + $result[self::BLACKLIST_TAG_NAME] = []; + foreach ($blacklist->getElementsByTagName(self::PATTERNS_TAG_NAME) as $patterns) { + $result[self::BLACKLIST_TAG_NAME][self::PATTERNS_TAG_NAME] = []; + foreach ($patterns->getElementsByTagName(self::PATTERN_TAG_NAME) as $pattern) { + $result[self::BLACKLIST_TAG_NAME][self::PATTERNS_TAG_NAME] + [$pattern->attributes->getNamedItem('name')->nodeValue] = $pattern->nodeValue; + } + } + } + + return $result; + } +} diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php b/app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php new file mode 100644 index 0000000000000..a502139b44ded --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php @@ -0,0 +1,65 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\MediaGallery\Model\Directory\Config; + +use Magento\Framework\App\Area; +use Magento\Framework\Config\ReaderInterface; +use Magento\Framework\Config\Reader\Filesystem; +use Magento\Framework\Config\FileResolverInterface; +use Magento\Framework\Config\ValidationStateInterface; +use Magento\Framework\Config\Dom; + +class Reader extends Filesystem implements ReaderInterface +{ + /** + * List of id attributes for merge + * + * @var array + */ + protected $_idAttributes = [ + '/config/patterns' => 'patterns', + '/config/patterns/pattern' => 'name', + ]; + + /** + * XML Configuration file name + */ + private const XML_FILE_NAME = 'directory.xml'; + + /** + * Construct the FileSystem Reader Class + * + * @param \Magento\Framework\Config\FileResolverInterface $fileResolver + * @param Converter $converter + * @param SchemaLocator $schemaLocator + * @param \Magento\Framework\Config\ValidationStateInterface $validationState + * @param string $fileName + * @param array $idAttributes + * @param string $domDocumentClass + * @param string $defaultScope + */ + public function __construct( + FileResolverInterface $fileResolver, + Converter $converter, + SchemaLocator $schemaLocator, + ValidationStateInterface $validationState, + $fileName = self::XML_FILE_NAME, + $idAttributes = [], + $domDocumentClass = Dom::class, + $defaultScope = Area::AREA_GLOBAL + ) { + parent::__construct( + $fileResolver, + $converter, + $schemaLocator, + $validationState, + $fileName, + $idAttributes, + $domDocumentClass, + $defaultScope + ); + } +} diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config/SchemaLocator.php b/app/code/Magento/MediaGallery/Model/Directory/Config/SchemaLocator.php new file mode 100644 index 0000000000000..26364951a23d4 --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/Directory/Config/SchemaLocator.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\MediaGallery\Model\Directory\Config; + +use Magento\Framework\Module\Dir; +use Magento\Framework\Module\Dir\Reader; +use Magento\Framework\Config\SchemaLocatorInterface; + +class SchemaLocator implements SchemaLocatorInterface +{ + /** + * Path to corresponding XSD file with validation rules for both individual and merged configs + * + * @var string + */ + private $schema; + + /** + * @param Reader $moduleReader + */ + public function __construct(Reader $moduleReader) + { + $this->schema = $moduleReader->getModuleDir(Dir::MODULE_ETC_DIR, 'Magento_MediaGallery') . '/directory.xsd'; + } + + /** + * Get path to merged config schema + * + * @return string|null + */ + public function getSchema() + { + return $this->schema; + } + + /** + * Get path to per file validation schema + * + * @return string|null + */ + public function getPerFileSchema() + { + return $this->schema; + } +} diff --git a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php index 312d5ab3dcf8a..7e79492f022dc 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php +++ b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php @@ -19,17 +19,15 @@ class IsBlacklisted implements IsBlacklistedInterface { /** - * @var array + * @var Config */ - private $patterns; + private $config; /** - * @param array $patterns + * @param Config $config */ - public function __construct( - array $patterns - ) { - $this->patterns = $patterns; + public function __construct(Config $config) { + $this->config = $config; } /** @@ -40,7 +38,7 @@ public function __construct( */ public function execute(string $path): bool { - foreach ($this->patterns as $pattern) { + foreach ($this->config->get('blacklist/patterns') as $pattern) { if (empty($pattern)) { continue; } diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index ea05da9498607..f06499455770d 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -28,20 +28,6 @@ <preference for="Magento\MediaGalleryApi\Model\File\Command\DeleteByAssetIdInterface" type="Magento\MediaGallery\Model\File\Command\DeleteByAssetId"/> - <type name="Magento\MediaGallery\Model\Directory\IsBlacklisted"> - <arguments> - <argument name="patterns" xsi:type="array"> - <item name="captcha" xsi:type="string">/pub\/media\/captcha/</item> - <item name="catalog" xsi:type="string">/pub\/media\/catalog\/product/</item> - <item name="customer" xsi:type="string">/pub\/media\/customer/</item> - <item name="downloadable" xsi:type="string">/pub\/media\/downloadable/</item> - <item name="import" xsi:type="string">/pub\/media\/import/</item> - <item name="theme" xsi:type="string">/pub\/media\/theme/</item> - <item name="theme_customization" xsi:type="string">/pub\/media\/theme_customization/</item> - <item name="tmp" xsi:type="string">/pub\/media\/tmp/</item> - </argument> - </arguments> - </type> <type name="Magento\Catalog\Model\Product\Gallery\Processor"> <plugin name="media_gallery_image_remove_metadata" type="Magento\MediaGallery\Plugin\Product\Gallery\Processor" sortOrder="10" disabled="false"/> @@ -50,4 +36,22 @@ <plugin name="media_gallery_image_remove_metadata_after_wysiwyg" type="Magento\MediaGallery\Plugin\Wysiwyg\Images\Storage" sortOrder="10" disabled="false"/> </type> + <type name="Magento\MediaGallery\Model\Directory\Config\Reader"> + <arguments> + <argument name="fileName" xsi:type="string">directory.xml</argument> + <argument name="converter" xsi:type="object">Magento\MediaGallery\Model\Directory\Config\Converter</argument> + <argument name="schemaLocator" xsi:type="object">Magento\MediaGallery\Model\Directory\Config\SchemaLocator</argument> + </arguments> + </type> + <virtualType name="Magento\MediaGallery\Model\Directory\Config\Data" type="Magento\Framework\Config\Data"> + <arguments> + <argument name="reader" xsi:type="object">Magento\MediaGallery\Model\Directory\Config\Reader</argument> + <argument name="cacheId" xsi:type="string">Media_Gallery_Patterns_CacheId</argument> + </arguments> + </virtualType> + <type name="Magento\MediaGallery\Model\Directory\Config"> + <arguments> + <argument name="data" xsi:type="object">Magento\MediaGallery\Model\Directory\Config\Data</argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/MediaGallery/etc/directory.xml b/app/code/Magento/MediaGallery/etc/directory.xml new file mode 100644 index 0000000000000..4bdaeb5edd0c7 --- /dev/null +++ b/app/code/Magento/MediaGallery/etc/directory.xml @@ -0,0 +1,22 @@ +<?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:module:Magento_MediaGallery:etc/directory.xsd"> + <blacklist> + <patterns> + <pattern name="captcha">/pub\/media\/captcha/</pattern> + <pattern name="catalog">/pub\/media\/catalog\/product/</pattern> + <pattern name="customer">/pub\/media\/customer/</pattern> + <pattern name="downloadable">/pub\/media\/downloadable/</pattern> + <pattern name="import">/pub\/media\/import/</pattern> + <pattern name="theme">/pub\/media\/theme/</pattern> + <pattern name="theme_customization">/pub\/media\/theme_customization/</pattern> + <pattern name="tmp">/pub\/media\/tmp/</pattern> + <pattern name="directories-with-dots">/^\./</pattern> + </patterns> + </blacklist> +</config> diff --git a/app/code/Magento/MediaGallery/etc/directory.xsd b/app/code/Magento/MediaGallery/etc/directory.xsd new file mode 100644 index 0000000000000..b9abd04ae1456 --- /dev/null +++ b/app/code/Magento/MediaGallery/etc/directory.xsd @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:element name="config" type="configType"> + </xs:element> + + <xs:complexType name="configType"> + <xs:sequence> + <xs:element type="blacklistType" name="blacklist" maxOccurs="unbounded" minOccurs="1"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="blacklistType"> + <xs:sequence> + <xs:element type="patternsType" name="patterns" maxOccurs="unbounded" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="patternsType"> + <xs:sequence> + <xs:element type="patternType" name="pattern" maxOccurs="unbounded" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="patternType"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute type="xs:string" name="name" use="required"/> + <xs:attribute type="xs:string" name="example" use="optional"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> +</xs:schema> From bbc1f10d87925709ff1abd7f6e79de73d1260fc5 Mon Sep 17 00:00:00 2001 From: Ji Lu <jilu1@adobe.com> Date: Mon, 6 Apr 2020 20:04:35 -0500 Subject: [PATCH 081/177] MQE-2046: remove deprecated entities usages in MFTF tests --- .../LoginAdminWithCredentialsActionGroup.xml | 13 ---- .../LoginAsAdminActionGroup.xml | 13 ---- .../Test/AdminAdvancedReportingButtonTest.xml | 2 +- .../LoginActionGroup.xml | 11 ---- .../LoginAdminWithCredentialsActionGroup.xml | 25 -------- .../LoginAsAdminActionGroup.xml | 24 ------- .../LoginAsAnyUserActionGroup.xml | 20 ------ .../LogoutActionGroup.xml | 11 ---- .../Mftf/Section/AdminMessagesSection.xml | 6 -- .../Backend/Test/Mftf/Test/AdminLoginTest.xml | 27 -------- .../BraintreeCreditCardOnCheckoutTest.xml | 11 +++- .../BundleProductWithTierPriceInCartTest.xml | 10 ++- .../AdminLoginWithCaptchaActionGroup.xml | 2 +- .../Mftf/Test/AdminLoginWithCaptchaTest.xml | 14 +++-- .../AddSimpleProductToCartActionGroup.xml | 2 +- ...AssertProductOnCategoryPageActionGroup.xml | 2 +- .../SaveCategoryFormActionGroup.xml | 20 ------ .../ActionGroup/_Deprecated_ActionGroup.xml | 12 ---- .../Test/AdminAddImageForCategoryTest.xml | 2 +- ...MediaRolesForFirstAddedImageViaApiTest.xml | 2 +- ...minCheckProductListPriceAttributesTest.xml | 2 +- ...inCreateRootCategoryRequiredFieldsTest.xml | 2 +- .../Test/AdminMoveAnchoredCategoryTest.xml | 6 +- ...ignedToCategoryWithoutCustomURLKeyTest.xml | 2 +- .../Test/AdminRemoveImageFromCategoryTest.xml | 4 +- ...rPriceInStockVisibleInCategoryOnlyTest.xml | 2 +- ...thCustomOptionsVisibleInSearchOnlyTest.xml | 2 +- ...tOfStockVisibleInCategoryAndSearchTest.xml | 2 +- ...iceOutOfStockVisibleInCategoryOnlyTest.xml | 2 +- ...PriceOutOfStockVisibleInSearchOnlyTest.xml | 2 +- ...eInStockVisibleInCategoryAndSearchTest.xml | 2 +- ...tOfStockVisibleInCategoryAndSearchTest.xml | 2 +- ...eInStockVisibleInCategoryAndSearchTest.xml | 6 +- ...rPriceInStockVisibleInCategoryOnlyTest.xml | 2 +- ...tOfStockVisibleInCategoryAndSearchTest.xml | 2 +- .../EndToEndB2CGuestUserMysqlTest.xml | 4 +- .../EndToEndB2CGuestUserTest.xml | 4 +- .../Mftf/Test/EndToEndB2CLoggedInUserTest.xml | 4 +- ...tProductsDisplayUsingElasticSearchTest.xml | 2 +- ...rontConfigurableOptionsThumbImagesTest.xml | 2 +- ...chorIsVisibleOnViewportOnceClickedTest.xml | 10 ++- ...teCatalogPriceRuleForCustomerGroupTest.xml | 10 ++- ...eProductWithAssignedSimpleProductsTest.xml | 2 +- ...eForConfigurableProductWithOptionsTest.xml | 2 +- .../Mftf/Test/AdminDeleteSearchTermTest.xml | 2 +- ...OfDefaultBillingAndShippingAddressTest.xml | 10 ++- ...refrontCustomerLoginDuringCheckoutTest.xml | 10 ++- ...capeAndEnterHandlesForWYSIWYGBlockTest.xml | 2 +- ...untryDropDownWithOneAllowedCountryTest.xml | 10 ++- .../Mftf/Test/EndToEndB2CLoggedInUserTest.xml | 2 +- ...tWithSeveralAttributesPrependMediaTest.xml | 4 +- ...hVisualSwatchAttributePrependMediaTest.xml | 4 +- ...nCurrencyConverterAPIConfigurationTest.xml | 16 ++--- ...efrontDefaultWelcomeMessageActionGroup.xml | 4 +- ...ustomerAddressInfoFillStateActionGroup.xml | 2 +- ...SignUpNewUserFromStorefrontActionGroup.xml | 2 +- ...CustomerWithWebSiteAndGroupActionGroup.xml | 33 ---------- ...CustomerAddressNoZipNoStateActionGroup.xml | 20 ------ ...etDefaultShippingAndBillingActionGroup.xml | 18 ------ .../EnterCustomerAddressInfoActionGroup.xml | 32 ---------- ...ustomerAddressInfoFillStateActionGroup.xml | 17 ----- ...NavigateToCustomerGroupPageActionGroup.xml | 11 ---- ...erifyCustomerBillingAddressActionGroup.xml | 29 --------- ...omerBillingAddressWithStateActionGroup.xml | 28 --------- ...erifyCustomerNameOnFrontendActionGroup.xml | 25 -------- ...rifyCustomerShippingAddressActionGroup.xml | 28 --------- ...merShippingAddressWithStateActionGroup.xml | 28 --------- .../Section/StorefrontPanelHeaderSection.xml | 3 - ...AdminCreateNewCustomerOnStorefrontTest.xml | 8 ++- .../ChangingAllCustomerGroupViaGridTest.xml | 28 --------- ...ChangingSingleCustomerGroupViaGridTest.xml | 62 ------------------- .../Mftf/Test/EndToEndB2CLoggedInUserTest.xml | 10 ++- ...StorefrontCheckTaxAddingValidVATIdTest.xml | 6 +- ...efrontUpdateCustomerAddressBelgiumTest.xml | 12 +++- ...orefrontUpdateCustomerAddressChinaTest.xml | 12 +++- ...refrontUpdateCustomerAddressFranceTest.xml | 12 +++- .../StorefrontUpdateCustomerAddressUKTest.xml | 12 +++- ...pdateCustomerInformationAddAddressTest.xml | 12 +++- .../AddingProductWithExpiredSessionTest.xml | 11 ---- .../StorefrontCustomerForgotPasswordTest.xml | 11 ---- .../VerifyDisabledCustomerGroupFieldTest.xml | 11 ---- ...dminImportCSVWithSpecialCharactersTest.xml | 2 +- .../CliRunReindexUsingCronJobsActionGroup.xml | 18 ------ ...chaseFunctionalityNegativeScenarioTest.xml | 4 +- ...efrontInstantPurchaseFunctionalityTest.xml | 2 +- ...oreFrontMyAccountWithMultishipmentTest.xml | 2 +- ...ingCartBehaviorAfterSessionExpiredTest.xml | 10 ++- ...listIsPersistedUnderLongTermCookieTest.xml | 8 +-- ...eConditionAndFreeShippingIsAppliedTest.xml | 2 +- ...talAndVerifyRuleConditionIsAppliedTest.xml | 2 +- ...oryAndVerifyRuleConditionIsAppliedTest.xml | 2 +- ...ghtAndVerifyRuleConditionIsAppliedTest.xml | 2 +- ...inSaveUserInvalidExpirationActionGroup.xml | 2 +- ...minLoginAdminUserWithInvalidExpiration.xml | 6 +- ...AdminLoginAdminUserWithValidExpiration.xml | 6 +- .../AdminNavigateWhileUserExpiredTest.xml | 6 +- .../GoToShipmentIntoOrderActionGroup.xml | 19 ------ .../SeeProductInShipmentItemsActionGroup.xml | 20 ------ .../SubmitShipmentIntoOrderActionGroup.xml | 19 ------ ...ifyBasicShipmentInformationActionGroup.xml | 33 ---------- ...atusDisabledVerifyErrorSaveMessageTest.xml | 2 +- ...EnabledVerifyAbsenceOfDeleteButtonTest.xml | 2 +- ...tusEnabledVerifyBackendAndFrontendTest.xml | 2 +- ...NewLocalizedStoreViewStatusEnabledTest.xml | 2 +- ...ithCustomWebsiteAndDefaultCategoryTest.xml | 2 +- ...upWithCustomWebsiteAndRootCategoryTest.xml | 2 +- ...thDefaultWebsiteAndDefaultCategoryTest.xml | 2 +- ...usDisabledVerifyBackendAndFrontendTest.xml | 2 +- ...tusEnabledVerifyBackendAndFrontendTest.xml | 2 +- .../Test/AdminDeleteDefaultStoreViewTest.xml | 2 +- .../Mftf/Test/AdminDeleteStoreGroupTest.xml | 2 +- .../Mftf/Test/AdminDeleteStoreViewTest.xml | 2 +- ...inMoveStoreToOtherGroupSameWebsiteTest.xml | 2 +- ...pAcceptAlertAndVerifyStoreViewFormTest.xml | 2 +- ...teStoreGroupAndVerifyStoreViewFormTest.xml | 2 +- .../Mftf/Test/AdminUpdateStoreViewTest.xml | 2 +- .../Test/Mftf/Test/AdminUpdateWebsiteTest.xml | 2 +- ...heckTextSwatchAttributeAddedViaApiTest.xml | 2 +- ...axRuleCustomProductTaxClassActionGroup.xml | 4 +- .../Test/AdminCheckingTaxReportGridTest.xml | 8 +-- ...orefrontTaxQuoteCartLoggedInSimpleTest.xml | 10 ++- ...refrontTaxQuoteCartLoggedInVirtualTest.xml | 10 ++- ...rontTaxQuoteCheckoutLoggedInSimpleTest.xml | 12 +++- ...ontTaxQuoteCheckoutLoggedInVirtualTest.xml | 12 +++- .../AdminFormSaveAndCloseActionGroup.xml | 19 ------ .../AdminFormSaveAndDuplicateActionGroup.xml | 20 ------ ...dFilterDeleteAndVerifyErrorMessageTest.xml | 2 +- .../AdminAddCustomUrlRewriteActionGroup.xml | 2 +- .../AdminAddUrlRewriteActionGroup.xml | 2 +- ...dminAddUrlRewriteForProductActionGroup.xml | 2 +- .../AdminDeleteUrlRewriteActionGroup.xml | 2 +- ...AdminUpdateCustomUrlRewriteActionGroup.xml | 2 +- .../AdminUpdateUrlRewriteActionGroup.xml | 2 +- ...rlKeyForStoreViewAndMovingCategoryTest.xml | 2 +- ...SeveralWebsitesAndCheckURLRewritesTest.xml | 2 +- .../Test/Mftf/Test/AdminUpdateUserTest.xml | 3 +- ...nfigurableProductInWishlistActionGroup.xml | 25 -------- ...bleProductInWishlistSidebarActionGroup.xml | 24 ------- 138 files changed, 281 insertions(+), 941 deletions(-) delete mode 100644 app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAdminWithCredentialsActionGroup.xml delete mode 100644 app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAsAdminActionGroup.xml delete mode 100644 app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginActionGroup.xml delete mode 100644 app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAdminWithCredentialsActionGroup.xml delete mode 100644 app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAsAdminActionGroup.xml delete mode 100644 app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAsAnyUserActionGroup.xml delete mode 100644 app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LogoutActionGroup.xml delete mode 100644 app/code/Magento/Backend/Test/Mftf/Test/AdminLoginTest.xml delete mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/SaveCategoryFormActionGroup.xml delete mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/_Deprecated_ActionGroup.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminCreateCustomerWithWebSiteAndGroupActionGroup.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminEditCustomerAddressNoZipNoStateActionGroup.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminEditCustomerAddressSetDefaultShippingAndBillingActionGroup.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/EnterCustomerAddressInfoActionGroup.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/EnterCustomerAddressInfoFillStateActionGroup.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/NavigateToCustomerGroupPageActionGroup.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerBillingAddressActionGroup.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerBillingAddressWithStateActionGroup.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerNameOnFrontendActionGroup.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerShippingAddressActionGroup.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerShippingAddressWithStateActionGroup.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/Test/ChangeCustomerGroupTest/ChangingAllCustomerGroupViaGridTest.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/Test/ChangeCustomerGroupTest/ChangingSingleCustomerGroupViaGridTest.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/AddingProductWithExpiredSessionTest.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/StorefrontCustomerForgotPasswordTest.xml delete mode 100644 app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/VerifyDisabledCustomerGroupFieldTest.xml delete mode 100644 app/code/Magento/Indexer/Test/Mftf/ActionGroup/CliRunReindexUsingCronJobsActionGroup.xml delete mode 100644 app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/GoToShipmentIntoOrderActionGroup.xml delete mode 100644 app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/SeeProductInShipmentItemsActionGroup.xml delete mode 100644 app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/SubmitShipmentIntoOrderActionGroup.xml delete mode 100644 app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyBasicShipmentInformationActionGroup.xml delete mode 100644 app/code/Magento/Ui/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminFormSaveAndCloseActionGroup.xml delete mode 100644 app/code/Magento/Ui/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminFormSaveAndDuplicateActionGroup.xml delete mode 100644 dev/tests/acceptance/tests/functional/Magento/ConfigurableProductWishlist/ActionGroup/_Deprecated_ActionGroup/StorefrontCustomerCheckConfigurableProductInWishlistActionGroup.xml delete mode 100644 dev/tests/acceptance/tests/functional/Magento/ConfigurableProductWishlist/ActionGroup/_Deprecated_ActionGroup/StorefrontCustomerCheckConfigurableProductInWishlistSidebarActionGroup.xml diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAdminWithCredentialsActionGroup.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAdminWithCredentialsActionGroup.xml deleted file mode 100644 index 15f6852b4767c..0000000000000 --- a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAdminWithCredentialsActionGroup.xml +++ /dev/null @@ -1,13 +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="LoginAdminWithCredentialsActionGroup" deprecated="Use AdminLoginActionGroup instead"> - <conditionalClick selector="{{AdminUsageNotificationSection.adminUsageDontAllowButton}}" dependentSelector="{{AdminUsageNotificationSection.adminUsageDontAllowButton}}" visible="true" stepKey="clickDontAllowButtonIfVisible" before="closeAdminNotification"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAsAdminActionGroup.xml b/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAsAdminActionGroup.xml deleted file mode 100644 index a2d024bee8b74..0000000000000 --- a/app/code/Magento/AdminAnalytics/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAsAdminActionGroup.xml +++ /dev/null @@ -1,13 +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="LoginAsAdmin" deprecated="Use AdminLoginActionGroup instead"> - <conditionalClick selector="{{AdminUsageNotificationSection.adminUsageDontAllowButton}}" dependentSelector="{{AdminUsageNotificationSection.adminUsageDontAllowButton}}" visible="true" stepKey="clickDontAllowButtonIfVisible" before="closeAdminNotification"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml b/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml index 5da7ccd3c9823..cbcbb3a5dd64c 100644 --- a/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml +++ b/app/code/Magento/Analytics/Test/Mftf/Test/AdminAdvancedReportingButtonTest.xml @@ -22,7 +22,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> </before> <after> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginActionGroup.xml deleted file mode 100644 index 4afabe2d0eff3..0000000000000 --- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginActionGroup.xml +++ /dev/null @@ -1,11 +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="LoginActionGroup" deprecated="Use AdminLoginActionGroup instead" extends="AdminLoginActionGroup"/> -</actionGroups> diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAdminWithCredentialsActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAdminWithCredentialsActionGroup.xml deleted file mode 100644 index cc124990c92ca..0000000000000 --- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAdminWithCredentialsActionGroup.xml +++ /dev/null @@ -1,25 +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="LoginAdminWithCredentialsActionGroup" deprecated="Use AdminLoginActionGroup"> - <annotations> - <description>Login to Backend Admin using provided Admin credentials. PLEASE NOTE: This Action Group does NOT validate that you are Logged In.</description> - </annotations> - <arguments> - <argument name="adminUser" type="string"/> - <argument name="adminPassword" type="string"/> - </arguments> - - <amOnPage url="{{_ENV.MAGENTO_BACKEND_NAME}}" stepKey="navigateToAdmin"/> - <fillField selector="{{AdminLoginFormSection.username}}" userInput="{{adminUser}}" stepKey="fillUsername"/> - <fillField selector="{{AdminLoginFormSection.password}}" userInput="{{adminPassword}}" stepKey="fillPassword"/> - <click selector="{{AdminLoginFormSection.signIn}}" stepKey="clickLogin"/> - <closeAdminNotification stepKey="closeAdminNotification"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAsAdminActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAsAdminActionGroup.xml deleted file mode 100644 index 6fe9f184f5ecf..0000000000000 --- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAsAdminActionGroup.xml +++ /dev/null @@ -1,24 +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="LoginAsAdmin" deprecated="Use AdminLoginActionGroup instead"> - <annotations> - <description>Login to Backend Admin using provided User Data. PLEASE NOTE: This Action Group does NOT validate that you are Logged In.</description> - </annotations> - <arguments> - <argument name="adminUser" type="entity" defaultValue="DefaultAdminUser"/> - </arguments> - - <amOnPage url="{{AdminLoginPage.url}}" stepKey="navigateToAdmin"/> - <fillField selector="{{AdminLoginFormSection.username}}" userInput="{{adminUser.username}}" stepKey="fillUsername"/> - <fillField selector="{{AdminLoginFormSection.password}}" userInput="{{adminUser.password}}" stepKey="fillPassword"/> - <click selector="{{AdminLoginFormSection.signIn}}" stepKey="clickLogin"/> - <closeAdminNotification stepKey="closeAdminNotification"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAsAnyUserActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAsAnyUserActionGroup.xml deleted file mode 100644 index b6cec9056bd5d..0000000000000 --- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LoginAsAnyUserActionGroup.xml +++ /dev/null @@ -1,20 +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="LoginAsAnyUser" deprecated="Use LoginAdminWithCredentialsActionGroup instead"> - <arguments> - <argument name="uname" type="string" defaultValue="{{_ENV.MAGENTO_ADMIN_USERNAME}}"/> - <argument name="passwd" type="string" defaultValue="{{_ENV.MAGENTO_ADMIN_PASSWORD}}"/> - </arguments> - <amOnPage url="{{_ENV.MAGENTO_BACKEND_NAME}}" stepKey="navigateToAdmin"/> - <fillField userInput="{{uname}}" selector="{{LoginFormSection.username}}" stepKey="fillUsername"/> - <fillField userInput="{{passwd}}" selector="{{LoginFormSection.password}}" stepKey="fillPassword"/> - <click selector="{{LoginFormSection.signIn}}" stepKey="clickLogin"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LogoutActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LogoutActionGroup.xml deleted file mode 100644 index ec79c982e730c..0000000000000 --- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/LogoutActionGroup.xml +++ /dev/null @@ -1,11 +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="logout" deprecated="Use AdminLogoutActionGroup instead" extends="AdminLogoutActionGroup"/> -</actionGroups> diff --git a/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml index bb1123d01c867..dbd5348d7d696 100644 --- a/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml +++ b/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml @@ -16,11 +16,5 @@ <element name="messageByType" type="text" selector="#messages div.message-{{messageType}}" parameterized="true" /> <element name="warning" type="text" selector="#messages div.message-warning"/> <element name="accessDenied" type="text" selector=".access-denied-page"/> - <!-- Deprecated elements, please do not use them. Use elements above--> - <!-- Elements below are too common and catch non messages blocks. Ex: system messages blocks--> - <element name="successMessage" type="text" selector=".message-success"/> - <element name="errorMessage" type="text" selector=".message.message-error.error"/> - <element name="warningMessage" type="text" selector=".message-warning"/> - <element name="noticeMessage" type="text" selector=".message-notice"/> </section> </sections> diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginTest.xml deleted file mode 100644 index 09893f5f51e5e..0000000000000 --- a/app/code/Magento/Backend/Test/Mftf/Test/AdminLoginTest.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?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="AdminLoginTest" deprecated="Replaced with AdminLoginSuccessfulTest"> - <annotations> - <features value="Backend"/> - <stories value="Login on the Admin Login page"/> - <title value="Admin should be able to log into the Magento Admin backend"/> - <description value="Admin should be able to log into the Magento Admin backend"/> - <severity value="CRITICAL"/> - <testCaseId value="MAGETWO-71572"/> - <group value="example"/> - <group value="login"/> - </annotations> - - <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> - <seeInCurrentUrl url="{{AdminLoginPage.url}}" stepKey="seeAdminLoginUrl"/> - <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/> - </test> -</tests> diff --git a/app/code/Magento/Braintree/Test/Mftf/Test/BraintreeCreditCardOnCheckoutTest.xml b/app/code/Magento/Braintree/Test/Mftf/Test/BraintreeCreditCardOnCheckoutTest.xml index 0747e785c4ae4..476d8a2e84800 100644 --- a/app/code/Magento/Braintree/Test/Mftf/Test/BraintreeCreditCardOnCheckoutTest.xml +++ b/app/code/Magento/Braintree/Test/Mftf/Test/BraintreeCreditCardOnCheckoutTest.xml @@ -43,10 +43,15 @@ <!--Go to storefront--> <amOnPage url="" stepKey="DoToStorefront"/> <!--Create account--> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUserFromStorefrontActionGroup"> - <argument name="Customer" value="Simple_US_Customer"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="Simple_US_Customer"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> - <!--Add product to cart--> <amOnPage url="$$product.sku$$.html" stepKey="goToProductPage"/> <waitForPageLoad stepKey="waitForPageLoad"/> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/BundleProductWithTierPriceInCartTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/BundleProductWithTierPriceInCartTest.xml index d08ad8970e19f..d6d06fbc21f7d 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/BundleProductWithTierPriceInCartTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/BundleProductWithTierPriceInCartTest.xml @@ -61,8 +61,14 @@ <argument name="price" value="Discount"/> <argument name="amount" value="50"/> </actionGroup> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="signUpNewUser"> - <argument name="Customer" value="CustomerEntityOne"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="CustomerEntityOne"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> <amOnPage url="{{StorefrontProductPage.url(BundleProduct.urlKey)}}" stepKey="goToStorefront"/> <waitForPageLoad stepKey="waitForStorefront"/> diff --git a/app/code/Magento/Captcha/Test/Mftf/ActionGroup/AdminLoginWithCaptchaActionGroup.xml b/app/code/Magento/Captcha/Test/Mftf/ActionGroup/AdminLoginWithCaptchaActionGroup.xml index b84977ba4fcd8..8d09944576538 100644 --- a/app/code/Magento/Captcha/Test/Mftf/ActionGroup/AdminLoginWithCaptchaActionGroup.xml +++ b/app/code/Magento/Captcha/Test/Mftf/ActionGroup/AdminLoginWithCaptchaActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminLoginWithCaptchaActionGroup" extends="LoginAsAdmin"> + <actionGroup name="AdminLoginWithCaptchaActionGroup" extends="AdminLoginActionGroup"> <annotations> <description>EXTENDS: LoginAsAdmin. Fills in the Captcha field on the Backend Admin Login page.</description> </annotations> diff --git a/app/code/Magento/Captcha/Test/Mftf/Test/AdminLoginWithCaptchaTest.xml b/app/code/Magento/Captcha/Test/Mftf/Test/AdminLoginWithCaptchaTest.xml index 962b788aa80bb..28253fb3c00ef 100644 --- a/app/code/Magento/Captcha/Test/Mftf/Test/AdminLoginWithCaptchaTest.xml +++ b/app/code/Magento/Captcha/Test/Mftf/Test/AdminLoginWithCaptchaTest.xml @@ -30,7 +30,7 @@ <magentoCLI command="config:set {{AdminCaptchaDefaultSymbolsConfigData.path}} {{AdminCaptchaDefaultSymbolsConfigData.value}}" stepKey="setDefaultCaptchaSymbols" /> <magentoCLI command="cache:clean config full_page" stepKey="cleanInvalidatedCaches"/> </after> - + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdminWithWrongCredentialsFirstAttempt"> <argument name="username" value="{{AdminUserWrongCredentials.username}}"/> <argument name="password" value="{{AdminUserWrongCredentials.password}}"/> @@ -54,17 +54,19 @@ <!-- Submit form with incorrect captcha --> <actionGroup ref="AdminLoginWithCaptchaActionGroup" stepKey="loginAsAdminWithIncorrectCaptcha"> - <argument name="adminUser" value="DefaultAdminUser" /> - <argument name="captcha" value="{{WrongCaptcha.value}}" /> + <argument name="username" value="{{DefaultAdminUser.username}}"/> + <argument name="password" value="{{DefaultAdminUser.password}}"/> + <argument name="captcha" value="{{WrongCaptcha.value}}"/> </actionGroup> <actionGroup ref="AssertMessageOnAdminLoginActionGroup" stepKey="seeIncorrectCaptchaErrorMessage"> - <argument name="message" value="Incorrect CAPTCHA." /> + <argument name="message" value="Incorrect CAPTCHA."/> </actionGroup> <actionGroup ref="AssertCaptchaVisibleOnAdminLoginFormActionGroup" stepKey="assertCaptchaVisibleAfterIncorrectCaptcha" /> <actionGroup ref="AdminLoginWithCaptchaActionGroup" stepKey="loginAsAdminWithCorrectCaptcha"> - <argument name="adminUser" value="DefaultAdminUser" /> - <argument name="captcha" value="{{PreconfiguredCaptcha.value}}" /> + <argument name="username" value="{{DefaultAdminUser.username}}"/> + <argument name="password" value="{{DefaultAdminUser.password}}"/> + <argument name="captcha" value="{{PreconfiguredCaptcha.value}}"/> </actionGroup> <actionGroup ref="AssertAdminSuccessLoginActionGroup" stepKey="verifyAdminLoggedIn" /> </test> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AddSimpleProductToCartActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AddSimpleProductToCartActionGroup.xml index 68a051c232338..81e3b8c99d9d2 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AddSimpleProductToCartActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AddSimpleProductToCartActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AddSimpleProductToCartActionGroup" deprecated="Avoid using super-ActionGroups. Use StorefrontOpenProductEntityPageActionGroup, StorefrontAddSimpleProductToCartActionGroup and StorefrontAssertProductAddedToCartResultMessageActionGroup"> + <actionGroup name="AddSimpleProductToCartActionGroup"> <annotations> <description>Navigates to the Storefront Product page. Then adds the Product to the Cart. Validates that the Success Message is present and correct.</description> </annotations> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductOnCategoryPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductOnCategoryPageActionGroup.xml index 4bd2c97af7afb..4225ed3a7fcc8 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductOnCategoryPageActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductOnCategoryPageActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertProductOnCategoryPageActionGroup" extends="StorefrontCheckCategorySimpleProductActionGroup"> + <actionGroup name="AssertProductOnCategoryPageActionGroup" extends="StorefrontCheckCategorySimpleProductActionGroup" deprecated="some"> <annotations> <description>DEPRECATED. Use AssertStorefrontProductIsPresentOnCategoryPageActionGroup. EXTENDS:StorefrontCheckCategorySimpleProduct. Removes 'AssertProductPrice', 'moveMouseOverProduct', 'AssertAddToCart'</description> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/SaveCategoryFormActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/SaveCategoryFormActionGroup.xml deleted file mode 100644 index 19f11a2402f56..0000000000000 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/SaveCategoryFormActionGroup.xml +++ /dev/null @@ -1,20 +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="SaveCategoryFormActionGroup"> - <annotations> - <description>DEPRECATED. Use AdminSaveCategoryFormActionGroup instead. Requires navigation to the Category creation/edit page. Checks that the url contains the AdminCategoryPage url. Saves the Category.</description> - </annotations> - - <seeInCurrentUrl url="{{AdminCategoryPage.url}}" stepKey="seeOnCategoryPage"/> - <click selector="{{AdminMainActionsSection.save}}" stepKey="saveCategory"/> - <seeElement selector="{{AdminMessagesSection.success}}" stepKey="assertSuccess"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/_Deprecated_ActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/_Deprecated_ActionGroup.xml deleted file mode 100644 index aff1de23af409..0000000000000 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/_Deprecated_ActionGroup.xml +++ /dev/null @@ -1,12 +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="GoToProductPageViaIDActionGroup" extends="AdminProductPageOpenByIdActionGroup" deprecated="Use AdminProductPageOpenByIdActionGroup instead"/> -</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageForCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageForCategoryTest.xml index dcb900164eba7..e4cf255a03e05 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageForCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageForCategoryTest.xml @@ -34,7 +34,7 @@ <argument name="categoryEntity" value="SimpleSubCategory"/> </actionGroup> <actionGroup ref="AddCategoryImageActionGroup" stepKey="addCategoryImage"/> - <actionGroup ref="SaveCategoryFormActionGroup" stepKey="saveCategoryForm"/> + <actionGroup ref="AdminSaveCategoryFormActionGroup" stepKey="saveCategoryForm"/> <!-- Verify category with image in admin --> <actionGroup ref="CheckCategoryImageInAdminActionGroup" stepKey="checkCategoryImageInAdmin"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckMediaRolesForFirstAddedImageViaApiTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckMediaRolesForFirstAddedImageViaApiTest.xml index dfde5779637a4..b5ccd62401c9b 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckMediaRolesForFirstAddedImageViaApiTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckMediaRolesForFirstAddedImageViaApiTest.xml @@ -27,7 +27,7 @@ <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> <!-- Reindex invalidated indices after product attribute has been created/deleted --> - <actionGroup ref="CliRunReindexUsingCronJobsActionGroup" stepKey="reindexInvalidatedIndices"/> + <magentoCron groups="index" stepKey="reindexInvalidatedIndices"/> </after> <actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="goToSimpleProduct"> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckProductListPriceAttributesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckProductListPriceAttributesTest.xml index c389d447feeba..27b8b06510ee1 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckProductListPriceAttributesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckProductListPriceAttributesTest.xml @@ -33,7 +33,7 @@ <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> <!-- Reindex invalidated indices after product attribute has been created/deleted --> - <actionGroup ref="CliRunReindexUsingCronJobsActionGroup" stepKey="reindexInvalidatedIndices"/> + <magentoCron groups="index" stepKey="reindexInvalidatedIndices"/> </after> <actionGroup ref="ToggleAdminProductGridColumnsDropdownActionGroup" stepKey="openColumnsDropdown"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryRequiredFieldsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryRequiredFieldsTest.xml index a5556b076fef6..624f342741502 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryRequiredFieldsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryRequiredFieldsTest.xml @@ -20,7 +20,7 @@ <group value="mtf_migrated"/> </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="LoginToAdminPanel"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="LoginToAdminPanel"/> </before> <after> <actionGroup ref="DeleteCategoryActionGroup" stepKey="deleteCategory"> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryTest.xml index d302dad52d6e6..61024f1cb3d35 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryTest.xml @@ -30,11 +30,7 @@ <createData entity="_defaultProduct" stepKey="productTwo"> <requiredEntity createDataKey="simpleSubCategoryOne"/> </createData> - - <!-- TODO: Replace this with CliRunReindexUsingCronJobsActionGroup after MC-29943 delivered--> - <magentoCLI command="cron:run" arguments="--group='index'" stepKey="firstRunToScheduleJobs"/> - <magentoCLI command="cron:run" arguments="--group='index'" stepKey="secondRunToExecuteJobs"/> - + <magentoCron groups="index" stepKey="RunToScheduleJobs"/> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> </before> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCustomURLKeyPreservedWhenAssignedToCategoryWithoutCustomURLKeyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCustomURLKeyPreservedWhenAssignedToCategoryWithoutCustomURLKeyTest.xml index 6d197d19eb924..1c536df7c2efb 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCustomURLKeyPreservedWhenAssignedToCategoryWithoutCustomURLKeyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductCustomURLKeyPreservedWhenAssignedToCategoryWithoutCustomURLKeyTest.xml @@ -76,7 +76,7 @@ <argument name="productSku" value="$createSimpleProductSecond.sku$"/> </actionGroup> - <actionGroup ref="SaveCategoryFormActionGroup" stepKey="saveCategory"/> + <actionGroup ref="AdminSaveCategoryFormActionGroup" stepKey="saveCategory"/> <executeJS function="return '$createCategory.name$'.toLowerCase();" stepKey="categoryNameLower" /> <executeJS function="return '$createSimpleProductFirst.name$'.toLowerCase();" stepKey="simpleProductFirstNameLower" /> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminRemoveImageFromCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminRemoveImageFromCategoryTest.xml index ee8636dece808..8033a2dffec7c 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminRemoveImageFromCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminRemoveImageFromCategoryTest.xml @@ -34,12 +34,12 @@ <argument name="categoryEntity" value="SimpleSubCategory"/> </actionGroup> <actionGroup ref="AddCategoryImageActionGroup" stepKey="addCategoryImage"/> - <actionGroup ref="SaveCategoryFormActionGroup" stepKey="saveCategoryForm"/> + <actionGroup ref="AdminSaveCategoryFormActionGroup" stepKey="saveCategoryForm"/> <actionGroup ref="CheckCategoryImageInAdminActionGroup" stepKey="checkCategoryImageInAdmin"/> <!-- Remove image from category --> <actionGroup ref="RemoveCategoryImageActionGroup" stepKey="removeCategoryImage"/> - <actionGroup ref="SaveCategoryFormActionGroup" stepKey="saveCategoryFormAfterRemove"/> + <actionGroup ref="AdminSaveCategoryFormActionGroup" stepKey="saveCategoryFormAfterRemove"/> <actionGroup ref="CheckCategoryOnStorefrontActionGroup" stepKey="CheckCategoryOnStorefront"> <argument name="categoryEntity" value="SimpleSubCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockVisibleInCategoryOnlyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockVisibleInCategoryOnlyTest.xml index cea09b0cdb4bd..595f9bcd489ec 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockVisibleInCategoryOnlyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockVisibleInCategoryOnlyTest.xml @@ -20,7 +20,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="SimpleSubCategory" stepKey="initialCategoryEntity"/> <createData entity="defaultVirtualProduct" stepKey="initialVirtualProduct"> <requiredEntity createDataKey="initialCategoryEntity"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockWithCustomOptionsVisibleInSearchOnlyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockWithCustomOptionsVisibleInSearchOnlyTest.xml index 77de42bdbac21..458d02d61426d 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockWithCustomOptionsVisibleInSearchOnlyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceInStockWithCustomOptionsVisibleInSearchOnlyTest.xml @@ -20,7 +20,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="SimpleSubCategory" stepKey="initialCategoryEntity"/> <createData entity="defaultVirtualProduct" stepKey="initialVirtualProduct"> <requiredEntity createDataKey="initialCategoryEntity"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceOutOfStockVisibleInCategoryAndSearchTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceOutOfStockVisibleInCategoryAndSearchTest.xml index 918cda5274216..6d6ff0b3b1b89 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceOutOfStockVisibleInCategoryAndSearchTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceOutOfStockVisibleInCategoryAndSearchTest.xml @@ -20,7 +20,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="SimpleSubCategory" stepKey="initialCategoryEntity"/> <createData entity="defaultVirtualProduct" stepKey="initialVirtualProduct"> <requiredEntity createDataKey="initialCategoryEntity"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceOutOfStockVisibleInCategoryOnlyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceOutOfStockVisibleInCategoryOnlyTest.xml index 5f6f44110bfb4..d5ae971d87695 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceOutOfStockVisibleInCategoryOnlyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceOutOfStockVisibleInCategoryOnlyTest.xml @@ -20,7 +20,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="SimpleSubCategory" stepKey="initialCategoryEntity"/> <createData entity="defaultVirtualProduct" stepKey="initialVirtualProduct"> <requiredEntity createDataKey="initialCategoryEntity"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceOutOfStockVisibleInSearchOnlyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceOutOfStockVisibleInSearchOnlyTest.xml index 393c280eedf1b..314df67d43d00 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceOutOfStockVisibleInSearchOnlyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithRegularPriceOutOfStockVisibleInSearchOnlyTest.xml @@ -20,7 +20,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="SimpleSubCategory" stepKey="initialCategoryEntity"/> <createData entity="defaultVirtualProduct" stepKey="initialVirtualProduct"> <requiredEntity createDataKey="initialCategoryEntity"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithSpecialPriceInStockVisibleInCategoryAndSearchTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithSpecialPriceInStockVisibleInCategoryAndSearchTest.xml index 9658597a04717..d0f4fc8882e3f 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithSpecialPriceInStockVisibleInCategoryAndSearchTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithSpecialPriceInStockVisibleInCategoryAndSearchTest.xml @@ -20,7 +20,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="SimpleSubCategory" stepKey="initialCategoryEntity"/> <createData entity="defaultVirtualProduct" stepKey="initialVirtualProduct"> <requiredEntity createDataKey="initialCategoryEntity"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithSpecialPriceOutOfStockVisibleInCategoryAndSearchTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithSpecialPriceOutOfStockVisibleInCategoryAndSearchTest.xml index 9d3d315487d65..2234d6f338b62 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithSpecialPriceOutOfStockVisibleInCategoryAndSearchTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithSpecialPriceOutOfStockVisibleInCategoryAndSearchTest.xml @@ -20,7 +20,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="SimpleSubCategory" stepKey="initialCategoryEntity"/> <createData entity="defaultVirtualProduct" stepKey="initialVirtualProduct"> <requiredEntity createDataKey="initialCategoryEntity"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryAndSearchTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryAndSearchTest.xml index f5571633c2da4..e0c5d83b4b014 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryAndSearchTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryAndSearchTest.xml @@ -25,10 +25,8 @@ <requiredEntity createDataKey="initialCategoryEntity"/> </createData> <createData entity="SimpleSubCategory" stepKey="categoryEntity"/> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> - - <!-- TODO: Replace this with CliRunReindexUsingCronJobsActionGroup after MC-29943 delivered--> - <magentoCLI command="indexer:reindex" arguments="catalogsearch_fulltext catalog_category_product" stepKey="reindexIndices"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + <magentoCron groups="index" stepKey="RunToScheduleJobs"/> </before> <after> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryOnlyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryOnlyTest.xml index 5c0b7c31756ca..8f0861fe33371 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryOnlyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryOnlyTest.xml @@ -20,7 +20,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="SimpleSubCategory" stepKey="initialCategoryEntity"/> <createData entity="defaultVirtualProduct" stepKey="initialVirtualProduct"> <requiredEntity createDataKey="initialCategoryEntity"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceOutOfStockVisibleInCategoryAndSearchTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceOutOfStockVisibleInCategoryAndSearchTest.xml index eeb85e8d6fc2e..f7f5385381590 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceOutOfStockVisibleInCategoryAndSearchTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceOutOfStockVisibleInCategoryAndSearchTest.xml @@ -20,7 +20,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="SimpleSubCategory" stepKey="initialCategoryEntity"/> <createData entity="defaultVirtualProduct" stepKey="initialVirtualProduct"> <requiredEntity createDataKey="initialCategoryEntity"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserMysqlTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserMysqlTest.xml index f334a6c5a66ce..6630557b37bd0 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserMysqlTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserMysqlTest.xml @@ -59,8 +59,8 @@ <!-- Step 1: User browses catalog --> <comment userInput="Start of browsing catalog" stepKey="startOfBrowsingCatalog"/> <actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToHomePage"/> - <waitForElementVisible selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="homeWaitForWelcomeMessage"/> - <see userInput="Default welcome msg!" selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="homeCheckWelcome"/> + <waitForElementVisible selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="homeWaitForWelcomeMessage"/> + <see userInput="Default welcome msg!" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="homeCheckWelcome"/> <!-- Open Category --> <comment userInput="Open category" stepKey="commentOpenCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserTest.xml index 94b0deaf6ce1c..441c9cd5eab8b 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserTest.xml @@ -62,8 +62,8 @@ <!-- Step 1: User browses catalog --> <comment userInput="Start of browsing catalog" stepKey="startOfBrowsingCatalog"/> <actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToHomePage"/> - <waitForElementVisible selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="homeWaitForWelcomeMessage"/> - <see userInput="Default welcome msg!" selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="homeCheckWelcome"/> + <waitForElementVisible selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="homeWaitForWelcomeMessage"/> + <see userInput="Default welcome msg!" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="homeCheckWelcome"/> <!-- Open Category --> <comment userInput="Open category" stepKey="commentOpenCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml index 4eb5b843eeb35..fbb6893e92b1e 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml @@ -49,8 +49,8 @@ <comment userInput="Start of browsing catalog" stepKey="startOfBrowsingCatalog" after="endOfSigningUpUserAccount"/> <amOnPage url="{{StorefrontHomePage.url}}" stepKey="amOnHomePage" after="startOfBrowsingCatalog"/> <waitForPageLoad stepKey="homeWaitForPageLoad" after="amOnHomePage"/> - <waitForElementVisible selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="homeWaitForWelcomeMessage" after="homeWaitForPageLoad"/> - <see userInput="Welcome, John Doe!" selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="homeCheckWelcome" after="homeWaitForWelcomeMessage"/> + <waitForElementVisible selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="homeWaitForWelcomeMessage" after="homeWaitForPageLoad"/> + <see userInput="Welcome, John Doe!" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="homeCheckWelcome" after="homeWaitForWelcomeMessage"/> <!-- Open Category --> <comment userInput="Open category" stepKey="commentOpenCategory" after="homeCheckWelcome"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontProductsDisplayUsingElasticSearchTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontProductsDisplayUsingElasticSearchTest.xml index ea7912613f7f2..e109dcb0deea5 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontProductsDisplayUsingElasticSearchTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontProductsDisplayUsingElasticSearchTest.xml @@ -113,7 +113,7 @@ <requiredEntity createDataKey="createCategory1"/> </createData> - <actionGroup ref="CliRunReindexUsingCronJobsActionGroup" stepKey="reindexInvalidatedIndices"/> + <magentoCron groups="index" stepKey="reindexInvalidatedIndices"/> <magentoCLI command="indexer:reindex" arguments="catalogsearch_fulltext" stepKey="performReindex"/> <magentoCLI command="cache:clean" arguments="full_page" stepKey="cleanFullPageCache"/> </before> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontConfigurableOptionsThumbImagesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontConfigurableOptionsThumbImagesTest.xml index c22f91b5394ea..dec36d72a50d6 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontConfigurableOptionsThumbImagesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontConfigurableOptionsThumbImagesTest.xml @@ -165,7 +165,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> <!-- Reindex invalidated indices after product attribute has been created/deleted --> - <actionGroup ref="CliRunReindexUsingCronJobsActionGroup" stepKey="reindexInvalidatedIndices"/> + <magentoCron groups="index" stepKey="reindexInvalidatedIndices"/> </after> <!-- Open ConfigProduct in Store Front Page --> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontEnsureThatAccordionAnchorIsVisibleOnViewportOnceClickedTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontEnsureThatAccordionAnchorIsVisibleOnViewportOnceClickedTest.xml index 8acc6272d5da4..020c3d85b9fdf 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontEnsureThatAccordionAnchorIsVisibleOnViewportOnceClickedTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontEnsureThatAccordionAnchorIsVisibleOnViewportOnceClickedTest.xml @@ -90,8 +90,14 @@ <actionGroup ref="SaveProductFormActionGroup" stepKey="saveSimpleProduct"/> <!-- Go to frontend and make a user account and login with it --> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="signUpNewUser"> - <argument name="Customer" value="CustomerEntityOne"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="CustomerEntityOne"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> <!-- Go to the product view page --> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleForCustomerGroupTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleForCustomerGroupTest.xml index 65ef23de65380..b9318f72bee9e 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleForCustomerGroupTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleForCustomerGroupTest.xml @@ -56,8 +56,14 @@ <see selector="{{StorefrontCategoryProductSection.ProductInfoByNumber('1')}}" userInput="$110.70" stepKey="seeDiscountedPrice1"/> <!-- Create a user account --> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="createAnAccount"> - <argument name="Customer" value="CustomerEntityOne"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="CustomerEntityOne"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> <!-- As a logged in user, go to the storefront category page and should NOT see discount --> diff --git a/app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithAssignedSimpleProductsTest.xml b/app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithAssignedSimpleProductsTest.xml index e4dd65479b784..4cc9449557520 100644 --- a/app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithAssignedSimpleProductsTest.xml +++ b/app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithAssignedSimpleProductsTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> - <test name="AdminApplyCatalogRuleForConfigurableProductWithAssignedSimpleProductsTest"> + <test name="AdminApplyCatalogRuleForConfigurableProductWithAssignedSimpleProductsTest" deprecated="some"> <annotations> <features value="CatalogRuleConfigurable"/> <stories value="Apply catalog price rule"/> diff --git a/app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithOptionsTest.xml b/app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithOptionsTest.xml index 8ed9c6ad09dad..436fc7714ce2d 100644 --- a/app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithOptionsTest.xml +++ b/app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithOptionsTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> - <test name="AdminApplyCatalogRuleForConfigurableProductWithOptionsTest"> + <test name="AdminApplyCatalogRuleForConfigurableProductWithOptionsTest" deprecated="some"> <annotations> <features value="CatalogRuleConfigurable"/> <stories value="Apply catalog price rule"/> diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminDeleteSearchTermTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminDeleteSearchTermTest.xml index a950fb6c379cb..c376456a64ac4 100644 --- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminDeleteSearchTermTest.xml +++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdminDeleteSearchTermTest.xml @@ -20,7 +20,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="SimpleSubCategory" stepKey="initialCategoryEntity"/> <createData entity="SimpleProduct" stepKey="simpleProduct"> <requiredEntity createDataKey="initialCategoryEntity"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml index e2d1a1b9139c8..c3713206ed1d2 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml @@ -31,8 +31,14 @@ <amOnPage url="" stepKey="DoToStorefront"/> <!-- Fill out form for a new user with address --> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="signUpNewUser"> - <argument name="Customer" value="Simple_US_Customer_NY"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="Simple_US_Customer_NY"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> <!-- Add simple product to cart --> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml index 9152949fbf2a1..27597a72fdb7f 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerLoginDuringCheckoutTest.xml @@ -41,7 +41,15 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <!-- Go to Storefront as Guest and create new account --> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="createNewCustomerAccount"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="CustomerEntityOne"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> + </actionGroup> <!-- Sign Out --> <actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="customerLogout"/> diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminCheckCreateFolderEscapeAndEnterHandlesForWYSIWYGBlockTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminCheckCreateFolderEscapeAndEnterHandlesForWYSIWYGBlockTest.xml index 0644542ccc0f3..aa29f33f90664 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/AdminCheckCreateFolderEscapeAndEnterHandlesForWYSIWYGBlockTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminCheckCreateFolderEscapeAndEnterHandlesForWYSIWYGBlockTest.xml @@ -20,7 +20,7 @@ <before> <createData entity="_defaultBlock" stepKey="createPreReqBlock" /> - <actionGroup ref="LoginActionGroup" stepKey="login"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="login"/> <actionGroup ref="EnabledWYSIWYGActionGroup" stepKey="enableWYSIWYG"/> <actionGroup ref="SwitchToVersion4ActionGroup" stepKey="switchToTinyMCE4" /> </before> diff --git a/app/code/Magento/Config/Test/Mftf/Test/CheckingCountryDropDownWithOneAllowedCountryTest.xml b/app/code/Magento/Config/Test/Mftf/Test/CheckingCountryDropDownWithOneAllowedCountryTest.xml index 9e05f4819cd73..5327979154389 100644 --- a/app/code/Magento/Config/Test/Mftf/Test/CheckingCountryDropDownWithOneAllowedCountryTest.xml +++ b/app/code/Magento/Config/Test/Mftf/Test/CheckingCountryDropDownWithOneAllowedCountryTest.xml @@ -35,8 +35,14 @@ <!--Flush Magento Cache--> <magentoCLI stepKey="flushCache" command="cache:flush"/> <!--Create a customer account from Storefront--> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="createAnAccount"> - <argument name="Customer" value="CustomerEntityOne"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="CustomerEntityOne"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> <click selector="{{CheckoutPaymentSection.addressBook}}" stepKey="goToAddressBook"/> <click selector="{{StorefrontCustomerAddressSection.country}}" stepKey="clickToExpandCountryDropDown"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml index 85c852d09e916..e4a9755adcef4 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml @@ -62,7 +62,7 @@ </createData> <updateData entity="ApiSimpleProductUpdateDescription" stepKey="updateConfigProduct" createDataKey="createConfigProduct"/> <!-- Reindex invalidated indices after product attribute has been created/deleted --> - <actionGroup ref="CliRunReindexUsingCronJobsActionGroup" stepKey="reindexInvalidatedIndices"/> + <magentoCron groups="index" stepKey="reindexInvalidatedIndices"/> </before> <after> <!-- @TODO: Uncomment once MQE-679 is fixed --> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontGalleryConfigurableProductWithSeveralAttributesPrependMediaTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontGalleryConfigurableProductWithSeveralAttributesPrependMediaTest.xml index a50d1e32d3614..3e74edfb68074 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontGalleryConfigurableProductWithSeveralAttributesPrependMediaTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontGalleryConfigurableProductWithSeveralAttributesPrependMediaTest.xml @@ -141,7 +141,7 @@ <actionGroup ref="SaveProductFormActionGroup" stepKey="saveConfigurableProductVariationOption2Option2"/> <!-- Reindex invalidated indices after product attribute has been created --> - <actionGroup ref="CliRunReindexUsingCronJobsActionGroup" stepKey="reindexInvalidatedIndicesAfterCreateAttributes"/> + <magentoCron groups="index" stepKey="reindexInvalidatedIndicesAfterCreateAttributes"/> </before> <after> @@ -160,7 +160,7 @@ <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearProductAttributeGridFilters"/> <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/> <!-- Reindex invalidated indices after product attribute has been created --> - <actionGroup ref="CliRunReindexUsingCronJobsActionGroup" stepKey="reindexInvalidatedIndicesAfterDeleteAttributes"/> + <magentoCron groups="index" stepKey="reindexInvalidatedIndicesAfterDeleteAttributes"/> </after> <actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openConfigurableProductPage"> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontGalleryConfigurableProductWithVisualSwatchAttributePrependMediaTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontGalleryConfigurableProductWithVisualSwatchAttributePrependMediaTest.xml index be81b64c7ed25..c76d49a76d947 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontGalleryConfigurableProductWithVisualSwatchAttributePrependMediaTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontGalleryConfigurableProductWithVisualSwatchAttributePrependMediaTest.xml @@ -106,7 +106,7 @@ <actionGroup ref="SaveProductFormActionGroup" stepKey="saveConfigurableProductVariationOption3"/> <!-- Reindex invalidated indices after product attribute has been created --> - <actionGroup ref="CliRunReindexUsingCronJobsActionGroup" stepKey="reindexInvalidatedIndicesAfterCreateAttributes"/> + <magentoCron groups="index" stepKey="reindexInvalidatedIndicesAfterCreateAttributes"/> </before> <after> @@ -122,7 +122,7 @@ <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearProductAttributeGridFilters"/> <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/> <!-- Reindex invalidated indices after product attribute has been created --> - <actionGroup ref="CliRunReindexUsingCronJobsActionGroup" stepKey="reindexInvalidatedIndicesAfterDeleteAttributes"/> + <magentoCron groups="index" stepKey="reindexInvalidatedIndicesAfterDeleteAttributes"/> </after> <actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openConfigurableProductPage"> diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminCurrencyConverterAPIConfigurationTest.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminCurrencyConverterAPIConfigurationTest.xml index 5d6d05ebfead4..f7e6e05347345 100644 --- a/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminCurrencyConverterAPIConfigurationTest.xml +++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminCurrencyConverterAPIConfigurationTest.xml @@ -47,14 +47,14 @@ <actionGroup ref="AdminImportCurrencyRatesActionGroup" stepKey="importCurrencyRates"> <argument name="rateService" value="Currency Converter API"/> </actionGroup> - <see selector="{{AdminMessagesSection.warningMessage}}" userInput='Click "Save" to apply the rates we found.' stepKey="seeImportMessage"/> - <see selector="{{AdminMessagesSection.warningMessage}}" userInput="We can't retrieve a rate from https://free.currconv.com for CHE." stepKey="seeWarningMessageForCHE"/> - <see selector="{{AdminMessagesSection.warningMessage}}" userInput="We can't retrieve a rate from https://free.currconv.com for RHD." stepKey="seeWarningMessageForRHD"/> - <see selector="{{AdminMessagesSection.warningMessage}}" userInput="We can't retrieve a rate from https://free.currconv.com for CHW." stepKey="seeWarningMessageForCHW"/> + <see selector="{{AdminMessagesSection.warning}}" userInput='Click "Save" to apply the rates we found.' stepKey="seeImportMessage"/> + <see selector="{{AdminMessagesSection.warning}}" userInput="We can't retrieve a rate from https://free.currconv.com for CHE." stepKey="seeWarningMessageForCHE"/> + <see selector="{{AdminMessagesSection.warning}}" userInput="We can't retrieve a rate from https://free.currconv.com for RHD." stepKey="seeWarningMessageForRHD"/> + <see selector="{{AdminMessagesSection.warning}}" userInput="We can't retrieve a rate from https://free.currconv.com for CHW." stepKey="seeWarningMessageForCHW"/> <actionGroup ref="AdminSaveCurrencyRatesActionGroup" stepKey="saveCurrencyRates"/> - <see selector="{{AdminMessagesSection.warningMessage}}" userInput='Please correct the input data for "USD => CHE" rate' stepKey="seeCHEMessageAfterSave"/> - <see selector="{{AdminMessagesSection.warningMessage}}" userInput='Please correct the input data for "USD => RHD" rate' stepKey="seeRHDMessageAfterSave"/> - <see selector="{{AdminMessagesSection.warningMessage}}" userInput='Please correct the input data for "USD => CHW" rate' stepKey="seeCHWMessageAfterSave"/> + <see selector="{{AdminMessagesSection.warning}}" userInput='Please correct the input data for "USD => CHE" rate' stepKey="seeCHEMessageAfterSave"/> + <see selector="{{AdminMessagesSection.warning}}" userInput='Please correct the input data for "USD => RHD" rate' stepKey="seeRHDMessageAfterSave"/> + <see selector="{{AdminMessagesSection.warning}}" userInput='Please correct the input data for "USD => CHW" rate' stepKey="seeCHWMessageAfterSave"/> <!--Go to the Storefront and check currency rates--> <amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="onCategoryPage"/> <waitForPageLoad stepKey="waitForCategoryPageLoad"/> @@ -74,6 +74,6 @@ <actionGroup ref="AdminImportCurrencyRatesActionGroup" stepKey="importCurrencyRatesGreaterThen10"> <argument name="rateService" value="Currency Converter API"/> </actionGroup> - <see selector="{{AdminMessagesSection.warningMessage}}" userInput="Too many pairs. Maximum of 10 is supported for the free version." stepKey="seeTooManyPairsMessage"/> + <see selector="{{AdminMessagesSection.warning}}" userInput="Too many pairs. Maximum of 10 is supported for the free version." stepKey="seeTooManyPairsMessage"/> </test> </tests> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertStorefrontDefaultWelcomeMessageActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertStorefrontDefaultWelcomeMessageActionGroup.xml index eb66cafe43dd3..7cfbc0283d505 100644 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertStorefrontDefaultWelcomeMessageActionGroup.xml +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertStorefrontDefaultWelcomeMessageActionGroup.xml @@ -13,8 +13,8 @@ <description>Validates that the Welcome message is present and correct and not you link absent.</description> </annotations> - <waitForElementVisible selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="waitDefaultMessage"/> - <see userInput="Default welcome msg!" selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="verifyDefaultMessage"/> + <waitForElementVisible selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="waitDefaultMessage"/> + <see userInput="Default welcome msg!" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="verifyDefaultMessage"/> <dontSeeElement selector="{{StorefrontPanelHeaderSection.notYouLink}}" stepKey="checkAbsenceLinkNotYou"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/EnterCustomerAddressInfoFillStateActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/EnterCustomerAddressInfoFillStateActionGroup.xml index 891b578e54e6b..257c9d5039c61 100644 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/EnterCustomerAddressInfoFillStateActionGroup.xml +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/EnterCustomerAddressInfoFillStateActionGroup.xml @@ -10,7 +10,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> <actionGroup name="EnterCustomerAddressInfoFillStateActionGroup" extends="EnterCustomerAddressInfoActionGroup"> <annotations> - <description>EXTENDS: EnterCustomerAddressInfo. Fills the State field.</description> + <description>EXTENDS: EnterCustomerAddressInfoActionGroup. Fills the State field.</description> </annotations> <fillField stepKey="selectState" selector="{{StorefrontCustomerAddressSection.stateProvinceFill}}" userInput="{{Address.state}}"/> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/SignUpNewUserFromStorefrontActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/SignUpNewUserFromStorefrontActionGroup.xml index 59601a58e64c7..56afa8854ce0d 100644 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/SignUpNewUserFromStorefrontActionGroup.xml +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/SignUpNewUserFromStorefrontActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="SignUpNewUserFromStorefrontActionGroup" deprecated="Avoid using super-ActionGroups. See StorefrontCreateCustomerTest for replacement."> + <actionGroup name="SignUpNewUserFromStorefrontActionGroup"> <annotations> <description>Goes to the Storefront. Clicks on 'Create Account'. Fills in the provided Customer details, excluding Newsletter Sign-Up. Clicks on 'Create Account' button. Validate that the Customer details are present and correct.</description> </annotations> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminCreateCustomerWithWebSiteAndGroupActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminCreateCustomerWithWebSiteAndGroupActionGroup.xml deleted file mode 100644 index 37b543f68935a..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminCreateCustomerWithWebSiteAndGroupActionGroup.xml +++ /dev/null @@ -1,33 +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="AdminCreateCustomerWithWebSiteAndGroup" deprecated="Use `AdminCreateCustomerWithWebSiteAndGroupActionGroup` instead"> - <annotations> - <description>Goes to the Customer grid page. Click on 'Add New Customer'. Fills provided Customer Data. Fill provided Customer Address data. Assigns Product to Website and Store View. Clicks on Save.</description> - </annotations> - <arguments> - <argument name="customerData" defaultValue="Simple_US_Customer"/> - <argument name="website" type="string" defaultValue="{{_defaultWebsite.name}}"/> - <argument name="storeView" type="string" defaultValue="{{_defaultStore.name}}"/> - </arguments> - - <amOnPage url="{{AdminCustomerPage.url}}" stepKey="goToCustomersPage"/> - <click stepKey="addNewCustomer" selector="{{AdminCustomerGridMainActionsSection.addNewCustomer}}"/> - <selectOption stepKey="selectWebSite" selector="{{AdminCustomerAccountInformationSection.associateToWebsite}}" userInput="{{website}}"/> - <selectOption selector="{{AdminCustomerAccountInformationSection.group}}" userInput="{{customerData.group}}" stepKey="selectCustomerGroup"/> - <fillField stepKey="FillFirstName" selector="{{AdminCustomerAccountInformationSection.firstName}}" userInput="{{customerData.firstname}}"/> - <fillField stepKey="FillLastName" selector="{{AdminCustomerAccountInformationSection.lastName}}" userInput="{{customerData.lastname}}"/> - <fillField stepKey="FillEmail" selector="{{AdminCustomerAccountInformationSection.email}}" userInput="{{customerData.email}}"/> - <selectOption stepKey="selectStoreView" selector="{{AdminCustomerAccountInformationSection.storeView}}" userInput="{{storeView}}"/> - <waitForElement selector="{{AdminCustomerAccountInformationSection.storeView}}" stepKey="waitForCustomerStoreViewExpand"/> - <click stepKey="save" selector="{{AdminCustomerAccountInformationSection.saveCustomer}}"/> - <waitForPageLoad stepKey="waitForCustomersPage"/> - <see stepKey="seeSuccessMessage" userInput="You saved the customer."/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminEditCustomerAddressNoZipNoStateActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminEditCustomerAddressNoZipNoStateActionGroup.xml deleted file mode 100644 index ebfd011115459..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminEditCustomerAddressNoZipNoStateActionGroup.xml +++ /dev/null @@ -1,20 +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="AdminEditCustomerAddressNoZipNoState" extends="AdminEditCustomerAddressesFrom" deprecated="Use `AdminEditCustomerAddressNoZipNoStateActionGroup` instead"> - <annotations> - <description>EXTENDS: AdminEditCustomerAddressesFrom. Removes 'selectState' and 'fillZipCode'. Clicks on 'Set Default' for Billing/Shipping.</description> - </annotations> - - <remove keyForRemoval="selectState"/> - <remove keyForRemoval="fillZipCode"/> - <click selector="{{AdminEditCustomerAddressesSection.defaultBillingAddressButton}}" stepKey="setDefaultBilling" before="setDefaultShipping"/> - <click selector="{{AdminEditCustomerAddressesSection.defaultShippingAddressButton}}" stepKey="setDefaultShipping" before="fillPrefixName"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminEditCustomerAddressSetDefaultShippingAndBillingActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminEditCustomerAddressSetDefaultShippingAndBillingActionGroup.xml deleted file mode 100644 index 326eee275f1f1..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminEditCustomerAddressSetDefaultShippingAndBillingActionGroup.xml +++ /dev/null @@ -1,18 +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="AdminEditCustomerAddressSetDefaultShippingAndBilling" extends="AdminEditCustomerAddressesFrom" deprecated="Use `AdminEditCustomerAddressSetDefaultShippingAndBillingActionGroup` instead"> - <annotations> - <description>EXTENDS: AdminEditCustomerAddressesFrom. Removes 'selectState' and 'fillZipCode'.</description> - </annotations> - - <click selector="{{AdminEditCustomerAddressesSection.defaultBillingAddressButton}}" stepKey="setDefaultBilling" before="setDefaultShipping"/> - <click selector="{{AdminEditCustomerAddressesSection.defaultShippingAddressButton}}" stepKey="setDefaultShipping" before="fillPrefixName"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/EnterCustomerAddressInfoActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/EnterCustomerAddressInfoActionGroup.xml deleted file mode 100644 index 0634e0564f04b..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/EnterCustomerAddressInfoActionGroup.xml +++ /dev/null @@ -1,32 +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="EnterCustomerAddressInfo" deprecated="Use `EnterCustomerAddressInfoActionGroup` instead"> - <annotations> - <description>Fills in the provided Customer details (First/Last Name, Company, Phone # and Address) on the Admin Customer creation/edit page. Clicks on the Save button.</description> - </annotations> - <arguments> - <argument name="Address"/> - </arguments> - - <amOnPage url="customer/address/new/" stepKey="goToAddressPage"/> - <waitForPageLoad stepKey="waitForAddressPage"/> - <fillField stepKey="fillFirstName" selector="{{StorefrontCustomerAddressSection.firstName}}" userInput="{{Address.firstname}}"/> - <fillField stepKey="fillLastName" selector="{{StorefrontCustomerAddressSection.lastName}}" userInput="{{Address.lastname}}"/> - <fillField stepKey="fillCompany" selector="{{StorefrontCustomerAddressSection.company}}" userInput="{{Address.company}}"/> - <fillField stepKey="fillPhoneNumber" selector="{{StorefrontCustomerAddressSection.phoneNumber}}" userInput="{{Address.telephone}}"/> - <fillField stepKey="fillStreetAddress1" selector="{{StorefrontCustomerAddressSection.streetAddress1}}" userInput="{{Address.street[0]}}"/> - <fillField stepKey="fillStreetAddress2" selector="{{StorefrontCustomerAddressSection.streetAddress2}}" userInput="{{Address.street[1]}}"/> - <fillField stepKey="fillCityName" selector="{{StorefrontCustomerAddressSection.city}}" userInput="{{Address.city}}"/> - <selectOption stepKey="selectCounty" selector="{{StorefrontCustomerAddressSection.country}}" userInput="{{Address.country_id}}"/> - <selectOption stepKey="selectState" selector="{{StorefrontCustomerAddressSection.stateProvince}}" userInput="{{Address.state}}"/> - <fillField stepKey="fillZip" selector="{{StorefrontCustomerAddressSection.zip}}" userInput="{{Address.postcode}}"/> - <click stepKey="saveAddress" selector="{{StorefrontCustomerAddressSection.saveAddress}}"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/EnterCustomerAddressInfoFillStateActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/EnterCustomerAddressInfoFillStateActionGroup.xml deleted file mode 100644 index 0705d1d0c8f2a..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/EnterCustomerAddressInfoFillStateActionGroup.xml +++ /dev/null @@ -1,17 +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="EnterCustomerAddressInfoFillState" extends="EnterCustomerAddressInfo" deprecated="Use `CreateSystemBackupActionGroup` instead"> - <annotations> - <description>EXTENDS: EnterCustomerAddressInfo. Fills the State field.</description> - </annotations> - - <fillField stepKey="selectState" selector="{{StorefrontCustomerAddressSection.stateProvinceFill}}" userInput="{{Address.state}}"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/NavigateToCustomerGroupPageActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/NavigateToCustomerGroupPageActionGroup.xml deleted file mode 100644 index 606089acf15d6..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/NavigateToCustomerGroupPageActionGroup.xml +++ /dev/null @@ -1,11 +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="NavigateToCustomerGroupPage" extends="AdminNavigateToCustomerGroupPageActionGroup" deprecated="Use AdminNavigateToCustomerGroupPageActionGroup"/> -</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerBillingAddressActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerBillingAddressActionGroup.xml deleted file mode 100644 index dd5bff2d5488c..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerBillingAddressActionGroup.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="VerifyCustomerBillingAddress" deprecated="Use `VerifyCustomerBillingAddressActionGroup` instead"> - <annotations> - <description>Goes to the Storefront Customer Dashboard Address area. Validates that the provided Customer Billing Address is present and correct on the Storefront Customer Dashboard Address section.</description> - </annotations> - <arguments> - <argument name="address"/> - </arguments> - - <amOnPage url="customer/address/index/" stepKey="goToAddressPage"/> - <waitForPageLoad stepKey="waitForAddressPageLoad"/> - - <see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.firstname}} {{address.lastname}}" stepKey="seeAssertCustomerDefaultBillingAddressFirstnameAndLastname"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.company}}" stepKey="seeAssertCustomerDefaultBillingAddressCompany"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.street[0]}}" stepKey="seeAssertCustomerDefaultBillingAddressStreet"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.street[1]}}" stepKey="seeAssertCustomerDefaultBillingAddressStreet1"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.city}}, {{address.postcode}}" stepKey="seeAssertCustomerDefaultBillingAddressCityAndPostcode"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.country}}" stepKey="seeAssertCustomerDefaultBillingAddressCountry"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.telephone}}" stepKey="seeAssertCustomerDefaultBillingAddressTelephone"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerBillingAddressWithStateActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerBillingAddressWithStateActionGroup.xml deleted file mode 100644 index 47403b23d7026..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerBillingAddressWithStateActionGroup.xml +++ /dev/null @@ -1,28 +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="VerifyCustomerBillingAddressWithState" deprecated="Use `VerifyCustomerBillingAddressWithStateActionGroup` instead"> - <annotations> - <description>Goes to the Storefront Customer Dashboard Address area. Validates that the provided Customer Billing Address, including the State, is present and correct.</description> - </annotations> - <arguments> - <argument name="address"/> - </arguments> - - <amOnPage url="customer/address/index/" stepKey="goToAddressPage"/> - <waitForPageLoad stepKey="waitForAddressPageLoad"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.firstname}} {{address.lastname}}" stepKey="seeAssertCustomerDefaultBillingAddressFirstnameAndLastname"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.company}}" stepKey="seeAssertCustomerDefaultBillingAddressCompany"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.street[0]}}" stepKey="seeAssertCustomerDefaultBillingAddressStreet"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.street[1]}}" stepKey="seeAssertCustomerDefaultBillingAddressStreet1"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.city}}, {{address.state}}, {{address.postcode}}" stepKey="seeAssertCustomerDefaultBillingAddressCityAndPostcode"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.country}}" stepKey="seeAssertCustomerDefaultBillingAddressCountry"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultBillingAddress}}" userInput="{{address.telephone}}" stepKey="seeAssertCustomerDefaultBillingAddressTelephone"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerNameOnFrontendActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerNameOnFrontendActionGroup.xml deleted file mode 100644 index cc01f3ade85ac..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerNameOnFrontendActionGroup.xml +++ /dev/null @@ -1,25 +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="VerifyCustomerNameOnFrontend" deprecated="Use `VerifyCustomerNameOnFrontendActionGroup` instead"> - <annotations> - <description>Goes to the Storefront Customer Dashboard page. Validates that the Customer First/Last Name is present and correct.</description> - </annotations> - <arguments> - <argument name="customer"/> - </arguments> - - <amOnPage url="customer/account/edit/" stepKey="goToAddressPage"/> - <waitForPageLoad stepKey="waitForAddressPageLoad"/> - <click selector="{{StorefrontCustomerSidebarSection.sidebarCurrentTab('Account Information')}}" stepKey="clickAccountInformationFromSidebarCurrentTab"/> - <waitForPageLoad stepKey="waitForAccountInformationTabToOpen"/> - <seeInField selector="{{StorefrontCustomerAccountInformationSection.firstName}}" userInput="{{customer.firstname}}" stepKey="seeAssertCustomerFirstName"/> - <seeInField selector="{{StorefrontCustomerAccountInformationSection.lastName}}" userInput="{{customer.lastname}}" stepKey="seeAssertCustomerLastName"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerShippingAddressActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerShippingAddressActionGroup.xml deleted file mode 100644 index 1d9f3fd600155..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerShippingAddressActionGroup.xml +++ /dev/null @@ -1,28 +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="VerifyCustomerShippingAddress" deprecated="Use `VerifyCustomerShippingAddressActionGroup` instead"> - <annotations> - <description>Goes to the Storefront Customer Dashboard Address area. Validates that the provided Customer Shipping Address is present and correct.</description> - </annotations> - <arguments> - <argument name="address"/> - </arguments> - - <amOnPage url="customer/address/index/" stepKey="goToAddressPage"/> - <waitForPageLoad stepKey="waitForAddressPageLoad"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.firstname}} {{address.lastname}}" stepKey="seeAssertCustomerDefaultShippingAddressFirstnameAndLastname"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.company}}" stepKey="seeAssertCustomerDefaultShippingAddressCompany"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.street[0]}}" stepKey="seeAssertCustomerDefaultShippingAddressStreet"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.street[1]}}" stepKey="seeAssertCustomerDefaultShippingAddressStreet1"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.city}}, {{address.postcode}}" stepKey="seeAssertCustomerDefaultShippingAddressCityAndPostcode"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.country}}" stepKey="seeAssertCustomerDefaultShippingAddressCountry"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.telephone}}" stepKey="seeAssertCustomerDefaultShippingAddressTelephone"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerShippingAddressWithStateActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerShippingAddressWithStateActionGroup.xml deleted file mode 100644 index 3291f9c8a7ef2..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyCustomerShippingAddressWithStateActionGroup.xml +++ /dev/null @@ -1,28 +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="VerifyCustomerShippingAddressWithState" deprecated="Use `VerifyCustomerShippingAddressWithStateActionGroup` instead"> - <annotations> - <description>Goes to the Storefront Customer Dashboard Address area. Validates that the provided Customer Shipping Address, including the State, is present and correct.</description> - </annotations> - <arguments> - <argument name="address"/> - </arguments> - - <amOnPage url="customer/address/index/" stepKey="goToAddressPage"/> - <waitForPageLoad stepKey="waitForAddressPageLoad"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.firstname}} {{address.lastname}}" stepKey="seeAssertCustomerDefaultShippingAddressFirstnameAndLastname"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.company}}" stepKey="seeAssertCustomerDefaultShippingAddressCompany"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.street[0]}}" stepKey="seeAssertCustomerDefaultShippingAddressStreet"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.street[1]}}" stepKey="seeAssertCustomerDefaultShippingAddressStreet1"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.city}}, {{address.state}}, {{address.postcode}}" stepKey="seeAssertCustomerDefaultShippingAddressCityAndPostcode"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.country}}" stepKey="seeAssertCustomerDefaultShippingAddressCountry"/> - <see selector="{{StorefrontCustomerAddressesSection.defaultShippingAddress}}" userInput="{{address.telephone}}" stepKey="seeAssertCustomerDefaultShippingAddressTelephone"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontPanelHeaderSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontPanelHeaderSection.xml index 3610532c5356b..39dd719ce10f4 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontPanelHeaderSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontPanelHeaderSection.xml @@ -9,9 +9,6 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="StorefrontPanelHeaderSection"> - <!-- Element name="WelcomeMessage" Deprecated due to incorrect naming convention please use name="welcomeMessage" --> - <element name="WelcomeMessage" type="text" selector=".greet.welcome span"/> - <element name="welcomeMessage" type="text" selector="header>.panel .greet.welcome" /> <element name="createAnAccountLink" type="select" selector="//div[@class='panel wrapper']//li/a[contains(.,'Create an Account')]" timeout="30"/> <element name="notYouLink" type="button" selector=".greet.welcome span a"/> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateNewCustomerOnStorefrontTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateNewCustomerOnStorefrontTest.xml index 8fe6e220c4aed..444e9aa643181 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateNewCustomerOnStorefrontTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateNewCustomerOnStorefrontTest.xml @@ -30,9 +30,15 @@ </after> <!--Create new customer on storefront and perform the asserts--> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="signUpNewUser"> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> <argument name="customer" value="CustomerEntityOne"/> </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> + </actionGroup> <actionGroup ref="AssertSignedUpNewsletterActionGroup" stepKey="assertSignedUpNewsLetter"> <argument name="customer" value="CustomerEntityOne"/> </actionGroup> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/ChangeCustomerGroupTest/ChangingAllCustomerGroupViaGridTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/ChangeCustomerGroupTest/ChangingAllCustomerGroupViaGridTest.xml deleted file mode 100644 index e6c114334000e..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/Test/ChangeCustomerGroupTest/ChangingAllCustomerGroupViaGridTest.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?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="ChangingAllCustomerGroupViaGridTest" extends="ChangingSingleCustomerGroupViaGridTest"> - <annotations> - <title value="DEPRECATED Change all customers' group via grid"/> - <description value="Select All customers to change their group"/> - <severity value="MAJOR"/> - <testCaseId value="MC-10924"/> - <stories value="Change Customer Group"/> - <group value="customer"/> - <group value="mtf_migrated"/> - <skip> - <issueId value="DEPRECATED">Use AdminChangeAllCustomersGroupViaGridTest instead</issueId> - </skip> - </annotations> - - <remove keyForRemoval="filterCustomer"/> - <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearFilters" before="selectCustomer"/> - <actionGroup ref="AdminSelectAllCustomers" stepKey="selectCustomer"/> - </test> -</tests> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/ChangeCustomerGroupTest/ChangingSingleCustomerGroupViaGridTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/ChangeCustomerGroupTest/ChangingSingleCustomerGroupViaGridTest.xml deleted file mode 100644 index 0edadb86888f5..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/Test/ChangeCustomerGroupTest/ChangingSingleCustomerGroupViaGridTest.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?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="ChangingSingleCustomerGroupViaGridTest"> - <annotations> - <title value="DEPRECATED Change a single customer group via grid"/> - <description value="From the selection of All Customers select a single customer to change their group"/> - <severity value="MAJOR"/> - <testCaseId value="MC-10921"/> - <stories value="Change Customer Group"/> - <group value="customer"/> - <group value="mtf_migrated"/> - <skip> - <issueId value="DEPRECATED">Use AdminChangeSingleCustomerGroupViaGridTest instead</issueId> - </skip> - </annotations> - - <before> - <createData entity="Simple_US_Customer" stepKey="createCustomer"/> - - <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> - </before> - <after> - <!--Delete created product--> - <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> - <actionGroup ref="NavigateToCustomerGroupPage" stepKey="navToCustomers"/> - <actionGroup ref="AdminDeleteCustomerGroupActionGroup" stepKey="deleteCustomerGroup"> - <argument name="customerGroupName" value="{{CustomerGroupChange.code}}"/> - </actionGroup> - - <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> - </after> - - <actionGroup ref="AdminCreateCustomerGroupActionGroup" stepKey="createCustomerGroup"> - <argument name="groupName" value="{{CustomerGroupChange.code}}"/> - <argument name="taxClass" value="{{CustomerGroupChange.tax_class_name}}"/> - </actionGroup> - <actionGroup ref="NavigateToAllCustomerPage" stepKey="navToCustomers"/> - <actionGroup ref="AdminFilterCustomerByName" stepKey="filterCustomer"> - <argument name="customerName" value="{{Simple_US_Customer.fullname}}"/> - </actionGroup> - <actionGroup ref="AdminSelectCustomerByEmail" stepKey="selectCustomer"> - <argument name="customerEmail" value="$$createCustomer.email$$"/> - </actionGroup> - <actionGroup ref="SetCustomerGroupForSelectedCustomersViaGrid" stepKey="setCustomerGroup"> - <argument name="groupName" value="{{CustomerGroupChange.code}}"/> - </actionGroup> - <actionGroup ref="AdminFilterCustomerByName" stepKey="filterCustomerAfterGroupChange"> - <argument name="customerName" value="{{Simple_US_Customer.fullname}}"/> - </actionGroup> - <actionGroup ref="VerifyCustomerGroupForCustomer" stepKey="verifyCustomerGroupSet"> - <argument name="customerEmail" value="$$createCustomer.email$$"/> - <argument name="groupName" value="{{CustomerGroupChange.code}}"/> - </actionGroup> - </test> -</tests> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml index 86218647778e6..2b6b1e7d1213c 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/EndToEndB2CLoggedInUserTest.xml @@ -31,8 +31,14 @@ </after> <!-- Step 0: User signs up an account --> <comment userInput="Start of signing up user account" stepKey="startOfSigningUpUserAccount" /> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser"> - <argument name="Customer" value="CustomerEntityOne"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="CustomerEntityOne"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> <comment userInput="End of signing up user account" stepKey="endOfSigningUpUserAccount" /> </test> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontCheckTaxAddingValidVATIdTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontCheckTaxAddingValidVATIdTest.xml index 9b4e7716f4a25..80cdeadb391da 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontCheckTaxAddingValidVATIdTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontCheckTaxAddingValidVATIdTest.xml @@ -67,9 +67,11 @@ </actionGroup> <!--Register customer on storefront--> - <actionGroup ref="SignUpNewCustomerStorefrontActionGroup" stepKey="createAnAccount"> - <argument name="Customer" value="CustomerEntityOne"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="CustomerEntityOne"/> </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> <!--Go to My account > Address book--> <actionGroup ref="EnterCustomerAddressInfoFillStateActionGroup" stepKey="enterAddressInfo"> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressBelgiumTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressBelgiumTest.xml index f45935b698fb5..b800b7870b5c5 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressBelgiumTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressBelgiumTest.xml @@ -19,9 +19,15 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser"> - <argument name="Customer" value="CustomerEntityOne"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="CustomerEntityOne"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> </before> <after> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressChinaTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressChinaTest.xml index 87390beaa50f9..41e0a5d1b7793 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressChinaTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressChinaTest.xml @@ -19,9 +19,15 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser"> - <argument name="Customer" value="CustomerEntityOne"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="CustomerEntityOne"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> </before> <after> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressFranceTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressFranceTest.xml index 6a4ed633fd413..1ecfb20b38e19 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressFranceTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressFranceTest.xml @@ -20,9 +20,15 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser"> - <argument name="Customer" value="CustomerEntityOne"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="CustomerEntityOne"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> </before> <after> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressUKTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressUKTest.xml index b3ad6cc96aae1..8e29452b5495e 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressUKTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressUKTest.xml @@ -20,9 +20,15 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser"> - <argument name="Customer" value="CustomerEntityOne"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="CustomerEntityOne"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> </before> <after> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontVerifyNoXssInjectionOnUpdateCustomerInformationAddAddressTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontVerifyNoXssInjectionOnUpdateCustomerInformationAddAddressTest.xml index 67aa050907f30..11aed4a3461e1 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontVerifyNoXssInjectionOnUpdateCustomerInformationAddAddressTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontVerifyNoXssInjectionOnUpdateCustomerInformationAddAddressTest.xml @@ -20,9 +20,15 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser"> - <argument name="Customer" value="Colorado_US_Customer"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="Colorado_US_Customer"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> </before> <after> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/AddingProductWithExpiredSessionTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/AddingProductWithExpiredSessionTest.xml deleted file mode 100644 index 2d580ab55075c..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/AddingProductWithExpiredSessionTest.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?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="AddingProductWithExpiredSessionTest" extends="StorefrontAddProductToCartWithExpiredSessionTest" deprecated="Use StorefrontAddProductToCartWithExpiredSessionTest"/> -</tests> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/StorefrontCustomerForgotPasswordTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/StorefrontCustomerForgotPasswordTest.xml deleted file mode 100644 index 7c29e00b6a3a9..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/StorefrontCustomerForgotPasswordTest.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?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="StorefrontCustomerForgotPasswordTest" extends="StorefrontResetCustomerPasswordSuccessTest" deprecated="Use StorefrontResetCustomerPasswordSuccessTest"/> -</tests> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/VerifyDisabledCustomerGroupFieldTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/VerifyDisabledCustomerGroupFieldTest.xml deleted file mode 100644 index 58e815b03126d..0000000000000 --- a/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/VerifyDisabledCustomerGroupFieldTest.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?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" extends="AdminVerifyDisabledCustomerGroupFieldTest" deprecated="Use AdminVerifyDisabledCustomerGroupFieldTest instead"/> -</tests> diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml index 111ba187c6f26..0a94bf8a52aaf 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml @@ -30,6 +30,6 @@ <argument name="importFile" value="importSpecChars.csv"/> </actionGroup> <see selector="{{AdminImportHeaderSection.messageNote}}" userInput='File must be saved in UTF-8 encoding for proper import' stepKey="seeNoteMessage"/> - <see selector="{{AdminMessagesSection.successMessage}}" userInput='File is valid! To start import process press "Import" button' stepKey="seeSuccessMessage"/> + <see selector="{{AdminMessagesSection.success}}" userInput='File is valid! To start import process press "Import" button' stepKey="seeSuccessMessage"/> </test> </tests> diff --git a/app/code/Magento/Indexer/Test/Mftf/ActionGroup/CliRunReindexUsingCronJobsActionGroup.xml b/app/code/Magento/Indexer/Test/Mftf/ActionGroup/CliRunReindexUsingCronJobsActionGroup.xml deleted file mode 100644 index 50407aff70cd5..0000000000000 --- a/app/code/Magento/Indexer/Test/Mftf/ActionGroup/CliRunReindexUsingCronJobsActionGroup.xml +++ /dev/null @@ -1,18 +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="CliRunReindexUsingCronJobsActionGroup" deprecated="Use magentoCron instead"> - <annotations> - <description>Run cron 'index' group which reindex all invalidated indices.</description> - </annotations> - - <magentoCLI command="cron:run" arguments="--group='index'" stepKey="firstRunToScheduleJobs"/> - <magentoCLI command="cron:run" arguments="--group='index'" stepKey="secondRunToExecuteJobs"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityNegativeScenarioTest.xml b/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityNegativeScenarioTest.xml index 5f806aca004d4..fc1f92dba7ad6 100644 --- a/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityNegativeScenarioTest.xml +++ b/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityNegativeScenarioTest.xml @@ -55,7 +55,7 @@ <requiredEntity createDataKey="createSimpleProduct"/> </createData> <!-- Reindex invalidated indices after product attribute has been created/deleted --> - <actionGroup ref="CliRunReindexUsingCronJobsActionGroup" stepKey="reindexInvalidatedIndices"/> + <magentoCron groups="index" stepKey="reindexInvalidatedIndices"/> <!-- Log in as a customer --> <actionGroup ref="LoginToStorefrontActionGroup" stepKey="customerLoginToStorefront"> <argument name="Customer" value="$customerWithDefaultAddress$"/> @@ -105,7 +105,7 @@ <deleteData createDataKey="createConfigChildProduct1CreateConfigurableProduct" stepKey="deleteConfigChildProduct1"/> <deleteData createDataKey="createConfigChildProduct2CreateConfigurableProduct" stepKey="deleteConfigChildProduct2"/> <!-- Reindex invalidated indices after product attribute has been created/deleted --> - <actionGroup ref="CliRunReindexUsingCronJobsActionGroup" stepKey="reindexInvalidatedIndicesAfterTest"/> + <magentoCron groups="index" stepKey="reindexInvalidatedIndicesAfterTest"/> </after> <!-- 1. Ensure customer is a guest --> <actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer"/> diff --git a/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityTest.xml b/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityTest.xml index b0235fe32ca27..4283f42660f1f 100644 --- a/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityTest.xml +++ b/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityTest.xml @@ -97,7 +97,7 @@ <deleteData createDataKey="createConfigChildProduct1CreateConfigurableProduct" stepKey="deleteConfigChildProduct1"/> <deleteData createDataKey="createConfigChildProduct2CreateConfigurableProduct" stepKey="deleteConfigChildProduct2"/> <!-- Reindex invalidated indices after product attribute has been created/deleted --> - <actionGroup ref="CliRunReindexUsingCronJobsActionGroup" stepKey="reindexInvalidatedIndices"/> + <magentoCron groups="index" stepKey="reindexInvalidatedIndices"/> </after> <!-- 1. Browse all product page and verify that the "Instant Purchase" button appears --> <!-- Virtual product --> diff --git a/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml b/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml index 312fa95bf77af..fd15b344da600 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.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="StorefrontMyAccountWithMultishipmentTest"> + <test name="StorefrontMyAccountWithMultishipmentTest" deprecated="some"> <annotations> <features value="Multishipping"/> <stories value="Shipping price shows 0 on Order view page after multiple address checkout"/> diff --git a/app/code/Magento/Persistent/Test/Mftf/Test/CheckShoppingCartBehaviorAfterSessionExpiredTest.xml b/app/code/Magento/Persistent/Test/Mftf/Test/CheckShoppingCartBehaviorAfterSessionExpiredTest.xml index a2488d564001c..18e19c4276548 100644 --- a/app/code/Magento/Persistent/Test/Mftf/Test/CheckShoppingCartBehaviorAfterSessionExpiredTest.xml +++ b/app/code/Magento/Persistent/Test/Mftf/Test/CheckShoppingCartBehaviorAfterSessionExpiredTest.xml @@ -27,8 +27,14 @@ <requiredEntity createDataKey="createCategory"/> </createData> <!-- Create new customer --> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser"> - <argument name="Customer" value="Simple_US_Customer_NY"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="Simple_US_Customer_NY"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> <!--Add shipping information--> <actionGroup ref="EnterCustomerAddressInfoActionGroup" stepKey="enterAddressInfo"> diff --git a/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontVerifyThatInformationAboutViewingComparisonWishlistIsPersistedUnderLongTermCookieTest.xml b/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontVerifyThatInformationAboutViewingComparisonWishlistIsPersistedUnderLongTermCookieTest.xml index 461304ef7aeaa..159f0c295a5b9 100644 --- a/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontVerifyThatInformationAboutViewingComparisonWishlistIsPersistedUnderLongTermCookieTest.xml +++ b/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontVerifyThatInformationAboutViewingComparisonWishlistIsPersistedUnderLongTermCookieTest.xml @@ -67,7 +67,7 @@ <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginCustomer"> <argument name="Customer" value="$$createCustomer$$"/> </actionGroup> - <see userInput="Welcome, $$createCustomer.firstname$$ $$createCustomer.lastname$$!" selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="checkWelcomeMessage"/> + <see userInput="Welcome, $$createCustomer.firstname$$ $$createCustomer.lastname$$!" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="checkWelcomeMessage"/> <!--Open the details page of Simple Product 1, Simple Product 2 and add to cart, get to the category--> <actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="addSimpleProductProductToCart"> @@ -144,7 +144,7 @@ <!--Sign out and check that widgets persist the information about the items--> <actionGroup ref="StorefrontSignOutActionGroup" stepKey="logoutFromCustomerToCheckThatWidgetsPersist"/> <amOnPage url="{{StorefrontCategoryPage.url($$createCategory.custom_attributes[url_key]$$)}}" stepKey="openCategoryPageAfterLogoutFromCustomer"/> - <see userInput="Welcome, $$createCustomer.firstname$$ $$createCustomer.lastname$$!" selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="checkWelcomeMessageAfterLogoutFromCustomer"/> + <see userInput="Welcome, $$createCustomer.firstname$$ $$createCustomer.lastname$$!" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="checkWelcomeMessageAfterLogoutFromCustomer"/> <seeElement selector="{{StorefrontPanelHeaderSection.notYouLink}}" stepKey="checkLinkNotYouAfterLogoutFromCustomer"/> <actionGroup ref="StorefrontAssertProductInRecentlyViewedWidgetActionGroup" stepKey="checkSimpleProductInRecentlyViewedWidgetAfterLogout"> @@ -164,7 +164,7 @@ <click selector="{{StorefrontPanelHeaderSection.notYouLink}}" stepKey="clickLinkNotYou"/> <waitForPageLoad stepKey="waitForPageLoadAfterClickLinkNotYou"/> <amOnPage url="{{StorefrontCategoryPage.url($$createCategory.custom_attributes[url_key]$$)}}" stepKey="openCategoryPageAfterClickNotYou"/> - <see userInput="Default welcome msg!" selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="checkWelcomeMessageAfterClickLinkNotYou"/> + <see userInput="Default welcome msg!" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="checkWelcomeMessageAfterClickLinkNotYou"/> <dontSee selector="{{StorefrontWidgetsSection.widgetRecentlyViewedProductsGrid}}" userInput="$$createSimpleProduct.name$$" stepKey="dontSeeProductInRecentlyViewedWidget"/> <dontSee selector="{{StorefrontCustomerWishlistSidebarSection.ProductTitleByName($$createSimpleProduct.name$$)}}" stepKey="dontSeeProductInWishlistWidget"/> <dontSee selector="{{StorefrontWidgetsSection.widgetRecentlyComparedProductsGrid}}" userInput="$$createSimpleProduct.name$$" stepKey="dontSeeProductInRecentlyComparedWidget"/> @@ -175,7 +175,7 @@ <argument name="Customer" value="$$createCustomer$$"/> </actionGroup> <amOnPage url="{{StorefrontCategoryPage.url($$createCategory.custom_attributes[url_key]$$)}}" stepKey="openCategoryPageToCheckWidgets"/> - <see userInput="Welcome, $$createCustomer.firstname$$ $$createCustomer.lastname$$!" selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="checkWelcomeMessageAfterLogin"/> + <see userInput="Welcome, $$createCustomer.firstname$$ $$createCustomer.lastname$$!" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="checkWelcomeMessageAfterLogin"/> <actionGroup ref="StorefrontCustomerCheckProductInWishlistSidebarActionGroup" stepKey="checkSimpleProductNameInWishlistSidebarAfterLogin"> <argument name="productVar" value="$$createSimpleProduct$$"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleAndVerifyRuleConditionAndFreeShippingIsAppliedTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleAndVerifyRuleConditionAndFreeShippingIsAppliedTest.xml index 54a6f7a16bb23..34152ea06745c 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleAndVerifyRuleConditionAndFreeShippingIsAppliedTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleAndVerifyRuleConditionAndFreeShippingIsAppliedTest.xml @@ -19,7 +19,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="defaultSimpleProduct" stepKey="initialSimpleProduct"/> </before> <after> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForMatchingSubtotalAndVerifyRuleConditionIsAppliedTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForMatchingSubtotalAndVerifyRuleConditionIsAppliedTest.xml index 7365f3b7a3425..34714e9637d46 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForMatchingSubtotalAndVerifyRuleConditionIsAppliedTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForMatchingSubtotalAndVerifyRuleConditionIsAppliedTest.xml @@ -19,7 +19,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="defaultSimpleProduct" stepKey="initialSimpleProduct"/> </before> <after> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingCategoryAndVerifyRuleConditionIsAppliedTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingCategoryAndVerifyRuleConditionIsAppliedTest.xml index 81c30d197759d..a3e6331e31cf6 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingCategoryAndVerifyRuleConditionIsAppliedTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingCategoryAndVerifyRuleConditionIsAppliedTest.xml @@ -19,7 +19,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="_defaultCategory" stepKey="createCategory"/> <actionGroup ref="FillAdminSimpleProductFormActionGroup" stepKey="fillProductFieldsInAdmin"> <argument name="category" value="$$createCategory$$"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingTotalWeightAndVerifyRuleConditionIsAppliedTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingTotalWeightAndVerifyRuleConditionIsAppliedTest.xml index 2685e004ba1e0..e9f7f3ec6c70a 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingTotalWeightAndVerifyRuleConditionIsAppliedTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingTotalWeightAndVerifyRuleConditionIsAppliedTest.xml @@ -19,7 +19,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="defaultSimpleProductWeight200" stepKey="initialSimpleProduct"/> </before> <after> diff --git a/app/code/Magento/Security/Test/Mftf/ActionGroup/AdminSaveUserInvalidExpirationActionGroup.xml b/app/code/Magento/Security/Test/Mftf/ActionGroup/AdminSaveUserInvalidExpirationActionGroup.xml index 02280ed809124..7cca38e68d8d1 100644 --- a/app/code/Magento/Security/Test/Mftf/ActionGroup/AdminSaveUserInvalidExpirationActionGroup.xml +++ b/app/code/Magento/Security/Test/Mftf/ActionGroup/AdminSaveUserInvalidExpirationActionGroup.xml @@ -16,7 +16,7 @@ <scrollToTopOfPage stepKey="scrollToTopOfPage"/> <click selector="{{AdminNewUserFormSection.userInfoTab}}" stepKey="openUserTab"/> <waitForPageLoad stepKey="waitForUserRoleTabOpened"/> - <see selector="{{AdminMessagesSection.errorMessage}}" userInput='"Expiration date" must be later than the current date.' + <see selector="{{AdminMessagesSection.error}}" userInput='"Expiration date" must be later than the current date.' stepKey="seeErrorMessage"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Security/Test/Mftf/Test/AdminLoginAdminUserWithInvalidExpiration.xml b/app/code/Magento/Security/Test/Mftf/Test/AdminLoginAdminUserWithInvalidExpiration.xml index 130dacfbc2237..3fb798521fb45 100644 --- a/app/code/Magento/Security/Test/Mftf/Test/AdminLoginAdminUserWithInvalidExpiration.xml +++ b/app/code/Magento/Security/Test/Mftf/Test/AdminLoginAdminUserWithInvalidExpiration.xml @@ -36,9 +36,9 @@ <actionGroup ref="AdminSaveUserSuccessActionGroup" stepKey="saveNewUserWithValidExpirationSuccess"/> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> <wait time="120" stepKey="waitForUserToExpire"/> - <actionGroup ref="LoginAdminWithCredentialsActionGroup" stepKey="loginAsNewAdmin"> - <argument name="adminUser" value="{$grabUsername}"/> - <argument name="adminPassword" value="{$grabPassword}"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsNewAdmin"> + <argument name="username" value="{$grabUsername}"/> + <argument name="password" value="{$grabPassword}"/> </actionGroup> <actionGroup ref="AssertMessageOnAdminLoginActionGroup" stepKey="checkLoginMessage" /> diff --git a/app/code/Magento/Security/Test/Mftf/Test/AdminLoginAdminUserWithValidExpiration.xml b/app/code/Magento/Security/Test/Mftf/Test/AdminLoginAdminUserWithValidExpiration.xml index 39e4a3b56ca13..5d12650351bc0 100644 --- a/app/code/Magento/Security/Test/Mftf/Test/AdminLoginAdminUserWithValidExpiration.xml +++ b/app/code/Magento/Security/Test/Mftf/Test/AdminLoginAdminUserWithValidExpiration.xml @@ -36,9 +36,9 @@ <grabValueFrom selector="{{AdminNewUserFormSection.password}}" stepKey="grabPassword"/> <actionGroup ref="AdminSaveUserSuccessActionGroup" stepKey="saveNewUserWithValidExpirationSuccess"/> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> - <actionGroup ref="LoginAdminWithCredentialsActionGroup" stepKey="loginAsNewAdmin"> - <argument name="adminUser" value="{$grabUsername}"/> - <argument name="adminPassword" value="{$grabPassword}"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsNewAdmin"> + <argument name="username" value="{$grabUsername}"/> + <argument name="password" value="{$grabPassword}"/> </actionGroup> <actionGroup ref="AssertAdminDashboardPageIsVisibleActionGroup" stepKey="seeDashboardPage"/> diff --git a/app/code/Magento/Security/Test/Mftf/Test/AdminNavigateWhileUserExpiredTest.xml b/app/code/Magento/Security/Test/Mftf/Test/AdminNavigateWhileUserExpiredTest.xml index 1c251ea2b9ec2..c1a951afd87ec 100644 --- a/app/code/Magento/Security/Test/Mftf/Test/AdminNavigateWhileUserExpiredTest.xml +++ b/app/code/Magento/Security/Test/Mftf/Test/AdminNavigateWhileUserExpiredTest.xml @@ -40,9 +40,9 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> <!-- Login as that user --> - <actionGroup ref="LoginAdminWithCredentialsActionGroup" stepKey="loginAsNewAdmin"> - <argument name="adminUser" value="{$grabUsername}"/> - <argument name="adminPassword" value="{$grabPassword}"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsNewAdmin"> + <argument name="username" value="{$grabUsername}"/> + <argument name="password" value="{$grabPassword}"/> </actionGroup> <actionGroup ref="AssertAdminDashboardPageIsVisibleActionGroup" stepKey="seeDashboardPage"/> <wait time="120" stepKey="waitForUserToExpire"/> diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/GoToShipmentIntoOrderActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/GoToShipmentIntoOrderActionGroup.xml deleted file mode 100644 index 71341593ff036..0000000000000 --- a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/GoToShipmentIntoOrderActionGroup.xml +++ /dev/null @@ -1,19 +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="goToShipmentIntoOrder"> - <annotations> - <description>Clicks on the 'Ship' button on the view Admin Order page. Validates that the URL and Page Title are present and correct.</description> - </annotations> - - <click selector="{{AdminOrderDetailsMainActionsSection.ship}}" stepKey="clickShipAction"/> - <seeInCurrentUrl url="{{AdminShipmentNewPage.url}}" stepKey="seeOrderShipmentUrl"/> - <see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Shipment" stepKey="seePageNameNewInvoicePage"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/SeeProductInShipmentItemsActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/SeeProductInShipmentItemsActionGroup.xml deleted file mode 100644 index 10ef44b090a8b..0000000000000 --- a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/SeeProductInShipmentItemsActionGroup.xml +++ /dev/null @@ -1,20 +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="seeProductInShipmentItems"> - <annotations> - <description>Validates that the provided Product is present and correct on the view Admin Order Shipment page under the 'Items Shipped' section.</description> - </annotations> - <arguments> - <argument name="product"/> - </arguments> - - <see selector="{{AdminShipmentItemsSection.skuColumn}}" userInput="{{product.sku}}" stepKey="seeProductSkuInGrid"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/SubmitShipmentIntoOrderActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/SubmitShipmentIntoOrderActionGroup.xml deleted file mode 100644 index c067a39e30f6c..0000000000000 --- a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/SubmitShipmentIntoOrderActionGroup.xml +++ /dev/null @@ -1,19 +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="submitShipmentIntoOrder"> - <annotations> - <description>Clicks on the 'Submit Shipment' button on the view Admin Order Shipment page. Validates that the URL and Page Title are present and correct.</description> - </annotations> - - <click selector="{{AdminShipmentMainActionsSection.submitShipment}}" stepKey="clickSubmitShipment"/> - <seeInCurrentUrl url="{{AdminOrderDetailsPage.url}}" stepKey="seeViewOrderPageShipping"/> - <see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="The shipment has been created." stepKey="seeShipmentCreateSuccess"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyBasicShipmentInformationActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyBasicShipmentInformationActionGroup.xml deleted file mode 100644 index 8d0d0e273e767..0000000000000 --- a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/VerifyBasicShipmentInformationActionGroup.xml +++ /dev/null @@ -1,33 +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="verifyBasicShipmentInformation"> - <annotations> - <description>Validates that the provided Customer, Shipping Address, Billing Address and Customer Group are present and correct on the view Admin Order page.</description> - </annotations> - <arguments> - <argument name="customer" defaultValue=""/> - <argument name="shippingAddress" defaultValue=""/> - <argument name="billingAddress" defaultValue=""/> - <argument name="customerGroup" defaultValue="GeneralCustomerGroup"/> - </arguments> - - <see selector="{{AdminShipmentOrderInformationSection.customerName}}" userInput="{{customer.firstname}}" stepKey="seeCustomerName"/> - <see selector="{{AdminShipmentOrderInformationSection.customerEmail}}" userInput="{{customer.email}}" stepKey="seeCustomerEmail"/> - <see selector="{{AdminShipmentOrderInformationSection.customerGroup}}" userInput="{{customerGroup.code}}" stepKey="seeCustomerGroup"/> - <see selector="{{AdminShipmentAddressInformationSection.billingAddress}}" userInput="{{billingAddress.street[0]}}" stepKey="seeBillingAddressStreet"/> - <see selector="{{AdminShipmentAddressInformationSection.billingAddress}}" userInput="{{billingAddress.city}}" stepKey="seeBillingAddressCity"/> - <see selector="{{AdminShipmentAddressInformationSection.billingAddress}}" userInput="{{billingAddress.country_id}}" stepKey="seeBillingAddressCountry"/> - <see selector="{{AdminShipmentAddressInformationSection.billingAddress}}" userInput="{{billingAddress.postcode}}" stepKey="seeBillingAddressPostcode"/> - <see selector="{{AdminShipmentAddressInformationSection.shippingAddress}}" userInput="{{shippingAddress.street[0]}}" stepKey="seeShippingAddressStreet"/> - <see selector="{{AdminShipmentAddressInformationSection.shippingAddress}}" userInput="{{shippingAddress.city}}" stepKey="seeShippingAddressCity"/> - <see selector="{{AdminShipmentAddressInformationSection.shippingAddress}}" userInput="{{shippingAddress.country_id}}" stepKey="seeShippingAddressCountry"/> - <see selector="{{AdminShipmentAddressInformationSection.shippingAddress}}" userInput="{{shippingAddress.postcode}}" stepKey="seeShippingAddressPostcode"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateCustomStoreViewStatusDisabledVerifyErrorSaveMessageTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateCustomStoreViewStatusDisabledVerifyErrorSaveMessageTest.xml index d4b5bc9a9b50f..0a7b7852c38d0 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateCustomStoreViewStatusDisabledVerifyErrorSaveMessageTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateCustomStoreViewStatusDisabledVerifyErrorSaveMessageTest.xml @@ -17,7 +17,7 @@ <group value="mtf_migrated"/> </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <!--Create website--> <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createWebsite"> <argument name="newWebsiteName" value="{{customWebsite.name}}"/> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateCustomStoreViewStatusEnabledVerifyAbsenceOfDeleteButtonTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateCustomStoreViewStatusEnabledVerifyAbsenceOfDeleteButtonTest.xml index dc24a2f635b52..aa39340013142 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateCustomStoreViewStatusEnabledVerifyAbsenceOfDeleteButtonTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateCustomStoreViewStatusEnabledVerifyAbsenceOfDeleteButtonTest.xml @@ -17,7 +17,7 @@ <group value="mtf_migrated"/> </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <!-- Create store --> <actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createFirstStore"> <argument name="website" value="{{_defaultWebsite.name}}"/> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateCustomStoreViewStatusEnabledVerifyBackendAndFrontendTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateCustomStoreViewStatusEnabledVerifyBackendAndFrontendTest.xml index 188300acc7015..929b3aade4022 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateCustomStoreViewStatusEnabledVerifyBackendAndFrontendTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateCustomStoreViewStatusEnabledVerifyBackendAndFrontendTest.xml @@ -17,7 +17,7 @@ <group value="mtf_migrated"/> </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <!-- Create store --> <actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createStore"> <argument name="website" value="{{_defaultWebsite.name}}"/> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateNewLocalizedStoreViewStatusEnabledTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateNewLocalizedStoreViewStatusEnabledTest.xml index faa9d38a2d6fe..abb44165abd13 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateNewLocalizedStoreViewStatusEnabledTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateNewLocalizedStoreViewStatusEnabledTest.xml @@ -17,7 +17,7 @@ <group value="mtf_migrated"/> </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> </before> <after> <actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="deleteStoreView"> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupWithCustomWebsiteAndDefaultCategoryTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupWithCustomWebsiteAndDefaultCategoryTest.xml index aaac3e5ea08b6..d9cd4c8f9f177 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupWithCustomWebsiteAndDefaultCategoryTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupWithCustomWebsiteAndDefaultCategoryTest.xml @@ -19,7 +19,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <!--Create website--> <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createWebsite"> <argument name="newWebsiteName" value="{{customWebsite.name}}"/> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupWithCustomWebsiteAndRootCategoryTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupWithCustomWebsiteAndRootCategoryTest.xml index 8091f01e1f7ec..e541204a636e2 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupWithCustomWebsiteAndRootCategoryTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupWithCustomWebsiteAndRootCategoryTest.xml @@ -19,7 +19,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <!--Create root category--> <createData entity="NewRootCategory" stepKey="rootCategory"/> <createData entity="SimpleRootSubCategory" stepKey="category"> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupWithDefaultWebsiteAndDefaultCategoryTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupWithDefaultWebsiteAndDefaultCategoryTest.xml index a161abe767010..809210f3bc436 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupWithDefaultWebsiteAndDefaultCategoryTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupWithDefaultWebsiteAndDefaultCategoryTest.xml @@ -19,7 +19,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> </before> <after> <actionGroup ref="DeleteCustomStoreActionGroup" stepKey="deleteStoreGroup"> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreViewStatusDisabledVerifyBackendAndFrontendTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreViewStatusDisabledVerifyBackendAndFrontendTest.xml index 0207faf692f14..f2bfc7f7cea76 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreViewStatusDisabledVerifyBackendAndFrontendTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreViewStatusDisabledVerifyBackendAndFrontendTest.xml @@ -17,7 +17,7 @@ <group value="mtf_migrated"/> </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> </before> <after> <actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="deleteStoreView"> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreViewStatusEnabledVerifyBackendAndFrontendTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreViewStatusEnabledVerifyBackendAndFrontendTest.xml index 767b452544714..5f2472a0c52ee 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreViewStatusEnabledVerifyBackendAndFrontendTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreViewStatusEnabledVerifyBackendAndFrontendTest.xml @@ -17,7 +17,7 @@ <group value="mtf_migrated"/> </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> </before> <after> <actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="deleteStoreView"> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteDefaultStoreViewTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteDefaultStoreViewTest.xml index c010935233a5b..ef4590eaff741 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteDefaultStoreViewTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteDefaultStoreViewTest.xml @@ -17,7 +17,7 @@ <group value="store"/> </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> </before> <after> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreGroupTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreGroupTest.xml index a3afddd794723..349bcfe8f31e0 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreGroupTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreGroupTest.xml @@ -20,7 +20,7 @@ <before> <magentoCLI command="config:set system/backup/functionality_enabled 1" stepKey="setEnableBackupToYes"/> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <!--Create custom store group--> <actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createNewCustomStoreGroup"> <argument name="website" value="{{_defaultWebsite.name}}"/> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml index c4e3f51e6138f..305b4540668e4 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminDeleteStoreViewTest.xml @@ -19,7 +19,7 @@ </annotations> <before> <magentoCLI command="config:set system/backup/functionality_enabled 1" stepKey="setEnableBackupToYes"/> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <!--Create custom store view--> <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createNewStoreView"> <argument name="StoreGroup" value="_defaultStoreGroup"/> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminMoveStoreToOtherGroupSameWebsiteTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminMoveStoreToOtherGroupSameWebsiteTest.xml index a94c1f8f66c7c..812fe6f2d4144 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminMoveStoreToOtherGroupSameWebsiteTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminMoveStoreToOtherGroupSameWebsiteTest.xml @@ -19,7 +19,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <!-- Create first store --> <actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createFirstStore"> <argument name="website" value="{{_defaultWebsite.name}}"/> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreGroupAcceptAlertAndVerifyStoreViewFormTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreGroupAcceptAlertAndVerifyStoreViewFormTest.xml index 8d4e095d6ed87..09a33d5eb86a6 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreGroupAcceptAlertAndVerifyStoreViewFormTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreGroupAcceptAlertAndVerifyStoreViewFormTest.xml @@ -19,7 +19,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <!--Create root category--> <createData entity="NewRootCategory" stepKey="rootCategory"/> <createData entity="SimpleRootSubCategory" stepKey="category"> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreGroupAndVerifyStoreViewFormTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreGroupAndVerifyStoreViewFormTest.xml index f8df1059fb1ef..1c5d58c13538e 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreGroupAndVerifyStoreViewFormTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreGroupAndVerifyStoreViewFormTest.xml @@ -19,7 +19,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <!--Create custom store group--> <actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createNewCustomStoreGroup"> <argument name="website" value="{{_defaultWebsite.name}}"/> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreViewTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreViewTest.xml index f2e9e12821595..c7c846c51af4d 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreViewTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateStoreViewTest.xml @@ -18,7 +18,7 @@ <group value="mtf_migrated"/> </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <!--Create custom store view--> <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createNewStoreView"> <argument name="StoreGroup" value="_defaultStoreGroup"/> diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateWebsiteTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateWebsiteTest.xml index e9f72e46e3973..1c1c0ae30f6b1 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateWebsiteTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/AdminUpdateWebsiteTest.xml @@ -19,7 +19,7 @@ </annotations> <before> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <!--Create website--> <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createWebsite"> <argument name="newWebsiteName" value="{{customWebsite.name}}"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/AdminCheckTextSwatchAttributeAddedViaApiTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/AdminCheckTextSwatchAttributeAddedViaApiTest.xml index 6ac5f2a55f3cf..0fcf0c0a35033 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/AdminCheckTextSwatchAttributeAddedViaApiTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/AdminCheckTextSwatchAttributeAddedViaApiTest.xml @@ -31,7 +31,7 @@ <deleteData createDataKey="createTextSwatchConfigProductAttribute" stepKey="deleteAttribute"/> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> <!-- Reindex invalidated indices after product attribute has been created/deleted --> - <actionGroup ref="CliRunReindexUsingCronJobsActionGroup" stepKey="reindexInvalidatedIndices"/> + <magentoCron groups="index" stepKey="reindexInvalidatedIndices"/> </after> <!-- Open the new simple product page --> diff --git a/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminCreateTaxRuleCustomProductTaxClassActionGroup.xml b/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminCreateTaxRuleCustomProductTaxClassActionGroup.xml index 377985a81af37..a1a488c2e4e37 100644 --- a/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminCreateTaxRuleCustomProductTaxClassActionGroup.xml +++ b/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminCreateTaxRuleCustomProductTaxClassActionGroup.xml @@ -25,7 +25,7 @@ <click selector="{{AdminTaxRulesSection.selectProductTaxClass(taxableGoodsTaxClass.class_name)}}" stepKey="unSelectTaxClass"/> <click selector="{{AdminTaxRulesSection.selectProductTaxClass(productTaxClassName)}}" stepKey="selectProductTaxClass"/> <click selector="{{AdminMainActionsSection.save}}" stepKey="clickSave"/> - <waitForElementVisible selector="{{AdminMessagesSection.successMessage}}" stepKey="waitForSuccessMessage"/> - <see selector="{{AdminMessagesSection.successMessage}}" userInput="You saved the tax rule." stepKey="verifyRuleSaved"/> + <waitForElementVisible selector="{{AdminMessagesSection.success}}" stepKey="waitForSuccessMessage"/> + <see selector="{{AdminMessagesSection.success}}" userInput="You saved the tax rule." stepKey="verifyRuleSaved"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCheckingTaxReportGridTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCheckingTaxReportGridTest.xml index 0990daf1ecfbf..01e1677ec8d8a 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCheckingTaxReportGridTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCheckingTaxReportGridTest.xml @@ -123,7 +123,7 @@ </after> <!--Open Created product. In Tax Class select new created Product Tax class.--> - <actionGroup ref="GoToProductPageViaIDActionGroup" stepKey="openProductForEdit"> + <actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openProductForEdit"> <argument name="productId" value="$createFirstProduct.id$"/> </actionGroup> <selectOption selector="{{AdminProductFormSection.productTaxClass}}" userInput="$productTaxClass.class_name$" stepKey="selectTexClassForProduct"/> @@ -131,7 +131,7 @@ <actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/> <!--Open Created Second Product. In Tax Class select new created Product Tax class.--> - <actionGroup ref="GoToProductPageViaIDActionGroup" stepKey="openSecondProductForEdit"> + <actionGroup ref="AdminProductPageOpenByIdActionGroup" stepKey="openSecondProductForEdit"> <argument name="productId" value="$createSecondProduct.id$"/> </actionGroup> @@ -181,9 +181,9 @@ <actionGroup ref="SubmitInvoiceActionGroup" stepKey="clickSubmitInvoice"/> - <actionGroup ref="goToShipmentIntoOrder" stepKey="seeShipmentOrderPage"/> + <actionGroup ref="GoToShipmentIntoOrderActionGroup" stepKey="seeShipmentOrderPage"/> <!--Submit Shipment--> - <actionGroup ref="submitShipmentIntoOrder" stepKey="clickSubmitShipment"/> + <actionGroup ref="SubmitShipmentIntoOrderActionGroup" stepKey="clickSubmitShipment"/> <!--Go to "Reports" -> "Sales" -> "Tax"--> <amOnPage url="{{AdminSalesTaxReportPage.url}}" stepKey="navigateToReportsTaxPage"/> <waitForPageLoad stepKey="waitForReportsTaxPageLoad"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInSimpleTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInSimpleTest.xml index 609c8c7b27980..e43511318f137 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInSimpleTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInSimpleTest.xml @@ -43,8 +43,14 @@ <magentoCLI command="cron:run --group=index" stepKey="runCronIndexer"/> <!-- Fill out form for a new user with address --> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser"> - <argument name="Customer" value="Simple_US_Customer_NY"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="Simple_US_Customer_NY"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> <actionGroup ref="EnterCustomerAddressInfoActionGroup" stepKey="enterAddressInfo"> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInVirtualTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInVirtualTest.xml index 724831d9409be..3b92ab3498442 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInVirtualTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInVirtualTest.xml @@ -42,8 +42,14 @@ <click stepKey="clickSave" selector="{{AdminStoresMainActionsSection.saveButton}}"/> <!-- Fill out form for a new user with address --> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser"> - <argument name="Customer" value="Simple_US_Customer_NY"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="Simple_US_Customer_NY"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> <actionGroup ref="EnterCustomerAddressInfoActionGroup" stepKey="enterAddressInfo"> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCheckoutTest/StorefrontTaxQuoteCheckoutLoggedInSimpleTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCheckoutTest/StorefrontTaxQuoteCheckoutLoggedInSimpleTest.xml index 3a67276c42737..18a1a11d35fd2 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCheckoutTest/StorefrontTaxQuoteCheckoutLoggedInSimpleTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCheckoutTest/StorefrontTaxQuoteCheckoutLoggedInSimpleTest.xml @@ -75,11 +75,17 @@ </after> <!-- Fill out form for a new user with address --> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser"> - <argument name="Customer" value="Simple_US_Customer_NY"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="Simple_US_Customer_NY"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> - <actionGroup ref="EnterCustomerAddressInfo" stepKey="enterAddressInfo"> + <actionGroup ref="EnterCustomerAddressInfoActionGroup" stepKey="enterAddressInfo"> <argument name="Address" value="US_Address_NY"/> </actionGroup> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCheckoutTest/StorefrontTaxQuoteCheckoutLoggedInVirtualTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCheckoutTest/StorefrontTaxQuoteCheckoutLoggedInVirtualTest.xml index 793468b7f0b1e..35a483da7f690 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCheckoutTest/StorefrontTaxQuoteCheckoutLoggedInVirtualTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCheckoutTest/StorefrontTaxQuoteCheckoutLoggedInVirtualTest.xml @@ -75,11 +75,17 @@ </after> <!-- Fill out form for a new user with address --> - <actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser"> - <argument name="Customer" value="Simple_US_Customer_NY"/> + <actionGroup ref="StorefrontOpenCustomerAccountCreatePageActionGroup" stepKey="openCreateAccountPage"/> + <actionGroup ref="StorefrontFillCustomerAccountCreationFormActionGroup" stepKey="fillCreateAccountForm"> + <argument name="customer" value="Simple_US_Customer_NY"/> + </actionGroup> + <actionGroup ref="StorefrontClickCreateAnAccountCustomerAccountCreationFormActionGroup" stepKey="submitCreateAccountForm"/> + <actionGroup ref="AssertMessageCustomerCreateAccountActionGroup" stepKey="seeSuccessMessage"> + <argument name="messageType" value="success"/> + <argument name="message" value="Thank you for registering with Main Website Store."/> </actionGroup> - <actionGroup ref="EnterCustomerAddressInfo" stepKey="enterAddressInfo"> + <actionGroup ref="EnterCustomerAddressInfoActionGroup" stepKey="enterAddressInfo"> <argument name="Address" value="US_Address_NY"/> </actionGroup> diff --git a/app/code/Magento/Ui/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminFormSaveAndCloseActionGroup.xml b/app/code/Magento/Ui/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminFormSaveAndCloseActionGroup.xml deleted file mode 100644 index d712c1a116068..0000000000000 --- a/app/code/Magento/Ui/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminFormSaveAndCloseActionGroup.xml +++ /dev/null @@ -1,19 +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="AdminFormSaveAndClose"> - <annotations> - <description>Clicks on 'Save and Close'. Validates that the Success Message is present.</description> - </annotations> - - <click selector="{{AdminProductFormActionSection.saveArrow}}" stepKey="openSaveDropDown"/> - <click selector="{{AdminProductFormActionSection.saveAndClose}}" stepKey="clickOnSaveAndClose"/> - <seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="assertSaveMessageSuccess"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Ui/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminFormSaveAndDuplicateActionGroup.xml b/app/code/Magento/Ui/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminFormSaveAndDuplicateActionGroup.xml deleted file mode 100644 index 51031a7225889..0000000000000 --- a/app/code/Magento/Ui/Test/Mftf/ActionGroup/_Deprecated_ActionGroup/AdminFormSaveAndDuplicateActionGroup.xml +++ /dev/null @@ -1,20 +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="AdminFormSaveAndDuplicate"> - <annotations> - <description>Clicks on 'Save and Duplicate'. Validates that the Success Message is present and correct.</description> - </annotations> - - <click selector="{{AdminProductFormActionSection.saveArrow}}" stepKey="openSaveDropDown"/> - <click selector="{{AdminProductFormActionSection.saveAndDuplicate}}" stepKey="clickOnSaveAndDuplicate"/> - <see selector="{{AdminProductMessagesSection.successMessage}}" stepKey="assertSaveSuccess" userInput="You saved the product."/> - <see selector="{{AdminProductMessagesSection.successMessage}}" stepKey="assertDuplicateSuccess" userInput="You duplicated the product."/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Ui/Test/Mftf/Test/AdminGridFilterDeleteAndVerifyErrorMessageTest.xml b/app/code/Magento/Ui/Test/Mftf/Test/AdminGridFilterDeleteAndVerifyErrorMessageTest.xml index 3cc120ad98176..d38e065914617 100644 --- a/app/code/Magento/Ui/Test/Mftf/Test/AdminGridFilterDeleteAndVerifyErrorMessageTest.xml +++ b/app/code/Magento/Ui/Test/Mftf/Test/AdminGridFilterDeleteAndVerifyErrorMessageTest.xml @@ -20,7 +20,7 @@ <before> <magentoCLI command="config:set system/backup/functionality_enabled 1" stepKey="setEnableBackupToYes"/> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <createData entity="NewRootCategory" stepKey="rootCategory"/> <createData entity="defaultSimpleProduct" stepKey="createProduct"> <requiredEntity createDataKey="rootCategory" /> diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddCustomUrlRewriteActionGroup.xml b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddCustomUrlRewriteActionGroup.xml index 5dcb97692d047..dbc5e4bd48e84 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddCustomUrlRewriteActionGroup.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddCustomUrlRewriteActionGroup.xml @@ -33,6 +33,6 @@ <click selector="{{AdminUrlRewriteEditSection.redirectTypeValue('redirectTypeValue')}}" stepKey="selectRedirectTypeValue"/> <fillField selector="{{AdminUrlRewriteEditSection.description}}" userInput="{{description}}" stepKey="fillDescription"/> <click selector="{{AdminUrlRewriteEditSection.saveButton}}" stepKey="clickOnSaveButton"/> - <seeElement selector="{{AdminMessagesSection.successMessage}}" stepKey="seeSuccessSaveMessage"/> + <seeElement selector="{{AdminMessagesSection.success}}" stepKey="seeSuccessSaveMessage"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddUrlRewriteActionGroup.xml b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddUrlRewriteActionGroup.xml index 1bb3e80aa06b7..b0335607d5455 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddUrlRewriteActionGroup.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddUrlRewriteActionGroup.xml @@ -35,6 +35,6 @@ <click selector="{{AdminUrlRewriteEditSection.redirectTypeValue('redirectTypeValue')}}" stepKey="clickOnRedirectTypeValue"/> <fillField selector="{{AdminUrlRewriteEditSection.description}}" userInput="{{description}}" stepKey="fillDescription"/> <click selector="{{AdminUrlRewriteEditSection.saveButton}}" stepKey="clickOnSaveButton"/> - <seeElement selector="{{AdminMessagesSection.successMessage}}" stepKey="seeSuccessSaveMessage"/> + <seeElement selector="{{AdminMessagesSection.success}}" stepKey="seeSuccessSaveMessage"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddUrlRewriteForProductActionGroup.xml b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddUrlRewriteForProductActionGroup.xml index 3a72c73f3e54a..f1dcf175455f3 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddUrlRewriteForProductActionGroup.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddUrlRewriteForProductActionGroup.xml @@ -29,6 +29,6 @@ <click selector="{{AdminUrlRewriteEditSection.redirectTypeValue('redirectTypeValue')}}" stepKey="clickOnRedirectTypeValue"/> <fillField selector="{{AdminUrlRewriteEditSection.description}}" userInput="{{description}}" stepKey="fillDescription"/> <click selector="{{AdminUrlRewriteEditSection.saveButton}}" stepKey="clickOnSaveButton"/> - <seeElement selector="{{AdminMessagesSection.successMessage}}" stepKey="seeSuccessSaveMessage"/> + <seeElement selector="{{AdminMessagesSection.success}}" stepKey="seeSuccessSaveMessage"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminDeleteUrlRewriteActionGroup.xml b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminDeleteUrlRewriteActionGroup.xml index a5519e84b4c03..4d26f60cd48eb 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminDeleteUrlRewriteActionGroup.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminDeleteUrlRewriteActionGroup.xml @@ -32,6 +32,6 @@ <waitForElementVisible selector="{{AdminUrlRewriteEditSection.okButton}}" stepKey="waitForOkButtonToVisible"/> <click selector="{{AdminUrlRewriteEditSection.okButton}}" stepKey="clickOnOkButton"/> <waitForPageLoad stepKey="waitForPageToLoad3"/> - <see selector="{{AdminMessagesSection.successMessage}}" userInput="You deleted the URL rewrite." stepKey="seeSuccessMessage"/> + <see selector="{{AdminMessagesSection.success}}" userInput="You deleted the URL rewrite." stepKey="seeSuccessMessage"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUpdateCustomUrlRewriteActionGroup.xml b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUpdateCustomUrlRewriteActionGroup.xml index 69b5906c9f6e1..ed60081160ace 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUpdateCustomUrlRewriteActionGroup.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUpdateCustomUrlRewriteActionGroup.xml @@ -27,6 +27,6 @@ <selectOption selector="{{AdminUrlRewriteEditSection.redirectType}}" userInput="{{redirectTypeValue}}" stepKey="selectRedirectTypeValue"/> <fillField selector="{{AdminUrlRewriteEditSection.description}}" userInput="{{description}}" stepKey="fillDescription"/> <click selector="{{AdminUrlRewriteEditSection.saveButton}}" stepKey="clickOnSaveButton"/> - <seeElement selector="{{AdminMessagesSection.successMessage}}" stepKey="seeSuccessSaveMessage"/> + <seeElement selector="{{AdminMessagesSection.success}}" stepKey="seeSuccessSaveMessage"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUpdateUrlRewriteActionGroup.xml b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUpdateUrlRewriteActionGroup.xml index 386836fe2da69..c3e539db34108 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUpdateUrlRewriteActionGroup.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUpdateUrlRewriteActionGroup.xml @@ -26,6 +26,6 @@ <click selector="{{AdminUrlRewriteEditSection.redirectTypeValue(redirectTypeValue)}}" stepKey="selectRedirectTypeValue"/> <fillField selector="{{AdminUrlRewriteEditSection.description}}" userInput="{{description}}" stepKey="fillDescription"/> <click selector="{{AdminUrlRewriteEditSection.saveButton}}" stepKey="clickOnSaveButton"/> - <seeElement selector="{{AdminMessagesSection.successMessage}}" stepKey="seeSuccessSaveMessage"/> + <seeElement selector="{{AdminMessagesSection.success}}" stepKey="seeSuccessSaveMessage"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest.xml index 82849755d78fc..6a1bcb38bdb31 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> - <test name="AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest"> + <test name="AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest" deprecated="some"> <annotations> <features value="Url Rewrite"/> <stories value="Update url rewrites"/> diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateProductWithSeveralWebsitesAndCheckURLRewritesTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateProductWithSeveralWebsitesAndCheckURLRewritesTest.xml index 653995da1a3a8..036d35d9c3258 100644 --- a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateProductWithSeveralWebsitesAndCheckURLRewritesTest.xml +++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateProductWithSeveralWebsitesAndCheckURLRewritesTest.xml @@ -24,7 +24,7 @@ <requiredEntity createDataKey="rootCategory"/> </createData> <createData entity="defaultSimpleProduct" stepKey="createProduct"/> - <actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> </before> <after> <actionGroup ref="DeleteCustomStoreActionGroup" stepKey="deleteStore1"> diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserTest.xml index d1034c7a5945f..10f81c9254b40 100644 --- a/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserTest.xml +++ b/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserTest.xml @@ -72,7 +72,8 @@ </actionGroup> <actionGroup ref="AdminLogoutActionGroup" stepKey="logOutFromAdminPanel"/> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsSaleRoleUser"> - <argument name="adminUser" value="AdminUserWithUpdatedUserRoleToSales"/> + <argument name="username" value="{{AdminUserWithUpdatedUserRoleToSales.username}}"/> + <argument name="password" value="{{AdminUserWithUpdatedUserRoleToSales.password}}"/> </actionGroup> <actionGroup ref="AssertAdminSuccessLoginActionGroup" stepKey="seeSuccessloginMessage"/> <actionGroup ref="AdminOpenAdminUsersPageActionGroup" stepKey="navigateToAdminUsersPage"/> diff --git a/dev/tests/acceptance/tests/functional/Magento/ConfigurableProductWishlist/ActionGroup/_Deprecated_ActionGroup/StorefrontCustomerCheckConfigurableProductInWishlistActionGroup.xml b/dev/tests/acceptance/tests/functional/Magento/ConfigurableProductWishlist/ActionGroup/_Deprecated_ActionGroup/StorefrontCustomerCheckConfigurableProductInWishlistActionGroup.xml deleted file mode 100644 index d6d6819b20bfa..0000000000000 --- a/dev/tests/acceptance/tests/functional/Magento/ConfigurableProductWishlist/ActionGroup/_Deprecated_ActionGroup/StorefrontCustomerCheckConfigurableProductInWishlistActionGroup.xml +++ /dev/null @@ -1,25 +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="StorefrontCustomerCheckConfigurableProductInWishlist"> - <annotations> - <description>Validates that the provided Configurable Product and Product Option is present in the Storefront Wish List.</description> - </annotations> - <arguments> - <argument name="productVar"/> - <argument name="optionProductVar"/> - </arguments> - - <waitForElement selector="{{StorefrontCustomerWishlistProductSection.ProductTitleByName(productVar.name)}}" time="30" stepKey="assertWishlistProductName"/> - <see userInput="${{optionProductVar.price}}.00" selector="{{StorefrontCustomerWishlistProductSection.ProductPriceByName(productVar.name)}}" stepKey="AssertWishlistProductPrice"/> - <moveMouseOver selector="{{StorefrontCustomerWishlistProductSection.ProductInfoByName(productVar.name)}}" stepKey="wishlistMoveMouseOverProduct"/> - <seeElement selector="{{StorefrontCustomerWishlistProductSection.ProductAddToCartByName(productVar.name)}}" stepKey="AssertWishlistAddToCart"/> - <seeElement selector="{{StorefrontCustomerWishlistProductSection.ProductImageByName(productVar.name)}}" stepKey="AssertWishlistProductImage"/> - </actionGroup> -</actionGroups> diff --git a/dev/tests/acceptance/tests/functional/Magento/ConfigurableProductWishlist/ActionGroup/_Deprecated_ActionGroup/StorefrontCustomerCheckConfigurableProductInWishlistSidebarActionGroup.xml b/dev/tests/acceptance/tests/functional/Magento/ConfigurableProductWishlist/ActionGroup/_Deprecated_ActionGroup/StorefrontCustomerCheckConfigurableProductInWishlistSidebarActionGroup.xml deleted file mode 100644 index 4b22145f5130b..0000000000000 --- a/dev/tests/acceptance/tests/functional/Magento/ConfigurableProductWishlist/ActionGroup/_Deprecated_ActionGroup/StorefrontCustomerCheckConfigurableProductInWishlistSidebarActionGroup.xml +++ /dev/null @@ -1,24 +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="StorefrontCustomerCheckConfigurableProductInWishlistSidebar"> - <annotations> - <description>Validates that the provided Configurable Product and Product Option is present in the Storefront Wish List sidebar.</description> - </annotations> - <arguments> - <argument name="productVar"/> - <argument name="optionProductVar"/> - </arguments> - - <waitForElement selector="{{StorefrontCustomerWishlistSidebarSection.ProductTitleByName(productVar.name)}}" time="30" stepKey="assertWishlistSidebarProductName"/> - <see userInput="${{optionProductVar.price}}.00" selector="{{StorefrontCustomerWishlistSidebarSection.ProductPriceByName(productVar.name)}}" stepKey="AssertWishlistSidebarProductPrice"/> - <seeElement selector="{{StorefrontCustomerWishlistSidebarSection.ProductAddToCartByName(productVar.name)}}" stepKey="AssertWishlistSidebarAddToCart"/> - <seeElement selector="{{StorefrontCustomerWishlistSidebarSection.ProductImageByName(productVar.name)}}" stepKey="AssertWishlistSidebarProductImage"/> - </actionGroup> -</actionGroups> From 90bf91d3cd8c5fecc25e32096a812dd5226b4852 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Tue, 7 Apr 2020 13:01:21 +0100 Subject: [PATCH 082/177] Corrected blacklist patterns --- .../Model/Directory/IsBlacklisted.php | 13 ++++++------- app/code/Magento/MediaGallery/etc/directory.xml | 16 ++++++++-------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php index 7e79492f022dc..def5a0c817401 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php +++ b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php @@ -10,14 +10,12 @@ use Magento\MediaGalleryApi\Model\Directory\IsBlacklistedInterface; /** - * Directories blacklisted for media gallery. This class should be used for DI configuration. - * - * Please use the interface in the code (for constructor injection) instead of this implementation. - * - * @api + * Check if the path is blacklisted for media gallery. Directory path may be blacklisted if it's reserved by the system */ class IsBlacklisted implements IsBlacklistedInterface { + const XML_PATH_BLACKLIST_PATTERNS = 'blacklist/patterns'; + /** * @var Config */ @@ -26,7 +24,8 @@ class IsBlacklisted implements IsBlacklistedInterface /** * @param Config $config */ - public function __construct(Config $config) { + public function __construct(Config $config) + { $this->config = $config; } @@ -38,7 +37,7 @@ public function __construct(Config $config) { */ public function execute(string $path): bool { - foreach ($this->config->get('blacklist/patterns') as $pattern) { + foreach ($this->config->get(self::XML_PATH_BLACKLIST_PATTERNS) as $pattern) { if (empty($pattern)) { continue; } diff --git a/app/code/Magento/MediaGallery/etc/directory.xml b/app/code/Magento/MediaGallery/etc/directory.xml index 4bdaeb5edd0c7..2eb37aa81ab42 100644 --- a/app/code/Magento/MediaGallery/etc/directory.xml +++ b/app/code/Magento/MediaGallery/etc/directory.xml @@ -8,14 +8,14 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_MediaGallery:etc/directory.xsd"> <blacklist> <patterns> - <pattern name="captcha">/pub\/media\/captcha/</pattern> - <pattern name="catalog">/pub\/media\/catalog\/product/</pattern> - <pattern name="customer">/pub\/media\/customer/</pattern> - <pattern name="downloadable">/pub\/media\/downloadable/</pattern> - <pattern name="import">/pub\/media\/import/</pattern> - <pattern name="theme">/pub\/media\/theme/</pattern> - <pattern name="theme_customization">/pub\/media\/theme_customization/</pattern> - <pattern name="tmp">/pub\/media\/tmp/</pattern> + <pattern name="captcha">/^captcha/</pattern> + <pattern name="catalog">/^catalog\/product/</pattern> + <pattern name="customer">/^customer/</pattern> + <pattern name="downloadable">/^downloadable/</pattern> + <pattern name="import">/^import/</pattern> + <pattern name="theme">/^theme/</pattern> + <pattern name="theme_customization">/^theme_customization/</pattern> + <pattern name="tmp">/^tmp/</pattern> <pattern name="directories-with-dots">/^\./</pattern> </patterns> </blacklist> From 5d9d688777b5d41bbf35ff5b2df1fdd4e21d86d9 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Tue, 7 Apr 2020 14:26:43 +0100 Subject: [PATCH 083/177] Intorduced media_content config --- .../MediaContent/Model/Content/Config.php | 41 +++++++++++ .../Model/Content/Config/Converter.php | 59 ++++++++++++++++ .../Model/Content/Config/Reader.php | 68 +++++++++++++++++++ .../Model/Content/Config/SchemaLocator.php | 50 ++++++++++++++ .../Model/ExtractAssetsFromContent.php | 21 +++--- app/code/Magento/MediaContent/etc/di.xml | 20 +++++- .../MediaContent/etc/media_content.xsd | 38 +++++++++++ .../Magento/MediaContentCatalog/etc/di.xml | 7 -- .../MediaContentCatalog/etc/media_content.xml | 14 ++++ app/code/Magento/MediaContentCms/etc/di.xml | 7 -- .../MediaContentCms/etc/media_content.xml | 14 ++++ 11 files changed, 312 insertions(+), 27 deletions(-) create mode 100644 app/code/Magento/MediaContent/Model/Content/Config.php create mode 100644 app/code/Magento/MediaContent/Model/Content/Config/Converter.php create mode 100644 app/code/Magento/MediaContent/Model/Content/Config/Reader.php create mode 100644 app/code/Magento/MediaContent/Model/Content/Config/SchemaLocator.php rename app/code/Magento/{MediaContentApi => MediaContent}/Model/ExtractAssetsFromContent.php (84%) create mode 100644 app/code/Magento/MediaContent/etc/media_content.xsd create mode 100644 app/code/Magento/MediaContentCatalog/etc/media_content.xml create mode 100644 app/code/Magento/MediaContentCms/etc/media_content.xml diff --git a/app/code/Magento/MediaContent/Model/Content/Config.php b/app/code/Magento/MediaContent/Model/Content/Config.php new file mode 100644 index 0000000000000..87be885977f38 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/Content/Config.php @@ -0,0 +1,41 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model\Content; + +use Magento\Framework\Config\DataInterface; + +/** + * Media content config + */ +class Config +{ + /** + * @var DataInterface + */ + private $data; + + /** + * @param DataInterface $data + */ + public function __construct(DataInterface $data) + { + $this->data = $data; + } + + /** + * Get config value by key. + * + * @param string|null $key + * @param string|null $default + * @return array + */ + public function get($key = null, $default = null) + { + return $this->data->get($key, $default); + } +} \ No newline at end of file diff --git a/app/code/Magento/MediaContent/Model/Content/Config/Converter.php b/app/code/Magento/MediaContent/Model/Content/Config/Converter.php new file mode 100644 index 0000000000000..76c98d2df35a9 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/Content/Config/Converter.php @@ -0,0 +1,59 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model\Content\Config; + +use Magento\Framework\Config\ConverterInterface; + +/** + * Class Converter + */ +class Converter implements ConverterInterface +{ + /** + * Blacklist tag name + */ + private const BLACKLIST_TAG_NAME = 'search'; + + /** + * Patterns tag name + */ + private const PATTERNS_TAG_NAME = 'patterns'; + + /** + * Pattern tag name + */ + private const PATTERN_TAG_NAME = 'pattern'; + + /** + * Convert dom node to array + * + * @param \DOMDocument $source + * @return array + */ + public function convert($source) : array + { + $result = []; + + if (!$source instanceof \DOMDocument) { + return $result; + } + + foreach ($source->getElementsByTagName(self::BLACKLIST_TAG_NAME) as $blacklist) { + $result[self::BLACKLIST_TAG_NAME] = []; + foreach ($blacklist->getElementsByTagName(self::PATTERNS_TAG_NAME) as $patterns) { + $result[self::BLACKLIST_TAG_NAME][self::PATTERNS_TAG_NAME] = []; + foreach ($patterns->getElementsByTagName(self::PATTERN_TAG_NAME) as $pattern) { + $result[self::BLACKLIST_TAG_NAME][self::PATTERNS_TAG_NAME] + [$pattern->attributes->getNamedItem('name')->nodeValue] = $pattern->nodeValue; + } + } + } + + return $result; + } +} \ No newline at end of file diff --git a/app/code/Magento/MediaContent/Model/Content/Config/Reader.php b/app/code/Magento/MediaContent/Model/Content/Config/Reader.php new file mode 100644 index 0000000000000..61c153652a388 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/Content/Config/Reader.php @@ -0,0 +1,68 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model\Content\Config; + +use Magento\Framework\App\Area; +use Magento\Framework\Config\Dom; +use Magento\Framework\Config\FileResolverInterface; +use Magento\Framework\Config\Reader\Filesystem; +use Magento\Framework\Config\ReaderInterface; +use Magento\Framework\Config\ValidationStateInterface; + +/** + * Media content config reader + */ +class Reader extends Filesystem implements ReaderInterface +{ + /** + * List of id attributes for merge + * + * @var array + */ + protected $_idAttributes = [ + '/config/patterns' => 'patterns', + '/config/patterns/pattern' => 'name', + ]; + + /** + * XML Configuration file name + */ + private const XML_FILE_NAME = 'media_content.xml'; + + /** + * @param FileResolverInterface $fileResolver + * @param Converter $converter + * @param SchemaLocator $schemaLocator + * @param ValidationStateInterface $validationState + * @param string $fileName + * @param array $idAttributes + * @param string $domDocumentClass + * @param string $defaultScope + */ + public function __construct( + FileResolverInterface $fileResolver, + Converter $converter, + SchemaLocator $schemaLocator, + ValidationStateInterface $validationState, + $fileName = self::XML_FILE_NAME, + $idAttributes = [], + $domDocumentClass = Dom::class, + $defaultScope = Area::AREA_GLOBAL + ) { + parent::__construct( + $fileResolver, + $converter, + $schemaLocator, + $validationState, + $fileName, + $idAttributes, + $domDocumentClass, + $defaultScope + ); + } +} diff --git a/app/code/Magento/MediaContent/Model/Content/Config/SchemaLocator.php b/app/code/Magento/MediaContent/Model/Content/Config/SchemaLocator.php new file mode 100644 index 0000000000000..863db23a52331 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/Content/Config/SchemaLocator.php @@ -0,0 +1,50 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model\Content\Config; + +use Magento\Framework\Config\SchemaLocatorInterface; +use Magento\Framework\Module\Dir; +use Magento\Framework\Module\Dir\Reader; + +class SchemaLocator implements SchemaLocatorInterface +{ + /** + * Path to corresponding XSD file with validation rules for both individual and merged configs + * + * @var string + */ + private $schema; + + /** + * @param Reader $moduleReader + */ + public function __construct(Reader $moduleReader) + { + $this->schema = $moduleReader->getModuleDir(Dir::MODULE_ETC_DIR, 'Magento_MediaContent') . '/media_content.xsd'; + } + + /** + * Get path to merged config schema + * + * @return string|null + */ + public function getSchema() + { + return $this->schema; + } + + /** + * Get path to per file validation schema + * + * @return string|null + */ + public function getPerFileSchema() + { + return $this->schema; + } +} \ No newline at end of file diff --git a/app/code/Magento/MediaContentApi/Model/ExtractAssetsFromContent.php b/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php similarity index 84% rename from app/code/Magento/MediaContentApi/Model/ExtractAssetsFromContent.php rename to app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php index 7db389a0558f1..dcc6de03badac 100644 --- a/app/code/Magento/MediaContentApi/Model/ExtractAssetsFromContent.php +++ b/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php @@ -5,8 +5,9 @@ */ declare(strict_types=1); -namespace Magento\MediaContentApi\Model; +namespace Magento\MediaContent\Model; +use Magento\MediaContent\Model\Content\Config; use Magento\MediaContentApi\Api\ExtractAssetsFromContentInterface; use Magento\MediaGalleryApi\Api\Data\AssetInterface; use Magento\MediaGalleryApi\Model\Asset\Command\GetByPathInterface; @@ -14,17 +15,13 @@ /** * Used for extracting media asset list from a media content by the search pattern. - * - * This class should be used for DI configuration only, please use the interface in the code - * - * @api */ class ExtractAssetsFromContent implements ExtractAssetsFromContentInterface { /** - * @var string + * @var Config */ - private $searchPatterns; + private $config; /** * @var GetByPathInterface @@ -37,18 +34,18 @@ class ExtractAssetsFromContent implements ExtractAssetsFromContentInterface private $logger; /** + * @param Config $config * @param GetByPathInterface $getMediaAssetByPath * @param LoggerInterface $logger - * @param array $searchPatterns */ public function __construct( + Config $config, GetByPathInterface $getMediaAssetByPath, - LoggerInterface $logger, - array $searchPatterns + LoggerInterface $logger ) { + $this->config = $config; $this->getMediaAssetByPath = $getMediaAssetByPath; $this->logger = $logger; - $this->searchPatterns = $searchPatterns; } /** @@ -61,7 +58,7 @@ public function execute(string $content): array { $paths = []; - foreach ($this->searchPatterns as $pattern) { + foreach ($this->config->get('search/patterns') as $pattern) { if (empty($pattern)) { continue; } diff --git a/app/code/Magento/MediaContent/etc/di.xml b/app/code/Magento/MediaContent/etc/di.xml index ef3262ea09a79..62b9aa289a9eb 100644 --- a/app/code/Magento/MediaContent/etc/di.xml +++ b/app/code/Magento/MediaContent/etc/di.xml @@ -10,7 +10,7 @@ <preference for="Magento\MediaContentApi\Api\UnassignAssetsInterface" type="Magento\MediaContent\Model\UnassignAssets"/> <preference for="Magento\MediaContentApi\Api\GetAssetIdsUsedInContentInterface" type="Magento\MediaContent\Model\GetAssetIdsUsedInContent"/> <preference for="Magento\MediaContentApi\Api\GetContentWithAssetsInterface" type="Magento\MediaContent\Model\GetContentWithAssets"/> - <preference for="Magento\MediaContentApi\Api\ExtractAssetsFromContentInterface" type="Magento\MediaContentApi\Model\ExtractAssetsFromContent"/> + <preference for="Magento\MediaContentApi\Api\ExtractAssetsFromContentInterface" type="Magento\MediaContent\Model\ExtractAssetsFromContent"/> <preference for="Magento\MediaContentApi\Api\UpdateRelationsInterface" type="Magento\MediaContent\Model\UpdateRelations"/> <preference for="Magento\MediaContentApi\Api\Data\ContentIdentityInterface" type="Magento\MediaContent\Model\Content"/> <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface"> @@ -19,4 +19,22 @@ <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByDirectoryPathInterface"> <plugin name="remove_media_content_after_asset_is_removed_by_directory_path" type="Magento\MediaContent\Model\Plugin\MediaGalleryAssetDeleteByDirectoryPath" /> </type> + <type name="Magento\MediaContent\Model\Content\Config\Reader"> + <arguments> + <argument name="fileName" xsi:type="string">media_content.xml</argument> + <argument name="converter" xsi:type="object">Magento\MediaContent\Model\Content\Config\Converter</argument> + <argument name="schemaLocator" xsi:type="object">Magento\MediaContent\Model\Content\Config\SchemaLocator</argument> + </arguments> + </type> + <virtualType name="Magento\MediaContent\Model\Directory\Config\Data" type="Magento\Framework\Config\Data"> + <arguments> + <argument name="reader" xsi:type="object">Magento\MediaContent\Model\Content\Config\Reader</argument> + <argument name="cacheId" xsi:type="string">Media_Content_Patterns_CacheId</argument> + </arguments> + </virtualType> + <type name="Magento\MediaContent\Model\Content\Config"> + <arguments> + <argument name="data" xsi:type="object">Magento\MediaContent\Model\Content\Config\Data</argument> + </arguments> + </type> </config> diff --git a/app/code/Magento/MediaContent/etc/media_content.xsd b/app/code/Magento/MediaContent/etc/media_content.xsd new file mode 100644 index 0000000000000..5ed3b4594b995 --- /dev/null +++ b/app/code/Magento/MediaContent/etc/media_content.xsd @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <xs:element name="config" type="configType"> + </xs:element> + + <xs:complexType name="configType"> + <xs:sequence> + <xs:element type="searchType" name="search" maxOccurs="unbounded" minOccurs="1"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="searchType"> + <xs:sequence> + <xs:element type="patternsType" name="patterns" maxOccurs="unbounded" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="patternsType"> + <xs:sequence> + <xs:element type="patternType" name="pattern" maxOccurs="unbounded" minOccurs="0"/> + </xs:sequence> + </xs:complexType> + + <xs:complexType name="patternType"> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute type="xs:string" name="name" use="required"/> + <xs:attribute type="xs:string" name="example" use="optional"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> +</xs:schema> \ No newline at end of file diff --git a/app/code/Magento/MediaContentCatalog/etc/di.xml b/app/code/Magento/MediaContentCatalog/etc/di.xml index 88c92f6028b02..b61b9c1df5f1f 100644 --- a/app/code/Magento/MediaContentCatalog/etc/di.xml +++ b/app/code/Magento/MediaContentCatalog/etc/di.xml @@ -22,11 +22,4 @@ </argument> </arguments> </type> - <type name="Magento\MediaContentApi\Model\ExtractAssetsFromContent"> - <arguments> - <argument name="searchPatterns" xsi:type="array"> - <item name="catalog_image" xsi:type="string">/^\/?media\/(.*)/</item> - </argument> - </arguments> - </type> </config> diff --git a/app/code/Magento/MediaContentCatalog/etc/media_content.xml b/app/code/Magento/MediaContentCatalog/etc/media_content.xml new file mode 100644 index 0000000000000..0f5d800ed5684 --- /dev/null +++ b/app/code/Magento/MediaContentCatalog/etc/media_content.xml @@ -0,0 +1,14 @@ +<?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:module:Magento_MediaGallery:etc/directory.xsd"> + <search> + <patterns> + <pattern name="catalog_image">/^\/?media\/(.*)/</pattern> + </patterns> + </search> +</config> \ No newline at end of file diff --git a/app/code/Magento/MediaContentCms/etc/di.xml b/app/code/Magento/MediaContentCms/etc/di.xml index e1f94ec753c7b..f980936465faf 100644 --- a/app/code/Magento/MediaContentCms/etc/di.xml +++ b/app/code/Magento/MediaContentCms/etc/di.xml @@ -20,11 +20,4 @@ </argument> </arguments> </type> - <type name="Magento\MediaContentApi\Model\ExtractAssetsFromContent"> - <arguments> - <argument name="searchPatterns" xsi:type="array"> - <item name="media_gallery" xsi:type="string">/{{media url="?(.*?)"?}}/</item> - </argument> - </arguments> - </type> </config> diff --git a/app/code/Magento/MediaContentCms/etc/media_content.xml b/app/code/Magento/MediaContentCms/etc/media_content.xml new file mode 100644 index 0000000000000..e0e80f65738f9 --- /dev/null +++ b/app/code/Magento/MediaContentCms/etc/media_content.xml @@ -0,0 +1,14 @@ +<?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:module:Magento_MediaGallery:etc/directory.xsd"> + <search> + <patterns> + <pattern name="media_gallery">/{{media url="?(.*?)"?}}/</pattern> + </patterns> + </search> +</config> \ No newline at end of file From 7fd26a92ae5a3c38d156c958356c6afdf40688f7 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Tue, 7 Apr 2020 14:29:50 +0100 Subject: [PATCH 084/177] Added comments and strict types enabling --- .../Magento/MediaGallery/Model/Directory/Config.php | 3 ++- .../Model/Directory/Config/Converter.php | 12 +++++++----- .../MediaGallery/Model/Directory/Config/Reader.php | 5 +++++ .../Model/Directory/Config/SchemaLocator.php | 5 +++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config.php b/app/code/Magento/MediaGallery/Model/Directory/Config.php index 59b37cb4bbd25..7cd83d4edcb32 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Config.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Config.php @@ -3,13 +3,14 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\MediaGallery\Model\Directory; use Magento\Framework\Config\DataInterface; /** - * Config of Magento Media Gallery Directory. + * Media gallery directory config */ class Config { diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config/Converter.php b/app/code/Magento/MediaGallery/Model/Directory/Config/Converter.php index 564512935a3c4..c0b927cd2d884 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Config/Converter.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Config/Converter.php @@ -3,29 +3,31 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\MediaGallery\Model\Directory\Config; use Magento\Framework\Config\ConverterInterface; /** - * Class Converter + * Media gallery directory config converter */ class Converter implements ConverterInterface { /** * Blacklist tag name */ - private CONST BLACKLIST_TAG_NAME = 'blacklist'; + private const BLACKLIST_TAG_NAME = 'blacklist'; /** * Patterns tag name */ - private CONST PATTERNS_TAG_NAME = 'patterns'; + private const PATTERNS_TAG_NAME = 'patterns'; /** * Pattern tag name */ - private CONST PATTERN_TAG_NAME = 'pattern'; + private const PATTERN_TAG_NAME = 'pattern'; /** * Convert dom node to array @@ -33,7 +35,7 @@ class Converter implements ConverterInterface * @param \DOMDocument $source * @return array */ - public function convert($source) : array + public function convert($source): array { $result = []; diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php b/app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php index a502139b44ded..b8f844e26d979 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php @@ -3,6 +3,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\MediaGallery\Model\Directory\Config; use Magento\Framework\App\Area; @@ -12,6 +14,9 @@ use Magento\Framework\Config\ValidationStateInterface; use Magento\Framework\Config\Dom; +/** + * Media gallery directory config reader + */ class Reader extends Filesystem implements ReaderInterface { /** diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config/SchemaLocator.php b/app/code/Magento/MediaGallery/Model/Directory/Config/SchemaLocator.php index 26364951a23d4..6661b0d7e95ee 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Config/SchemaLocator.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Config/SchemaLocator.php @@ -3,12 +3,17 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\MediaGallery\Model\Directory\Config; use Magento\Framework\Module\Dir; use Magento\Framework\Module\Dir\Reader; use Magento\Framework\Config\SchemaLocatorInterface; +/** + * Media gallery directory config schema locator + */ class SchemaLocator implements SchemaLocatorInterface { /** From 28717cf7fbccf6f1049c9cdb91b099851eee9cf5 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Tue, 7 Apr 2020 16:03:54 +0100 Subject: [PATCH 085/177] Services convered with integration tests --- .../MediaContent/Model/AssignAssets.php | 9 +- .../MediaContent/Model/ContentIdentity.php | 4 +- .../Model/GetAssetIdsUsedInContent.php | 6 +- .../Model/GetContentWithAssets.php | 11 ++- .../MediaContent/Model/UnassignAssets.php | 4 +- .../Test/Unit/Model/AssignAssetsTest.php | 4 +- .../Unit/Model/GetAssetsusedInContentTest.php | 2 +- .../Magento/MediaContent/etc/db_schema.xml | 5 +- .../MediaContent/etc/db_schema_whitelist.json | 2 +- app/code/Magento/MediaContent/etc/di.xml | 4 +- .../MediaStorage/AssignGetUnassignTest.php | 92 +++++++++++++++++++ 11 files changed, 122 insertions(+), 21 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/MediaStorage/AssignGetUnassignTest.php diff --git a/app/code/Magento/MediaContent/Model/AssignAssets.php b/app/code/Magento/MediaContent/Model/AssignAssets.php index 7184e8b9914fa..a84edad563a78 100644 --- a/app/code/Magento/MediaContent/Model/AssignAssets.php +++ b/app/code/Magento/MediaContent/Model/AssignAssets.php @@ -20,7 +20,7 @@ class AssignAssets implements AssignAssetsInterface { private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; private const ASSET_ID = 'asset_id'; - private const TYPE = 'type'; + private const ENTITY_TYPE = 'entity_type'; private const ENTITY_ID = 'entity_id'; private const FIELD = 'field'; @@ -56,7 +56,7 @@ public function execute(ContentIdentityInterface $contentIdentity, array $assetI foreach ($assetIds as $assetId) { $data[] = [ self::ASSET_ID => $assetId, - self::TYPE => $contentIdentity->getEntityType(), + self::ENTITY_TYPE => $contentIdentity->getEntityType(), self::ENTITY_ID => $contentIdentity->getEntityId(), self::FIELD => $contentIdentity->getField() ]; @@ -64,8 +64,9 @@ public function execute(ContentIdentityInterface $contentIdentity, array $assetI $connection->insertMultiple($tableName, $data); } catch (\Exception $exception) { $this->logger->critical($exception); - $message = __('An error occurred while saving relation between media asset and media content.'); - throw new CouldNotSaveException($message); + throw new CouldNotSaveException( + __('An error occurred while saving relation between media asset and media content.') + ); } } } diff --git a/app/code/Magento/MediaContent/Model/ContentIdentity.php b/app/code/Magento/MediaContent/Model/ContentIdentity.php index 2af8dd043680d..3ded1358e068a 100644 --- a/app/code/Magento/MediaContent/Model/ContentIdentity.php +++ b/app/code/Magento/MediaContent/Model/ContentIdentity.php @@ -15,7 +15,7 @@ */ class ContentIdentity extends AbstractExtensibleModel implements ContentIdentityInterface { - private const TYPE = 'entity_type'; + private const ENTITY_TYPE = 'entity_type'; private const ENTITY_ID = 'entity_id'; private const FIELD = 'field'; @@ -24,7 +24,7 @@ class ContentIdentity extends AbstractExtensibleModel implements ContentIdentity */ public function getEntityType(): string { - return (string) $this->getData(self::TYPE); + return (string) $this->getData(self::ENTITY_TYPE); } /** diff --git a/app/code/Magento/MediaContent/Model/GetAssetIdsUsedInContent.php b/app/code/Magento/MediaContent/Model/GetAssetIdsUsedInContent.php index 4da0898525887..d33c8e6d2eb90 100644 --- a/app/code/Magento/MediaContent/Model/GetAssetIdsUsedInContent.php +++ b/app/code/Magento/MediaContent/Model/GetAssetIdsUsedInContent.php @@ -20,7 +20,7 @@ class GetAssetIdsUsedInContent implements GetAssetIdsUsedInContentInterface { private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; private const ASSET_ID = 'asset_id'; - private const TYPE = 'type'; + private const ENTITY_TYPE = 'entity_type'; private const ENTITY_ID = 'entity_id'; private const FIELD = 'field'; @@ -58,7 +58,7 @@ public function execute(ContentIdentityInterface $contentIdentity): array $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME), self::ASSET_ID )->where( - self::TYPE . ' = ?', + self::ENTITY_TYPE . ' = ?', $contentIdentity->getEntityType() )->where( self::ENTITY_ID . '= ?', @@ -68,7 +68,7 @@ public function execute(ContentIdentityInterface $contentIdentity): array $contentIdentity->getField() ); - return $connection->fetchAssoc($select); + return array_keys($connection->fetchAssoc($select)); } catch (\Exception $exception) { $this->logger->critical($exception); $message = __('An error occurred at getting asset used in content information.'); diff --git a/app/code/Magento/MediaContent/Model/GetContentWithAssets.php b/app/code/Magento/MediaContent/Model/GetContentWithAssets.php index 8f014ee77e680..adb38da4d04b0 100644 --- a/app/code/Magento/MediaContent/Model/GetContentWithAssets.php +++ b/app/code/Magento/MediaContent/Model/GetContentWithAssets.php @@ -20,6 +20,9 @@ class GetContentWithAssets implements GetContentWithAssetsInterface { private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; private const ASSET_ID = 'asset_id'; + private const ENTITY_TYPE = 'entity_type'; + private const ENTITY_ID = 'entity_id'; + private const FIELD = 'field'; /** * @var ResourceConnection @@ -59,8 +62,12 @@ public function execute(array $assetIds): array try { $connection = $this->resourceConnection->getConnection(); $select = $connection->select() - ->from($this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME)) - ->where(self::ASSET_ID . 'IN (?)', $assetIds); + ->distinct() + ->from( + $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME), + [self::ENTITY_TYPE, self::ENTITY_ID, self::FIELD] + ) + ->where(self::ASSET_ID . ' IN (?)', $assetIds); $contentIdentities = []; foreach ($connection->fetchAssoc($select) as $contentIdentityData) { diff --git a/app/code/Magento/MediaContent/Model/UnassignAssets.php b/app/code/Magento/MediaContent/Model/UnassignAssets.php index 3236538ff181c..0a2f952760e55 100644 --- a/app/code/Magento/MediaContent/Model/UnassignAssets.php +++ b/app/code/Magento/MediaContent/Model/UnassignAssets.php @@ -20,7 +20,7 @@ class UnassignAssets implements UnassignAssetsInterface { private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; private const ASSET_ID = 'asset_id'; - private const TYPE = 'type'; + private const ENTITY_TYPE = 'entity_type'; private const ENTITY_ID = 'entity_id'; private const FIELD = 'field'; @@ -58,7 +58,7 @@ public function execute(ContentIdentityInterface $contentIdentity, array $assetI $tableName, [ self::ASSET_ID . ' IN (?)' => $assetIds, - self::TYPE . ' = ?' => $contentIdentity->getEntityType(), + self::ENTITY_TYPE . ' = ?' => $contentIdentity->getEntityType(), self::ENTITY_ID . ' = ?' => $contentIdentity->getEntityId(), self::FIELD . ' = ?' => $contentIdentity->getField() ] diff --git a/app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetsTest.php b/app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetsTest.php index d2bb1ca5c59b7..c79cb36be27bd 100644 --- a/app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetsTest.php +++ b/app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetsTest.php @@ -41,7 +41,7 @@ class AssignAssetsTest extends TestCase /** * Media content type */ - private const TYPE = 'type'; + private const ENTITY_TYPE = 'entity_type'; /** * Media entity id @@ -120,7 +120,7 @@ public function testSuccessfulExecute( ): void { $saveData = [ self::ASSET_ID => $assetId, - self::TYPE => $contentType, + self::ENTITY_TYPE => $contentType, self::ENTITY_ID => $contentEntityId, self::FIELD => $contentField ]; diff --git a/app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php b/app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php index 5b5cf2b277ee5..4942ea24240bb 100644 --- a/app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php +++ b/app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php @@ -143,7 +143,7 @@ public function getAssetsListRelatedToContent(): array return [ [ [ - 'type' => 'cms_page', + 'entity_type' => 'cms_page', 'entity_id' => '1', 'field' => 'content' ], diff --git a/app/code/Magento/MediaContent/etc/db_schema.xml b/app/code/Magento/MediaContent/etc/db_schema.xml index 2cd917070cf0b..18700f09fd802 100644 --- a/app/code/Magento/MediaContent/etc/db_schema.xml +++ b/app/code/Magento/MediaContent/etc/db_schema.xml @@ -8,13 +8,14 @@ <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> <table name="media_content_asset" resource="default" engine="innodb" comment="Relation between media content and media asset"> <column xsi:type="int" padding="10" name="asset_id" unsigned="true" nullable="false" identity="true" comment="Entity ID"/> - <column xsi:type="varchar" length="255" name="type" nullable="false" comment="Content type"/> + <column xsi:type="varchar" length="255" name="entity_type" nullable="false" comment="Content type"/> <column xsi:type="varchar" length="255" name="entity_id" nullable="false" comment="Content entity id"/> <column xsi:type="varchar" length="255" name="field" nullable="false" comment="Content field"/> <constraint xsi:type="primary" referenceId="PRIMARY"> <column name="asset_id"/> - <column name="type"/> + <column name="entity_type"/> <column name="field"/> + <column name="entity_id"/> </constraint> </table> </schema> diff --git a/app/code/Magento/MediaContent/etc/db_schema_whitelist.json b/app/code/Magento/MediaContent/etc/db_schema_whitelist.json index 071dc72b3a467..a9e141117c72e 100644 --- a/app/code/Magento/MediaContent/etc/db_schema_whitelist.json +++ b/app/code/Magento/MediaContent/etc/db_schema_whitelist.json @@ -2,7 +2,7 @@ "media_content_asset": { "column": { "asset_id": true, - "type": true, + "entity_type": true, "entity_id": true, "field": true }, diff --git a/app/code/Magento/MediaContent/etc/di.xml b/app/code/Magento/MediaContent/etc/di.xml index 62b9aa289a9eb..a5e0ec876a801 100644 --- a/app/code/Magento/MediaContent/etc/di.xml +++ b/app/code/Magento/MediaContent/etc/di.xml @@ -12,7 +12,7 @@ <preference for="Magento\MediaContentApi\Api\GetContentWithAssetsInterface" type="Magento\MediaContent\Model\GetContentWithAssets"/> <preference for="Magento\MediaContentApi\Api\ExtractAssetsFromContentInterface" type="Magento\MediaContent\Model\ExtractAssetsFromContent"/> <preference for="Magento\MediaContentApi\Api\UpdateRelationsInterface" type="Magento\MediaContent\Model\UpdateRelations"/> - <preference for="Magento\MediaContentApi\Api\Data\ContentIdentityInterface" type="Magento\MediaContent\Model\Content"/> + <preference for="Magento\MediaContentApi\Api\Data\ContentIdentityInterface" type="Magento\MediaContent\Model\ContentIdentity"/> <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface"> <plugin name="remove_media_content_after_asset_is_removed_by_path" type="Magento\MediaContent\Model\Plugin\MediaGalleryAssetDeleteByPath" /> </type> @@ -26,7 +26,7 @@ <argument name="schemaLocator" xsi:type="object">Magento\MediaContent\Model\Content\Config\SchemaLocator</argument> </arguments> </type> - <virtualType name="Magento\MediaContent\Model\Directory\Config\Data" type="Magento\Framework\Config\Data"> + <virtualType name="Magento\MediaContent\Model\Content\Config\Data" type="Magento\Framework\Config\Data"> <arguments> <argument name="reader" xsi:type="object">Magento\MediaContent\Model\Content\Config\Reader</argument> <argument name="cacheId" xsi:type="string">Media_Content_Patterns_CacheId</argument> diff --git a/dev/tests/integration/testsuite/Magento/MediaStorage/AssignGetUnassignTest.php b/dev/tests/integration/testsuite/Magento/MediaStorage/AssignGetUnassignTest.php new file mode 100644 index 0000000000000..01911284447dd --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaStorage/AssignGetUnassignTest.php @@ -0,0 +1,92 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + * + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\MediaContentApi\Api\AssignAssetsInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; +use Magento\MediaContentApi\Api\GetAssetIdsUsedInContentInterface; +use Magento\MediaContentApi\Api\GetContentWithAssetsInterface; +use Magento\MediaContentApi\Api\UnassignAssetsInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Test for AssignAssets service + */ +class AssignGetUnassignTest extends TestCase +{ + /** + * @var AssignAssetsInterface + */ + private $assign; + + /** + * @var GetAssetIdsUsedInContentInterface + */ + private $getAssetIds; + + /** + * @var GetContentWithAssetsInterface + */ + private $getContent; + + /** + * @var UnassignAssetsInterface + */ + private $unassign; + + /** + * @inheritdoc + */ + public function setUp() + { + $this->assign = Bootstrap::getObjectManager()->create(AssignAssetsInterface::class); + $this->getAssetIds = Bootstrap::getObjectManager()->create(GetAssetIdsUsedInContentInterface::class); + $this->getContent = Bootstrap::getObjectManager()->create(GetContentWithAssetsInterface::class); + $this->unassign = Bootstrap::getObjectManager()->create(UnassignAssetsInterface::class); + } + + /** + * Assing assets to content, retrieve the data, then unassign assets from content + */ + public function testAssignRetrieveAndUnassign() + { + $contentIdentity = Bootstrap::getObjectManager()->create( + ContentIdentityInterface::class, + [ + 'data' => [ + 'entity_type' => 'catalog_product', + 'entity_id' => '42', + 'field' => 'description' + ] + ] + ); + $assetIds = [56, 78]; + + $this->assign->execute($contentIdentity, $assetIds); + + $retrievedAssetIds = $this->getAssetIds->execute($contentIdentity); + $this->assertEquals($assetIds, $retrievedAssetIds); + + + $retrievedContentIdentities = $this->getContent->execute($assetIds); + + $this->assertEquals(count($retrievedContentIdentities), 1); + + $identity = $retrievedContentIdentities[0]; + $this->assertEquals('catalog_product', $identity->getEntityType()); + $this->assertEquals('42', $identity->getEntityId()); + $this->assertEquals('description', $identity->getField()); + + $this->unassign->execute($contentIdentity, $assetIds); + + $this->assertEmpty($this->getContent->execute($assetIds)); + $this->assertEmpty($this->getAssetIds->execute($contentIdentity)); + } +} From 3d8c2cf620ef9f06381c872383be5d5df30d2156 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Tue, 7 Apr 2020 17:40:26 +0100 Subject: [PATCH 086/177] Removed unnecessary sequence --- app/code/Magento/Cms/etc/module.xml | 1 - app/code/Magento/MediaContentCms/etc/module.xml | 4 +--- .../Model}/AssignGetUnassignTest.php | 0 3 files changed, 1 insertion(+), 4 deletions(-) rename dev/tests/integration/testsuite/Magento/{MediaStorage => MediaContent/Model}/AssignGetUnassignTest.php (100%) diff --git a/app/code/Magento/Cms/etc/module.xml b/app/code/Magento/Cms/etc/module.xml index 4c2e91ad5e172..d3fc2846217d9 100644 --- a/app/code/Magento/Cms/etc/module.xml +++ b/app/code/Magento/Cms/etc/module.xml @@ -11,7 +11,6 @@ <module name="Magento_Store"/> <module name="Magento_Theme"/> <module name="Magento_Variable"/> - <module name="Magento_MediaContentCms"/> </sequence> </module> </config> diff --git a/app/code/Magento/MediaContentCms/etc/module.xml b/app/code/Magento/MediaContentCms/etc/module.xml index e273636359b5b..868a6d96fdf51 100644 --- a/app/code/Magento/MediaContentCms/etc/module.xml +++ b/app/code/Magento/MediaContentCms/etc/module.xml @@ -6,7 +6,5 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> - <module name="Magento_MediaContentCms"> - <module name="Magento_MediaContent"/> - </module> + <module name="Magento_MediaContentCms"/> </config> diff --git a/dev/tests/integration/testsuite/Magento/MediaStorage/AssignGetUnassignTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php similarity index 100% rename from dev/tests/integration/testsuite/Magento/MediaStorage/AssignGetUnassignTest.php rename to dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php From e1bea53943aeff722bc4c070701640218a62c06b Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets <vzaets@magento.com> Date: Tue, 7 Apr 2020 23:16:03 -0500 Subject: [PATCH 087/177] - Fix unit test - Refactoring --- .../MediaGallery/Model/Directory/Config.php | 12 ++++++ .../Model/Directory/Config/Converter.php | 2 +- .../Model/Directory/Config/Reader.php | 43 ------------------- .../Model/Directory/IsBlacklisted.php | 4 +- .../Unit/Model/Asset/Command/SaveTest.php | 1 - .../Model/Directory/IsBlacklistedTest.php | 23 ++++++---- 6 files changed, 28 insertions(+), 57 deletions(-) diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config.php b/app/code/Magento/MediaGallery/Model/Directory/Config.php index 7cd83d4edcb32..3e47161f35c06 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Config.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Config.php @@ -14,6 +14,8 @@ */ class Config { + private const XML_PATH_BLACKLIST_PATTERNS = 'blacklist/patterns'; + /** * @var DataInterface */ @@ -38,4 +40,14 @@ public function get($key = null, $default = null) { return $this->data->get($key, $default); } + + /** + * Returns list of blacklist regexp patterns + * + * @return array + */ + public function getBlacklistPatterns() : array + { + return $this->data->get(self::XML_PATH_BLACKLIST_PATTERNS); + } } diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config/Converter.php b/app/code/Magento/MediaGallery/Model/Directory/Config/Converter.php index c0b927cd2d884..91f16d246f636 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Config/Converter.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Config/Converter.php @@ -40,7 +40,7 @@ public function convert($source): array $result = []; if (!$source instanceof \DOMDocument) { - return $result; + throw new \InvalidArgumentException('The source should be instance of DOMDocument'); } foreach ($source->getElementsByTagName(self::BLACKLIST_TAG_NAME) as $blacklist) { diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php b/app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php index b8f844e26d979..85f61f712d580 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php @@ -7,12 +7,8 @@ namespace Magento\MediaGallery\Model\Directory\Config; -use Magento\Framework\App\Area; use Magento\Framework\Config\ReaderInterface; use Magento\Framework\Config\Reader\Filesystem; -use Magento\Framework\Config\FileResolverInterface; -use Magento\Framework\Config\ValidationStateInterface; -use Magento\Framework\Config\Dom; /** * Media gallery directory config reader @@ -28,43 +24,4 @@ class Reader extends Filesystem implements ReaderInterface '/config/patterns' => 'patterns', '/config/patterns/pattern' => 'name', ]; - - /** - * XML Configuration file name - */ - private const XML_FILE_NAME = 'directory.xml'; - - /** - * Construct the FileSystem Reader Class - * - * @param \Magento\Framework\Config\FileResolverInterface $fileResolver - * @param Converter $converter - * @param SchemaLocator $schemaLocator - * @param \Magento\Framework\Config\ValidationStateInterface $validationState - * @param string $fileName - * @param array $idAttributes - * @param string $domDocumentClass - * @param string $defaultScope - */ - public function __construct( - FileResolverInterface $fileResolver, - Converter $converter, - SchemaLocator $schemaLocator, - ValidationStateInterface $validationState, - $fileName = self::XML_FILE_NAME, - $idAttributes = [], - $domDocumentClass = Dom::class, - $defaultScope = Area::AREA_GLOBAL - ) { - parent::__construct( - $fileResolver, - $converter, - $schemaLocator, - $validationState, - $fileName, - $idAttributes, - $domDocumentClass, - $defaultScope - ); - } } diff --git a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php index def5a0c817401..3ec50eaac4b9e 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php +++ b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php @@ -14,8 +14,6 @@ */ class IsBlacklisted implements IsBlacklistedInterface { - const XML_PATH_BLACKLIST_PATTERNS = 'blacklist/patterns'; - /** * @var Config */ @@ -37,7 +35,7 @@ public function __construct(Config $config) */ public function execute(string $path): bool { - foreach ($this->config->get(self::XML_PATH_BLACKLIST_PATTERNS) as $pattern) { + foreach ($this->config->getBlacklistPatterns() as $pattern) { if (empty($pattern)) { continue; } diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php index 8af26f0c64b16..16f5e4576d736 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php @@ -7,7 +7,6 @@ namespace Magento\MediaGallery\Test\Unit\Model\Asset\Command; -use Magento\Eav\Helper\Data; use Magento\MediaGallery\Model\Asset\Command\Save; use Magento\MediaGalleryApi\Api\Data\AssetInterface; use Magento\Framework\App\ResourceConnection; diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php index 4742db34cfcab..0871759087468 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php @@ -10,6 +10,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use PHPUnit\Framework\TestCase; use Magento\MediaGallery\Model\Directory\IsBlacklisted; +use Magento\MediaGallery\Model\Directory\Config; /** * Test the Excluded model @@ -21,20 +22,24 @@ class IsBlacklistedTest extends TestCase */ private $object; + /** + * @var + */ + private $config; + /** * Initialize basic test class mocks */ protected function setUp(): void { - $this->object = (new ObjectManager($this))->getObject( - IsBlacklisted::class, - [ - 'patterns' => [ - 'tmp' => '/pub\/media\/tmp/', - 'captcha' => '/pub\/media\/captcha/' - ] - ] - ); + $this->config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); + $this->config->expects($this->at(0))->method('getBlacklistPatterns')->willReturn([ + 'tmp' => '/pub\/media\/tmp/', + 'captcha' => '/pub\/media\/captcha/' + ]); + $this->object = (new ObjectManager($this))->getObject(IsBlacklisted::class, [ + 'config' => $this->config + ]); } /** From 2bd86096ca464ca5a2d9369c778981bc0f510e88 Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets <vzaets@magento.com> Date: Tue, 7 Apr 2020 23:18:55 -0500 Subject: [PATCH 088/177] - Fix unit test --- .../MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php index 16f5e4576d736..4340a77e0b39a 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php @@ -112,7 +112,7 @@ protected function setUp(): void Save::class, [ 'resourceConnection' => $this->resourceConnectionMock, - 'objectProcessor' => $this->objectProcessor, + 'objectProcessor' => $this->objectProcessor, 'logger' => $this->loggerMock ] ); From e69ee881fde34e5caff736b6a1364f24617115ee Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets <vzaets@magento.com> Date: Tue, 7 Apr 2020 23:53:01 -0500 Subject: [PATCH 089/177] - Remove optional example attribute from xsd --- app/code/Magento/MediaGallery/etc/directory.xsd | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/MediaGallery/etc/directory.xsd b/app/code/Magento/MediaGallery/etc/directory.xsd index b9abd04ae1456..4c0b1120db304 100644 --- a/app/code/Magento/MediaGallery/etc/directory.xsd +++ b/app/code/Magento/MediaGallery/etc/directory.xsd @@ -31,7 +31,6 @@ <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute type="xs:string" name="name" use="required"/> - <xs:attribute type="xs:string" name="example" use="optional"/> </xs:extension> </xs:simpleContent> </xs:complexType> From 5aceeab83acb63ed233b4cdd028540c12c5cfd6d Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets <vzaets@magento.com> Date: Wed, 8 Apr 2020 01:07:59 -0500 Subject: [PATCH 090/177] - Add rollback for media_asset fixture. - fix typo --- .../File/Command/DeleteByAssertIdTest.php | 4 ++-- .../_files/media_asset_rollback.php | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/File/Command/DeleteByAssertIdTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/File/Command/DeleteByAssertIdTest.php index 7eb0d7a886e92..5acfb6170e155 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/File/Command/DeleteByAssertIdTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/File/Command/DeleteByAssertIdTest.php @@ -14,7 +14,7 @@ use Magento\MediaGalleryApi\Model\Asset\Command\GetByIdInterface; /** - * Test methods of class DeleteByPath + * Test methods of class DeleteByAssertIdTest */ class DeleteByAssertIdTest extends \PHPUnit\Framework\TestCase { @@ -24,7 +24,7 @@ class DeleteByAssertIdTest extends \PHPUnit\Framework\TestCase private CONST TEST_DIRECTORY_NAME = 'testDirectory'; /** - * Absolute path to the media direcrory + * Absolute path to the media directory */ private static $_mediaPath; diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php new file mode 100644 index 0000000000000..5f26d9350775e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php @@ -0,0 +1,22 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +use Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); + +/** @var DeleteByPathInterface $mediaSave */ +$mediaAssetDelete = $objectManager->get(DeleteByPathInterface::class); + +try { + $mediaAssetDelete->execute('testDirectory/path.jpg'); +} catch (\Exception $exception) { + +} + From 05667ed53584030e1771654585cdb9234ad834fe Mon Sep 17 00:00:00 2001 From: "rostyslav.hymon" <rostyslav.hymon@transoftgroup.com> Date: Wed, 8 Apr 2020 09:23:02 +0300 Subject: [PATCH 091/177] MC-33151: Performance issue caused by checking if DB tables exist on every call --- .../App/Config/Source/RuntimeConfigSource.php | 18 ++++++- .../Config/Source/RuntimeConfigSourceTest.php | 54 +++++++++++++++---- .../App/Config/Source/RuntimeConfigSource.php | 36 +++++++------ .../Store/Model/Config/Processor/Fallback.php | 35 ++++++++---- .../Store/Model/ResourceModel/Store.php | 14 ++--- .../Store/Model/ResourceModel/Website.php | 12 ++--- .../Config/Source/RuntimeConfigSourceTest.php | 32 ++++++++--- .../Unit/Model/ResourceModel/StoreTest.php | 40 -------------- .../Unit/Model/ResourceModel/WebsiteTest.php | 40 -------------- .../Model/ResourceModel/Db/ProfilerTest.php | 4 +- .../Magento/Setup/Module/DataSetupTest.php | 5 +- .../Framework/DB/Adapter/Pdo/Mysql.php | 13 ++++- .../DB/Adapter/TableNotFoundException.php | 15 ++++++ 13 files changed, 172 insertions(+), 146 deletions(-) create mode 100644 lib/internal/Magento/Framework/DB/Adapter/TableNotFoundException.php diff --git a/app/code/Magento/Config/App/Config/Source/RuntimeConfigSource.php b/app/code/Magento/Config/App/Config/Source/RuntimeConfigSource.php index b33c944c73477..7926708772a9f 100644 --- a/app/code/Magento/Config/App/Config/Source/RuntimeConfigSource.php +++ b/app/code/Magento/Config/App/Config/Source/RuntimeConfigSource.php @@ -8,9 +8,12 @@ use Magento\Framework\App\Config\ConfigSourceInterface; use Magento\Framework\App\Config\ScopeCodeResolver; use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\DeploymentConfig; +use Magento\Framework\App\ObjectManager; use Magento\Framework\DataObject; use Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory; use Magento\Framework\App\Config\Scope\Converter; +use Magento\Framework\DB\Adapter\TableNotFoundException; /** * Class for retrieving runtime configuration from database. @@ -34,20 +37,27 @@ class RuntimeConfigSource implements ConfigSourceInterface * @var ScopeCodeResolver */ private $scopeCodeResolver; + /** + * @var DeploymentConfig + */ + private $deploymentConfig; /** * @param CollectionFactory $collectionFactory * @param ScopeCodeResolver $scopeCodeResolver * @param Converter $converter + * @param DeploymentConfig|null $deploymentConfig */ public function __construct( CollectionFactory $collectionFactory, ScopeCodeResolver $scopeCodeResolver, - Converter $converter + Converter $converter, + ?DeploymentConfig $deploymentConfig = null ) { $this->collectionFactory = $collectionFactory; $this->converter = $converter; $this->scopeCodeResolver = $scopeCodeResolver; + $this->deploymentConfig = $deploymentConfig ?? ObjectManager::getInstance()->get(DeploymentConfig::class); } /** @@ -59,7 +69,7 @@ public function __construct( */ public function get($path = '') { - $data = new DataObject($this->loadConfig()); + $data = new DataObject($this->deploymentConfig->isDbAvailable() ? $this->loadConfig() : []); return $data->getData($path) ?: []; } @@ -75,8 +85,12 @@ private function loadConfig() { try { $collection = $this->collectionFactory->create(); + $collection->load(); } catch (\DomainException $e) { $collection = []; + } catch (TableNotFoundException $exception) { + // database is empty or not setup + $collection = []; } $config = []; foreach ($collection as $item) { diff --git a/app/code/Magento/Config/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php b/app/code/Magento/Config/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php index ae6ee8a028868..d880d93d78da3 100644 --- a/app/code/Magento/Config/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php +++ b/app/code/Magento/Config/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php @@ -5,41 +5,46 @@ */ namespace Magento\Config\Test\Unit\App\Config\Source; +use ArrayIterator; use Magento\Config\App\Config\Source\RuntimeConfigSource; +use Magento\Config\Model\ResourceModel\Config\Data\Collection; use Magento\Config\Model\ResourceModel\Config\Data\CollectionFactory; use Magento\Framework\App\Config\Scope\Converter; use Magento\Framework\App\Config\ScopeCodeResolver; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\Config\Value; +use Magento\Framework\App\DeploymentConfig; +use Magento\Framework\DB\Adapter\TableNotFoundException; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; /** * Test Class for retrieving runtime configuration from database. - * @package Magento\Config\Test\Unit\App\Config\Source */ -class RuntimeConfigSourceTest extends \PHPUnit\Framework\TestCase +class RuntimeConfigSourceTest extends TestCase { /** - * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + * @var CollectionFactory|MockObject */ private $collectionFactory; /** - * @var ScopeCodeResolver|\PHPUnit_Framework_MockObject_MockObject + * @var ScopeCodeResolver|MockObject */ private $scopeCodeResolver; /** - * @var Converter|\PHPUnit_Framework_MockObject_MockObject + * @var Converter|MockObject */ private $converter; /** - * @var Value|\PHPUnit_Framework_MockObject_MockObject + * @var Value|MockObject */ private $configItem; /** - * @var Value|\PHPUnit_Framework_MockObject_MockObject + * @var Value|MockObject */ private $configItemTwo; @@ -47,6 +52,10 @@ class RuntimeConfigSourceTest extends \PHPUnit\Framework\TestCase * @var RuntimeConfigSource */ private $configSource; + /** + * @var DeploymentConfig|MockObject + */ + private $deploymentConfig; public function setUp() { @@ -68,20 +77,29 @@ public function setUp() ->disableOriginalConstructor() ->setMethods(['getScope', 'getPath', 'getValue', 'getScopeId']) ->getMock(); + $this->deploymentConfig = $this->createPartialMock(DeploymentConfig::class, ['isDbAvailable']); $this->configSource = new RuntimeConfigSource( $this->collectionFactory, $this->scopeCodeResolver, - $this->converter + $this->converter, + $this->deploymentConfig ); } public function testGet() { + $this->deploymentConfig->method('isDbAvailable') + ->willReturn(true); + $collection = $this->createPartialMock(Collection::class, ['load', 'getIterator']); + $collection->method('load') + ->willReturn($collection); + $collection->method('getIterator') + ->willReturn(new ArrayIterator([$this->configItem, $this->configItemTwo])); $scope = 'websites'; $scopeCode = 'myWebsites'; $this->collectionFactory->expects($this->once()) ->method('create') - ->willReturn([$this->configItem, $this->configItemTwo]); + ->willReturn($collection); $this->configItem->expects($this->exactly(2)) ->method('getScope') ->willReturn(ScopeConfigInterface::SCOPE_TYPE_DEFAULT); @@ -133,4 +151,22 @@ public function testGet() $this->configSource->get() ); } + + public function testGetWhenDbIsNotAvailable() + { + $this->deploymentConfig->method('isDbAvailable')->willReturn(false); + $this->assertEquals([], $this->configSource->get()); + } + + public function testGetWhenDbIsEmpty() + { + $this->deploymentConfig->method('isDbAvailable') + ->willReturn(true); + $collection = $this->createPartialMock(Collection::class, ['load']); + $collection->method('load') + ->willThrowException($this->createMock(TableNotFoundException::class)); + $this->collectionFactory->method('create') + ->willReturn($collection); + $this->assertEquals([], $this->configSource->get()); + } } diff --git a/app/code/Magento/Store/App/Config/Source/RuntimeConfigSource.php b/app/code/Magento/Store/App/Config/Source/RuntimeConfigSource.php index f732871114061..b8b0ede43c70d 100644 --- a/app/code/Magento/Store/App/Config/Source/RuntimeConfigSource.php +++ b/app/code/Magento/Store/App/Config/Source/RuntimeConfigSource.php @@ -9,6 +9,7 @@ use Magento\Framework\App\DeploymentConfig; use Magento\Framework\App\ResourceConnection; use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\DB\Adapter\TableNotFoundException; /** * Config source. Retrieve all configuration for scopes from db @@ -53,15 +54,21 @@ public function __construct( */ public function get($path = '') { - if ($this->canUseDatabase()) { - return [ - 'websites' => $this->getEntities('store_website', 'code'), - 'groups' => $this->getEntities('store_group', 'group_id'), - 'stores' => $this->getEntities('store', 'code'), - ]; + $data = []; + try { + if ($this->canUseDatabase()) { + $data = [ + 'websites' => $this->getEntities('store_website', 'code'), + 'groups' => $this->getEntities('store_group', 'group_id'), + 'stores' => $this->getEntities('store', 'code'), + ]; + } + } catch (TableNotFoundException $exception) { + // database is empty or not setup + $data = []; } - return []; + return $data; } /** @@ -89,14 +96,13 @@ private function getEntities($table, $keyField) $data = []; $tableName = $this->resourceConnection->getTableName($table); // Check if db table exists before fetch data - if ($this->resourceConnection->getConnection()->isTableExists($tableName)) { - $entities = $this->getConnection()->fetchAll( - $this->getConnection()->select()->from($tableName) - ); - foreach ($entities as $entity) { - $data[$entity[$keyField]] = $entity; - } + $entities = $this->getConnection()->fetchAll( + $this->getConnection()->select()->from($tableName) + ); + + foreach ($entities as $entity) { + $data[$entity[$keyField]] = $entity; } return $data; @@ -109,6 +115,6 @@ private function getEntities($table, $keyField) */ private function canUseDatabase() { - return $this->deploymentConfig->get('db'); + return $this->deploymentConfig->isDbAvailable(); } } diff --git a/app/code/Magento/Store/Model/Config/Processor/Fallback.php b/app/code/Magento/Store/Model/Config/Processor/Fallback.php index 57ac3459ccb48..4e8b3bca14c92 100644 --- a/app/code/Magento/Store/Model/Config/Processor/Fallback.php +++ b/app/code/Magento/Store/Model/Config/Processor/Fallback.php @@ -8,8 +8,7 @@ use Magento\Framework\App\Config\Spi\PostProcessorInterface; use Magento\Framework\App\DeploymentConfig; use Magento\Framework\App\ResourceConnection; -use Magento\Store\Api\Data\StoreInterface; -use Magento\Store\Api\Data\WebsiteInterface; +use Magento\Framework\DB\Adapter\TableNotFoundException; use Magento\Store\App\Config\Type\Scopes; use Magento\Store\Model\ResourceModel\Store; use Magento\Store\Model\ResourceModel\Store\AllStoresCollectionFactory; @@ -85,13 +84,7 @@ public function __construct( */ public function process(array $data) { - if ($this->deploymentConfig->isDbAvailable()) {//read only from db - $this->storeData = $this->storeResource->readAllStores(); - $this->websiteData = $this->websiteResource->readAllWebsites(); - } else { - $this->storeData = $this->scopes->get('stores'); - $this->websiteData = $this->scopes->get('websites'); - } + $this->loadScopes(); $defaultConfig = isset($data['default']) ? $data['default'] : []; $result = [ @@ -177,4 +170,28 @@ private function getWebsiteConfig(array $websites, $id) } return []; } + + /** + * Load config from database. + * + * @return void + */ + private function loadScopes(): void + { + $loaded = false; + try { + if ($this->deploymentConfig->isDbAvailable()) { + $this->storeData = $this->storeResource->readAllStores(); + $this->websiteData = $this->websiteResource->readAllWebsites(); + $loaded = true; + } + } catch (TableNotFoundException $exception) { + // database is empty or not setup + $loaded = false; + } + if (!$loaded) { + $this->storeData = $this->scopes->get('stores'); + $this->websiteData = $this->scopes->get('websites'); + } + } } diff --git a/app/code/Magento/Store/Model/ResourceModel/Store.php b/app/code/Magento/Store/Model/ResourceModel/Store.php index 7a2821987f9bf..cadbe1817aed2 100644 --- a/app/code/Magento/Store/Model/ResourceModel/Store.php +++ b/app/code/Magento/Store/Model/ResourceModel/Store.php @@ -166,16 +166,10 @@ protected function _changeGroup(\Magento\Framework\Model\AbstractModel $model) */ public function readAllStores() { - $stores = []; - if ($this->getConnection()->isTableExists($this->getMainTable())) { - $select = $this->getConnection() - ->select() - ->from($this->getTable($this->getMainTable())); - - $stores = $this->getConnection()->fetchAll($select); - } - - return $stores; + $select = $this->getConnection() + ->select() + ->from($this->getTable($this->getMainTable())); + return $this->getConnection()->fetchAll($select); } /** diff --git a/app/code/Magento/Store/Model/ResourceModel/Website.php b/app/code/Magento/Store/Model/ResourceModel/Website.php index 431a9d62e7c39..a59c7746bec6e 100644 --- a/app/code/Magento/Store/Model/ResourceModel/Website.php +++ b/app/code/Magento/Store/Model/ResourceModel/Website.php @@ -48,14 +48,12 @@ public function readAllWebsites() { $websites = []; $tableName = $this->getMainTable(); - if ($this->getConnection()->isTableExists($tableName)) { - $select = $this->getConnection() - ->select() - ->from($tableName); + $select = $this->getConnection() + ->select() + ->from($tableName); - foreach ($this->getConnection()->fetchAll($select) as $websiteData) { - $websites[$websiteData['code']] = $websiteData; - } + foreach ($this->getConnection()->fetchAll($select) as $websiteData) { + $websites[$websiteData['code']] = $websiteData; } return $websites; diff --git a/app/code/Magento/Store/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php b/app/code/Magento/Store/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php index a8f76d0a28fee..104c1bbba2614 100644 --- a/app/code/Magento/Store/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php +++ b/app/code/Magento/Store/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php @@ -8,6 +8,7 @@ use Magento\Framework\App\DeploymentConfig; use Magento\Framework\App\ResourceConnection; use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\DB\Adapter\TableNotFoundException; use Magento\Framework\DB\Select; use Magento\Store\App\Config\Source\RuntimeConfigSource; @@ -54,8 +55,7 @@ public function setUp() public function testGet() { $this->deploymentConfig->expects($this->any()) - ->method('get') - ->with('db') + ->method('isDbAvailable') ->willReturn(true); $this->resourceConnection->expects($this->any())->method('getConnection')->willReturn($this->connection); @@ -63,7 +63,6 @@ public function testGet() $selectMock->expects($this->any())->method('from')->willReturnSelf(); $this->connection->expects($this->any())->method('select')->willReturn($selectMock); $this->connection->expects($this->any())->method('fetchAll')->willReturn([]); - $this->assertEquals( [ 'websites' => [], @@ -74,13 +73,32 @@ public function testGet() ); } - public function testGenWhenDbNotAvailable() + public function testGetWhenDbIsNotAvailable() { $this->deploymentConfig->expects($this->once()) - ->method('get') - ->with('db') + ->method('isDbAvailable') ->willReturn(false); - $this->resourceConnection->expects($this->never())->method('getConnection'); + $this->resourceConnection->expects($this->never()) + ->method('getConnection'); + + $this->assertEquals([], $this->configSource->get()); + } + + public function testGetWhenDbIsEmpty() + { + $this->deploymentConfig->expects($this->once()) + ->method('isDbAvailable') + ->willReturn(true); + $this->connection->method('fetchAll') + ->willThrowException($this->createMock(TableNotFoundException::class)); + $selectMock = $this->createMock(Select::class); + $selectMock->method('from') + ->willReturnSelf(); + $this->connection->method('select') + ->willReturn($selectMock); + $this->resourceConnection->expects($this->once()) + ->method('getConnection') + ->willReturn($this->connection); $this->assertEquals([], $this->configSource->get()); } diff --git a/app/code/Magento/Store/Test/Unit/Model/ResourceModel/StoreTest.php b/app/code/Magento/Store/Test/Unit/Model/ResourceModel/StoreTest.php index 926764b989686..b4e6c5af7c9f9 100644 --- a/app/code/Magento/Store/Test/Unit/Model/ResourceModel/StoreTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/ResourceModel/StoreTest.php @@ -131,11 +131,6 @@ public function testReadAllStores() ->method('getTableName') ->willReturn($mainTable); - $this->connectionMock->expects($this->once()) - ->method('isTableExists') - ->with($mainTable) - ->willReturn(true); - $this->connectionMock->expects($this->once()) ->method('select') ->willReturn($this->select); @@ -152,39 +147,4 @@ public function testReadAllStores() $this->assertEquals($data, $this->model->readAllStores()); } - - public function testReadAllStoresNoDbTable() - { - $mainTable = 'no_store_table'; - $data = []; - - $this->resourceMock->expects($this->once()) - ->method('getConnection') - ->willReturn($this->connectionMock); - - $this->resourceMock->expects($this->once()) - ->method('getTableName') - ->willReturn($mainTable); - - $this->connectionMock->expects($this->once()) - ->method('isTableExists') - ->with($mainTable) - ->willReturn(false); - - $this->connectionMock->expects($this->never()) - ->method('select') - ->willReturn($this->select); - - $this->select->expects($this->never()) - ->method('from') - ->with($mainTable) - ->willReturnSelf(); - - $this->connectionMock->expects($this->never()) - ->method('fetchAll') - ->with($this->select) - ->willReturn($data); - - $this->assertEquals($data, $this->model->readAllStores()); - } } diff --git a/app/code/Magento/Store/Test/Unit/Model/ResourceModel/WebsiteTest.php b/app/code/Magento/Store/Test/Unit/Model/ResourceModel/WebsiteTest.php index 5fd5aa09a46be..3238023cd6e09 100644 --- a/app/code/Magento/Store/Test/Unit/Model/ResourceModel/WebsiteTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/ResourceModel/WebsiteTest.php @@ -79,11 +79,6 @@ public function testReadAllWebsites() ->method('getConnection') ->willReturn($this->connectionMock); - $this->connectionMock->expects($this->once()) - ->method('isTableExists') - ->with($mainTable) - ->willReturn(true); - $this->connectionMock->expects($this->once()) ->method('select') ->willReturn($this->select); @@ -101,41 +96,6 @@ public function testReadAllWebsites() $this->assertEquals($data, $this->model->readAllWebsites()); } - public function testReadAllWebsitesNoDbTable() - { - $data = []; - $mainTable = 'no_store_website_table'; - - $this->resourceMock->expects($this->once()) - ->method('getTableName') - ->willReturn($mainTable); - - $this->resourceMock->expects($this->atLeastOnce()) - ->method('getConnection') - ->willReturn($this->connectionMock); - - $this->connectionMock->expects($this->once()) - ->method('isTableExists') - ->with($mainTable) - ->willReturn(false); - - $this->connectionMock->expects($this->never()) - ->method('select') - ->willReturn($this->select); - - $this->select->expects($this->never()) - ->method('from') - ->with($mainTable) - ->willReturnSelf(); - - $this->connectionMock->expects($this->never()) - ->method('fetchAll') - ->with($this->select) - ->willReturn($data); - - $this->assertEquals($data, $this->model->readAllWebsites()); - } - public function testGetDefaultStoresSelect($includeDefault = false) { $storeId = 1; diff --git a/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Db/ProfilerTest.php b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Db/ProfilerTest.php index 99305ad2d4e80..5caa94b680c88 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Db/ProfilerTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Model/ResourceModel/Db/ProfilerTest.php @@ -10,7 +10,7 @@ use Magento\Framework\Config\ConfigOptionsListConstants; /** - * Class ProfilerTest + * Test profiler on database queries */ class ProfilerTest extends \PHPUnit\Framework\TestCase { @@ -140,7 +140,7 @@ public function testProfilerDuringSqlException() try { $connection->select()->from('unknown_table')->query()->fetch(); - } catch (\Zend_Db_Statement_Exception $exception) { + } catch (\Magento\Framework\DB\Adapter\TableNotFoundException $exception) { $this->assertNotEmpty($exception); } diff --git a/dev/tests/integration/testsuite/Magento/Setup/Module/DataSetupTest.php b/dev/tests/integration/testsuite/Magento/Setup/Module/DataSetupTest.php index 425840b44ba0e..4c35d9882a0ac 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Module/DataSetupTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Module/DataSetupTest.php @@ -39,7 +39,7 @@ public function testUpdateTableRow() } /** - * @expectedException \Zend_Db_Statement_Exception + * @expectedException \Magento\Framework\DB\Adapter\TableNotFoundException */ public function testDeleteTableRow() { @@ -47,8 +47,7 @@ public function testDeleteTableRow() } /** - * @covers \Magento\Setup\Module\DataSetup::updateTableRow - * @expectedException \Zend_Db_Statement_Exception + * @expectedException \Magento\Framework\DB\Adapter\TableNotFoundException */ public function testUpdateTableRowNameConversion() { diff --git a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php index ec2731c667ee6..80d8808ab1768 100644 --- a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php +++ b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php @@ -13,6 +13,7 @@ use Magento\Framework\DB\Adapter\DeadlockException; use Magento\Framework\DB\Adapter\DuplicateException; use Magento\Framework\DB\Adapter\LockWaitException; +use Magento\Framework\DB\Adapter\TableNotFoundException; use Magento\Framework\DB\Ddl\Table; use Magento\Framework\DB\ExpressionConverter; use Magento\Framework\DB\LoggerInterface; @@ -38,6 +39,7 @@ * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @since 100.0.2 */ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface { @@ -257,6 +259,8 @@ public function __construct( 1213 => DeadlockException::class, // SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 1062 => DuplicateException::class, + // SQLSTATE[42S02]: Base table or view not found: 1146 + 1146 => TableNotFoundException::class, ]; try { parent::__construct($config); @@ -687,7 +691,8 @@ public function proccessBindCallback($matches) if (isset($matches[6]) && ( strpos($matches[6], "'") !== false || strpos($matches[6], ':') !== false || - strpos($matches[6], '?') !== false) + strpos($matches[6], '?') !== false + ) ) { $bindName = ':_mage_bind_var_' . (++$this->_bindIncrement); $this->_bindParams[$bindName] = $this->_unQuote($matches[6]); @@ -1822,7 +1827,7 @@ public function modifyColumnByDdl($tableName, $columnName, $definition, $flushDa * Retrieve column data type by data from describe table * * @param array $column - * @return string + * @return string|null * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function _getColumnTypeByDdl($column) @@ -1862,6 +1867,7 @@ protected function _getColumnTypeByDdl($column) case 'numeric': return Table::TYPE_DECIMAL; } + return null; } /** @@ -4020,6 +4026,7 @@ public function getAutoIncrementField($tableName, $schemaName = null) * Required to listen all DDL changes done by 3-rd party modules with old Install/UpgradeSchema scripts. * * @return SchemaListener + * @since 102.0.0 */ public function getSchemaListener() { @@ -4031,6 +4038,8 @@ public function getSchemaListener() /** * Closes the connection. + * + * @since 102.0.4 */ public function closeConnection() { diff --git a/lib/internal/Magento/Framework/DB/Adapter/TableNotFoundException.php b/lib/internal/Magento/Framework/DB/Adapter/TableNotFoundException.php new file mode 100644 index 0000000000000..7fded1fa01e91 --- /dev/null +++ b/lib/internal/Magento/Framework/DB/Adapter/TableNotFoundException.php @@ -0,0 +1,15 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Framework\DB\Adapter; + +/** + * Database base table or view not found exception + */ +class TableNotFoundException extends \Zend_Db_Adapter_Exception +{ +} From 86506a3da0f539b315954048c2ad5d1d9a1afb12 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Wed, 8 Apr 2020 11:15:00 +0100 Subject: [PATCH 092/177] magento/magento2#27536: Added ExtractAssetsFromContentTest --- .../Model/Content/Config/Converter.php | 12 +-- .../Model/Content/Config/Reader.php | 68 --------------- app/code/Magento/MediaContent/etc/di.xml | 7 +- .../MediaContentCatalog/etc/media_content.xml | 2 +- .../MediaContentCms/etc/media_content.xml | 2 +- .../Model/AssignGetUnassignTest.php | 26 +++--- .../Model/ExtractAssetsFromContentTest.php | 85 +++++++++++++++++++ .../MediaContent/_files/media_asset.php | 28 ++++++ .../_files/media_asset_rollback.php | 27 ++++++ 9 files changed, 168 insertions(+), 89 deletions(-) delete mode 100644 app/code/Magento/MediaContent/Model/Content/Config/Reader.php create mode 100644 dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php create mode 100644 dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset.php create mode 100644 dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset_rollback.php diff --git a/app/code/Magento/MediaContent/Model/Content/Config/Converter.php b/app/code/Magento/MediaContent/Model/Content/Config/Converter.php index 76c98d2df35a9..353942d8f5c6d 100644 --- a/app/code/Magento/MediaContent/Model/Content/Config/Converter.php +++ b/app/code/Magento/MediaContent/Model/Content/Config/Converter.php @@ -15,9 +15,9 @@ class Converter implements ConverterInterface { /** - * Blacklist tag name + * Search tag name */ - private const BLACKLIST_TAG_NAME = 'search'; + private const SEARCH_TAG_NAME = 'search'; /** * Patterns tag name @@ -43,12 +43,12 @@ public function convert($source) : array return $result; } - foreach ($source->getElementsByTagName(self::BLACKLIST_TAG_NAME) as $blacklist) { - $result[self::BLACKLIST_TAG_NAME] = []; + foreach ($source->getElementsByTagName(self::SEARCH_TAG_NAME) as $blacklist) { + $result[self::SEARCH_TAG_NAME] = []; foreach ($blacklist->getElementsByTagName(self::PATTERNS_TAG_NAME) as $patterns) { - $result[self::BLACKLIST_TAG_NAME][self::PATTERNS_TAG_NAME] = []; + $result[self::SEARCH_TAG_NAME][self::PATTERNS_TAG_NAME] = []; foreach ($patterns->getElementsByTagName(self::PATTERN_TAG_NAME) as $pattern) { - $result[self::BLACKLIST_TAG_NAME][self::PATTERNS_TAG_NAME] + $result[self::SEARCH_TAG_NAME][self::PATTERNS_TAG_NAME] [$pattern->attributes->getNamedItem('name')->nodeValue] = $pattern->nodeValue; } } diff --git a/app/code/Magento/MediaContent/Model/Content/Config/Reader.php b/app/code/Magento/MediaContent/Model/Content/Config/Reader.php deleted file mode 100644 index 61c153652a388..0000000000000 --- a/app/code/Magento/MediaContent/Model/Content/Config/Reader.php +++ /dev/null @@ -1,68 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaContent\Model\Content\Config; - -use Magento\Framework\App\Area; -use Magento\Framework\Config\Dom; -use Magento\Framework\Config\FileResolverInterface; -use Magento\Framework\Config\Reader\Filesystem; -use Magento\Framework\Config\ReaderInterface; -use Magento\Framework\Config\ValidationStateInterface; - -/** - * Media content config reader - */ -class Reader extends Filesystem implements ReaderInterface -{ - /** - * List of id attributes for merge - * - * @var array - */ - protected $_idAttributes = [ - '/config/patterns' => 'patterns', - '/config/patterns/pattern' => 'name', - ]; - - /** - * XML Configuration file name - */ - private const XML_FILE_NAME = 'media_content.xml'; - - /** - * @param FileResolverInterface $fileResolver - * @param Converter $converter - * @param SchemaLocator $schemaLocator - * @param ValidationStateInterface $validationState - * @param string $fileName - * @param array $idAttributes - * @param string $domDocumentClass - * @param string $defaultScope - */ - public function __construct( - FileResolverInterface $fileResolver, - Converter $converter, - SchemaLocator $schemaLocator, - ValidationStateInterface $validationState, - $fileName = self::XML_FILE_NAME, - $idAttributes = [], - $domDocumentClass = Dom::class, - $defaultScope = Area::AREA_GLOBAL - ) { - parent::__construct( - $fileResolver, - $converter, - $schemaLocator, - $validationState, - $fileName, - $idAttributes, - $domDocumentClass, - $defaultScope - ); - } -} diff --git a/app/code/Magento/MediaContent/etc/di.xml b/app/code/Magento/MediaContent/etc/di.xml index a5e0ec876a801..578bed7588699 100644 --- a/app/code/Magento/MediaContent/etc/di.xml +++ b/app/code/Magento/MediaContent/etc/di.xml @@ -19,13 +19,16 @@ <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByDirectoryPathInterface"> <plugin name="remove_media_content_after_asset_is_removed_by_directory_path" type="Magento\MediaContent\Model\Plugin\MediaGalleryAssetDeleteByDirectoryPath" /> </type> - <type name="Magento\MediaContent\Model\Content\Config\Reader"> + <virtualType name="Magento\MediaContent\Model\Content\Config\Reader" type="Magento\Framework\Config\Reader\Filesystem"> <arguments> <argument name="fileName" xsi:type="string">media_content.xml</argument> <argument name="converter" xsi:type="object">Magento\MediaContent\Model\Content\Config\Converter</argument> <argument name="schemaLocator" xsi:type="object">Magento\MediaContent\Model\Content\Config\SchemaLocator</argument> + <argument name="idAttributes" xsi:type="array"> + <item name="/config/search/patterns/pattern" xsi:type="string">name</item> + </argument> </arguments> - </type> + </virtualType> <virtualType name="Magento\MediaContent\Model\Content\Config\Data" type="Magento\Framework\Config\Data"> <arguments> <argument name="reader" xsi:type="object">Magento\MediaContent\Model\Content\Config\Reader</argument> diff --git a/app/code/Magento/MediaContentCatalog/etc/media_content.xml b/app/code/Magento/MediaContentCatalog/etc/media_content.xml index 0f5d800ed5684..e3f169d49fa3b 100644 --- a/app/code/Magento/MediaContentCatalog/etc/media_content.xml +++ b/app/code/Magento/MediaContentCatalog/etc/media_content.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_MediaGallery:etc/directory.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_MediaContent:etc/media_content.xsd"> <search> <patterns> <pattern name="catalog_image">/^\/?media\/(.*)/</pattern> diff --git a/app/code/Magento/MediaContentCms/etc/media_content.xml b/app/code/Magento/MediaContentCms/etc/media_content.xml index e0e80f65738f9..1fa175d51e9e3 100644 --- a/app/code/Magento/MediaContentCms/etc/media_content.xml +++ b/app/code/Magento/MediaContentCms/etc/media_content.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_MediaGallery:etc/directory.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_MediaContent:etc/media_content.xsd"> <search> <patterns> <pattern name="media_gallery">/{{media url="?(.*?)"?}}/</pattern> diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php index 01911284447dd..5ea2adc284b83 100644 --- a/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php @@ -44,7 +44,7 @@ class AssignGetUnassignTest extends TestCase /** * @inheritdoc */ - public function setUp() + public function setUp(): void { $this->assign = Bootstrap::getObjectManager()->create(AssignAssetsInterface::class); $this->getAssetIds = Bootstrap::getObjectManager()->create(GetAssetIdsUsedInContentInterface::class); @@ -55,34 +55,38 @@ public function setUp() /** * Assing assets to content, retrieve the data, then unassign assets from content */ - public function testAssignRetrieveAndUnassign() + public function testAssignRetrieveAndUnassign(): void { + $entityType = 'catalog_product'; + $entityId = '42'; + $field = 'description'; + $assetIds = [56, 78]; + $contentIdentity = Bootstrap::getObjectManager()->create( ContentIdentityInterface::class, [ 'data' => [ - 'entity_type' => 'catalog_product', - 'entity_id' => '42', - 'field' => 'description' + 'entity_type' => $entityType, + 'entity_id' => $entityId, + 'field' => $field ] ] ); - $assetIds = [56, 78]; $this->assign->execute($contentIdentity, $assetIds); $retrievedAssetIds = $this->getAssetIds->execute($contentIdentity); $this->assertEquals($assetIds, $retrievedAssetIds); - $retrievedContentIdentities = $this->getContent->execute($assetIds); $this->assertEquals(count($retrievedContentIdentities), 1); - $identity = $retrievedContentIdentities[0]; - $this->assertEquals('catalog_product', $identity->getEntityType()); - $this->assertEquals('42', $identity->getEntityId()); - $this->assertEquals('description', $identity->getField()); + foreach ($retrievedContentIdentities as $identity) { + $this->assertEquals($entityType, $identity->getEntityType()); + $this->assertEquals($entityId, $identity->getEntityId()); + $this->assertEquals($field, $identity->getField()); + } $this->unassign->execute($contentIdentity, $assetIds); diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php new file mode 100644 index 0000000000000..561230d636f37 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php @@ -0,0 +1,85 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + * + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\MediaContentApi\Api\ExtractAssetsFromContentInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Test for ExtractAssetsFromContent + */ +class ExtractAssetsFromContentTest extends TestCase +{ + /** + * @var ExtractAssetsFromContentInterface + */ + private $service; + + /** + * @inheritdoc + */ + public function setUp(): void + { + $this->service = Bootstrap::getObjectManager()->create(ExtractAssetsFromContentInterface::class); + } + + /** + * Assing assets to content, retrieve the data, then unassign assets from content + * + * @magentoDataFixture Magento/MediaContent/_files/media_asset.php + * + * @dataProvider contentProvider + * @param string $content + * @param array $assetIds + */ + public function testExecute(string $content, array $assetIds): void + { + $assets = $this->service->execute($content); + + $extractedAssetIds = []; + foreach ($assets as $asset) { + $extractedAssetIds[] = $asset->getId(); + } + + sort($assetIds); + sort($extractedAssetIds); + + $this->assertEquals($assetIds, $extractedAssetIds); + } + + /** + * Data provider for testExecute + * + * @return array + */ + public function contentProvider() + { + return [ + 'Empty Content' => [ + '', + [] + ], + 'No paths in content' => [ + 'content without paths', + [] + ], + 'Relevant paths in content' => [ + 'content {{media url="testDirectory/path.jpg"}} content', + [ + 55 + ] + ], + 'Irrelevant paths in content' => [ + 'content {{media url="media/non-existing-path.png"}} content', + [] + ], + ]; + } +} diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset.php b/dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset.php new file mode 100644 index 0000000000000..59b00c289b03c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset.php @@ -0,0 +1,28 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +use Magento\MediaGalleryApi\Api\Data\AssetInterface; +use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory; +use Magento\MediaGalleryApi\Model\Asset\Command\SaveInterface; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +/** @var AssetInterfaceFactory $mediaAssetFactory */ +$mediaAssetFactory = $objectManager->get(AssetInterfaceFactory::class); +/** @var AssetInterface $mediaAsset */ +$mediaAsset = $mediaAssetFactory->create( + [ + 'data' => [ + 'id' => 55, + 'path' => '/testDirectory/path.jpg' + ] + ] +); +/** @var SaveInterface $saveAsset */ +$saveAsset = $objectManager->get(SaveInterface::class); +$mediaId = $saveAsset->execute($mediaAsset); \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset_rollback.php b/dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset_rollback.php new file mode 100644 index 0000000000000..b4c68a4aec58e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset_rollback.php @@ -0,0 +1,27 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\AdobeStockAssetApi\Model\Asset\Command\DeleteByIdInterface; +use Magento\MediaGalleryApi\Api\Data\AssetInterface; +use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +/** @var AssetInterfaceFactory $mediaAssetFactory */ +$mediaAssetFactory = $objectManager->get(AssetInterfaceFactory::class); +/** @var AssetInterface $mediaAsset */ +$mediaAsset = $mediaAssetFactory->create( + [ + 'data' => [ + 'id' => 55, + 'path' => 'testDirectory/path.jpg' + ] + ] +); +/** @var DeleteByIdInterface $deleteMediaAsset */ +$deleteMediaAsset = $objectManager->get(DeleteByIdInterface::class); +$deleteMediaAsset->execute(55); \ No newline at end of file From 1d9317d2ae415ed90b9fc587183016df32b57b05 Mon Sep 17 00:00:00 2001 From: Nikita Shcherbatykh <nikita.shcherbatykh@transoftgroup.com> Date: Wed, 8 Apr 2020 13:15:52 +0300 Subject: [PATCH 093/177] MC-32547: Error when adding product as button link in Pagebuilder --- .../base/web/js/form/element/ui-select.js | 2 + .../Magento/Ui/base/js/form/ui-select.test.js | 51 ++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/ui-select.js b/app/code/Magento/Ui/view/base/web/js/form/element/ui-select.js index 5667ce5d71d81..b488a4b2f8c16 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/ui-select.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/ui-select.js @@ -1160,6 +1160,7 @@ define([ if (this.isSearchKeyCached(searchKey)) { cachedSearchResult = this.getCachedSearchResults(searchKey); + this.cacheOptions.plain = cachedSearchResult.options; this.options(cachedSearchResult.options); this.afterLoadOptions(searchKey, cachedSearchResult.lastPage, cachedSearchResult.total); @@ -1274,6 +1275,7 @@ define([ }); this.total = response.total; + this.cacheOptions.plain = existingOptions; this.options(existingOptions); }, diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/ui-select.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/ui-select.test.js index ac6e230e7ed1c..f46ff6b30abbe 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/ui-select.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/ui-select.test.js @@ -624,6 +624,24 @@ define([ expect(obj.options).toHaveBeenCalledWith([]); expect(obj.processRequest).toHaveBeenCalledWith(searchKey, 1); }); + it('Should update cacheOptions if response was cached', function () { + var searchKey = 'cake', + searchResult = 'piece a cake'; + + obj.deviation = 30; + obj.cachedSearchResults = { + cake: { + options: [searchResult], + lastPage: 1, + total: 1 + } + }; + + spyOn(obj, 'options'); + obj.loadOptions(searchKey); + expect(obj.options).toHaveBeenCalledWith([searchResult]); + expect(obj.cacheOptions.plain).toContain(searchResult); + }); }); describe('"isSearchKeyCached" method', function () { it('Should return false if searchKey has already been cached and total covers > 1 page', function () { @@ -672,7 +690,7 @@ define([ }); }); describe('"processRequest" method', function () { - it('Should store options successfully fetched from ajax request', function () { + it('Should store options and update cache successfully after fetched from ajax request', function () { var ajaxRequest, successfulAjaxResponse = { options: { @@ -686,6 +704,24 @@ define([ } }; + // place a number of options to cache prior fetch + obj.cacheOptions.plain = [{ + '2053': { + value: '2057', + label: 'testProductName5a8ddfd933b5c', + 'is_active': 1, + path: 'testSku5a8ddfd933b5c', + optgroup: false + }, + '2054': { + value: '2058', + label: 'testProductName5a8ddfd933b5c', + 'is_active': 1, + path: 'testSku5a8ddfd933b5c', + optgroup: false + } + }]; + $.ajax = jasmine.createSpy().and.callFake(function (request) { ajaxRequest = request.success.bind(obj); }); @@ -693,7 +729,18 @@ define([ expect(obj.processRequest()).toBeUndefined(); ajaxRequest(successfulAjaxResponse); - expect(JSON.stringify(obj.options())).toEqual(JSON.stringify([successfulAjaxResponse.options['2053']])); + + expect( + JSON.stringify(obj.options()) + ).toEqual( + JSON.stringify([successfulAjaxResponse.options['2053']]) + ); + + expect( + JSON.stringify(obj.cacheOptions.plain) + ).toEqual( + JSON.stringify([successfulAjaxResponse.options['2053']]) + ); }); }); }); From 93ce4b5300713200dc53db08c03dcc67d544d443 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Wed, 8 Apr 2020 11:32:32 +0100 Subject: [PATCH 094/177] magento/magento2#27536: Added UpdateRelationsTest --- .../MediaContent/Model/UpdateRelations.php | 2 +- .../Model/ExtractAssetsFromContentTest.php | 8 +- .../Model/UpdateRelationsTest.php | 74 +++++++++++++++++++ .../_files/media_asset_rollback.php | 27 ------- .../_files/media_asset.php | 2 +- .../_files/media_asset_rollback.php | 14 ++++ 6 files changed, 97 insertions(+), 30 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php delete mode 100644 dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset_rollback.php rename dev/tests/integration/testsuite/Magento/{MediaContent => MediaGallery}/_files/media_asset.php (94%) create mode 100644 dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php diff --git a/app/code/Magento/MediaContent/Model/UpdateRelations.php b/app/code/Magento/MediaContent/Model/UpdateRelations.php index c3ae928ead364..81a0767729786 100644 --- a/app/code/Magento/MediaContent/Model/UpdateRelations.php +++ b/app/code/Magento/MediaContent/Model/UpdateRelations.php @@ -58,7 +58,7 @@ class UpdateRelations implements UpdateRelationsInterface */ public function __construct( ExtractAssetsFromContentInterface $extractAssetFromContent, - UnassignAssetsInterface $assignAsset, + AssignAssetsInterface $assignAsset, GetAssetIdsUsedInContentInterface $getAssetsUsedInContent, UnassignAssetsInterface $unassignAsset, LoggerInterface $logger diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php index 561230d636f37..6560b5a8b2036 100644 --- a/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php @@ -33,7 +33,7 @@ public function setUp(): void /** * Assing assets to content, retrieve the data, then unassign assets from content * - * @magentoDataFixture Magento/MediaContent/_files/media_asset.php + * @magentoDataFixture Magento/MediaGallery/_files/media_asset.php * * @dataProvider contentProvider * @param string $content @@ -76,6 +76,12 @@ public function contentProvider() 55 ] ], + 'Relevant path content' => [ + '/media/testDirectory/path.jpg', + [ + 55 + ] + ], 'Irrelevant paths in content' => [ 'content {{media url="media/non-existing-path.png"}} content', [] diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php new file mode 100644 index 0000000000000..aa2b81a5ae3d9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php @@ -0,0 +1,74 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + * + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; +use Magento\MediaContentApi\Api\GetAssetIdsUsedInContentInterface; +use Magento\MediaContentApi\Api\UpdateRelationsInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Test for ExtractAssetsFromContent + */ +class UpdateRelationsTest extends TestCase +{ + /** + * @var UpdateRelationsInterface + */ + private $service; + + /** + * @var GetAssetIdsUsedInContentInterface + */ + private $getAssetIds; + + /** + * @inheritdoc + */ + public function setUp(): void + { + $this->service = Bootstrap::getObjectManager()->create(UpdateRelationsInterface::class); + $this->getAssetIds = Bootstrap::getObjectManager()->create(GetAssetIdsUsedInContentInterface::class); + } + + /** + * Assing assets to content, retrieve the data, then unassign assets from content + * + * @magentoDataFixture Magento/MediaGallery/_files/media_asset.php + */ + public function testExecute(): void + { + $entityType = 'catalog_product'; + $entityId = '42'; + $field = 'description'; + $contentWithoutAsset = ''; + $contentWithAsset = 'content {{media url="testDirectory/path.jpg"}} content'; + + $contentIdentity = Bootstrap::getObjectManager()->create( + ContentIdentityInterface::class, + [ + 'data' => [ + 'entity_type' => $entityType, + 'entity_id' => $entityId, + 'field' => $field + ] + ] + ); + + $this->service->execute($contentIdentity, $contentWithoutAsset); + $this->assertEmpty($this->getAssetIds->execute($contentIdentity)); + + $this->service->execute($contentIdentity, $contentWithAsset); + $this->assertNotEmpty($this->getAssetIds->execute($contentIdentity)); + + $this->service->execute($contentIdentity, $contentWithoutAsset); + $this->assertEmpty($this->getAssetIds->execute($contentIdentity)); + } +} diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset_rollback.php b/dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset_rollback.php deleted file mode 100644 index b4c68a4aec58e..0000000000000 --- a/dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset_rollback.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -use Magento\AdobeStockAssetApi\Model\Asset\Command\DeleteByIdInterface; -use Magento\MediaGalleryApi\Api\Data\AssetInterface; -use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory; -use Magento\TestFramework\Helper\Bootstrap; - -$objectManager = Bootstrap::getObjectManager(); -/** @var AssetInterfaceFactory $mediaAssetFactory */ -$mediaAssetFactory = $objectManager->get(AssetInterfaceFactory::class); -/** @var AssetInterface $mediaAsset */ -$mediaAsset = $mediaAssetFactory->create( - [ - 'data' => [ - 'id' => 55, - 'path' => 'testDirectory/path.jpg' - ] - ] -); -/** @var DeleteByIdInterface $deleteMediaAsset */ -$deleteMediaAsset = $objectManager->get(DeleteByIdInterface::class); -$deleteMediaAsset->execute(55); \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset.php b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php similarity index 94% rename from dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset.php rename to dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php index 59b00c289b03c..b078734fc82d6 100644 --- a/dev/tests/integration/testsuite/Magento/MediaContent/_files/media_asset.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php @@ -25,4 +25,4 @@ ); /** @var SaveInterface $saveAsset */ $saveAsset = $objectManager->get(SaveInterface::class); -$mediaId = $saveAsset->execute($mediaAsset); \ No newline at end of file +$saveAsset->execute($mediaAsset); \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php new file mode 100644 index 0000000000000..daa186f462418 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php @@ -0,0 +1,14 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\AdobeStockAssetApi\Model\Asset\Command\DeleteByIdInterface; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +/** @var DeleteByIdInterface $deleteMediaAsset */ +$deleteMediaAsset = $objectManager->get(DeleteByIdInterface::class); +$deleteMediaAsset->execute(55); \ No newline at end of file From 1ab7fca520ee97a02122c079cf87ae034f30cb30 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Wed, 8 Apr 2020 11:47:15 +0100 Subject: [PATCH 095/177] magento/magento2#27536: Moved xsd to api module, removed unit tests, updated comments --- .../MediaContent/Model/AssignAssets.php | 3 +- .../MediaContent/Model/Content/Config.php | 2 +- .../Model/Content/Config/Converter.php | 19 +- .../Model/Content/Config/SchemaLocator.php | 8 +- .../Model/ExtractAssetsFromContent.php | 22 +- .../Model/GetContentWithAssets.php | 2 +- .../MediaContent/Model/UnassignAssets.php | 5 +- .../MediaContent/Model/UpdateRelations.php | 7 +- .../Test/Unit/Model/AssignAssetsTest.php | 203 ------------------ .../Unit/Model/GetAssetsusedInContentTest.php | 154 ------------- .../Unit/Model/GetContentWithAssetsTest.php | 118 ---------- .../Test/Unit/Model/UnassignAssetTest.php | 199 ----------------- .../etc/media_content.xsd | 0 .../MediaContentCatalog/etc/media_content.xml | 2 +- .../MediaContentCms/etc/media_content.xml | 2 +- 15 files changed, 36 insertions(+), 710 deletions(-) delete mode 100644 app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetsTest.php delete mode 100644 app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php delete mode 100644 app/code/Magento/MediaContent/Test/Unit/Model/GetContentWithAssetsTest.php delete mode 100644 app/code/Magento/MediaContent/Test/Unit/Model/UnassignAssetTest.php rename app/code/Magento/{MediaContent => MediaContentApi}/etc/media_content.xsd (100%) diff --git a/app/code/Magento/MediaContent/Model/AssignAssets.php b/app/code/Magento/MediaContent/Model/AssignAssets.php index a84edad563a78..bb26f2f66e3f7 100644 --- a/app/code/Magento/MediaContent/Model/AssignAssets.php +++ b/app/code/Magento/MediaContent/Model/AssignAssets.php @@ -65,7 +65,8 @@ public function execute(ContentIdentityInterface $contentIdentity, array $assetI } catch (\Exception $exception) { $this->logger->critical($exception); throw new CouldNotSaveException( - __('An error occurred while saving relation between media asset and media content.') + __('An error occurred while saving relation between media asset and media content.'), + $exception ); } } diff --git a/app/code/Magento/MediaContent/Model/Content/Config.php b/app/code/Magento/MediaContent/Model/Content/Config.php index 87be885977f38..e2f9f58289d31 100644 --- a/app/code/Magento/MediaContent/Model/Content/Config.php +++ b/app/code/Magento/MediaContent/Model/Content/Config.php @@ -10,7 +10,7 @@ use Magento\Framework\Config\DataInterface; /** - * Media content config + * Media content configuration */ class Config { diff --git a/app/code/Magento/MediaContent/Model/Content/Config/Converter.php b/app/code/Magento/MediaContent/Model/Content/Config/Converter.php index 353942d8f5c6d..16658d0299b05 100644 --- a/app/code/Magento/MediaContent/Model/Content/Config/Converter.php +++ b/app/code/Magento/MediaContent/Model/Content/Config/Converter.php @@ -10,23 +10,12 @@ use Magento\Framework\Config\ConverterInterface; /** - * Class Converter + * Media Content configuration Converter */ class Converter implements ConverterInterface { - /** - * Search tag name - */ private const SEARCH_TAG_NAME = 'search'; - - /** - * Patterns tag name - */ private const PATTERNS_TAG_NAME = 'patterns'; - - /** - * Pattern tag name - */ private const PATTERN_TAG_NAME = 'pattern'; /** @@ -43,9 +32,9 @@ public function convert($source) : array return $result; } - foreach ($source->getElementsByTagName(self::SEARCH_TAG_NAME) as $blacklist) { + foreach ($source->getElementsByTagName(self::SEARCH_TAG_NAME) as $search) { $result[self::SEARCH_TAG_NAME] = []; - foreach ($blacklist->getElementsByTagName(self::PATTERNS_TAG_NAME) as $patterns) { + foreach ($search->getElementsByTagName(self::PATTERNS_TAG_NAME) as $patterns) { $result[self::SEARCH_TAG_NAME][self::PATTERNS_TAG_NAME] = []; foreach ($patterns->getElementsByTagName(self::PATTERN_TAG_NAME) as $pattern) { $result[self::SEARCH_TAG_NAME][self::PATTERNS_TAG_NAME] @@ -56,4 +45,4 @@ public function convert($source) : array return $result; } -} \ No newline at end of file +} diff --git a/app/code/Magento/MediaContent/Model/Content/Config/SchemaLocator.php b/app/code/Magento/MediaContent/Model/Content/Config/SchemaLocator.php index 863db23a52331..76a13b213ce8e 100644 --- a/app/code/Magento/MediaContent/Model/Content/Config/SchemaLocator.php +++ b/app/code/Magento/MediaContent/Model/Content/Config/SchemaLocator.php @@ -11,6 +11,9 @@ use Magento\Framework\Module\Dir; use Magento\Framework\Module\Dir\Reader; +/** + * Media Content configuration schema locator + */ class SchemaLocator implements SchemaLocatorInterface { /** @@ -25,7 +28,8 @@ class SchemaLocator implements SchemaLocatorInterface */ public function __construct(Reader $moduleReader) { - $this->schema = $moduleReader->getModuleDir(Dir::MODULE_ETC_DIR, 'Magento_MediaContent') . '/media_content.xsd'; + $this->schema = $moduleReader->getModuleDir(Dir::MODULE_ETC_DIR, 'Magento_MediaContentApi') + . '/media_content.xsd'; } /** @@ -47,4 +51,4 @@ public function getPerFileSchema() { return $this->schema; } -} \ No newline at end of file +} diff --git a/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php b/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php index dcc6de03badac..4e1e559c39a9d 100644 --- a/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php +++ b/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php @@ -18,6 +18,8 @@ */ class ExtractAssetsFromContent implements ExtractAssetsFromContentInterface { + private const XML_PATH_SEARCH_PATTERNS = 'search/patterns'; + /** * @var Config */ @@ -49,16 +51,13 @@ public function __construct( } /** - * Search for the media asset in content and extract it providing a list of media assets. - * - * @param string $content - * @return AssetInterface[] + * @inheritdoc */ public function execute(string $content): array { $paths = []; - foreach ($this->config->get('search/patterns') as $pattern) { + foreach ($this->config->get(self::XML_PATH_SEARCH_PATTERNS) as $pattern) { if (empty($pattern)) { continue; } @@ -86,7 +85,7 @@ private function getAssetsByPaths(array $paths): array foreach ($paths as $path) { try { /** @var AssetInterface $asset */ - $asset = $this->getMediaAssetByPath->execute('/' . $path); + $asset = $this->getMediaAssetByPath->execute($this->getPathStartingWithSlash($path)); $assets[$asset->getId()] = $asset; } catch (\Exception $exception) { $this->logger->critical($exception); @@ -95,4 +94,15 @@ private function getAssetsByPaths(array $paths): array return $assets; } + + /** + * Ensure the extracted paths matches the standard format + * + * @param string $path + * @return string + */ + private function getPathStartingWithSlash(string $path): string + { + return '/' . ltrim($path, '/'); + } } diff --git a/app/code/Magento/MediaContent/Model/GetContentWithAssets.php b/app/code/Magento/MediaContent/Model/GetContentWithAssets.php index adb38da4d04b0..12cba0d141fc8 100644 --- a/app/code/Magento/MediaContent/Model/GetContentWithAssets.php +++ b/app/code/Magento/MediaContent/Model/GetContentWithAssets.php @@ -55,7 +55,7 @@ public function __construct( } /** - * @inheritDoc + * @inheritdoc */ public function execute(array $assetIds): array { diff --git a/app/code/Magento/MediaContent/Model/UnassignAssets.php b/app/code/Magento/MediaContent/Model/UnassignAssets.php index 0a2f952760e55..d553b2d0a7258 100644 --- a/app/code/Magento/MediaContent/Model/UnassignAssets.php +++ b/app/code/Magento/MediaContent/Model/UnassignAssets.php @@ -35,8 +35,6 @@ class UnassignAssets implements UnassignAssetsInterface private $logger; /** - * GetAssetsUsedInContent constructor. - * * @param ResourceConnection $resourceConnection * @param LoggerInterface $logger */ @@ -66,7 +64,8 @@ public function execute(ContentIdentityInterface $contentIdentity, array $assetI } catch (\Exception $exception) { $this->logger->critical($exception); throw new CouldNotDeleteException( - __('An error occurred at unassign relation between the media asset and media content.') + __('An error occurred at unassign relation between the media asset and media content.'), + $exception ); } } diff --git a/app/code/Magento/MediaContent/Model/UpdateRelations.php b/app/code/Magento/MediaContent/Model/UpdateRelations.php index 81a0767729786..d878f10e47e42 100644 --- a/app/code/Magento/MediaContent/Model/UpdateRelations.php +++ b/app/code/Magento/MediaContent/Model/UpdateRelations.php @@ -71,10 +71,7 @@ public function __construct( } /** - * Create new relation between media asset and content or updated existing - * - * @param ContentIdentityInterface $contentIdentity - * @param string $data + * @inheritdoc */ public function execute(ContentIdentityInterface $contentIdentity, string $data): void { @@ -86,7 +83,7 @@ public function execute(ContentIdentityInterface $contentIdentity, string $data) } /** - * Records a relation for the newly added asset + * Find out which relations are obsolete and which are new and update them * * @param ContentIdentityInterface $contentIdentity * @param string $data diff --git a/app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetsTest.php b/app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetsTest.php deleted file mode 100644 index c79cb36be27bd..0000000000000 --- a/app/code/Magento/MediaContent/Test/Unit/Model/AssignAssetsTest.php +++ /dev/null @@ -1,203 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaContent\Test\Unit\Model; - -use Magento\Framework\App\ResourceConnection; -use Magento\Framework\DB\Adapter\AdapterInterface; -use Magento\Framework\DB\Adapter\Pdo\Mysql; -use Magento\Framework\Exception\CouldNotSaveException; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\MediaContent\Model\AssignAssets; -use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; -use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; -use Psr\Log\LoggerInterface; - -/** - * Tests for the AssignAsset command. - */ -class AssignAssetsTest extends TestCase -{ - /** - * Media content relation data storage table name - */ - private const TABLE_MEDIA_CONTENT_ASSET = 'media_content_asset'; - - /** - * Prefixed media content relation data storage table name - */ - private const PREFIXED_TABLE_MEDIA_CONTENT_ASSET = 'prefix_' . self::TABLE_MEDIA_CONTENT_ASSET; - - /** - * Media asset id - */ - private const ASSET_ID = 'asset_id'; - - /** - * Media content type - */ - private const ENTITY_TYPE = 'entity_type'; - - /** - * Media entity id - */ - private const ENTITY_ID = 'entity_id'; - - /** - * Media content field where media asset is used - */ - private const FIELD = 'field'; - - /** - * Constant for affected rows count after data insertion - */ - private const AFFECTED_ROWS = 1; - - /** - * @var ResourceConnection | MockObject - */ - private $resourceConnectionMock; - - /** - * @var AdapterInterface | MockObject - */ - private $adapterMock; - - /** - * @var LoggerInterface | MockObject - */ - private $loggerMock; - - /** - * @var AssignAssets - */ - private $assignAsset; - - /** - * Set up test mocks - */ - protected function setUp(): void - { - $this->adapterMock = $this->createMock(Mysql::class); - $this->loggerMock = $this->createMock(LoggerInterface::class); - $this->resourceConnectionMock = $this->createConfiguredMock( - ResourceConnection::class, - [ - 'getConnection' => $this->adapterMock, - 'getTableName' => self::PREFIXED_TABLE_MEDIA_CONTENT_ASSET - ] - ); - - $this->assignAsset = (new ObjectManager($this))->getObject( - AssignAssets::class, - [ - 'resourceConnection' => $this->resourceConnectionMock, - 'logger' => $this->loggerMock - ] - ); - } - - /** - * Tests successful scenario for saving relation between media asset and media content. - * - * @param int $assetId - * @param string $contentType - * @param string $contentEntityId - * @param string $contentField - * @dataProvider assignAssetDataProvider - * @return void - */ - public function testSuccessfulExecute( - int $assetId, - string $contentType, - string $contentEntityId, - string $contentField - ): void { - $saveData = [ - self::ASSET_ID => $assetId, - self::ENTITY_TYPE => $contentType, - self::ENTITY_ID => $contentEntityId, - self::FIELD => $contentField - ]; - $this->adapterMock - ->expects(self::once()) - ->method('insertMultiple') - ->with(self::PREFIXED_TABLE_MEDIA_CONTENT_ASSET, [$saveData]) - ->willReturn(self::AFFECTED_ROWS); - - $this->assignAsset->execute( - $this->getContentIdentity($contentType, $contentField, $contentEntityId), - [ - $assetId - ] - ); - } - - /** - * Tests with exception scenario for saving relation between media asset and media content. - */ - public function testExceptionExecute(): void { - $this->resourceConnectionMock->method('getConnection') - ->willThrowException((new \Exception())); - - $this->loggerMock - ->expects(self::once()) - ->method('critical') - ->willReturnSelf(); - - $this->expectException(CouldNotSaveException::class); - $this->assignAsset->execute( - $this->createMock(ContentIdentityInterface::class), - [ - '42' - ] - ); - } - - /** - * Get content identity mock - * - * @param string $type - * @param string $field - * @param string $id - * @return MockObject|ContentIdentityInterface - */ - private function getContentIdentity(string $type, string $field, string $id): MockObject - { - $contentIdentity = $this->createMock(ContentIdentityInterface::class); - $contentIdentity->expects($this->once()) - ->method('getEntityId') - ->willReturn($id); - $contentIdentity->expects($this->once()) - ->method('getField') - ->willReturn($field); - $contentIdentity->expects($this->once()) - ->method('getEntityType') - ->willReturn($type); - - return $contentIdentity; - } - - /** - * Media asset to media content relation data - * - * @return array - */ - public function assignAssetDataProvider(): array - { - - return [ - [ - '18976345', - 'cms_page', - '1', - 'content' - ] - ]; - } -} diff --git a/app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php b/app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php deleted file mode 100644 index 4942ea24240bb..0000000000000 --- a/app/code/Magento/MediaContent/Test/Unit/Model/GetAssetsusedInContentTest.php +++ /dev/null @@ -1,154 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaContent\Test\Unit\Model; - -use Magento\Framework\App\ResourceConnection; -use Magento\Framework\DB\Adapter\AdapterInterface; -use Magento\Framework\DB\Select; -use Magento\Framework\Exception\IntegrationException; -use Magento\MediaContent\Model\GetAssetIdsUsedInContent; -use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; -use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; -use Psr\Log\LoggerInterface; - -/** - * Test for the GetAssetUsedInContentTest command. - */ -class GetAssetsusedInContentTest extends TestCase -{ - /** - * @var ResourceConnection | MockObject - */ - private $resourceConnectionStub; - - /** - * @var LoggerInterface | MockObject - */ - private $loggerMock; - - /** - * @var GetAssetIdsUsedInContent - */ - private $getAssetsUsedInContent; - - /** - * @inheritdoc - */ - protected function setUp(): void - { - $this->resourceConnectionStub = $this->createMock(ResourceConnection::class); - $this->loggerMock = $this->createMock(LoggerInterface::class); - $this->getAssetsUsedInContent = new GetAssetIdsUsedInContent( - $this->resourceConnectionStub, - $this->loggerMock - ); - } - - /** - * Test successful execution of the GetAssetsUsedInContent::execute. - * - * @param array $requestParameters - * @param array $expectedAssetIdList - * @dataProvider getAssetsListRelatedToContent - */ - public function testSuccessfulGetUsedAssets( - array $requestParameters, - array $expectedAssetIdList - ): void { - $this->configureResourceConnectionStub($expectedAssetIdList); - $assetList = $this->getAssetsUsedInContent->execute( - $this->getContentIdentity( - $requestParameters['type'], - $requestParameters['field'], - $requestParameters['entity_id'] - ) - ); - - $this->assertEquals($expectedAssetIdList, $assetList); - } - - /** - * Test GetAssetsUsedInContent::execute with exception. - */ - public function testGetUsedAssetsWithException(): void - { - $this->resourceConnectionStub->method('getConnection')->willThrowException((new \Exception())); - $this->expectException(IntegrationException::class); - $this->loggerMock->expects($this->once()) - ->method('critical') - ->willReturnSelf(); - - $this->getAssetsUsedInContent->execute($this->createMock(ContentIdentityInterface::class)); - } - - /** - * Configure resource connection for the command. Based on the current implementation. - * - * @param array $expectedAssetIdList - */ - private function configureResourceConnectionStub(array $expectedAssetIdList): void - { - $selectStub = $this->createMock(Select::class); - $selectStub->expects($this->any())->method('from')->willReturnSelf(); - $selectStub->expects($this->any())->method('where')->willReturnSelf(); - - $connectionMock = $this->getMockBuilder(AdapterInterface::class)->getMock(); - $connectionMock->expects($this->any())->method('select')->willReturn($selectStub); - $connectionMock->expects($this->any()) - ->method('fetchAssoc') - ->with($selectStub) - ->willReturn($expectedAssetIdList); - $this->resourceConnectionStub->expects($this->any()) - ->method('getConnection') - ->willReturn($connectionMock); - } - - /** - * Get content identity mock - * - * @param string $type - * @param string $field - * @param string $id - * @return MockObject|ContentIdentityInterface - */ - private function getContentIdentity(string $type, string $field, string $id): MockObject - { - $contentIdentity = $this->createMock(ContentIdentityInterface::class); - $contentIdentity->expects($this->once()) - ->method('getEntityId') - ->willReturn($id); - $contentIdentity->expects($this->once()) - ->method('getField') - ->willReturn($field); - $contentIdentity->expects($this->once()) - ->method('getEntityType') - ->willReturn($type); - - return $contentIdentity; - } - - /** - * Media asset to media content relation data - * - * @return array - */ - public function getAssetsListRelatedToContent(): array - { - return [ - [ - [ - 'entity_type' => 'cms_page', - 'entity_id' => '1', - 'field' => 'content' - ], - [1234123] - ] - ]; - } -} diff --git a/app/code/Magento/MediaContent/Test/Unit/Model/GetContentWithAssetsTest.php b/app/code/Magento/MediaContent/Test/Unit/Model/GetContentWithAssetsTest.php deleted file mode 100644 index f2958d0a378ed..0000000000000 --- a/app/code/Magento/MediaContent/Test/Unit/Model/GetContentWithAssetsTest.php +++ /dev/null @@ -1,118 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaContent\Test\Unit\Model; - -use Magento\Framework\App\ResourceConnection; -use Magento\Framework\DB\Adapter\AdapterInterface; -use Magento\Framework\DB\Select; -use Magento\Framework\Exception\IntegrationException; -use Magento\MediaContent\Model\GetContentWithAssets; -use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; -use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory; -use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; -use Psr\Log\LoggerInterface; - -/** - * Test for the GetContentWithAsset command. - */ -class GetContentWithAssetsTest extends TestCase -{ - /** - * @var ResourceConnection | MockObject - */ - private $resourceConnectionStub; - - /** - * @var LoggerInterface | MockObject - */ - private $loggerMock; - - /** - * @var GetContentWithAssets - */ - private $getContentWithAsset; - - /** - * @var ContentIdentityInterfaceFactory - */ - private $factory; - - /** - * @inheritdoc - */ - protected function setUp(): void - { - $this->resourceConnectionStub = $this->createMock(ResourceConnection::class); - $this->loggerMock = $this->createMock(LoggerInterface::class); - $this->factory = $this->createMock(ContentIdentityInterfaceFactory::class); - $this->getContentWithAsset = new GetContentWithAssets( - $this->factory, - $this->resourceConnectionStub, - $this->loggerMock - ); - } - - /** - * Test successful execution of the GetContentWithAsset::execute. - */ - public function testSuccessfulGetContentWithAsset(): void - { - $assetId = 1234123; - $contentIdentityData = [ - 'entity_type' => 'catalog_product', - 'entity_id' => 42, - 'field' => 'desctiption' - ]; - $this->configureResourceConnectionStub($contentIdentityData); - - $contentIdentity = $this->createMock(ContentIdentityInterface::class); - $this->factory->expects($this->once()) - ->method('create') - ->with(['data' => $contentIdentityData]) - ->willReturn($contentIdentity); - - $this->assertEquals([$contentIdentity], $this->getContentWithAsset->execute([$assetId])); - } - - /** - * Test GetContentWithAsset::execute with exception. - */ - public function testGetContentWithAssetWithException(): void - { - $this->resourceConnectionStub->method('getConnection')->willThrowException((new \Exception())); - $this->expectException(IntegrationException::class); - $this->loggerMock->expects($this->once()) - ->method('critical') - ->willReturnSelf(); - - $this->getContentWithAsset->execute([1]); - } - - /** - * Configure resource connection for the command. Based on the current implementation. - * - * @param array $contentIdentityData - */ - private function configureResourceConnectionStub(array $contentIdentityData): void - { - $selectStub = $this->createMock(Select::class); - $selectStub->method('from')->willReturnSelf(); - $selectStub->method('where')->willReturnSelf(); - - $connectionMock = $this->getMockBuilder(AdapterInterface::class)->getMock(); - $connectionMock->expects($this->any())->method('select')->willReturn($selectStub); - $connectionMock->expects($this->any()) - ->method('fetchAssoc') - ->with($selectStub) - ->willReturn([$contentIdentityData]); - $this->resourceConnectionStub->expects($this->any()) - ->method('getConnection') - ->willReturn($connectionMock); - } -} diff --git a/app/code/Magento/MediaContent/Test/Unit/Model/UnassignAssetTest.php b/app/code/Magento/MediaContent/Test/Unit/Model/UnassignAssetTest.php deleted file mode 100644 index 5b5fc41cb29fa..0000000000000 --- a/app/code/Magento/MediaContent/Test/Unit/Model/UnassignAssetTest.php +++ /dev/null @@ -1,199 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaContent\Test\Unit\Model; - -use Magento\Framework\App\ResourceConnection; -use Magento\Framework\DB\Adapter\AdapterInterface; -use Magento\Framework\DB\Adapter\Pdo\Mysql; -use Magento\Framework\Exception\CouldNotDeleteException; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\MediaContent\Model\UnassignAssets; -use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; -use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; -use Psr\Log\LoggerInterface; - -/** - * Tests for the UnassignAsset command. - */ -class UnassignAssetTest extends TestCase -{ - /** - * Media content relation data storage table name - */ - private const TABLE_MEDIA_CONTENT_ASSET = 'media_content_asset'; - - /** - * Prefixed media content relation data storage table name - */ - private const PREFIXED_TABLE_MEDIA_CONTENT_ASSET = 'prefix_' . self::TABLE_MEDIA_CONTENT_ASSET; - - /** - * Media asset id - */ - private const ASSET_ID = 'asset_id'; - - /** - * Media content type - */ - private const TYPE = 'type'; - - /** - * Media entity id - */ - private const ENTITY_ID = 'entity_id'; - - /** - * Media content field where media asset is used - */ - private const FIELD = 'field'; - - /** - * @var ResourceConnection | MockObject - */ - private $resourceConnectionMock; - - /** - * @var AdapterInterface | MockObject - */ - private $adapterMock; - - /** - * @var LoggerInterface | MockObject - */ - private $loggerMock; - - /** - * @var UnassignAssets - */ - private $unassignAsset; - - /** - * Initialize basic test class mocks - */ - protected function setUp(): void - { - $this->adapterMock = $this->createMock(Mysql::class); - $this->loggerMock = $this->createMock(LoggerInterface::class); - $this->resourceConnectionMock = $this->createConfiguredMock( - ResourceConnection::class, - [ - 'getConnection' => $this->adapterMock, - 'getTableName' => self::PREFIXED_TABLE_MEDIA_CONTENT_ASSET - ] - ); - - $this->unassignAsset = (new ObjectManager($this))->getObject( - UnassignAssets::class, - [ - 'resourceConnection' => $this->resourceConnectionMock, - 'logger' => $this->loggerMock - ] - ); - } - - /** - * Test successful scenario for deleting relation between media asset and media content. - * - * @param int $assetId - * @param string $contentType - * @param string $contentEntityId - * @param string $contentField - * @dataProvider unassignAssetDataProvider - * @return void - */ - public function testSuccessfulUnassignAsset( - int $assetId, - string $contentType, - string $contentEntityId, - string $contentField - ): void { - $this->adapterMock->expects($this->once()) - ->method('delete') - ->with( - self::PREFIXED_TABLE_MEDIA_CONTENT_ASSET, - [ - self::ASSET_ID . ' IN (?)' => [$assetId], - self::TYPE . ' = ?' => $contentType, - self::ENTITY_ID . ' = ?' => $contentEntityId, - self::FIELD . ' = ?' => $contentField - ] - ); - - $this->unassignAsset->execute( - $this->getContentIdentity( - $contentType, - $contentField, - $contentEntityId - ), - [ - $assetId - ] - ); - } - - /** - * Test exception scenario for deleting relation between media asset and media content. - */ - public function testUnassignAssetWithException(): void { - $this->resourceConnectionMock->method('getConnection') - ->willThrowException((new \Exception())); - - $this->expectException(CouldNotDeleteException::class); - $this->loggerMock->expects($this->once()) - ->method('critical') - ->willReturnSelf(); - $this->unassignAsset->execute( - $this->createMock(ContentIdentityInterface::class), - [ - '42' - ] - ); - } - - /** - * Get content identity mock - * - * @param string $type - * @param string $field - * @param string $id - * @return MockObject|ContentIdentityInterface - */ - private function getContentIdentity(string $type, string $field, string $id): MockObject - { - $contentIdentity = $this->createMock(ContentIdentityInterface::class); - $contentIdentity->expects($this->once()) - ->method('getEntityId') - ->willReturn($id); - $contentIdentity->expects($this->once()) - ->method('getField') - ->willReturn($field); - $contentIdentity->expects($this->once()) - ->method('getEntityType') - ->willReturn($type); - - return $contentIdentity; - } - - /** - * Media asset to media content relation data - * - * @return array - */ - public function unassignAssetDataProvider(): array - { - return [ - [ - 18976345, - 'cms_page', - '1', - 'content' - ] - ]; - } -} diff --git a/app/code/Magento/MediaContent/etc/media_content.xsd b/app/code/Magento/MediaContentApi/etc/media_content.xsd similarity index 100% rename from app/code/Magento/MediaContent/etc/media_content.xsd rename to app/code/Magento/MediaContentApi/etc/media_content.xsd diff --git a/app/code/Magento/MediaContentCatalog/etc/media_content.xml b/app/code/Magento/MediaContentCatalog/etc/media_content.xml index e3f169d49fa3b..5277462268acb 100644 --- a/app/code/Magento/MediaContentCatalog/etc/media_content.xml +++ b/app/code/Magento/MediaContentCatalog/etc/media_content.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_MediaContent:etc/media_content.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_MediaContentApi:etc/media_content.xsd"> <search> <patterns> <pattern name="catalog_image">/^\/?media\/(.*)/</pattern> diff --git a/app/code/Magento/MediaContentCms/etc/media_content.xml b/app/code/Magento/MediaContentCms/etc/media_content.xml index 1fa175d51e9e3..57c954a9d70fe 100644 --- a/app/code/Magento/MediaContentCms/etc/media_content.xml +++ b/app/code/Magento/MediaContentCms/etc/media_content.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_MediaContent:etc/media_content.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_MediaContentApi:etc/media_content.xsd"> <search> <patterns> <pattern name="media_gallery">/{{media url="?(.*?)"?}}/</pattern> From d7bf23ba8bd0bf16cc50834ecdf4b6c287de94a9 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Wed, 8 Apr 2020 12:28:25 +0100 Subject: [PATCH 096/177] magento/magento2#27536: Updated plugins --- ...MediaGalleryAssetDeleteByDirectoryPath.php | 52 ++++++++------ .../Plugin/MediaGalleryAssetDeleteByPath.php | 49 +++++-------- .../Model/RemoveRelationsForAssetIds.php | 69 +++++++++++++++++++ 3 files changed, 117 insertions(+), 53 deletions(-) create mode 100644 app/code/Magento/MediaContent/Model/RemoveRelationsForAssetIds.php diff --git a/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php b/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php index 569798be356ca..d2ba6dd271834 100644 --- a/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php +++ b/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php @@ -3,12 +3,14 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\MediaContent\Model\Plugin; use Magento\Framework\App\ResourceConnection; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\MediaContent\Model\RemoveRelationsForAssetIds; use Magento\MediaGalleryApi\Model\Asset\Command\DeleteByDirectoryPathInterface; use Psr\Log\LoggerInterface; @@ -17,6 +19,8 @@ */ class MediaGalleryAssetDeleteByDirectoryPath { + private const TABLE_MEDIA_GALLERY_ASSET = 'media_gallery_asset'; + /** * @var ResourceConnection */ @@ -28,15 +32,21 @@ class MediaGalleryAssetDeleteByDirectoryPath private $logger; /** - * DeleteById constructor. - * + * @var RemoveRelationsForAssetIds + */ + private $removeRelationsForAssetIds; + + /** + * @param RemoveRelationsForAssetIds $removeRelationsForAssetIds * @param ResourceConnection $resourceConnection * @param LoggerInterface $logger */ public function __construct( + RemoveRelationsForAssetIds $removeRelationsForAssetIds, ResourceConnection $resourceConnection, LoggerInterface $logger ) { + $this->removeRelationsForAssetIds = $removeRelationsForAssetIds; $this->resourceConnection = $resourceConnection; $this->logger = $logger; } @@ -55,30 +65,28 @@ public function aroundExecute( \Closure $proceed, string $directoryPath ) : void { + $assetIds = $this->getAssetIdsByDirectoryPath($directoryPath); + + $proceed(); + + $this->removeRelationsForAssetIds->execute($assetIds); + } + + /** + * Get ids of media assets by directory path + * + * @param string $path + * @return int[] + */ + private function getAssetIdsByDirectoryPath(string $path): array + { /** @var AdapterInterface $connection */ $connection = $this->resourceConnection->getConnection(); - $galleryAssetTableName = $this->resourceConnection->getTableName('media_gallery_asset'); - $mediaContentAssetTableName = $this->resourceConnection->getTableName('media_content_asset'); + $galleryAssetTableName = $this->resourceConnection->getTableName(self::TABLE_MEDIA_GALLERY_ASSET); $select = $connection->select(); $select->from($galleryAssetTableName, ['id']); - $select->where('path LIKE ?', $directoryPath); - $galleryAssetIds = $connection->fetchCol($select); - - $proceed(); - - try { - $connection->delete( - $mediaContentAssetTableName, - ['asset_id IN(?)' => implode(', ', $galleryAssetIds)] - ); - } catch (\Exception $exception) { - $this->logger->critical($exception); - $message = __( - 'Could not delete media content assets for media gallery asset with path %path: %error', - ['path' => $directoryPath, 'error' => $exception->getMessage()] - ); - throw new CouldNotDeleteException($message, $exception); - } + $select->where('path LIKE ?', $path . '%'); + return $connection->fetchCol($select); } } diff --git a/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByPath.php b/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByPath.php index b5bf39cb70b69..2f74afd099dfc 100644 --- a/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByPath.php +++ b/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByPath.php @@ -3,13 +3,14 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\MediaContent\Model\Plugin; -use Magento\Framework\App\ResourceConnection; -use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\MediaContent\Model\RemoveRelationsForAssetIds; use Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface; +use Magento\MediaGalleryApi\Model\Asset\Command\GetByPathInterface; use Psr\Log\LoggerInterface; /** @@ -18,9 +19,9 @@ class MediaGalleryAssetDeleteByPath { /** - * @var ResourceConnection + * @var GetByPathInterface */ - private $resourceConnection; + private $getByPath; /** * @var LoggerInterface @@ -28,16 +29,22 @@ class MediaGalleryAssetDeleteByPath private $logger; /** - * DeleteById constructor. - * - * @param ResourceConnection $resourceConnection + * @var RemoveRelationsForAssetIds + */ + private $removeRelationsForAssetIds; + + /** + * @param RemoveRelationsForAssetIds $removeRelationsForAssetIds + * @param GetByPathInterface $getByPath * @param LoggerInterface $logger */ public function __construct( - ResourceConnection $resourceConnection, + RemoveRelationsForAssetIds $removeRelationsForAssetIds, + GetByPathInterface $getByPath, LoggerInterface $logger ) { - $this->resourceConnection = $resourceConnection; + $this->removeRelationsForAssetIds = $removeRelationsForAssetIds; + $this->getByPath = $getByPath; $this->logger = $logger; } @@ -55,30 +62,10 @@ public function aroundExecute( \Closure $proceed, string $mediaAssetPath ) : void { - /** @var AdapterInterface $connection */ - $connection = $this->resourceConnection->getConnection(); - $galleryAssetTableName = $this->resourceConnection->getTableName('media_gallery_asset'); - $mediaContentAssetTableName = $this->resourceConnection->getTableName('media_content_asset'); - - $select = $connection->select(); - $select->from($galleryAssetTableName, ['id']); - $select->where('path = ?', $mediaAssetPath); - $galleryAssetIds = $connection->fetchCol($select); + $asset = $this->getByPath->execute($mediaAssetPath); $proceed(); - try { - $connection->delete( - $mediaContentAssetTableName, - ['asset_id IN(?)' => implode(', ', $galleryAssetIds)] - ); - } catch (\Exception $exception) { - $this->logger->critical($exception); - $message = __( - 'Could not delete media content assets for media gallery asset with path %path: %error', - ['path' => $mediaAssetPath, 'error' => $exception->getMessage()] - ); - throw new CouldNotDeleteException($message, $exception); - } + $this->removeRelationsForAssetIds->execute([$asset->getId()]); } } diff --git a/app/code/Magento/MediaContent/Model/RemoveRelationsForAssetIds.php b/app/code/Magento/MediaContent/Model/RemoveRelationsForAssetIds.php new file mode 100644 index 0000000000000..c265d83f8f488 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/RemoveRelationsForAssetIds.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\Exception\CouldNotDeleteException; +use Psr\Log\LoggerInterface; + +/** + * Used for saving relation between the media asset and media content where the media asset is used + */ +class RemoveRelationsForAssetIds +{ + private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; + private const ASSET_ID = 'asset_id'; + + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * @param ResourceConnection $resourceConnection + * @param LoggerInterface $logger + */ + public function __construct(ResourceConnection $resourceConnection, LoggerInterface $logger) + { + $this->resourceConnection = $resourceConnection; + $this->logger = $logger; + } + + /** + * Remove media content relations for media asset ids + * + * @param array $assetIds + * @throws CouldNotDeleteException + */ + public function execute(array $assetIds): void + { + $commaSeparatedAssetIds = implode(', ', $assetIds); + try { + $this->resourceConnection->getConnection()->delete( + $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME), + [ + self::ASSET_ID . ' IN (?)' => $commaSeparatedAssetIds + ] + ); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $message = __( + 'Could not remove media content relations for assets ids: %ids', + [ + 'ids' => $commaSeparatedAssetIds + ] + ); + throw new CouldNotDeleteException($message, $exception); + } + } +} From 2b7e6a5eab84b7e8cc58ae9c3331069401941ea4 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Wed, 8 Apr 2020 12:35:00 +0100 Subject: [PATCH 097/177] magento/magento2#27536: Added content identity implementation of extension attributes --- .../MediaContent/Model/ContentIdentity.php | 17 +++++++++++++++++ .../Api/Data/ContentIdentityInterface.php | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/app/code/Magento/MediaContent/Model/ContentIdentity.php b/app/code/Magento/MediaContent/Model/ContentIdentity.php index 3ded1358e068a..9f1e5038f98a6 100644 --- a/app/code/Magento/MediaContent/Model/ContentIdentity.php +++ b/app/code/Magento/MediaContent/Model/ContentIdentity.php @@ -9,6 +9,7 @@ use Magento\Framework\Model\AbstractExtensibleModel; use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityExtensionInterface; /** * @inheritdoc @@ -42,4 +43,20 @@ public function getField(): string { return (string) $this->getData(self::FIELD); } + + /** + * @inheritdoc + */ + public function getExtensionAttributes(): ContentIdentityExtensionInterface + { + return $this->_getExtensionAttributes(); + } + + /** + * @inheritdoc + */ + public function setExtensionAttributes(ContentIdentityExtensionInterface $extensionAttributes): void + { + $this->_setExtensionAttributes($extensionAttributes); + } } diff --git a/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php b/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php index c107a9cd124db..e775b3ebf5dca 100644 --- a/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php +++ b/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php @@ -8,6 +8,8 @@ namespace Magento\MediaContentApi\Api\Data; +use Magento\MediaContentApi\Api\Data\ContentIdentityExtensionInterface; + /** * Data interface representing the identificator of content. I.e. short description field of product entity with id 42 * @api @@ -34,4 +36,19 @@ public function getEntityId(): string; * @return string */ public function getField(): string; + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\MediaContentApi\Api\Data\ContentIdentityExtensionInterface|null + */ + public function getExtensionAttributes(): ContentIdentityExtensionInterface; + + /** + * Set extension attributes + * + * @param \Magento\MediaContentApi\Api\Data\ContentIdentityExtensionInterface $extensionAttributes + * @return void + */ + public function setExtensionAttributes(ContentIdentityExtensionInterface $extensionAttributes): void; } From 1415e5aa86864f41f3ce2b39d235add1f9ec8c6b Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Wed, 8 Apr 2020 12:41:13 +0100 Subject: [PATCH 098/177] magento/magento2#27536: Added public method for retrieving search patterns from configuration --- .../Magento/MediaContent/Model/Content/Config.php | 12 ++++++++++++ .../MediaContent/Model/ExtractAssetsFromContent.php | 4 +--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/MediaContent/Model/Content/Config.php b/app/code/Magento/MediaContent/Model/Content/Config.php index e2f9f58289d31..166a1f8166d7d 100644 --- a/app/code/Magento/MediaContent/Model/Content/Config.php +++ b/app/code/Magento/MediaContent/Model/Content/Config.php @@ -14,6 +14,8 @@ */ class Config { + private const XML_PATH_SEARCH_PATTERNS = 'search/patterns'; + /** * @var DataInterface */ @@ -38,4 +40,14 @@ public function get($key = null, $default = null) { return $this->data->get($key, $default); } + + /** + * Retrieve search regexp patterns for finding media asset paths within content + * + * @return array + */ + public function getSearchPatterns(): array + { + return $this->get(self::XML_PATH_SEARCH_PATTERNS); + } } \ No newline at end of file diff --git a/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php b/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php index 4e1e559c39a9d..1a71c50291c93 100644 --- a/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php +++ b/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php @@ -18,8 +18,6 @@ */ class ExtractAssetsFromContent implements ExtractAssetsFromContentInterface { - private const XML_PATH_SEARCH_PATTERNS = 'search/patterns'; - /** * @var Config */ @@ -57,7 +55,7 @@ public function execute(string $content): array { $paths = []; - foreach ($this->config->get(self::XML_PATH_SEARCH_PATTERNS) as $pattern) { + foreach ($this->config->getSearchPatterns() as $pattern) { if (empty($pattern)) { continue; } From c2515ccb21757ddf8c5b0294d39669eb49b056b4 Mon Sep 17 00:00:00 2001 From: Serhii Balko <serhii.balko@transoftgroup.com> Date: Wed, 8 Apr 2020 14:41:14 +0300 Subject: [PATCH 099/177] MC-33117: PayPal payflow pro cancel fraud transaction on paypal no reference to Magento --- .../Paypal/Model/Payflow/Transparent.php | 38 ++++++++++++++++++- app/code/Magento/Paypal/i18n/en_US.csv | 1 + .../Adminhtml/Order/ReviewPayment.php | 12 +++--- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Paypal/Model/Payflow/Transparent.php b/app/code/Magento/Paypal/Model/Payflow/Transparent.php index 44a9b6f73c80e..87cb0df7b0d7f 100644 --- a/app/code/Magento/Paypal/Model/Payflow/Transparent.php +++ b/app/code/Magento/Paypal/Model/Payflow/Transparent.php @@ -61,7 +61,7 @@ class Transparent extends Payflowpro implements TransparentInterface * * @var bool */ - protected $_canFetchTransactionInfo = false; + protected $_canFetchTransactionInfo = true; /** * @var ResponseValidator @@ -355,11 +355,11 @@ public function capture(InfoInterface $payment, $amount) * * @param InfoInterface $payment * @return bool - * @throws InvalidTransitionException * @throws LocalizedException */ public function acceptPayment(InfoInterface $payment) { + $this->validatePaymentTransaction($payment); if ($this->getConfigPaymentAction() === MethodInterface::ACTION_AUTHORIZE_CAPTURE) { $invoices = iterator_to_array($payment->getOrder()->getInvoiceCollection()); $invoice = count($invoices) ? reset($invoices) : null; @@ -387,6 +387,20 @@ public function denyPayment(InfoInterface $payment) return true; } + /** + * @inheritDoc + */ + public function fetchTransactionInfo(InfoInterface $payment, $transactionId) + { + $result = parent::fetchTransactionInfo($payment, $transactionId); + $this->_canFetchTransactionInfo = false; + if ($payment->getIsTransactionApproved()) { + $this->acceptPayment($payment); + } + + return $result; + } + /** * Marks payment as fraudulent. * @@ -444,4 +458,24 @@ private function getZeroAmountAuthorizationId(InfoInterface $payment): string { return (string)$payment->getAdditionalInformation(self::PNREF); } + + /** + * Validates payment transaction status on PayPal. + * + * @param InfoInterface $payment + * @throws LocalizedException + */ + private function validatePaymentTransaction(InfoInterface $payment): void + { + if ($payment->canFetchTransactionInfo()) { + $transactionId = $payment->getLastTransId(); + parent::fetchTransactionInfo($payment, $transactionId); + $this->_canFetchTransactionInfo = false; + if ($payment->getIsTransactionDenied()) { + throw new LocalizedException( + __('Payment can\'t be accepted since transaction was rejected by merchant.') + ); + } + } + } } diff --git a/app/code/Magento/Paypal/i18n/en_US.csv b/app/code/Magento/Paypal/i18n/en_US.csv index 54dd611d49073..912b99e2e6427 100644 --- a/app/code/Magento/Paypal/i18n/en_US.csv +++ b/app/code/Magento/Paypal/i18n/en_US.csv @@ -739,3 +739,4 @@ User,User "Elektronisches Lastschriftverfahren - German ELV","Elektronisches Lastschriftverfahren - German ELV" "Please enter at least 0 and at most 65535","Please enter at least 0 and at most 65535" "Order is suspended as an account verification transaction is suspected to be fraudulent.","Order is suspended as an account verification transaction is suspected to be fraudulent." +"Payment can't be accepted since transaction was rejected by merchant.","Payment can't be accepted since transaction was rejected by merchant." diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php index 93c8305ec2396..57cd21ffa9eb1 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/ReviewPayment.php @@ -8,7 +8,6 @@ namespace Magento\Sales\Controller\Adminhtml\Order; -use Magento\Backend\App\Action; use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface; /** @@ -63,17 +62,20 @@ public function execute() } $this->orderRepository->save($order); $this->messageManager->addSuccessMessage($message); - $resultRedirect->setPath('sales/order/view', ['order_id' => $order->getEntityId()]); - } else { - $resultRedirect->setPath('sales/*/'); - return $resultRedirect; } // phpcs:ignore Magento2.Exceptions.ThrowCatch } catch (\Magento\Framework\Exception\LocalizedException $e) { + $this->messageManager->addErrorMessage($e->getMessage()); $this->messageManager->addErrorMessage(__('We can\'t update the payment right now.')); $this->logger->critical($e); + } + + if ($order) { + $resultRedirect->setPath('sales/order/view', ['order_id' => $order->getEntityId()]); + } else { $resultRedirect->setPath('sales/*/'); } + return $resultRedirect; } } From a8ba20347528ee7c951f48d4dc3d10810da9ac92 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Wed, 8 Apr 2020 13:08:57 +0100 Subject: [PATCH 100/177] magento/magento2#27499: Moved configuration xsd to MediaGalleryApi module --- .../MediaGallery/Model/Directory/Config.php | 2 +- .../Model/Directory/Config/Reader.php | 27 ------------- .../Model/Directory/Config/SchemaLocator.php | 2 +- .../Unit/Model/Asset/Command/SaveTest.php | 1 - app/code/Magento/MediaGallery/etc/di.xml | 7 +++- .../Magento/MediaGallery/etc/directory.xml | 2 +- .../etc/directory.xsd | 15 +++++++ .../Directory/Command/CreateByPathTest.php | 19 ++++----- .../Directory/Command/DeleteByPathTest.php | 40 +++++++------------ 9 files changed, 44 insertions(+), 71 deletions(-) delete mode 100644 app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php rename app/code/Magento/{MediaGallery => MediaGalleryApi}/etc/directory.xsd (68%) diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config.php b/app/code/Magento/MediaGallery/Model/Directory/Config.php index 3e47161f35c06..46314be9edfc1 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Config.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Config.php @@ -48,6 +48,6 @@ public function get($key = null, $default = null) */ public function getBlacklistPatterns() : array { - return $this->data->get(self::XML_PATH_BLACKLIST_PATTERNS); + return $this->get(self::XML_PATH_BLACKLIST_PATTERNS); } } diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php b/app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php deleted file mode 100644 index 85f61f712d580..0000000000000 --- a/app/code/Magento/MediaGallery/Model/Directory/Config/Reader.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaGallery\Model\Directory\Config; - -use Magento\Framework\Config\ReaderInterface; -use Magento\Framework\Config\Reader\Filesystem; - -/** - * Media gallery directory config reader - */ -class Reader extends Filesystem implements ReaderInterface -{ - /** - * List of id attributes for merge - * - * @var array - */ - protected $_idAttributes = [ - '/config/patterns' => 'patterns', - '/config/patterns/pattern' => 'name', - ]; -} diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config/SchemaLocator.php b/app/code/Magento/MediaGallery/Model/Directory/Config/SchemaLocator.php index 6661b0d7e95ee..7fdf414cdd228 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Config/SchemaLocator.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Config/SchemaLocator.php @@ -28,7 +28,7 @@ class SchemaLocator implements SchemaLocatorInterface */ public function __construct(Reader $moduleReader) { - $this->schema = $moduleReader->getModuleDir(Dir::MODULE_ETC_DIR, 'Magento_MediaGallery') . '/directory.xsd'; + $this->schema = $moduleReader->getModuleDir(Dir::MODULE_ETC_DIR, 'Magento_MediaGalleryApi') . '/directory.xsd'; } /** diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php index 4340a77e0b39a..8db0258fe3981 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php @@ -24,7 +24,6 @@ */ class SaveTest extends TestCase { - /** * Constant for tablename of media gallery assets */ diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index 11e63b710697e..bfbab191e68d3 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -34,13 +34,16 @@ <plugin name="media_gallery_image_remove_metadata_after_wysiwyg" type="Magento\MediaGallery\Plugin\Wysiwyg\Images\Storage" sortOrder="10" disabled="false"/> </type> - <type name="Magento\MediaGallery\Model\Directory\Config\Reader"> + <virtualType name="Magento\MediaGallery\Model\Directory\Config\Reader" type="Magento\Framework\Config\Reader\Filesystem"> <arguments> <argument name="fileName" xsi:type="string">directory.xml</argument> <argument name="converter" xsi:type="object">Magento\MediaGallery\Model\Directory\Config\Converter</argument> <argument name="schemaLocator" xsi:type="object">Magento\MediaGallery\Model\Directory\Config\SchemaLocator</argument> + <argument name="idAttributes" xsi:type="array"> + <item name="/config/blacklist/patterns/pattern" xsi:type="string">name</item> + </argument> </arguments> - </type> + </virtualType> <virtualType name="Magento\MediaGallery\Model\Directory\Config\Data" type="Magento\Framework\Config\Data"> <arguments> <argument name="reader" xsi:type="object">Magento\MediaGallery\Model\Directory\Config\Reader</argument> diff --git a/app/code/Magento/MediaGallery/etc/directory.xml b/app/code/Magento/MediaGallery/etc/directory.xml index 2eb37aa81ab42..c6da55482976e 100644 --- a/app/code/Magento/MediaGallery/etc/directory.xml +++ b/app/code/Magento/MediaGallery/etc/directory.xml @@ -5,7 +5,7 @@ * See COPYING.txt for license details. */ --> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_MediaGallery:etc/directory.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_MediaGalleryApi:etc/directory.xsd"> <blacklist> <patterns> <pattern name="captcha">/^captcha/</pattern> diff --git a/app/code/Magento/MediaGallery/etc/directory.xsd b/app/code/Magento/MediaGalleryApi/etc/directory.xsd similarity index 68% rename from app/code/Magento/MediaGallery/etc/directory.xsd rename to app/code/Magento/MediaGalleryApi/etc/directory.xsd index 4c0b1120db304..51ca17809ab78 100644 --- a/app/code/Magento/MediaGallery/etc/directory.xsd +++ b/app/code/Magento/MediaGalleryApi/etc/directory.xsd @@ -16,18 +16,33 @@ </xs:complexType> <xs:complexType name="blacklistType"> + <xs:annotation> + <xs:documentation> + Blacklist used for excluding directories from media gallery rendering and operations + </xs:documentation> + </xs:annotation> <xs:sequence> <xs:element type="patternsType" name="patterns" maxOccurs="unbounded" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="patternsType"> + <xs:annotation> + <xs:documentation> + List of directory paths regexp patterns + </xs:documentation> + </xs:annotation> <xs:sequence> <xs:element type="patternType" name="pattern" maxOccurs="unbounded" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="patternType"> + <xs:annotation> + <xs:documentation> + Directory path regexp pattern + </xs:documentation> + </xs:annotation> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute type="xs:string" name="name" use="required"/> diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php index 84861a5375713..ad28d180fb899 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php @@ -4,6 +4,8 @@ * See COPYING.txt for license details. * */ +declare(strict_types=1); + namespace Magento\MediaGallery\Model\Directory\Command; use Magento\Framework\App\Filesystem\DirectoryList; @@ -19,33 +21,26 @@ class CreateByPathTest extends \PHPUnit\Framework\TestCase /** * Test directory name */ - private CONST TEST_DIRECTORY_NAME = 'testCreateDirectory'; + private const TEST_DIRECTORY_NAME = 'testCreateDirectory'; /** * Absolute path to the media direcrory */ - private static $_mediaPath; + private $mediaDirectoryPath; /** * @var CreateByPathInterface */ private $createByPath; - /** - * @inheritdoc - */ - public static function setUpBeforeClass() - { - self::$_mediaPath = Bootstrap::getObjectManager()->get(Filesystem::class) - ->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath(); - } - /** * @inheritdoc */ public function setUp() { $this->createByPath = Bootstrap::getObjectManager()->create(CreateByPathInterface::class); + $this->mediaDirectoryPath = Bootstrap::getObjectManager()->get(Filesystem::class) + ->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath(); } /** @@ -54,7 +49,7 @@ public function setUp() */ public function testCreateDirectory(): void { - $fullPath = self::$_mediaPath . self::TEST_DIRECTORY_NAME; + $fullPath = $this->mediaDirectoryPath . self::TEST_DIRECTORY_NAME; $this->createByPath->execute('', self::TEST_DIRECTORY_NAME); $this->assertFileExists($fullPath); } diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php index 282dbe2ed11d0..01234db0241d7 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php @@ -4,6 +4,8 @@ * See COPYING.txt for license details. * */ +declare(strict_types=1); + namespace Magento\MediaGallery\Model\Directory\Command; use Magento\Framework\App\Filesystem\DirectoryList; @@ -16,31 +18,15 @@ */ class DeleteByPathTest extends \PHPUnit\Framework\TestCase { - /** - * Test directory name - */ - private CONST TEST_DIRECTORY_NAME = 'testDeleteDirectory'; - - /** - * Absolute path to the media direcrory - */ - private static $_mediaPath; - /** * @var DeleteByPathInterface */ private $deleteByPath; /** - * @inheritdoc + * @var string */ - public static function setUpBeforeClass() - { - /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $directory */ - $directory = Bootstrap::getObjectManager()->get(Filesystem::class)->getDirectoryWrite(DirectoryList::MEDIA); - self::$_mediaPath = $directory->getAbsolutePath(); - $directory->create(self::TEST_DIRECTORY_NAME); - } + private $testDirectoryName = 'testDeleteDirectory'; /** * @inheritdoc @@ -51,19 +37,22 @@ public function setUp() } /** - * @return void * @throws \Magento\Framework\Exception\CouldNotDeleteException + * @throws \Magento\Framework\Exception\FileSystemException */ public function testDeleteDirectoryWithExistingDirectoryAndCorrectAbsolutePath(): void { - $fullPath = self::$_mediaPath . self::TEST_DIRECTORY_NAME; + /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $mediaDirectory */ + $mediaDirectory = Bootstrap::getObjectManager()->get(Filesystem::class) + ->getDirectoryRead(DirectoryList::MEDIA); + $mediaDirectory->create($this->testDirectoryName); + $fullPath = $mediaDirectory->getAbsolutePath($this->testDirectoryName); $this->assertFileExists($fullPath); - $this->deleteByPath->execute(self::TEST_DIRECTORY_NAME); + $this->deleteByPath->execute($this->testDirectoryName); $this->assertFileNotExists($fullPath); } /** - * @return void * @throws \Magento\Framework\Exception\CouldNotDeleteException * @expectedException \Magento\Framework\Exception\CouldNotDeleteException */ @@ -73,7 +62,6 @@ public function testDeleteDirectoryWithRelativePathUnderMediaFolder(): void } /** - * @return void * @throws \Magento\Framework\Exception\CouldNotDeleteException * @expectedException \Magento\Framework\Exception\CouldNotDeleteException */ @@ -85,14 +73,14 @@ public function testDeleteDirectoryThatIsNotAllowed(): void /** * @throws \Magento\Framework\Exception\FileSystemException */ - public static function tearDownAfterClass() + public function tearDown() { $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->get(\Magento\Framework\Filesystem::class); /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $directory */ $directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); - if ($directory->isExist(self::TEST_DIRECTORY_NAME)) { - $directory->delete(self::TEST_DIRECTORY_NAME); + if ($directory->isExist($this->testDirectoryName)) { + $directory->delete($this->testDirectoryName); } } } From fcd1b5808625364e09dc6aea2d9eb8c0ee209d25 Mon Sep 17 00:00:00 2001 From: Serhii Balko <serhii.balko@transoftgroup.com> Date: Wed, 8 Apr 2020 16:10:07 +0300 Subject: [PATCH 101/177] MC-33138: Extend using Magento Recommendations failed --- .../Quote/Model/ShippingMethodManagement.php | 73 ++++++++++-------- .../Model/ShippingMethodManagementTest.php | 74 +++++++++++++------ 2 files changed, 95 insertions(+), 52 deletions(-) diff --git a/app/code/Magento/Quote/Model/ShippingMethodManagement.php b/app/code/Magento/Quote/Model/ShippingMethodManagement.php index 73a2a43b2581f..d9fa37c0185a9 100644 --- a/app/code/Magento/Quote/Model/ShippingMethodManagement.php +++ b/app/code/Magento/Quote/Model/ShippingMethodManagement.php @@ -3,20 +3,27 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\Quote\Model; +use Magento\Customer\Api\AddressRepositoryInterface; use Magento\Customer\Api\Data\AddressInterfaceFactory; use Magento\Customer\Model\Session as CustomerSession; +use Magento\Framework\Api\ExtensibleDataInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\StateException; use Magento\Framework\Reflection\DataObjectProcessor; +use Magento\Quote\Api\CartRepositoryInterface; use Magento\Quote\Api\Data\AddressInterface; use Magento\Quote\Api\Data\EstimateAddressInterface; +use Magento\Quote\Api\Data\ShippingMethodInterface; use Magento\Quote\Api\ShipmentEstimationInterface; +use Magento\Quote\Model\Cart\ShippingMethodConverter; +use Magento\Quote\Model\Quote\Address; +use Magento\Quote\Model\Quote\Address\Rate; +use Magento\Quote\Model\Quote\TotalsCollector; use Magento\Quote\Model\ResourceModel\Quote\Address as QuoteAddressResource; /** @@ -33,21 +40,21 @@ class ShippingMethodManagement implements /** * Quote repository. * - * @var \Magento\Quote\Api\CartRepositoryInterface + * @var CartRepositoryInterface */ protected $quoteRepository; /** * Shipping method converter * - * @var \Magento\Quote\Model\Cart\ShippingMethodConverter + * @var ShippingMethodConverter */ protected $converter; /** * Customer Address repository * - * @var \Magento\Customer\Api\AddressRepositoryInterface + * @var AddressRepositoryInterface */ protected $addressRepository; @@ -57,7 +64,7 @@ class ShippingMethodManagement implements protected $totalsCollector; /** - * @var \Magento\Framework\Reflection\DataObjectProcessor $dataProcessor + * @var DataObjectProcessor $dataProcessor */ private $dataProcessor; @@ -79,19 +86,19 @@ class ShippingMethodManagement implements /** * Constructor * - * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository + * @param CartRepositoryInterface $quoteRepository * @param Cart\ShippingMethodConverter $converter - * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository + * @param AddressRepositoryInterface $addressRepository * @param Quote\TotalsCollector $totalsCollector * @param AddressInterfaceFactory|null $addressFactory * @param QuoteAddressResource|null $quoteAddressResource * @param CustomerSession|null $customerSession */ public function __construct( - \Magento\Quote\Api\CartRepositoryInterface $quoteRepository, + CartRepositoryInterface $quoteRepository, Cart\ShippingMethodConverter $converter, - \Magento\Customer\Api\AddressRepositoryInterface $addressRepository, - \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector, + AddressRepositoryInterface $addressRepository, + TotalsCollector $totalsCollector, AddressInterfaceFactory $addressFactory = null, QuoteAddressResource $quoteAddressResource = null, CustomerSession $customerSession = null @@ -112,10 +119,10 @@ public function __construct( */ public function get($cartId) { - /** @var \Magento\Quote\Model\Quote $quote */ + /** @var Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); - /** @var \Magento\Quote\Model\Quote\Address $shippingAddress */ + /** @var Address $shippingAddress */ $shippingAddress = $quote->getShippingAddress(); if (!$shippingAddress->getCountryId()) { throw new StateException(__('The shipping address is missing. Set the address and try again.')); @@ -127,7 +134,7 @@ public function get($cartId) } $shippingAddress->collectShippingRates(); - /** @var \Magento\Quote\Model\Quote\Address\Rate $shippingRate */ + /** @var Rate $shippingRate */ $shippingRate = $shippingAddress->getShippingRateByCode($shippingMethod); if (!$shippingRate) { return null; @@ -142,7 +149,7 @@ public function getList($cartId) { $output = []; - /** @var \Magento\Quote\Model\Quote $quote */ + /** @var Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); // no methods applicable for empty carts or carts with virtual products @@ -169,7 +176,7 @@ public function getList($cartId) */ public function set($cartId, $carrierCode, $methodCode) { - /** @var \Magento\Quote\Model\Quote $quote */ + /** @var Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); try { $this->apply($cartId, $carrierCode, $methodCode); @@ -199,7 +206,7 @@ public function set($cartId, $carrierCode, $methodCode) */ public function apply($cartId, $carrierCode, $methodCode) { - /** @var \Magento\Quote\Model\Quote $quote */ + /** @var Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); if (0 == $quote->getItemsCount()) { throw new InputException( @@ -223,9 +230,9 @@ public function apply($cartId, $carrierCode, $methodCode) /** * @inheritDoc */ - public function estimateByAddress($cartId, \Magento\Quote\Api\Data\EstimateAddressInterface $address) + public function estimateByAddress($cartId, EstimateAddressInterface $address) { - /** @var \Magento\Quote\Model\Quote $quote */ + /** @var Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); // no methods applicable for empty carts or carts with virtual products @@ -241,7 +248,7 @@ public function estimateByAddress($cartId, \Magento\Quote\Api\Data\EstimateAddre */ public function estimateByExtendedAddress($cartId, AddressInterface $address) { - /** @var \Magento\Quote\Model\Quote $quote */ + /** @var Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); // no methods applicable for empty carts or carts with virtual products @@ -256,7 +263,7 @@ public function estimateByExtendedAddress($cartId, AddressInterface $address) */ public function estimateByAddressId($cartId, $addressId) { - /** @var \Magento\Quote\Model\Quote $quote */ + /** @var Quote $quote */ $quote = $this->quoteRepository->getActive($cartId); // no methods applicable for empty carts or carts with virtual products @@ -276,13 +283,13 @@ public function estimateByAddressId($cartId, $addressId) * @param string $postcode * @param int $regionId * @param string $region - * @param \Magento\Framework\Api\ExtensibleDataInterface|null $address - * @return \Magento\Quote\Api\Data\ShippingMethodInterface[] An array of shipping methods. + * @param ExtensibleDataInterface|null $address + * @return ShippingMethodInterface[] An array of shipping methods. * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @deprecated 100.2.0 */ protected function getEstimatedRates( - \Magento\Quote\Model\Quote $quote, + Quote $quote, $country, $postcode, $regionId, @@ -301,9 +308,9 @@ protected function getEstimatedRates( /** * Get list of available shipping methods * - * @param \Magento\Quote\Model\Quote $quote - * @param \Magento\Framework\Api\ExtensibleDataInterface $address - * @return \Magento\Quote\Api\Data\ShippingMethodInterface[] + * @param Quote $quote + * @param ExtensibleDataInterface $address + * @return ShippingMethodInterface[] */ private function getShippingMethods(Quote $quote, $address) { @@ -334,27 +341,31 @@ private function getShippingMethods(Quote $quote, $address) /** * Get transform address interface into Array * - * @param \Magento\Framework\Api\ExtensibleDataInterface $address + * @param ExtensibleDataInterface $address * @return array */ private function extractAddressData($address) { $className = \Magento\Customer\Api\Data\AddressInterface::class; - if ($address instanceof \Magento\Quote\Api\Data\AddressInterface) { - $className = \Magento\Quote\Api\Data\AddressInterface::class; + if ($address instanceof AddressInterface) { + $className = AddressInterface::class; } elseif ($address instanceof EstimateAddressInterface) { $className = EstimateAddressInterface::class; } - return $this->getDataObjectProcessor()->buildOutputDataArray( + + $addressData = $this->getDataObjectProcessor()->buildOutputDataArray( $address, $className ); + unset($addressData[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]); + + return $addressData; } /** * Gets the data object processor * - * @return \Magento\Framework\Reflection\DataObjectProcessor + * @return DataObjectProcessor * @deprecated 100.2.0 */ private function getDataObjectProcessor() diff --git a/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php index 34d7707d31666..c5b0b264bb79c 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/ShippingMethodManagementTest.php @@ -1,14 +1,19 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\Quote\Test\Unit\Model; +use Magento\Customer\Api\AddressRepositoryInterface; +use Magento\Customer\Api\Data\AddressInterface; +use Magento\Customer\Api\Data\AddressInterfaceFactory; +use Magento\Framework\Api\ExtensibleDataInterface; +use Magento\Framework\Reflection\DataObjectProcessor; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Quote\Api\CartRepositoryInterface; use Magento\Quote\Api\Data\ShippingMethodInterface; +use Magento\Quote\Api\Data\ShippingMethodInterfaceFactory; use Magento\Quote\Model\Cart\ShippingMethodConverter; use Magento\Quote\Model\Quote; use Magento\Quote\Model\Quote\Address; @@ -18,12 +23,13 @@ use Magento\Quote\Model\ResourceModel\Quote\Address as QuoteAddressResource; use Magento\Quote\Model\ShippingMethodManagement; use Magento\Store\Model\Store; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ShippingMethodManagementTest extends \PHPUnit\Framework\TestCase +class ShippingMethodManagementTest extends TestCase { /** * @var ShippingMethodManagement @@ -31,12 +37,12 @@ class ShippingMethodManagementTest extends \PHPUnit\Framework\TestCase protected $model; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $shippingMethodMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $methodDataFactoryMock; @@ -46,7 +52,7 @@ class ShippingMethodManagementTest extends \PHPUnit\Framework\TestCase protected $converter; /** - * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager + * @var ObjectManager */ protected $objectManager; @@ -66,17 +72,17 @@ class ShippingMethodManagementTest extends \PHPUnit\Framework\TestCase private $shippingAddress; /** - * @var \Magento\Framework\Reflection\DataObjectProcessor|MockObject + * @var DataObjectProcessor|MockObject */ private $dataProcessor; /** - * @var \Magento\Customer\Api\Data\AddressInterfaceFactory|MockObject + * @var AddressInterfaceFactory|MockObject */ private $addressFactory; /** - * @var \Magento\Customer\Api\AddressRepositoryInterface|MockObject + * @var AddressRepositoryInterface|MockObject */ private $addressRepository; @@ -95,19 +101,22 @@ class ShippingMethodManagementTest extends \PHPUnit\Framework\TestCase */ private $quoteAddressResource; + /** + * @inheritdoc + */ protected function setUp() { $this->objectManager = new ObjectManager($this); - $this->quoteRepository = $this->createMock(\Magento\Quote\Api\CartRepositoryInterface::class); - $this->addressRepository = $this->createMock(\Magento\Customer\Api\AddressRepositoryInterface::class); + $this->quoteRepository = $this->createMock(CartRepositoryInterface::class); + $this->addressRepository = $this->createMock(AddressRepositoryInterface::class); - $className = \Magento\Quote\Api\Data\ShippingMethodInterfaceFactory::class; + $className = ShippingMethodInterfaceFactory::class; $this->methodDataFactoryMock = $this->createPartialMock($className, ['create']); - $className = \Magento\Customer\Api\Data\AddressInterfaceFactory::class; + $className = AddressInterfaceFactory::class; $this->addressFactory = $this->createPartialMock($className, ['create']); - $className = \Magento\Framework\Reflection\DataObjectProcessor::class; + $className = DataObjectProcessor::class; $this->dataProcessor = $this->createMock($className); $this->quoteAddressResource = $this->createMock(QuoteAddressResource::class); @@ -196,6 +205,9 @@ public function testGetMethodWhenShippingAddressIsNotSet() $this->assertNull($this->model->get($cartId)); } + /** + * Test to returns selected shipping method for a specified quote + */ public function testGetMethod() { $cartId = 666; @@ -213,14 +225,14 @@ public function testGetMethod() ->method('getShippingMethod')->will($this->returnValue('one_two')); $this->shippingAddress->expects($this->once())->method('collectShippingRates')->willReturnSelf(); - $shippingRateMock = $this->createMock(\Magento\Quote\Model\Quote\Address\Rate::class); + $shippingRateMock = $this->createMock(Rate::class); $this->shippingAddress->expects($this->once()) ->method('getShippingRateByCode') ->with('one_two') ->willReturn($shippingRateMock); - $this->shippingMethodMock = $this->createMock(\Magento\Quote\Api\Data\ShippingMethodInterface::class); + $this->shippingMethodMock = $this->createMock(ShippingMethodInterface::class); $this->converter->expects($this->once()) ->method('modelToDataObject') ->with($shippingRateMock, $currencyCode) @@ -228,6 +240,9 @@ public function testGetMethod() $this->model->get($cartId); } + /** + * Test to returns selected shipping method for a specified quote if method isn't set + */ public function testGetMethodIfMethodIsNotSet() { $cartId = 666; @@ -245,6 +260,9 @@ public function testGetMethodIfMethodIsNotSet() $this->assertNull($this->model->get($cartId)); } + /** + * Test to get lists applicable shipping methods for a specified quote + */ public function testGetListForVirtualCart() { $cartId = 834; @@ -256,6 +274,9 @@ public function testGetListForVirtualCart() $this->assertEquals([], $this->model->getList($cartId)); } + /** + * Test to get lists applicable shipping methods for a specified quote + */ public function testGetListForEmptyCart() { $cartId = 834; @@ -289,6 +310,9 @@ public function testGetListWhenShippingAddressIsNotSet() $this->model->getList($cartId); } + /** + * Test to get lists applicable shipping methods for a specified quote + */ public function testGetList() { $cartId = 834; @@ -302,7 +326,7 @@ public function testGetList() ->method('getShippingAddress')->will($this->returnValue($this->shippingAddress)); $this->shippingAddress->expects($this->once())->method('getCountryId')->will($this->returnValue(345)); $this->shippingAddress->expects($this->once())->method('collectShippingRates'); - $shippingRateMock = $this->createMock(\Magento\Quote\Model\Quote\Address\Rate::class); + $shippingRateMock = $this->createMock(Rate::class); $this->shippingAddress->expects($this->once()) ->method('getGroupedAllShippingRates') ->will($this->returnValue([[$shippingRateMock]])); @@ -441,6 +465,9 @@ public function testSetMethodWithoutAddress() $this->model->set($cartId, $carrierCode, $methodCode); } + /** + * Test to sets the carrier and shipping methods codes for a specified cart + */ public function testSetMethod() { $cartId = 12; @@ -472,6 +499,9 @@ public function testEstimateByExtendedAddress() { $cartId = 1; + $addressExtAttr = [ + 'discounts' => 100 + ]; $addressData = [ 'region' => 'California', 'region_id' => 23, @@ -509,7 +539,9 @@ public function testEstimateByExtendedAddress() $this->dataProcessor->expects(static::any()) ->method('buildOutputDataArray') - ->willReturn($addressData); + ->willReturn($addressData + [ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY => $addressExtAttr]); + + $this->shippingAddress->expects($this->once())->method('addData')->with($addressData); $this->shippingAddress->expects(static::once()) ->method('setCollectShippingRates') @@ -561,9 +593,9 @@ public function testEstimateByAddressId() $currencyCode = 'UAH'; /** - * @var \Magento\Customer\Api\Data\AddressInterface|MockObject $address + * @var AddressInterface|MockObject $address */ - $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class) + $address = $this->getMockBuilder(AddressInterface::class) ->disableOriginalConstructor() ->getMock(); From eb809fd3fae3413cc014a58b38ab6368973828c3 Mon Sep 17 00:00:00 2001 From: Ji Lu <jilu1@adobe.com> Date: Wed, 8 Apr 2020 12:43:32 -0500 Subject: [PATCH 102/177] MQE-2046: remove deprecated entities usages in MFTF tests --- .../Backend/Test/Mftf/Section/AdminMessagesSection.xml | 6 +++--- .../Mftf/ActionGroup/AddSimpleProductToCartActionGroup.xml | 2 +- .../StorefrontAddSimpleProductToCartActionGroup.xml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml index dbd5348d7d696..fce74f1f419e6 100644 --- a/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml +++ b/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml @@ -9,12 +9,12 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminMessagesSection"> - <element name="success" type="text" selector="#messages div.message-success"/> + <element name="success" type="text" selector=".message-success"/> <element name="nthSuccess" type="text" selector=".message.message-success.success:nth-of-type({{n}})>div" parameterized="true"/> - <element name="error" type="text" selector="#messages div.message-error"/> + <element name="error" type="text" selector=".message.message-error.error"/> <element name="notice" type="text" selector=".message.message-notice.notice"/> <element name="messageByType" type="text" selector="#messages div.message-{{messageType}}" parameterized="true" /> - <element name="warning" type="text" selector="#messages div.message-warning"/> + <element name="warning" type="text" selector=".message-warning"/> <element name="accessDenied" type="text" selector=".access-denied-page"/> </section> </sections> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AddSimpleProductToCartActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AddSimpleProductToCartActionGroup.xml index 81e3b8c99d9d2..b4f7571429151 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AddSimpleProductToCartActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AddSimpleProductToCartActionGroup.xml @@ -10,7 +10,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> <actionGroup name="AddSimpleProductToCartActionGroup"> <annotations> - <description>Navigates to the Storefront Product page. Then adds the Product to the Cart. Validates that the Success Message is present and correct.</description> + <description>Only works on Storefront Product Page - Add Simple Product to Cart</description> </annotations> <arguments> <argument name="product" defaultValue="product"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAddSimpleProductToCartActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAddSimpleProductToCartActionGroup.xml index a17a6b4353783..d6add9a5d5c00 100644 --- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAddSimpleProductToCartActionGroup.xml +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAddSimpleProductToCartActionGroup.xml @@ -11,12 +11,12 @@ <!-- Add Product to Cart from the category page and check message --> <actionGroup name="StorefrontAddSimpleProductToCartActionGroup"> <annotations> - <description>Adds the provided Product to the Storefront Shopping Cart from a Storefront Category page. Validates that the provided Success Message is present and correct.</description> + <description>Only works on Storefront Category Page - Add Simple Product to Cart</description> </annotations> <arguments> <argument name="product" type="entity"/> </arguments> - + <moveMouseOver selector="{{StorefrontCategoryProductSection.ProductInfoByName(product.name)}}" stepKey="moveMouseOverProduct"/> <click selector="{{StorefrontCategoryProductSection.ProductAddToCartByName(product.name)}}" stepKey="clickAddToCart"/> <waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" stepKey="waitForSuccessMessage"/> From 9f4bafce862acdd6e406e73dc24ee8a6e293cebe Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Wed, 8 Apr 2020 21:58:44 +0100 Subject: [PATCH 103/177] magento/magento2#27499: MediaGallery bulk interfaces introduced --- .../Asset/Command/DeleteByDirectoryPath.php | 3 +- .../Model/Asset/Command/DeleteByPath.php | 1 + .../Model/Asset/Command/GetById.php | 1 + .../Model/Asset/Command/GetByPath.php | 3 +- .../MediaGallery/Model/Asset/Command/Save.php | 1 + .../MediaGallery/Model/AssetKeywords.php | 53 ++++++++ .../Model/Directory/Command/CreateByPath.php | 38 ++++-- .../Model/Directory/Command/DeleteByPath.php | 33 +++-- .../Model/Directory/IsBlacklisted.php | 4 +- .../Model/File/Command/DeleteByAssetId.php | 72 ---------- .../Magento/MediaGallery/Model/Keyword.php | 3 +- .../Keyword/Command/GetAssetKeywords.php | 1 + .../Keyword/Command/SaveAssetKeywords.php | 6 +- .../ResourceModel/DeleteAssetsByPaths.php | 100 ++++++++++++++ .../Model/ResourceModel/GetAssetsByIds.php | 80 +++++++++++ .../Model/ResourceModel/GetAssetsByPaths.php | 87 ++++++++++++ .../Keyword/GetAssetsKeywords.php | 128 ++++++++++++++++++ .../Keyword}/SaveAssetLinks.php | 15 +- .../Keyword/SaveAssetsKeywords.php | 128 ++++++++++++++++++ .../Model/ResourceModel/SaveAssets.php | 88 ++++++++++++ .../Keyword/Command/SaveAssetKeywordsTest.php | 2 +- .../Keyword/Command/SaveAssetLinksTest.php | 2 +- app/code/Magento/MediaGallery/etc/di.xml | 15 +- .../CreateDirectoriesByPathsInterface.php} | 9 +- .../Api/Data/AssetKeywordsInterface.php | 48 +++++++ .../Api/DeleteAssetsByPathsInterface.php | 24 ++++ .../DeleteDirectoriesByPathsInterface.php} | 8 +- .../Api/GetAssetsByIdsInterface.php | 25 ++++ .../Api/GetAssetsByPathsInterface.php | 24 ++++ .../Api/GetAssetsKeywordsInterface.php | 23 ++++ .../IsPathBlacklistedInterface.php} | 4 +- .../Api/SaveAssetsInterface.php | 26 ++++ .../Api/SaveAssetsKeywordsInterface.php | 23 ++++ .../DeleteByDirectoryPathInterface.php | 2 +- .../Asset/Command/DeleteByPathInterface.php | 2 +- .../Model/Asset/Command/GetByIdInterface.php | 2 +- .../Asset/Command/GetByPathInterface.php | 2 +- .../Model/Asset/Command/SaveInterface.php | 2 +- .../File/Command/DeleteByAssetIdInterface.php | 24 ---- .../Command/GetAssetKeywordsInterface.php | 2 +- .../Command/SaveAssetKeywordsInterface.php | 2 +- .../Directory/Command/CreateByPathTest.php | 2 +- 42 files changed, 954 insertions(+), 164 deletions(-) create mode 100644 app/code/Magento/MediaGallery/Model/AssetKeywords.php delete mode 100644 app/code/Magento/MediaGallery/Model/File/Command/DeleteByAssetId.php create mode 100644 app/code/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsByPaths.php create mode 100644 app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByIds.php create mode 100644 app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php create mode 100644 app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php rename app/code/Magento/MediaGallery/Model/{Keyword/Command => ResourceModel/Keyword}/SaveAssetLinks.php (84%) create mode 100644 app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/SaveAssetsKeywords.php create mode 100644 app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php rename app/code/Magento/MediaGalleryApi/{Model/Directory/Command/CreateByPathInterface.php => Api/CreateDirectoriesByPathsInterface.php} (60%) create mode 100644 app/code/Magento/MediaGalleryApi/Api/Data/AssetKeywordsInterface.php create mode 100644 app/code/Magento/MediaGalleryApi/Api/DeleteAssetsByPathsInterface.php rename app/code/Magento/MediaGalleryApi/{Model/Directory/Command/DeleteByPathInterface.php => Api/DeleteDirectoriesByPathsInterface.php} (65%) create mode 100644 app/code/Magento/MediaGalleryApi/Api/GetAssetsByIdsInterface.php create mode 100644 app/code/Magento/MediaGalleryApi/Api/GetAssetsByPathsInterface.php create mode 100644 app/code/Magento/MediaGalleryApi/Api/GetAssetsKeywordsInterface.php rename app/code/Magento/MediaGalleryApi/{Model/Directory/IsBlacklistedInterface.php => Api/IsPathBlacklistedInterface.php} (84%) create mode 100644 app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php create mode 100644 app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php delete mode 100644 app/code/Magento/MediaGalleryApi/Model/File/Command/DeleteByAssetIdInterface.php diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByDirectoryPath.php b/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByDirectoryPath.php index a50095fb3d8e7..8487a9cbb46db 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByDirectoryPath.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByDirectoryPath.php @@ -14,9 +14,8 @@ use Psr\Log\LoggerInterface; /** - * Class DeleteByDirectoryPath - * * Remove asset(s) that correspond the provided directory path + * @deprecated use \Magento\MediaGalleryApi\Api\DeleteAssetsByPathInterface instead */ class DeleteByDirectoryPath implements DeleteByDirectoryPathInterface { diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByPath.php b/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByPath.php index c05a08149bfca..eaf47b467e3a9 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByPath.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByPath.php @@ -15,6 +15,7 @@ /** * Class DeleteByPath + * @deprecated use \Magento\MediaGalleryApi\Api\DeleteAssetsByPathInterface instead */ class DeleteByPath implements DeleteByPathInterface { diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php b/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php index 4475d5570c988..9826ef7725023 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php @@ -17,6 +17,7 @@ /** * Get media asset by id + * @deprecated use \Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface instead */ class GetById implements GetByIdInterface { diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php b/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php index 32c7323c3a511..bebb7ea91c481 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php @@ -16,7 +16,8 @@ use Psr\Log\LoggerInterface; /** - * Class GetListByIds + * Class GetByPath + * @deprecated use \Magento\MediaGalleryApi\Api\GetAssetsByPathInterface instead */ class GetByPath implements GetByPathInterface { diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php index e017c4c58eb63..5d84b3ae29c80 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php @@ -16,6 +16,7 @@ /** * Class Save + * @deprecated use \Magento\MediaGalleryApi\Api\SaveAssetInterface instead */ class Save implements SaveInterface { diff --git a/app/code/Magento/MediaGallery/Model/AssetKeywords.php b/app/code/Magento/MediaGallery/Model/AssetKeywords.php new file mode 100644 index 0000000000000..95a060fccffcd --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/AssetKeywords.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model; + +use Magento\Framework\Model\AbstractExtensibleModel; +use Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface; +use Magento\MediaGalleryApi\Api\Data\AssetKeywordsExtensionInterface; + +/** + * Asset's Keywords + */ +class AssetKeywords extends AbstractExtensibleModel implements AssetKeywordsInterface +{ + private const ASSET_ID = 'asset_id'; + private const KEYWORDS = 'keywords'; + + /** + * @inheritdoc + */ + public function getAssetId(): int + { + return (int) $this->getData(self::ASSET_ID); + } + + /** + * @inheritdoc + */ + public function getKeywords(): array + { + return $this->getData(self::KEYWORDS); + } + + /** + * @inheritdoc + */ + public function getExtensionAttributes(): AssetKeywordsExtensionInterface + { + return $this->_getExtensionAttributes(); + } + + /** + * @inheritdoc + */ + public function setExtensionAttributes(AssetKeywordsExtensionInterface $extensionAttributes): void + { + $this->_setExtensionAttributes($extensionAttributes); + } +} diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php index c70f71df02a39..b85a9cf30ef51 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php @@ -9,13 +9,13 @@ use Magento\Cms\Model\Wysiwyg\Images\Storage; use Magento\Framework\Exception\CouldNotSaveException; -use Magento\MediaGalleryApi\Model\Directory\Command\CreateByPathInterface; +use Magento\MediaGalleryApi\Api\CreateDirectoriesByPathsInterface; use Psr\Log\LoggerInterface; /** * Create folder by provided path */ -class CreateByPath implements CreateByPathInterface +class CreateByPath implements CreateDirectoriesByPathsInterface { /** * @var LoggerInterface @@ -40,19 +40,31 @@ public function __construct( } /** - * Create new directory by the provided path in the media storage - * - * @param string $path - * @param string $name - * @throws CouldNotSaveException + * @inheritdoc */ - public function execute(string $path, string $name): void + public function execute(array $paths): void { - try { - $this->storage->createDirectory($name, $this->storage->getCmsWysiwygImages()->getStorageRoot() . $path); - } catch (\Exception $exception) { - $this->logger->critical($exception); - throw new CouldNotSaveException(__('Failed to create the folder'), $exception); + $failedPaths = []; + foreach ($paths as $path) { + try { + $name = end(explode('/', $path)); + $this->storage->createDirectory( + $name, + $this->storage->getCmsWysiwygImages()->getStorageRoot() . $path + ); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $failedPaths[] = $path; + } + } + + if (!empty($failedPaths)) { + throw new CouldNotSaveException( + __( + 'Could not save directories: %paths', + implode(' ,', $failedPaths) + ) + ); } } } diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php b/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php index 73f0e08add751..c6b2f396e364e 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php @@ -9,13 +9,13 @@ use Magento\Cms\Model\Wysiwyg\Images\Storage; use Magento\Framework\Exception\CouldNotDeleteException; -use Magento\MediaGalleryApi\Model\Directory\Command\DeleteByPathInterface; +use Magento\MediaGalleryApi\Api\DeleteDirectoriesByPathsInterface; use Psr\Log\LoggerInterface; /** * Delete directory from media storage by path */ -class DeleteByPath implements DeleteByPathInterface +class DeleteByPath implements DeleteDirectoriesByPathsInterface { /** * @var LoggerInterface @@ -40,18 +40,27 @@ public function __construct( } /** - * Removes directory and corresponding thumbnails directory from media storage if not in blacklist - * - * @param string $path - * @throws CouldNotDeleteException + * @inheritdoc */ - public function execute(string $path): void + public function execute(array $paths): void { - try { - $this->storage->deleteDirectory($this->storage->getCmsWysiwygImages()->getStorageRoot() . $path); - } catch (\Exception $exception) { - $this->logger->critical($exception); - throw new CouldNotDeleteException(__('Failed to delete the folder'), $exception); + $failedPaths = []; + foreach ($paths as $path) { + try { + $this->storage->deleteDirectory($this->storage->getCmsWysiwygImages()->getStorageRoot() . $path); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $failedPaths[] = $path; + } + } + + if (!empty($failedPaths)) { + throw new CouldNotDeleteException( + __( + 'Could not delete directories: %paths', + implode(' ,', $failedPaths) + ) + ); } } } diff --git a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php index 3ec50eaac4b9e..d2e59b5613b4a 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php +++ b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php @@ -7,12 +7,12 @@ namespace Magento\MediaGallery\Model\Directory; -use Magento\MediaGalleryApi\Model\Directory\IsBlacklistedInterface; +use Magento\MediaGalleryApi\Api\IsPathBlacklistedInterface; /** * Check if the path is blacklisted for media gallery. Directory path may be blacklisted if it's reserved by the system */ -class IsBlacklisted implements IsBlacklistedInterface +class IsBlacklisted implements IsPathBlacklistedInterface { /** * @var Config diff --git a/app/code/Magento/MediaGallery/Model/File/Command/DeleteByAssetId.php b/app/code/Magento/MediaGallery/Model/File/Command/DeleteByAssetId.php deleted file mode 100644 index dff91e73c8c7a..0000000000000 --- a/app/code/Magento/MediaGallery/Model/File/Command/DeleteByAssetId.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaGallery\Model\File\Command; - -use Magento\Cms\Model\Wysiwyg\Images\Storage; -use Magento\Framework\App\Filesystem\DirectoryList; -use Magento\Framework\Exception\LocalizedException; -use Magento\Framework\Filesystem; -use Magento\MediaGalleryApi\Model\File\Command\DeleteByAssetIdInterface; -use Magento\MediaGalleryApi\Model\Asset\Command\GetByIdInterface; - -/** - * Load Media Asset path from database by id and delete the file - */ -class DeleteByAssetId implements DeleteByAssetIdInterface -{ - /** - * @var GetByIdInterface - */ - private $getAssetById; - - /** - * @var Storage - */ - private $imagesStorage; - - /** - * @var Filesystem - */ - private $filesystem; - - /** - * DeleteAssetById constructor. - * - * @param GetByIdInterface $getAssetById - * @param Storage $imagesStorage - * @param Filesystem $filesystem - */ - public function __construct( - GetByIdInterface $getAssetById, - Storage $imagesStorage, - Filesystem $filesystem - ) { - $this->getAssetById = $getAssetById; - $this->imagesStorage = $imagesStorage; - $this->filesystem = $filesystem; - } - - /** - * Delete image by asset ID - * - * @param int $assetId - * @return void - * @throws LocalizedException - */ - public function execute(int $assetId): void - { - $mediaFilePath = $this->getAssetById->execute($assetId)->getPath(); - $mediaDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA); - - if (!$mediaDirectory->isFile($mediaFilePath)) { - throw new LocalizedException(__('File "%1" does not exist in media directory.', $mediaFilePath)); - } - - $this->imagesStorage->deleteFile($mediaDirectory->getAbsolutePath() . $mediaFilePath); - } -} diff --git a/app/code/Magento/MediaGallery/Model/Keyword.php b/app/code/Magento/MediaGallery/Model/Keyword.php index c5c60d3152846..18600af0dfc6c 100644 --- a/app/code/Magento/MediaGallery/Model/Keyword.php +++ b/app/code/Magento/MediaGallery/Model/Keyword.php @@ -18,7 +18,6 @@ class Keyword extends AbstractExtensibleModel implements KeywordInterface { private const ID = 'id'; - private const KEYWORD = 'keyword'; /** @@ -40,7 +39,7 @@ public function getId(): ?int */ public function getKeyword(): string { - return (string)$this->getData(self::KEYWORD); + return (string) $this->getData(self::KEYWORD); } /** diff --git a/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php b/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php index 6cd8bd2463a2c..4112b717c24a2 100644 --- a/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php +++ b/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php @@ -16,6 +16,7 @@ /** * Retrieve keywords for the media asset + * @deprecated use \Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface instead */ class GetAssetKeywords implements GetAssetKeywordsInterface { diff --git a/app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetKeywords.php b/app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetKeywords.php index b355a9a651cd4..748b1e0d2463a 100644 --- a/app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetKeywords.php +++ b/app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetKeywords.php @@ -7,16 +7,18 @@ namespace Magento\MediaGallery\Model\Keyword\Command; -use Magento\MediaGalleryApi\Api\Data\KeywordInterface; -use Magento\MediaGalleryApi\Model\Keyword\Command\SaveAssetKeywordsInterface; use Magento\Framework\App\ResourceConnection; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\DB\Adapter\Pdo\Mysql; use Magento\Framework\Exception\CouldNotSaveException; +use Magento\MediaGallery\Model\ResourceModel\Keyword\SaveAssetLinks; +use Magento\MediaGalleryApi\Api\Data\KeywordInterface; +use Magento\MediaGalleryApi\Model\Keyword\Command\SaveAssetKeywordsInterface; use Psr\Log\LoggerInterface; /** * Class SaveAssetKeywords + * @deprecated use \Magento\MediaGalleryApi\Api\SaveAssetKeywordsInterface instead */ class SaveAssetKeywords implements SaveAssetKeywordsInterface { diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsByPaths.php b/app/code/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsByPaths.php new file mode 100644 index 0000000000000..c263b3937e0d2 --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsByPaths.php @@ -0,0 +1,100 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model\ResourceModel; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface; +use Psr\Log\LoggerInterface; + +/** + * Remove asset(s) that correspond the provided path + */ +class DeleteAssetsByPaths implements DeleteAssetsByPathsInterface +{ + private const TABLE_MEDIA_GALLERY_ASSET = 'media_gallery_asset'; + private const MEDIA_GALLERY_ASSET_PATH = 'path'; + + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * DeleteById constructor. + * + * @param ResourceConnection $resourceConnection + * @param LoggerInterface $logger + */ + public function __construct( + ResourceConnection $resourceConnection, + LoggerInterface $logger + ) { + $this->resourceConnection = $resourceConnection; + $this->logger = $logger; + } + + /** + * @inheritdoc + */ + public function execute(array $paths): void + { + $failedPaths = []; + + foreach ($paths as $path) { + try { + $this->validateDirectoryPath($path); + $this->deleteAssetsByDirectoryPath($path); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $failedPaths[] = $path; + } + } + + if (!empty($failedPaths)) { + throw new CouldNotDeleteException( + __( + 'Could not delete media assets by paths: %paths', + [ + 'paths' => implode(' ,', $failedPaths) + ] + ) + ); + } + } + + private function deleteAssetsByDirectoryPath(string $path) + { + // Make sure that the path has a trailing slash + $path = rtrim($path, '/') . '/'; + + /** @var AdapterInterface $connection */ + $connection = $this->resourceConnection->getConnection(); + $tableName = $this->resourceConnection->getTableName(self::TABLE_MEDIA_GALLERY_ASSET); + $connection->delete($tableName, [self::MEDIA_GALLERY_ASSET_PATH . ' LIKE ?' => $path . '%']); + } + + /** + * Validate the directory path + * + * @param string $path + * @throws CouldNotDeleteException + */ + private function validateDirectoryPath(string $path): void + { + if (!$path || trim($path) === '') { + throw new CouldNotDeleteException(__('Cannot remove assets, the directory path does not exist')); + } + } +} diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByIds.php b/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByIds.php new file mode 100644 index 0000000000000..ec3183e481370 --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByIds.php @@ -0,0 +1,80 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model\ResourceModel; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\Exception\LocalizedException; +use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory; +use Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface; +use Psr\Log\LoggerInterface; + +/** + * Get media assets by ids + */ +class GetAssetsByIds implements GetAssetsByIdsInterface +{ + private const TABLE_MEDIA_GALLERY_ASSET = 'media_gallery_asset'; + + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var AssetInterfaceFactory + */ + private $assetFactory; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * GetById constructor. + * + * @param ResourceConnection $resourceConnection + * @param AssetInterfaceFactory $assetFactory + * @param LoggerInterface $logger + */ + public function __construct( + ResourceConnection $resourceConnection, + AssetInterfaceFactory $assetFactory, + LoggerInterface $logger + ) { + $this->resourceConnection = $resourceConnection; + $this->assetFactory = $assetFactory; + $this->logger = $logger; + } + + /** + * @inheritdoc + */ + public function execute(array $ids): array + { + try { + $mediaAssetTable = $this->resourceConnection->getTableName(self::TABLE_MEDIA_GALLERY_ASSET); + $connection = $this->resourceConnection->getConnection(); + $select = $connection->select() + ->from(['amg' => $mediaAssetTable]) + ->where('amg.id IN (?)', $ids); + $assetsData = $connection->query($select)->fetchAll(); + } catch (\Exception $exception) { + $this->logger->critical($exception); + throw new LocalizedException(__('Could not retrieve media assets'), $exception); + } + + $assets = []; + + foreach ($assetsData as $assetData) { + $assets[] = $this->assetFactory->create(['data' => $assetData]); + } + + return $assets; + } +} diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php b/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php new file mode 100644 index 0000000000000..78aa5fe471df9 --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php @@ -0,0 +1,87 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model\ResourceModel; + +use Magento\Framework\Exception\LocalizedException; +use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory; +use Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface; +use Magento\Framework\App\ResourceConnection; +use Psr\Log\LoggerInterface; + +/** + * Class GetByPath + */ +class GetAssetsByPaths implements GetAssetsByPathsInterface +{ + private const TABLE_MEDIA_GALLERY_ASSET = 'media_gallery_asset'; + private const MEDIA_GALLERY_ASSET_PATH = 'path'; + + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var AssetInterfaceFactory + */ + private $mediaAssetFactory; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * GetByPath constructor. + * + * @param ResourceConnection $resourceConnection + * @param AssetInterfaceFactory $mediaAssetFactory + * @param LoggerInterface $logger + */ + public function __construct( + ResourceConnection $resourceConnection, + AssetInterfaceFactory $mediaAssetFactory, + LoggerInterface $logger + ) { + $this->resourceConnection = $resourceConnection; + $this->mediaAssetFactory = $mediaAssetFactory; + $this->logger = $logger; + } + + /** + * @inheritdoc + */ + public function execute(array $paths): array + { + try { + $connection = $this->resourceConnection->getConnection(); + $select = $connection->select() + ->from($this->resourceConnection->getTableName(self::TABLE_MEDIA_GALLERY_ASSET)) + ->where(self::MEDIA_GALLERY_ASSET_PATH . ' IN (?)', $paths); + $assetsData = $connection->query($select)->fetchAll(); + } catch (\Exception $exception) { + $this->logger->critical($exception); + throw new LocalizedException( + __( + 'Could not get media assets for paths: %paths', + [ + 'paths' => implode(' ,', $paths) + ] + ) + ); + } + + $assets = []; + + foreach ($assetsData as $assetData) { + $assets[] = $this->mediaAssetFactory->create(['data' => $assetData]); + } + + return $assets; + } +} diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php new file mode 100644 index 0000000000000..a83c6e28b2d94 --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php @@ -0,0 +1,128 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model\ResourceModel\Keyword; + +use Magento\Framework\Exception\IntegrationException; +use Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface; +use Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterfaceFactory; +use Magento\MediaGalleryApi\Api\Data\KeywordInterface; +use Magento\MediaGalleryApi\Api\Data\KeywordInterfaceFactory; +use Magento\MediaGalleryApi\Api\GetAssetsKeywordsInterface; +use Magento\Framework\App\ResourceConnection; +use Psr\Log\LoggerInterface; + +/** + * Retrieve keywords for the media asset + */ +class GetAssetsKeywords implements GetAssetsKeywordsInterface +{ + private const TABLE_KEYWORD = 'media_gallery_keyword'; + private const TABLE_ASSET_KEYWORD = 'media_gallery_asset_keyword'; + private const FIELD_ASSET_ID = 'asset_id'; + + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var KeywordInterfaceFactory + */ + private $keywordFactory; + + /** + * @var AssetKeywordsInterfaceFactory + */ + private $assetKeywordsFactory; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * @param AssetKeywordsInterfaceFactory $assetKeywordsFactory + * @param ResourceConnection $resourceConnection + * @param KeywordInterfaceFactory $keywordFactory + * @param LoggerInterface $logger + */ + public function __construct( + AssetKeywordsInterfaceFactory $assetKeywordsFactory, + ResourceConnection $resourceConnection, + KeywordInterfaceFactory $keywordFactory, + LoggerInterface $logger + ) { + $this->assetKeywordsFactory = $assetKeywordsFactory; + $this->resourceConnection = $resourceConnection; + $this->keywordFactory = $keywordFactory; + $this->logger = $logger; + } + + /** + * @inheritdoc + */ + public function execute(array $assetIds): array + { + try { + $this->getAssetKeywords($this->getKeywordsData($assetIds)); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $message = __('An error occurred during get asset keywords: %1', $exception->getMessage()); + throw new IntegrationException($message, $exception); + } + } + + /** + * Load keywords data + * + * @param array $assetIds + * @return array + * @throws \Zend_Db_Statement_Exception + */ + private function getKeywordsData(array $assetIds): array + { + $connection = $this->resourceConnection->getConnection(); + $select = $connection->select() + ->from(['k' => $this->resourceConnection->getTableName(self::TABLE_KEYWORD)]) + ->join(['ak' => self::TABLE_ASSET_KEYWORD], 'k.id = ak.keyword_id') + ->where('ak.asset_id IN (?)', $assetIds); + return $connection->query($select)->fetchAll(); + } + + /** + * Build AssetKeywords objects array + * + * @param array $keywordsData + * @return AssetKeywordsInterface[] + */ + private function getAssetKeywords(array $keywordsData): array + { + $keywordsByAsset = []; + foreach ($keywordsData as $keywordData) { + $keywordsByAsset[$keywordData[self::FIELD_ASSET_ID]][] = $this->keywordFactory->create( + [ + 'data' => $keywordData + ] + ); + } + + $assetKeywords = []; + foreach ($keywordsByAsset as $assetId => $keywords) { + $assetKeywords[] = $this->assetKeywordsFactory->create( + [ + 'data' => [ + 'asset_id' => $assetId, + 'keywords' => $keywords + ] + ] + ); + } + + return $assetKeywords; + } +} diff --git a/app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetLinks.php b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/SaveAssetLinks.php similarity index 84% rename from app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetLinks.php rename to app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/SaveAssetLinks.php index 4d3fd2bb5c30d..3437cc1c519e8 100644 --- a/app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetLinks.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/SaveAssetLinks.php @@ -5,18 +5,17 @@ */ declare(strict_types=1); -namespace Magento\MediaGallery\Model\Keyword\Command; +namespace Magento\MediaGallery\Model\ResourceModel\Keyword; -use Magento\MediaGalleryApi\Api\Data\KeywordInterface; -use Magento\MediaGalleryApi\Model\Keyword\Command\SaveAssetLinksInterface; use Magento\Framework\App\ResourceConnection; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\DB\Adapter\Pdo\Mysql; use Magento\Framework\Exception\CouldNotSaveException; +use Magento\MediaGalleryApi\Api\Data\KeywordInterface; use Psr\Log\LoggerInterface; /** - * Class SaveAssetLinks + * Save links between asset and keyword to media_gallery_asset_keyword table */ class SaveAssetLinks { @@ -35,8 +34,6 @@ class SaveAssetLinks private $logger; /** - * SaveAssetLinks constructor. - * * @param ResourceConnection $resourceConnection * @param LoggerInterface $logger */ @@ -76,8 +73,10 @@ public function execute(int $assetId, array $keywordIds): void } } catch (\Exception $exception) { $this->logger->critical($exception); - $message = __('An error occurred during save asset keyword links: %1', $exception->getMessage()); - throw new CouldNotSaveException($message, $exception); + throw new CouldNotSaveException( + __('Could not save asset keyword links'), + $exception + ); } } } diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/SaveAssetsKeywords.php b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/SaveAssetsKeywords.php new file mode 100644 index 0000000000000..cb64c3173dfc9 --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/SaveAssetsKeywords.php @@ -0,0 +1,128 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model\ResourceModel\Keyword; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\DB\Adapter\Pdo\Mysql; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\MediaGalleryApi\Api\Data\KeywordInterface; +use Magento\MediaGalleryApi\Api\SaveAssetsKeywordsInterface; +use Psr\Log\LoggerInterface; + +/** + * Save keywords of assets + */ +class SaveAssetsKeywords implements SaveAssetsKeywordsInterface +{ + private const TABLE_KEYWORD = 'media_gallery_keyword'; + private const ID = 'id'; + private const KEYWORD = 'keyword'; + + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var SaveAssetLinks + */ + private $saveAssetLinks; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * SaveAssetKeywords constructor. + * + * @param ResourceConnection $resourceConnection + * @param SaveAssetLinks $saveAssetLinks + * @param LoggerInterface $logger + */ + public function __construct( + ResourceConnection $resourceConnection, + SaveAssetLinks $saveAssetLinks, + LoggerInterface $logger + ) { + $this->resourceConnection = $resourceConnection; + $this->saveAssetLinks = $saveAssetLinks; + $this->logger = $logger; + } + + /** + * @inheritdoc + */ + public function execute(array $assetKeywords): void + { + $failedAssetIds = []; + foreach ($assetKeywords as $assetKeyword) { + try { + $this->saveAssetKeywords($assetKeyword->getKeywords(), $assetKeyword->getAssetId()); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $failedAssetIds[] = $assetKeyword->getAssetId(); + } + } + + if (!empty($failedAssetIds)) { + throw new CouldNotSaveException( + __('Could not save keywords for asset ids: %ids', ['ids' => implode(' ,', $failedAssetIds)]) + ); + } + } + + /** + * Save asset keywords. + * + * @param KeywordInterface[] $keywords + * @param int $assetId + * @throws CouldNotSaveException + * @throws \Zend_Db_Exception + */ + private function saveAssetKeywords(array $keywords, int $assetId): void + { + $data = []; + foreach ($keywords as $keyword) { + $data[] = $keyword->getKeyword(); + } + + if (empty($data)) { + return; + } + + /** @var Mysql $connection */ + $connection = $this->resourceConnection->getConnection(); + $connection->insertArray( + $this->resourceConnection->getTableName(self::TABLE_KEYWORD), + [self::KEYWORD], + $data, + AdapterInterface::INSERT_IGNORE + ); + + $this->saveAssetLinks->execute($assetId, $this->getKeywordIds($data)); + } + + /** + * Select keywords by names + * + * @param string[] $keywords + * @return int[] + */ + private function getKeywordIds(array $keywords): array + { + $connection = $this->resourceConnection->getConnection(); + $select = $connection->select() + ->from(['k' => $this->resourceConnection->getTableName(self::TABLE_KEYWORD)]) + ->columns(self::ID) + ->where('k.' . self::KEYWORD . ' in (?)', $keywords); + + return $connection->fetchCol($select); + } +} diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php b/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php new file mode 100644 index 0000000000000..e75acca66d0f4 --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php @@ -0,0 +1,88 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model\ResourceModel; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Reflection\DataObjectProcessor; +use Magento\MediaGalleryApi\Api\Data\AssetInterface; +use Magento\MediaGalleryApi\Api\SaveAssetsInterface; +use Psr\Log\LoggerInterface; + +/** + * Save media asset to the database + */ +class SaveAssets implements SaveAssetsInterface +{ + private const TABLE_MEDIA_GALLERY_ASSET = 'media_gallery_asset'; + + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var DataObjectProcessor + */ + private $objectProcessor; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * Save constructor. + * + * @param ResourceConnection $resourceConnection + * @param DataObjectProcessor $objectProcessor + * @param LoggerInterface $logger + */ + public function __construct( + ResourceConnection $resourceConnection, + DataObjectProcessor $objectProcessor, + LoggerInterface $logger + ) { + $this->resourceConnection = $resourceConnection; + $this->objectProcessor = $objectProcessor; + $this->logger = $logger; + } + + /** + * @inheritdoc + */ + public function execute(array $assets): void + { + $connection = $this->resourceConnection->getConnection(); + $tableName = $this->resourceConnection->getTableName(self::TABLE_MEDIA_GALLERY_ASSET); + + $failedAssets = []; + foreach ($assets as $asset) { + try { + $connection->insertOnDuplicate( + $tableName, + array_filter($this->objectProcessor->buildOutputDataArray($asset, AssetInterface::class)) + ); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $failedAssets[] = $asset; + } + } + + if (!empty($failedAssets)) { + throw new CouldNotSaveException( + __( + 'Could not save the media assets: %assets', + [ + 'assets' => $failedAssets + ] + ) + ); + } + } +} diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetKeywordsTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetKeywordsTest.php index a55c60024c08d..031213b873a25 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetKeywordsTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetKeywordsTest.php @@ -13,7 +13,7 @@ use Magento\Framework\DB\Select; use Magento\Framework\Exception\CouldNotSaveException; use Magento\MediaGallery\Model\Keyword\Command\SaveAssetKeywords; -use Magento\MediaGallery\Model\Keyword\Command\SaveAssetLinks; +use Magento\MediaGallery\Model\ResourceModel\Keyword\SaveAssetLinks; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetLinksTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetLinksTest.php index 2981c534586e2..e029ae585169c 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetLinksTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetLinksTest.php @@ -7,10 +7,10 @@ namespace Magento\MediaGallery\Test\Unit\Model\Keyword\Command; -use Magento\MediaGallery\Model\Keyword\Command\SaveAssetLinks; use Magento\Framework\App\ResourceConnection; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\Exception\CouldNotSaveException; +use Magento\MediaGallery\Model\ResourceModel\Keyword\SaveAssetLinks; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index bfbab191e68d3..25f4850427929 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -8,6 +8,7 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Magento\MediaGalleryApi\Api\Data\KeywordInterface" type="Magento\MediaGallery\Model\Keyword"/> <preference for="Magento\MediaGalleryApi\Api\Data\AssetInterface" type="Magento\MediaGallery\Model\Asset"/> + <preference for="Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface" type="Magento\MediaGallery\Model\AssetKeywords"/> <preference for="Magento\MediaGalleryApi\Model\Asset\Command\GetByIdInterface" type="Magento\MediaGallery\Model\Asset\Command\GetById"/> <preference for="Magento\MediaGalleryApi\Model\Asset\Command\SaveInterface" type="Magento\MediaGallery\Model\Asset\Command\Save"/> @@ -17,14 +18,18 @@ <preference for="Magento\MediaGalleryApi\Model\Keyword\Command\GetAssetKeywordsInterface" type="Magento\MediaGallery\Model\Keyword\Command\GetAssetKeywords"/> <preference for="Magento\MediaGalleryApi\Model\Keyword\Command\SaveAssetKeywordsInterface" type="Magento\MediaGallery\Model\Keyword\Command\SaveAssetKeywords"/> - <preference for="Magento\MediaGalleryApi\Model\Keyword\Command\SaveAssetLinksInterface" type="Magento\MediaGallery\Model\Keyword\Command\SaveAssetLinks"/> - <preference for="Magento\MediaGalleryApi\Model\Directory\Command\CreateByPathInterface" type="Magento\MediaGallery\Model\Directory\Command\CreateByPath"/> - <preference for="Magento\MediaGalleryApi\Model\Directory\Command\DeleteByPathInterface" type="Magento\MediaGallery\Model\Directory\Command\DeleteByPath"/> + <preference for="Magento\MediaGalleryApi\Api\CreateDirectoriesByPathsInterface" type="Magento\MediaGallery\Model\Directory\Command\CreateByPath"/> + <preference for="Magento\MediaGalleryApi\Api\DeleteDirectoriesByPathsInterface" type="Magento\MediaGallery\Model\Directory\Command\DeleteByPath"/> - <preference for="Magento\MediaGalleryApi\Model\Directory\IsBlacklistedInterface" type="Magento\MediaGallery\Model\Directory\IsBlacklisted"/> + <preference for="Magento\MediaGalleryApi\Api\IsPathBlacklistedInterface" type="Magento\MediaGallery\Model\Directory\IsBlacklisted"/> - <preference for="Magento\MediaGalleryApi\Model\File\Command\DeleteByAssetIdInterface" type="Magento\MediaGallery\Model\File\Command\DeleteByAssetId"/> + <preference for="Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface" type="Magento\MediaGallery\Model\ResourceModel\DeleteAssetsByPaths"/> + <preference for="Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface" type="Magento\MediaGallery\Model\ResourceModel\GetAssetsByIds"/> + <preference for="Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface" type="Magento\MediaGallery\Model\ResourceModel\GetAssetsByPaths"/> + <preference for="Magento\MediaGalleryApi\Api\SaveAssetsInterface" type="Magento\MediaGallery\Model\ResourceModel\SaveAssets"/> + <preference for="Magento\MediaGalleryApi\Api\GetAssetsKeywordsInterface" type="Magento\MediaGallery\Model\ResourceModel\Keyword\GetAssetsKeywords"/> + <preference for="Magento\MediaGalleryApi\Api\SaveAssetsKeywordsInterface" type="Magento\MediaGallery\Model\ResourceModel\Keyword\SaveAssetsKeywords"/> <type name="Magento\Catalog\Model\Product\Gallery\Processor"> <plugin name="media_gallery_image_remove_metadata" type="Magento\MediaGallery\Plugin\Product\Gallery\Processor" diff --git a/app/code/Magento/MediaGalleryApi/Model/Directory/Command/CreateByPathInterface.php b/app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php similarity index 60% rename from app/code/Magento/MediaGalleryApi/Model/Directory/Command/CreateByPathInterface.php rename to app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php index 59a371cdb823f..51cef91b703ae 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Directory/Command/CreateByPathInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php @@ -5,20 +5,19 @@ */ declare(strict_types=1); -namespace Magento\MediaGalleryApi\Model\Directory\Command; +namespace Magento\MediaGalleryApi\Api; /** * Create folder by provided path * @api */ -interface CreateByPathInterface +interface CreateDirectoriesByPathsInterface { /** * Create new directory by provided path * - * @param string $path - * @param string $name + * @param string[] $paths * @throws \Magento\Framework\Exception\CouldNotSaveException */ - public function execute(string $path, string $name): void; + public function execute(array $paths): void; } diff --git a/app/code/Magento/MediaGalleryApi/Api/Data/AssetKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Api/Data/AssetKeywordsInterface.php new file mode 100644 index 0000000000000..e4356f05a1ece --- /dev/null +++ b/app/code/Magento/MediaGalleryApi/Api/Data/AssetKeywordsInterface.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGalleryApi\Api\Data; + +use Magento\MediaGalleryApi\Api\Data\AssetKeywordsExtensionInterface; +use Magento\Framework\Api\ExtensibleDataInterface; + +/** + * Interface for asset's keywords aggregation + * @api + */ +interface AssetKeywordsInterface extends ExtensibleDataInterface +{ + /** + * Get ID + * + * @return int + */ + public function getAssetId(): int; + + /** + * Get the keyword + * + * @return KeywordInterface[] + */ + public function getKeywords(): array; + + + /** + * Get extension attributes + * + * @return \Magento\MediaGalleryApi\Api\Data\AssetKeywordsExtensionInterface|null + */ + public function getExtensionAttributes(): AssetKeywordsExtensionInterface; + + /** + * Set extension attributes + * + * @param \Magento\MediaGalleryApi\Api\Data\AssetKeywordsExtensionInterface $extensionAttributes + * @return void + */ + public function setExtensionAttributes(AssetKeywordsExtensionInterface $extensionAttributes): void; +} diff --git a/app/code/Magento/MediaGalleryApi/Api/DeleteAssetsByPathsInterface.php b/app/code/Magento/MediaGalleryApi/Api/DeleteAssetsByPathsInterface.php new file mode 100644 index 0000000000000..2651638fc024c --- /dev/null +++ b/app/code/Magento/MediaGalleryApi/Api/DeleteAssetsByPathsInterface.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\MediaGalleryApi\Api; + +/** + * Delete media asset by exact or directory path + * @api + */ +interface DeleteAssetsByPathsInterface +{ + /** + * Delete media assets by path + * + * @param string[] $paths + * @return void + */ + public function execute(array $paths): void; +} diff --git a/app/code/Magento/MediaGalleryApi/Model/Directory/Command/DeleteByPathInterface.php b/app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php similarity index 65% rename from app/code/Magento/MediaGalleryApi/Model/Directory/Command/DeleteByPathInterface.php rename to app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php index d43d7199ef4f1..397c4b45590a6 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Directory/Command/DeleteByPathInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php @@ -5,19 +5,19 @@ */ declare(strict_types=1); -namespace Magento\MediaGalleryApi\Model\Directory\Command; +namespace Magento\MediaGalleryApi\Api; /** * Delete folder by provided path * @api */ -interface DeleteByPathInterface +interface DeleteDirectoriesByPathsInterface { /** * Deletes the existing folder * - * @param string $path + * @param string[] $paths * @throws \Magento\Framework\Exception\CouldNotDeleteException */ - public function execute(string $path): void; + public function execute(array $paths): void; } diff --git a/app/code/Magento/MediaGalleryApi/Api/GetAssetsByIdsInterface.php b/app/code/Magento/MediaGalleryApi/Api/GetAssetsByIdsInterface.php new file mode 100644 index 0000000000000..a4d56b501b6d0 --- /dev/null +++ b/app/code/Magento/MediaGalleryApi/Api/GetAssetsByIdsInterface.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\MediaGalleryApi\Api; + +/** + * A command represents the get media gallery asset by using media gallery asset id as a filter parameter. + * @api + */ +interface GetAssetsByIdsInterface +{ + /** + * Get media asset by id + * + * @param int[] $ids + * @return \Magento\MediaGalleryApi\Api\Data\AssetInterface[] + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function execute(array $ids): array; +} diff --git a/app/code/Magento/MediaGalleryApi/Api/GetAssetsByPathsInterface.php b/app/code/Magento/MediaGalleryApi/Api/GetAssetsByPathsInterface.php new file mode 100644 index 0000000000000..ef64b73112155 --- /dev/null +++ b/app/code/Magento/MediaGalleryApi/Api/GetAssetsByPathsInterface.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGalleryApi\Api; + +/** + * A command represents the get media gallery asset by using media gallery asset path as a filter parameter. + * @api + */ +interface GetAssetsByPathsInterface +{ + /** + * Get media asset list + * + * @param string[] $paths + * @return \Magento\MediaGalleryApi\Api\Data\AssetInterface[] + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function execute(array $paths): array; +} diff --git a/app/code/Magento/MediaGalleryApi/Api/GetAssetsKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Api/GetAssetsKeywordsInterface.php new file mode 100644 index 0000000000000..c919d6b4d0fee --- /dev/null +++ b/app/code/Magento/MediaGalleryApi/Api/GetAssetsKeywordsInterface.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGalleryApi\Api; + +/** + * A command represents functionality to get a media gallery asset keywords filtered by media gallery asset id. + * @api + */ +interface GetAssetsKeywordsInterface +{ + /** + * Get assets related keywords. + * + * @param int[] $assetIds + * @return \Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface[] + */ + public function execute(array $assetIds): array; +} diff --git a/app/code/Magento/MediaGalleryApi/Model/Directory/IsBlacklistedInterface.php b/app/code/Magento/MediaGalleryApi/Api/IsPathBlacklistedInterface.php similarity index 84% rename from app/code/Magento/MediaGalleryApi/Model/Directory/IsBlacklistedInterface.php rename to app/code/Magento/MediaGalleryApi/Api/IsPathBlacklistedInterface.php index bc01bcdc77912..b2e5afabee11e 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Directory/IsBlacklistedInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/IsPathBlacklistedInterface.php @@ -5,13 +5,13 @@ */ declare(strict_types=1); -namespace Magento\MediaGalleryApi\Model\Directory; +namespace Magento\MediaGalleryApi\Api; /** * Directory paths that are reserved by system and not be included in the media gallery * @api */ -interface IsBlacklistedInterface +interface IsPathBlacklistedInterface { /** * Check if the path is excluded from displaying and processing in the media gallery diff --git a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php new file mode 100644 index 0000000000000..52ff1670ec3ab --- /dev/null +++ b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\MediaGalleryApi\Api; + +use Magento\MediaGalleryApi\Api\Data\AssetInterface; + +/** + * A command which executes the media gallery asset save operation. + * @api + */ +interface SaveAssetsInterface +{ + /** + * Save media asset and return the media asset id + * + * @param \Magento\MediaGalleryApi\Api\Data\AssetInterface[] $assets + * @throws \Magento\Framework\Exception\CouldNotSaveException + */ + public function execute(array $assets): void; +} diff --git a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php new file mode 100644 index 0000000000000..0aa64710802d5 --- /dev/null +++ b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGalleryApi\Api; + +/** + * A command represents the media gallery asset keywords save operation. + * @api + */ +interface SaveAssetsKeywordsInterface +{ + /** + * Save asset keywords. + * + * @param \Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface[] $assetKeywords + * @throws \Magento\Framework\Exception\CouldNotSaveException + */ + public function execute(array $assetKeywords): void; +} diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByDirectoryPathInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByDirectoryPathInterface.php index ee012c068a697..f4189308f12b5 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByDirectoryPathInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByDirectoryPathInterface.php @@ -11,7 +11,7 @@ /** * A command represents the media gallery assets delete action. A media gallery asset is filtered by directory * path value. - * @api + * @deprecated use \Magento\MediaGalleryApi\Api\DeleteAssetsByPathInterface instead */ interface DeleteByDirectoryPathInterface { diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php index 0f04eaecf02ec..94641b8135818 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php @@ -10,7 +10,7 @@ /** * A command represents the media gallery asset delete action. A media gallery asset is filtered by path value. - * @api + * @deprecated use \Magento\MediaGalleryApi\Api\DeleteAssetsByPathInterface instead */ interface DeleteByPathInterface { diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php index 9d0b8863baf22..3a8d0aa9aad98 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php @@ -10,7 +10,7 @@ /** * A command represents the get media gallery asset by using media gallery asset id as a filter parameter. - * @api + * @deprecated use \Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface instead */ interface GetByIdInterface { diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php index aa3f76f721374..092a16ba053e2 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php @@ -10,7 +10,7 @@ /** * A command represents the get media gallery asset by using media gallery asset path as a filter parameter. - * @api + * @deprecated use \Magento\MediaGalleryApi\Api\GetAssetsByPathInterface instead */ interface GetByPathInterface { diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php index 77f8fcf8b2c2e..96779238ec942 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php @@ -12,7 +12,7 @@ /** * A command which executes the media gallery asset save operation. - * @api + * @deprecated use \Magento\MediaGalleryApi\Api\SaveAssetInterface instead */ interface SaveInterface { diff --git a/app/code/Magento/MediaGalleryApi/Model/File/Command/DeleteByAssetIdInterface.php b/app/code/Magento/MediaGalleryApi/Model/File/Command/DeleteByAssetIdInterface.php deleted file mode 100644 index 5d973eb785abf..0000000000000 --- a/app/code/Magento/MediaGalleryApi/Model/File/Command/DeleteByAssetIdInterface.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\MediaGalleryApi\Model\File\Command; - -/** - * Remove the media asset file from the media storage - * @api - */ -interface DeleteByAssetIdInterface -{ - /** - * Remove the file of the media asset identified by the passed id from the media storage - * - * @param int $assetId - * @return void - * @throws \Magento\Framework\Exception\LocalizedException - */ - public function execute(int $assetId): void; -} diff --git a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php index 613301c0fd210..7f29a6b5f508e 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php @@ -9,7 +9,7 @@ /** * A command represents functionality to get a media gallery asset keywords filtered by media gallery asset id. - * @api + * @deprecated use \Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface instead */ interface GetAssetKeywordsInterface { diff --git a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php index 3c305a29296e7..05467d9dc0a80 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php @@ -9,7 +9,7 @@ /** * A command represents the media gallery asset keywords save operation. - * @api + * @deprecated use \Magento\MediaGalleryApi\Api\SaveAssetKeywordsInterface instead */ interface SaveAssetKeywordsInterface { diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php index ad28d180fb899..63daab064e5e1 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php @@ -38,7 +38,7 @@ class CreateByPathTest extends \PHPUnit\Framework\TestCase */ public function setUp() { - $this->createByPath = Bootstrap::getObjectManager()->create(CreateByPathInterface::class); + $this->createByPath = Bootstrap::getObjectManager()->get(CreateByPathInterface::class); $this->mediaDirectoryPath = Bootstrap::getObjectManager()->get(Filesystem::class) ->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath(); } From f2b6435d4bcd1fa06366d6b07327ddbfe05a1a8d Mon Sep 17 00:00:00 2001 From: Ji Lu <jilu1@adobe.com> Date: Wed, 8 Apr 2020 16:21:50 -0500 Subject: [PATCH 104/177] MQE-2046: remove deprecated entities usages in MFTF tests --- .../Test/Mftf/Section/AdminMessagesSection.xml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml index fce74f1f419e6..c1d5599f9e1c2 100644 --- a/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml +++ b/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml @@ -9,12 +9,20 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminMessagesSection"> - <element name="success" type="text" selector=".message-success"/> + <!-- Keep both Set1 and Set2 elements --> + <!-- Neither Set1 nor Set2 works for all Magento blocks --> + <!-- Set1 --> + <element name="success" type="text" selector="#messages div.message-success"/> <element name="nthSuccess" type="text" selector=".message.message-success.success:nth-of-type({{n}})>div" parameterized="true"/> - <element name="error" type="text" selector=".message.message-error.error"/> + <element name="error" type="text" selector="#messages div.message-error"/> <element name="notice" type="text" selector=".message.message-notice.notice"/> <element name="messageByType" type="text" selector="#messages div.message-{{messageType}}" parameterized="true" /> - <element name="warning" type="text" selector=".message-warning"/> + <element name="warning" type="text" selector="#messages div.message-warning"/> <element name="accessDenied" type="text" selector=".access-denied-page"/> + <!-- Set2 --> + <element name="successMessage" type="text" selector=".message-success"/> + <element name="errorMessage" type="text" selector=".message.message-error.error"/> + <element name="warningMessage" type="text" selector=".message-warning"/> + <element name="noticeMessage" type="text" selector=".message-notice"/> </section> </sections> From 2a824b03b01a000fd3874ca8a97854b0e55f0aa5 Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Thu, 9 Apr 2020 11:32:41 +0300 Subject: [PATCH 105/177] Use Action Group to click on minicart --- .../Mftf/Test/CurrencyChangingBundleProductInCartTest.xml | 3 +-- .../CaptchaWithDisabledGuestCheckoutTest.xml | 4 ++-- .../Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml | 2 +- .../Test/AdminConfigureProductImagePlaceholderTest.xml | 4 ++-- ...ProductWithRegularPriceInStockWithCustomOptionsTest.xml | 2 +- ...teCatalogPriceRuleEntityFromConfigurableProductTest.xml | 3 +-- ...inDeleteCatalogPriceRuleEntityFromSimpleProductTest.xml | 2 +- ...ErrorCartCheckoutForProductsDeletedFromMiniCartTest.xml | 7 +++---- .../ShoppingCartAndMiniShoppingCartPerCustomerTest.xml | 3 +-- ...StoreFrontUpdateShoppingCartWhileUpdateMinicartTest.xml | 2 +- ...StorefrontAddBundleDynamicProductToShoppingCartTest.xml | 3 +-- .../StorefrontAddConfigurableProductToShoppingCartTest.xml | 3 +-- .../StorefrontAddDownloadableProductToShoppingCartTest.xml | 3 +-- .../Test/StorefrontAddGroupedProductToShoppingCartTest.xml | 3 +-- ...AddTwoBundleMultiSelectOptionsToTheShoppingCartTest.xml | 3 +-- ...orefrontDeleteBundleProductFromMiniShoppingCartTest.xml | 3 +-- ...ntDeleteDownloadableProductFromMiniShoppingCartTest.xml | 3 +-- ...leteSimpleAndVirtualProductFromMiniShoppingCartTest.xml | 3 +-- ...orefrontDeleteSimpleProductFromMiniShoppingCartTest.xml | 3 +-- ...ctNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml | 2 +- .../Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml | 2 +- .../Test/Mftf/Test/NoErrorForMiniCartItemEditTest.xml | 2 +- .../Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml | 2 +- .../Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml | 2 +- 24 files changed, 28 insertions(+), 41 deletions(-) diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/CurrencyChangingBundleProductInCartTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/CurrencyChangingBundleProductInCartTest.xml index 0ae7ce836a4a9..b65cf573cc4b3 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/CurrencyChangingBundleProductInCartTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/CurrencyChangingBundleProductInCartTest.xml @@ -77,8 +77,7 @@ <argument name="product" value="$$simpleProduct2$$"/> <argument name="currency" value="USD - US Dollar"/> </actionGroup> - <click stepKey="openMiniCart" selector="{{StorefrontMinicartSection.showCart}}"/> - <waitForPageLoad stepKey="waitForMiniCart"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart"/> <see stepKey="seeCartSubtotal" userInput="$12,300.00"/> </test> </tests> diff --git a/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest/CaptchaWithDisabledGuestCheckoutTest.xml b/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest/CaptchaWithDisabledGuestCheckoutTest.xml index c3b43d7788433..40f1c73b81786 100644 --- a/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest/CaptchaWithDisabledGuestCheckoutTest.xml +++ b/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest/CaptchaWithDisabledGuestCheckoutTest.xml @@ -38,7 +38,7 @@ <waitForPageLoad stepKey="waitForAddToCart"/> <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <waitForText userInput="You added $$createSimpleProduct.name$$ to your shopping cart." stepKey="waitForText"/> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickCart"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> <click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout"/> <waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.email}}" stepKey="waitEmailFieldVisible"/> <fillField selector="{{StorefrontCustomerSignInPopupFormSection.email}}" userInput="{{Simple_US_Customer.email}}" stepKey="fillCustomerEmail"/> @@ -50,7 +50,7 @@ <waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaReload}}" stepKey="seeCaptchaReloadButton"/> <reloadPage stepKey="refreshPage"/> <waitForPageLoad stepKey="waitForPageLoad2"/> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickCart2"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart2"/> <click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout2"/> <waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.email}}" stepKey="waitEmailFieldVisible2"/> <waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaField}}" stepKey="seeCaptchaField2"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml index 4aa96c91eb299..c04ee46037123 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml @@ -83,7 +83,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <seeElement selector="{{StorefrontProductPageSection.successMsg}}" stepKey="seeSuccessSaveMessage"/> <seeElement selector="{{StorefrontMinicartSection.quantity(1)}}" stepKey="seeAddedProductQuantityInCart"/> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickOnMiniCart"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <see selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="{{SimpleProduct.name}}" stepKey="seeProductNameInMiniCart"/> <see selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="{{SimpleProduct.price}}" stepKey="seeProductPriceInMiniCart"/> <seeElement selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="seeCheckOutButtonInMiniCart"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminConfigureProductImagePlaceholderTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminConfigureProductImagePlaceholderTest.xml index a4414901517b9..cc42c0f4ae821 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminConfigureProductImagePlaceholderTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminConfigureProductImagePlaceholderTest.xml @@ -114,7 +114,7 @@ <seeElement selector="{{StorefrontProductMediaSection.imageFile(placeholderBaseImage.name)}}" stepKey="seeBasePlaceholderImage"/> <click selector="{{StorefrontProductPageSection.addToCartBtn}}" stepKey="addProductToCart1"/> <waitForElementVisible selector="{{StorefrontProductPageSection.successMsg}}" stepKey="waitForProductAdded1"/> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniCart1"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart1"/> <grabAttributeFrom selector="{{StorefrontMinicartSection.productImageByName($$productNoImages.name$$)}}" userInput="src" stepKey="getThumbnailPlaceholderImageSrc"/> <assertContains stepKey="checkThumbnailPlaceholderImage"> <actualResult type="variable">$getThumbnailPlaceholderImageSrc</actualResult> @@ -132,7 +132,7 @@ <dontSeeElement selector="{{StorefrontProductMediaSection.imageFile(placeholderBaseImage.name)}}" stepKey="dontSeeBasePlaceholderImage"/> <click selector="{{StorefrontProductPageSection.addToCartBtn}}" stepKey="addProductToCart2"/> <waitForElementVisible selector="{{StorefrontProductPageSection.successMsg}}" stepKey="waitForProductAdded2"/> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniCart2"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart2"/> <grabAttributeFrom selector="{{StorefrontMinicartSection.productImageByName($$productWithImages.name$$)}}" userInput="src" stepKey="getThumbnailImageSrc"/> <assertNotContains stepKey="checkThumbnailImage"> <actualResult type="variable">$getThumbnailImageSrc</actualResult> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockWithCustomOptionsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockWithCustomOptionsTest.xml index c924c94a9aba8..c23b17d8f157d 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockWithCustomOptionsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockWithCustomOptionsTest.xml @@ -155,7 +155,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <seeElement selector="{{StorefrontProductPageSection.successMsg}}" stepKey="seeYouAddedSimpleprod4ToYourShoppingCartSuccessSaveMessage"/> <seeElement selector="{{StorefrontMinicartSection.quantity(1)}}" stepKey="seeAddedProductQuantityInCart"/> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickOnMiniCart"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <see selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="{{simpleProductRegularPriceCustomOptions.name}}" stepKey="seeProductNameInMiniCart"/> <see selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="{{simpleProductRegularPriceCustomOptions.storefront_new_cartprice}}" stepKey="seeProductPriceInMiniCart"/> </test> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromConfigurableProductTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromConfigurableProductTest.xml index 5fb33c9482709..36611a2a86afe 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromConfigurableProductTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromConfigurableProductTest.xml @@ -135,8 +135,7 @@ <waitForPageLoad time="30" stepKey="waitForPageLoad4"/> <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <see selector="{{StorefrontMessagesSection.success}}" userInput="You added $$createConfigProduct1.name$ to your shopping cart." stepKey="seeAddToCartSuccessMessage"/> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniShoppingCart1"/> - <waitForPageLoad time="30" stepKey="waitForPageLoad5"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniShoppingCart1"/> <see selector="{{StorefrontMinicartSection.productPriceByName($$createConfigProduct1.name$$)}}" userInput="$$createConfigProduct1.price$$" stepKey="seeCorrectProductPrice1"/> </test> </tests> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromSimpleProductTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromSimpleProductTest.xml index fc37fc893f871..fa2fc59ab5cde 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromSimpleProductTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromSimpleProductTest.xml @@ -80,7 +80,7 @@ <actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addProductToShoppingCart1"> <argument name="productName" value="$$createProduct1.name$$"/> </actionGroup> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniShoppingCart1"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniShoppingCart1"/> <see selector="{{StorefrontMinicartSection.productPriceByName($$createProduct1.name$$)}}" userInput="$$createProduct1.price$$" stepKey="seeCorrectProductPrice1"/> <!-- Assert that the rule isn't present on the Checkout page --> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/NoErrorCartCheckoutForProductsDeletedFromMiniCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/NoErrorCartCheckoutForProductsDeletedFromMiniCartTest.xml index fd6656b1d1b28..288b02f39bc6d 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/NoErrorCartCheckoutForProductsDeletedFromMiniCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/NoErrorCartCheckoutForProductsDeletedFromMiniCartTest.xml @@ -41,17 +41,16 @@ <see selector="{{StorefrontCategoryMainSection.SuccessMsg}}" userInput="You added $$createSimpleProduct.name$$ to your shopping cart." stepKey="seeAddedToCartMessage"/> <see selector="{{StorefrontMinicartSection.quantity}}" userInput="1" stepKey="seeCartQuantity"/> <!-- open the minicart --> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickShowMinicart1"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickShowMinicart1"/> <click selector="{{StorefrontMinicartSection.viewAndEditCart}}" stepKey="editProductFromMiniCart"/> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickShowMinicart2"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickShowMinicart2"/> <click selector="{{StorefrontMinicartSection.deleteMiniCartItem}}" stepKey="deleteMiniCartItem"/> <waitForElementVisible selector="{{StoreFrontRemoveItemModalSection.message}}" stepKey="waitFortheConfirmationModal"/> <see selector="{{StoreFrontRemoveItemModalSection.message}}" userInput="Are you sure you would like to remove this item from the shopping cart?" stepKey="seeDeleteConfirmationMessage"/> <click selector="{{StoreFrontRemoveItemModalSection.ok}}" stepKey="confirmDelete"/> <waitForPageLoad stepKey="waitForDeleteToFinish"/> <dontSeeElement selector="{{CheckoutCartProductSection.RemoveItem}}" stepKey="dontSeeDeleteProductFromCheckoutCart"/> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickCart"/> - <waitForPageLoad stepKey="WaitForPageLoad3"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> <see userInput="You have no items in your shopping cart." stepKey="seeNoItemsInShoppingCart"/> </test> </tests> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml index 741fde91f851e..aad28b9107559 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml @@ -168,8 +168,7 @@ <!-- Assert product in mini cart --> <actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToHomePage"/> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickOnMiniCart"/> - <waitForPageLoad stepKey="waitForPageToLoad"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertProductInMiniCart"> <argument name="productName" value="$$createSimpleProduct.name$$"/> <argument name="productPrice" value="$$createSimpleProduct.price$$"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontUpdateShoppingCartWhileUpdateMinicartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontUpdateShoppingCartWhileUpdateMinicartTest.xml index f7ae9d29ada55..fd8bfe1c31f25 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontUpdateShoppingCartWhileUpdateMinicartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontUpdateShoppingCartWhileUpdateMinicartTest.xml @@ -45,7 +45,7 @@ </assertEquals> <!--Open minicart and change Qty--> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniCart"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart"/> <waitForElementVisible selector="{{StorefrontMinicartSection.quantity}}" stepKey="waitForElementQty"/> <pressKey selector="{{StorefrontMinicartSection.itemQuantity($$createProduct.name$$)}}" parameterArray="[\Facebook\WebDriver\WebDriverKeys::BACKSPACE]" stepKey="deleteFiled"/> <fillField selector="{{StorefrontMinicartSection.itemQuantity($$createProduct.name$$)}}" userInput="5" stepKey="changeQty"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddBundleDynamicProductToShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddBundleDynamicProductToShoppingCartTest.xml index 5e5278a256194..ca2c236753507 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddBundleDynamicProductToShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddBundleDynamicProductToShoppingCartTest.xml @@ -111,8 +111,7 @@ </actionGroup> <!-- Assert Product in Mini Cart --> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickOnMiniCart"/> - <waitForPageLoad stepKey="waitForPageToLoad1"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertSimpleProduct3MiniCart"> <argument name="productName" value="$$createBundleProduct.name$$"/> <argument name="productPrice" value="$50.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddConfigurableProductToShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddConfigurableProductToShoppingCartTest.xml index b8e70d7492539..0d6f9d07b7aba 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddConfigurableProductToShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddConfigurableProductToShoppingCartTest.xml @@ -157,8 +157,7 @@ </actionGroup> <!-- Assert product details in Mini Cart --> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickOnMiniCart"/> - <waitForPageLoad stepKey="waitForPageToLoad"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertMiniCart"> <argument name="productName" value="$$createConfigProduct.name$$"/> <argument name="productPrice" value="$$createConfigChildProduct2.price$$"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddDownloadableProductToShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddDownloadableProductToShoppingCartTest.xml index e098c15c0eb6a..228da8a87dea5 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddDownloadableProductToShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddDownloadableProductToShoppingCartTest.xml @@ -77,8 +77,7 @@ </actionGroup> <!-- Assert product details in Mini Cart --> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickOnMiniCart"/> - <waitForPageLoad stepKey="waitForPageToLoad1"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertMiniCart"> <argument name="productName" value="$$createDownloadableProduct.name$$"/> <argument name="productPrice" value="$123.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddGroupedProductToShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddGroupedProductToShoppingCartTest.xml index 0fc4cee5e0582..92ec1f619e030 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddGroupedProductToShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddGroupedProductToShoppingCartTest.xml @@ -101,8 +101,7 @@ </actionGroup> <!-- Assert product1 details in Mini Cart --> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickOnMiniCart"/> - <waitForPageLoad stepKey="waitForPageToLoad1"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertSimpleProduct3MiniCart"> <argument name="productName" value="$$simple3.name$$"/> <argument name="productPrice" value="$300.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddTwoBundleMultiSelectOptionsToTheShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddTwoBundleMultiSelectOptionsToTheShoppingCartTest.xml index 14788250a9bca..fd80af59109c5 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddTwoBundleMultiSelectOptionsToTheShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddTwoBundleMultiSelectOptionsToTheShoppingCartTest.xml @@ -112,8 +112,7 @@ </actionGroup> <!-- Assert Product in Mini Cart --> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickOnMiniCart"/> - <waitForPageLoad stepKey="waitForPageToLoad1"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertSimpleProduct3MiniCart"> <argument name="productName" value="$$createBundleProduct.name$$"/> <argument name="productPrice" value="$60.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteBundleProductFromMiniShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteBundleProductFromMiniShoppingCartTest.xml index fe320fb276c8a..369cb53d8d710 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteBundleProductFromMiniShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteBundleProductFromMiniShoppingCartTest.xml @@ -65,8 +65,7 @@ <waitForPageLoad stepKey="waitForMiniCartPanelToAppear"/> <!-- Assert Product in Mini Cart --> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickOnMiniCart"/> - <waitForPageLoad stepKey="waitForPageToLoad1"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertSimpleProduct3MiniCart"> <argument name="productName" value="$$createBundleProduct.name$$"/> <argument name="productPrice" value="$10.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteDownloadableProductFromMiniShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteDownloadableProductFromMiniShoppingCartTest.xml index 3c234602df17a..202bbb76c81b2 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteDownloadableProductFromMiniShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteDownloadableProductFromMiniShoppingCartTest.xml @@ -49,8 +49,7 @@ <actionGroup ref="ClickViewAndEditCartFromMiniCartActionGroup" stepKey="selectViewAndEditCart"/> <!-- Assert product details in Mini Cart --> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickOnMiniCart"/> - <waitForPageLoad stepKey="waitForPageToLoad1"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertMiniCart"> <argument name="productName" value="$$createDownloadableProduct.name$$"/> <argument name="productPrice" value="$123.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleAndVirtualProductFromMiniShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleAndVirtualProductFromMiniShoppingCartTest.xml index 643c6d8c14dd7..0530a1c6142cd 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleAndVirtualProductFromMiniShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleAndVirtualProductFromMiniShoppingCartTest.xml @@ -47,8 +47,7 @@ </actionGroup> <!-- Assert Simple and Virtual products in mini cart --> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickOnMiniCart"/> - <waitForPageLoad stepKey="waitForPageToLoad1"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertSimpleProductInMiniCart"> <argument name="productName" value="$$simpleProduct.name$$"/> <argument name="productPrice" value="$10.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleProductFromMiniShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleProductFromMiniShoppingCartTest.xml index a7bb3d927f620..2cfc473ec4039 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleProductFromMiniShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleProductFromMiniShoppingCartTest.xml @@ -36,8 +36,7 @@ </actionGroup> <!-- Assert Product in Mini Cart --> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickOnMiniCart"/> - <waitForPageLoad stepKey="waitForPageToLoad1"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertSimpleProduct3MiniCart"> <argument name="productName" value="$$simpleProduct.name$$"/> <argument name="productPrice" value="$10.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml index e6e5c4f1a9299..4d8e9ead40016 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml @@ -69,7 +69,7 @@ <waitForPageLoad stepKey="waitForStoreView"/> <!--Check product name in Minicart--> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickCart"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> <grabTextFrom selector="{{StorefrontMinicartSection.productName}}" stepKey="grabProductNameMinicart"/> <assertContains stepKey="assertProductNameMinicart"> <actualResult type="const">$grabProductNameMinicart</actualResult> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml index 542c0ed6586e9..a39b0b03dc55e 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml @@ -68,7 +68,7 @@ </actionGroup> <!--Proceed to shipment--> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickToOpenCard"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickToOpenCard"/> <click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="clickToProceedToCheckout"/> <waitForPageLoad stepKey="waitForTheFormIsOpened"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoErrorForMiniCartItemEditTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoErrorForMiniCartItemEditTest.xml index c2ac4dde21c35..37e11dda29a54 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoErrorForMiniCartItemEditTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoErrorForMiniCartItemEditTest.xml @@ -60,7 +60,7 @@ <waitForPageLoad stepKey="waitForMiniCart"/> <!-- Edit Item in Cart --> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniCart"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart"/> <click selector="{{StorefrontMinicartSection.editMiniCartItem}}" stepKey="clickEditCartItem"/> <!-- Check if Product Configuration is still selected --> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml index 1411f7b292757..93ff0275d9e4b 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml @@ -36,7 +36,7 @@ <moveMouseOver selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" stepKey="hoverProduct"/> <click selector="{{StorefrontCategoryMainSection.AddToCartBtn}}" stepKey="addToCart"/> <waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" time="30" stepKey="waitForProductAdded"/> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickCart"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> <click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout"/> <waitForPageLoad stepKey="waitForPageLoad2"/> <fillField selector="{{CheckoutShippingGuestInfoSection.email}}" userInput="{{CustomerEntityOne.email}}" stepKey="enterEmail"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml index 09197963434eb..189e90e1ab668 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml @@ -66,7 +66,7 @@ <moveMouseOver selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" stepKey="hoverOverProduct"/> <click selector="{{StorefrontCategoryMainSection.AddToCartBtn}}" stepKey="addToCart"/> <waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" time="30" stepKey="waitForProductToAdd"/> - <click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickCart"/> + <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> <click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout"/> <waitForPageLoad stepKey="waitForPageLoad2"/> <!-- fill out customer information --> From 3edb1f8d841be19db6cc9e00108df75f001f66d5 Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Thu, 9 Apr 2020 12:07:05 +0300 Subject: [PATCH 106/177] fixed own mistake --- .../Mftf/Test/CurrencyChangingBundleProductInCartTest.xml | 2 +- .../CaptchaWithDisabledGuestCheckoutTest.xml | 4 ++-- .../Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml | 2 +- .../Mftf/Test/AdminConfigureProductImagePlaceholderTest.xml | 4 ++-- ...eProductWithRegularPriceInStockWithCustomOptionsTest.xml | 2 +- ...eteCatalogPriceRuleEntityFromConfigurableProductTest.xml | 2 +- ...minDeleteCatalogPriceRuleEntityFromSimpleProductTest.xml | 2 +- ...oErrorCartCheckoutForProductsDeletedFromMiniCartTest.xml | 6 +++--- .../Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml | 2 +- .../StoreFrontUpdateShoppingCartWhileUpdateMinicartTest.xml | 2 +- .../StorefrontAddBundleDynamicProductToShoppingCartTest.xml | 2 +- .../StorefrontAddConfigurableProductToShoppingCartTest.xml | 2 +- .../StorefrontAddDownloadableProductToShoppingCartTest.xml | 2 +- .../Test/StorefrontAddGroupedProductToShoppingCartTest.xml | 2 +- ...tAddTwoBundleMultiSelectOptionsToTheShoppingCartTest.xml | 2 +- ...torefrontDeleteBundleProductFromMiniShoppingCartTest.xml | 2 +- ...ontDeleteDownloadableProductFromMiniShoppingCartTest.xml | 2 +- ...eleteSimpleAndVirtualProductFromMiniShoppingCartTest.xml | 2 +- ...torefrontDeleteSimpleProductFromMiniShoppingCartTest.xml | 2 +- ...uctNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml | 2 +- .../Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml | 2 +- .../Test/Mftf/Test/NoErrorForMiniCartItemEditTest.xml | 2 +- .../Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml | 2 +- .../Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml | 2 +- 24 files changed, 28 insertions(+), 28 deletions(-) diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/CurrencyChangingBundleProductInCartTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/CurrencyChangingBundleProductInCartTest.xml index b65cf573cc4b3..ada91d068efcf 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/CurrencyChangingBundleProductInCartTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/CurrencyChangingBundleProductInCartTest.xml @@ -77,7 +77,7 @@ <argument name="product" value="$$simpleProduct2$$"/> <argument name="currency" value="USD - US Dollar"/> </actionGroup> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart"/> <see stepKey="seeCartSubtotal" userInput="$12,300.00"/> </test> </tests> diff --git a/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest/CaptchaWithDisabledGuestCheckoutTest.xml b/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest/CaptchaWithDisabledGuestCheckoutTest.xml index 40f1c73b81786..bfea4e99996c3 100644 --- a/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest/CaptchaWithDisabledGuestCheckoutTest.xml +++ b/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest/CaptchaWithDisabledGuestCheckoutTest.xml @@ -38,7 +38,7 @@ <waitForPageLoad stepKey="waitForAddToCart"/> <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <waitForText userInput="You added $$createSimpleProduct.name$$ to your shopping cart." stepKey="waitForText"/> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> <click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout"/> <waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.email}}" stepKey="waitEmailFieldVisible"/> <fillField selector="{{StorefrontCustomerSignInPopupFormSection.email}}" userInput="{{Simple_US_Customer.email}}" stepKey="fillCustomerEmail"/> @@ -50,7 +50,7 @@ <waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaReload}}" stepKey="seeCaptchaReloadButton"/> <reloadPage stepKey="refreshPage"/> <waitForPageLoad stepKey="waitForPageLoad2"/> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart2"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart2"/> <click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout2"/> <waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.email}}" stepKey="waitEmailFieldVisible2"/> <waitForElementVisible selector="{{StorefrontCustomerSignInPopupFormSection.captchaField}}" stepKey="seeCaptchaField2"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml index c04ee46037123..52da8c70a3bc8 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml @@ -83,7 +83,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <seeElement selector="{{StorefrontProductPageSection.successMsg}}" stepKey="seeSuccessSaveMessage"/> <seeElement selector="{{StorefrontMinicartSection.quantity(1)}}" stepKey="seeAddedProductQuantityInCart"/> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <see selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="{{SimpleProduct.name}}" stepKey="seeProductNameInMiniCart"/> <see selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="{{SimpleProduct.price}}" stepKey="seeProductPriceInMiniCart"/> <seeElement selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="seeCheckOutButtonInMiniCart"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminConfigureProductImagePlaceholderTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminConfigureProductImagePlaceholderTest.xml index cc42c0f4ae821..85378ecfb76a9 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminConfigureProductImagePlaceholderTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminConfigureProductImagePlaceholderTest.xml @@ -114,7 +114,7 @@ <seeElement selector="{{StorefrontProductMediaSection.imageFile(placeholderBaseImage.name)}}" stepKey="seeBasePlaceholderImage"/> <click selector="{{StorefrontProductPageSection.addToCartBtn}}" stepKey="addProductToCart1"/> <waitForElementVisible selector="{{StorefrontProductPageSection.successMsg}}" stepKey="waitForProductAdded1"/> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart1"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart1"/> <grabAttributeFrom selector="{{StorefrontMinicartSection.productImageByName($$productNoImages.name$$)}}" userInput="src" stepKey="getThumbnailPlaceholderImageSrc"/> <assertContains stepKey="checkThumbnailPlaceholderImage"> <actualResult type="variable">$getThumbnailPlaceholderImageSrc</actualResult> @@ -132,7 +132,7 @@ <dontSeeElement selector="{{StorefrontProductMediaSection.imageFile(placeholderBaseImage.name)}}" stepKey="dontSeeBasePlaceholderImage"/> <click selector="{{StorefrontProductPageSection.addToCartBtn}}" stepKey="addProductToCart2"/> <waitForElementVisible selector="{{StorefrontProductPageSection.successMsg}}" stepKey="waitForProductAdded2"/> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart2"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart2"/> <grabAttributeFrom selector="{{StorefrontMinicartSection.productImageByName($$productWithImages.name$$)}}" userInput="src" stepKey="getThumbnailImageSrc"/> <assertNotContains stepKey="checkThumbnailImage"> <actualResult type="variable">$getThumbnailImageSrc</actualResult> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockWithCustomOptionsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockWithCustomOptionsTest.xml index c23b17d8f157d..855a2b1d9b0cc 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockWithCustomOptionsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockWithCustomOptionsTest.xml @@ -155,7 +155,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <seeElement selector="{{StorefrontProductPageSection.successMsg}}" stepKey="seeYouAddedSimpleprod4ToYourShoppingCartSuccessSaveMessage"/> <seeElement selector="{{StorefrontMinicartSection.quantity(1)}}" stepKey="seeAddedProductQuantityInCart"/> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <see selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="{{simpleProductRegularPriceCustomOptions.name}}" stepKey="seeProductNameInMiniCart"/> <see selector="{{StorefrontMinicartSection.miniCartItemsText}}" userInput="{{simpleProductRegularPriceCustomOptions.storefront_new_cartprice}}" stepKey="seeProductPriceInMiniCart"/> </test> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromConfigurableProductTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromConfigurableProductTest.xml index 36611a2a86afe..6b34fd1e67e9b 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromConfigurableProductTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromConfigurableProductTest.xml @@ -135,7 +135,7 @@ <waitForPageLoad time="30" stepKey="waitForPageLoad4"/> <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <see selector="{{StorefrontMessagesSection.success}}" userInput="You added $$createConfigProduct1.name$ to your shopping cart." stepKey="seeAddToCartSuccessMessage"/> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniShoppingCart1"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniShoppingCart1"/> <see selector="{{StorefrontMinicartSection.productPriceByName($$createConfigProduct1.name$$)}}" userInput="$$createConfigProduct1.price$$" stepKey="seeCorrectProductPrice1"/> </test> </tests> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromSimpleProductTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromSimpleProductTest.xml index fa2fc59ab5cde..49a9d5e8ae51b 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromSimpleProductTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromSimpleProductTest.xml @@ -80,7 +80,7 @@ <actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addProductToShoppingCart1"> <argument name="productName" value="$$createProduct1.name$$"/> </actionGroup> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniShoppingCart1"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniShoppingCart1"/> <see selector="{{StorefrontMinicartSection.productPriceByName($$createProduct1.name$$)}}" userInput="$$createProduct1.price$$" stepKey="seeCorrectProductPrice1"/> <!-- Assert that the rule isn't present on the Checkout page --> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/NoErrorCartCheckoutForProductsDeletedFromMiniCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/NoErrorCartCheckoutForProductsDeletedFromMiniCartTest.xml index 288b02f39bc6d..ceaf72fff83bb 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/NoErrorCartCheckoutForProductsDeletedFromMiniCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/NoErrorCartCheckoutForProductsDeletedFromMiniCartTest.xml @@ -41,16 +41,16 @@ <see selector="{{StorefrontCategoryMainSection.SuccessMsg}}" userInput="You added $$createSimpleProduct.name$$ to your shopping cart." stepKey="seeAddedToCartMessage"/> <see selector="{{StorefrontMinicartSection.quantity}}" userInput="1" stepKey="seeCartQuantity"/> <!-- open the minicart --> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickShowMinicart1"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickShowMinicart1"/> <click selector="{{StorefrontMinicartSection.viewAndEditCart}}" stepKey="editProductFromMiniCart"/> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickShowMinicart2"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickShowMinicart2"/> <click selector="{{StorefrontMinicartSection.deleteMiniCartItem}}" stepKey="deleteMiniCartItem"/> <waitForElementVisible selector="{{StoreFrontRemoveItemModalSection.message}}" stepKey="waitFortheConfirmationModal"/> <see selector="{{StoreFrontRemoveItemModalSection.message}}" userInput="Are you sure you would like to remove this item from the shopping cart?" stepKey="seeDeleteConfirmationMessage"/> <click selector="{{StoreFrontRemoveItemModalSection.ok}}" stepKey="confirmDelete"/> <waitForPageLoad stepKey="waitForDeleteToFinish"/> <dontSeeElement selector="{{CheckoutCartProductSection.RemoveItem}}" stepKey="dontSeeDeleteProductFromCheckoutCart"/> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> <see userInput="You have no items in your shopping cart." stepKey="seeNoItemsInShoppingCart"/> </test> </tests> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml index aad28b9107559..1ed6912f2ca46 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml @@ -168,7 +168,7 @@ <!-- Assert product in mini cart --> <actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="goToHomePage"/> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertProductInMiniCart"> <argument name="productName" value="$$createSimpleProduct.name$$"/> <argument name="productPrice" value="$$createSimpleProduct.price$$"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontUpdateShoppingCartWhileUpdateMinicartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontUpdateShoppingCartWhileUpdateMinicartTest.xml index fd8bfe1c31f25..1f9948f80f391 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontUpdateShoppingCartWhileUpdateMinicartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontUpdateShoppingCartWhileUpdateMinicartTest.xml @@ -45,7 +45,7 @@ </assertEquals> <!--Open minicart and change Qty--> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart"/> <waitForElementVisible selector="{{StorefrontMinicartSection.quantity}}" stepKey="waitForElementQty"/> <pressKey selector="{{StorefrontMinicartSection.itemQuantity($$createProduct.name$$)}}" parameterArray="[\Facebook\WebDriver\WebDriverKeys::BACKSPACE]" stepKey="deleteFiled"/> <fillField selector="{{StorefrontMinicartSection.itemQuantity($$createProduct.name$$)}}" userInput="5" stepKey="changeQty"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddBundleDynamicProductToShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddBundleDynamicProductToShoppingCartTest.xml index ca2c236753507..e82f3c0588835 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddBundleDynamicProductToShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddBundleDynamicProductToShoppingCartTest.xml @@ -111,7 +111,7 @@ </actionGroup> <!-- Assert Product in Mini Cart --> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertSimpleProduct3MiniCart"> <argument name="productName" value="$$createBundleProduct.name$$"/> <argument name="productPrice" value="$50.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddConfigurableProductToShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddConfigurableProductToShoppingCartTest.xml index 0d6f9d07b7aba..21e785de6cab3 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddConfigurableProductToShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddConfigurableProductToShoppingCartTest.xml @@ -157,7 +157,7 @@ </actionGroup> <!-- Assert product details in Mini Cart --> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertMiniCart"> <argument name="productName" value="$$createConfigProduct.name$$"/> <argument name="productPrice" value="$$createConfigChildProduct2.price$$"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddDownloadableProductToShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddDownloadableProductToShoppingCartTest.xml index 228da8a87dea5..bbc0a29000a77 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddDownloadableProductToShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddDownloadableProductToShoppingCartTest.xml @@ -77,7 +77,7 @@ </actionGroup> <!-- Assert product details in Mini Cart --> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertMiniCart"> <argument name="productName" value="$$createDownloadableProduct.name$$"/> <argument name="productPrice" value="$123.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddGroupedProductToShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddGroupedProductToShoppingCartTest.xml index 92ec1f619e030..3e2f32a4ab055 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddGroupedProductToShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddGroupedProductToShoppingCartTest.xml @@ -101,7 +101,7 @@ </actionGroup> <!-- Assert product1 details in Mini Cart --> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertSimpleProduct3MiniCart"> <argument name="productName" value="$$simple3.name$$"/> <argument name="productPrice" value="$300.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddTwoBundleMultiSelectOptionsToTheShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddTwoBundleMultiSelectOptionsToTheShoppingCartTest.xml index fd80af59109c5..265f9a7cbbc98 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddTwoBundleMultiSelectOptionsToTheShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddTwoBundleMultiSelectOptionsToTheShoppingCartTest.xml @@ -112,7 +112,7 @@ </actionGroup> <!-- Assert Product in Mini Cart --> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertSimpleProduct3MiniCart"> <argument name="productName" value="$$createBundleProduct.name$$"/> <argument name="productPrice" value="$60.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteBundleProductFromMiniShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteBundleProductFromMiniShoppingCartTest.xml index 369cb53d8d710..d116d0049c9df 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteBundleProductFromMiniShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteBundleProductFromMiniShoppingCartTest.xml @@ -65,7 +65,7 @@ <waitForPageLoad stepKey="waitForMiniCartPanelToAppear"/> <!-- Assert Product in Mini Cart --> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertSimpleProduct3MiniCart"> <argument name="productName" value="$$createBundleProduct.name$$"/> <argument name="productPrice" value="$10.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteDownloadableProductFromMiniShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteDownloadableProductFromMiniShoppingCartTest.xml index 202bbb76c81b2..8a52fa7740b95 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteDownloadableProductFromMiniShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteDownloadableProductFromMiniShoppingCartTest.xml @@ -49,7 +49,7 @@ <actionGroup ref="ClickViewAndEditCartFromMiniCartActionGroup" stepKey="selectViewAndEditCart"/> <!-- Assert product details in Mini Cart --> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertMiniCart"> <argument name="productName" value="$$createDownloadableProduct.name$$"/> <argument name="productPrice" value="$123.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleAndVirtualProductFromMiniShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleAndVirtualProductFromMiniShoppingCartTest.xml index 0530a1c6142cd..21966875519dc 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleAndVirtualProductFromMiniShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleAndVirtualProductFromMiniShoppingCartTest.xml @@ -47,7 +47,7 @@ </actionGroup> <!-- Assert Simple and Virtual products in mini cart --> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertSimpleProductInMiniCart"> <argument name="productName" value="$$simpleProduct.name$$"/> <argument name="productPrice" value="$10.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleProductFromMiniShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleProductFromMiniShoppingCartTest.xml index 2cfc473ec4039..effd376ab4bfb 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleProductFromMiniShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontDeleteSimpleProductFromMiniShoppingCartTest.xml @@ -36,7 +36,7 @@ </actionGroup> <!-- Assert Product in Mini Cart --> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/> <actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="assertSimpleProduct3MiniCart"> <argument name="productName" value="$$simpleProduct.name$$"/> <argument name="productPrice" value="$10.00"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml index 4d8e9ead40016..f666226233b6d 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest.xml @@ -69,7 +69,7 @@ <waitForPageLoad stepKey="waitForStoreView"/> <!--Check product name in Minicart--> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> <grabTextFrom selector="{{StorefrontMinicartSection.productName}}" stepKey="grabProductNameMinicart"/> <assertContains stepKey="assertProductNameMinicart"> <actualResult type="const">$grabProductNameMinicart</actualResult> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml index a39b0b03dc55e..43d20e0d676ea 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml @@ -68,7 +68,7 @@ </actionGroup> <!--Proceed to shipment--> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickToOpenCard"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickToOpenCard"/> <click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="clickToProceedToCheckout"/> <waitForPageLoad stepKey="waitForTheFormIsOpened"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoErrorForMiniCartItemEditTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoErrorForMiniCartItemEditTest.xml index 37e11dda29a54..10d8aeb875742 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoErrorForMiniCartItemEditTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoErrorForMiniCartItemEditTest.xml @@ -60,7 +60,7 @@ <waitForPageLoad stepKey="waitForMiniCart"/> <!-- Edit Item in Cart --> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="openMiniCart"/> <click selector="{{StorefrontMinicartSection.editMiniCartItem}}" stepKey="clickEditCartItem"/> <!-- Check if Product Configuration is still selected --> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml index 93ff0275d9e4b..cdc81c66b833d 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml @@ -36,7 +36,7 @@ <moveMouseOver selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" stepKey="hoverProduct"/> <click selector="{{StorefrontCategoryMainSection.AddToCartBtn}}" stepKey="addToCart"/> <waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" time="30" stepKey="waitForProductAdded"/> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> <click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout"/> <waitForPageLoad stepKey="waitForPageLoad2"/> <fillField selector="{{CheckoutShippingGuestInfoSection.email}}" userInput="{{CustomerEntityOne.email}}" stepKey="enterEmail"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml index 189e90e1ab668..36f8df7b271d3 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml @@ -66,7 +66,7 @@ <moveMouseOver selector="{{StorefrontCategoryMainSection.ProductItemInfo}}" stepKey="hoverOverProduct"/> <click selector="{{StorefrontCategoryMainSection.AddToCartBtn}}" stepKey="addToCart"/> <waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" time="30" stepKey="waitForProductToAdd"/> - <actionGroup name="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> + <actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickCart"/> <click selector="{{StorefrontMinicartSection.goToCheckout}}" stepKey="goToCheckout"/> <waitForPageLoad stepKey="waitForPageLoad2"/> <!-- fill out customer information --> From 040f7a8628a0c14387d96f517b55499d2f113a90 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Thu, 9 Apr 2020 10:51:45 +0100 Subject: [PATCH 107/177] magento/magento2#27536: Removed unnecessary node from xsd --- app/code/Magento/MediaContentApi/etc/media_content.xsd | 1 - .../Magento/MediaContent/Model/AssignGetUnassignTest.php | 8 ++++---- .../MediaContent/Model/ExtractAssetsFromContentTest.php | 2 +- .../Magento/MediaContent/Model/UpdateRelationsTest.php | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/MediaContentApi/etc/media_content.xsd b/app/code/Magento/MediaContentApi/etc/media_content.xsd index 5ed3b4594b995..39312d6bbf93c 100644 --- a/app/code/Magento/MediaContentApi/etc/media_content.xsd +++ b/app/code/Magento/MediaContentApi/etc/media_content.xsd @@ -31,7 +31,6 @@ <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute type="xs:string" name="name" use="required"/> - <xs:attribute type="xs:string" name="example" use="optional"/> </xs:extension> </xs:simpleContent> </xs:complexType> diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php index 5ea2adc284b83..a0fd632b843ed 100644 --- a/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php @@ -46,10 +46,10 @@ class AssignGetUnassignTest extends TestCase */ public function setUp(): void { - $this->assign = Bootstrap::getObjectManager()->create(AssignAssetsInterface::class); - $this->getAssetIds = Bootstrap::getObjectManager()->create(GetAssetIdsUsedInContentInterface::class); - $this->getContent = Bootstrap::getObjectManager()->create(GetContentWithAssetsInterface::class); - $this->unassign = Bootstrap::getObjectManager()->create(UnassignAssetsInterface::class); + $this->assign = Bootstrap::getObjectManager()->get(AssignAssetsInterface::class); + $this->getAssetIds = Bootstrap::getObjectManager()->get(GetAssetIdsUsedInContentInterface::class); + $this->getContent = Bootstrap::getObjectManager()->get(GetContentWithAssetsInterface::class); + $this->unassign = Bootstrap::getObjectManager()->get(UnassignAssetsInterface::class); } /** diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php index 6560b5a8b2036..3e319a1a2afc6 100644 --- a/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php @@ -27,7 +27,7 @@ class ExtractAssetsFromContentTest extends TestCase */ public function setUp(): void { - $this->service = Bootstrap::getObjectManager()->create(ExtractAssetsFromContentInterface::class); + $this->service = Bootstrap::getObjectManager()->get(ExtractAssetsFromContentInterface::class); } /** diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php index aa2b81a5ae3d9..1364747036848 100644 --- a/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php @@ -34,8 +34,8 @@ class UpdateRelationsTest extends TestCase */ public function setUp(): void { - $this->service = Bootstrap::getObjectManager()->create(UpdateRelationsInterface::class); - $this->getAssetIds = Bootstrap::getObjectManager()->create(GetAssetIdsUsedInContentInterface::class); + $this->service = Bootstrap::getObjectManager()->get(UpdateRelationsInterface::class); + $this->getAssetIds = Bootstrap::getObjectManager()->get(GetAssetIdsUsedInContentInterface::class); } /** From c1480f30b159e55a934e241c24ba4265744a9532 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Thu, 9 Apr 2020 11:04:27 +0100 Subject: [PATCH 108/177] magento/magento2#27536: Updated plugins --- .../Plugin/MediaGalleryAssetDeleteByDirectoryPath.php | 4 ++-- .../{Model => }/Plugin/MediaGalleryAssetDeleteByPath.php | 4 ++-- app/code/Magento/MediaContent/etc/di.xml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) rename app/code/Magento/MediaContent/{Model => }/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php (97%) rename app/code/Magento/MediaContent/{Model => }/Plugin/MediaGalleryAssetDeleteByPath.php (96%) diff --git a/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php similarity index 97% rename from app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php rename to app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php index d2ba6dd271834..3401fade27c06 100644 --- a/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php +++ b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\MediaContent\Model\Plugin; +namespace Magento\MediaContent\Plugin; use Magento\Framework\App\ResourceConnection; use Magento\Framework\DB\Adapter\AdapterInterface; @@ -67,7 +67,7 @@ public function aroundExecute( ) : void { $assetIds = $this->getAssetIdsByDirectoryPath($directoryPath); - $proceed(); + $proceed($directoryPath); $this->removeRelationsForAssetIds->execute($assetIds); } diff --git a/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByPath.php b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php similarity index 96% rename from app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByPath.php rename to app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php index 2f74afd099dfc..c088e9928f9b9 100644 --- a/app/code/Magento/MediaContent/Model/Plugin/MediaGalleryAssetDeleteByPath.php +++ b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\MediaContent\Model\Plugin; +namespace Magento\MediaContent\Plugin; use Magento\Framework\Exception\CouldNotDeleteException; use Magento\MediaContent\Model\RemoveRelationsForAssetIds; @@ -64,7 +64,7 @@ public function aroundExecute( ) : void { $asset = $this->getByPath->execute($mediaAssetPath); - $proceed(); + $proceed($mediaAssetPath); $this->removeRelationsForAssetIds->execute([$asset->getId()]); } diff --git a/app/code/Magento/MediaContent/etc/di.xml b/app/code/Magento/MediaContent/etc/di.xml index 578bed7588699..c4837a687389b 100644 --- a/app/code/Magento/MediaContent/etc/di.xml +++ b/app/code/Magento/MediaContent/etc/di.xml @@ -14,10 +14,10 @@ <preference for="Magento\MediaContentApi\Api\UpdateRelationsInterface" type="Magento\MediaContent\Model\UpdateRelations"/> <preference for="Magento\MediaContentApi\Api\Data\ContentIdentityInterface" type="Magento\MediaContent\Model\ContentIdentity"/> <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface"> - <plugin name="remove_media_content_after_asset_is_removed_by_path" type="Magento\MediaContent\Model\Plugin\MediaGalleryAssetDeleteByPath" /> + <plugin name="remove_media_content_after_asset_is_removed_by_path" type="Magento\MediaContent\Model\MediaGalleryAssetDeleteByPath" /> </type> <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByDirectoryPathInterface"> - <plugin name="remove_media_content_after_asset_is_removed_by_directory_path" type="Magento\MediaContent\Model\Plugin\MediaGalleryAssetDeleteByDirectoryPath" /> + <plugin name="remove_media_content_after_asset_is_removed_by_directory_path" type="Magento\MediaContent\Plugin\MediaGalleryAssetDeleteByDirectoryPath" /> </type> <virtualType name="Magento\MediaContent\Model\Content\Config\Reader" type="Magento\Framework\Config\Reader\Filesystem"> <arguments> From 9106468b2f4a714a51ca43bafa714ae7e785277a Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Thu, 9 Apr 2020 11:17:22 +0100 Subject: [PATCH 109/177] magento/magento2#27499: Extracted MediaGalleryCatalog module --- app/code/Magento/MediaGallery/composer.json | 3 +- app/code/Magento/MediaGallery/etc/di.xml | 4 -- .../Magento/MediaGallery/etc/directory.xml | 1 - .../Magento/MediaGalleryCatalog/LICENSE.txt | 48 +++++++++++++++++++ .../MediaGalleryCatalog/LICENSE_AFL.txt | 48 +++++++++++++++++++ .../Plugin/Product/Gallery/Processor.php | 20 ++++---- .../Magento/MediaGalleryCatalog/README.md | 17 +++++++ .../Plugin/Product/Gallery/ProcessorTest.php | 9 ++-- .../Magento/MediaGalleryCatalog/composer.json | 23 +++++++++ .../Magento/MediaGalleryCatalog/etc/di.xml | 13 +++++ .../MediaGalleryCatalog/etc/directory.xml | 14 ++++++ .../MediaGalleryCatalog/etc/module.xml | 10 ++++ .../MediaGalleryCatalog/registration.php | 9 ++++ 13 files changed, 196 insertions(+), 23 deletions(-) create mode 100644 app/code/Magento/MediaGalleryCatalog/LICENSE.txt create mode 100644 app/code/Magento/MediaGalleryCatalog/LICENSE_AFL.txt rename app/code/Magento/{MediaGallery => MediaGalleryCatalog}/Plugin/Product/Gallery/Processor.php (70%) create mode 100644 app/code/Magento/MediaGalleryCatalog/README.md rename app/code/Magento/{MediaGallery => MediaGalleryCatalog}/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php (94%) create mode 100644 app/code/Magento/MediaGalleryCatalog/composer.json create mode 100644 app/code/Magento/MediaGalleryCatalog/etc/di.xml create mode 100644 app/code/Magento/MediaGalleryCatalog/etc/directory.xml create mode 100644 app/code/Magento/MediaGalleryCatalog/etc/module.xml create mode 100644 app/code/Magento/MediaGalleryCatalog/registration.php diff --git a/app/code/Magento/MediaGallery/composer.json b/app/code/Magento/MediaGallery/composer.json index 977277d993061..686cec00b7f55 100644 --- a/app/code/Magento/MediaGallery/composer.json +++ b/app/code/Magento/MediaGallery/composer.json @@ -5,8 +5,7 @@ "php": "~7.1.3||~7.2.0||~7.3.0", "magento/framework": "*", "magento/module-media-gallery-api": "*", - "magento/module-cms": "*", - "magento/module-catalog": "*" + "magento/module-cms": "*" }, "type": "magento2-module", "license": [ diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index 25f4850427929..ab49d5fa3b25e 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -31,10 +31,6 @@ <preference for="Magento\MediaGalleryApi\Api\GetAssetsKeywordsInterface" type="Magento\MediaGallery\Model\ResourceModel\Keyword\GetAssetsKeywords"/> <preference for="Magento\MediaGalleryApi\Api\SaveAssetsKeywordsInterface" type="Magento\MediaGallery\Model\ResourceModel\Keyword\SaveAssetsKeywords"/> - <type name="Magento\Catalog\Model\Product\Gallery\Processor"> - <plugin name="media_gallery_image_remove_metadata" type="Magento\MediaGallery\Plugin\Product\Gallery\Processor" - sortOrder="10" disabled="false"/> - </type> <type name="Magento\Cms\Model\Wysiwyg\Images\Storage"> <plugin name="media_gallery_image_remove_metadata_after_wysiwyg" type="Magento\MediaGallery\Plugin\Wysiwyg\Images\Storage" sortOrder="10" disabled="false"/> diff --git a/app/code/Magento/MediaGallery/etc/directory.xml b/app/code/Magento/MediaGallery/etc/directory.xml index c6da55482976e..92f50b2dd0a30 100644 --- a/app/code/Magento/MediaGallery/etc/directory.xml +++ b/app/code/Magento/MediaGallery/etc/directory.xml @@ -9,7 +9,6 @@ <blacklist> <patterns> <pattern name="captcha">/^captcha/</pattern> - <pattern name="catalog">/^catalog\/product/</pattern> <pattern name="customer">/^customer/</pattern> <pattern name="downloadable">/^downloadable/</pattern> <pattern name="import">/^import/</pattern> diff --git a/app/code/Magento/MediaGalleryCatalog/LICENSE.txt b/app/code/Magento/MediaGalleryCatalog/LICENSE.txt new file mode 100644 index 0000000000000..49525fd99da9c --- /dev/null +++ b/app/code/Magento/MediaGalleryCatalog/LICENSE.txt @@ -0,0 +1,48 @@ + +Open Software License ("OSL") v. 3.0 + +This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Open Software License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + 1. to reproduce the Original Work in copies, either alone or as part of a collective work; + + 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; + + 4. to perform the Original Work publicly; and + + 5. to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including 'fair use' or 'fair dealing'). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright (C) 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. \ No newline at end of file diff --git a/app/code/Magento/MediaGalleryCatalog/LICENSE_AFL.txt b/app/code/Magento/MediaGalleryCatalog/LICENSE_AFL.txt new file mode 100644 index 0000000000000..f39d641b18a19 --- /dev/null +++ b/app/code/Magento/MediaGalleryCatalog/LICENSE_AFL.txt @@ -0,0 +1,48 @@ + +Academic Free License ("AFL") v. 3.0 + +This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: + +Licensed under the Academic Free License version 3.0 + + 1. Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: + + 1. to reproduce the Original Work in copies, either alone or as part of a collective work; + + 2. to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; + + 3. to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License; + + 4. to perform the Original Work publicly; and + + 5. to display the Original Work publicly. + + 2. Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. + + 3. Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. + + 4. Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. + + 5. External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). + + 6. Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. + + 7. Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. + + 8. Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. + + 9. Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). + + 10. Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. + + 11. Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. + + 12. Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. + + 13. Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. + + 14. Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + + 15. Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. + + 16. Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. diff --git a/app/code/Magento/MediaGallery/Plugin/Product/Gallery/Processor.php b/app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/Processor.php similarity index 70% rename from app/code/Magento/MediaGallery/Plugin/Product/Gallery/Processor.php rename to app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/Processor.php index 3fbe4e3a91a2b..c595d43009dd4 100644 --- a/app/code/Magento/MediaGallery/Plugin/Product/Gallery/Processor.php +++ b/app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/Processor.php @@ -3,25 +3,24 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - declare(strict_types=1); -namespace Magento\MediaGallery\Plugin\Product\Gallery; +namespace Magento\MediaGalleryCatalog\Plugin\Product\Gallery; -use Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface; +use Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Gallery\Processor as ProcessorSubject; use Psr\Log\LoggerInterface; /** - * Ensures that metadata is removed from the database when a product image has been deleted. + * Ensures that metadata is removed from the database when an image has been deleted (from legacy media gallery) */ class Processor { /** - * @var DeleteByPathInterface + * @var DeleteAssetsByPathsInterface */ - private $deleteMediaAssetByPath; + private $deleteByPaths; /** * @var LoggerInterface @@ -31,14 +30,14 @@ class Processor /** * Processor constructor. * - * @param DeleteByPathInterface $deleteMediaAssetByPath + * @param DeleteAssetsByPathsInterface $deleteByPaths * @param LoggerInterface $logger */ public function __construct( - DeleteByPathInterface $deleteMediaAssetByPath, + DeleteAssetsByPathsInterface $deleteByPaths, LoggerInterface $logger ) { - $this->deleteMediaAssetByPath = $deleteMediaAssetByPath; + $this->deleteByPaths = $deleteByPaths; $this->logger = $logger; } @@ -49,7 +48,6 @@ public function __construct( * @param ProcessorSubject $result * @param Product $product * @param string $file - * * @return ProcessorSubject * * @SuppressWarnings(PHPMD.UnusedFormalParameter) @@ -65,7 +63,7 @@ public function afterRemoveImage( } try { - $this->deleteMediaAssetByPath->execute($file); + $this->deleteByPaths->execute([$file]); } catch (\Exception $exception) { $this->logger->critical($exception); } diff --git a/app/code/Magento/MediaGalleryCatalog/README.md b/app/code/Magento/MediaGalleryCatalog/README.md new file mode 100644 index 0000000000000..b39b1fae756d5 --- /dev/null +++ b/app/code/Magento/MediaGalleryCatalog/README.md @@ -0,0 +1,17 @@ +# Magento_MediaGalleryCatalog module + +The Magento_MediaGalleryCatalog module is responsible for for catalog gallery processor delete operation handling + +## Installation details + +For information about module installation in Magento 2, see [Enable or disable modules](https://devdocs.magento.com/guides/v2.3/install-gde/install/cli/install-cli-subcommands-enable.html). + +## Extensibility + +Extension developers can interact with the Magento_MediaGallery module. For more information about the Magento extension mechanism, see [Magento plug-ins](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/plugins.html). + +[The Magento dependency injection mechanism](https://devdocs.magento.com/guides/v2.3/extension-dev-guide/depend-inj.html) enables you to override the functionality of the Magento_MediaGallery module. + +## Additional information + +For information about significant changes in patch releases, see [2.3.x Release information](https://devdocs.magento.com/guides/v2.3/release-notes/bk-release-notes.html). diff --git a/app/code/Magento/MediaGallery/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php b/app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php similarity index 94% rename from app/code/Magento/MediaGallery/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php rename to app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php index 94c3aaf5c2f19..c16150cbb3ad1 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php +++ b/app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php @@ -3,16 +3,15 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - declare(strict_types=1); -namespace Magento\MediaGallery\Test\Unit\Plugin\Product\Gallery; +namespace Magento\MediaGalleryCatalog\Test\Unit\Plugin\Product\Gallery; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Gallery\Processor as ProcessorSubject; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use Magento\MediaGallery\Plugin\Product\Gallery\Processor; -use Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface; +use Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; @@ -25,7 +24,7 @@ class ProcessorTest extends TestCase private const STUB_FILE_NAME = 'file'; /** - * @var DeleteByPathInterface|MockObject + * @var DeleteAssetsByPathsInterface|MockObject */ private $deleteMediaAssetByPathMock; @@ -57,7 +56,7 @@ protected function setUp() $this->processorSubjectMock = $this->createMock(ProcessorSubject::class); $this->productMock = $this->createMock(Product::class); - $this->deleteMediaAssetByPathMock = $this->getMockBuilder(DeleteByPathInterface::class) + $this->deleteMediaAssetByPathMock = $this->getMockBuilder(DeleteAssetsByPathsInterface::class) ->disableOriginalConstructor() ->setMethods(['execute']) ->getMockForAbstractClass(); diff --git a/app/code/Magento/MediaGalleryCatalog/composer.json b/app/code/Magento/MediaGalleryCatalog/composer.json new file mode 100644 index 0000000000000..8152fb5aac8bb --- /dev/null +++ b/app/code/Magento/MediaGalleryCatalog/composer.json @@ -0,0 +1,23 @@ +{ + "name": "magento/module-media-gallery", + "description": "Magento module responsible for catalog gallery processor delete operation handling", + "require": { + "php": "~7.1.3||~7.2.0||~7.3.0", + "magento/framework": "*", + "magento/module-media-gallery-api": "*", + "magento/module-catalog": "*" + }, + "type": "magento2-module", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "Magento\\MediaGalleryCatalog\\": "" + } + } +} diff --git a/app/code/Magento/MediaGalleryCatalog/etc/di.xml b/app/code/Magento/MediaGalleryCatalog/etc/di.xml new file mode 100644 index 0000000000000..41dfeaf14aace --- /dev/null +++ b/app/code/Magento/MediaGalleryCatalog/etc/di.xml @@ -0,0 +1,13 @@ +<?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:ObjectManager/etc/config.xsd"> + <type name="Magento\Catalog\Model\Product\Gallery\Processor"> + <plugin name="media_gallery_image_remove_metadata" type="Magento\MediaGallery\Plugin\Product\Gallery\Processor" + sortOrder="10" disabled="false"/> + </type> +</config> diff --git a/app/code/Magento/MediaGalleryCatalog/etc/directory.xml b/app/code/Magento/MediaGalleryCatalog/etc/directory.xml new file mode 100644 index 0000000000000..eaced3f642f70 --- /dev/null +++ b/app/code/Magento/MediaGalleryCatalog/etc/directory.xml @@ -0,0 +1,14 @@ +<?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:module:Magento_MediaGalleryApi:etc/directory.xsd"> + <blacklist> + <patterns> + <pattern name="catalog">/^catalog\/product/</pattern> + </patterns> + </blacklist> +</config> diff --git a/app/code/Magento/MediaGalleryCatalog/etc/module.xml b/app/code/Magento/MediaGalleryCatalog/etc/module.xml new file mode 100644 index 0000000000000..83f60ded3d35a --- /dev/null +++ b/app/code/Magento/MediaGalleryCatalog/etc/module.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:Module/etc/module.xsd"> + <module name="Magento_MediaGalleryCatalog"/> +</config> diff --git a/app/code/Magento/MediaGalleryCatalog/registration.php b/app/code/Magento/MediaGalleryCatalog/registration.php new file mode 100644 index 0000000000000..3c24d0c298f38 --- /dev/null +++ b/app/code/Magento/MediaGalleryCatalog/registration.php @@ -0,0 +1,9 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_MediaGalleryCatalog', __DIR__); From 96d38623ae9d44ab576bc07eb3ff702bac2b7b4a Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Thu, 9 Apr 2020 11:55:07 +0100 Subject: [PATCH 110/177] magento/magento2#27499: Corrected services implementation --- .../{CreateByPath.php => CreateByPaths.php} | 2 +- .../{DeleteByPath.php => DeleteByPaths.php} | 2 +- .../ResourceModel/DeleteAssetsByPaths.php | 7 +++- .../Model/ResourceModel/GetAssetsByIds.php | 34 ++++++++++++------- .../Model/ResourceModel/GetAssetsByPaths.php | 32 ++++++++++------- .../Model/ResourceModel/SaveAssets.php | 2 +- .../Plugin/Wysiwyg/Images/Storage.php | 17 +++++++--- app/code/Magento/MediaGallery/etc/di.xml | 4 +-- 8 files changed, 65 insertions(+), 35 deletions(-) rename app/code/Magento/MediaGallery/Model/Directory/Command/{CreateByPath.php => CreateByPaths.php} (96%) rename app/code/Magento/MediaGallery/Model/Directory/Command/{DeleteByPath.php => DeleteByPaths.php} (95%) diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php similarity index 96% rename from app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php rename to app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php index b85a9cf30ef51..a6b09ed8cda62 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPath.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php @@ -15,7 +15,7 @@ /** * Create folder by provided path */ -class CreateByPath implements CreateDirectoriesByPathsInterface +class CreateByPaths implements CreateDirectoriesByPathsInterface { /** * @var LoggerInterface diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php b/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php similarity index 95% rename from app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php rename to app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php index c6b2f396e364e..9be25574822ae 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPath.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php @@ -15,7 +15,7 @@ /** * Delete directory from media storage by path */ -class DeleteByPath implements DeleteDirectoriesByPathsInterface +class DeleteByPaths implements DeleteDirectoriesByPathsInterface { /** * @var LoggerInterface diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsByPaths.php b/app/code/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsByPaths.php index c263b3937e0d2..d965ed63de5fd 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsByPaths.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsByPaths.php @@ -74,7 +74,12 @@ public function execute(array $paths): void } } - private function deleteAssetsByDirectoryPath(string $path) + /** + * Delete assets from database based on the first part (beginning) of the path + * + * @param string $path + */ + private function deleteAssetsByDirectoryPath(string $path): void { // Make sure that the path has a trailing slash $path = rtrim($path, '/') . '/'; diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByIds.php b/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByIds.php index ec3183e481370..89daded071c33 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByIds.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByIds.php @@ -57,24 +57,32 @@ public function __construct( */ public function execute(array $ids): array { + $assets = []; try { - $mediaAssetTable = $this->resourceConnection->getTableName(self::TABLE_MEDIA_GALLERY_ASSET); - $connection = $this->resourceConnection->getConnection(); - $select = $connection->select() - ->from(['amg' => $mediaAssetTable]) - ->where('amg.id IN (?)', $ids); - $assetsData = $connection->query($select)->fetchAll(); + foreach ($this->getAssetsData($ids) as $assetData) { + $assets[] = $this->assetFactory->create(['data' => $assetData]); + } } catch (\Exception $exception) { $this->logger->critical($exception); throw new LocalizedException(__('Could not retrieve media assets'), $exception); } - - $assets = []; - - foreach ($assetsData as $assetData) { - $assets[] = $this->assetFactory->create(['data' => $assetData]); - } - return $assets; } + + /** + * Retrieve assets data from database + * + * @param array $ids + * @return array + * @throws \Zend_Db_Statement_Exception + */ + private function getAssetsData(array $ids): array + { + $mediaAssetTable = $this->resourceConnection->getTableName(self::TABLE_MEDIA_GALLERY_ASSET); + $connection = $this->resourceConnection->getConnection(); + $select = $connection->select() + ->from(['amg' => $mediaAssetTable]) + ->where('amg.id IN (?)', $ids); + return $connection->query($select)->fetchAll(); + } } diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php b/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php index 78aa5fe471df9..93c66e9a7fe51 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php @@ -58,12 +58,11 @@ public function __construct( */ public function execute(array $paths): array { + $assets = []; try { - $connection = $this->resourceConnection->getConnection(); - $select = $connection->select() - ->from($this->resourceConnection->getTableName(self::TABLE_MEDIA_GALLERY_ASSET)) - ->where(self::MEDIA_GALLERY_ASSET_PATH . ' IN (?)', $paths); - $assetsData = $connection->query($select)->fetchAll(); + foreach ($this->getAssetsData($paths) as $assetData) { + $assets[] = $this->mediaAssetFactory->create(['data' => $assetData]); + } } catch (\Exception $exception) { $this->logger->critical($exception); throw new LocalizedException( @@ -75,13 +74,22 @@ public function execute(array $paths): array ) ); } - - $assets = []; - - foreach ($assetsData as $assetData) { - $assets[] = $this->mediaAssetFactory->create(['data' => $assetData]); - } - return $assets; } + + /** + * Retrieve assets data from database + * + * @param array $paths + * @return array + * @throws \Zend_Db_Statement_Exception + */ + private function getAssetsData(array $paths): array + { + $connection = $this->resourceConnection->getConnection(); + $select = $connection->select() + ->from($this->resourceConnection->getTableName(self::TABLE_MEDIA_GALLERY_ASSET)) + ->where(self::MEDIA_GALLERY_ASSET_PATH . ' IN (?)', $paths); + return $connection->query($select)->fetchAll(); + } } diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php b/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php index e75acca66d0f4..84733ca2ff1c6 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php @@ -79,7 +79,7 @@ public function execute(array $assets): void __( 'Could not save the media assets: %assets', [ - 'assets' => $failedAssets + 'assets' => implode(' ,', $failedAssets) ] ) ); diff --git a/app/code/Magento/MediaGallery/Plugin/Wysiwyg/Images/Storage.php b/app/code/Magento/MediaGallery/Plugin/Wysiwyg/Images/Storage.php index 11331e4b9303f..11cb0f0dfd920 100644 --- a/app/code/Magento/MediaGallery/Plugin/Wysiwyg/Images/Storage.php +++ b/app/code/Magento/MediaGallery/Plugin/Wysiwyg/Images/Storage.php @@ -88,7 +88,7 @@ public function afterDeleteFile(StorageSubject $subject, StorageSubject $result, return $result; } - $relativePath = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA)->getRelativePath($target); + $relativePath = $this->getMediaDirectoryRelativePath($target); if (!$relativePath) { return $result; } @@ -120,13 +120,22 @@ public function afterDeleteDirectory(StorageSubject $subject, $result, $path) } try { - $mediaDirectoryRead = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA); - $relativePath = $mediaDirectoryRead->getRelativePath($path); - $this->deleteMediaAssetByDirectoryPath->execute($relativePath); + $this->deleteMediaAssetByDirectoryPath->execute($this->getMediaDirectoryRelativePath($path)); } catch (ValidatorException $exception) { $this->logger->critical($exception); } return $result; } + + /** + * Get path relative to media directory + * + * @param string $path + * @return string + */ + private function getMediaDirectoryRelativePath(string $path): string + { + return $this->filesystem->getDirectoryRead(DirectoryList::MEDIA)->getRelativePath($path); + } } diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index ab49d5fa3b25e..4fcc18e29726c 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -19,8 +19,8 @@ <preference for="Magento\MediaGalleryApi\Model\Keyword\Command\GetAssetKeywordsInterface" type="Magento\MediaGallery\Model\Keyword\Command\GetAssetKeywords"/> <preference for="Magento\MediaGalleryApi\Model\Keyword\Command\SaveAssetKeywordsInterface" type="Magento\MediaGallery\Model\Keyword\Command\SaveAssetKeywords"/> - <preference for="Magento\MediaGalleryApi\Api\CreateDirectoriesByPathsInterface" type="Magento\MediaGallery\Model\Directory\Command\CreateByPath"/> - <preference for="Magento\MediaGalleryApi\Api\DeleteDirectoriesByPathsInterface" type="Magento\MediaGallery\Model\Directory\Command\DeleteByPath"/> + <preference for="Magento\MediaGalleryApi\Api\CreateDirectoriesByPathsInterface" type="Magento\MediaGallery\Model\Directory\Command\CreateByPaths"/> + <preference for="Magento\MediaGalleryApi\Api\DeleteDirectoriesByPathsInterface" type="Magento\MediaGallery\Model\Directory\Command\DeleteByPaths"/> <preference for="Magento\MediaGalleryApi\Api\IsPathBlacklistedInterface" type="Magento\MediaGallery\Model\Directory\IsBlacklisted"/> From 88cb58901068236c9a57e557d5471744391617c2 Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Thu, 9 Apr 2020 15:37:35 +0300 Subject: [PATCH 111/177] add AdminClickFirstRowOrderGridActionGroup --- .../Test/AdminDashboardWithChartsChart.xml | 7 +++---- ...ProductWithZeroPriceToShoppingCartTest.xml | 4 ++-- ...ctCustomOptionsDifferentStoreViewsTest.xml | 4 ++-- ...thCustomOptionsWithLongValuesTitleTest.xml | 4 ++-- ...tedProductToConfigurableOutOfStockTest.xml | 3 +-- ...efrontApplyPromoCodeDuringCheckoutTest.xml | 4 ++-- .../StorefrontGuestCheckoutTest.xml | 3 +-- ...SubtotalOrdersWithProcessingStatusTest.xml | 4 ++-- .../ProductsQtyReturnAfterOrderCancelTest.xml | 3 +-- .../Test/AdminCreatingShippingLabelTest.xml | 2 +- ...AdminClickFirstRowOrderGridActionGroup.xml | 19 +++++++++++++++++++ ...ectnessInvoicedItemInBundleProductTest.xml | 3 +-- .../Test/Mftf/Test/AdminCreateInvoiceTest.xml | 3 +-- ...editMemoTotalAfterShippingDiscountTest.xml | 3 +-- 14 files changed, 39 insertions(+), 27 deletions(-) create mode 100644 app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickFirstRowOrderGridActionGroup.xml diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml index 147f2fa1dfaed..55b1648d1f23f 100644 --- a/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml +++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml @@ -83,8 +83,8 @@ <waitForLoadingMaskToDisappear stepKey="waitForSearchingOrder"/> <!-- Create invoice --> <comment userInput="Create invoice" stepKey="createInvoice"/> - <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> - <waitForPageLoad stepKey="waitForOrderPageToLoad"/> + + <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> <click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceButton"/> <waitForPageLoad stepKey="waitForInvoicePageToLoad"/> <see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Invoice" stepKey="seeNewInvoiceInPageTitle" after="clickInvoiceButton"/> @@ -95,8 +95,7 @@ <comment userInput="Create Shipment for the order" stepKey="createShipmentForOrder"/> <amOnPage url="{{AdminOrdersPage.url}}" stepKey="onOrdersPage2"/> <waitForPageLoad time="30" stepKey="waitForOrderListPageLoading"/> - <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="openOrderPageForShip"/> - <waitForPageLoad stepKey="waitForOrderDetailsPage"/> + <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="openOrderPageForShip"/> <click selector="{{AdminOrderDetailsMainActionsSection.ship}}" stepKey="clickShipAction"/> <waitForPageLoad stepKey="waitForShipmentPagePage"/> <seeInCurrentUrl url="{{AdminShipmentNewPage.url}}" stepKey="seeOrderShipmentUrl"/> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAddBundleProductWithZeroPriceToShoppingCartTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAddBundleProductWithZeroPriceToShoppingCartTest.xml index 1a40489387197..5c75441f85b9c 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAddBundleProductWithZeroPriceToShoppingCartTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAddBundleProductWithZeroPriceToShoppingCartTest.xml @@ -70,8 +70,8 @@ <actionGroup ref="FilterOrderGridByIdActionGroup" stepKey="filterOrderById"> <argument name="orderId" value="$grabOrderNumber"/> </actionGroup> - <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> - <waitForPageLoad stepKey="waitForAdminOrderPageLoad"/> + + <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> <scrollTo selector="{{AdminOrderTotalSection.subTotal}}" stepKey="scrollToOrderTotalSection"/> <see selector="{{AdminOrderTotalSection.subTotal}}" userInput="$0.00" stepKey="checkSubtotal"/> </test> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml index 95af6e299662b..cfa82ab18e9a4 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml @@ -199,8 +199,8 @@ <actionGroup ref="FilterOrderGridByIdActionGroup" stepKey="openOrdersGrid"> <argument name="orderId" value="{$grabOrderNumber}"/> </actionGroup> - <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> - <waitForPageLoad time="30" stepKey="waitForPageLoad10"/> + + <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> <!-- Checking the correctness of displayed custom options for user parameters on Order --> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsWithLongValuesTitleTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsWithLongValuesTitleTest.xml index 3c1dc2bc844cf..f539940f1cdc1 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsWithLongValuesTitleTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsWithLongValuesTitleTest.xml @@ -104,8 +104,8 @@ <fillField selector="{{AdminOrdersGridSection.search}}" userInput="{$grabOrderNumber}" stepKey="fillOrderNum"/> <click selector="{{AdminOrdersGridSection.submitSearch}}" stepKey="submitSearchOrderNum"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappearOnSearch"/> - <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> - <waitForPageLoad stepKey="waitForOrderPageToLoad"/> + + <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> <!-- Checking the correctness of displayed custom options for user parameters on Order --> diff --git a/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml b/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml index b291fb46ae71c..84da79f64f700 100644 --- a/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml +++ b/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml @@ -124,8 +124,7 @@ <click selector="{{AdminOrdersGridSection.submitSearch}}" stepKey="submitSearch"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask4"/> - <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> - <waitForPageLoad stepKey="waitForOrderPageToLoad"/> + <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> <click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoice"/> <waitForPageLoad stepKey="waitForNewInvoicePageToLoad"/> <click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="clickSubmitInvoice"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontApplyPromoCodeDuringCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontApplyPromoCodeDuringCheckoutTest.xml index e4eb53a1f1925..5b48c014ef713 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontApplyPromoCodeDuringCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontApplyPromoCodeDuringCheckoutTest.xml @@ -83,8 +83,8 @@ <actionGroup ref="FilterOrderGridByIdActionGroup" stepKey="filterOrderById"> <argument name="orderId" value="$grabOrderNumber"/> </actionGroup> - <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> - <waitForPageLoad stepKey="waitForAdminOrderPageLoad"/> + + <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> <scrollTo selector="{{AdminOrderTotalSection.grandTotal}}" stepKey="scrollToOrderTotalSection"/> <see selector="{{AdminOrderTotalSection.grandTotal}}" userInput="$$createProduct.price$$" stepKey="checkTotal"/> </test> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest/StorefrontGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest/StorefrontGuestCheckoutTest.xml index 5c06f9ed55067..9c2c18242c3b3 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest/StorefrontGuestCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest/StorefrontGuestCheckoutTest.xml @@ -64,8 +64,7 @@ <fillField selector="{{AdminOrdersGridSection.search}}" userInput="{$grabOrderNumber}" stepKey="fillOrderNum"/> <click selector="{{AdminOrdersGridSection.submitSearch}}" stepKey="submitSearchOrderNum"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappearOnSearch"/> - <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> - <waitForPageLoad stepKey="waitForOrderPageToLoad"/> + <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> <see selector="{{AdminOrderDetailsInformationSection.orderStatus}}" userInput="Pending" stepKey="seeAdminOrderStatus"/> <see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="{{CustomerEntityOne.fullname}}" stepKey="seeAdminOrderGuest"/> <see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="{{CustomerEntityOne.email}}" stepKey="seeAdminOrderEmail"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml index 542c0ed6586e9..75e6f44c8f776 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml @@ -93,8 +93,8 @@ <actionGroup ref="FilterOrderGridByIdActionGroup" stepKey="filterOrderGridById"> <argument name="orderId" value="$grabOrderNumber"/> </actionGroup> - <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> - <waitForPageLoad stepKey="waitForCreatedOrderPageOpened"/> + + <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> <!--Verify that Created order is in Processing status--> <see selector="{{AdminShipmentOrderInformationSection.orderStatus}}" userInput="Processing" stepKey="seeShipmentOrderStatus"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/ProductsQtyReturnAfterOrderCancelTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/ProductsQtyReturnAfterOrderCancelTest.xml index 355c4fa049f01..a01bcb786795a 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/ProductsQtyReturnAfterOrderCancelTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/ProductsQtyReturnAfterOrderCancelTest.xml @@ -70,8 +70,7 @@ <argument name="orderId" value="$grabOrderNumber"/> </actionGroup> - <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> - <waitForPageLoad stepKey="waitForOrderPageToLoad"/> + <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> <click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceButton"/> <waitForPageLoad stepKey="waitForNewInvoicePageLoad"/> <fillField selector="{{AdminInvoiceItemsSection.qtyToInvoiceColumn}}" userInput="1" stepKey="ChangeQtyToInvoice"/> diff --git a/app/code/Magento/Fedex/Test/Mftf/Test/AdminCreatingShippingLabelTest.xml b/app/code/Magento/Fedex/Test/Mftf/Test/AdminCreatingShippingLabelTest.xml index 3850bfabc0c34..bd84dce153001 100644 --- a/app/code/Magento/Fedex/Test/Mftf/Test/AdminCreatingShippingLabelTest.xml +++ b/app/code/Magento/Fedex/Test/Mftf/Test/AdminCreatingShippingLabelTest.xml @@ -109,7 +109,7 @@ <actionGroup ref="SearchAdminDataGridByKeywordActionGroup" stepKey="searchOrder"> <argument name="keyword" value="$grabOrderNumber"/> </actionGroup> - <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> + <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> <!--Create Invoice--> <actionGroup ref="AdminCreateInvoiceActionGroup" stepKey="createInvoice"/> <!--Create shipping label--> diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickFirstRowOrderGridActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickFirstRowOrderGridActionGroup.xml new file mode 100644 index 0000000000000..ffbbee5d0c276 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickFirstRowOrderGridActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminClickFirstRowOrderGridActionGroup"> + <annotations> + <description>Click on first row of Order Grid.</description> + </annotations> + + <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickFirstOrderRow"/> + <waitForPageLoad stepKey="waitForOrderPageLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml index 69e3ade9231d0..3b4e3b79c1142 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml @@ -81,8 +81,7 @@ <actionGroup ref="FilterOrderGridByIdActionGroup" stepKey="filterOrderGridById"> <argument name="orderId" value="$grabOrderNumber"/> </actionGroup> - <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> - <waitForPageLoad stepKey="waitForCreatedOrderPageOpened"/> + <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> <actionGroup ref="GoToInvoiceIntoOrderActionGroup" stepKey="goToInvoiceIntoOrderPage"/> <fillField selector="{{AdminInvoiceItemsSection.qtyToInvoiceColumn}}" userInput="5" stepKey="ChangeQtyToInvoice"/> <click selector="{{AdminInvoiceItemsSection.updateQty}}" stepKey="updateQuantity"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml index 1411f7b292757..386f736525ebb 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml @@ -68,8 +68,7 @@ <click selector="{{AdminOrdersGridSection.submitSearch}}" stepKey="submitSearch"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask4"/> - <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> - <waitForPageLoad stepKey="waitForOrderPageToLoad"/> + <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> <click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoice"/> <waitForPageLoad stepKey="waitForNewInvoicePageToLoad"/> <click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="clickSubmitInvoice"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml index 09197963434eb..1f35a42b5a657 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml @@ -103,8 +103,7 @@ <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask4"/> <!-- Create invoice --> - <click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRow"/> - <waitForPageLoad stepKey="waitForOrderPageToLoad"/> + <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> <click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceButton"/> <waitForPageLoad stepKey="waitForNewInvoicePageToLoad"/> <see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Invoice" stepKey="seeNewInvoiceInPageTitle" after="clickInvoiceButton"/> From e7a78fae7c23cbcfab75d126644f558808cbea24 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Thu, 9 Apr 2020 14:16:50 +0100 Subject: [PATCH 112/177] magento/magento2#27499: Fixed directory integration tests --- .../Model/Directory/Command/CreateByPaths.php | 6 +- .../Model/Directory/Command/DeleteByPaths.php | 4 +- .../Keyword/GetAssetsKeywords.php | 5 +- ...teByPathTest.php => CreateByPathsTest.php} | 50 +++++++--- ...teByPathTest.php => DeleteByPathsTest.php} | 53 ++++++---- .../File/Command/DeleteByAssertIdTest.php | 99 ------------------- 6 files changed, 78 insertions(+), 139 deletions(-) rename dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/{CreateByPathTest.php => CreateByPathsTest.php} (58%) rename dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/{DeleteByPathTest.php => DeleteByPathsTest.php} (53%) delete mode 100644 dev/tests/integration/testsuite/Magento/MediaGallery/Model/File/Command/DeleteByAssertIdTest.php diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php index a6b09ed8cda62..cbd2f08365246 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php @@ -47,7 +47,7 @@ public function execute(array $paths): void $failedPaths = []; foreach ($paths as $path) { try { - $name = end(explode('/', $path)); + $name = basename($path); $this->storage->createDirectory( $name, $this->storage->getCmsWysiwygImages()->getStorageRoot() . $path @@ -62,7 +62,9 @@ public function execute(array $paths): void throw new CouldNotSaveException( __( 'Could not save directories: %paths', - implode(' ,', $failedPaths) + [ + 'paths' => implode(' ,', $failedPaths) + ] ) ); } diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php b/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php index 9be25574822ae..b313fdb368e12 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php @@ -58,7 +58,9 @@ public function execute(array $paths): void throw new CouldNotDeleteException( __( 'Could not delete directories: %paths', - implode(' ,', $failedPaths) + [ + 'paths' => implode(' ,', $failedPaths) + ] ) ); } diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php index a83c6e28b2d94..40df55805d955 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php @@ -69,11 +69,10 @@ public function __construct( public function execute(array $assetIds): array { try { - $this->getAssetKeywords($this->getKeywordsData($assetIds)); + return $this->getAssetKeywords($this->getKeywordsData($assetIds)); } catch (\Exception $exception) { $this->logger->critical($exception); - $message = __('An error occurred during get asset keywords: %1', $exception->getMessage()); - throw new IntegrationException($message, $exception); + throw new IntegrationException(__('Could not retrieve asset keywords.'), $exception); } } diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathsTest.php similarity index 58% rename from dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php rename to dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathsTest.php index 63daab064e5e1..c35ba75be34ff 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathsTest.php @@ -10,13 +10,13 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Filesystem; -use Magento\MediaGalleryApi\Model\Directory\Command\CreateByPathInterface; +use Magento\MediaGalleryApi\Api\CreateDirectoriesByPathsInterface; use Magento\TestFramework\Helper\Bootstrap; /** * Test methods of class CreateByPath */ -class CreateByPathTest extends \PHPUnit\Framework\TestCase +class CreateByPathsTest extends \PHPUnit\Framework\TestCase { /** * Test directory name @@ -24,54 +24,74 @@ class CreateByPathTest extends \PHPUnit\Framework\TestCase private const TEST_DIRECTORY_NAME = 'testCreateDirectory'; /** - * Absolute path to the media direcrory + * Absolute path to the media directory */ private $mediaDirectoryPath; /** - * @var CreateByPathInterface + * @var CreateDirectoriesByPathsInterface */ - private $createByPath; + private $createByPaths; /** * @inheritdoc */ public function setUp() { - $this->createByPath = Bootstrap::getObjectManager()->get(CreateByPathInterface::class); + $this->createByPaths = Bootstrap::getObjectManager()->get(CreateDirectoriesByPathsInterface::class); $this->mediaDirectoryPath = Bootstrap::getObjectManager()->get(Filesystem::class) ->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath(); } /** - * @return void * @throws \Magento\Framework\Exception\CouldNotSaveException */ public function testCreateDirectory(): void { - $fullPath = $this->mediaDirectoryPath . self::TEST_DIRECTORY_NAME; - $this->createByPath->execute('', self::TEST_DIRECTORY_NAME); - $this->assertFileExists($fullPath); + $this->createByPaths->execute([self::TEST_DIRECTORY_NAME]); + $this->assertFileExists($this->mediaDirectoryPath . self::TEST_DIRECTORY_NAME); } /** - * @return void * @throws \Magento\Framework\Exception\CouldNotSaveException * @expectedException \Magento\Framework\Exception\CouldNotSaveException */ public function testCreateDirectoryThatAlreadyExist(): void { - $this->createByPath->execute('', self::TEST_DIRECTORY_NAME); + $this->createByPaths->execute([self::TEST_DIRECTORY_NAME]); + $this->assertFileExists($this->mediaDirectoryPath . self::TEST_DIRECTORY_NAME); + $this->createByPaths->execute([self::TEST_DIRECTORY_NAME]); } /** - * @return void + * @param array $paths * @throws \Magento\Framework\Exception\CouldNotSaveException * @expectedException \Magento\Framework\Exception\CouldNotSaveException + * @dataProvider notAllowedPathsProvider */ - public function testCreateDirectoryWithRelativePath(): void + public function testCreateDirectoryWithRelativePath(array $paths): void { - $this->createByPath->execute('../../pub/', self::TEST_DIRECTORY_NAME); + $this->createByPaths->execute($paths); + } + + /** + * Provider of paths that are not allowed for deletion + * + * @return array + */ + public function notAllowedPathsProvider(): array + { + return [ + [ + ['../../pub/' . self::TEST_DIRECTORY_NAME] + ], + [ + ['theme/' . self::TEST_DIRECTORY_NAME] + ], + [ + ['../../pub/media', 'theme'] + ] + ]; } /** diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathsTest.php similarity index 53% rename from dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php rename to dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathsTest.php index 01234db0241d7..8d9439bbae876 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathsTest.php @@ -10,64 +10,82 @@ use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\Filesystem; -use Magento\MediaGalleryApi\Model\Directory\Command\DeleteByPathInterface; +use Magento\MediaGalleryApi\Api\DeleteDirectoriesByPathsInterface; use Magento\TestFramework\Helper\Bootstrap; /** * Test methods of class DeleteByPath */ -class DeleteByPathTest extends \PHPUnit\Framework\TestCase +class DeleteByPathsTest extends \PHPUnit\Framework\TestCase { /** - * @var DeleteByPathInterface + * @var DeleteDirectoriesByPathsInterface */ - private $deleteByPath; + private $deleteByPaths; /** * @var string */ private $testDirectoryName = 'testDeleteDirectory'; + /** + * @var Filesystem + */ + private $filesystem; + /** * @inheritdoc */ public function setUp() { - $this->deleteByPath = Bootstrap::getObjectManager()->create(DeleteByPathInterface::class); + $this->deleteByPaths = Bootstrap::getObjectManager()->get(DeleteDirectoriesByPathsInterface::class); + $this->filesystem = Bootstrap::getObjectManager()->get(Filesystem::class); } /** * @throws \Magento\Framework\Exception\CouldNotDeleteException * @throws \Magento\Framework\Exception\FileSystemException */ - public function testDeleteDirectoryWithExistingDirectoryAndCorrectAbsolutePath(): void + public function testDeleteDirectory(): void { /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $mediaDirectory */ - $mediaDirectory = Bootstrap::getObjectManager()->get(Filesystem::class) - ->getDirectoryRead(DirectoryList::MEDIA); + $mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); $mediaDirectory->create($this->testDirectoryName); $fullPath = $mediaDirectory->getAbsolutePath($this->testDirectoryName); $this->assertFileExists($fullPath); - $this->deleteByPath->execute($this->testDirectoryName); + $this->deleteByPaths->execute([$this->testDirectoryName]); $this->assertFileNotExists($fullPath); } /** + * @param array $paths * @throws \Magento\Framework\Exception\CouldNotDeleteException * @expectedException \Magento\Framework\Exception\CouldNotDeleteException + * @dataProvider notAllowedPathsProvider */ - public function testDeleteDirectoryWithRelativePathUnderMediaFolder(): void + public function testDeleteDirectoryThatIsNotAllowed(array $paths): void { - $this->deleteByPath->execute('../../pub/media'); + $this->deleteByPaths->execute($paths); } /** - * @throws \Magento\Framework\Exception\CouldNotDeleteException - * @expectedException \Magento\Framework\Exception\CouldNotDeleteException + * Provider of paths that are not allowed for deletion + * + * @return array */ - public function testDeleteDirectoryThatIsNotAllowed(): void + public function notAllowedPathsProvider(): array { - $this->deleteByPath->execute('theme'); + return [ + [ + ['../../pub/media'] + ], + [ + ['theme'] + ], + [ + ['../../pub/media', 'theme'] + ] + ]; } /** @@ -75,10 +93,7 @@ public function testDeleteDirectoryThatIsNotAllowed(): void */ public function tearDown() { - $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get(\Magento\Framework\Filesystem::class); - /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $directory */ - $directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); + $directory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); if ($directory->isExist($this->testDirectoryName)) { $directory->delete($this->testDirectoryName); } diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/File/Command/DeleteByAssertIdTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/File/Command/DeleteByAssertIdTest.php deleted file mode 100644 index 5acfb6170e155..0000000000000 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/File/Command/DeleteByAssertIdTest.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - * - */ -namespace Magento\MediaGallery\Model\Directory\Command; - -use Magento\Framework\App\Filesystem\DirectoryList; -use Magento\Framework\Filesystem; -use Magento\MediaGallery\Model\File\Command\DeleteByAssetId; -use Magento\MediaGalleryApi\Model\File\Command\DeleteByAssetIdInterface; -use Magento\TestFramework\Helper\Bootstrap; -use Magento\MediaGalleryApi\Model\Asset\Command\GetByIdInterface; - -/** - * Test methods of class DeleteByAssertIdTest - */ -class DeleteByAssertIdTest extends \PHPUnit\Framework\TestCase -{ - /** - * Test directory name - */ - private CONST TEST_DIRECTORY_NAME = 'testDirectory'; - - /** - * Absolute path to the media directory - */ - private static $_mediaPath; - - /** - * @var DeleteByAssetId - */ - private $deleteByAssetId; - - /** - * @inheritdoc - */ - public static function setUpBeforeClass() - { - /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $directory */ - $directory = Bootstrap::getObjectManager()->get(Filesystem::class)->getDirectoryWrite(DirectoryList::MEDIA); - self::$_mediaPath = $directory->getAbsolutePath(); - $directory->create(self::TEST_DIRECTORY_NAME); - $directory->touch(self::TEST_DIRECTORY_NAME . '/path.jpg'); - } - - /** - * @inheritdoc - */ - public function setUp() - { - $this->deleteByAssetId = Bootstrap::getObjectManager()->create(DeleteByAssetIdInterface::class); - } - - /** - * @magentoDataFixture Magento/MediaGallery/_files/media_asset.php - * @return void - * @throws \Magento\Framework\Exception\LocalizedException - */ - public function testDeleteByAssetIdWithExistingAsset(): void - { - $fullPath = self::$_mediaPath . self::TEST_DIRECTORY_NAME . '/path.jpg'; - $getById = Bootstrap::getObjectManager()->get(GetByIdInterface::class); - $this->assertFileExists($fullPath); - $this->assertEquals(1, $getById->execute(1)->getId()); - $this->deleteByAssetId->execute(1); - $this->assertFileNotExists($fullPath); - $this->expectException(\Magento\Framework\Exception\NoSuchEntityException::class); - $getById->execute(1); - } - - /** - * @magentoDataFixture Magento/MediaGallery/_files/media_asset.php - * @return void - * @throws \Magento\Framework\Exception\LocalizedException - * @expectedException \Magento\Framework\Exception\LocalizedException - */ - public function testDeleteByAssetIdWithoutAsset(): void - { - $fullPath = self::$_mediaPath . self::TEST_DIRECTORY_NAME . '/path.jpg'; - $this->assertFileNotExists($fullPath); - $this->deleteByAssetId->execute(1); - } - - /** - * @throws \Magento\Framework\Exception\FileSystemException - */ - public static function tearDownAfterClass() - { - $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get(\Magento\Framework\Filesystem::class); - /** @var \Magento\Framework\Filesystem\Directory\WriteInterface $directory */ - $directory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA); - if ($directory->isExist(self::TEST_DIRECTORY_NAME)) { - $directory->delete(self::TEST_DIRECTORY_NAME); - } - } -} From 788540b07d0c0f538386010e82dd65fd17ea782e Mon Sep 17 00:00:00 2001 From: Yurii Sapiha <yurasapiga93@gmail.com> Date: Thu, 9 Apr 2020 16:25:28 +0300 Subject: [PATCH 113/177] MC-32704: Storefront: My Downloadable Products tab on customer profile page --- .../RemoveLinkPurchasedByOrderIncrementId.php | 48 +++++ .../Downloadable/Block/Account/LinkTest.php | 67 +++++++ .../Customer/Products/ListProductsTest.php | 181 ++++++++++++++++++ ...with_customer_and_downloadable_product.php | 78 ++++++++ ...omer_and_downloadable_product_rollback.php | 33 ++++ 5 files changed, 407 insertions(+) create mode 100644 dev/tests/integration/framework/Magento/TestFramework/Downloadable/Model/RemoveLinkPurchasedByOrderIncrementId.php create mode 100644 dev/tests/integration/testsuite/Magento/Downloadable/Block/Account/LinkTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Downloadable/Block/Customer/Products/ListProductsTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Downloadable/_files/order_with_customer_and_downloadable_product.php create mode 100644 dev/tests/integration/testsuite/Magento/Downloadable/_files/order_with_customer_and_downloadable_product_rollback.php diff --git a/dev/tests/integration/framework/Magento/TestFramework/Downloadable/Model/RemoveLinkPurchasedByOrderIncrementId.php b/dev/tests/integration/framework/Magento/TestFramework/Downloadable/Model/RemoveLinkPurchasedByOrderIncrementId.php new file mode 100644 index 0000000000000..7f27ab0932b42 --- /dev/null +++ b/dev/tests/integration/framework/Magento/TestFramework/Downloadable/Model/RemoveLinkPurchasedByOrderIncrementId.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\TestFramework\Downloadable\Model; + +use Magento\Downloadable\Model\ResourceModel\Link\Purchased as PurchasedResource; +use Magento\Downloadable\Model\ResourceModel\Link\Purchased\CollectionFactory; + +/** + * Delete records from downloadable_link_purchased associated with provided order + */ +class RemoveLinkPurchasedByOrderIncrementId +{ + /** @var CollectionFactory */ + private $linkCollectionFactory; + + /** @var PurchasedResource */ + private $purchasedResource; + + /** + * @param CollectionFactory $linkCollectionFactory + * @param PurchasedResource $purchasedResource + */ + public function __construct(CollectionFactory $linkCollectionFactory, PurchasedResource $purchasedResource) + { + $this->linkCollectionFactory = $linkCollectionFactory; + $this->purchasedResource = $purchasedResource; + } + + /** + * Remove records from downloadable_link_purchased related to provided order + * + * @param string $orderIncrementId + * @return void + */ + public function execute(string $orderIncrementId): void + { + $collection = $this->linkCollectionFactory->create(); + $collection->addFieldToFilter('order_increment_id', $orderIncrementId); + foreach ($collection as $item) { + $this->purchasedResource->delete($item); + } + } +} diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/Block/Account/LinkTest.php b/dev/tests/integration/testsuite/Magento/Downloadable/Block/Account/LinkTest.php new file mode 100644 index 0000000000000..8916fc4853b05 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Downloadable/Block/Account/LinkTest.php @@ -0,0 +1,67 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Downloadable\Block\Account; + +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\Result\Page; +use Magento\Framework\View\Result\PageFactory; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Checks My Downloadable Product link displaying in account dashboard + * + * @magentoAppArea frontend + * @magentoDbIsolation enabled + */ +class LinkTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Page */ + private $page; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->page = $this->objectManager->get(PageFactory::class)->create(); + } + + /** + * @return void + */ + public function testMyDownloadableProductLink(): void + { + $this->preparePage(); + $block = $this->page->getLayout()->getBlock('customer-account-navigation-downloadable-products-link'); + $this->assertNotFalse($block); + $html = $block->toHtml(); + $this->assertContains('downloadable/customer/products', $html); + $this->assertEquals('My Downloadable Products', strip_tags($html)); + } + + /** + * Prepare page before render + * + * @return void + */ + private function preparePage(): void + { + $this->page->addHandle([ + 'default', + 'customer_account', + ]); + $this->page->getLayout()->generateXml(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/Block/Customer/Products/ListProductsTest.php b/dev/tests/integration/testsuite/Magento/Downloadable/Block/Customer/Products/ListProductsTest.php new file mode 100644 index 0000000000000..b1f68043198ca --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Downloadable/Block/Customer/Products/ListProductsTest.php @@ -0,0 +1,181 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Downloadable\Block\Customer\Products; + +use Magento\Customer\Model\Session; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\LayoutInterface; +use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Api\InvoiceOrderInterface; +use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\Sales\Api\RefundOrderInterface; +use Magento\Sales\Model\OrderFactory; +use Magento\Sales\Model\OrderRepository; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + +/** + * Class to check My Downloadable products tab content + * + * @see ListProducts + * @magentoAppArea frontend + * @magentoAppIsolation enabled + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class ListProductsTest extends TestCase +{ + /** @var string */ + private $downloadLinkXpath = "//a[contains(@href, 'downloadable/download/link') and contains(text(), '%s')]"; + + /** @var string */ + private $statusXpath = "//table[@id='my-downloadable-products-table']" + . "//td[@data-th='Status' and contains(text(), '%s')]"; + + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var LayoutInterface */ + private $layout; + + /** @var Session */ + private $customerSession; + + /** @var OrderRepositoryInterface */ + private $orderRepository; + + /** @var InvoiceOrderInterface */ + private $invoiceOrder; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->layout = $this->objectManager->get(LayoutInterface::class); + $this->customerSession = $this->objectManager->get(Session::class); + $this->orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); + $this->invoiceOrder = $this->objectManager->get(InvoiceOrderInterface::class); + } + + /** + * @inheritdoc + */ + protected function tearDown() + { + $this->customerSession->logout(); + + parent::tearDown(); + } + + /** + * @return void + */ + public function testNoItems(): void + { + $html = $this->createBlock()->toHtml(); + $this->assertContains((string)__('You have not purchased any downloadable products yet.'), strip_tags($html)); + } + + /** + * @magentoDataFixture Magento/Downloadable/_files/order_with_customer_and_downloadable_product.php + * + * @return void + */ + public function testPendingOrder(): void + { + $this->customerSession->loginById(1); + $this->assertEquals( + 0, + Xpath::getElementsCountForXpath( + sprintf($this->downloadLinkXpath, 'Downloadable Product Link'), + $this->createBlock()->toHtml() + ), + 'The download link displayed' + ); + } + + /** + * @magentoDataFixture Magento/Downloadable/_files/order_with_customer_and_downloadable_product.php + * + * @return void + */ + public function testCompleteOrder(): void + { + $order = $this->getOrder('100000001'); + $this->invoiceOrder->execute($order->getId()); + $this->customerSession->loginById(1); + $html = $this->createBlock()->toHtml(); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath(sprintf($this->downloadLinkXpath, 'Downloadable Product Link'), $html), + 'The download link is not found' + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath(sprintf($this->statusXpath, (string)__('Available')), $html), + 'Wrong status displayed' + ); + } + + /** + * @magentoDataFixture Magento/Downloadable/_files/order_with_customer_and_downloadable_product.php + * + * @return void + */ + public function testClosedOrder(): void + { + $order = $this->getOrder('100000001'); + $this->invoiceOrder->execute($order->getId()); + $this->objectManager->removeSharedInstance(OrderRepository::class); + $refundOrder = $this->objectManager->create(RefundOrderInterface::class); + $refundOrder->execute($order->getId()); + $this->customerSession->loginById(1); + $html = $this->createBlock()->toHtml(); + $this->assertEquals( + 0, + Xpath::getElementsCountForXpath(sprintf($this->downloadLinkXpath, 'Downloadable Product Link'), $html), + 'The download link is displayed for closed order' + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath(sprintf($this->statusXpath, (string)__('Expired')), $html), + 'Wrong status displayed' + ); + } + + /** + * Load order by increment id + * + * @param $orderIncrementId + * @return OrderInterface + */ + private function getOrder($orderIncrementId): OrderInterface + { + $order = $this->objectManager->get(OrderFactory::class)->create(); + + return $order->loadByIncrementId($orderIncrementId); + } + + /** + * Create ProductsList block + * + * @return ListProducts + */ + private function createBlock(): ListProducts + { + $block = $this->objectManager->create(ListProducts::class); + $block->setTemplate('Magento_Downloadable::customer/products/list.phtml'); + $this->layout->addBlock($block, 'downloadable_customer_products_list'); + + return $block; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/order_with_customer_and_downloadable_product.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/order_with_customer_and_downloadable_product.php new file mode 100644 index 0000000000000..be5fa49f48eeb --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/order_with_customer_and_downloadable_product.php @@ -0,0 +1,78 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Downloadable\Api\Data\LinkInterface; +use Magento\Downloadable\Model\Product\Type; +use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\Address; +use Magento\Sales\Model\Order\AddressFactory; +use Magento\Sales\Model\Order\ItemFactory; +use Magento\Sales\Model\Order\PaymentFactory; +use Magento\Sales\Model\OrderFactory; +use Magento\Store\Model\StoreManagerInterface; + +require __DIR__ . '/../../../Magento/Downloadable/_files/product_downloadable.php'; +require __DIR__ . '/../../../Magento/Customer/_files/customer.php'; + +$addressData = include __DIR__ . '/../../../Magento/Sales/_files/address_data.php'; +/** @var AddressFactory $addressFactory */ +$addressFactory = $objectManager->get(AddressFactory::class); +$billingAddress = $addressFactory->create(['data' => $addressData]); +$billingAddress->setAddressType(Address::TYPE_BILLING); +/** @var ItemFactory $orderItemFactory */ +$orderItemFactory = $objectManager->get(ItemFactory::class); +/** @var PaymentFactory $orderPaymentFactory */ +$orderPaymentFactory = $objectManager->get(PaymentFactory::class); +/** @var StoreManagerInterface $storeManager */ +$storeManager = $objectManager->get(StoreManagerInterface::class); +/** @var OrderRepositoryInterface $orderRepository */ +$orderRepository = $objectManager->create(OrderRepositoryInterface::class); +/** @var OrderFactory $orderFactory */ +$orderFactory = $objectManager->get(OrderFactory::class); + +$payment = $orderPaymentFactory->create(); +$payment->setMethod('checkmo') + ->setAdditionalInformation('last_trans_id', '11122') + ->setAdditionalInformation( + 'metadata', + ['type' => 'free', 'fraudulent' => false] + ); +/** @var ProductInterface $product */ +$product = $productRepository->get('downloadable-product'); +/** @var LinkInterface $links */ +$links = $product->getExtensionAttributes()->getDownloadableProductLinks(); +$link = reset($links); + +$orderItem = $orderItemFactory->create(); +$orderItem->setProductId($product->getId()) + ->setQtyOrdered(1) + ->setBasePrice($product->getPrice()) + ->setProductOptions(['links' => [$link->getId()]]) + ->setPrice($product->getPrice()) + ->setRowTotal($product->getPrice()) + ->setProductType(Type::TYPE_DOWNLOADABLE) + ->setName($product->getName()) + ->setSku($product->getSku()); + +$order = $orderFactory->create(); +$order->setIncrementId('100000001') + ->setState(Order::STATE_PROCESSING) + ->setStatus($order->getConfig()->getStateDefaultStatus(Order::STATE_PROCESSING)) + ->setSubtotal(100) + ->setGrandTotal(100) + ->setBaseSubtotal(100) + ->setBaseGrandTotal(100) + ->setCustomerId($customer->getId()) + ->setCustomerEmail($customer->getEmail()) + ->setBillingAddress($billingAddress) + ->setStoreId($storeManager->getStore()->getId()) + ->addItem($orderItem) + ->setPayment($payment); + +$orderRepository->save($order); diff --git a/dev/tests/integration/testsuite/Magento/Downloadable/_files/order_with_customer_and_downloadable_product_rollback.php b/dev/tests/integration/testsuite/Magento/Downloadable/_files/order_with_customer_and_downloadable_product_rollback.php new file mode 100644 index 0000000000000..c182a67495f89 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Downloadable/_files/order_with_customer_and_downloadable_product_rollback.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\Sales\Model\OrderFactory; +use Magento\TestFramework\Downloadable\Model\RemoveLinkPurchasedByOrderIncrementId; + +require __DIR__ . '/../../../Magento/Customer/_files/customer_rollback.php'; +require __DIR__ . '/../../../Magento/Downloadable/_files/product_downloadable_rollback.php'; + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var RemoveLinkPurchasedByOrderIncrementId $removeLinkPurchasedByOrderIncrementId */ +$removeLinkPurchasedByOrderIncrementId = $objectManager->get(RemoveLinkPurchasedByOrderIncrementId::class); +/** @var OrderRepositoryInterface $orderRepository */ +$orderRepository = $objectManager->get(OrderRepositoryInterface::class); +$orderIncrementIdToDelete = '100000001'; +$removeLinkPurchasedByOrderIncrementId->execute($orderIncrementIdToDelete); +/** @var OrderFactory $order */ +$order = $objectManager->get(OrderFactory::class)->create(); +$order->loadByIncrementId($orderIncrementIdToDelete); + +if ($order->getId()) { + $orderRepository->delete($order); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); From a7d1c1e84a6bbd9b14b579bad82e3901d70693b0 Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Thu, 9 Apr 2020 16:29:46 +0300 Subject: [PATCH 114/177] Removed redundant ActionGroup --- .../AdminOpenCategoriesPageActionGroup.xml | 14 -------------- ...sabledCmsBlockEntityAndAssignToCategoryTest.xml | 2 +- ...nabledCmsBlockEntityAndAssignToCategoryTest.xml | 2 +- 3 files changed, 2 insertions(+), 16 deletions(-) delete mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminOpenCategoriesPageActionGroup.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminOpenCategoriesPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminOpenCategoriesPageActionGroup.xml deleted file mode 100644 index 7f41a0c4eb1a3..0000000000000 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminOpenCategoriesPageActionGroup.xml +++ /dev/null @@ -1,14 +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="AdminOpenCategoriesPageActionGroup"> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="onCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageLoad" after="onCategoryIndexPage"/> - </actionGroup> -</actionGroups> \ No newline at end of file diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateDisabledCmsBlockEntityAndAssignToCategoryTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateDisabledCmsBlockEntityAndAssignToCategoryTest.xml index 51fbbf8020545..9924d814b0487 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateDisabledCmsBlockEntityAndAssignToCategoryTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateDisabledCmsBlockEntityAndAssignToCategoryTest.xml @@ -35,7 +35,7 @@ <actionGroup ref="AdminSetCMSBlockDisabledActionGroup" stepKey="disableBlock"/> <actionGroup ref="SaveCMSBlockActionGroup" stepKey="saveCMSBlock"/> - <actionGroup ref="AdminOpenCategoriesPageActionGroup" stepKey="openCategoriesPage"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openCategoriesPage"/> <actionGroup ref="AdminCategoriesExpandAllActionGroup" stepKey="expandAll"/> <actionGroup ref="AdminCategoriesOpenCategoryActionGroup" stepKey="openCategory"> <argument name="category" value="$$newDefaultCategory$$"/> diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateEnabledCmsBlockEntityAndAssignToCategoryTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateEnabledCmsBlockEntityAndAssignToCategoryTest.xml index 5ccd8fa713cc0..98a617bec5366 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateEnabledCmsBlockEntityAndAssignToCategoryTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateEnabledCmsBlockEntityAndAssignToCategoryTest.xml @@ -29,7 +29,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> - <actionGroup ref="AdminOpenCategoriesPageActionGroup" stepKey="openCategoriesPage"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openCategoriesPage"/> <actionGroup ref="AdminCategoriesExpandAllActionGroup" stepKey="expandAll"/> <actionGroup ref="AdminCategoriesOpenCategoryActionGroup" stepKey="openCategory"> <argument name="category" value="$$newDefaultCategory$$"/> From 2027d8ac986621f537df9c8377ff8facd7cb885c Mon Sep 17 00:00:00 2001 From: Ji Lu <jilu1@adobe.com> Date: Thu, 9 Apr 2020 10:02:45 -0500 Subject: [PATCH 115/177] MQE-2046: remove deprecated entities usages in MFTF tests --- .../Backend/Test/Mftf/Section/AdminMessagesSection.xml | 7 +++---- .../Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml index c1d5599f9e1c2..7983554051f89 100644 --- a/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml +++ b/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml @@ -9,9 +9,8 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminMessagesSection"> - <!-- Keep both Set1 and Set2 elements --> - <!-- Neither Set1 nor Set2 works for all Magento blocks --> - <!-- Set1 --> + <!-- Keep both sets of elements --> + <!-- Set One - more specific, works for most of message blocks --> <element name="success" type="text" selector="#messages div.message-success"/> <element name="nthSuccess" type="text" selector=".message.message-success.success:nth-of-type({{n}})>div" parameterized="true"/> <element name="error" type="text" selector="#messages div.message-error"/> @@ -19,7 +18,7 @@ <element name="messageByType" type="text" selector="#messages div.message-{{messageType}}" parameterized="true" /> <element name="warning" type="text" selector="#messages div.message-warning"/> <element name="accessDenied" type="text" selector=".access-denied-page"/> - <!-- Set2 --> + <!-- Set Two - more generic, needed for message blocks in Product Import, Staging Update, etc --> <element name="successMessage" type="text" selector=".message-success"/> <element name="errorMessage" type="text" selector=".message.message-error.error"/> <element name="warningMessage" type="text" selector=".message-warning"/> diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml index 0a94bf8a52aaf..111ba187c6f26 100644 --- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml +++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml @@ -30,6 +30,6 @@ <argument name="importFile" value="importSpecChars.csv"/> </actionGroup> <see selector="{{AdminImportHeaderSection.messageNote}}" userInput='File must be saved in UTF-8 encoding for proper import' stepKey="seeNoteMessage"/> - <see selector="{{AdminMessagesSection.success}}" userInput='File is valid! To start import process press "Import" button' stepKey="seeSuccessMessage"/> + <see selector="{{AdminMessagesSection.successMessage}}" userInput='File is valid! To start import process press "Import" button' stepKey="seeSuccessMessage"/> </test> </tests> From d376b80db56cc6ac4af2f4fb12ae8391d04d45b0 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Thu, 9 Apr 2020 18:13:20 +0200 Subject: [PATCH 116/177] Lint code --- ...rontRecentlyViewedAtStoreViewLevelTest.xml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml index 0a027be898c70..5eef25c789a7e 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ +/** +* 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"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="StoreFrontRecentlyViewedAtStoreViewLevelTest"> <annotations> <stories value="Recently Viewed Product"/> @@ -37,7 +37,6 @@ <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreViewOne"> <argument name="customStore" value="customStoreEN"/> </actionGroup> - <magentoCron stepKey="runCronIndex" groups="index"/> <!-- Set Stores > Configurations > Catalog > Recently Viewed/Compared Products > Show for Current = store view--> @@ -96,7 +95,7 @@ <amOnPage url="{{StorefrontProductPage.url($createSimpleProduct3.name$)}}" stepKey="goToStore1ProductPage3"/> <!-- Go to Home Page --> <actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="amOnHomePage"/> - <actionGroup ref="AssertSeeProductDetailsOnStorefrontRecentlyViewedWidgetActionGroup" stepKey="assertStore1RecentlyViewedProduct2"> + <actionGroup ref="AssertSeeProductDetailsOnStorefrontRecentlyViewedWidgetActionGroup" stepKey="assertStore1RecentlyViewedProduct2"> <argument name="productName" value="$$createSimpleProduct2.name$$"/> <argument name="productPosition" value="2"/> </actionGroup> @@ -129,7 +128,7 @@ <grabTextFrom selector="{{StoreFrontRecentlyViewedProductSection.ProductName('2')}}" stepKey="grabDontSeeHomeProduct3"/> <assertNotContains stepKey="assertNotSeeProduct3"> <actualResult type="const">$grabDontSeeHomeProduct3</actualResult> - <expectedResult type="const">$$createSimpleProduct3.name$$</expectedResult> + <expectedResult type="const">$$createSimpleProduct3.name$$</expectedResult> </assertNotContains> <actionGroup ref="StorefrontSwitchDefaultStoreViewActionGroup" stepKey="switchToDefualtStoreView"/> @@ -146,8 +145,8 @@ <grabTextFrom selector="{{StoreFrontRecentlyViewedProductSection.ProductName('2')}}" stepKey="grabDontSeeHomeProduct1"/> <assertNotContains stepKey="assertNotSeeProduct1"> - <actualResult type="const">$grabDontSeeHomeProduct1</actualResult> - <expectedResult type="const">$$createSimpleProduct1.name$$</expectedResult> + <actualResult type="const">$grabDontSeeHomeProduct1</actualResult> + <expectedResult type="const">$$createSimpleProduct1.name$$</expectedResult> </assertNotContains> </test> </tests> From f4d980a378bfeb44c2ad3774b84fa1dc3c1d4884 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Thu, 9 Apr 2020 19:05:55 +0100 Subject: [PATCH 117/177] magento/magento2#27499: Integration tests --- .../ResourceModel/DeleteAssetsByPaths.php | 3 - .../Keyword/GetAssetsKeywords.php | 2 +- .../Api/SaveAssetsInterface.php | 2 - .../MediaGallery/Model/AssetEndToEndTest.php | 153 +++++++++++++++ .../Directory/Command/CreateByPathsTest.php | 2 +- .../Directory/Command/DeleteByPathsTest.php | 2 +- .../MediaGallery/Model/IsBlacklistedTest.php | 59 ++++++ .../Model/ResourceModel/AssetKeywordsTest.php | 147 +++++++++++++++ .../Model/ResourceModel/AssetsByIdsTest.php | 48 +++++ .../Model/ResourceModel/AssetsTest.php | 174 ++++++++++++++++++ .../Model/ResourceModel/DeleteAssetsTest.php | 101 ++++++++++ .../MediaGallery/_files/media_asset.php | 3 +- .../_files/media_asset_rollback.php | 1 - 13 files changed, 686 insertions(+), 11 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php create mode 100644 dev/tests/integration/testsuite/Magento/MediaGallery/Model/IsBlacklistedTest.php create mode 100644 dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetKeywordsTest.php create mode 100644 dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsByIdsTest.php create mode 100644 dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php create mode 100644 dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsTest.php diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsByPaths.php b/app/code/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsByPaths.php index d965ed63de5fd..031bf25c4e5bb 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsByPaths.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsByPaths.php @@ -81,9 +81,6 @@ public function execute(array $paths): void */ private function deleteAssetsByDirectoryPath(string $path): void { - // Make sure that the path has a trailing slash - $path = rtrim($path, '/') . '/'; - /** @var AdapterInterface $connection */ $connection = $this->resourceConnection->getConnection(); $tableName = $this->resourceConnection->getTableName(self::TABLE_MEDIA_GALLERY_ASSET); diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php index 40df55805d955..ab67c23e2cd4e 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php @@ -112,7 +112,7 @@ private function getAssetKeywords(array $keywordsData): array $assetKeywords = []; foreach ($keywordsByAsset as $assetId => $keywords) { - $assetKeywords[] = $this->assetKeywordsFactory->create( + $assetKeywords[$assetId] = $this->assetKeywordsFactory->create( [ 'data' => [ 'asset_id' => $assetId, diff --git a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php index 52ff1670ec3ab..35f0da862e8d1 100644 --- a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php @@ -8,8 +8,6 @@ namespace Magento\MediaGalleryApi\Api; -use Magento\MediaGalleryApi\Api\Data\AssetInterface; - /** * A command which executes the media gallery asset save operation. * @api diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php new file mode 100644 index 0000000000000..cd1c928bf5d0c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php @@ -0,0 +1,153 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model; + +use Magento\MediaGalleryApi\Api\Data\KeywordInterfaceFactory; +use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory; +use Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterfaceFactory; +use Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface; +use Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface; +use Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface; +use Magento\MediaGalleryApi\Api\GetAssetsKeywordsInterface; +use Magento\MediaGalleryApi\Api\SaveAssetsInterface; +use Magento\MediaGalleryApi\Api\SaveAssetsKeywordsInterface; +use Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Testing assets keywords save and get + */ +class AssetEndToEndTest extends TestCase +{ + /** + * @var GetAssetsKeywordsInterface + */ + private $saveAssetsKeywords; + + /** + * @var GetAssetsKeywordsInterface + */ + private $getAssetsKeywords; + + /** + * @var AssetKeywordsInterfaceFactory + */ + private $assetsKeywordsFactory; + + /** + * @var AssetInterfaceFactory + */ + private $assetFactory; + + /** + * @var KeywordInterfaceFactory + */ + private $keywordFactory; + + /** + * @var SaveAssetsInterface + */ + private $saveAssets; + + /** + * @var GetAssetsByIdsInterface + */ + private $getAssetsByIds; + + /** + * @var GetAssetsByPathsInterface + */ + private $getAssetsByPath; + + /** + * @var DeleteAssetsByPathsInterface + */ + private $deleteAssetsByPaths; + + /** + * @inheritdoc + */ + public function setUp() + { + $this->saveAssetsKeywords = Bootstrap::getObjectManager()->get(SaveAssetsKeywordsInterface::class); + $this->getAssetsKeywords = Bootstrap::getObjectManager()->get(GetAssetsKeywordsInterface::class); + $this->assetsKeywordsFactory = Bootstrap::getObjectManager()->get(AssetKeywordsInterfaceFactory::class); + $this->assetFactory = Bootstrap::getObjectManager()->get(AssetInterfaceFactory::class); + $this->keywordFactory = Bootstrap::getObjectManager()->get(KeywordInterfaceFactory::class); + $this->saveAssets = Bootstrap::getObjectManager()->get(SaveAssetsInterface::class); + $this->getAssetsByIds = Bootstrap::getObjectManager()->get(GetAssetsByIdsInterface::class); + $this->getAssetsByPath = Bootstrap::getObjectManager()->get(GetAssetsByPathsInterface::class); + $this->deleteAssetsByPaths = Bootstrap::getObjectManager()->get(DeleteAssetsByPathsInterface::class); + } + + /** + * Testing assets keywords save and get + */ + public function testExecute(): void + { + $keyword1 = $this->keywordFactory->create( + [ + 'data' => [ + 'keyword' => 'pear' + ] + ] + ); + + $keyword2 = $this->keywordFactory->create( + [ + 'data' => [ + 'keyword' => 'plum' + ] + ] + ); + + $asset = $this->assetFactory->create( + [ + 'data' => [ + 'path' => 'fruit.jpg' + ] + ] + ); + $this->saveAssets->execute([$asset]); + $loadedAssets = $this->getAssetsByPath->execute([$asset->getPath()]); + $loadedAsset = $loadedAssets[0]; + + $this->assertEquals(1, count($loadedAssets)); + + $assetKeywords = $this->assetsKeywordsFactory->create( + [ + 'data' => [ + 'asset_id' => $loadedAsset->getId(), + 'keywords' => [ + $keyword1, + $keyword2 + ] + ] + ] + ); + + $this->saveAssetsKeywords->execute([$assetKeywords]); + $loadedAssetKeywords = $this->getAssetsKeywords->execute([$loadedAsset->getId()]); + + $this->assertEquals(1, count($loadedAssetKeywords)); + + /** @var AssetKeywordsInterface $loadedAssetKeywords1 */ + $loadedAssetKeywords1 = current($loadedAssetKeywords); + + $loadedKeywords = $loadedAssetKeywords1->getKeywords(); + + $this->assertEquals(2, count($loadedKeywords)); + + foreach ($loadedKeywords as $theKeyword) { + $this->assertTrue(in_array($theKeyword->getKeyword(), ['pear', 'plum'])); + } + + $this->deleteAssetsByPaths->execute(['fruit.jpg']); + } +} diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathsTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathsTest.php index c35ba75be34ff..3511cdec532fa 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathsTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/CreateByPathsTest.php @@ -14,7 +14,7 @@ use Magento\TestFramework\Helper\Bootstrap; /** - * Test methods of class CreateByPath + * Test for CreateDirectoriesByPathsInterface */ class CreateByPathsTest extends \PHPUnit\Framework\TestCase { diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathsTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathsTest.php index 8d9439bbae876..3eaf7fbe3538a 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathsTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/Directory/Command/DeleteByPathsTest.php @@ -14,7 +14,7 @@ use Magento\TestFramework\Helper\Bootstrap; /** - * Test methods of class DeleteByPath + * Test for DeleteDirectoriesByPathsInterface */ class DeleteByPathsTest extends \PHPUnit\Framework\TestCase { diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/IsBlacklistedTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/IsBlacklistedTest.php new file mode 100644 index 0000000000000..e87cbe22ac622 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/IsBlacklistedTest.php @@ -0,0 +1,59 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model; + +use Magento\MediaGalleryApi\Api\IsPathBlacklistedInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Test methods of class CreateByPath + */ +class CreateByPathsTest extends TestCase +{ + + /** + * @var IsPathBlacklistedInterface + */ + private $service; + + /** + * @inheritdoc + */ + public function setUp() + { + $this->service = Bootstrap::getObjectManager()->get(IsPathBlacklistedInterface::class); + } + + /** + * Testing the blacklisted paths + * + * @param string $path + * @param bool $isBlacklisted + * @dataProvider pathsProvider + */ + public function testExecute(string $path, bool $isBlacklisted): void + { + $this->assertEquals($isBlacklisted, $this->service->execute($path)); + } + + /** + * Provider of paths and if the path should be in the blacklist + * + * @return array + */ + public function pathsProvider(): array + { + return [ + ['theme', true], + ['.thumbs', true], + ['catalog/product/somedir', true], + ['catalog/category', false] + ]; + } +} diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetKeywordsTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetKeywordsTest.php new file mode 100644 index 0000000000000..f26ff54eb7bec --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetKeywordsTest.php @@ -0,0 +1,147 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model; + +use Behat\Gherkin\Keywords\KeywordsInterface; +use Magento\MediaGalleryApi\Api\Data\KeywordInterfaceFactory; +use Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterfaceFactory; +use Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface; +use Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface; +use Magento\MediaGalleryApi\Api\GetAssetsKeywordsInterface; +use Magento\MediaGalleryApi\Api\SaveAssetsKeywordsInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Testing assets keywords save and get + */ +class AssetKeywordsTest extends TestCase +{ + private const FIXTURE_ASSET_PATH = 'testDirectory/path.jpg'; + + /** + * @var GetAssetsKeywordsInterface + */ + private $saveAssetsKeywords; + + /** + * @var GetAssetsKeywordsInterface + */ + private $getAssetsKeywords; + + /** + * @var AssetKeywordsInterfaceFactory + */ + private $assetsKeywordsFactory; + + /** + * @var KeywordInterfaceFactory + */ + private $keywordFactory; + + /** + * @var GetAssetsByPathsInterface + */ + private $getAssetsByPath; + + /** + * @inheritdoc + */ + public function setUp() + { + $this->saveAssetsKeywords = Bootstrap::getObjectManager()->get(SaveAssetsKeywordsInterface::class); + $this->getAssetsKeywords = Bootstrap::getObjectManager()->get(GetAssetsKeywordsInterface::class); + $this->assetsKeywordsFactory = Bootstrap::getObjectManager()->get(AssetKeywordsInterfaceFactory::class); + $this->keywordFactory = Bootstrap::getObjectManager()->get(KeywordInterfaceFactory::class); + $this->getAssetsByPath = Bootstrap::getObjectManager()->get(GetAssetsByPathsInterface::class); + } + + /** + * Testing assets keywords save and get + * + * @magentoDataFixture Magento/MediaGallery/_files/media_asset.php + * @dataProvider keywordsProvider + * @param array $keywords + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function testSaveAndGetKeywords(array $keywords): void + { + $keywords = ['pear', 'plum']; + + $loadedAssets = $this->getAssetsByPath->execute([self::FIXTURE_ASSET_PATH]); + $this->assertEquals(1, count($loadedAssets)); + $loadedAsset = current($loadedAssets); + + $assetKeywords = $this->assetsKeywordsFactory->create( + [ + 'data' => [ + 'asset_id' => $loadedAsset->getId(), + 'keywords' => $this->getKeywords($keywords) + ] + ] + ); + + $this->saveAssetsKeywords->execute([$assetKeywords]); + $loadedAssetKeywords = $this->getAssetsKeywords->execute([$loadedAsset->getId()]); + + $this->assertEquals(1, count($loadedAssetKeywords)); + + /** @var AssetKeywordsInterface $loadedAssetKeyword */ + $loadedAssetKeyword = current($loadedAssetKeywords); + + $loadedKeywords = $loadedAssetKeyword->getKeywords(); + + $this->assertEquals(count($keywords), count($loadedKeywords)); + + $loadedKeywordStrings = []; + foreach ($loadedKeywords as $loadedKeywordObject) { + $loadedKeywordStrings[] = $loadedKeywordObject->getKeyword(); + } + + sort($loadedKeywordStrings); + sort($keywords); + + $this->assertEquals($keywords, $loadedKeywordStrings); + } + + /** + * Data provider of paths matching existing asset + * + * @return array + */ + public function keywordsProvider(): array + { + return [ + [['one-keyword']], + [['кириллица']], + [['plum', 'pear']], + [[]] + ]; + } + + /** + * Create keywords + * + * @param string[] $keywords + * @return KeywordsInterface[] + */ + private function getKeywords(array $keywords): array + { + $keywordObjects = []; + foreach ($keywords as $keyword) { + $keywordObjects[] = $this->keywordFactory->create( + [ + 'data' => [ + 'keyword' => $keyword + ] + ] + ); + } + return $keywordObjects; + } +} diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsByIdsTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsByIdsTest.php new file mode 100644 index 0000000000000..ebf4ae94e811a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsByIdsTest.php @@ -0,0 +1,48 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model\ResourceModel; + +use Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Testing assets keywords save and get + */ +class AssetsByIdsTest extends TestCase +{ + private const FIXTURE_ASSET_ID = 2020; + private const FIXTURE_ASSET_PATH = 'testDirectory/path.jpg'; + + /** + * @var GetAssetsByIdsInterface + */ + private $getAssetsByIds; + + /** + * @inheritdoc + */ + public function setUp() + { + $this->getAssetsByIds = Bootstrap::getObjectManager()->get(GetAssetsByIdsInterface::class); + } + + /** + * Testing assets keywords save and get + * + * @throws \Magento\Framework\Exception\LocalizedException + * + * @magentoDataFixture Magento/MediaGallery/_files/media_asset.php + */ + public function testExecute(): void + { + $assets = $this->getAssetsByIds->execute([self::FIXTURE_ASSET_ID]); + $this->assertEquals(1, count($assets)); + $this->assertEquals($assets[0]->getPath(), self::FIXTURE_ASSET_PATH); + } +} diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php new file mode 100644 index 0000000000000..17a555ac0b66f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php @@ -0,0 +1,174 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model\ResourceModel; + +use Magento\Framework\Reflection\DataObjectProcessor; +use Magento\MediaGalleryApi\Api\Data\AssetInterfaceFactory; +use Magento\MediaGalleryApi\Api\Data\AssetInterface; +use Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface; +use Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface; +use Magento\MediaGalleryApi\Api\SaveAssetsInterface; +use Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Testing assets keywords save and get + */ +class AssetsTest extends TestCase +{ + /** + * @var AssetInterfaceFactory + */ + private $assetFactory; + + /** + * @var SaveAssetsInterface + */ + private $saveAssets; + + /** + * @var GetAssetsByIdsInterface + */ + private $getAssetsByIds; + + /** + * @var GetAssetsByPathsInterface + */ + private $getAssetsByPath; + + /** + * @var DeleteAssetsByPathsInterface + */ + private $deleteAssetsByPaths; + + /** + * @var DataObjectProcessor + */ + private $dataObjectProcessor; + + /** + * @inheritdoc + */ + public function setUp() + { + $this->assetFactory = Bootstrap::getObjectManager()->get(AssetInterfaceFactory::class); + $this->saveAssets = Bootstrap::getObjectManager()->get(SaveAssetsInterface::class); + $this->getAssetsByIds = Bootstrap::getObjectManager()->get(GetAssetsByIdsInterface::class); + $this->getAssetsByPath = Bootstrap::getObjectManager()->get(GetAssetsByPathsInterface::class); + $this->deleteAssetsByPaths = Bootstrap::getObjectManager()->get(DeleteAssetsByPathsInterface::class); + $this->dataObjectProcessor = Bootstrap::getObjectManager()->get(DataObjectProcessor::class); + } + + /** + * Testing assets keywords save and get + * + * @param array $assetsData + * @throws \Magento\Framework\Exception\CouldNotSaveException + * @throws \Magento\Framework\Exception\LocalizedException + * + * @dataProvider assetsDataProvider + */ + public function testExecute(array $assetsData): void + { + $this->saveAssets->execute($this->getAssets($assetsData)); + + $paths = $this->getKeyValues($assetsData, 'path'); + $loadedAssets = $this->getAssetsByPath->execute($paths); + $loadedPaths = $this->getFieldValues($loadedAssets, 'path'); + + $this->assertEquals(count($assetsData), count($loadedAssets)); + + sort($paths); + sort($loadedPaths); + $this->assertEquals($paths, $loadedPaths); + + $this->deleteAssetsByPaths->execute($paths); + $this->assertEmpty($this->getAssetsByPath->execute($paths)); + } + + /** + * Data provider for testExecute + * + * @return array + */ + public function assetsDataProvider(): array + { + return [ + 'One asset' => [ + 'assetsData' => [ + 'asset1' => [ + 'path' => 'fruit.jpg' + ] + ] + ], + 'Two assets' => [ + 'assetsData' => [ + 'asset1' => [ + 'path' => 'image.jpg' + ], + 'asset2' => [ + 'path' => 'image2.png' + ] + ] + ], + ]; + } + + /** + * Create assets + * + * @param array $assetsData + * @return AssetInterface[] + */ + private function getAssets(array $assetsData): array + { + $assets = []; + foreach ($assetsData as $assetData) { + $assets[] = $this->assetFactory->create( + [ + 'data' => $assetData + ] + ); + } + return $assets; + } + + /** + * Get field values from assets + * + * @param AssetInterface[] $assets + * @param string $fieldName + * @return string[] + */ + private function getFieldValues(array $assets, string $fieldName): array + { + $values = []; + foreach ($assets as $asset) { + $data = $this->dataObjectProcessor->buildOutputDataArray($asset, AssetInterface::class); + $values[] = $data[$fieldName]; + } + return $values; + } + + /** + * Get key values from assets data array + * + * @param array $assetsData + * @param string $key + * @return string[] + */ + private function getKeyValues(array $assetsData, string $key): array + { + $values = []; + foreach ($assetsData as $assetData) { + $values[] = $assetData[$key]; + } + return $values; + } +} diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsTest.php new file mode 100644 index 0000000000000..c9710c0dd4f28 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsTest.php @@ -0,0 +1,101 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model\ResourceModel; + +use Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface; +use Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Testing delete assets + */ +class DeleteAssetsTest extends TestCase +{ + private const FIXTURE_ASSET_PATH = 'testDirectory/path.jpg'; + /** + * @var GetAssetsByPathsInterface + */ + private $getAssetsByPath; + + /** + * @var DeleteAssetsByPathsInterface + */ + private $deleteAssetsByPaths; + + /** + * @inheritdoc + */ + public function setUp() + { + $this->getAssetsByPath = Bootstrap::getObjectManager()->get(GetAssetsByPathsInterface::class); + $this->deleteAssetsByPaths = Bootstrap::getObjectManager()->get(DeleteAssetsByPathsInterface::class); + } + + /** + * Test deletion of assets by path + * + * @magentoDataFixture Magento/MediaGallery/_files/media_asset.php + * + * @param array $paths + * @throws \Magento\Framework\Exception\CouldNotSaveException + * @throws \Magento\Framework\Exception\LocalizedException + * + * @dataProvider matchingPathsProvider + */ + public function testAssetsAreDeleted(array $paths): void + { + $this->deleteAssetsByPaths->execute($paths); + $this->assertEmpty($this->getAssetsByPath->execute([self::FIXTURE_ASSET_PATH])); + } + + /** + * Test scenarios where delete operation should not delete an asset + * + * @magentoDataFixture Magento/MediaGallery/_files/media_asset.php + * + * @param array $paths + * @throws \Magento\Framework\Exception\CouldNotSaveException + * @throws \Magento\Framework\Exception\LocalizedException + * + * @dataProvider notMatchingPathsProvider + */ + public function testAssetsAreNotDeleted(array $paths): void + { + $this->deleteAssetsByPaths->execute($paths); + $this->assertNotEmpty($this->getAssetsByPath->execute([self::FIXTURE_ASSET_PATH])); + } + + /** + * Data provider of paths matching existing asset + * + * @return array + */ + public function matchingPathsProvider(): array + { + return [ + [['testDirectory/path.jpg']], + [['testDirectory/']], + [['testDirectory']] + ]; + } + + /** + * Data provider of paths not matching existing asset + * + * @return array + */ + public function notMatchingPathsProvider(): array + { + return [ + [['testDirectory/path.png']], + [['anotherDirectory/path.jpg']], + [['path.jpg']] + ]; + } +} diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php index c0a6691e54852..f9ad69220dc4d 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php @@ -3,7 +3,6 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - declare(strict_types=1); use Magento\MediaGalleryApi\Api\Data\AssetInterface; @@ -18,7 +17,7 @@ $mediaAsset = $mediaAssetFactory->create( [ 'data' => [ - 'id' => 1, + 'id' => 2020, 'path' => 'testDirectory/path.jpg' ] ] diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php index 5f26d9350775e..0f51c10814029 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php @@ -3,7 +3,6 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - declare(strict_types=1); use Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface; From ce08d3487a9e8543fbfa8766a263609528240e80 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Thu, 9 Apr 2020 19:34:26 +0100 Subject: [PATCH 118/177] magento/magento2#27499: Corrected comments and unit tests --- .../Asset/Command/DeleteByDirectoryPath.php | 1 + .../Model/Asset/Command/DeleteByPath.php | 1 + .../Model/Asset/Command/GetById.php | 1 + .../Model/Asset/Command/GetByPath.php | 3 +- .../MediaGallery/Model/Asset/Command/Save.php | 3 +- .../MediaGallery/Model/AssetKeywords.php | 2 +- .../Model/Directory/Command/CreateByPaths.php | 2 +- .../Model/Directory/Command/DeleteByPaths.php | 2 +- .../Model/ResourceModel/GetAssetsByPaths.php | 2 +- .../Keyword/GetAssetsKeywords.php | 2 +- .../Keyword/SaveAssetsKeywords.php | 2 +- .../Model/Directory/IsBlacklistedTest.php | 9 +- .../File/Command/DeleteByAssetIdTest.php | 103 ------------------ .../Keyword/Command/GetAssetKeywordsTest.php | 2 +- .../Keyword/Command/SaveAssetKeywordsTest.php | 2 +- .../Keyword/Command/SaveAssetLinksTest.php | 2 +- .../Test/Unit/Plugin/Images/StorageTest.php | 3 +- .../Api/CreateDirectoriesByPathsInterface.php | 4 +- .../Api/DeleteAssetsByPathsInterface.php | 4 +- .../Api/DeleteDirectoriesByPathsInterface.php | 4 +- .../Api/GetAssetsByIdsInterface.php | 2 +- .../Api/GetAssetsByPathsInterface.php | 2 +- .../Api/GetAssetsKeywordsInterface.php | 4 +- .../Api/SaveAssetsInterface.php | 4 +- .../Api/SaveAssetsKeywordsInterface.php | 4 +- .../DeleteByDirectoryPathInterface.php | 3 +- .../Asset/Command/DeleteByPathInterface.php | 1 + .../Model/Asset/Command/GetByIdInterface.php | 1 + .../Asset/Command/GetByPathInterface.php | 1 + .../Model/Asset/Command/SaveInterface.php | 3 +- .../Command/GetAssetKeywordsInterface.php | 3 +- .../Command/SaveAssetKeywordsInterface.php | 3 +- .../Plugin/Product/Gallery/ProcessorTest.php | 20 ++-- .../MediaGallery/Model/AssetEndToEndTest.php | 2 +- .../MediaGallery/Model/IsBlacklistedTest.php | 2 +- .../Model/ResourceModel/AssetKeywordsTest.php | 2 +- .../Model/ResourceModel/AssetsByIdsTest.php | 2 +- .../Model/ResourceModel/AssetsTest.php | 2 +- .../Model/ResourceModel/DeleteAssetsTest.php | 2 +- 39 files changed, 60 insertions(+), 157 deletions(-) delete mode 100644 app/code/Magento/MediaGallery/Test/Unit/Model/File/Command/DeleteByAssetIdTest.php diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByDirectoryPath.php b/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByDirectoryPath.php index 8487a9cbb46db..3abe4cb50f2ea 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByDirectoryPath.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByDirectoryPath.php @@ -16,6 +16,7 @@ /** * Remove asset(s) that correspond the provided directory path * @deprecated use \Magento\MediaGalleryApi\Api\DeleteAssetsByPathInterface instead + * @see \Magento\MediaGalleryApi\Api\DeleteAssetsByPathInterfac */ class DeleteByDirectoryPath implements DeleteByDirectoryPathInterface { diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByPath.php b/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByPath.php index eaf47b467e3a9..3abe707fbf863 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByPath.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByPath.php @@ -16,6 +16,7 @@ /** * Class DeleteByPath * @deprecated use \Magento\MediaGalleryApi\Api\DeleteAssetsByPathInterface instead + * @see \Magento\MediaGalleryApi\Api\DeleteAssetsByPathInterface */ class DeleteByPath implements DeleteByPathInterface { diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php b/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php index 9826ef7725023..18fd3738580c4 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php @@ -18,6 +18,7 @@ /** * Get media asset by id * @deprecated use \Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface instead + * @see \Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface */ class GetById implements GetByIdInterface { diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php b/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php index bebb7ea91c481..21a27ce500332 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php @@ -17,7 +17,8 @@ /** * Class GetByPath - * @deprecated use \Magento\MediaGalleryApi\Api\GetAssetsByPathInterface instead + * @deprecated use \Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface instead + * @see \Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface */ class GetByPath implements GetByPathInterface { diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php index 5d84b3ae29c80..b8a7ae3b624f3 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php @@ -16,7 +16,8 @@ /** * Class Save - * @deprecated use \Magento\MediaGalleryApi\Api\SaveAssetInterface instead + * @deprecated use \Magento\MediaGalleryApi\Api\SaveAssetsInterface instead + * @see \Magento\MediaGalleryApi\Api\SaveAssetsInterface */ class Save implements SaveInterface { diff --git a/app/code/Magento/MediaGallery/Model/AssetKeywords.php b/app/code/Magento/MediaGallery/Model/AssetKeywords.php index 95a060fccffcd..c4cced87f4d4e 100644 --- a/app/code/Magento/MediaGallery/Model/AssetKeywords.php +++ b/app/code/Magento/MediaGallery/Model/AssetKeywords.php @@ -12,7 +12,7 @@ use Magento\MediaGalleryApi\Api\Data\AssetKeywordsExtensionInterface; /** - * Asset's Keywords + * Asset Id and Keywords combination data object for bulk operations with keyword services */ class AssetKeywords extends AbstractExtensibleModel implements AssetKeywordsInterface { diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php index cbd2f08365246..52459d42086e4 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php @@ -13,7 +13,7 @@ use Psr\Log\LoggerInterface; /** - * Create folder by provided path + * Create directories by provided paths in the media storage */ class CreateByPaths implements CreateDirectoriesByPathsInterface { diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php b/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php index b313fdb368e12..10360e3d98926 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php @@ -13,7 +13,7 @@ use Psr\Log\LoggerInterface; /** - * Delete directory from media storage by path + * Delete directory by provided paths in the media storage */ class DeleteByPaths implements DeleteDirectoriesByPathsInterface { diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php b/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php index 93c66e9a7fe51..3a94ebd287399 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php @@ -14,7 +14,7 @@ use Psr\Log\LoggerInterface; /** - * Class GetByPath + * Get media assets by paths */ class GetAssetsByPaths implements GetAssetsByPathsInterface { diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php index ab67c23e2cd4e..f9d767d70bed8 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php @@ -17,7 +17,7 @@ use Psr\Log\LoggerInterface; /** - * Retrieve keywords for the media asset + * Retrieve keywords of the media assets */ class GetAssetsKeywords implements GetAssetsKeywordsInterface { diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/SaveAssetsKeywords.php b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/SaveAssetsKeywords.php index cb64c3173dfc9..a97c5f602c5c7 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/SaveAssetsKeywords.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/SaveAssetsKeywords.php @@ -16,7 +16,7 @@ use Psr\Log\LoggerInterface; /** - * Save keywords of assets + * Save keywords of media assets */ class SaveAssetsKeywords implements SaveAssetsKeywordsInterface { diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php index 0871759087468..84240fb9e3fe7 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php @@ -8,22 +8,23 @@ namespace Magento\MediaGallery\Test\Unit\Model\Directory; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use PHPUnit\Framework\TestCase; use Magento\MediaGallery\Model\Directory\IsBlacklisted; use Magento\MediaGallery\Model\Directory\Config; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; /** - * Test the Excluded model + * Test for IsBlacklisted */ class IsBlacklistedTest extends TestCase { /** - * @var + * @var IsBlacklisted */ private $object; /** - * @var + * @var Config|MockObject */ private $config; diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/File/Command/DeleteByAssetIdTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/File/Command/DeleteByAssetIdTest.php deleted file mode 100644 index 903b366d0a9fd..0000000000000 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/File/Command/DeleteByAssetIdTest.php +++ /dev/null @@ -1,103 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaGallery\Test\Unit\Model\File\Command; - -use Magento\Cms\Model\Wysiwyg\Images\Storage; -use Magento\Framework\App\Filesystem\DirectoryList; -use Magento\Framework\Filesystem; -use Magento\Framework\Filesystem\Directory\Read; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; -use Magento\MediaGalleryApi\Api\Data\AssetInterface; -use Magento\MediaGalleryApi\Model\Asset\Command\GetByIdInterface; -use Magento\MediaGallery\Model\File\Command\DeleteByAssetId; -use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; - -/** - * Test the DeleteByAssetIdTest command model - */ -class DeleteByAssetIdTest extends TestCase -{ - /** - * @var MockObject|Filesystem - */ - private $filesystem; - - /** - * @var MockObject|Storage - */ - private $storage; - - /** - * @var MockObject|GetByIdInterface - */ - private $getById; - - /** - * @var DeleteByAssetId - */ - private $object; - - /** - * Initialize basic test class mocks - */ - protected function setUp(): void - { - $this->filesystem = $this->createMock(Filesystem::class); - $this->storage = $this->createMock(Storage::class); - $this->getById = $this->createMock(GetByIdInterface::class); - - $this->object = (new ObjectManager($this))->getObject( - DeleteByAssetId::class, - [ - 'filesystem' => $this->filesystem, - 'imagesStorage' => $this->storage, - 'getAssetById' => $this->getById - ] - ); - } - - /** - * Test delete file by asset id - */ - public function testExecute(): void - { - $assetId = 42; - $path = '/file1.jpg'; - $absoluteMediaPath = '/var/www/html/pub/media'; - - $asset = $this->createMock(AssetInterface::class); - $asset->expects($this->once()) - ->method('getPath') - ->willReturn($path); - - $this->getById->expects($this->once()) - ->method('execute') - ->with($assetId) - ->willReturn($asset); - - $directory = $this->createMock(Read::class); - $directory->expects($this->once()) - ->method('isFile') - ->willReturn(true); - $directory->expects($this->once()) - ->method('getAbsolutePath') - ->willReturn($absoluteMediaPath); - - $this->filesystem->expects($this->once()) - ->method('getDirectoryRead') - ->with(DirectoryList::MEDIA) - ->willReturn($directory); - - $this->storage->expects($this->once()) - ->method('deleteFile') - ->with($absoluteMediaPath . $path); - - $this->object->execute($assetId); - } -} diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/GetAssetKeywordsTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/GetAssetKeywordsTest.php index 2ccac4eac8343..0d2d5269c766d 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/GetAssetKeywordsTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/GetAssetKeywordsTest.php @@ -19,7 +19,7 @@ use Psr\Log\LoggerInterface; /** - * GetAssetKeywordsTest + * Test for GetAssetKeywords */ class GetAssetKeywordsTest extends TestCase { diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetKeywordsTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetKeywordsTest.php index 031213b873a25..302c8c8774bc6 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetKeywordsTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetKeywordsTest.php @@ -19,7 +19,7 @@ use Psr\Log\LoggerInterface; /** - * SaveAssetKeywordsTest. + * Test for SaveAssetKeywords */ class SaveAssetKeywordsTest extends TestCase { diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetLinksTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetLinksTest.php index e029ae585169c..fe9202353fa2e 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetLinksTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetLinksTest.php @@ -16,7 +16,7 @@ use Psr\Log\LoggerInterface; /** - * SaveAssetLinksTest. + * Test for SaveAssetLinks */ class SaveAssetLinksTest extends TestCase { diff --git a/app/code/Magento/MediaGallery/Test/Unit/Plugin/Images/StorageTest.php b/app/code/Magento/MediaGallery/Test/Unit/Plugin/Images/StorageTest.php index 4ac448733c47f..817c56b34e348 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Plugin/Images/StorageTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Plugin/Images/StorageTest.php @@ -22,12 +22,11 @@ use Psr\Log\LoggerInterface; /** - * Test the DeleteByDirectoryPath command model + * Test for the Sorage::deleteDirectory after plugin */ class StorageTest extends TestCase { private const NON_STRING_PATH = 2020; - private const NON_EXISTENT_PATH = 'non_existent'; private const INVALID_PATH = '&&'; private const VALID_PATH = 'test-directory-path/'; diff --git a/app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php b/app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php index 51cef91b703ae..65115b940a900 100644 --- a/app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php @@ -8,13 +8,13 @@ namespace Magento\MediaGalleryApi\Api; /** - * Create folder by provided path + * Create folders by provided paths * @api */ interface CreateDirectoriesByPathsInterface { /** - * Create new directory by provided path + * Create new directories by provided paths * * @param string[] $paths * @throws \Magento\Framework\Exception\CouldNotSaveException diff --git a/app/code/Magento/MediaGalleryApi/Api/DeleteAssetsByPathsInterface.php b/app/code/Magento/MediaGalleryApi/Api/DeleteAssetsByPathsInterface.php index 2651638fc024c..5370235a31b95 100644 --- a/app/code/Magento/MediaGalleryApi/Api/DeleteAssetsByPathsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/DeleteAssetsByPathsInterface.php @@ -9,13 +9,13 @@ namespace Magento\MediaGalleryApi\Api; /** - * Delete media asset by exact or directory path + * Delete media assets by exact or directory paths * @api */ interface DeleteAssetsByPathsInterface { /** - * Delete media assets by path + * Delete media assets by paths. Removes all the assets which paths start with provided paths * * @param string[] $paths * @return void diff --git a/app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php b/app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php index 397c4b45590a6..5e04976e32c60 100644 --- a/app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php @@ -8,13 +8,13 @@ namespace Magento\MediaGalleryApi\Api; /** - * Delete folder by provided path + * Delete folders by provided paths * @api */ interface DeleteDirectoriesByPathsInterface { /** - * Deletes the existing folder + * Deletes the existing folders * * @param string[] $paths * @throws \Magento\Framework\Exception\CouldNotDeleteException diff --git a/app/code/Magento/MediaGalleryApi/Api/GetAssetsByIdsInterface.php b/app/code/Magento/MediaGalleryApi/Api/GetAssetsByIdsInterface.php index a4d56b501b6d0..5df6722a190d4 100644 --- a/app/code/Magento/MediaGalleryApi/Api/GetAssetsByIdsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/GetAssetsByIdsInterface.php @@ -9,7 +9,7 @@ namespace Magento\MediaGalleryApi\Api; /** - * A command represents the get media gallery asset by using media gallery asset id as a filter parameter. + * Get media gallery assets by id attribute * @api */ interface GetAssetsByIdsInterface diff --git a/app/code/Magento/MediaGalleryApi/Api/GetAssetsByPathsInterface.php b/app/code/Magento/MediaGalleryApi/Api/GetAssetsByPathsInterface.php index ef64b73112155..dbaed6e0e9123 100644 --- a/app/code/Magento/MediaGalleryApi/Api/GetAssetsByPathsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/GetAssetsByPathsInterface.php @@ -8,7 +8,7 @@ namespace Magento\MediaGalleryApi\Api; /** - * A command represents the get media gallery asset by using media gallery asset path as a filter parameter. + * Get media gallery assets by paths in media storage * @api */ interface GetAssetsByPathsInterface diff --git a/app/code/Magento/MediaGalleryApi/Api/GetAssetsKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Api/GetAssetsKeywordsInterface.php index c919d6b4d0fee..99b05291f32a0 100644 --- a/app/code/Magento/MediaGalleryApi/Api/GetAssetsKeywordsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/GetAssetsKeywordsInterface.php @@ -8,13 +8,13 @@ namespace Magento\MediaGalleryApi\Api; /** - * A command represents functionality to get a media gallery asset keywords filtered by media gallery asset id. + * Get a media gallery asset keywords related to media gallery asset ids provided * @api */ interface GetAssetsKeywordsInterface { /** - * Get assets related keywords. + * Get assets related keywords * * @param int[] $assetIds * @return \Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface[] diff --git a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php index 35f0da862e8d1..eb9f7d70bbccf 100644 --- a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php @@ -9,13 +9,13 @@ namespace Magento\MediaGalleryApi\Api; /** - * A command which executes the media gallery asset save operation. + * Save media gallery assets to the database * @api */ interface SaveAssetsInterface { /** - * Save media asset and return the media asset id + * Save media asset. The saved asset can later be retrieved by path * * @param \Magento\MediaGalleryApi\Api\Data\AssetInterface[] $assets * @throws \Magento\Framework\Exception\CouldNotSaveException diff --git a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php index 0aa64710802d5..072ae7a4ec6d5 100644 --- a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php @@ -8,13 +8,13 @@ namespace Magento\MediaGalleryApi\Api; /** - * A command represents the media gallery asset keywords save operation. + * Save keywords related to assets to the database * @api */ interface SaveAssetsKeywordsInterface { /** - * Save asset keywords. + * Save assets keywords * * @param \Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface[] $assetKeywords * @throws \Magento\Framework\Exception\CouldNotSaveException diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByDirectoryPathInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByDirectoryPathInterface.php index f4189308f12b5..79b209823aeb0 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByDirectoryPathInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByDirectoryPathInterface.php @@ -11,7 +11,8 @@ /** * A command represents the media gallery assets delete action. A media gallery asset is filtered by directory * path value. - * @deprecated use \Magento\MediaGalleryApi\Api\DeleteAssetsByPathInterface instead + * @deprecated use \Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface instead + * @see \Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface */ interface DeleteByDirectoryPathInterface { diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php index 94641b8135818..f33022e75d2fe 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php @@ -11,6 +11,7 @@ /** * A command represents the media gallery asset delete action. A media gallery asset is filtered by path value. * @deprecated use \Magento\MediaGalleryApi\Api\DeleteAssetsByPathInterface instead + * @see \Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface */ interface DeleteByPathInterface { diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php index 3a8d0aa9aad98..65cc2e3eae109 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php @@ -11,6 +11,7 @@ /** * A command represents the get media gallery asset by using media gallery asset id as a filter parameter. * @deprecated use \Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface instead + * @see \Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface */ interface GetByIdInterface { diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php index 092a16ba053e2..d8d5b6773fbbc 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php @@ -11,6 +11,7 @@ /** * A command represents the get media gallery asset by using media gallery asset path as a filter parameter. * @deprecated use \Magento\MediaGalleryApi\Api\GetAssetsByPathInterface instead + * @see \Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface */ interface GetByPathInterface { diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php index 96779238ec942..610ecf0cd22bf 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php @@ -12,7 +12,8 @@ /** * A command which executes the media gallery asset save operation. - * @deprecated use \Magento\MediaGalleryApi\Api\SaveAssetInterface instead + * @deprecated use \Magento\MediaGalleryApi\Api\SaveAssetsInterface instead + * @see \Magento\MediaGalleryApi\Api\SaveAssetsInterface */ interface SaveInterface { diff --git a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php index 7f29a6b5f508e..e42c370c1c6f7 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php @@ -9,7 +9,8 @@ /** * A command represents functionality to get a media gallery asset keywords filtered by media gallery asset id. - * @deprecated use \Magento\MediaGalleryApi\Api\GetAssetsByIdsInterface instead + * @deprecated use \Magento\MediaGalleryApi\Api\GetAssetsKeywordsInterface instead + * @see \Magento\MediaGalleryApi\Api\GetAssetsKeywordsInterface */ interface GetAssetKeywordsInterface { diff --git a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php index 05467d9dc0a80..824cbca178988 100644 --- a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php @@ -9,7 +9,8 @@ /** * A command represents the media gallery asset keywords save operation. - * @deprecated use \Magento\MediaGalleryApi\Api\SaveAssetKeywordsInterface instead + * @deprecated use \Magento\MediaGalleryApi\Api\SaveAssetsKeywordsInterface instead + * @see \Magento\MediaGalleryApi\Api\SaveAssetsKeywordsInterface */ interface SaveAssetKeywordsInterface { diff --git a/app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php b/app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php index c16150cbb3ad1..3a8c9294259f9 100644 --- a/app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php +++ b/app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php @@ -10,14 +10,14 @@ use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Gallery\Processor as ProcessorSubject; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -use Magento\MediaGallery\Plugin\Product\Gallery\Processor; +use Magento\MediaGalleryCatalog\Plugin\Product\Gallery\Processor; use Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; /** - * Unit test for \Magento\MediaGallery\Plugin\Product\Gallery\Processor + * Unit test for \Magento\MediaGalleryCatalog\Plugin\Product\Gallery\Processor */ class ProcessorTest extends TestCase { @@ -56,19 +56,13 @@ protected function setUp() $this->processorSubjectMock = $this->createMock(ProcessorSubject::class); $this->productMock = $this->createMock(Product::class); - $this->deleteMediaAssetByPathMock = $this->getMockBuilder(DeleteAssetsByPathsInterface::class) - ->disableOriginalConstructor() - ->setMethods(['execute']) - ->getMockForAbstractClass(); - $this->loggerMock = $this->getMockBuilder(LoggerInterface::class) - ->disableOriginalConstructor() - ->setMethods(['critical']) - ->getMockForAbstractClass(); + $this->deleteMediaAssetByPathMock = $this->createMock(DeleteAssetsByPathsInterface::class); + $this->loggerMock = $this->createMock(LoggerInterface::class); $this->plugin = (new ObjectManagerHelper($this))->getObject( Processor::class, [ - 'deleteMediaAssetByPath' => $this->deleteMediaAssetByPathMock, + 'deleteByPaths' => $this->deleteMediaAssetByPathMock, 'logger' => $this->loggerMock ] ); @@ -81,7 +75,7 @@ public function testAfterRemoveImageExpectsExecuteCalled() { $this->deleteMediaAssetByPathMock->expects($this->once()) ->method('execute') - ->with(self::STUB_FILE_NAME); + ->with([self::STUB_FILE_NAME]); $this->loggerMock->expects($this->never())->method('critical'); $actualResult = $this->plugin->afterRemoveImage( @@ -117,7 +111,7 @@ public function testAfterRemoveImageExpectsExecuteWillThrowException() { $this->deleteMediaAssetByPathMock->expects($this->once()) ->method('execute') - ->with(self::STUB_FILE_NAME) + ->with([self::STUB_FILE_NAME]) ->willThrowException(new \Exception('Some Exception')); $this->loggerMock->expects($this->once())->method('critical'); diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php index cd1c928bf5d0c..f24a960a29be9 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php @@ -21,7 +21,7 @@ use PHPUnit\Framework\TestCase; /** - * Testing assets keywords save and get + * End to end test for working with assets and keywords */ class AssetEndToEndTest extends TestCase { diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/IsBlacklistedTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/IsBlacklistedTest.php index e87cbe22ac622..57822d674a842 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/IsBlacklistedTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/IsBlacklistedTest.php @@ -12,7 +12,7 @@ use PHPUnit\Framework\TestCase; /** - * Test methods of class CreateByPath + * Test for IsPathBlacklistedInterface */ class CreateByPathsTest extends TestCase { diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetKeywordsTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetKeywordsTest.php index f26ff54eb7bec..02249021f2a50 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetKeywordsTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetKeywordsTest.php @@ -18,7 +18,7 @@ use PHPUnit\Framework\TestCase; /** - * Testing assets keywords save and get + * Testing assets keywords operation */ class AssetKeywordsTest extends TestCase { diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsByIdsTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsByIdsTest.php index ebf4ae94e811a..de0393372d23d 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsByIdsTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsByIdsTest.php @@ -12,7 +12,7 @@ use PHPUnit\Framework\TestCase; /** - * Testing assets keywords save and get + * Test for GetAssetsByIdsInterface */ class AssetsByIdsTest extends TestCase { diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php index 17a555ac0b66f..c32113dfdda33 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php @@ -18,7 +18,7 @@ use PHPUnit\Framework\TestCase; /** - * Testing assets keywords save and get + * Test for assets operations */ class AssetsTest extends TestCase { diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsTest.php index c9710c0dd4f28..0b790730805e9 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/DeleteAssetsTest.php @@ -13,7 +13,7 @@ use PHPUnit\Framework\TestCase; /** - * Testing delete assets + * Testing delete assets operation */ class DeleteAssetsTest extends TestCase { From 6dfb2cc9f5cfb888a578ab63522cd670fe3cf67b Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Thu, 9 Apr 2020 19:46:28 +0100 Subject: [PATCH 119/177] magento/magento2#27499: Filtering data for insert --- .../MediaGallery/Model/Asset/Command/Save.php | 30 +++++++++++++++++-- .../Model/ResourceModel/SaveAssets.php | 26 +++++++++++++++- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php index b8a7ae3b624f3..0ce0d0c18e6d2 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php @@ -7,11 +7,11 @@ namespace Magento\MediaGallery\Model\Asset\Command; -use Magento\MediaGalleryApi\Api\Data\AssetInterface; -use Magento\MediaGalleryApi\Model\Asset\Command\SaveInterface; use Magento\Framework\App\ResourceConnection; use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\Reflection\DataObjectProcessor; +use Magento\MediaGalleryApi\Api\Data\AssetInterface; +use Magento\MediaGalleryApi\Model\Asset\Command\SaveInterface; use Psr\Log\LoggerInterface; /** @@ -72,7 +72,7 @@ public function execute(AssetInterface $mediaAsset): int $connection->insertOnDuplicate( $tableName, - array_filter($this->objectProcessor->buildOutputDataArray($mediaAsset, AssetInterface::class)) + $this->filterData($this->objectProcessor->buildOutputDataArray($mediaAsset, AssetInterface::class)) ); return (int) $connection->lastInsertId($tableName); } catch (\Exception $exception) { @@ -81,4 +81,28 @@ public function execute(AssetInterface $mediaAsset): int throw new CouldNotSaveException($message, $exception); } } + + /** + * Filter data to get flat array without null values + * + * @param array $data + * @return array + */ + private function filterData(array $data): array + { + $filteredData = []; + foreach ($data as $key => $value) { + if ($value === null) { + continue; + } + if (is_array($value)) { + continue; + } + if (is_object($value)) { + continue; + } + $filteredData[$key] = $value; + } + return $filteredData; + } } diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php b/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php index 84733ca2ff1c6..64689d0ab4275 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php @@ -66,7 +66,7 @@ public function execute(array $assets): void try { $connection->insertOnDuplicate( $tableName, - array_filter($this->objectProcessor->buildOutputDataArray($asset, AssetInterface::class)) + $this->filterData($this->objectProcessor->buildOutputDataArray($asset, AssetInterface::class)) ); } catch (\Exception $exception) { $this->logger->critical($exception); @@ -85,4 +85,28 @@ public function execute(array $assets): void ); } } + + /** + * Filter data to get flat array without null values + * + * @param array $data + * @return array + */ + private function filterData(array $data): array + { + $filteredData = []; + foreach ($data as $key => $value) { + if ($value === null) { + continue; + } + if (is_array($value)) { + continue; + } + if (is_object($value)) { + continue; + } + $filteredData[$key] = $value; + } + return $filteredData; + } } From baebe46dee141a95bf67695ee1bbf4b30af49018 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Thu, 9 Apr 2020 16:47:42 -0500 Subject: [PATCH 120/177] MC-33086: [Improvement] Apply Event To Category observer --- app/code/Magento/Catalog/Block/Product/ListProduct.php | 9 ++++++++- app/code/Magento/Catalog/Model/Product.php | 9 +++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Product/ListProduct.php b/app/code/Magento/Catalog/Block/Product/ListProduct.php index 59f5cc1b53b26..76fcdfbf232e5 100644 --- a/app/code/Magento/Catalog/Block/Product/ListProduct.php +++ b/app/code/Magento/Catalog/Block/Product/ListProduct.php @@ -136,7 +136,14 @@ public function getLayer() */ public function getLoadedProductCollection() { - return $this->_getProductCollection(); + $collection = $this->_getProductCollection(); + + $categoryId = $this->getLayer()->getCurrentCategory()->getId(); + foreach ($collection as $product) { + $product->setData('category_id', $categoryId); + } + + return $collection; } /** diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index a9907c1661bd8..fd59130db4bdf 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -725,9 +725,14 @@ public function getIdBySku($sku) */ public function getCategoryId() { + if ($this->hasData('category_id')) { + return $this->getData('category_id'); + } $category = $this->_registry->registry('current_category'); - if ($category && in_array($category->getId(), $this->getCategoryIds())) { - return $category->getId(); + $categoryId = $category ? $category->getId() : null; + if ($categoryId && in_array($categoryId, $this->getCategoryIds())) { + $this->setData('category_id', $categoryId); + return $categoryId; } return false; } From cc5f1bc603d9fe18f6b6fc71b2ccf2e013d22490 Mon Sep 17 00:00:00 2001 From: Bartosz Gorski <bartosz.m.gorski@gmail.com> Date: Fri, 10 Apr 2020 05:35:21 +0200 Subject: [PATCH 121/177] Removed a duplicate variable in \Magento\QuoteGraphQl\Model\Resolver\Cart and in \Magento\QuoteGraphQl\Model\Resolver\SetBillingAddressOnCart --- app/code/Magento/QuoteGraphQl/Model/Resolver/Cart.php | 2 +- .../QuoteGraphQl/Model/Resolver/SetBillingAddressOnCart.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart.php index 34812c3eac410..fdfdc4b7280c2 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart.php @@ -43,7 +43,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value $maskedCartId = $args['cart_id']; $currentUserId = $context->getUserId(); - $storeId = $storeId = (int)$context->getExtensionAttributes()->getStore()->getId(); + $storeId = (int)$context->getExtensionAttributes()->getStore()->getId(); $cart = $this->getCartForUser->execute($maskedCartId, $currentUserId, $storeId); return [ diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/SetBillingAddressOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/SetBillingAddressOnCart.php index c315aa9b14146..eb82510003fc7 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Resolver/SetBillingAddressOnCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/SetBillingAddressOnCart.php @@ -65,7 +65,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value } $billingAddress = $args['input']['billing_address']; - $storeId = $storeId = (int)$context->getExtensionAttributes()->getStore()->getId(); + $storeId = (int)$context->getExtensionAttributes()->getStore()->getId(); $cart = $this->getCartForUser->execute($maskedCartId, $context->getUserId(), $storeId); $this->checkCartCheckoutAllowance->execute($cart); $this->setBillingAddressOnCart->execute($context, $cart, $billingAddress); From d4b108a26b3b0bdf56ba9cde55cb142f419c088d Mon Sep 17 00:00:00 2001 From: "rostyslav.hymon" <rostyslav.hymon@transoftgroup.com> Date: Fri, 10 Apr 2020 09:18:21 +0300 Subject: [PATCH 122/177] MC-33278: [Magento Cloud] - Magento\Framework\App\DeploymentConfig\Reader::load function is taking too much time --- .../Magento/Developer/Model/Logger/Handler/DebugTest.php | 2 +- lib/internal/Magento/Framework/App/DeploymentConfig.php | 4 +++- lib/internal/Magento/Framework/Locale/Resolver.php | 4 ++-- lib/internal/Magento/Framework/Module/ModuleList.php | 7 ++----- .../Magento/Framework/Module/Test/Unit/ModuleListTest.php | 5 ----- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Developer/Model/Logger/Handler/DebugTest.php b/dev/tests/integration/testsuite/Magento/Developer/Model/Logger/Handler/DebugTest.php index fec71206accd8..30e70bd8f10d6 100644 --- a/dev/tests/integration/testsuite/Magento/Developer/Model/Logger/Handler/DebugTest.php +++ b/dev/tests/integration/testsuite/Magento/Developer/Model/Logger/Handler/DebugTest.php @@ -139,7 +139,7 @@ public function testDebugInDeveloperMode() { $message = 'test message'; $this->reinitDebugHandler(State::MODE_DEVELOPER); - + $this->deploymentConfig->resetData(); $this->removeDebugLog(); $this->logger->debug($message); $this->assertFileExists($this->getDebuggerLogPath()); diff --git a/lib/internal/Magento/Framework/App/DeploymentConfig.php b/lib/internal/Magento/Framework/App/DeploymentConfig.php index ddd7faa80b906..6aeec2c2d0192 100644 --- a/lib/internal/Magento/Framework/App/DeploymentConfig.php +++ b/lib/internal/Magento/Framework/App/DeploymentConfig.php @@ -15,6 +15,7 @@ * Application deployment configuration * * @api + * @since 100.0.2 */ class DeploymentConfig { @@ -148,7 +149,7 @@ public function isDbAvailable() */ private function load() { - if (null === $this->data) { + if (empty($this->data)) { $this->data = $this->reader->load(); if ($this->overrideData) { $this->data = array_replace($this->data, $this->overrideData); @@ -183,6 +184,7 @@ private function flattenParams(array $params, $path = null, array &$flattenResul $newPath = $key; } if (isset($flattenResult[$newPath])) { + //phpcs:ignore Magento2.Exceptions.DirectThrow throw new RuntimeException(new Phrase("Key collision '%1' is already defined.", [$newPath])); } $flattenResult[$newPath] = $param; diff --git a/lib/internal/Magento/Framework/Locale/Resolver.php b/lib/internal/Magento/Framework/Locale/Resolver.php index d058bfd41ab1a..55ef2a4e9a30c 100644 --- a/lib/internal/Magento/Framework/Locale/Resolver.php +++ b/lib/internal/Magento/Framework/Locale/Resolver.php @@ -15,7 +15,7 @@ class Resolver implements ResolverInterface { /** - * Default locale + * Resolver default locale */ const DEFAULT_LOCALE = 'en_US'; @@ -79,7 +79,7 @@ public function __construct( $this->scopeConfig = $scopeConfig; $this->defaultLocalePath = $defaultLocalePath; $this->scopeType = $scopeType; - $this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->create(DeploymentConfig::class); + $this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->get(DeploymentConfig::class); $this->setLocale($locale); } diff --git a/lib/internal/Magento/Framework/Module/ModuleList.php b/lib/internal/Magento/Framework/Module/ModuleList.php index 5a60a1c102b05..b3cf433bbaf45 100644 --- a/lib/internal/Magento/Framework/Module/ModuleList.php +++ b/lib/internal/Magento/Framework/Module/ModuleList.php @@ -140,11 +140,8 @@ public function isModuleInfoAvailable() */ private function loadConfigData() { - if (null === $this->configData) { - $this->config->resetData(); - if (null !== $this->config->get(ConfigOptionsListConstants::KEY_MODULES)) { - $this->configData = $this->config->get(ConfigOptionsListConstants::KEY_MODULES); - } + if (null === $this->configData && null !== $this->config->get(ConfigOptionsListConstants::KEY_MODULES)) { + $this->configData = $this->config->get(ConfigOptionsListConstants::KEY_MODULES); } } } diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php index 3142bbbc6771a..363f90501dd0d 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php @@ -47,7 +47,6 @@ protected function setUp() public function testGetAll() { - $this->config->expects($this->once())->method('resetData'); $this->setLoadAllExpectation(); $this->setLoadConfigExpectation(); $expected = ['foo' => self::$allFixture['foo']]; @@ -65,7 +64,6 @@ public function testGetAllNoData() public function testGetOne() { - $this->config->expects($this->once())->method('resetData'); $this->setLoadAllExpectation(); $this->setLoadConfigExpectation(); $this->assertSame(['key' => 'value'], $this->model->getOne('foo')); @@ -74,7 +72,6 @@ public function testGetOne() public function testGetNames() { - $this->config->expects($this->once())->method('resetData'); $this->setLoadAllExpectation(false); $this->setLoadConfigExpectation(); $this->assertSame(['foo'], $this->model->getNames()); @@ -83,7 +80,6 @@ public function testGetNames() public function testHas() { - $this->config->expects($this->once())->method('resetData'); $this->setLoadAllExpectation(false); $this->setLoadConfigExpectation(); $this->assertTrue($this->model->has('foo')); @@ -92,7 +88,6 @@ public function testHas() public function testIsModuleInfoAvailable() { - $this->config->expects($this->once())->method('resetData'); $this->setLoadConfigExpectation(true); $this->assertTrue($this->model->isModuleInfoAvailable()); } From aa8ed066962411571cf605f5b80efec9da26ddf3 Mon Sep 17 00:00:00 2001 From: "rostyslav.hymon" <rostyslav.hymon@transoftgroup.com> Date: Fri, 10 Apr 2020 11:03:03 +0300 Subject: [PATCH 123/177] MC-33278: [Magento Cloud] - Magento\Framework\App\DeploymentConfig\Reader::load function is taking too much time --- .../App/Test/Unit/DeploymentConfigTest.php | 12 +++++++----- .../Framework/Module/Test/Unit/ModuleListTest.php | 13 +++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php index 81a4f842bdf1d..f93153f3cd75c 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/DeploymentConfigTest.php @@ -6,10 +6,12 @@ namespace Magento\Framework\App\Test\Unit; -use \Magento\Framework\App\DeploymentConfig; -use \Magento\Framework\Config\ConfigOptionsListConstants; +use Magento\Framework\App\DeploymentConfig; +use Magento\Framework\Config\ConfigOptionsListConstants; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; -class DeploymentConfigTest extends \PHPUnit\Framework\TestCase +class DeploymentConfigTest extends TestCase { /** * @var array @@ -63,7 +65,7 @@ class DeploymentConfigTest extends \PHPUnit\Framework\TestCase protected $_deploymentConfigMerged; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ private $reader; @@ -124,7 +126,7 @@ public function testNotAvailable(): void */ public function testNotAvailableThenAvailable(): void { - $this->reader->expects($this->once())->method('load')->willReturn([]); + $this->reader->expects($this->once())->method('load')->willReturn(['Test']); $object = new DeploymentConfig($this->reader); $this->assertFalse($object->isAvailable()); $this->assertFalse($object->isAvailable()); diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php index 363f90501dd0d..f8b02d177e097 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/ModuleListTest.php @@ -5,9 +5,14 @@ */ namespace Magento\Framework\Module\Test\Unit; -use \Magento\Framework\Module\ModuleList; +use Magento\Framework\Module\ModuleList; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; -class ModuleListTest extends \PHPUnit\Framework\TestCase +/** + * Test for module list + */ +class ModuleListTest extends TestCase { /** * Fixture for all modules' meta-information @@ -24,12 +29,12 @@ class ModuleListTest extends \PHPUnit\Framework\TestCase private static $enabledFixture = ['foo' => 1, 'bar' => 0]; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ private $config; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ private $loader; From 0e46cc8b6414b6addf7d4b9ad279a8fc25991a06 Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Fri, 10 Apr 2020 11:58:12 +0300 Subject: [PATCH 124/177] using action group to go to admin category page --- ...ndleProductShownInCategoryListAndGridTest.xml | 3 +-- .../Test/AdminAddImageToWYSIWYGCatalogTest.xml | 3 +-- ...ndSubcategoryIsNotVisibleInNavigationTest.xml | 3 +-- ...bcategoryIsNotVisibleInNavigationMenuTest.xml | 3 +-- ...ndSubcategoryIsNotVisibleInNavigationTest.xml | 3 +-- .../AdminCheckPaginationInStorefrontTest.xml | 3 +-- ...bCategoryIsNotVisibleInNavigationMenuTest.xml | 3 +-- ...tegoryFormDisplaySettingsUIValidationTest.xml | 3 +-- ...ategoryLayoutFromConfigurationSettingTest.xml | 3 +-- .../AdminCreateCategoryTest.xml | 3 +-- .../AdminCreateCategoryWithAnchorFieldTest.xml | 3 +-- ...nCreateCategoryWithCustomRootCategoryTest.xml | 3 +-- .../AdminCreateCategoryWithFiveNestingTest.xml | 6 ++---- ...minCreateCategoryWithInactiveCategoryTest.xml | 3 +-- ...eateCategoryWithInactiveIncludeInMenuTest.xml | 3 +-- .../AdminCreateCategoryWithNoAnchorFieldTest.xml | 3 +-- ...nCreateCategoryWithProductsGridFilterTest.xml | 3 +-- ...AdminCreateCategoryWithRequiredFieldsTest.xml | 3 +-- ...activeFlatCategoryAndUpdateAsInactiveTest.xml | 3 +-- .../Test/AdminCreateInactiveFlatCategoryTest.xml | 3 +-- ...AdminCreateInactiveInMenuFlatCategoryTest.xml | 3 +-- ...minCreateRootCategoryAndSubcategoriesTest.xml | 2 +- ...AdminCreateRootCategoryRequiredFieldsTest.xml | 2 +- ...dminDeleteRootCategoryAssignedToStoreTest.xml | 3 +-- .../Mftf/Test/AdminDeleteRootCategoryTest.xml | 6 ++---- .../Mftf/Test/AdminDeleteRootSubCategoryTest.xml | 3 +-- ...ingCategoryProductsUsingScopeSelectorTest.xml | 2 +- .../Mftf/Test/AdminMoveAnchoredCategoryTest.xml | 6 ++---- ...MoveAnchoredCategoryToDefaultCategoryTest.xml | 6 ++---- .../AdminMoveCategoryAndCheckUrlRewritesTest.xml | 6 ++---- ...oveCategoryFromParentAnchoredCategoryTest.xml | 6 ++---- ...tegoryToAnotherPositionInCategoryTreeTest.xml | 6 ++---- ...uiredFieldsHaveRequiredFieldIndicatorTest.xml | 2 +- ...egoryAndCheckDefaultUrlKeyOnStoreViewTest.xml | 3 +-- .../AdminUpdateCategoryAndMakeInactiveTest.xml | 6 ++---- .../AdminUpdateCategoryNameWithStoreViewTest.xml | 3 +-- .../Test/AdminUpdateCategoryStoreUrlKeyTest.xml | 3 +-- ...dminUpdateCategoryUrlKeyWithStoreViewTest.xml | 3 +-- ...dateCategoryWithInactiveIncludeInMenuTest.xml | 6 ++---- .../Test/AdminUpdateCategoryWithProductsTest.xml | 3 +-- ...AdminUpdateFlatCategoryAndAddProductsTest.xml | 3 +-- ...UpdateFlatCategoryIncludeInNavigationTest.xml | 3 +-- ...nUpdateFlatCategoryNameAndDescriptionTest.xml | 6 ++---- ...gularPriceInStockUnassignFromCategoryTest.xml | 3 +-- ...minUpdateTopCategoryUrlWithNoRedirectTest.xml | 3 +-- ...AdminUpdateTopCategoryUrlWithRedirectTest.xml | 3 +-- .../Test/Mftf/Test/DeleteCategoriesTest.xml | 12 ++++-------- .../Test/Mftf/Test/EndToEndB2CAdminTest.xml | 9 +++------ ...ctAvailableAfterEnablingSubCategoriesTest.xml | 3 +-- ...ChildCategoriesShouldNotIncludeInMenuTest.xml | 16 ++++++---------- ...rifyTinyMCEv4IsNativeWYSIWYGOnCatalogTest.xml | 3 +-- .../CatalogProductListWidgetOperatorsTest.xml | 3 +-- ...ontSwatchAttributesDisplayInWidgetCMSTest.xml | 3 +-- 53 files changed, 73 insertions(+), 140 deletions(-) diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGridTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGridTest.xml index 822b42af4c5a8..871bf71d1f876 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGridTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGridTest.xml @@ -36,8 +36,7 @@ <deleteData createDataKey="simpleProduct4" stepKey="deleteSimpleProduct4"/> </after> <!--Make category--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="goToCategoryPage"/> - <waitForPageLoad stepKey="waitForCategoryPageLoad"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="goToCategoryPage"/> <actionGroup ref="CreateCategoryActionGroup" stepKey="createASubcategory"> <argument name="categoryEntity" value="SimpleSubCategory"/> </actionGroup> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageToWYSIWYGCatalogTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageToWYSIWYGCatalogTest.xml index 1850faebd16c6..6eb4de39726f0 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageToWYSIWYGCatalogTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageToWYSIWYGCatalogTest.xml @@ -22,8 +22,7 @@ <severity value="CRITICAL"/> <testCaseId value="MAGETWO-84373"/> </annotations> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToNewCatalog"/> - <waitForPageLoad stepKey="wait1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToNewCatalog"/> <waitForLoadingMaskToDisappear stepKey="wait2" /> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategory"/> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{SimpleSubCategory.name}}" stepKey="enterCategoryName"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckInactiveAndNotIncludeInMenuCategoryAndSubcategoryIsNotVisibleInNavigationTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckInactiveAndNotIncludeInMenuCategoryAndSubcategoryIsNotVisibleInNavigationTest.xml index f076f4fa407b4..de8110f995606 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckInactiveAndNotIncludeInMenuCategoryAndSubcategoryIsNotVisibleInNavigationTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckInactiveAndNotIncludeInMenuCategoryAndSubcategoryIsNotVisibleInNavigationTest.xml @@ -30,8 +30,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <!--Open Category Page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <!--Create subcategory under parent category --> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <waitForPageLoad stepKey="waitForCategoryToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckInactiveCategoryAndSubcategoryIsNotVisibleInNavigationMenuTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckInactiveCategoryAndSubcategoryIsNotVisibleInNavigationMenuTest.xml index 8a0b1977bf901..fd8093d8d3b52 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckInactiveCategoryAndSubcategoryIsNotVisibleInNavigationMenuTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckInactiveCategoryAndSubcategoryIsNotVisibleInNavigationMenuTest.xml @@ -29,8 +29,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <!--Open Category Page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <!--Create subcategory under parent category --> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <waitForPageLoad stepKey="waitForCategoryToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckInactiveIncludeInMenuCategoryAndSubcategoryIsNotVisibleInNavigationTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckInactiveIncludeInMenuCategoryAndSubcategoryIsNotVisibleInNavigationTest.xml index e832f2baf24a2..e6cbe156698e7 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckInactiveIncludeInMenuCategoryAndSubcategoryIsNotVisibleInNavigationTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckInactiveIncludeInMenuCategoryAndSubcategoryIsNotVisibleInNavigationTest.xml @@ -30,8 +30,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <!--Open Category Page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <!--Create subcategory under parent category --> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <waitForPageLoad stepKey="waitForCategoryToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckPaginationInStorefrontTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckPaginationInStorefrontTest.xml index 278a1fdc7ad9c..549b1bb37cce4 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckPaginationInStorefrontTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckPaginationInStorefrontTest.xml @@ -99,8 +99,7 @@ <seeInField selector="{{AdminCatalogStorefrontConfigSection.productsPerPageDefaultValue}}" userInput="12" stepKey="seeDefaultValueProductPerPage"/> <!--Open Category Page and select created category--> <comment userInput="Open Category Page and select created category" stepKey="commentOpenCategoryPage"/> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoad1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <waitForPageLoad stepKey="waitForPageToLoad0"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(_defaultCategory.name)}}" stepKey="selectCreatedCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckSubCategoryIsNotVisibleInNavigationMenuTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckSubCategoryIsNotVisibleInNavigationMenuTest.xml index ff1e65bca9acc..192bab7c6d126 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckSubCategoryIsNotVisibleInNavigationMenuTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckSubCategoryIsNotVisibleInNavigationMenuTest.xml @@ -29,8 +29,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <!--Open Category Page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <!--Create subcategory under parent category --> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <waitForPageLoad stepKey="waitForCategoryToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest/AdminCategoryFormDisplaySettingsUIValidationTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest/AdminCategoryFormDisplaySettingsUIValidationTest.xml index e0fa4a3c3410c..c282cccb72952 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest/AdminCategoryFormDisplaySettingsUIValidationTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest/AdminCategoryFormDisplaySettingsUIValidationTest.xml @@ -23,8 +23,7 @@ <after> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage"/> - <waitForPageLoad time="30" stepKey="waitForPageLoad1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPage"/> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategory"/> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{SimpleSubCategory.name}}" stepKey="enterCategoryName"/> <click selector="{{CategoryDisplaySettingsSection.DisplaySettingTab}}" stepKey="clickOnDisplaySettingsTab"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest/AdminConfigDefaultCategoryLayoutFromConfigurationSettingTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest/AdminConfigDefaultCategoryLayoutFromConfigurationSettingTest.xml index e8b13afc7138e..900b3f6cd2f1c 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest/AdminConfigDefaultCategoryLayoutFromConfigurationSettingTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest/AdminConfigDefaultCategoryLayoutFromConfigurationSettingTest.xml @@ -31,8 +31,7 @@ <seeOptionIsSelected selector="{{DefaultLayoutsSection.categoryLayout}}" userInput="No layout updates" stepKey="seeNoLayoutUpdatesSelected"/> <selectOption selector="{{DefaultLayoutsSection.categoryLayout}}" userInput="2 columns with right bar" stepKey="select2ColumnsLayout"/> <click selector="{{ContentManagementSection.Save}}" stepKey="clickSaveConfig"/> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToNewCatalog"/> - <waitForPageLoad stepKey="wait1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToNewCatalog"/> <waitForLoadingMaskToDisappear stepKey="wait2"/> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategory"/> <click selector="{{CategoryDesignSection.DesignTab}}" stepKey="clickOnDesignTab"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest/AdminCreateCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest/AdminCreateCategoryTest.xml index 8ad76bdde7306..b8e58eae8a98a 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest/AdminCreateCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryTest/AdminCreateCategoryTest.xml @@ -22,8 +22,7 @@ </after> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin1"/> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage"/> - <waitForPageLoad time="30" stepKey="waitForPageLoad1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPage"/> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategory"/> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{SimpleSubCategory.name}}" stepKey="enterCategoryName"/> <click selector="{{AdminCategorySEOSection.SectionHeader}}" stepKey="openSEO"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithAnchorFieldTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithAnchorFieldTest.xml index 7deb79c66ff6d..ca83f746ee969 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithAnchorFieldTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithAnchorFieldTest.xml @@ -29,8 +29,7 @@ <deleteData stepKey="deleteSimpleProduct" createDataKey="simpleProduct"/> </after> <!--Create SubCategory--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton"/> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{_defaultCategory.name}}" stepKey="fillCategoryName"/> <checkOption selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="enableCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithCustomRootCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithCustomRootCategoryTest.xml index 71167882d135d..4b0774d2307dd 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithCustomRootCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithCustomRootCategoryTest.xml @@ -31,8 +31,7 @@ </actionGroup> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForCategoryIndexPageToBeLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <!--Create Root Category--> <actionGroup ref="AdminCreateRootCategory" stepKey="createNewRootCategory"> <argument name="categoryEntity" value="NewRootCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithFiveNestingTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithFiveNestingTest.xml index c1df630685949..967cb773fe3b0 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithFiveNestingTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithFiveNestingTest.xml @@ -22,8 +22,7 @@ <actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminPanel"/> </before> <after> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="goToCategoryPage"/> - <waitForPageLoad time="60" stepKey="waitForCategoryPageLoad"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="goToCategoryPage"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(FirstLevelSubCat.name)}}" stepKey="clickCategoryLink"/> <click selector="{{AdminCategoryMainActionsSection.DeleteButton}}" stepKey="clickDelete"/> <waitForElementVisible selector="{{AdminCategoryModalSection.message}}" stepKey="waitForConfirmationModal"/> @@ -36,8 +35,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <!--Create Category with Five Nesting --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForCategoryIndexPageToBeLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <!--Create Nested First Category--> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton"/> <checkOption selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="enableCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveCategoryTest.xml index 34714db67fbd6..c82658d283cfb 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveCategoryTest.xml @@ -25,8 +25,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <!-- Create In active Category --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForCategoryIndexPageToBeLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton"/> <click selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}" stepKey="disableCategory"/> <checkOption selector="{{AdminCategoryBasicFieldSection.IncludeInMenu}}" stepKey="enableIncludeInMenu"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveIncludeInMenuTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveIncludeInMenuTest.xml index a11717c04ea8c..0019c9c4e948e 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveIncludeInMenuTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveIncludeInMenuTest.xml @@ -25,8 +25,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <!--Create Category with not included in menu Subcategory --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForCategoryIndexPageToBeLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton"/> <checkOption selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="enableCategory"/> <click selector="{{AdminCategoryBasicFieldSection.includeInMenuLabel}}" stepKey="disableIncludeInMenu"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithNoAnchorFieldTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithNoAnchorFieldTest.xml index ec3c7a26723c2..9ae3149d94039 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithNoAnchorFieldTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithNoAnchorFieldTest.xml @@ -30,8 +30,7 @@ </after> <!--Create SubCategory--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton"/> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{_defaultCategory.name}}" stepKey="fillCategoryName"/> <checkOption selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="enableCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithProductsGridFilterTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithProductsGridFilterTest.xml index 99d0f88cf0e9a..00e93122d28bc 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithProductsGridFilterTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithProductsGridFilterTest.xml @@ -58,8 +58,7 @@ <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveProduct"/> <waitForPageLoad stepKey="waitForProductSaved"/> <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the product." stepKey="messageYouSavedTheProductIsShown"/> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <!--Create sub category--> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton"/> <checkOption selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="enableCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithRequiredFieldsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithRequiredFieldsTest.xml index 871dd606c14db..20d4da8e6f09b 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithRequiredFieldsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithRequiredFieldsTest.xml @@ -25,8 +25,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <!-- Create subcategory with required fields --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForCategoryIndexPageToBeLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton"/> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{_defaultCategory.name}}" stepKey="fillCategoryName"/> <checkOption selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="enableCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateInactiveFlatCategoryAndUpdateAsInactiveTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateInactiveFlatCategoryAndUpdateAsInactiveTest.xml index c3b86c99bbd67..1c12b048e96d0 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateInactiveFlatCategoryAndUpdateAsInactiveTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateInactiveFlatCategoryAndUpdateAsInactiveTest.xml @@ -55,8 +55,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <!-- Select created category and make category inactive--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoad"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(CatNotActive.name)}}" stepKey="selectCreatedCategory"/> <waitForPageLoad stepKey="waitForCategoryPageToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateInactiveFlatCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateInactiveFlatCategoryTest.xml index affdbaf7b0eb7..ff30c46a51c3a 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateInactiveFlatCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateInactiveFlatCategoryTest.xml @@ -55,8 +55,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <!-- Select created category and make category inactive--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoad"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleSubCategory.name)}}" stepKey="selectCreatedCategory"/> <waitForPageLoad stepKey="waitForCategoryPageToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateInactiveInMenuFlatCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateInactiveInMenuFlatCategoryTest.xml index 10e4d9f434be0..2b4437aed1bb2 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateInactiveInMenuFlatCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateInactiveInMenuFlatCategoryTest.xml @@ -55,8 +55,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <!-- Select created category and disable Include In Menu option--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoad"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleSubCategory.name)}}" stepKey="selectCreatedCategory"/> <waitForPageLoad stepKey="waitForCategoryPageToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryAndSubcategoriesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryAndSubcategoriesTest.xml index b959b961ef1ea..40ca511e1f7bc 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryAndSubcategoriesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryAndSubcategoriesTest.xml @@ -39,7 +39,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout2"/> </after> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin1"/> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="amOnAdminCategoryPage"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="amOnAdminCategoryPage"/> <scrollToTopOfPage stepKey="scrollToTopOfPage1"/> <waitForPageLoad stepKey="waitForPageLoad1"/> <!--Create new root category--> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryRequiredFieldsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryRequiredFieldsTest.xml index a5556b076fef6..72833de24ae5e 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryRequiredFieldsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryRequiredFieldsTest.xml @@ -29,7 +29,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout" /> </after> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="OpenAdminCatergoryIndexPage"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="OpenAdminCatergoryIndexPage"/> <click selector="{{AdminCategorySidebarActionSection.AddRootCategoryButton}}" stepKey="ClickOnAddRootButton"/> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{_defaultCategory.name}}" stepKey="FillCategoryField"/> <checkOption selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="EnableCheckOption"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteRootCategoryAssignedToStoreTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteRootCategoryAssignedToStoreTest.xml index 0396ab743c745..2fa91604e1776 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteRootCategoryAssignedToStoreTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteRootCategoryAssignedToStoreTest.xml @@ -39,8 +39,7 @@ <see userInput="You saved the store." stepKey="seeSaveMessage"/> <!--Verify Delete Root Category can not be deleted--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage1"/> - <waitForPageLoad stepKey="waitForCategoryIndexPageToBeLoaded1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage1"/> <scrollToTopOfPage stepKey="scrollToTopOfPage2"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="expandToSeeAllCategories"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(NewRootCategory.name))}}" stepKey="clickRootCategoryInTree"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteRootCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteRootCategoryTest.xml index 0a41842d5709c..40bd3bdcfea20 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteRootCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteRootCategoryTest.xml @@ -26,8 +26,7 @@ </after> <!--Verify Created root Category--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForCategoryIndexPageToBeLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="expandToSeeAllCategories"/> <waitForPageLoad stepKey="waitForPageToLoad"/> <seeElement selector="{{AdminCategoryBasicFieldSection.CategoryNameInput(NewRootCategory.name)}}" stepKey="seeRootCategory"/> @@ -36,8 +35,7 @@ <deleteData createDataKey="rootCategory" stepKey="deleteRootCategory"/> <!--Verify Root Category is not listed in backend--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage1"/> - <waitForPageLoad stepKey="waitForCategoryIndexPageToBeLoaded1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage1"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="expandToSeeAllCategories1"/> <dontSee selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{NewRootCategory.name}}" stepKey="dontSeeRootCategory"/> </test> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteRootSubCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteRootSubCategoryTest.xml index 6ae00d213bf77..fe07360d6b9ca 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteRootSubCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminDeleteRootSubCategoryTest.xml @@ -70,8 +70,7 @@ <deleteData createDataKey="category" stepKey="deleteCategory"/> <!--Verify Sub Category is absent in backend --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForCategoryIndexPageToBeLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="expandToSeeAllCategories2"/> <dontSee selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleRootSubCategory.name)}}" stepKey="dontSeeCategoryInTree"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml index 89b3b2cb6fb41..2b198dacca241 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml @@ -100,7 +100,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <!-- Step 1-2: Open Category page and Set scope selector to All Store Views--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="goToCategoryPage"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="goToCategoryPage"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree($$createCategory.name$$)}}" stepKey="clickCategoryName"/> <click selector="{{AdminCategoryProductsSection.sectionHeader}}" stepKey="openProductSection"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryTest.xml index d302dad52d6e6..8ca09273c2a4a 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryTest.xml @@ -48,8 +48,7 @@ </after> <!--Move category one to category two--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToAdminCategoryPage"/> - <waitForPageLoad stepKey="waitForAdminCategoryPageLoad1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToAdminCategoryPage"/> <actionGroup ref="MoveCategoryActionGroup" stepKey="moveSimpleSubCategoryOneToSimpleSubCategoryTwo"> <argument name="childCategory" value="$simpleSubCategoryOne.name$"/> <argument name="parentCategory" value="$simpleSubCategoryTwo.name$"/> @@ -89,8 +88,7 @@ <see selector="{{StorefrontNavigationSection.breadcrumbs}}" userInput="$simpleSubCategoryOne.name$" stepKey="seeSubCategoryWithParentInBreadcrumbsOnSubCategoryWithParent"/> <see selector="{{StorefrontNavigationSection.breadcrumbs}}" userInput="$productOne.name$" stepKey="seeProductInBreadcrumbsOnSubCategoryWithParent"/> <!--Move category one to the same level as category two--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToAdminCategoryPage2"/> - <waitForPageLoad stepKey="waitForAdminCategoryPageLoad2"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToAdminCategoryPage2"/> <actionGroup ref="MoveCategoryActionGroup" stepKey="moveSimpleSubCategoryOneToDefaultCategory"> <argument name="childCategory" value="$simpleSubCategoryOne.name$"/> <argument name="parentCategory" value="Default Category"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryToDefaultCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryToDefaultCategoryTest.xml index 1ea1f60f52a2c..bf5fde3b85bba 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryToDefaultCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryToDefaultCategoryTest.xml @@ -29,8 +29,7 @@ </after> <!--Open Category Page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <waitForPageLoad stepKey="waitForCategoryToLoad"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(_defaultCategory.name)}}" stepKey="selectCategory"/> @@ -92,8 +91,7 @@ <see selector="{{StorefrontProductInfoMainSection.productName}}" userInput="{{defaultSimpleProduct.name}}" stepKey="assertProductName"/> <!--Open Category Page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage1"/> - <waitForPageLoad stepKey="waitForPageToLoad1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage1"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree2"/> <waitForPageLoad stepKey="waitForPageToLoad2"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryAndCheckUrlRewritesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryAndCheckUrlRewritesTest.xml index 39040c7e88205..4dbbdc8f4399e 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryAndCheckUrlRewritesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryAndCheckUrlRewritesTest.xml @@ -32,8 +32,7 @@ </after> <!--Open category page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <waitForPageLoad stepKey="waitForCategoryToLoad"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(FirstLevelSubCat.name)}}" stepKey="selectCategory"/> @@ -74,8 +73,7 @@ <see stepKey="verifyTheTargetPath" selector="{{AdminUrlRewriteIndexSection.gridCellByColumnRowNumber('1', 'Target Path')}}" userInput="catalog/category/view/id/{$categoryId}"/> <!--Open Category Page --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage1"/> - <waitForPageLoad stepKey="waitForPageToLoad1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage1"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree2"/> <waitForPageLoad stepKey="waitForPageToLoad2"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryFromParentAnchoredCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryFromParentAnchoredCategoryTest.xml index 7fdc6e7b9cf8f..116df566f2bd0 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryFromParentAnchoredCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryFromParentAnchoredCategoryTest.xml @@ -32,8 +32,7 @@ </after> <!--Open Category page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <waitForPageLoad stepKey="waitForCategoryToLoad"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(_defaultCategory.name)}}" stepKey="selectCategory"/> @@ -81,8 +80,7 @@ <see selector="{{StorefrontProductInfoMainSection.productName}}" userInput="{{defaultSimpleProduct.name}}" stepKey="assertProductName"/> <!--Open Category Page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage1"/> - <waitForPageLoad stepKey="waitForPageToLoad1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage1"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree2"/> <waitForPageLoad stepKey="waitForPageToLoad2"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryToAnotherPositionInCategoryTreeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryToAnotherPositionInCategoryTreeTest.xml index 2909d17b1541b..fd9e50928d748 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryToAnotherPositionInCategoryTreeTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveCategoryToAnotherPositionInCategoryTreeTest.xml @@ -32,8 +32,7 @@ </after> <!-- Open Category Page --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickExpandTree"/> <waitForPageLoad stepKey="waitForCategoryToLoad"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(_defaultCategory.name)}}" stepKey="selectCategory"/> @@ -68,8 +67,7 @@ </assertEquals> <!-- Move Category to another position in category tree and click ok button--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openTheAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitTillPageLoad"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openTheAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <waitForPageLoad stepKey="waitForPageLoad"/> <dragAndDrop selector1="{{AdminCategorySidebarTreeSection.categoryInTree(SecondLevelSubCat.name)}}" selector2="{{AdminCategorySidebarTreeSection.categoryInTree('Default Category')}}" stepKey="DragCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminRequiredFieldsHaveRequiredFieldIndicatorTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminRequiredFieldsHaveRequiredFieldIndicatorTest.xml index 0281fded3a8e4..2444165fa1b39 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminRequiredFieldsHaveRequiredFieldIndicatorTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminRequiredFieldsHaveRequiredFieldIndicatorTest.xml @@ -22,7 +22,7 @@ </after> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin1"/> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPage"/> <waitForElementVisible selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="waitForAddSubCategoryVisible"/> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryAndCheckDefaultUrlKeyOnStoreViewTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryAndCheckDefaultUrlKeyOnStoreViewTest.xml index f3225bcd7fe3d..e0e517defdeac 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryAndCheckDefaultUrlKeyOnStoreViewTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryAndCheckDefaultUrlKeyOnStoreViewTest.xml @@ -50,8 +50,7 @@ </actionGroup> <!--Update Category--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleRootSubCategory.name)}}" stepKey="selectCategory"/> <waitForPageLoad stepKey="waitForPageToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryAndMakeInactiveTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryAndMakeInactiveTest.xml index 2865e9bc87dd3..a36f62bc4bedf 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryAndMakeInactiveTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryAndMakeInactiveTest.xml @@ -27,8 +27,7 @@ </after> <!--Open category page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <!--Update category and make category inactive--> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> @@ -47,8 +46,7 @@ <waitForPageLoad time="15" stepKey="wait"/> <!--Verify Inactive Category in category page --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage1"/> - <waitForPageLoad stepKey="waitForPageToLoaded1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage1"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree1"/> <seeElement selector="{{AdminCategoryContentSection.categoryInTree(_defaultCategory.name)}}" stepKey="assertCategoryInTree" /> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(_defaultCategory.name)}}" stepKey="selectCreatedCategory1"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryNameWithStoreViewTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryNameWithStoreViewTest.xml index 3c3baf3524e87..0ca8e74c4e59e 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryNameWithStoreViewTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryNameWithStoreViewTest.xml @@ -57,8 +57,7 @@ <seeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(SimpleRootSubCategory.name)}}" stepKey="seeCatergoryInStoreFront"/> <!--Open Category Page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <!--Update Category--> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="expandToSeeAllCategories"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryStoreUrlKeyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryStoreUrlKeyTest.xml index 8b57c2e371355..87d7f91431dc3 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryStoreUrlKeyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryStoreUrlKeyTest.xml @@ -27,8 +27,7 @@ <!-- Create category, change store view to default --> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage"/> - <waitForPageLoad stepKey="waitForPageLoad1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPage"/> <actionGroup ref="CreateCategoryActionGroup" stepKey="createCategory"> <argument name="categoryEntity" value="_defaultCategory"/> </actionGroup> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryUrlKeyWithStoreViewTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryUrlKeyWithStoreViewTest.xml index 117019da38ffa..6a12b991bd225 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryUrlKeyWithStoreViewTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryUrlKeyWithStoreViewTest.xml @@ -59,8 +59,7 @@ <waitForPageLoad stepKey="waitForProductToLoad"/> <!--Update URL Key--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded2"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleRootSubCategory.name)}}" stepKey="selectCategory1"/> <scrollTo selector="{{AdminCategorySEOSection.SectionHeader}}" stepKey="scrollToSearchEngineOptimization"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithInactiveIncludeInMenuTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithInactiveIncludeInMenuTest.xml index 9663632e6dc36..b313f14627fe5 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithInactiveIncludeInMenuTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithInactiveIncludeInMenuTest.xml @@ -28,8 +28,7 @@ </after> <!--Open Category Page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <!--Update Category name,description, urlKey, meta title and disable Include in Menu--> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> @@ -65,8 +64,7 @@ <seeElement selector="{{StorefrontCategoryMainSection.CategoryTitle(SimpleRootSubCategory.name)}}" stepKey="seeUpdatedCategoryInStoreFrontPage"/> <!--Verify Updated fields in Category Page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage1"/> - <waitForPageLoad stepKey="waitForPageToLoaded1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage1"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree1"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleRootSubCategory.name)}}" stepKey="selectCreatedCategory1"/> <waitForPageLoad stepKey="waitForCategoryPageToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithProductsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithProductsTest.xml index ccab2f9e96ce7..6412bf975003b 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithProductsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithProductsTest.xml @@ -29,8 +29,7 @@ </after> <!--Open Category Page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(_defaultCategory.name)}}" stepKey="selectCreatedCategory"/> <checkOption selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="enableCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryAndAddProductsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryAndAddProductsTest.xml index 512df79cb7c9c..1950b385c4a68 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryAndAddProductsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryAndAddProductsTest.xml @@ -58,8 +58,7 @@ </after> <!-- Select Created Category--> <magentoCLI command="indexer:reindex" stepKey="reindexBeforeFlow"/> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoad"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleSubCategory.name)}}" stepKey="selectCreatedCategory"/> <waitForPageLoad stepKey="waitForTheCategoryPageToLoaded"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryIncludeInNavigationTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryIncludeInNavigationTest.xml index f444e741fea0e..6ee1fd6a58e42 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryIncludeInNavigationTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryIncludeInNavigationTest.xml @@ -58,8 +58,7 @@ <waitForPageLoad time="60" stepKey="waitForPageToBeLoaded"/> <dontSee selector="{{StorefrontHeaderSection.NavigationCategoryByName(CatNotIncludeInMenu.name)}}" stepKey="dontSeeCategoryOnNavigation"/> <!-- Select created category and enable Include In Menu option--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoad"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(CatNotIncludeInMenu.name)}}" stepKey="selectCreatedCategory"/> <waitForPageLoad stepKey="waitForCategoryPageToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryNameAndDescriptionTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryNameAndDescriptionTest.xml index 2b9cbf379c5e6..dd79dd6824bbb 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryNameAndDescriptionTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryNameAndDescriptionTest.xml @@ -55,8 +55,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <!-- Select Created Category--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoad"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(_defaultCategory.name)}}" stepKey="selectCreatedCategory"/> <waitForPageLoad stepKey="waitForPageToLoaded"/> @@ -89,8 +88,7 @@ <waitForPageLoad stepKey="waitForSecondStoreView"/> <seeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(SimpleSubCategory.name)}}" stepKey="seeCategoryOnNavigation1"/> <!-- Verify Updated Category Name and description on Category Page--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage1"/> - <waitForPageLoad stepKey="waitForCategoryPageToLoad"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage1"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree1"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleSubCategory.name)}}" stepKey="selectUpdatedCategory"/> <waitForPageLoad stepKey="waitForUpdatedCategoryPageToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockUnassignFromCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockUnassignFromCategoryTest.xml index 45f8918100083..4256f93ea41d1 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockUnassignFromCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockUnassignFromCategoryTest.xml @@ -55,8 +55,7 @@ <see selector="{{AdminProductFormSection.successMessage}}" userInput="You saved the product." stepKey="seeAssertSimpleProductSaveSuccessMessage"/> <!--Search default simple product in the grid page --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="OpenCategoryCatalogPage"/> - <waitForPageLoad stepKey="waitForCategoryCatalogPage"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="OpenCategoryCatalogPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickExpandTree"/> <waitForPageLoad stepKey="waitForCategoryToLoad"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree($$initialCategoryEntity.name$$)}}" stepKey="selectCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithNoRedirectTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithNoRedirectTest.xml index db8b808e74f76..5221510fd4dce 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithNoRedirectTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithNoRedirectTest.xml @@ -40,8 +40,7 @@ </after> <!-- Open Category page --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <!-- Open 3rd Level category --> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithRedirectTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithRedirectTest.xml index c5757a6428e8d..505ca583da3f4 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithRedirectTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithRedirectTest.xml @@ -38,8 +38,7 @@ </after> <!-- Open Category page --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForPageToLoaded"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openAdminCategoryIndexPage"/> <!-- Open 3rd Level category --> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/DeleteCategoriesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/DeleteCategoriesTest.xml index b0a3d02f31846..ce9ff3af18607 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/DeleteCategoriesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/DeleteCategoriesTest.xml @@ -42,8 +42,7 @@ <deleteData createDataKey="createProduct3" stepKey="deleteProduct3"/> </after> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin1"/> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage1"/> - <waitForPageLoad time="30" stepKey="waitForPageCategoryLoadAfterNavigate"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPage1"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree($$createNewRootCategoryA.name$$)}}" stepKey="openNewRootCategory"/> <waitForPageLoad stepKey="waitForPageCategoryLoadAfterClickOnNewRootCategory"/> <seeElement selector="{{AdminCategoryMainActionsSection.DeleteButton}}" stepKey="assertDeleteButtonIsPresent"/> @@ -79,8 +78,7 @@ <!--<magentoCLI command="indexer:reindex" stepKey="magentoCli"/>--> <!-- Delete Default Root Category. --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPageAfterCLIReindexCommand"/> - <waitForPageLoad time="30" stepKey="waitForPageCategoryLoadAfterCLIReindexCommand"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPageAfterCLIReindexCommand"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree('Default Category')}}" stepKey="clickOnDefaultRootCategory"/> <waitForPageLoad stepKey="waitForPageDefaultCategoryEditLoad" /> <seeElement selector="{{AdminCategoryMainActionsSection.DeleteButton}}" stepKey="assertDeleteButtonIsPresent1"/> @@ -122,8 +120,7 @@ <!--</actionGroup>--> <!-- Delete Categories 1(with subcategory) and 3. --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPageAfterStoreFrontCategoryAssertions"/> - <waitForPageLoad time="30" stepKey="waitForCategoryPageLoadAfterStoreFrontCategoryAssertions"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPageAfterStoreFrontCategoryAssertions"/> <actionGroup ref="DeleteCategoryActionGroup" stepKey="deleteCategoryC"> <argument name="categoryEntity" value="$$createCategoryC$$"/> </actionGroup> @@ -151,8 +148,7 @@ <argument name="product" value="$$createProduct3$$"/> </actionGroup> <!-- Rename New Root Category to Default category --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPageAfterStoreFrontProductsAssertions"/> - <waitForPageLoad time="30" stepKey="waitForCategoryPageLoadAfterStoreFrontProductsAssertions"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPageAfterStoreFrontProductsAssertions"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree('$$createNewRootCategoryA.name$$')}}" stepKey="clickOnNewRootCategoryA"/> <waitForPageLoad stepKey="waitForPageNewRootCategoryALoad" /> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="Default Category" stepKey="enterCategoryNameAsDefaultCategory"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CAdminTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CAdminTest.xml index 151046f0474e0..5c3f79694e79a 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CAdminTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CAdminTest.xml @@ -202,8 +202,7 @@ <!--Admin creates category--> <comment userInput="Admin creates category." stepKey="adminCreatesCategoryComment" before="navigateToCategoryPage"/> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage"/> - <waitForPageLoad time="30" stepKey="waitForCategoryPageLoad"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPage"/> <!--Create category under Default Category--> <click selector="{{AdminCategorySidebarTreeSection.categoryTreeRoot}}" stepKey="clickDefaultCategory"/> <actionGroup ref="CheckCategoryNameIsRequiredFieldActionGroup" stepKey="checkCategoryNameIsRequired"/> @@ -218,8 +217,7 @@ <!--Admin moves category--> <comment userInput="Admin moves category." stepKey="adminMovesCategoryComment" before="onCategoryPageToMoveCategory"/> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="onCategoryPageToMoveCategory"/> - <waitForPageLoad time="30" stepKey="waitForPageLoadMoveCategory"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="onCategoryPageToMoveCategory"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="expandTree"/> <dragAndDrop selector1="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleSubCategory.name)}}" selector2="{{AdminCategorySidebarTreeSection.categoryTreeRoot}}" @@ -233,8 +231,7 @@ <!--Admin deletes category--> <comment userInput="Admin deletes category" stepKey="deleteCategoryComment"/> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="onCategoryPageToDeleteCategory"/> - <waitForPageLoad time="30" stepKey="waitForCategoryPageDelete"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="onCategoryPageToDeleteCategory"/> <actionGroup ref="DeleteCategoryActionGroup" stepKey="deleteCategory"> <argument name="categoryEntity" value="_defaultCategory"/> </actionGroup> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml index ea9a4cb08bb08..4a36ebe7a2a42 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml @@ -40,8 +40,7 @@ <amOnPage url="$$createCategory.name$$.html" stepKey="goToCategoryStorefront2"/> <waitForPageLoad stepKey="waitForCategoryStorefront"/> <dontSeeElement selector="{{StorefrontCategoryProductSection.ProductImageByName($$createSimpleProduct.name$$)}}" stepKey="dontSeeCreatedProduct"/> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="onCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForCategoryPageLoadAddProducts"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="onCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="expandAll"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree($$simpleSubCategory.name$$)}}" stepKey="clickOnCreatedSimpleSubCategoryBeforeDelete"/> <waitForPageLoad stepKey="AdminCategoryEditPageLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/VerifyChildCategoriesShouldNotIncludeInMenuTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/VerifyChildCategoriesShouldNotIncludeInMenuTest.xml index 66d811ced9ac6..54a9e5a244427 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/VerifyChildCategoriesShouldNotIncludeInMenuTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/VerifyChildCategoriesShouldNotIncludeInMenuTest.xml @@ -19,8 +19,8 @@ <group value="category"/> </annotations> <after> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage2"/> - <waitForPageLoad stepKey="waitForPageLoad3"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPage2"/> + <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleSubCategory.name)}}" stepKey="clickOnCreatedSimpleSubCategoryBeforeDelete"/> <actionGroup ref="DeleteCategoryActionGroup" stepKey="deleteCategory"> <argument name="categoryEntity" value="SimpleSubCategory"/> @@ -28,8 +28,7 @@ <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage1"/> - <waitForPageLoad stepKey="waitForPageLoad1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPage1"/> <scrollToTopOfPage stepKey="scrollToTopOfPage"/> <!--Create new category under Default Category--> <actionGroup ref="CreateCategoryActionGroup" stepKey="createSubcategory1"> @@ -44,8 +43,7 @@ <seeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(SimpleSubCategory.name)}}" stepKey="seeSimpleSubCategoryOnStorefront1"/> <dontSeeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(SubCategoryWithParent.name)}}" stepKey="dontSeeSubCategoryWithParentOnStorefront1"/> <!--Set Include in menu to No on created category under Default Category --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage2"/> - <waitForPageLoad stepKey="waitForPageLoad3"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPage2"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleSubCategory.name)}}" stepKey="clickOnCreatedSimpleSubCategory1"/> <click selector="{{AdminCategoryBasicFieldSection.includeInMenuLabel}}" stepKey="setNoToIncludeInMenuSelect"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="clickSaveButton1"/> @@ -56,8 +54,7 @@ <dontSeeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(SimpleSubCategory.name)}}" stepKey="dontSeeSimpleSubCategoryOnStorefront1"/> <dontSeeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(SubCategoryWithParent.name)}}" stepKey="dontSeeSubCategoryWithParentOnStorefront2"/> <!--Set Enable category to No and Include in menu to Yes on created category under Default Category --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage3"/> - <waitForPageLoad stepKey="waitForPageLoad5"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPage3"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleSubCategory.name)}}" stepKey="clickOnCreatedSimpleSubCategory2"/> <click selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}" stepKey="SetNoToEnableCategorySelect"/> <click selector="{{AdminCategoryBasicFieldSection.includeInMenuLabel}}" stepKey="SetYesToIncludeInMenuSelect"/> @@ -69,8 +66,7 @@ <dontSeeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(SimpleSubCategory.name)}}" stepKey="dontSeeSimpleSubCategoryOnStorefront2"/> <dontSeeElement selector="{{StorefrontHeaderSection.NavigationCategoryByName(SubCategoryWithParent.name)}}" stepKey="dontSeeSubCategoryWithParentOnStorefront3"/> <!--Set Enable category to No and Include in menu to No on created category under Default Category --> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage4"/> - <waitForPageLoad stepKey="waitForPageLoad7"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPage4"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleSubCategory.name)}}" stepKey="clickOnCreatedSimpleSubCategory3"/> <click selector="{{AdminCategoryBasicFieldSection.includeInMenuLabel}}" stepKey="setNoToIncludeInMenuSelect2"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="clickSaveButton3"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogTest.xml index b439223674b60..a15081e0cbda3 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/VerifyTinyMCEv4IsNativeWYSIWYGOnCatalogTest.xml @@ -23,8 +23,7 @@ <actionGroup ref="EnabledWYSIWYGActionGroup" stepKey="enableWYSIWYG"/> <actionGroup ref="SwitchToVersion4ActionGroup" stepKey="switchToTinyMCE4" /> </before> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToNewCatalog"/> - <waitForPageLoad stepKey="wait1"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToNewCatalog"/> <waitForLoadingMaskToDisappear stepKey="wait2" /> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategory"/> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{SimpleSubCategory.name}}" stepKey="enterCategoryName"/> diff --git a/app/code/Magento/CatalogWidget/Test/Mftf/Test/CatalogProductListWidgetOperatorsTest.xml b/app/code/Magento/CatalogWidget/Test/Mftf/Test/CatalogProductListWidgetOperatorsTest.xml index 288134a889db0..9b05d1ea8c1ea 100644 --- a/app/code/Magento/CatalogWidget/Test/Mftf/Test/CatalogProductListWidgetOperatorsTest.xml +++ b/app/code/Magento/CatalogWidget/Test/Mftf/Test/CatalogProductListWidgetOperatorsTest.xml @@ -53,8 +53,7 @@ </actionGroup> <!--Go to Catalog > Categories (choose category where created products)--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="onCategoryIndexPage"/> - <waitForPageLoad stepKey="waitForCategoryPageLoadAddProducts" after="onCategoryIndexPage"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="onCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickExpandAll" after="waitForCategoryPageLoadAddProducts"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleSubCategory.name)}}" stepKey="clickCategoryLink"/> <waitForPageLoad stepKey="waitForCategoryPageLoad"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml index a1d346ffa2744..97ef502bec679 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml @@ -40,8 +40,7 @@ <argument name="ProductAttribute" value="visualSwatchAttribute"/> </actionGroup> <!--delete root category--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage"/> - <waitForPageLoad time="30" stepKey="waitForPageCategoryLoad"/> + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="navigateToCategoryPage"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree('$$createRootCategory.name$$')}}" stepKey="clickOnDefaultRootCategory"/> <waitForPageLoad stepKey="waitForPageDefaultCategoryEditLoad" /> <seeElement selector="{{AdminCategoryMainActionsSection.DeleteButton}}" stepKey="assertDeleteButtonIsPresent1"/> From 0621f4f5179b5a42c81c8ba7eac779d1b1efb0f3 Mon Sep 17 00:00:00 2001 From: Serhii Balko <serhii.balko@transoftgroup.com> Date: Fri, 10 Apr 2020 12:27:51 +0300 Subject: [PATCH 125/177] MC-32414: API call bug on add to cart as guest --- .../Quote/Model/Quote/Item/Compare.php | 13 +- .../Unit/Model/Quote/Item/CompareTest.php | 197 ++++++++---------- 2 files changed, 94 insertions(+), 116 deletions(-) diff --git a/app/code/Magento/Quote/Model/Quote/Item/Compare.php b/app/code/Magento/Quote/Model/Quote/Item/Compare.php index 76ba324518dc1..abe8b0d966050 100644 --- a/app/code/Magento/Quote/Model/Quote/Item/Compare.php +++ b/app/code/Magento/Quote/Model/Quote/Item/Compare.php @@ -71,17 +71,14 @@ public function compare(Item $target, Item $compared) if ($target->getProductId() != $compared->getProductId()) { return false; } - $targetOptions = $this->getOptions($target); - $comparedOptions = $this->getOptions($compared); - if (array_diff_key($targetOptions, $comparedOptions) != array_diff_key($comparedOptions, $targetOptions) - ) { + $targetOptionByCode = $target->getOptionsByCode(); + $comparedOptionsByCode = $compared->getOptionsByCode(); + if (!$target->compareOptions($targetOptionByCode, $comparedOptionsByCode)) { return false; } - foreach ($targetOptions as $name => $value) { - if ($comparedOptions[$name] != $value) { - return false; - } + if (!$target->compareOptions($comparedOptionsByCode, $targetOptionByCode)) { + return false; } return true; } diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/CompareTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/CompareTest.php index c3e69237fc2bb..e5e267713f963 100644 --- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/CompareTest.php +++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/CompareTest.php @@ -3,57 +3,65 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - namespace Magento\Quote\Test\Unit\Model\Quote\Item; +use Magento\Framework\Serialize\JsonValidator; +use Magento\Framework\Serialize\Serializer\Json; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Quote\Model\Quote\Item; +use Magento\Quote\Model\Quote\Item\Compare; +use Magento\Quote\Model\Quote\Item\Option; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; + /** - * Class CompareTest + * Tests the class that is used to compare Quote Item Options */ -class CompareTest extends \PHPUnit\Framework\TestCase +class CompareTest extends TestCase { /** - * @var \Magento\Quote\Model\Quote\Item\Compare + * @var Compare */ private $helper; /** - * @var \Magento\Quote\Model\Quote\Item|\PHPUnit_Framework_MockObject_MockObject + * @var Item|MockObject */ private $itemMock; /** - * @var \Magento\Quote\Model\Quote\Item|\PHPUnit_Framework_MockObject_MockObject + * @var Item|MockObject */ private $comparedMock; /** - * @var \Magento\Quote\Model\Quote\Item\Option|\PHPUnit_Framework_MockObject_MockObject + * @var Option|MockObject */ private $optionMock; /** - * @var \Magento\Framework\Serialize\JsonValidator|\PHPUnit_Framework_MockObject_MockObject + * @var JsonValidator|MockObject */ private $jsonValidatorMock; /** - * test setUp + * @inheritdoc */ protected function setUp() { $this->itemMock = $this->createPartialMock( - \Magento\Quote\Model\Quote\Item::class, - ['__wakeup', 'getProductId', 'getOptions'] + Item::class, + ['__wakeup', 'getProductId', 'getOptions', 'getOptionsByCode'] ); $this->comparedMock = $this->createPartialMock( - \Magento\Quote\Model\Quote\Item::class, - ['__wakeup', 'getProductId', 'getOptions'] + Item::class, + ['__wakeup', 'getProductId', 'getOptions', 'getOptionsByCode'] ); $this->optionMock = $this->createPartialMock( - \Magento\Quote\Model\Quote\Item\Option::class, + Option::class, ['__wakeup', 'getCode', 'getValue'] ); - $serializer = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class) + $serializer = $this->getMockBuilder(Json::class) ->setMethods(['unserialize']) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -65,13 +73,13 @@ function ($value) { } ); - $this->jsonValidatorMock = $this->getMockBuilder(\Magento\Framework\Serialize\JsonValidator::class) + $this->jsonValidatorMock = $this->getMockBuilder(JsonValidator::class) ->disableOriginalConstructor() ->getMock(); - $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $objectManagerHelper = new ObjectManager($this); $this->helper = $objectManagerHelper->getObject( - \Magento\Quote\Model\Quote\Item\Compare::class, + Compare::class, [ 'serializer' => $serializer, 'jsonValidator' => $this->jsonValidatorMock @@ -82,17 +90,17 @@ function ($value) { /** * @param string $code * @param mixed $value - * @return \PHPUnit_Framework_MockObject_MockObject + * @return MockObject */ protected function getOptionMock($code, $value) { $optionMock = clone $this->optionMock; - $optionMock->expects($this->once()) + $optionMock->expects($this->any()) ->method('getCode') - ->will($this->returnValue($code)); - $optionMock->expects($this->once()) + ->willReturn($code); + $optionMock->expects($this->any()) ->method('getValue') - ->will($this->returnValue($value)); + ->willReturn($value); return $optionMock; } @@ -103,10 +111,10 @@ public function testCompareDifferentProduct() { $this->itemMock->expects($this->once()) ->method('getProductId') - ->will($this->returnValue(1)); + ->willReturn(1); $this->itemMock->expects($this->once()) ->method('getProductId') - ->will($this->returnValue(2)); + ->willReturn(2); $this->assertFalse($this->helper->compare($this->itemMock, $this->comparedMock)); } @@ -116,36 +124,47 @@ public function testCompareDifferentProduct() */ public function testCompareProductWithDifferentOptions() { + // Identical Product Ids $this->itemMock->expects($this->any()) ->method('getProductId') - ->will($this->returnValue(1)); + ->willReturn(1); $this->comparedMock->expects($this->any()) ->method('getProductId') - ->will($this->returnValue(1)); + ->willReturn(1); + // Identical Option Keys $this->itemMock->expects($this->any()) ->method('getOptions') - ->will( - $this->returnValue( - [ - $this->getOptionMock('option-1', 1), - $this->getOptionMock('option-2', 'option-value'), - $this->getOptionMock('option-3', json_encode(['value' => 'value-1', 'qty' => 2])) - ] - ) - ); + ->willReturn([$this->getOptionMock('identical', 'value')]); $this->comparedMock->expects($this->any()) ->method('getOptions') - ->will($this->returnValue( + ->willReturn([$this->getOptionMock('identical', 'value')]); + + // Different Option Values + $this->itemMock->expects($this->once()) + ->method('getOptionsByCode') + ->willReturn( [ - $this->getOptionMock('option-4', 1), - $this->getOptionMock('option-2', 'option-value'), - $this->getOptionMock('option-3', json_encode([ - 'value' => 'value-1', - 'qty' => 2, - ])), + 'info_buyRequest' => $this->getOptionMock('info_buyRequest', ['value-1']), + 'option' => $this->getOptionMock('option', 1), + 'simple_product' => $this->getOptionMock('simple_product', 3), + 'product_qty_2' => $this->getOptionMock('product_qty_2', 10), + 'attributes' => $this->getOptionMock('attributes', 93), ] - )); + ); + + $this->comparedMock->expects($this->once()) + ->method('getOptionsByCode') + ->willReturn( + [ + 'info_buyRequest' => $this->getOptionMock('info_buyRequest', ['value-2']), + 'option' => $this->getOptionMock('option', 1), + 'simple_product' => $this->getOptionMock('simple_product', 3), + 'product_qty_2' => $this->getOptionMock('product_qty_2', 10), + 'attributes' => $this->getOptionMock('attributes', 94), + ] + ); + $this->assertFalse($this->helper->compare($this->itemMock, $this->comparedMock)); } @@ -156,24 +175,24 @@ public function testCompareItemWithComparedWithoutOption() { $this->itemMock->expects($this->any()) ->method('getProductId') - ->will($this->returnValue(1)); + ->willReturn(1); $this->comparedMock->expects($this->any()) ->method('getProductId') - ->will($this->returnValue(1)); - $this->itemMock->expects($this->any()) - ->method('getOptions') - ->will( - $this->returnValue( - [ - $this->getOptionMock('option-1', 1), - $this->getOptionMock('option-2', 'option-value'), - $this->getOptionMock('option-3', json_encode(['value' => 'value-1', 'qty' => 2])), - ] - ) + ->willReturn(1); + $this->itemMock->expects($this->once()) + ->method('getOptionsByCode') + ->willReturn( + [ + 'info_buyRequest' => $this->getOptionMock('info_buyRequest', ['value-1']), + 'option' => $this->getOptionMock('option', 1), + 'simple_product' => $this->getOptionMock('simple_product', 3), + 'product_qty_2' => $this->getOptionMock('product_qty_2', 10), + 'attributes' => $this->getOptionMock('attributes', 93), + ] ); $this->comparedMock->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue([])); + ->method('getOptionsByCode') + ->willReturn([]); $this->assertFalse($this->helper->compare($this->itemMock, $this->comparedMock)); } @@ -184,62 +203,24 @@ public function testCompareItemWithoutOptionWithCompared() { $this->itemMock->expects($this->any()) ->method('getProductId') - ->will($this->returnValue(1)); + ->willReturn(1); $this->comparedMock->expects($this->any()) ->method('getProductId') - ->will($this->returnValue(1)); - $this->comparedMock->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue( - [ - $this->getOptionMock('option-1', 1), - $this->getOptionMock('option-2', 'option-value'), - $this->getOptionMock( - 'option-3', - json_encode(['value' => 'value-1', 'qty' => 2]) - ), - ] - )); - $this->itemMock->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue([])); - $this->assertFalse($this->helper->compare($this->itemMock, $this->comparedMock)); - } - - /** - * Verify that compare ignores empty options. - */ - public function testCompareWithEmptyValues() - { - $itemOptionValue = '{"non-empty-option":"test","empty_option":""}'; - $comparedOptionValue = '{"non-empty-option":"test"}'; - - $this->jsonValidatorMock->expects($this->any()) - ->method('isValid') - ->willReturn(true); - - $this->itemMock->expects($this->any()) - ->method('getProductId') - ->will($this->returnValue(1)); - $this->comparedMock->expects($this->any()) - ->method('getProductId') - ->will($this->returnValue(1)); - - $this->itemMock->expects($this->once()) - ->method('getOptions') - ->willReturn( - [ - $this->getOptionMock('option-1', $itemOptionValue) - ] - ); + ->willReturn(1); $this->comparedMock->expects($this->once()) - ->method('getOptions') + ->method('getOptionsByCode') ->willReturn( [ - $this->getOptionMock('option-1', $comparedOptionValue) + 'info_buyRequest' => $this->getOptionMock('info_buyRequest', ['value-2']), + 'option' => $this->getOptionMock('option', 1), + 'simple_product' => $this->getOptionMock('simple_product', 3), + 'product_qty_2' => $this->getOptionMock('product_qty_2', 10), + 'attributes' => $this->getOptionMock('attributes', 94), ] ); - - $this->assertTrue($this->helper->compare($this->itemMock, $this->comparedMock)); + $this->itemMock->expects($this->any()) + ->method('getOptionsByCode') + ->willReturn([]); + $this->assertFalse($this->helper->compare($this->itemMock, $this->comparedMock)); } } From c4e003e65c56457eac7f8af57d145b9d542abbe6 Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Fri, 10 Apr 2020 14:00:56 +0300 Subject: [PATCH 126/177] fix for failed checks --- .../Test/Mftf/Test/CatalogProductListWidgetOperatorsTest.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogWidget/Test/Mftf/Test/CatalogProductListWidgetOperatorsTest.xml b/app/code/Magento/CatalogWidget/Test/Mftf/Test/CatalogProductListWidgetOperatorsTest.xml index 9b05d1ea8c1ea..288134a889db0 100644 --- a/app/code/Magento/CatalogWidget/Test/Mftf/Test/CatalogProductListWidgetOperatorsTest.xml +++ b/app/code/Magento/CatalogWidget/Test/Mftf/Test/CatalogProductListWidgetOperatorsTest.xml @@ -53,7 +53,8 @@ </actionGroup> <!--Go to Catalog > Categories (choose category where created products)--> - <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="onCategoryIndexPage"/> + <amOnPage url="{{AdminCategoryPage.url}}" stepKey="onCategoryIndexPage"/> + <waitForPageLoad stepKey="waitForCategoryPageLoadAddProducts" after="onCategoryIndexPage"/> <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickExpandAll" after="waitForCategoryPageLoadAddProducts"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree(SimpleSubCategory.name)}}" stepKey="clickCategoryLink"/> <waitForPageLoad stepKey="waitForCategoryPageLoad"/> From e64ab03b6e49b8bbfed86e4e41272c454afe083e Mon Sep 17 00:00:00 2001 From: Ihor Sviziev <ihor-sviziev@users.noreply.github.com> Date: Fri, 10 Apr 2020 14:54:52 +0300 Subject: [PATCH 127/177] MFTF: Fix failing CMS tests due to PageBuilder conflict Fix minor issue in formatting --- .../Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml index 5eef25c789a7e..6d4a848f414fa 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- /** -* Copyright © Magento, Inc. All rights reserved. -* See COPYING.txt for license details. -*/ + * 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"> From 38e2c5ab3c064c1637a5e106fd3f4e9453018d1d Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Fri, 10 Apr 2020 16:59:06 +0300 Subject: [PATCH 128/177] add AssertAdminCategorySaveSuccessMessageActionGroup --- .../AdminSaveCategoryActionGroup.xml | 3 +-- ...nCategorySaveSuccessMessageActionGroup.xml | 19 +++++++++++++++++++ .../AdminCheckPaginationInStorefrontTest.xml | 2 +- ...AdminCreateCategoryWithAnchorFieldTest.xml | 2 +- ...AdminCreateCategoryWithFiveNestingTest.xml | 10 +++++----- ...CreateCategoryWithInactiveCategoryTest.xml | 2 +- ...eCategoryWithInactiveIncludeInMenuTest.xml | 2 +- ...minCreateCategoryWithNoAnchorFieldTest.xml | 2 +- ...eateCategoryWithProductsGridFilterTest.xml | 2 +- ...inCreateCategoryWithRequiredFieldsTest.xml | 2 +- ...inCreateRootCategoryRequiredFieldsTest.xml | 2 +- ...AdminUpdateCategoryAndMakeInactiveTest.xml | 2 +- ...eCategoryWithInactiveIncludeInMenuTest.xml | 2 +- .../AdminUpdateCategoryWithProductsTest.xml | 2 +- ...vailableAfterEnablingSubCategoriesTest.xml | 2 +- ...goryWithRestrictedUrlKeyNotCreatedTest.xml | 8 ++++---- .../CatalogProductListWidgetOperatorsTest.xml | 2 +- ...dCmsBlockEntityAndAssignToCategoryTest.xml | 1 + ...dCmsBlockEntityAndAssignToCategoryTest.xml | 1 + 19 files changed, 44 insertions(+), 24 deletions(-) create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminCategorySaveSuccessMessageActionGroup.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSaveCategoryActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSaveCategoryActionGroup.xml index 535a08382aabb..95f11901c97f0 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSaveCategoryActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSaveCategoryActionGroup.xml @@ -10,6 +10,5 @@ <actionGroup name="AdminSaveCategoryActionGroup"> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategoryWithProducts"/> <waitForPageLoad stepKey="waitForCategorySaved"/> - <see userInput="You saved the category." stepKey="seeSuccessMessage"/> </actionGroup> -</actionGroups> \ No newline at end of file +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminCategorySaveSuccessMessageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminCategorySaveSuccessMessageActionGroup.xml new file mode 100644 index 0000000000000..ddc2a5d44acbd --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminCategorySaveSuccessMessageActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AssertAdminCategorySaveSuccessMessageActionGroup"> + <annotations> + <description>Checks success message after category was saved.</description> + </annotations> + + <waitForElementVisible selector="{{AdminMessagesSection.success}}" time="30" stepKey="waitForElement"/> + <see selector="{{AdminMessagesSection.success}}" userInput="You saved the category." stepKey="seeSuccessMessage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckPaginationInStorefrontTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckPaginationInStorefrontTest.xml index 278a1fdc7ad9c..02610f539d3c0 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckPaginationInStorefrontTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckPaginationInStorefrontTest.xml @@ -123,7 +123,7 @@ <click selector="{{AdminCategoryProductsGridSection.productSelectAll}}" stepKey="selectSelectAll"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="clickSaveButton"/> <waitForPageLoad stepKey="waitForCategorySaved"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="assertSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage"/> <waitForPageLoad stepKey="waitForPageTitleToBeSaved"/> <!--Open Category Store Front Page--> <comment userInput="Open Category Store Front Page" stepKey="commentOpenCategoryOnStorefront"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithAnchorFieldTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithAnchorFieldTest.xml index 7deb79c66ff6d..59d634e492200 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithAnchorFieldTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithAnchorFieldTest.xml @@ -60,7 +60,7 @@ <click selector="{{AdminCategoryContentSection.productTableRow}}" stepKey="selectProductFromTableRow"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="clickSaveButton"/> <waitForPageLoad stepKey="waitForCategorySaved"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="assertSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage"/> <waitForPageLoad stepKey="waitForPageTitleToBeSaved"/> <!--Verify the Category Title--> <see selector="{{AdminCategoryContentSection.categoryPageTitle}}" userInput="{{_defaultCategory.name}}" stepKey="seePageTitle" /> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithFiveNestingTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithFiveNestingTest.xml index c1df630685949..dc15d28c9f447 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithFiveNestingTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithFiveNestingTest.xml @@ -45,35 +45,35 @@ <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveFirstSubCategory"/> <waitForPageLoad stepKey="waitForSFirstSubCategorySaved"/> <!-- Verify success message --> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="assertSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage"/> <!--Create Nested Second Sub Category--> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton1"/> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{SecondLevelSubCat.name}}" stepKey="fillSecondSubCategoryName"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveSecondSubCategory"/> <waitForPageLoad stepKey="waitForSecondCategory"/> <!-- Verify success message --> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="assertSuccessMessage1"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage1"/> <!--Create Nested Third Sub Category/>--> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton2"/> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{ThirdLevelSubCat.name}}" stepKey="fillThirdSubCategoryName"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveThirdSubCategory"/> <waitForPageLoad stepKey="waitForThirdCategorySaved"/> <!-- Verify success message --> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="assertSuccessMessage2"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage2"/> <!--Create Nested fourth Sub Category />--> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton3"/> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{FourthLevelSubCat.name}}" stepKey="fillFourthSubCategoryName"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveFourthSubCategory"/> <waitForPageLoad stepKey="waitForFourthCategorySaved"/> <!-- Verify success message --> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="assertSuccessMessage3"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage3"/> <!--Create Nested fifth Sub Category />--> <click selector="{{AdminCategorySidebarActionSection.AddSubcategoryButton}}" stepKey="clickOnAddSubCategoryButton4"/> <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{FifthLevelCat.name}}" stepKey="fillFifthSubCategoryName"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveFifthLevelCategory"/> <waitForPageLoad stepKey="waitForFifthCategorySaved"/> <!-- Verify success message --> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="assertSuccessMessage4"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage4"/> <amOnPage url="/{{FirstLevelSubCat.name}}/{{SecondLevelSubCat.name}}/{{ThirdLevelSubCat.name}}/{{FourthLevelSubCat.name}}/{{FifthLevelCat.name}}.html" stepKey="seeTheCategoryInStoreFrontPage"/> <waitForPageLoad time="60" stepKey="waitForStoreFrontPageLoad"/> <!--<Verify category displayed in store front page--> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveCategoryTest.xml index 34714db67fbd6..40b0bd74e59c3 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveCategoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveCategoryTest.xml @@ -33,7 +33,7 @@ <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{_defaultCategory.name}}" stepKey="fillCategoryName"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="clickSaveButton"/> <waitForPageLoad stepKey="waitForCategorySaved"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="assertSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage"/> <see selector="{{AdminCategoryContentSection.categoryPageTitle}}" userInput="{{_defaultCategory.name}}" stepKey="seePageTitle" /> <dontSeeCheckboxIsChecked selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="dontCategoryIsChecked"/> <!--Verify InActive Category is created--> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveIncludeInMenuTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveIncludeInMenuTest.xml index a11717c04ea8c..0745a831796af 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveIncludeInMenuTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithInactiveIncludeInMenuTest.xml @@ -33,7 +33,7 @@ <fillField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{_defaultCategory.name}}" stepKey="fillCategoryName"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="clickSaveButton"/> <waitForPageLoad stepKey="waitForCategorySaved"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="assertSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage"/> <waitForPageLoad stepKey="waitForPageSaved"/> <see selector="{{AdminCategoryContentSection.categoryPageTitle}}" userInput="{{_defaultCategory.name}}" stepKey="seePageTitle" /> <!--Verify Category is created/>--> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithNoAnchorFieldTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithNoAnchorFieldTest.xml index ec3c7a26723c2..2ef7f997661f3 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithNoAnchorFieldTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithNoAnchorFieldTest.xml @@ -62,7 +62,7 @@ </actionGroup> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="clickSaveButton"/> <waitForPageLoad stepKey="waitForCategorySaved"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="assertSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage"/> <waitForPageLoad stepKey="waitForPageTitleToBeSaved"/> <!-- Get Category ID --> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithProductsGridFilterTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithProductsGridFilterTest.xml index 99d0f88cf0e9a..5c9a28ef4ae05 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithProductsGridFilterTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithProductsGridFilterTest.xml @@ -75,7 +75,7 @@ <click selector="{{AdminCategoryContentSection.productTableRow}}" stepKey="selectDefaultProductFromTableRow"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="clickSaveButton"/> <waitForPageLoad stepKey="WaitForCategorySaved"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="successMessageYouSavedTheCategory"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="successMessageYouSavedTheCategory"/> <!--Verify product with grid filter is not not visible--> <amOnPage url="{{StorefrontProductPage.url(defaultSimpleProduct.urlKey)}}" stepKey="seeOnProductPage"/> <waitForPageLoad stepKey="waitForStoreFrontProductPageToLoad"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithRequiredFieldsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithRequiredFieldsTest.xml index 871dd606c14db..337fe43a39447 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithRequiredFieldsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateCategoryWithRequiredFieldsTest.xml @@ -33,7 +33,7 @@ <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="clickSaveButton"/> <waitForPageLoad stepKey="waitForCategorySaved"/> <!-- Verify success message --> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="assertSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage"/> <!-- Verify subcategory created with required fields --> <see selector="{{AdminCategoryContentSection.categoryPageTitle}}" userInput="{{_defaultCategory.name}}" stepKey="seePageTitle" /> <seeElement selector="{{AdminCategoryContentSection.activeCategoryInTree(_defaultCategory.name)}}" stepKey="seeCategoryInTree" /> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryRequiredFieldsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryRequiredFieldsTest.xml index a5556b076fef6..df85d76a2dd25 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryRequiredFieldsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateRootCategoryRequiredFieldsTest.xml @@ -35,7 +35,7 @@ <checkOption selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="EnableCheckOption"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="ClickSaveButton"/> <waitForPageLoad stepKey="WaitForCategorySaved"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="AssertSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="AssertSuccessMessage"/> <seeCheckboxIsChecked selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="SeeCheckBoxisSelected"/> <seeInField selector="{{AdminCategoryBasicFieldSection.CategoryNameInput}}" userInput="{{_defaultCategory.name}}" stepKey="SeedFieldInput"/> </test> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryAndMakeInactiveTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryAndMakeInactiveTest.xml index 2865e9bc87dd3..11541ac837764 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryAndMakeInactiveTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryAndMakeInactiveTest.xml @@ -36,7 +36,7 @@ <click selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}" stepKey="disableCategory"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="clickSaveButton"/> <waitForPageLoad stepKey="waitForCategorySaved"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="assertSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage"/> <see selector="{{AdminCategoryContentSection.categoryPageTitle}}" userInput="{{_defaultCategory.name}}" stepKey="seePageTitle" /> <dontSeeCheckboxIsChecked selector="{{AdminCategoryBasicFieldSection.EnableCategory}}" stepKey="dontCategoryIsChecked"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithInactiveIncludeInMenuTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithInactiveIncludeInMenuTest.xml index 9663632e6dc36..0a93556783e17 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithInactiveIncludeInMenuTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithInactiveIncludeInMenuTest.xml @@ -47,7 +47,7 @@ <fillField selector="{{AdminCategorySEOSection.MetaTitleInput}}" userInput="{{SimpleRootSubCategory.name}}" stepKey="fillUpdatedMetaTitle"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="clickSaveButton"/> <waitForPageLoad stepKey="waitForCategorySaved"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="assertSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage"/> <!--Open UrlRewrite Page--> <amOnPage url="{{AdminUrlRewriteIndexPage.url}}" stepKey="openUrlRewriteIndexPage"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithProductsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithProductsTest.xml index ccab2f9e96ce7..7f6ddfe3f6138 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithProductsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateCategoryWithProductsTest.xml @@ -58,7 +58,7 @@ <click selector="{{AdminCategoryContentSection.productTableRow}}" stepKey="selectProduct1FromTableRow"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="clickSaveButton"/> <waitForPageLoad stepKey="waitForCategorySaved"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the category." stepKey="assertSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage"/> <waitForPageLoad stepKey="waitForPageTitleToBeSaved"/> <!--Verify Category Title--> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml index ea9a4cb08bb08..0783efa0b713d 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml @@ -48,7 +48,7 @@ <click selector="{{AdminCategoryBasicFieldSection.enableCategoryLabel}}" stepKey="EnableCategory"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategoryWithProducts"/> <waitForPageLoad stepKey="waitForCategorySaved"/> - <see userInput="You saved the category." stepKey="seeSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="seeSuccessMessage"/> <!--Run re-index task--> <magentoCLI command="indexer:reindex" stepKey="reindex"/> diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminCategoryWithRestrictedUrlKeyNotCreatedTest.xml b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminCategoryWithRestrictedUrlKeyNotCreatedTest.xml index dec157484dfef..213099d3ba974 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminCategoryWithRestrictedUrlKeyNotCreatedTest.xml +++ b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminCategoryWithRestrictedUrlKeyNotCreatedTest.xml @@ -57,7 +57,7 @@ <argument name="categoryName" value="admin"/> <argument name="categoryUrlKey" value="{{SimpleSubCategory.name}}"/> </actionGroup> - <see selector="{{AdminMessagesSection.success}}" userInput="You saved the category." stepKey="seeAdminSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="seeAdminSuccessMessage"/> <seeElement selector="{{AdminCategorySidebarTreeSection.categoryByName('admin')}}" stepKey="seeAdminCategoryInTree"/> <!--Check category creation with restricted url key 'soap'--> <comment userInput="Check category creation with restricted url key 'soap'" stepKey="commentCheckSoapCategoryCreation"/> @@ -78,7 +78,7 @@ <argument name="categoryName" value="soap"/> <argument name="categoryUrlKey" value="{{ApiCategory.name}}"/> </actionGroup> - <see selector="{{AdminMessagesSection.success}}" userInput="You saved the category." stepKey="seeSoapSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="seeSoapSuccessMessage"/> <seeElement selector="{{AdminCategorySidebarTreeSection.categoryByName('soap')}}" stepKey="seeSoapCategoryInTree"/> <!--Check category creation with restricted url key 'rest'--> <comment userInput="Check category creation with restricted url key 'rest'" stepKey="commentCheckRestCategoryCreation"/> @@ -99,7 +99,7 @@ <argument name="categoryName" value="rest"/> <argument name="categoryUrlKey" value="{{SubCategoryWithParent.name}}"/> </actionGroup> - <see selector="{{AdminMessagesSection.success}}" userInput="You saved the category." stepKey="seeRestSuccessMesdgssage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="seeRestSuccessMesdgssage"/> <seeElement selector="{{AdminCategorySidebarTreeSection.categoryByName('rest')}}" stepKey="seeRestCategoryInTree"/> <!--Check category creation with restricted url key 'graphql'--> <comment userInput="Check category creation with restricted url key 'graphql'" stepKey="commentCheckGraphQlCategoryCreation"/> @@ -120,7 +120,7 @@ <argument name="categoryName" value="graphql"/> <argument name="categoryUrlKey" value="{{NewSubCategoryWithParent.name}}"/> </actionGroup> - <see selector="{{AdminMessagesSection.success}}" userInput="You saved the category." stepKey="seeGraphQlSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="seeGraphQlSuccessMessage"/> <seeElement selector="{{AdminCategorySidebarTreeSection.categoryByName('graphql')}}" stepKey="seeGraphQlCategoryInTree"/> </test> </tests> diff --git a/app/code/Magento/CatalogWidget/Test/Mftf/Test/CatalogProductListWidgetOperatorsTest.xml b/app/code/Magento/CatalogWidget/Test/Mftf/Test/CatalogProductListWidgetOperatorsTest.xml index 288134a889db0..59f0cd7437f44 100644 --- a/app/code/Magento/CatalogWidget/Test/Mftf/Test/CatalogProductListWidgetOperatorsTest.xml +++ b/app/code/Magento/CatalogWidget/Test/Mftf/Test/CatalogProductListWidgetOperatorsTest.xml @@ -73,7 +73,7 @@ <selectOption stepKey="selectStaticBlockOnlyOption" userInput="Static block only" selector="{{AdminCategoryDisplaySettingsSection.displayMode}}"/> <click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategoryWithProducts"/> <waitForPageLoad stepKey="waitForCategorySaved"/> - <see userInput="You saved the category." stepKey="seeSuccessMessage"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="seeSuccessMessage"/> <!--Go to Storefront > category--> <amOnPage url="$$simplecategory.name$$.html" stepKey="goToStorefrontCategoryPage"/> diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateDisabledCmsBlockEntityAndAssignToCategoryTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateDisabledCmsBlockEntityAndAssignToCategoryTest.xml index 51fbbf8020545..e56f2149d0232 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateDisabledCmsBlockEntityAndAssignToCategoryTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateDisabledCmsBlockEntityAndAssignToCategoryTest.xml @@ -46,6 +46,7 @@ <argument name="value" value="Static block only"/> </actionGroup> <actionGroup ref="AdminSaveCategoryActionGroup" stepKey="saveCategory"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage"/> <actionGroup ref="AssertStorefrontNoTextOnCategoryPageActionGroup" stepKey="assertBlockOnCategoryFrontPage"> <argument name="category" value="$$newDefaultCategory$$"/> diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateEnabledCmsBlockEntityAndAssignToCategoryTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateEnabledCmsBlockEntityAndAssignToCategoryTest.xml index 5ccd8fa713cc0..312ca950b2604 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateEnabledCmsBlockEntityAndAssignToCategoryTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateEnabledCmsBlockEntityAndAssignToCategoryTest.xml @@ -40,6 +40,7 @@ <argument name="value" value="Static block only"/> </actionGroup> <actionGroup ref="AdminSaveCategoryActionGroup" stepKey="saveCategory"/> + <actionGroup ref="AssertAdminCategorySaveSuccessMessageActionGroup" stepKey="assertSuccessMessage"/> <actionGroup ref="AssertStorefrontTextOnCategoryPageActionGroup" stepKey="assertBlockOnCategoryFrontPage"> <argument name="category" value="$$newDefaultCategory$$"/> From d18adc4aca8bdb91ab8f3f65bbb501377f355376 Mon Sep 17 00:00:00 2001 From: Michail Slabko <mslabko@magento.com> Date: Fri, 10 Apr 2020 12:15:45 -0500 Subject: [PATCH 129/177] MC-33086: [Improvement] Apply Event To Category observer - fix tests --- .../testsuite/Magento/Catalog/Block/Product/ListTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ListTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ListTest.php index 6c735e52f8c1a..25e26bc66ab51 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ListTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/ListTest.php @@ -92,8 +92,10 @@ public function testGetAdditionalHtml() public function testSetCollection() { - $this->_block->setCollection('test'); - $this->assertEquals('test', $this->_block->getLoadedProductCollection()); + $collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create(\Magento\Framework\Data\Collection::class); + $this->_block->setCollection($collection); + $this->assertEquals($collection, $this->_block->getLoadedProductCollection()); } public function testGetPriceBlockTemplate() From 9a7be2d539e04069b43f97d8df3eb32040b36532 Mon Sep 17 00:00:00 2001 From: Yurii Sapiha <yurasapiga93@gmail.com> Date: Thu, 9 Apr 2020 16:41:02 +0300 Subject: [PATCH 130/177] MC-32711: Admin: View customer product review --- .../Block/Adminhtml/Edit/Tab/ReviewsTest.php | 50 +++++++++++++++++++ .../Adminhtml/Customer/ProductReviewsTest.php | 50 +++++++++++++++++-- 2 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Review/Block/Adminhtml/Edit/Tab/ReviewsTest.php diff --git a/dev/tests/integration/testsuite/Magento/Review/Block/Adminhtml/Edit/Tab/ReviewsTest.php b/dev/tests/integration/testsuite/Magento/Review/Block/Adminhtml/Edit/Tab/ReviewsTest.php new file mode 100644 index 0000000000000..0b9fbe9428b5a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Review/Block/Adminhtml/Edit/Tab/ReviewsTest.php @@ -0,0 +1,50 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Review\Block\Adminhtml\Edit\Tab; + +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\LayoutInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Checks customer products reviews tab + * + * @see \Magento\Review\Block\Adminhtml\Edit\Tab\Reviews + * @magentoAppArea adminhtml + */ +class ReviewsTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Reviews */ + private $block; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Reviews::class); + } + + /** + * @magentoDataFixture Magento/Review/_files/customer_review.php + * + * @return void + */ + public function testReviewGrid(): void + { + $this->block->setCustomerId(1); + $this->assertCount(1, $this->block->getPreparedCollection()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Review/Controller/Adminhtml/Customer/ProductReviewsTest.php b/dev/tests/integration/testsuite/Magento/Review/Controller/Adminhtml/Customer/ProductReviewsTest.php index 4203fb9c16b29..961e029dfc38b 100644 --- a/dev/tests/integration/testsuite/Magento/Review/Controller/Adminhtml/Customer/ProductReviewsTest.php +++ b/dev/tests/integration/testsuite/Magento/Review/Controller/Adminhtml/Customer/ProductReviewsTest.php @@ -8,13 +8,30 @@ namespace Magento\Review\Controller\Adminhtml\Customer; use Magento\Framework\App\Request\Http; +use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\View\LayoutInterface; use Magento\TestFramework\TestCase\AbstractBackendController; /** * Test for customer product reviews page. + * + * @magentoAppArea adminhtml */ class ProductReviewsTest extends AbstractBackendController { + /** @var LayoutInterface */ + private $layout; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + + $this->layout = $this->_objectManager->get(LayoutInterface::class); + } + /** * Check Customer product review action. * @@ -23,9 +40,36 @@ class ProductReviewsTest extends AbstractBackendController */ public function testProductReviewsAction(): void { - $this->getRequest()->setPostValue(['id' => 1])->setMethod(Http::METHOD_POST); + $this->dispatchWithIdParam(1); + $this->assertContains('<div id="reviewGrid"', $this->getResponse()->getBody()); + } + + /** + * @return void + */ + public function testProductReviews(): void + { + $customerId = 1; + $this->dispatchWithIdParam($customerId); + $block = $this->layout->getBlock('admin.customer.reviews'); + $this->assertNotFalse($block); + $this->assertEquals( + $customerId, + $block->getCustomerId(), + 'Block customer id value does not match expected value' + ); + } + + /** + * Dispatch request with id parameter + * + * @param int $id + * @return void + */ + private function dispatchWithIdParam(int $id): void + { + $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setParams(['id' => $id]); $this->dispatch('backend/review/customer/productReviews'); - $body = $this->getResponse()->getBody(); - $this->assertContains('<div id="reviewGrid"', $body); } } From 8ac3a67b1c44802387264c8902b3987de0e82f1b Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Fri, 10 Apr 2020 22:30:20 +0300 Subject: [PATCH 131/177] Renamed ActionGroup --- .../Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml | 4 ++-- ...refrontAddBundleProductWithZeroPriceToShoppingCartTest.xml | 2 +- ...ontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml | 2 +- ...urchaseProductWithCustomOptionsWithLongValuesTitleTest.xml | 2 +- .../Test/AssociatedProductToConfigurableOutOfStockTest.xml | 2 +- .../Mftf/Test/StorefrontApplyPromoCodeDuringCheckoutTest.xml | 2 +- .../StorefrontGuestCheckoutTest.xml | 2 +- .../Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml | 2 +- .../Test/Mftf/Test/ProductsQtyReturnAfterOrderCancelTest.xml | 2 +- .../Fedex/Test/Mftf/Test/AdminCreatingShippingLabelTest.xml | 2 +- ...onGroup.xml => AdminOrderGridClickFirstRowActionGroup.xml} | 2 +- .../Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml | 2 +- .../Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml | 2 +- .../Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) rename app/code/Magento/Sales/Test/Mftf/ActionGroup/{AdminClickFirstRowOrderGridActionGroup.xml => AdminOrderGridClickFirstRowActionGroup.xml} (90%) diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml index 55b1648d1f23f..972947656cd3d 100644 --- a/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml +++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminDashboardWithChartsChart.xml @@ -84,7 +84,7 @@ <!-- Create invoice --> <comment userInput="Create invoice" stepKey="createInvoice"/> - <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/> <click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceButton"/> <waitForPageLoad stepKey="waitForInvoicePageToLoad"/> <see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Invoice" stepKey="seeNewInvoiceInPageTitle" after="clickInvoiceButton"/> @@ -95,7 +95,7 @@ <comment userInput="Create Shipment for the order" stepKey="createShipmentForOrder"/> <amOnPage url="{{AdminOrdersPage.url}}" stepKey="onOrdersPage2"/> <waitForPageLoad time="30" stepKey="waitForOrderListPageLoading"/> - <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="openOrderPageForShip"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="openOrderPageForShip"/> <click selector="{{AdminOrderDetailsMainActionsSection.ship}}" stepKey="clickShipAction"/> <waitForPageLoad stepKey="waitForShipmentPagePage"/> <seeInCurrentUrl url="{{AdminShipmentNewPage.url}}" stepKey="seeOrderShipmentUrl"/> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAddBundleProductWithZeroPriceToShoppingCartTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAddBundleProductWithZeroPriceToShoppingCartTest.xml index 5c75441f85b9c..b3c542af7bbc9 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAddBundleProductWithZeroPriceToShoppingCartTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAddBundleProductWithZeroPriceToShoppingCartTest.xml @@ -71,7 +71,7 @@ <argument name="orderId" value="$grabOrderNumber"/> </actionGroup> - <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/> <scrollTo selector="{{AdminOrderTotalSection.subTotal}}" stepKey="scrollToOrderTotalSection"/> <see selector="{{AdminOrderTotalSection.subTotal}}" userInput="$0.00" stepKey="checkSubtotal"/> </test> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml index cfa82ab18e9a4..767e0c88b7af2 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductCustomOptionsDifferentStoreViewsTest.xml @@ -200,7 +200,7 @@ <argument name="orderId" value="{$grabOrderNumber}"/> </actionGroup> - <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/> <!-- Checking the correctness of displayed custom options for user parameters on Order --> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsWithLongValuesTitleTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsWithLongValuesTitleTest.xml index f539940f1cdc1..fbecc15a59b1f 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsWithLongValuesTitleTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsWithLongValuesTitleTest.xml @@ -105,7 +105,7 @@ <click selector="{{AdminOrdersGridSection.submitSearch}}" stepKey="submitSearchOrderNum"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappearOnSearch"/> - <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/> <!-- Checking the correctness of displayed custom options for user parameters on Order --> diff --git a/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml b/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml index 84da79f64f700..95d3943d04b80 100644 --- a/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml +++ b/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml @@ -124,7 +124,7 @@ <click selector="{{AdminOrdersGridSection.submitSearch}}" stepKey="submitSearch"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask4"/> - <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/> <click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoice"/> <waitForPageLoad stepKey="waitForNewInvoicePageToLoad"/> <click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="clickSubmitInvoice"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontApplyPromoCodeDuringCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontApplyPromoCodeDuringCheckoutTest.xml index 5b48c014ef713..3648ac361ccc9 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontApplyPromoCodeDuringCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontApplyPromoCodeDuringCheckoutTest.xml @@ -84,7 +84,7 @@ <argument name="orderId" value="$grabOrderNumber"/> </actionGroup> - <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/> <scrollTo selector="{{AdminOrderTotalSection.grandTotal}}" stepKey="scrollToOrderTotalSection"/> <see selector="{{AdminOrderTotalSection.grandTotal}}" userInput="$$createProduct.price$$" stepKey="checkTotal"/> </test> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest/StorefrontGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest/StorefrontGuestCheckoutTest.xml index 9c2c18242c3b3..0d69306a4b1ba 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest/StorefrontGuestCheckoutTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest/StorefrontGuestCheckoutTest.xml @@ -64,7 +64,7 @@ <fillField selector="{{AdminOrdersGridSection.search}}" userInput="{$grabOrderNumber}" stepKey="fillOrderNum"/> <click selector="{{AdminOrdersGridSection.submitSearch}}" stepKey="submitSearchOrderNum"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappearOnSearch"/> - <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/> <see selector="{{AdminOrderDetailsInformationSection.orderStatus}}" userInput="Pending" stepKey="seeAdminOrderStatus"/> <see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="{{CustomerEntityOne.fullname}}" stepKey="seeAdminOrderGuest"/> <see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="{{CustomerEntityOne.email}}" stepKey="seeAdminOrderEmail"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml index 75e6f44c8f776..0dd4d0be6c808 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml @@ -94,7 +94,7 @@ <argument name="orderId" value="$grabOrderNumber"/> </actionGroup> - <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/> <!--Verify that Created order is in Processing status--> <see selector="{{AdminShipmentOrderInformationSection.orderStatus}}" userInput="Processing" stepKey="seeShipmentOrderStatus"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/ProductsQtyReturnAfterOrderCancelTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/ProductsQtyReturnAfterOrderCancelTest.xml index a01bcb786795a..a8856288b422a 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/ProductsQtyReturnAfterOrderCancelTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/ProductsQtyReturnAfterOrderCancelTest.xml @@ -70,7 +70,7 @@ <argument name="orderId" value="$grabOrderNumber"/> </actionGroup> - <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/> <click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceButton"/> <waitForPageLoad stepKey="waitForNewInvoicePageLoad"/> <fillField selector="{{AdminInvoiceItemsSection.qtyToInvoiceColumn}}" userInput="1" stepKey="ChangeQtyToInvoice"/> diff --git a/app/code/Magento/Fedex/Test/Mftf/Test/AdminCreatingShippingLabelTest.xml b/app/code/Magento/Fedex/Test/Mftf/Test/AdminCreatingShippingLabelTest.xml index bd84dce153001..1c61bd290f005 100644 --- a/app/code/Magento/Fedex/Test/Mftf/Test/AdminCreatingShippingLabelTest.xml +++ b/app/code/Magento/Fedex/Test/Mftf/Test/AdminCreatingShippingLabelTest.xml @@ -109,7 +109,7 @@ <actionGroup ref="SearchAdminDataGridByKeywordActionGroup" stepKey="searchOrder"> <argument name="keyword" value="$grabOrderNumber"/> </actionGroup> - <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/> <!--Create Invoice--> <actionGroup ref="AdminCreateInvoiceActionGroup" stepKey="createInvoice"/> <!--Create shipping label--> diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickFirstRowOrderGridActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderGridClickFirstRowActionGroup.xml similarity index 90% rename from app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickFirstRowOrderGridActionGroup.xml rename to app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderGridClickFirstRowActionGroup.xml index ffbbee5d0c276..92b67af7d7f5a 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickFirstRowOrderGridActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderGridClickFirstRowActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminClickFirstRowOrderGridActionGroup"> + <actionGroup name="AdminOrderGridClickFirstRowActionGroup"> <annotations> <description>Click on first row of Order Grid.</description> </annotations> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml index 3b4e3b79c1142..b8612f7f795fb 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml @@ -81,7 +81,7 @@ <actionGroup ref="FilterOrderGridByIdActionGroup" stepKey="filterOrderGridById"> <argument name="orderId" value="$grabOrderNumber"/> </actionGroup> - <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/> <actionGroup ref="GoToInvoiceIntoOrderActionGroup" stepKey="goToInvoiceIntoOrderPage"/> <fillField selector="{{AdminInvoiceItemsSection.qtyToInvoiceColumn}}" userInput="5" stepKey="ChangeQtyToInvoice"/> <click selector="{{AdminInvoiceItemsSection.updateQty}}" stepKey="updateQuantity"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml index 386f736525ebb..1796a46a2af26 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml @@ -68,7 +68,7 @@ <click selector="{{AdminOrdersGridSection.submitSearch}}" stepKey="submitSearch"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask4"/> - <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/> <click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoice"/> <waitForPageLoad stepKey="waitForNewInvoicePageToLoad"/> <click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="clickSubmitInvoice"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml index 1f35a42b5a657..ca35d7f8c8a90 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml @@ -103,7 +103,7 @@ <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask4"/> <!-- Create invoice --> - <actionGroup ref="AdminClickFirstRowOrderGridActionGroup" stepKey="clickOrderRow"/> + <actionGroup ref="AdminOrderGridClickFirstRowActionGroup" stepKey="clickOrderRow"/> <click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceButton"/> <waitForPageLoad stepKey="waitForNewInvoicePageToLoad"/> <see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Invoice" stepKey="seeNewInvoiceInPageTitle" after="clickInvoiceButton"/> From f34f8c3e3a775a0f67ab4eb5b1edea5dc83ee5c7 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Fri, 10 Apr 2020 23:01:51 +0200 Subject: [PATCH 132/177] #27638 Fix fatal errors in Unit Tests --- .../Catalog/Test/Unit/Model/Product/CopierTest.php | 10 +++++----- .../Unit/Model/Product/Website/ReadHandlerTest.php | 6 +++--- .../Unit/Model/Product/Website/SaveHandlerTest.php | 2 +- .../Catalog/Test/Unit/Model/ProductRepositoryTest.php | 2 +- .../Test/Unit/Model/LinkManagementTest.php | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php index 91441890e83b1..c58a652fb5c1e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php @@ -6,7 +6,7 @@ namespace Magento\Catalog\Test\Unit\Model\Product; -use Magento\Catalog\Api\Data\ProductExtension; +use Magento\Catalog\Api\Data\ProductExtensionInterface; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\Attribute\ScopeOverriddenValue; use Magento\Catalog\Model\Product; @@ -106,9 +106,9 @@ protected function setUp() public function testCopy(): void { $stockItem = $this->createMock(StockItemInterface::class); - $extensionAttributes = $this->getMockBuilder(ProductExtension::class) + $extensionAttributes = $this->getMockBuilder(ProductExtensionInterface::class) ->setMethods(['getStockItem', 'setData']) - ->getMock(); + ->getMockForAbstractClass(); $extensionAttributes ->expects($this->once()) ->method('getStockItem') @@ -262,9 +262,9 @@ public function testUrlAlreadyExistsExceptionWhileCopyStoresUrl(): void { $stockItem = $this->getMockBuilder(StockItemInterface::class) ->getMock(); - $extensionAttributes = $this->getMockBuilder(ProductExtension::class) + $extensionAttributes = $this->getMockBuilder(ProductExtensionInterface::class) ->setMethods(['getStockItem', 'setData']) - ->getMock(); + ->getMockForAbstractClass(); $extensionAttributes ->expects($this->once()) ->method('getStockItem') diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/ReadHandlerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/ReadHandlerTest.php index 2e93aa79aefd2..e796c6829688b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/ReadHandlerTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/ReadHandlerTest.php @@ -6,7 +6,7 @@ namespace Magento\Catalog\Test\Unit\Model\Product\Website; -use Magento\Catalog\Api\Data\ProductExtension; +use Magento\Catalog\Api\Data\ProductExtensionInterface; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Website\ReadHandler; use Magento\Catalog\Model\ResourceModel\Product as ResourceModel; @@ -27,10 +27,10 @@ public function setUp() $this->websiteLink = $this->getMockBuilder(ResourceModel\Website\Link::class) ->disableOriginalConstructor() ->getMock(); - $this->extensionAttributes = $this->getMockBuilder(ProductExtension::class) + $this->extensionAttributes = $this->getMockBuilder(ProductExtensionInterface::class) ->setMethods(['setWebsiteIds', 'getWebsiteIds']) ->disableArgumentCloning() - ->getMock(); + ->getMockForAbstractClass(); $this->readHandler = new ReadHandler($this->websiteLink); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/SaveHandlerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/SaveHandlerTest.php index b2c9a182648ca..f5be99939cd62 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/SaveHandlerTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/SaveHandlerTest.php @@ -6,7 +6,7 @@ namespace Magento\Catalog\Test\Unit\Model\Product\Website; -use Magento\Catalog\Api\Data\ProductExtension; +use Magento\Catalog\Api\Data\ProductExtensionInterface; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\ResourceModel\Product\Website\Link; use Magento\Catalog\Model\Product\Website\SaveHandler; diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php index 0dc294e139d3e..8a05d84ef1f3c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php @@ -175,7 +175,7 @@ class ProductRepositoryTest extends TestCase /** * @var ProductExtensionInterface|MockObject */ - private $productExtension; + private $ProductExtensionInterface; /** * @var Json|MockObject diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php index c385934352ab8..b212fed7ca898 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php @@ -149,7 +149,7 @@ public function testAddChild() ->disableOriginalConstructor() ->setMethods(['getId', 'getData']) ->getMock(); - $extensionAttributesMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductExtension::class) + $extensionAttributesMock = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductExtensionInterface::class) ->disableOriginalConstructor() ->setMethods( [ @@ -158,7 +158,7 @@ public function testAddChild() 'setConfigurableProductLinks' ] ) - ->getMock(); + ->getMockForAbstractClass(); $optionMock = $this->getMockBuilder(\Magento\ConfigurableProduct\Api\Data\Option::class) ->disableOriginalConstructor() ->setMethods(['getProductAttribute', 'getPosition', 'getAttributeId']) From f616fd85974a003d1aa8bda9ef3009ab3ec6030b Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Sat, 11 Apr 2020 00:52:21 +0200 Subject: [PATCH 133/177] #27638 Fix static checks --- .../Model/Product/Website/ReadHandlerTest.php | 29 ++++++++++--------- .../Model/Product/Website/SaveHandlerTest.php | 7 +++-- .../Test/Unit/Model/ProductRepositoryTest.php | 7 ++--- .../Test/Unit/Model/LinkManagementTest.php | 13 +++++---- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/ReadHandlerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/ReadHandlerTest.php index e796c6829688b..b2ee8180cd8b5 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/ReadHandlerTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/ReadHandlerTest.php @@ -10,28 +10,29 @@ use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Website\ReadHandler; use Magento\Catalog\Model\ResourceModel\Product as ResourceModel; +use PHPUnit\Framework\MockObject\MockObject; class ReadHandlerTest extends \PHPUnit\Framework\TestCase { - /** @var ResourceModel\Website\Link | \PHPUnit_Framework_MockObject_MockObject */ - private $websiteLink; + /** @var ResourceModel\Website\Link|MockObject */ + private $websiteLinkMock; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - private $extensionAttributes; + /** @var MockObject */ + private $extensionAttributesMock; /** @var ReadHandler */ private $readHandler; public function setUp() { - $this->websiteLink = $this->getMockBuilder(ResourceModel\Website\Link::class) + $this->websiteLinkMock = $this->getMockBuilder(ResourceModel\Website\Link::class) ->disableOriginalConstructor() ->getMock(); - $this->extensionAttributes = $this->getMockBuilder(ProductExtensionInterface::class) + $this->extensionAttributesMock = $this->getMockBuilder(ProductExtensionInterface::class) ->setMethods(['setWebsiteIds', 'getWebsiteIds']) ->disableArgumentCloning() ->getMockForAbstractClass(); - $this->readHandler = new ReadHandler($this->websiteLink); + $this->readHandler = new ReadHandler($this->websiteLinkMock); } public function testExecuteWithNonCachedExtensionAttributes() @@ -44,20 +45,20 @@ public function testExecuteWithNonCachedExtensionAttributes() ->method('getId') ->willReturn($productId); $websiteIds = [1,2]; - $this->websiteLink->expects($this->once()) + $this->websiteLinkMock->expects($this->once()) ->method("getWebsiteIdsByProductId") ->with($productId) ->willReturn($websiteIds); $product->expects($this->exactly(2)) ->method('getExtensionAttributes') - ->willReturn($this->extensionAttributes); - $this->extensionAttributes->expects($this->once()) + ->willReturn($this->extensionAttributesMock); + $this->extensionAttributesMock->expects($this->once()) ->method("getWebsiteIds") ->willReturn(null); $product->expects($this->once()) ->method('setExtensionAttributes') - ->with($this->extensionAttributes); + ->with($this->extensionAttributesMock); $this->assertEquals($this->readHandler->execute($product, []), $product); } @@ -68,15 +69,15 @@ public function testExecuteWithCachedWebsiteIds() ->disableOriginalConstructor() ->getMock(); $websiteIds = [1,2]; - $this->extensionAttributes->expects($this->once()) + $this->extensionAttributesMock->expects($this->once()) ->method("getWebsiteIds") ->willReturn($websiteIds); $product->expects($this->never()) ->method('setExtensionAttributes') - ->with($this->extensionAttributes); + ->with($this->extensionAttributesMock); $product->expects($this->once()) ->method('getExtensionAttributes') - ->willReturn($this->extensionAttributes); + ->willReturn($this->extensionAttributesMock); $this->assertEquals($this->readHandler->execute($product, []), $product); } } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/SaveHandlerTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/SaveHandlerTest.php index f5be99939cd62..392f01a62b3ee 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/SaveHandlerTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Website/SaveHandlerTest.php @@ -15,19 +15,20 @@ use Magento\Framework\Api\ExtensionAttributesInterface; use Magento\Store\Api\Data\StoreInterface; use Magento\Store\Model\StoreManagerInterface; +use PHPUnit\Framework\MockObject\MockObject; class SaveHandlerTest extends \PHPUnit\Framework\TestCase { - /** @var ResourceModel\Website\Link | \PHPUnit_Framework_MockObject_MockObject */ + /** @var ResourceModel\Website\Link|MockObject */ private $productWebsiteLink; - /** @var StoreManagerInterface | \PHPUnit_Framework_MockObject_MockObject */ + /** @var StoreManagerInterface|MockObject */ private $storeManager; /** @var SaveHandler */ private $saveHandler; - /** @var ProductInterface | \PHPUnit_Framework_MockObject_MockObject */ + /** @var ProductInterface|MockObject */ private $product; public function setUp() diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php index 8a05d84ef1f3c..594d897938ae8 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php @@ -42,12 +42,11 @@ use Magento\Store\Api\Data\StoreInterface; use Magento\Store\Model\Store; use Magento\Store\Model\StoreManagerInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; + /** - * Class ProductRepositoryTest - * @package Magento\Catalog\Test\Unit\Model * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) @@ -175,7 +174,7 @@ class ProductRepositoryTest extends TestCase /** * @var ProductExtensionInterface|MockObject */ - private $ProductExtensionInterface; + private $productExtension; /** * @var Json|MockObject diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php index b212fed7ca898..5a238ceca20a5 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php +++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Model/LinkManagementTest.php @@ -8,6 +8,7 @@ use Magento\ConfigurableProduct\Model\LinkManagement; use Magento\ConfigurableProduct\Model\Product\Type\Configurable; +use PHPUnit\Framework\MockObject\MockObject; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -15,12 +16,12 @@ class LinkManagementTest extends \PHPUnit\Framework\TestCase { /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $productRepository; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $productFactory; @@ -30,7 +31,7 @@ class LinkManagementTest extends \PHPUnit\Framework\TestCase protected $objectManagerHelper; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $configurableType; @@ -40,7 +41,7 @@ class LinkManagementTest extends \PHPUnit\Framework\TestCase protected $object; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Api\DataObjectHelper + * @var MockObject|\Magento\Framework\Api\DataObjectHelper */ protected $dataObjectHelperMock; @@ -159,10 +160,10 @@ public function testAddChild() ] ) ->getMockForAbstractClass(); - $optionMock = $this->getMockBuilder(\Magento\ConfigurableProduct\Api\Data\Option::class) + $optionMock = $this->getMockBuilder(\Magento\ConfigurableProduct\Api\Data\OptionInterface::class) ->disableOriginalConstructor() ->setMethods(['getProductAttribute', 'getPosition', 'getAttributeId']) - ->getMock(); + ->getMockForAbstractClass(); $productAttributeMock = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class) ->disableOriginalConstructor() ->setMethods(['getAttributeCode']) From df6d0c5233b02fcb0a39cd3d82413ae9b1e717d4 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Fri, 10 Apr 2020 19:12:08 -0500 Subject: [PATCH 134/177] MQE-2069: [MTF-to-MFTF] Create Newsletter Template Entity #761 --- .../AdminIntegrationOpenExistingEntityActionGroup.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationOpenExistingEntityActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationOpenExistingEntityActionGroup.xml index 8d9af21c63ef6..5631da6213bfe 100644 --- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationOpenExistingEntityActionGroup.xml +++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminIntegrationOpenExistingEntityActionGroup.xml @@ -8,7 +8,6 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminIntegrationOpenExistingEntityActionGroup"> <click stepKey="clickEditIcon" selector="{{AdminIntegrationsGridSection.edit}}"/> </actionGroup> From 6fe59941502035b484c34eadad6938c63c036bc6 Mon Sep 17 00:00:00 2001 From: Ji Lu <jilu1@adobe.com> Date: Fri, 10 Apr 2020 21:11:38 -0500 Subject: [PATCH 135/177] MQE-2046: remove deprecated entities usages in MFTF tests --- ...torefrontSortBundleProductsByPriceTest.xml | 12 +- ...AssertProductOnCategoryPageActionGroup.xml | 20 -- ...leteProductAttributeByLabelActionGroup.xml | 29 -- ...ProductAbsentOnCategoryPageActionGroup.xml | 25 -- ...roductWithTierPriceForGeneralGroupTest.xml | 4 +- ...eInStockVisibleInCategoryAndSearchTest.xml | 4 +- ...rontRecentlyComparedAtWebsiteLevelTest.xml | 6 +- .../CatalogPriceRuleActionGroup.xml | 2 +- ...eRuleByUIWithConditionIsSKUActionGroup.xml | 2 +- ...eProductWithAssignedSimpleProductsTest.xml | 271 ------------------ ...eForConfigurableProductWithOptionsTest.xml | 224 --------------- ...refrontSelectOptionDropDownActionGroup.xml | 22 -- ...CartAndMiniShoppingCartPerCustomerTest.xml | 6 +- ...pesOfCustomOptionToTheShoppingCartTest.xml | 5 +- ...hangedWhenSavingProductWithSameSkuTest.xml | 4 +- ...onfigurableProductBasedOnParentSkuTest.xml | 4 +- ...ctWithCreatingCategoryAndAttributeTest.xml | 4 +- ...ctWithTwoOptionsAssignedToCategoryTest.xml | 4 +- ...woOptionsWithoutAssignedToCategoryTest.xml | 4 +- ...efrontVisibilityOfDuplicateProductTest.xml | 8 +- ...ductQuickSearchUsingElasticSearch6Test.xml | 16 +- ...oreFrontMyAccountWithMultishipmentTest.xml | 117 -------- .../AdminReportsOrderedGroupedBySkuTest.xml | 4 +- ...tImageColorWhenFilterByColorFilterTest.xml | 4 +- ...SwatchAttributesDisplayInWidgetCMSTest.xml | 4 +- ...rlKeyForStoreViewAndMovingCategoryTest.xml | 87 ------ 26 files changed, 50 insertions(+), 842 deletions(-) delete mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductOnCategoryPageActionGroup.xml delete mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/DeleteProductAttributeByLabelActionGroup.xml delete mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductAbsentOnCategoryPageActionGroup.xml delete mode 100644 app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithAssignedSimpleProductsTest.xml delete mode 100644 app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithOptionsTest.xml delete mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontSelectOptionDropDownActionGroup.xml delete mode 100644 app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml delete mode 100644 app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest.xml diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontSortBundleProductsByPriceTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontSortBundleProductsByPriceTest.xml index 26321f269e6d2..1c7cb39d7746f 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontSortBundleProductsByPriceTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontSortBundleProductsByPriceTest.xml @@ -120,8 +120,8 @@ </actionGroup> <!-- Assert first bundle products in category product grid --> - <actionGroup ref="AssertProductOnCategoryPageActionGroup" stepKey="assertFirstBundleProduct"> - <argument name="product" value="$$createFirstBundleProduct$$"/> + <actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="assertFirstBundleProduct"> + <argument name="productName" value="$$createFirstBundleProduct.name$$"/> </actionGroup> <actionGroup ref="AssertStorefrontElementVisibleActionGroup" stepKey="seePriceRangeFromForFirstBundleProduct"> <argument name="selector" value="{{StorefrontCategoryProductSection.priceFromByProductId($$createFirstBundleProduct.id$$)}}"/> @@ -133,8 +133,8 @@ </actionGroup> <!-- Assert second bundle products in category product grid --> - <actionGroup ref="AssertProductOnCategoryPageActionGroup" stepKey="assertSecondBundleProduct"> - <argument name="product" value="$$createSecondBundleProduct$$"/> + <actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="assertSecondBundleProduct"> + <argument name="productName" value="$$createSecondBundleProduct.name$$"/> </actionGroup> <actionGroup ref="AssertStorefrontElementVisibleActionGroup" stepKey="seePriceRangeFromForSecondBundleProduct"> <argument name="selector" value="{{StorefrontCategoryProductSection.priceFromByProductId($$createSecondBundleProduct.id$$)}}"/> @@ -146,8 +146,8 @@ </actionGroup> <!-- Assert third bundle products in category product grid --> - <actionGroup ref="AssertProductOnCategoryPageActionGroup" stepKey="assertThirdBundleProduct"> - <argument name="product" value="$$createThirdBundleProduct$$"/> + <actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="assertThirdBundleProduct"> + <argument name="productName" value="$$createThirdBundleProduct.name$$"/> </actionGroup> <actionGroup ref="AssertStorefrontElementVisibleActionGroup" stepKey="seePriceRangeFromForThirdBundleProduct"> <argument name="selector" value="{{StorefrontCategoryProductSection.priceFromByProductId($$createThirdBundleProduct.id$$)}}"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductOnCategoryPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductOnCategoryPageActionGroup.xml deleted file mode 100644 index 4225ed3a7fcc8..0000000000000 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertProductOnCategoryPageActionGroup.xml +++ /dev/null @@ -1,20 +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="AssertProductOnCategoryPageActionGroup" extends="StorefrontCheckCategorySimpleProductActionGroup" deprecated="some"> - <annotations> - <description>DEPRECATED. Use AssertStorefrontProductIsPresentOnCategoryPageActionGroup. - EXTENDS:StorefrontCheckCategorySimpleProduct. Removes 'AssertProductPrice', 'moveMouseOverProduct', 'AssertAddToCart'</description> - </annotations> - <remove keyForRemoval="AssertProductPrice"/> - <remove keyForRemoval="moveMouseOverProduct"/> - <remove keyForRemoval="AssertAddToCart"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/DeleteProductAttributeByLabelActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/DeleteProductAttributeByLabelActionGroup.xml deleted file mode 100644 index 15c3d55fb9382..0000000000000 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/DeleteProductAttributeByLabelActionGroup.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="DeleteProductAttributeByLabelActionGroup"> - <annotations> - <description>DEPRECATED. Please use AdminDeleteProductAttributeByLabelActionGroup instead. Goes to the Admin Product Attributes grid page. Filters the grid for the provided Product Attribute (Label). Deletes the Product Attribute from the grid. Validates that the Success Message is present.</description> - </annotations> - <arguments> - <argument name="ProductAttribute"/> - </arguments> - - <amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="navigateToProductAttributeGrid"/> - <fillField selector="{{AdminProductAttributeGridSection.FilterByAttributeCode}}" userInput="{{ProductAttribute.default_label}}" stepKey="setAttributeCode"/> - <click selector="{{AdminProductAttributeGridSection.Search}}" stepKey="searchForAttributeFromTheGrid"/> - <click selector="{{AdminProductAttributeGridSection.FirstRow}}" stepKey="clickOnAttributeRow"/> - <waitForPageLoad stepKey="waitForPageLoad"/> - <click selector="{{AttributePropertiesSection.DeleteAttribute}}" stepKey="deleteAttribute"/> - <click selector="{{ModalConfirmationSection.OkButton}}" stepKey="ClickOnDeleteButton"/> - <waitForPageLoad stepKey="waitForPageLoad1"/> - <seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="waitForSuccessMessage"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductAbsentOnCategoryPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductAbsentOnCategoryPageActionGroup.xml deleted file mode 100644 index 0effec5329cc0..0000000000000 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontAssertProductAbsentOnCategoryPageActionGroup.xml +++ /dev/null @@ -1,25 +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="StorefrontAssertProductAbsentOnCategoryPageActionGroup"> - <annotations> - <description>DEPRECATED. Please use AssertStorefrontProductAbsentOnCategoryPageActionGroup instead. - Navigate to category page and verify product is absent.</description> - </annotations> - <arguments> - <argument name="category" defaultValue="_defaultCategory"/> - <argument name="product" defaultValue="SimpleProduct"/> - </arguments> - <amOnPage url="{{StorefrontCategoryPage.url(category.name)}}" stepKey="navigateToCategoryPage"/> - <waitForPageLoad stepKey="waitForCategoryPageLoad"/> - <dontSee selector="{{StorefrontCategoryMainSection.productName}}" userInput="{{product.name}}" stepKey="assertProductIsNotPresent"/> - <dontSee selector="{{StorefrontCategoryMainSection.productPrice}}" userInput="{{product.price}}" stepKey="assertProductIsNotPricePresent"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceForGeneralGroupTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceForGeneralGroupTest.xml index 9305e9ed3fd49..5076ab2515332 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceForGeneralGroupTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateVirtualProductWithTierPriceForGeneralGroupTest.xml @@ -96,8 +96,8 @@ <actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="openCategoryPageOnFrontend"> <argument name="category" value="$categoryEntity$"/> </actionGroup> - <actionGroup ref="AssertProductOnCategoryPageActionGroup" stepKey="checkProductOnCategoryPage"> - <argument name="product" value="virtualProductGeneralGroup"/> + <actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="checkProductOnCategoryPage"> + <argument name="productName" value="{{virtualProductGeneralGroup.name}}"/> </actionGroup> <!--Verify customer see updated virtual product with tier price on product storefront page --> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryAndSearchTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryAndSearchTest.xml index e0c5d83b4b014..ab5d23f0f875e 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryAndSearchTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateVirtualProductWithTierPriceInStockVisibleInCategoryAndSearchTest.xml @@ -108,8 +108,8 @@ <actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="openCategoryPageOnFrontend"> <argument name="category" value="$categoryEntity$"/> </actionGroup> - <actionGroup ref="AssertProductOnCategoryPageActionGroup" stepKey="checkProductOnCategoryPage"> - <argument name="product" value="updateVirtualProductTierPriceInStock"/> + <actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="checkProductOnCategoryPage"> + <argument name="productName" value="{{updateVirtualProductTierPriceInStock.name}}"/> </actionGroup> <!--Verify customer see updated virtual product with tier price on product storefront page --> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyComparedAtWebsiteLevelTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyComparedAtWebsiteLevelTest.xml index f675e66f42aea..51150a4ecffb3 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyComparedAtWebsiteLevelTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyComparedAtWebsiteLevelTest.xml @@ -35,7 +35,7 @@ </createData> <createData entity="Simple_US_Customer" stepKey="createCustomer"/> <!-- Login as admin --> - <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> <!-- Create product widget --> <actionGroup ref="AdminCreateRecentlyProductsWidgetActionGroup" stepKey="createRecentlyComparedProductsWidget"> <argument name="widget" value="RecentlyComparedProductsWidget"/> @@ -51,7 +51,7 @@ <argument name="widget" value="RecentlyComparedProductsWidget"/> </actionGroup> <!-- Logout Admin --> - <actionGroup ref="logout" stepKey="logout"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> <!-- Reset Stores > Configurations > Catalog > Recently Viewed/Compared Products > Show for Current = Website--> <magentoCLI command="config:set {{RecentlyViewedProductScopeWebsite.path}} {{RecentlyViewedProductScopeWebsite.value}}" stepKey="RecentlyViewedProductScopeWebsite"/> <!-- Delete Products and Category --> @@ -66,7 +66,7 @@ <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginCustomer"> <argument name="Customer" value="$$createCustomer$$"/> </actionGroup> - <see userInput="Welcome, $$createCustomer.firstname$$ $$createCustomer.lastname$$!" selector="{{StorefrontPanelHeaderSection.WelcomeMessage}}" stepKey="checkWelcomeMessage"/> + <see userInput="Welcome, $$createCustomer.firstname$$ $$createCustomer.lastname$$!" selector="{{StorefrontPanelHeaderSection.welcomeMessage}}" stepKey="checkWelcomeMessage"/> <amOnPage url="{{StorefrontCategoryPage.url($$createCategory.custom_attributes[url_key]$$)}}" stepKey="openCategoryPageAfterAddedProductToCart"/> <!--Add to compare Simple Product and Simple Product 2--> <actionGroup ref="StorefrontAddCategoryProductToCompareActionGroup" stepKey="addSimpleProduct1ToCompare" > diff --git a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml index d20798aef4838..85961a28fac53 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml @@ -11,7 +11,7 @@ <!-- action group to create a new catalog price rule giving a catalogRule entity --> <actionGroup name="NewCatalogPriceRuleByUIActionGroup"> <annotations> - <description>DEPRECATED. Please use set of AG: AdminOpenNewCatalogPriceRuleFormPageActionGroup, AdminCatalogPriceRuleFillMainInfoActionGroup, AdminCatalogPriceRuleFillActionsActionGroup, AdminCatalogPriceRuleSaveAndApplyActionGroup + <description>Consider using set of AG: AdminOpenNewCatalogPriceRuleFormPageActionGroup, AdminCatalogPriceRuleFillMainInfoActionGroup, AdminCatalogPriceRuleFillActionsActionGroup, AdminCatalogPriceRuleSaveAndApplyActionGroup Goes to the Catalog Price Rule grid. Clicks on Add. Fills in the provided Catalog Rule details.</description> </annotations> <arguments> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/NewCatalogPriceRuleByUIWithConditionIsSKUActionGroup.xml b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/NewCatalogPriceRuleByUIWithConditionIsSKUActionGroup.xml index 217a7519defa7..bd8d1d21bf694 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/NewCatalogPriceRuleByUIWithConditionIsSKUActionGroup.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/NewCatalogPriceRuleByUIWithConditionIsSKUActionGroup.xml @@ -10,7 +10,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> <actionGroup name="NewCatalogPriceRuleByUIWithConditionIsSKUActionGroup" extends="NewCatalogPriceRuleByUIActionGroup"> <annotations> - <description>DEPRECATED. Please use set of AG: AdminOpenNewCatalogPriceRuleFormPageActionGroup, AdminCatalogPriceRuleFillMainInfoActionGroup, AdminCatalogPriceRuleFillActionsActionGroup, AdminCatalogPriceRuleAddSkuConditionActionGroup, AdminCatalogPriceRuleSaveAndApplyActionGroup + <description>Consider using set of AG: AdminOpenNewCatalogPriceRuleFormPageActionGroup, AdminCatalogPriceRuleFillMainInfoActionGroup, AdminCatalogPriceRuleFillActionsActionGroup, AdminCatalogPriceRuleAddSkuConditionActionGroup, AdminCatalogPriceRuleSaveAndApplyActionGroup EXTENDS: newCatalogPriceRuleByUI. Add a Catalog Price Rule Condition based on the provided SKU.</description> </annotations> <arguments> diff --git a/app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithAssignedSimpleProductsTest.xml b/app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithAssignedSimpleProductsTest.xml deleted file mode 100644 index 4cc9449557520..0000000000000 --- a/app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithAssignedSimpleProductsTest.xml +++ /dev/null @@ -1,271 +0,0 @@ -<?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="AdminApplyCatalogRuleForConfigurableProductWithAssignedSimpleProductsTest" deprecated="some"> - <annotations> - <features value="CatalogRuleConfigurable"/> - <stories value="Apply catalog price rule"/> - <title value="DEPRECATED. Apply catalog rule for configurable product with assigned simple products"/> - <description value="DEPRECATED. Admin should be able to apply catalog rule for configurable product with assigned simple products"/> - <severity value="CRITICAL"/> - <testCaseId value="MC-14063"/> - <group value="catalogRuleConfigurable"/> - <group value="mtf_migrated"/> - <skip> - <issueId value="DEPRECATED">Use AdminApplyCatalogRuleForConfigurableProductWithAssignedSimpleProducts2Test instead</issueId> - </skip> - </annotations> - <before> - <!-- Create category for first configurable product --> - <createData entity="SimpleSubCategory" stepKey="firstSimpleCategory"/> - - <!-- Create first configurable product with two options --> - <createData entity="ApiConfigurableProduct" stepKey="createFirstConfigProduct"> - <requiredEntity createDataKey="firstSimpleCategory"/> - </createData> - - <createData entity="productAttributeWithTwoOptions" stepKey="createFirstConfigProductAttribute"/> - <createData entity="productAttributeOption1" stepKey="createFirstConfigProductAttributeFirstOption"> - <requiredEntity createDataKey="createFirstConfigProductAttribute"/> - </createData> - <createData entity="productAttributeOption2" stepKey="createFirstConfigProductAttributeSecondOption"> - <requiredEntity createDataKey="createFirstConfigProductAttribute"/> - </createData> - - <createData entity="AddToDefaultSet" stepKey="addFirstProductToAttributeSet"> - <requiredEntity createDataKey="createFirstConfigProductAttribute"/> - </createData> - - <getData entity="ProductAttributeOptionGetter" index="1" stepKey="getFirstConfigAttributeFirstOption"> - <requiredEntity createDataKey="createFirstConfigProductAttribute"/> - </getData> - <getData entity="ProductAttributeOptionGetter" index="2" stepKey="getFirstConfigAttributeSecondOption"> - <requiredEntity createDataKey="createFirstConfigProductAttribute"/> - </getData> - - <!-- Create two child products for first configurable product --> - <createData entity="ApiSimpleOne" stepKey="createFirstConfigFirstChildProduct"> - <requiredEntity createDataKey="createFirstConfigProductAttribute"/> - <requiredEntity createDataKey="getFirstConfigAttributeFirstOption"/> - </createData> - - <createData entity="ApiSimpleOne" stepKey="createFirstConfigSecondChildProduct"> - <requiredEntity createDataKey="createFirstConfigProductAttribute"/> - <requiredEntity createDataKey="getFirstConfigAttributeSecondOption"/> - </createData> - - <createData entity="ConfigurableProductTwoOptions" stepKey="createFirstConfigProductOption"> - <requiredEntity createDataKey="createFirstConfigProduct"/> - <requiredEntity createDataKey="createFirstConfigProductAttribute"/> - <requiredEntity createDataKey="getFirstConfigAttributeFirstOption"/> - <requiredEntity createDataKey="getFirstConfigAttributeSecondOption"/> - </createData> - - <createData entity="ConfigurableProductAddChild" stepKey="createFirstConfigProductAddFirstChild"> - <requiredEntity createDataKey="createFirstConfigProduct"/> - <requiredEntity createDataKey="createFirstConfigFirstChildProduct"/> - </createData> - <createData entity="ConfigurableProductAddChild" stepKey="createFirstConfigProductAddSecondChild"> - <requiredEntity createDataKey="createFirstConfigProduct"/> - <requiredEntity createDataKey="createFirstConfigSecondChildProduct"/> - </createData> - - <!-- Add customizable options to first product --> - <updateData createDataKey="createFirstConfigProduct" entity="productWithOptionRadiobutton" stepKey="updateFirstProductWithOption"/> - - <!-- Create category for second configurable product --> - <createData entity="SimpleSubCategory" stepKey="secondSimpleCategory"/> - - <!-- Create second configurable product with two options --> - <createData entity="ApiConfigurableProduct" stepKey="createSecondConfigProduct"> - <requiredEntity createDataKey="secondSimpleCategory"/> - </createData> - - <createData entity="productAttributeWithTwoOptions" stepKey="createSecondConfigProductAttribute"/> - <createData entity="productAttributeOption1" stepKey="createSecondConfigProductAttributeFirstOption"> - <requiredEntity createDataKey="createSecondConfigProductAttribute"/> - </createData> - <createData entity="productAttributeOption2" stepKey="createSecondConfigProductAttributeSecondOption"> - <requiredEntity createDataKey="createSecondConfigProductAttribute"/> - </createData> - - <createData entity="AddToDefaultSet" stepKey="addSecondProductToAttributeSet"> - <requiredEntity createDataKey="createSecondConfigProductAttribute"/> - </createData> - - <getData entity="ProductAttributeOptionGetter" index="1" stepKey="getSecondConfigAttributeFirstOption"> - <requiredEntity createDataKey="createSecondConfigProductAttribute"/> - </getData> - <getData entity="ProductAttributeOptionGetter" index="2" stepKey="getSecondConfigAttributeSecondOption"> - <requiredEntity createDataKey="createSecondConfigProductAttribute"/> - </getData> - - <!-- Create two child products for second configurable product --> - <createData entity="ApiSimpleOne" stepKey="createSecondConfigFirstChildProduct"> - <requiredEntity createDataKey="createSecondConfigProductAttribute"/> - <requiredEntity createDataKey="getSecondConfigAttributeFirstOption"/> - </createData> - - <createData entity="ApiSimpleOne" stepKey="createSecondConfigSecondChildProduct"> - <requiredEntity createDataKey="createSecondConfigProductAttribute"/> - <requiredEntity createDataKey="getSecondConfigAttributeSecondOption"/> - </createData> - - <createData entity="ConfigurableProductTwoOptions" stepKey="createSecondConfigProductOption"> - <requiredEntity createDataKey="createSecondConfigProduct"/> - <requiredEntity createDataKey="createSecondConfigProductAttribute"/> - <requiredEntity createDataKey="getSecondConfigAttributeFirstOption"/> - <requiredEntity createDataKey="getSecondConfigAttributeSecondOption"/> - </createData> - - <createData entity="ConfigurableProductAddChild" stepKey="createSecondConfigProductAddFirstChild"> - <requiredEntity createDataKey="createSecondConfigProduct"/> - <requiredEntity createDataKey="createSecondConfigFirstChildProduct"/> - </createData> - <createData entity="ConfigurableProductAddChild" stepKey="createSecondConfigProductAddSecondChild"> - <requiredEntity createDataKey="createSecondConfigProduct"/> - <requiredEntity createDataKey="createSecondConfigSecondChildProduct"/> - </createData> - - <!-- Add customizable options to second product --> - <updateData createDataKey="createSecondConfigProduct" entity="productWithOptionRadiobutton" stepKey="updateSecondProductWithOption"/> - - <!--Create customer group --> - <createData entity="CustomCustomerGroup" stepKey="customerGroup"/> - - <!-- Create Customer --> - <createData entity="SimpleUsCustomerWithNewCustomerGroup" stepKey="createCustomer"> - <requiredEntity createDataKey="customerGroup" /> - </createData> - - <!-- Login as Admin --> - <actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminPanel"/> - </before> - <after> - <!-- Customer log out --> - <actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="customerLogout"/> - - <!-- Delete created data --> - <deleteData createDataKey="createFirstConfigProduct" stepKey="deleteFirstConfigProduct"/> - <deleteData createDataKey="createFirstConfigFirstChildProduct" stepKey="deleteFirstConfigFirstChildProduct"/> - <deleteData createDataKey="createFirstConfigSecondChildProduct" stepKey="deleteFirstConfigSecondChildProduct"/> - <deleteData createDataKey="createFirstConfigProductAttribute" stepKey="deleteFirstConfigProductAttribute"/> - <deleteData createDataKey="firstSimpleCategory" stepKey="deleteFirstSimpleCategory"/> - - <deleteData createDataKey="createSecondConfigProduct" stepKey="deleteSecondConfigProduct"/> - <deleteData createDataKey="createSecondConfigFirstChildProduct" stepKey="deleteSecondConfigFirstChildProduct"/> - <deleteData createDataKey="createSecondConfigSecondChildProduct" stepKey="deleteSecondConfigSecondChildProduct"/> - <deleteData createDataKey="createSecondConfigProductAttribute" stepKey="deleteSecondConfigProductAttribute"/> - <deleteData createDataKey="secondSimpleCategory" stepKey="deleteSimpleCategory"/> - - <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> - <deleteData createDataKey="customerGroup" stepKey="deleteCustomerGroup"/> - - <!-- Delete created price rules --> - <amOnPage url="{{CatalogRulePage.url}}" stepKey="goToPriceRulePage"/> - <actionGroup ref="deleteEntitySecondaryGrid" stepKey="deletePriceRuleForFirstOption"> - <argument name="name" value="{{CatalogRuleToFixed.name}}"/> - <argument name="searchInput" value="{{AdminSecondaryGridSection.catalogRuleIdentifierSearch}}"/> - </actionGroup> - - <!-- Admin log out --> - <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> - - <!-- Reindex invalidated indices after product attribute has been created/deleted --> - <magentoCron groups="index" stepKey="reindexInvalidatedIndices"/> - </after> - <!-- Create price rule --> - <actionGroup ref="NewCatalogPriceRuleByUIActionGroup" stepKey="createPriceRule"> - <argument name="catalogRule" value="CatalogRuleToFixed"/> - </actionGroup> - <actionGroup ref="CatalogSelectCustomerGroupActionGroup" stepKey="addCustomerGroup"> - <argument name="customerGroupName" value="$$customerGroup.code$$"/> - </actionGroup> - - <!-- Save price rule --> - <click selector="{{AdminNewCatalogPriceRule.saveAndApply}}" stepKey="clickSaveAndApplyRule"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the rule." stepKey="assertSuccessMessage"/> - - <!-- Run full reindex and clear caches --> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> - - <!-- Login to storefront from customer --> - <actionGroup ref="LoginToStorefrontActionGroup" stepKey="logInFromCustomer"> - <argument name="Customer" value="$$createCustomer$$"/> - </actionGroup> - - <!-- Assert first product in category --> - <amOnPage url="$$firstSimpleCategory.name$$.html" stepKey="goToFirstCategoryPageStorefront"/> - <waitForPageLoad stepKey="waitForFirstCategoryPageLoad"/> - <actionGroup ref="StorefrontCheckCategoryConfigurableProductWithUpdatedPriceActionGroup" stepKey="checkFirstProductPriceInCategory"> - <argument name="productName" value="$$createFirstConfigProduct.name$$"/> - <argument name="expectedPrice" value="{{CatalogRuleToFixed.discount_amount}}"/> - </actionGroup> - - <!-- Assert second product in category --> - <amOnPage url="$$secondSimpleCategory.name$$.html" stepKey="goToSecondCategoryPageStorefront"/> - <waitForPageLoad stepKey="waitForSecondCategoryPageLoad"/> - <actionGroup ref="StorefrontCheckCategoryConfigurableProductWithUpdatedPriceActionGroup" stepKey="checkSecondProductPriceInCategory"> - <argument name="productName" value="$$createSecondConfigProduct.name$$"/> - <argument name="expectedPrice" value="{{CatalogRuleToFixed.discount_amount}}"/> - </actionGroup> - - <!-- Assert first product in storefront product page --> - <amOnPage url="$$createFirstConfigProduct.custom_attributes[url_key]$$.html" stepKey="amOnFirstProductPage"/> - <waitForPageLoad stepKey="waitForFirstProductPageLoad"/> - <actionGroup ref="StorefrontAssertUpdatedProductPriceInStorefrontProductPageActionGroup" stepKey="checkFirstProductPriceInStorefrontProductPage"> - <argument name="productName" value="$$createFirstConfigProduct.name$$"/> - <argument name="expectedPrice" value="{{CatalogRuleToFixed.discount_amount}}"/> - </actionGroup> - - <!-- Add first product with selected options to the cart --> - <actionGroup ref="StorefrontAddProductWithSelectedConfigurableAndCustomOptionsToCartActionGroup" stepKey="addFirstProductWithSelectedOptionToCart1"> - <argument name="product" value="$$createFirstConfigProduct$$"/> - <argument name="option" value="$$createFirstConfigProductAttributeFirstOption.option[store_labels][1][label]$$"/> - <argument name="customizableOption" value="{{ProductOptionValueRadioButtons1.title}}"/> - </actionGroup> - <grabTextFrom selector="{{StorefrontProductInfoMainSection.updatedPrice}}" stepKey="grabForthProductUpdatedPrice1"/> - - <actionGroup ref="StorefrontAddProductWithSelectedConfigurableAndCustomOptionsToCartActionGroup" stepKey="addFirstProductWithSelectedOptionToCart2"> - <argument name="product" value="$$createFirstConfigProduct$$"/> - <argument name="option" value="$$createFirstConfigProductAttributeSecondOption.option[store_labels][1][label]$$"/> - <argument name="customizableOption" value="{{ProductOptionValueRadioButtons3.title}}"/> - </actionGroup> - - <!-- Assert second product in storefront product page --> - <amOnPage url="$$createSecondConfigProduct.custom_attributes[url_key]$$.html" stepKey="amOnSecondProductPage"/> - <waitForPageLoad stepKey="waitForSecondProductPageLoad"/> - <actionGroup ref="StorefrontAssertUpdatedProductPriceInStorefrontProductPageActionGroup" stepKey="checkSecondProductPriceInStorefrontProductPage"> - <argument name="productName" value="$$createSecondConfigProduct.name$$"/> - <argument name="expectedPrice" value="{{CatalogRuleToFixed.discount_amount}}"/> - </actionGroup> - - <!-- Add second product with selected options to the cart --> - <actionGroup ref="StorefrontAddProductWithSelectedConfigurableAndCustomOptionsToCartActionGroup" stepKey="addSecondProductWithSelectedOptionToCart1"> - <argument name="product" value="$$createSecondConfigProduct$$"/> - <argument name="option" value="$$createSecondConfigProductAttributeFirstOption.option[store_labels][1][label]$$"/> - <argument name="customizableOption" value="{{ProductOptionValueRadioButtons1.title}}"/> - </actionGroup> - - <actionGroup ref="StorefrontAddProductWithSelectedConfigurableAndCustomOptionsToCartActionGroup" stepKey="addSecondProductWithSelectedOptionToCart2"> - <argument name="product" value="$$createSecondConfigProduct$$"/> - <argument name="option" value="$$createSecondConfigProductAttributeSecondOption.option[store_labels][1][label]$$"/> - <argument name="customizableOption" value="{{ProductOptionValueRadioButtons3.title}}"/> - </actionGroup> - - <!--Assert products prices in the cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnShoppingCartPage"/> - <waitForPageLoad stepKey="waitForShoppingCartPageLoad"/> - <see userInput="$210.69" selector="{{CheckoutCartProductSection.ProductPriceByOption($$createFirstConfigProductAttributeFirstOption.option[store_labels][1][label]$$)}}" stepKey="assertFirstProductPriceForFirstProductOption"/> - <see userInput="$120.70" selector="{{CheckoutCartProductSection.ProductPriceByOption($$createFirstConfigProductAttributeSecondOption.option[store_labels][1][label]$$)}}" stepKey="assertFirstProductPriceForSecondProductOption"/> - <see userInput="$210.69" selector="{{CheckoutCartProductSection.ProductPriceByOption($$createSecondConfigProductAttributeFirstOption.option[store_labels][1][label]$$)}}" stepKey="assertSecondProductPriceForFirstProductOption"/> - <see userInput="$120.70" selector="{{CheckoutCartProductSection.ProductPriceByOption($$createSecondConfigProductAttributeSecondOption.option[store_labels][1][label]$$)}}" stepKey="assertSecondProductPriceForSecondProductOption"/> - </test> -</tests> diff --git a/app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithOptionsTest.xml b/app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithOptionsTest.xml deleted file mode 100644 index 436fc7714ce2d..0000000000000 --- a/app/code/Magento/CatalogRuleConfigurable/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithOptionsTest.xml +++ /dev/null @@ -1,224 +0,0 @@ -<?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="AdminApplyCatalogRuleForConfigurableProductWithOptionsTest" deprecated="some"> - <annotations> - <features value="CatalogRuleConfigurable"/> - <stories value="Apply catalog price rule"/> - <title value="DEPRECATED. Apply catalog price rule for configurable product with options"/> - <description value="DEPRECATED. Admin should be able to apply the catalog rule for configurable product with options"/> - <severity value="CRITICAL"/> - <testCaseId value="MC-14062"/> - <group value="catalogRuleConfigurable"/> - <group value="mtf_migrated"/> - <skip> - <issueId value="DEPRECATED">Use AdminApplyCatalogRuleForConfigurableProductWithOptions2Test instead</issueId> - </skip> - </annotations> - <before> - <!-- Create category --> - <createData entity="SimpleSubCategory" stepKey="simpleCategory"/> - - <!-- Create configurable product with three options --> - <createData entity="ApiConfigurableProduct" stepKey="createConfigProduct"> - <requiredEntity createDataKey="simpleCategory"/> - </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="productAttributeOption3" stepKey="createConfigProductAttributeThirdOption"> - <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> - <getData entity="ProductAttributeOptionGetter" index="3" stepKey="getConfigAttributeThirdOption"> - <requiredEntity createDataKey="createConfigProductAttribute"/> - </getData> - - <!-- Create three child products --> - <createData entity="ApiSimpleOne" stepKey="createConfigFirstChildProduct"> - <requiredEntity createDataKey="createConfigProductAttribute"/> - <requiredEntity createDataKey="getConfigAttributeFirstOption"/> - </createData> - - <createData entity="ApiSimpleOne" stepKey="createConfigSecondChildProduct"> - <requiredEntity createDataKey="createConfigProductAttribute"/> - <requiredEntity createDataKey="getConfigAttributeSecondOption"/> - </createData> - - <createData entity="ApiSimpleOne" stepKey="createConfigThirdChildProduct"> - <requiredEntity createDataKey="createConfigProductAttribute"/> - <requiredEntity createDataKey="getConfigAttributeThirdOption"/> - </createData> - - <createData entity="ConfigurableProductTwoOptions" stepKey="createConfigProductOption"> - <requiredEntity createDataKey="createConfigProduct"/> - <requiredEntity createDataKey="createConfigProductAttribute"/> - <requiredEntity createDataKey="getConfigAttributeFirstOption"/> - <requiredEntity createDataKey="getConfigAttributeSecondOption"/> - <requiredEntity createDataKey="getConfigAttributeThirdOption"/> - </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> - <createData entity="ConfigurableProductAddChild" stepKey="createConfigProductAddThirdChild"> - <requiredEntity createDataKey="createConfigProduct"/> - <requiredEntity createDataKey="createConfigThirdChildProduct"/> - </createData> - - <!-- Login as Admin --> - <actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminPanel"/> - </before> - <after> - <!-- Delete created data --> - <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> - <deleteData createDataKey="createConfigFirstChildProduct" stepKey="deleteFirstSimpleProduct"/> - <deleteData createDataKey="createConfigSecondChildProduct" stepKey="deleteSecondSimpleProduct"/> - <deleteData createDataKey="createConfigThirdChildProduct" stepKey="deleteThirdSimpleProduct"/> - <deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/> - <deleteData createDataKey="simpleCategory" stepKey="deleteCategory"/> - - <!-- Delete created price rules --> - <amOnPage url="{{CatalogRulePage.url}}" stepKey="goToPriceRulePage"/> - <actionGroup ref="deleteEntitySecondaryGrid" stepKey="deletePriceRuleForFirstOption"> - <argument name="name" value="{{CatalogRuleToFixed.name}}"/> - <argument name="searchInput" value="{{AdminSecondaryGridSection.catalogRuleIdentifierSearch}}"/> - </actionGroup> - - <actionGroup ref="deleteEntitySecondaryGrid" stepKey="deletePriceRuleForSecondOption"> - <argument name="name" value="{{_defaultCatalogRule.name}}"/> - <argument name="searchInput" value="{{AdminSecondaryGridSection.catalogRuleIdentifierSearch}}"/> - </actionGroup> - - <actionGroup ref="deleteEntitySecondaryGrid" stepKey="deletePriceRuleForThirdOption"> - <argument name="name" value="{{CatalogRuleWithoutDiscount.name}}"/> - <argument name="searchInput" value="{{AdminSecondaryGridSection.catalogRuleIdentifierSearch}}"/> - </actionGroup> - - <!-- Log out --> - <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> - - <!-- Reindex invalidated indices after product attribute has been created/deleted --> - <magentoCron groups="index" stepKey="reindexInvalidatedIndices"/> - </after> - - <!-- Create price rule for first configurable product option --> - <actionGroup ref="NewCatalogPriceRuleByUIActionGroup" stepKey="createFirstPriceRule"> - <argument name="catalogRule" value="CatalogRuleToFixed"/> - </actionGroup> - <actionGroup ref="SelectNotLoggedInCustomerGroupActionGroup" stepKey="selectNotLoggedInCustomerGroupForFirstPriceRule"/> - <actionGroup ref="CreateCatalogPriceRuleConditionWithAttributeAndOptionActionGroup" stepKey="createFirstCatalogPriceRuleCondition"> - <argument name="attributeName" value="$$createConfigProductAttribute.attribute[frontend_labels][0][label]$$"/> - <argument name="targetSelectValue" value="$$createConfigProductAttributeFirstOption.option[store_labels][1][label]$$"/> - <argument name="indexA" value="1"/> - <argument name="indexB" value="1"/> - </actionGroup> - <click selector="{{AdminNewCatalogPriceRule.saveAndApply}}" stepKey="saveAndApplyFirstPriceRule"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the rule." stepKey="assertSuccessMessageForFirstPriceRule"/> - - <!-- Create price rule for second configurable product option --> - <actionGroup ref="NewCatalogPriceRuleByUIActionGroup" stepKey="createSecondPriceRule"> - <argument name="catalogRule" value="_defaultCatalogRule"/> - </actionGroup> - <actionGroup ref="SelectNotLoggedInCustomerGroupActionGroup" stepKey="selectNotLoggedInCustomerGroupForSecondPriceRule"/> - <actionGroup ref="CreateCatalogPriceRuleConditionWithAttributeAndOptionActionGroup" stepKey="createSecondCatalogPriceRuleCondition"> - <argument name="attributeName" value="$$createConfigProductAttribute.attribute[frontend_labels][0][label]$$"/> - <argument name="targetSelectValue" value="$$createConfigProductAttributeSecondOption.option[store_labels][1][label]$$"/> - <argument name="indexA" value="1"/> - <argument name="indexB" value="1"/> - </actionGroup> - <click selector="{{AdminNewCatalogPriceRule.saveAndApply}}" stepKey="saveAndApplySecondPriceRule"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the rule." stepKey="assertSuccessMessageForSecondPriceRule"/> - - <!-- Create price rule for third configurable product option --> - <actionGroup ref="NewCatalogPriceRuleByUIActionGroup" stepKey="createThirdPriceRule"> - <argument name="catalogRule" value="CatalogRuleWithoutDiscount"/> - </actionGroup> - <actionGroup ref="SelectNotLoggedInCustomerGroupActionGroup" stepKey="selectNotLoggedInCustomerGroupForThirdPriceRule"/> - <actionGroup ref="CreateCatalogPriceRuleConditionWithAttributeAndOptionActionGroup" stepKey="createThirdCatalogPriceRuleCondition"> - <argument name="attributeName" value="$$createConfigProductAttribute.attribute[frontend_labels][0][label]$$"/> - <argument name="targetSelectValue" value="$$createConfigProductAttributeThirdOption.option[store_labels][1][label]$$"/> - <argument name="indexA" value="1"/> - <argument name="indexB" value="1"/> - </actionGroup> - <click selector="{{AdminNewCatalogPriceRule.saveAndApply}}" stepKey="saveAndApplyThirdPriceRule"/> - <see selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You saved the rule." stepKey="assertSuccessMessageForThirdPriceRule"/> - - <!-- Run full reindex and clear caches --> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> - - <!-- Assert product in storefront product page --> - <amOnPage url="$$createConfigProduct.custom_attributes[url_key]$$.html" stepKey="amOnProductPage"/> - <waitForPageLoad stepKey="waitForProductPageLoad"/> - <actionGroup ref="StorefrontAssertUpdatedProductPriceInStorefrontProductPageActionGroup" stepKey="assertUpdatedProductPriceInStorefrontProductPage"> - <argument name="productName" value="$$createConfigProduct.name$$"/> - <argument name="expectedPrice" value="{{CatalogRuleToFixed.discount_amount}}"/> - </actionGroup> - - <!-- Assert product options price in storefront product page --> - <actionGroup ref="StorefrontAssertCatalogPriceRuleAppliedToProductOptionActionGroup" stepKey="assertCatalogPriceRuleAppliedToFirstProductOption"> - <argument name="option" value="$$createConfigProductAttributeFirstOption.option[store_labels][1][label]$$"/> - <argument name="expectedPrice" value="{{CatalogRuleToFixed.discount_amount}}"/> - </actionGroup> - - <actionGroup ref="StorefrontAssertCatalogPriceRuleAppliedToProductOptionActionGroup" stepKey="assertCatalogPriceRuleAppliedToSecondProductOption"> - <argument name="option" value="$$createConfigProductAttributeSecondOption.option[store_labels][1][label]$$"/> - <argument name="expectedPrice" value="$110.70"/> - </actionGroup> - - <actionGroup ref="StorefrontAssertCatalogPriceRuleAppliedToProductOptionActionGroup" stepKey="assertCatalogPriceRuleAppliedToThirdProductOption"> - <argument name="option" value="$$createConfigProductAttributeThirdOption.option[store_labels][1][label]$$"/> - <argument name="expectedPrice" value="{{ApiConfigurableProduct.price}}"/> - </actionGroup> - - <!-- Add product with selected option to the cart --> - <actionGroup ref="StorefrontAddProductWithSelectedConfigurableOptionToCartActionGroup" stepKey="addProductWithSelectedFirstOptionToCart"> - <argument name="product" value="$$createConfigProduct$$"/> - <argument name="option" value="$$createConfigProductAttributeFirstOption.option[store_labels][1][label]$$"/> - </actionGroup> - - <actionGroup ref="StorefrontAddProductWithSelectedConfigurableOptionToCartActionGroup" stepKey="addProductWithSelectedSecondOptionToCart"> - <argument name="product" value="$$createConfigProduct$$"/> - <argument name="option" value="$$createConfigProductAttributeSecondOption.option[store_labels][1][label]$$"/> - </actionGroup> - - <actionGroup ref="StorefrontAddProductWithSelectedConfigurableOptionToCartActionGroup" stepKey="addProductWithSelectedThirdOptionToCart"> - <argument name="product" value="$$createConfigProduct$$"/> - <argument name="option" value="$$createConfigProductAttributeThirdOption.option[store_labels][1][label]$$"/> - </actionGroup> - - <!--Assert product price in the cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnShoppingCartPage"/> - <waitForPageLoad stepKey="waitForShoppingCartPageLoad"/> - <see userInput="{{CatalogRuleToFixed.discount_amount}}" selector="{{CheckoutCartProductSection.ProductPriceByOption($$createConfigProductAttributeFirstOption.option[store_labels][1][label]$$)}}" stepKey="assertProductPriceForFirstProductOption"/> - <see userInput="$110.70" selector="{{CheckoutCartProductSection.ProductPriceByOption($$createConfigProductAttributeSecondOption.option[store_labels][1][label]$$)}}" stepKey="assertProductPriceForSecondProductOption"/> - <see userInput="{{ApiConfigurableProduct.price}}" selector="{{CheckoutCartProductSection.ProductPriceByOption($$createConfigProductAttributeThirdOption.option[store_labels][1][label]$$)}}" stepKey="assertProductPriceForThirdProductOption"/> - </test> -</tests> diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontSelectOptionDropDownActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontSelectOptionDropDownActionGroup.xml deleted file mode 100644 index fa169373c1096..0000000000000 --- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontSelectOptionDropDownActionGroup.xml +++ /dev/null @@ -1,22 +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="StorefrontSelectOptionDropDownActionGroup"> - <annotations> - <description>DEPRECATED. Please use StorefrontProductPageSelectDropDownOptionValueActionGroup instead. Selects the provided Product Option Value under the provided Product Option Title on a Storefront Product page.</description> - </annotations> - <arguments> - <argument name="optionTitle" defaultValue="ProductOptionDropDown"/> - <argument name="option" defaultValue="ProductOptionValueDropdown2.title"/> - </arguments> - - <selectOption selector="{{StorefrontProductInfoMainSection.productOptionSelect(optionTitle.title)}}" userInput="{{option}}" stepKey="fillOptionDropDown"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml index 741fde91f851e..8f7ff6a751b96 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml @@ -75,9 +75,9 @@ <waitForPageLoad stepKey="waitForSecondProductPageLoad"/> <!-- Fill the custom options values --> - <actionGroup ref="StorefrontSelectOptionDropDownActionGroup" stepKey="selectFirstOption"> - <argument name="optionTitle" value="ProductOptionValueDropdown"/> - <argument name="option" value="ProductOptionValueWithSkuDropdown1.title"/> + <actionGroup ref="StorefrontProductPageSelectDropDownOptionValueActionGroup" stepKey="selectFirstOption"> + <argument name="attributeLabel" value="{{ProductOptionValueDropdown.title}}"/> + <argument name="optionLabel" value="{{ProductOptionValueWithSkuDropdown1.title}}"/> </actionGroup> <fillField selector="{{StorefrontProductInfoMainSection.productOptionFieldInput(ProductOptionField.title)}}" userInput="OptionField" stepKey="fillProductOptionInputField"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddProductWithAllTypesOfCustomOptionToTheShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddProductWithAllTypesOfCustomOptionToTheShoppingCartTest.xml index 8081abcff307b..e8a72b6e88109 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddProductWithAllTypesOfCustomOptionToTheShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontAddProductWithAllTypesOfCustomOptionToTheShoppingCartTest.xml @@ -48,7 +48,10 @@ <actionGroup ref="StorefrontAttachOptionFileActionGroup" stepKey="selectAndAttachFile"/> <!--Select Option From DropDown option --> - <actionGroup ref="StorefrontSelectOptionDropDownActionGroup" stepKey="selectDropDownOption"/> + <actionGroup ref="StorefrontProductPageSelectDropDownOptionValueActionGroup" stepKey="selectFirstOption"> + <argument name="attributeLabel" value="{{ProductOptionDropDown.title}}"/> + <argument name="optionLabel" value="{{ProductOptionValueDropdown2.title}}"/> + </actionGroup> <scrollTo selector="{{StorefrontProductInfoMainSection.customOptionLabel(ProductOptionMultiSelect.title)}}" stepKey="scrollToMultiSelect"/> <!-- Select CheckBox From CheckBox option --> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminAssertNoticeThatExistingSkuAutomaticallyChangedWhenSavingProductWithSameSkuTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminAssertNoticeThatExistingSkuAutomaticallyChangedWhenSavingProductWithSameSkuTest.xml index d58e7cfab1350..6e26d73f3a36f 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminAssertNoticeThatExistingSkuAutomaticallyChangedWhenSavingProductWithSameSkuTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminAssertNoticeThatExistingSkuAutomaticallyChangedWhenSavingProductWithSameSkuTest.xml @@ -27,8 +27,8 @@ </actionGroup> <!-- Delete product attribute --> - <actionGroup ref="DeleteProductAttributeByLabelActionGroup" stepKey="deleteProductAttribute"> - <argument name="ProductAttribute" value="colorProductAttribute"/> + <actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="deleteProductAttribute"> + <argument name="productAttributeLabel" value="{{colorProductAttribute.default_label}}"/> </actionGroup> <!-- Log out --> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductBasedOnParentSkuTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductBasedOnParentSkuTest.xml index 78cbca2d4c099..e5456429373e1 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductBasedOnParentSkuTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductBasedOnParentSkuTest.xml @@ -27,8 +27,8 @@ </actionGroup> <!-- Delete product attribute --> - <actionGroup ref="DeleteProductAttributeByLabelActionGroup" stepKey="deleteProductAttribute"> - <argument name="ProductAttribute" value="colorProductAttribute"/> + <actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="deleteProductAttribute"> + <argument name="productAttributeLabel" value="{{colorProductAttribute.default_label}}"/> </actionGroup> <!-- Log out --> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithCreatingCategoryAndAttributeTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithCreatingCategoryAndAttributeTest.xml index 3913139c9b7e6..32117fdfe4366 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithCreatingCategoryAndAttributeTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithCreatingCategoryAndAttributeTest.xml @@ -36,8 +36,8 @@ </actionGroup> <!-- Delete product attribute --> - <actionGroup ref="DeleteProductAttributeByLabelActionGroup" stepKey="deleteProductAttribute"> - <argument name="ProductAttribute" value="colorProductAttribute"/> + <actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="deleteProductAttribute"> + <argument name="productAttributeLabel" value="{{colorProductAttribute.default_label}}"/> </actionGroup> <!-- Delete attribute set --> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml index 868690e19f6ba..bceabb27e3ae7 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml @@ -39,8 +39,8 @@ </actionGroup> <!-- Delete product attribute --> - <actionGroup ref="DeleteProductAttributeByLabelActionGroup" stepKey="deleteProductAttribute"> - <argument name="ProductAttribute" value="colorProductAttribute"/> + <actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="deleteProductAttribute"> + <argument name="productAttributeLabel" value="{{colorProductAttribute.default_label}}"/> </actionGroup> <!-- Delete attribute set --> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml index 9335f49c9bc2e..9bb5b5073215b 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml @@ -35,8 +35,8 @@ </actionGroup> <!-- Delete product attribute --> - <actionGroup ref="DeleteProductAttributeByLabelActionGroup" stepKey="deleteProductAttribute"> - <argument name="ProductAttribute" value="colorProductAttribute"/> + <actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="deleteProductAttribute"> + <argument name="productAttributeLabel" value="{{colorProductAttribute.default_label}}"/> </actionGroup> <!-- Delete attribute set --> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontVisibilityOfDuplicateProductTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontVisibilityOfDuplicateProductTest.xml index 6126338461fdd..180172ac287d8 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontVisibilityOfDuplicateProductTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontVisibilityOfDuplicateProductTest.xml @@ -36,12 +36,12 @@ <actionGroup ref="ResetProductGridToDefaultViewActionGroup" stepKey="resetGridToDefaultKeywordSearch"/> <!--Delete product attributes--> <comment userInput="Delete product attributes" stepKey="deleteCommentAttributes"/> - <actionGroup ref="DeleteProductAttributeByLabelActionGroup" stepKey="deleteProductAttribute"> - <argument name="ProductAttribute" value="colorProductAttribute"/> + <actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="deleteProductAttribute"> + <argument name="productAttributeLabel" value="{{colorProductAttribute.default_label}}"/> </actionGroup> <click selector="{{AdminProductAttributeGridSection.ResetFilter}}" stepKey="resetFiltersOnGridFirst"/> - <actionGroup ref="DeleteProductAttributeByLabelActionGroup" stepKey="deleteProductSecondAttribute"> - <argument name="ProductAttribute" value="productAttributeColor"/> + <actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="{{deleteProductSecondAttribute.default_label}}"> + <argument name="productAttributeLabel" value="productAttributeColor"/> </actionGroup> <click selector="{{AdminProductAttributeGridSection.ResetFilter}}" stepKey="resetFiltersOnGridSecond"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontProductQuickSearchUsingElasticSearch6Test.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontProductQuickSearchUsingElasticSearch6Test.xml index 3cb06014234dc..c3b76d4ff1c9e 100644 --- a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontProductQuickSearchUsingElasticSearch6Test.xml +++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontProductQuickSearchUsingElasticSearch6Test.xml @@ -46,15 +46,15 @@ <actionGroup ref="StorefrontCheckQuickSearchStringActionGroup" stepKey="quickSearchSimpleProduct"> <argument name="phrase" value="AAA"/> </actionGroup> - <actionGroup ref="AssertProductOnCategoryPageActionGroup" stepKey="assertFirstProductOnCatalogSearchPage"> - <argument name="product" value="$createFirstProduct$"/> + <actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="assertFirstProductOnCatalogSearchPage"> + <argument name="productName" value="$createFirstProduct.name$"/> </actionGroup> <actionGroup ref="StorefrontCheckProductIsMissingInCategoryProductsPageActionGroup" stepKey="assertSecondProductIsMissingOnCatalogSearchPage"> <argument name="productName" value="$createSecondProduct.name$"/> </actionGroup> <click selector="{{StorefrontCategoryBottomToolbarSection.nextPage}}" stepKey="clickNextPageCatalogSearchPager"/> - <actionGroup ref="AssertProductOnCategoryPageActionGroup" stepKey="assertSecondProductOnCatalogSearchPage"> - <argument name="product" value="$createSecondProduct$"/> + <actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="assertSecondProductOnCatalogSearchPage"> + <argument name="productName" value="$createSecondProduct.name$"/> </actionGroup> <actionGroup ref="StorefrontCheckProductIsMissingInCategoryProductsPageActionGroup" stepKey="assertFirstProductIsMissingOnCatalogSearchPage"> <argument name="productName" value="$createFirstProduct.name$"/> @@ -64,11 +64,11 @@ <dontSeeInCurrentUrl stepKey="assertRedirectedToFirstPage" url="?p=2"/> - <actionGroup ref="AssertProductOnCategoryPageActionGroup" stepKey="assertFirstProductDisplayedOnCatalogSearchPage"> - <argument name="product" value="$createFirstProduct$"/> + <actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="assertFirstProductDisplayedOnCatalogSearchPage"> + <argument name="productName" value="$createFirstProduct.name$"/> </actionGroup> - <actionGroup ref="AssertProductOnCategoryPageActionGroup" stepKey="assertSecondProductDisplayedOnCatalogSearchPage"> - <argument name="product" value="$createSecondProduct$"/> + <actionGroup ref="AssertStorefrontProductIsPresentOnCategoryPageActionGroup" stepKey="assertSecondProductDisplayedOnCatalogSearchPage"> + <argument name="productName" value="$createSecondProduct.name$"/> </actionGroup> </test> </tests> diff --git a/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml b/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml deleted file mode 100644 index fd15b344da600..0000000000000 --- a/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml +++ /dev/null @@ -1,117 +0,0 @@ -<?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="StorefrontMyAccountWithMultishipmentTest" deprecated="some"> - <annotations> - <features value="Multishipping"/> - <stories value="Shipping price shows 0 on Order view page after multiple address checkout"/> - <title value="DEPRECATED. Verify Shipping price for Storefront after multiple address checkout"/> - <description value="Verify that shipping price on My account matches with shipping method prices after multiple addresses checkout (Order view page)"/> - <severity value="CRITICAL"/> - <testCaseId value="MC-19303"/> - <group value="multishipping"/> - <skip> - <issueId value="DEPRECATED">Please use StorefrontOrderWithMultishippingTest instead</issueId> - </skip> - </annotations> - - <before> - <createData entity="SimpleSubCategory" stepKey="category"/> - <createData entity="SimpleProduct" stepKey="product1"> - <requiredEntity createDataKey="category"/> - </createData> - <createData entity="SimpleProduct" stepKey="product2"> - <requiredEntity createDataKey="category"/> - </createData> - <createData entity="Simple_US_Customer_Two_Addresses" stepKey="customer"/> - <!-- Set configurations --> - <magentoCLI command="config:set {{EnableMultiShippingCheckoutMultiple.path}} {{EnableMultiShippingCheckoutMultiple.value}}" stepKey="allowShippingToMultipleAddresses"/> - <magentoCLI command="config:set {{EnableFreeShippingMethod.path}} {{EnableFreeShippingMethod.value}}" stepKey="enableFreeShipping"/> - <magentoCLI command="config:set {{EnableFlatRateShippingMethod.path}} {{EnableFlatRateShippingMethod.value}}" stepKey="enableFlatRateShipping"/> - <magentoCLI command="config:set {{EnableCheckMoneyOrderPaymentMethod.path}} {{EnableCheckMoneyOrderPaymentMethod.value}}" stepKey="enableCheckMoneyOrderPaymentMethod"/> - <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> - <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefrontAccount"> - <argument name="Customer" value="$$customer$$"/> - </actionGroup> - </before> - <after> - <actionGroup ref="StorefrontSignOutActionGroup" stepKey="customerLogout"/> - <magentoCLI command="config:set {{DisableMultiShippingCheckoutMultiple.path}} {{DisableMultiShippingCheckoutMultiple.value}}" stepKey="withdrawShippingToMultipleAddresses"/> - <deleteData createDataKey="category" stepKey="deleteCategory"/> - <deleteData createDataKey="product1" stepKey="deleteProduct1"/> - <deleteData createDataKey="product2" stepKey="deleteProduct2"/> - <deleteData createDataKey="customer" stepKey="deleteCustomer"/> - <magentoCLI command="config:set {{DisableFreeShippingMethod.path}} {{DisableFreeShippingMethod.value}}" stepKey="disableFreeShipping"/> - <actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearAllFilters"/> - <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutAdmin"/> - </after> - <actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="addSimpleProduct1ToCart"> - <argument name="product" value="$$product1$$"/> - </actionGroup> - <waitForPageLoad stepKey="waitForSecondProductPageLoad"/> - <actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="addSimpleProduct2ToCart"> - <argument name="product" value="$$product2$$"/> - </actionGroup> - <actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openCart"/> - <actionGroup ref="CheckingWithMultipleAddressesActionGroup" stepKey="checkoutWithMultipleAddresses"/> - <waitForPageLoad stepKey="waitForShippingInfoPageLoad"/> - <actionGroup ref="SelectMultiShippingInfoActionGroup" stepKey="checkoutWithMultipleShipping"/> - <!--Select Check / Money order Payment method--> - <actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyPayment"/> - <actionGroup ref="SelectBillingInfoActionGroup" stepKey="checkoutWithPaymentMethod"/> - <waitForPageLoad stepKey="waitForReviewOrderPageLoad"/> - <actionGroup ref="ReviewOrderForMultiShipmentActionGroup" stepKey="reviewOrderForMultiShipment"> - <argument name="totalNameForFirstOrder" value="Shipping & Handling"/> - <argument name="totalPositionForFirstOrder" value="1"/> - <argument name="totalNameForSecondOrder" value="Shipping & Handling"/> - <argument name="totalPositionForSecondOrder" value="2"/> - </actionGroup> - <waitForPageLoad stepKey="waitForPlaceOrderPageLoad"/> - <actionGroup ref="StorefrontPlaceOrderForMultipleAddressesActionGroup" stepKey="placeOrder"> - <argument name="firstOrderPosition" value="1"/> - <argument name="secondOrderPosition" value="2"/> - </actionGroup> - <waitForPageLoad stepKey="waitForOrderPageLoad"/> - <amOnPage url="{{StorefrontCustomerOrdersHistoryPage.url}}" stepKey="goToSalesOrder"/> - <actionGroup ref="AssertStorefrontSalesOrderMatchesGrandTotalActionGroup" stepKey="checkSalesOrderForFirstOrder"> - <argument name="dataHref" value="$dataHrefForFirstOrderPlaceOrder"/> - </actionGroup> - <amOnPage url="{{StorefrontCustomerOrdersHistoryPage.url}}" stepKey="goToSalesOrder2"/> - <waitForPageLoad stepKey="waitForOrderPageLoad2"/> - <actionGroup ref="AssertStorefrontSalesOrderMatchesGrandTotalActionGroup" stepKey="checkSalesOrderForSecondOrder"> - <argument name="dataHref" value="$dataHrefForSecondOrderPlaceOrder"/> - </actionGroup> - <waitForPageLoad stepKey="waitForAdminPageToLoad"/> - <!-- Go to Stores > Configuration > Sales > Orders --> - <amOnPage url="{{AdminOrdersPage.url}}" stepKey="onAdminOrdersPage"/> - <waitForPageLoad stepKey="waitForOrderPageLoad3"/> - <actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearFilters"/> - <waitForLoadingMaskToDisappear stepKey="waitForLoading"/> - <!--Assert order in orders grid --> - <!-- Go to order page --> - <actionGroup ref="OpenOrderByIdActionGroup" stepKey="openFirstOrderPage"> - <argument name="orderId" value="{$getFirstOrderIdPlaceOrder}"/> - </actionGroup> - <!-- Check status --> - <see selector="{{AdminOrderDetailsInformationSection.orderStatus}}" userInput="Pending" stepKey="seeFirstOrderPendingStatus"/> - <actionGroup ref="AdminSalesOrderActionGroup" stepKey="validateOrderTotalsForFirstOrder"/> - <amOnPage url="{{AdminOrdersPage.url}}" stepKey="onAdminOrdersPage2"/> - <waitForPageLoad stepKey="waitForOrderPageLoad4"/> - <actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearFilters2"/> - <!-- Go to order page --> - <actionGroup ref="OpenOrderByIdActionGroup" stepKey="openSecondOrderPage"> - <argument name="orderId" value="{$getSecondOrderIdPlaceOrder}"/> - </actionGroup> - <!-- Check status --> - <see selector="{{AdminOrderDetailsInformationSection.orderStatus}}" userInput="Pending" stepKey="seeSecondOrderPendingStatus"/> - <actionGroup ref="AdminSalesOrderActionGroup" stepKey="validateOrderTotalsForSecondOrder"/> - <amOnPage url="{{StorefrontHomePage.url}}" stepKey="gotToHomePage"/> - </test> -</tests> diff --git a/app/code/Magento/Reports/Test/Mftf/Test/AdminReportsOrderedGroupedBySkuTest.xml b/app/code/Magento/Reports/Test/Mftf/Test/AdminReportsOrderedGroupedBySkuTest.xml index 6d0b335ac7094..650097214a0c4 100644 --- a/app/code/Magento/Reports/Test/Mftf/Test/AdminReportsOrderedGroupedBySkuTest.xml +++ b/app/code/Magento/Reports/Test/Mftf/Test/AdminReportsOrderedGroupedBySkuTest.xml @@ -28,8 +28,8 @@ <actionGroup ref="DeleteProductBySkuActionGroup" stepKey="deleteConfigurableProduct"> <argument name="sku" value="{{_defaultProduct.sku}}"/> </actionGroup> - <actionGroup ref="DeleteProductAttributeByLabelActionGroup" stepKey="deleteAttributeSet"> - <argument name="ProductAttribute" value="colorProductAttribute"/> + <actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="deleteAttributeSet"> + <argument name="productAttributeLabel" value="{{colorProductAttribute.default_label}}"/> </actionGroup> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontImageColorWhenFilterByColorFilterTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontImageColorWhenFilterByColorFilterTest.xml index 47ca8ce44bec3..03c09c70f3654 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontImageColorWhenFilterByColorFilterTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontImageColorWhenFilterByColorFilterTest.xml @@ -30,8 +30,8 @@ <after> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> - <actionGroup ref="DeleteProductAttributeByLabelActionGroup" stepKey="deleteAttribute"> - <argument name="ProductAttribute" value="visualSwatchAttribute"/> + <actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="deleteAttribute"> + <argument name="productAttributeLabel" value="{{visualSwatchAttribute.default_label}}"/> </actionGroup> <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="openProductIndexPage"/> <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearGridFilter"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml index a1d346ffa2744..2e58aba5963ec 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml @@ -36,8 +36,8 @@ <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPage"/> <waitForPageLoad stepKey="waitForAdminProductGridLoad"/> <conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial"/> - <actionGroup ref="DeleteProductAttributeByLabelActionGroup" stepKey="deleteAttribute"> - <argument name="ProductAttribute" value="visualSwatchAttribute"/> + <actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="deleteAttribute"> + <argument name="productAttributeLabel" value="{{visualSwatchAttribute.default_label}}"/> </actionGroup> <!--delete root category--> <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage"/> diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest.xml deleted file mode 100644 index 6a1bcb38bdb31..0000000000000 --- a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest.xml +++ /dev/null @@ -1,87 +0,0 @@ -<?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="AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategoryTest" deprecated="some"> - <annotations> - <features value="Url Rewrite"/> - <stories value="Update url rewrites"/> - <title value="DEPRECATED. Check url rewrites in catalog categories after changing url key"/> - <description value="DEPRECATED. Check url rewrites in catalog categories after changing url key for store view and moving category"/> - <severity value="CRITICAL"/> - <testCaseId value="MC-5352"/> - <group value="url_rewrite"/> - <group value="mtf_migrated"/> - <skip> - <issueId value="DEPRECATED">Use AdminCheckUrlRewritesInCatalogCategoriesAfterChangingUrlKeyForStoreViewAndMovingCategory2Test instead</issueId> - </skip> - </annotations> - <before> - <!-- Create two sub-categories in default category with simple products --> - <createData entity="_defaultCategory" stepKey="createFirstCategory"/> - <createData entity="_defaultProduct" stepKey="createFirstSimpleProduct"> - <requiredEntity createDataKey="createFirstCategory"/> - </createData> - <createData entity="_defaultCategory" stepKey="createSecondCategory"/> - <createData entity="_defaultProduct" stepKey="createSecondSimpleProduct"> - <requiredEntity createDataKey="createSecondCategory"/> - </createData> - - <!-- Log in to backend --> - <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> - - <!--Create additional Store View in Main Website Store --> - <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreView"/> - - <!-- Reindex and flush the cache --> - <magentoCLI command="indexer:reindex" stepKey="runReindex"/> - <magentoCLI command="cache:flush" stepKey="cleanCache"/> - </before> - <after> - <deleteData createDataKey="createFirstCategory" stepKey="deleteFirstCategory"/> - <deleteData createDataKey="createSecondCategory" stepKey="deleteSecondCategory"/> - <deleteData createDataKey="createFirstSimpleProduct" stepKey="deleteFirstSimpleProduct"/> - <deleteData createDataKey="createSecondSimpleProduct" stepKey="deleteSecondSimpleProduct"/> - <actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="deleteStoreView"/> - <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> - </after> - - <!-- On the categories editing page change store view to created additional view --> - <actionGroup ref="SwitchCategoryStoreViewActionGroup" stepKey="switchStoreView"> - <argument name="Store" value="customStore.name"/> - <argument name="CatName" value="$$createFirstCategory.name$$"/> - </actionGroup> - - <!-- Change url key for category for first category; save --> - <actionGroup ref="ChangeSeoUrlKeyForSubCategoryActionGroup" stepKey="changeUrlKey"> - <argument name="value" value="{{SimpleRootSubCategory.url_key}}"/> - </actionGroup> - - <!-- Change store view to "All store views" for first category --> - <actionGroup ref="SwitchCategoryToAllStoreViewActionGroup" stepKey="switchToAllStoreViewProduct"> - <argument name="CatName" value="$$createFirstCategory.name$$"/> - </actionGroup> - - <!-- Move first category inside second category --> - <actionGroup ref="MoveCategoryActionGroup" stepKey="moveFirstCategoryToSecondCategory"> - <argument name="childCategory" value="$$createFirstCategory.name$$"/> - <argument name="parentCategory" value="$$createSecondCategory.name$$"/> - </actionGroup> - - <!-- Switch default store view on store view created below for first category --> - <actionGroup ref="StorefrontOpenHomePageActionGroup" stepKey="amOnStorefrontPage"/> - <actionGroup ref="StorefrontSwitchStoreViewActionGroup" stepKey="storefrontSwitchStoreView"> - <argument name="storeView" value="customStore"/> - </actionGroup> - - <!-- Assert category url with custom store view --> - <amOnPage url="{{StorefrontHomePage.url}}$$createSecondCategory.name$$/{{SimpleRootSubCategory.url_key}}.html" stepKey="amOnCategoryPage"/> - <waitForPageLoad stepKey="waitForCategoryPageLoad"/> - <see userInput="$$createFirstSimpleProduct.name$$" selector="{{StorefrontCategoryMainSection.productsList}}" stepKey="seeProductInCategory"/> - </test> -</tests> From dd39f7ef6991820a861b3a22276c8c82ccc816e1 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Sat, 11 Apr 2020 04:17:49 +0200 Subject: [PATCH 136/177] #27638 Fix static checks --- .../Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php index 594d897938ae8..1f3faf659e390 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php @@ -45,7 +45,6 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; - /** * @SuppressWarnings(PHPMD.TooManyFields) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) From 7e5b5b150c5bb81d6f79aa77db68d14870704bab Mon Sep 17 00:00:00 2001 From: Ji Lu <jilu1@adobe.com> Date: Fri, 10 Apr 2020 21:18:42 -0500 Subject: [PATCH 137/177] MQE-2046: remove deprecated entities usages in MFTF tests --- .../Mftf/Test/StorefrontVisibilityOfDuplicateProductTest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontVisibilityOfDuplicateProductTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontVisibilityOfDuplicateProductTest.xml index 180172ac287d8..801dfdb8540e8 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontVisibilityOfDuplicateProductTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontVisibilityOfDuplicateProductTest.xml @@ -40,8 +40,8 @@ <argument name="productAttributeLabel" value="{{colorProductAttribute.default_label}}"/> </actionGroup> <click selector="{{AdminProductAttributeGridSection.ResetFilter}}" stepKey="resetFiltersOnGridFirst"/> - <actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="{{deleteProductSecondAttribute.default_label}}"> - <argument name="productAttributeLabel" value="productAttributeColor"/> + <actionGroup ref="AdminDeleteProductAttributeByLabelActionGroup" stepKey="deleteProductSecondAttribute"> + <argument name="productAttributeLabel" value="{{productAttributeColor.default_label}}"/> </actionGroup> <click selector="{{AdminProductAttributeGridSection.ResetFilter}}" stepKey="resetFiltersOnGridSecond"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> From 29e876ccc0625bdcb4d249ca613962cfd94771cb Mon Sep 17 00:00:00 2001 From: "rostyslav.hymon" <rostyslav.hymon@transoftgroup.com> Date: Mon, 13 Apr 2020 09:22:16 +0300 Subject: [PATCH 138/177] MC-33110: Paypal Express Checkout - payment loading infinitely in checkout --- .../Paypal/Model/SmartButtonConfig.php | 21 +++++++++- .../Test/Unit/Model/SmartButtonConfigTest.php | 13 ++++-- .../Unit/Model/_files/expected_config.php | 42 +++++++++++-------- 3 files changed, 52 insertions(+), 24 deletions(-) diff --git a/app/code/Magento/Paypal/Model/SmartButtonConfig.php b/app/code/Magento/Paypal/Model/SmartButtonConfig.php index 59e4db6d84201..921dc4679b089 100644 --- a/app/code/Magento/Paypal/Model/SmartButtonConfig.php +++ b/app/code/Magento/Paypal/Model/SmartButtonConfig.php @@ -13,7 +13,7 @@ use Magento\Store\Model\ScopeInterface; /** - * Smart button config + * Smart button configuration. */ class SmartButtonConfig { @@ -96,7 +96,14 @@ public function getConfig(string $page): array private function getDisallowedFunding(): array { $disallowedFunding = $this->config->getValue('disable_funding_options'); - return $disallowedFunding ? explode(',', $disallowedFunding) : []; + $result = $disallowedFunding ? explode(',', $disallowedFunding) : []; + + // PayPal Guest Checkout Credit Card Icons only available when Guest Checkout option is enabled + if ($this->isPaypalGuestCheckoutAllowed() === false && !in_array('CARD', $result)) { + array_push($result, 'CARD'); + } + + return $result; } /** @@ -168,4 +175,14 @@ private function updateStyles(array $styles, string $page): array return $styles; } + + /** + * Returns if is allowed PayPal Guest Checkout. + * + * @return bool + */ + private function isPaypalGuestCheckoutAllowed(): bool + { + return $this->config->getValue('solution_type') === Config::EC_SOLUTION_TYPE_SOLE; + } } diff --git a/app/code/Magento/Paypal/Test/Unit/Model/SmartButtonConfigTest.php b/app/code/Magento/Paypal/Test/Unit/Model/SmartButtonConfigTest.php index 5aa3dee0874b2..7446b9d7a74e3 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/SmartButtonConfigTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/SmartButtonConfigTest.php @@ -13,9 +13,6 @@ use Magento\Framework\Locale\ResolverInterface; use Magento\Paypal\Model\ConfigFactory; -/** - * Class SmartButtonConfigTest - */ class SmartButtonConfigTest extends \PHPUnit\Framework\TestCase { /** @@ -65,6 +62,7 @@ protected function setUp() * * @param string $page * @param string $locale + * @param bool $isCustomize * @param string $disallowedFundings * @param string $layout * @param string $size @@ -73,6 +71,7 @@ protected function setUp() * @param string $color * @param string $installmentPeriodLabel * @param string $installmentPeriodLocale + * @param string $isPaypalGuestCheckoutEnabled * @param array $expected * @dataProvider getConfigDataProvider * @SuppressWarnings(PHPMD.ExcessiveParameterList) @@ -89,13 +88,19 @@ public function testGetConfig( string $color, string $installmentPeriodLabel, string $installmentPeriodLocale, + string $isPaypalGuestCheckoutEnabled, array $expected = [] ) { - $this->localeResolverMock->expects($this->any())->method('getLocale')->willReturn($locale); + $this->localeResolverMock->method('getLocale')->willReturn($locale); $this->configMock->method('getValue')->will( $this->returnValueMap( [ ['merchant_id', null, 'merchant'], + [ + 'solution_type', + null, + $isPaypalGuestCheckoutEnabled ? Config::EC_SOLUTION_TYPE_SOLE : Config::EC_SOLUTION_TYPE_MARK + ], ['sandbox_flag', null, true], ['disable_funding_options', null, $disallowedFundings], ["{$page}_page_button_customize", null, $isCustomize], diff --git a/app/code/Magento/Paypal/Test/Unit/Model/_files/expected_config.php b/app/code/Magento/Paypal/Test/Unit/Model/_files/expected_config.php index 7256984ab5226..f17b9f9fb4979 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/_files/expected_config.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/_files/expected_config.php @@ -18,6 +18,7 @@ 'blue', 'my_label', 'mx', + true, [ 'merchantId' => 'merchant', 'environment' => 'sandbox', @@ -48,6 +49,7 @@ 'blue', 'my_label', 'br', + true, [ 'merchantId' => 'merchant', 'environment' => 'sandbox', @@ -78,6 +80,7 @@ 'blue', 'my_label', 'br', + true, [ 'merchantId' => 'merchant', 'environment' => 'sandbox', @@ -95,11 +98,11 @@ 'isGuestCheckoutAllowed' => true ] ], - 'mini_cart' => [ + 'product' => [ 'cart', 'en', false, - null, + 'CREDIT', 'horizontal', 'small', 'pillow', @@ -107,28 +110,29 @@ 'blue', 'my_label', 'br', + true, [ 'merchantId' => 'merchant', 'environment' => 'sandbox', 'locale' => 'en', - 'allowedFunding' => ['CREDIT', 'ELV'], - 'disallowedFunding' => [], + 'allowedFunding' => ['ELV'], + 'disallowedFunding' => ['CREDIT'], 'styles' => [ 'layout' => 'vertical', 'size' => 'responsive', 'color' => 'gold', 'shape' => 'rect', - 'label' => 'paypal' + 'label' => 'paypal', ], 'isVisibleOnProductPage' => false, 'isGuestCheckoutAllowed' => true ] ], - 'product' => [ + 'checkout_with_paypal_guest_checkout_disabled' => [ 'cart', - 'en', - false, - 'CREDIT', + 'en_BR', + true, + null, 'horizontal', 'small', 'pillow', @@ -136,21 +140,23 @@ 'blue', 'my_label', 'br', + false, [ 'merchantId' => 'merchant', 'environment' => 'sandbox', - 'locale' => 'en', - 'allowedFunding' => ['ELV'], - 'disallowedFunding' => ['CREDIT'], + 'locale' => 'en_BR', + 'allowedFunding' => ['CREDIT', 'ELV'], + 'disallowedFunding' => ['CARD'], 'styles' => [ - 'layout' => 'vertical', - 'size' => 'responsive', - 'color' => 'gold', - 'shape' => 'rect', - 'label' => 'paypal', + 'layout' => 'horizontal', + 'size' => 'small', + 'color' => 'blue', + 'shape' => 'pillow', + 'label' => 'installment', + 'installmentperiod' => 0 ], 'isVisibleOnProductPage' => false, 'isGuestCheckoutAllowed' => true ] - ] + ], ]; From 663c21b4d75c758af69cd3d9fe62a3f9be52dba8 Mon Sep 17 00:00:00 2001 From: "rostyslav.hymon" <rostyslav.hymon@transoftgroup.com> Date: Mon, 13 Apr 2020 12:23:46 +0300 Subject: [PATCH 139/177] MC-33110: Paypal Express Checkout - payment loading infinitely in checkout --- .../Test/Unit/Model/SmartButtonConfigTest.php | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Paypal/Test/Unit/Model/SmartButtonConfigTest.php b/app/code/Magento/Paypal/Test/Unit/Model/SmartButtonConfigTest.php index 7446b9d7a74e3..4002c78bb0ecc 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/SmartButtonConfigTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/SmartButtonConfigTest.php @@ -12,8 +12,13 @@ use Magento\Paypal\Model\SmartButtonConfig; use Magento\Framework\Locale\ResolverInterface; use Magento\Paypal\Model\ConfigFactory; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; -class SmartButtonConfigTest extends \PHPUnit\Framework\TestCase +/** + * Test for smart button config + */ +class SmartButtonConfigTest extends TestCase { /** * @var \Magento\Paypal\Model\SmartButtonConfig @@ -21,15 +26,18 @@ class SmartButtonConfigTest extends \PHPUnit\Framework\TestCase private $model; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ private $localeResolverMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ private $configMock; + /** + * @inheritdoc + */ protected function setUp() { $this->localeResolverMock = $this->getMockForAbstractClass(ResolverInterface::class); @@ -37,12 +45,12 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); - /** @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject $scopeConfigMock */ + /** @var ScopeConfigInterface|MockObject $scopeConfigMock */ $scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class); $scopeConfigMock->method('isSetFlag') ->willReturn(true); - /** @var \PHPUnit_Framework_MockObject_MockObject $configFactoryMock */ + /** @var MockObject $configFactoryMock */ $configFactoryMock = $this->getMockBuilder(ConfigFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) @@ -122,6 +130,8 @@ public function testGetConfig( } /** + * Get config data provider + * * @return array */ public function getConfigDataProvider() @@ -130,6 +140,8 @@ public function getConfigDataProvider() } /** + * Get default styles + * * @return array */ private function getDefaultStyles() @@ -138,6 +150,8 @@ private function getDefaultStyles() } /** + * Get allowed fundings + * * @return array */ private function getAllowedFundings() From dd0c6c003b3e1a44f93865fe317153a773523bb5 Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Mon, 13 Apr 2020 15:57:20 +0300 Subject: [PATCH 140/177] Remove redundant Index and flush cache action group --- .../AdminReindexAndFlushCacheActionGroup.xml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 app/code/Magento/Indexer/Test/Mftf/ActionGroup/IndexerActionGroup/AdminReindexAndFlushCacheActionGroup.xml diff --git a/app/code/Magento/Indexer/Test/Mftf/ActionGroup/IndexerActionGroup/AdminReindexAndFlushCacheActionGroup.xml b/app/code/Magento/Indexer/Test/Mftf/ActionGroup/IndexerActionGroup/AdminReindexAndFlushCacheActionGroup.xml deleted file mode 100644 index 42b6b047ae73e..0000000000000 --- a/app/code/Magento/Indexer/Test/Mftf/ActionGroup/IndexerActionGroup/AdminReindexAndFlushCacheActionGroup.xml +++ /dev/null @@ -1,18 +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="AdminReindexAndFlushCache"> - <annotations> - <description>Run reindex and flush cache.</description> - </annotations> - - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> - </actionGroup> -</actionGroups> From 9daf3780246e36a3353e6813c40a2bb9073761c3 Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Mon, 13 Apr 2020 18:02:25 +0300 Subject: [PATCH 141/177] Added assertion to AssertAdminSuccessLoginActionGroup --- .../Test/Mftf/ActionGroup/AssertAdminSuccessLoginActionGroup.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminSuccessLoginActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminSuccessLoginActionGroup.xml index 1f0ce1824fead..f669c4b9f3ca4 100644 --- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminSuccessLoginActionGroup.xml +++ b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminSuccessLoginActionGroup.xml @@ -14,5 +14,6 @@ </annotations> <waitForElementVisible selector="{{AdminHeaderSection.adminUserAccountText}}" stepKey="waitForAdminAccountTextVisible"/> + <seeElement selector="{{AdminHeaderSection.adminUserAccountText}}" stepKey="assertAdminAccountTextElement"/> </actionGroup> </actionGroups> From de0c98dc1bc628c1ab7b86a64ef5921fa7d7adba Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Mon, 13 Apr 2020 19:35:52 +0300 Subject: [PATCH 142/177] Use ActionGroup to go to checkout page --- .../Test/Mftf/Test/StorefrontAdminEditDataTest.xml | 6 ++---- .../Test/StorefrontBundleAddToCartSuccessTest.xml | 3 +-- .../Mftf/Test/StorefrontEditBundleProductTest.xml | 6 ++---- .../Test/Mftf/Test/AddToCartCrossSellTest.xml | 3 +-- .../AdminApplyTierPriceToProductTest.xml | 12 ++++-------- .../AdminBackorderAllowedAddProductToCartTest.xml | 3 +-- ...AssociatedProductToConfigurableOutOfStockTest.xml | 2 +- .../AdminCreateCatalogPriceRuleByPercentTest.xml | 3 +-- .../Mftf/Test/CheckoutSpecificDestinationsTest.xml | 5 ++--- ...eleteBundleDynamicProductFromShoppingCartTest.xml | 3 +-- .../DeleteBundleFixedProductFromShoppingCartTest.xml | 3 +-- ...DeleteConfigurableProductFromShoppingCartTest.xml | 3 +-- ...DeleteDownloadableProductFromShoppingCartTest.xml | 3 +-- .../DeleteGroupedProductFromShoppingCartTest.xml | 3 +-- .../DeleteVirtualProductFromShoppingCartTest.xml | 3 +-- ...hoppingCartAndMiniShoppingCartPerCustomerTest.xml | 6 ++---- ...ShippingRecalculationAfterCouponCodeAddedTest.xml | 3 +-- ...torefrontOnePageCheckoutDataWhenChangeQtyTest.xml | 3 +-- ...tentDataForGuestCustomerWithPhysicalQuoteTest.xml | 4 ++-- ...refrontUpdateShoppingCartSimpleProductQtyTest.xml | 3 +-- ...pingCartSimpleWithCustomOptionsProductQtyTest.xml | 3 +-- ...leProductWithTwoOptionsAssignedToCategoryTest.xml | 3 +-- ...ctWithTwoOptionsWithoutAssignedToCategoryTest.xml | 3 +-- ...ntConfigurableProductWithFileCustomOptionTest.xml | 3 +-- .../AdminCreateDownloadableProductWithLinkTest.xml | 3 +-- ...nloadableProductWithSeparateLinksFromCartTest.xml | 3 +-- ...gCheckoutWhenCartPageIsOpenedInAnotherTabTest.xml | 5 ++--- ...frontFreeShippingDisplayWithInclTaxOptionTest.xml | 3 +-- ...sonWishlistIsPersistedUnderLongTermCookieTest.xml | 2 +- .../StorefrontGuestCheckoutDisabledProductTest.xml | 2 +- .../AdminCreateCartPriceRuleEmptyFromDateTest.xml | 3 +-- .../AdminCreateCartPriceRuleForCouponCodeTest.xml | 3 +-- ...dminCreateCartPriceRuleForGeneratedCouponTest.xml | 3 +-- .../Mftf/Test/StorefrontCartPriceRuleCountryTest.xml | 3 +-- .../Test/StorefrontCartPriceRulePostcodeTest.xml | 3 +-- .../Test/StorefrontCartPriceRuleQuantityTest.xml | 6 ++---- .../Mftf/Test/StorefrontCartPriceRuleStateTest.xml | 3 +-- .../Test/StorefrontCartPriceRuleSubtotalTest.xml | 6 ++---- ...rtTotalValueWithFullDiscountUsingCartRuleTest.xml | 3 +-- ...tomerCanChangeProductOptionsUsingSwatchesTest.xml | 2 +- ...orefrontSwatchProductWithFileCustomOptionTest.xml | 3 +-- .../StorefrontTaxQuoteCartGuestSimpleTest.xml | 3 +-- .../StorefrontTaxQuoteCartGuestVirtualTest.xml | 3 +-- .../StorefrontTaxQuoteCartLoggedInSimpleTest.xml | 3 +-- .../StorefrontTaxQuoteCartLoggedInVirtualTest.xml | 3 +-- 45 files changed, 56 insertions(+), 104 deletions(-) diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdminEditDataTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdminEditDataTest.xml index a37ec0cffbbb8..5bdecea1cfe63 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdminEditDataTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdminEditDataTest.xml @@ -80,8 +80,7 @@ <waitForPageLoad stepKey="waitForElementAdded"/> <!-- Go to the shopping cart page and grab the value of the option title --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="onPageShoppingCart"/> - <waitForPageLoad stepKey="waitForCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="onPageShoppingCart"/> <grabTextFrom selector="{{CheckoutCartProductSection.nthBundleOptionName('1')}}" stepKey="grabTotalBefore"/> <!-- Find the product that we just created using the product grid --> @@ -101,8 +100,7 @@ <see stepKey="assertSuccess2" selector="{{AdminProductMessagesSection.successMessage}}" userInput="You saved the product."/> <!-- Go to the shopping cart page and make sure the title has changed --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="onPageShoppingCart1"/> - <waitForPageLoad stepKey="waitForCartPageLoad1"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="onPageShoppingCart1"/> <grabTextFrom selector="{{CheckoutCartProductSection.nthBundleOptionName('1')}}" stepKey="grabTotalAfter"/> <assertNotEquals stepKey="assertNotEquals"> <actualResult type="string">{$grabTotalAfter}</actualResult> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartSuccessTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartSuccessTest.xml index 85be636ec269c..784e7d8a4a308 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartSuccessTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartSuccessTest.xml @@ -100,8 +100,7 @@ <see selector="{{StorefrontMessagesSection.success}}" userInput="You added {{BundleProduct.name}} to your shopping cart." stepKey="seeAddToCartSuccessMessage"/> <!-- Verify cart contents --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCart"/> - <waitForPageLoad stepKey="waitForCart"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> <see selector="{{StorefrontBundledSection.nthItemOptionsTitle('1')}}" userInput="Option One" stepKey="seeOption1"/> <see selector="{{StorefrontBundledSection.nthItemOptionsTitle('2')}}" userInput="Option Two" stepKey="seeOption2"/> <see selector="{{StorefrontBundledSection.nthItemOptionsTitle('3')}}" userInput="Option Three" stepKey="seeOption3"/> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontEditBundleProductTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontEditBundleProductTest.xml index 3082e467ec734..5fdc9f0a26af3 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontEditBundleProductTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontEditBundleProductTest.xml @@ -89,8 +89,7 @@ <waitForPageLoad stepKey="waitForElementAdded2"/> <!-- Go to the shopping cart page and edit the first product --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="onPageShoppingCart"/> - <waitForPageLoad stepKey="waitForCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="onPageShoppingCart"/> <waitForElementVisible stepKey="waitForInfoDropdown" selector="{{CheckoutCartSummarySection.total}}"/> <waitForPageLoad stepKey="waitForCartPageLoad3"/> <grabTextFrom selector="{{CheckoutCartSummarySection.total}}" stepKey="grabTotalBefore"/> @@ -107,8 +106,7 @@ <waitForPageLoad stepKey="waitForElementAdded3"/> <!-- Go to the shopping cart page --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="onPageShoppingCart2"/> - <waitForPageLoad stepKey="waitForCartPageLoad2"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="onPageShoppingCart2"/> <!-- Assert that the options are both there and the proce no longer matches --> <see stepKey="assertBothOptions" selector="{{CheckoutCartProductSection.nthItemOption('2')}}" userInput="$$simpleProduct1.sku$$"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AddToCartCrossSellTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AddToCartCrossSellTest.xml index 83a05fef83607..d7dea954ef6b0 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AddToCartCrossSellTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AddToCartCrossSellTest.xml @@ -77,8 +77,7 @@ </actionGroup> <!-- Check that cart page contains cross-sell to simpleProduct2 and simpleProduct3--> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCart1"/> - <waitForPageLoad stepKey="waitForCartToLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart1"/> <waitForElementVisible selector="{{CheckoutCartCrossSellSection.products}}" stepKey="waitForCrossSellLoading"/> <see stepKey="seeProduct2InCrossSell" selector="{{CheckoutCartCrossSellSection.products}}" userInput="$simpleProduct2.name$"/> <see stepKey="seeProduct3InCrossSell" selector="{{CheckoutCartCrossSellSection.products}}" userInput="$simpleProduct3.name$"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminApplyTierPriceToProductTest/AdminApplyTierPriceToProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminApplyTierPriceToProductTest/AdminApplyTierPriceToProductTest.xml index b2181164070dc..f56ef530c6851 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminApplyTierPriceToProductTest/AdminApplyTierPriceToProductTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminApplyTierPriceToProductTest/AdminApplyTierPriceToProductTest.xml @@ -171,8 +171,7 @@ <fillField selector="{{AdminProductFormAdvancedPricingSection.productTierPricePercentageValuePriceInput('1')}}" userInput="25" stepKey="selectProductTierPricePercentageValue2"/> <click selector="{{AdminProductFormAdvancedPricingSection.doneButton}}" stepKey="clickDoneButton4"/> <actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct4"/> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToShoppingCartPage1"/> - <waitForPageLoad time="30" stepKey="waitForShoppingCartPagePageLoad1"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToShoppingCartPage1"/> <seeInField userInput="20" selector="{{CheckoutCartProductSection.ProductQuantityByName($$createSimpleProduct.name$$)}}" stepKey="seeInQtyField20"/> <grabTextFrom selector="{{CheckoutCartProductSection.productSubtotalByName($$createSimpleProduct.name$$)}}" stepKey="grabTextFromSubtotalField4"/> <assertEquals message="Shopping cart should contain subtotal $1,500" stepKey="assertSubtotalField4"> @@ -198,8 +197,7 @@ <click selector="{{AdminConfigSection.saveButton}}" stepKey="saveConfig1"/> <see selector="{{AdminMessagesSection.success}}" userInput="You saved the configuration." stepKey="seeConfigSuccessMessage1"/> <actionGroup ref="ClearCacheActionGroup" stepKey="flushCache1"/> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToShoppingCartPage2"/> - <waitForPageLoad time="30" stepKey="waitForShoppingCartPagePageLoad2"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToShoppingCartPage2"/> <seeInField userInput="20" selector="{{CheckoutCartProductSection.ProductQuantityByName($$createSimpleProduct.name$$)}}" stepKey="seeInQtyField20_2"/> <grabTextFrom selector="{{CheckoutCartProductSection.productSubtotalByName($$createSimpleProduct.name$$)}}" stepKey="grabTextFromSubtotalField5"/> <assertEquals message="Shopping cart should contain subtotal $1,500" stepKey="assertSubtotalField5"> @@ -212,8 +210,7 @@ <click selector="{{AdminConfigSection.saveButton}}" stepKey="saveConfig2"/> <see selector="{{AdminMessagesSection.success}}" userInput="You saved the configuration." stepKey="seeConfigSuccessMessage2"/> <actionGroup ref="ClearCacheActionGroup" stepKey="flushCache2"/> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToShoppingCartPage3"/> - <waitForPageLoad time="30" stepKey="waitForShoppingCartPagePageLoad3"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToShoppingCartPage3"/> <seeInField userInput="20" selector="{{CheckoutCartProductSection.ProductQuantityByName($$createSimpleProduct.name$$)}}" stepKey="seeInQtyField20_3"/> <grabTextFrom selector="{{CheckoutCartProductSection.productSubtotalByName($$createSimpleProduct.name$$)}}" stepKey="grabTextFromSubtotalField6"/> <assertEquals message="Shopping cart should contain subtotal $1,500" stepKey="assertSubtotalField6"> @@ -250,8 +247,7 @@ <waitForElementVisible selector="{{AdminProductFormSection.productPrice}}" stepKey="waitForAdminProductFormSectionProductPriceInput"/> <fillField selector="{{AdminProductFormSection.productPrice}}" userInput="200" stepKey="fillProductPrice200"/> <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveButton"/> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToShoppingCartPage4"/> - <waitForPageLoad time="30" stepKey="waitForShoppingCartPagePageLoad4"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToShoppingCartPage4"/> <grabTextFrom selector="{{CheckoutCartProductSection.productSubtotalByName($$createSimpleProduct.name$$)}}" stepKey="grabTextFromSubtotalField7"/> <assertEquals message="Shopping cart should contain subtotal $4,000" stepKey="assertSubtotalField7"> <expectedResult type="string">$4,000.00</expectedResult> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminBackorderAllowedAddProductToCartTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminBackorderAllowedAddProductToCartTest.xml index 2640ab04023a3..c96636d5f9dcd 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminBackorderAllowedAddProductToCartTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminBackorderAllowedAddProductToCartTest.xml @@ -41,8 +41,7 @@ </actionGroup> <!-- Go to the cart page and verify we see the product --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="gotoCart"/> - <waitForPageLoad stepKey="waitForCartLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="gotoCart"/> <actionGroup ref="AssertStorefrontCheckoutCartItemsActionGroup" stepKey="assertProductItemInCheckOutCart"> <argument name="productName" value="$$createProduct.name$$"/> <argument name="productSku" value="$$createProduct.sku$$"/> diff --git a/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml b/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml index b291fb46ae71c..d11a0d8860f00 100644 --- a/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml +++ b/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml @@ -103,7 +103,7 @@ <selectOption userInput="$$createConfigProductAttributeOption1.option[store_labels][1][label]$$" selector="{{StorefrontProductInfoMainSection.optionByAttributeId($$createConfigProductAttribute.attribute_id$$)}}" stepKey="configProductFillOption" /> <click stepKey="addSimpleProductToCart" selector="{{StorefrontProductActionSection.addToCart}}"/> <waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" time="30" stepKey="waitForProductAdded"/> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToShoppingCartPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToShoppingCartPage"/> <actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/> <waitForElement selector="{{CheckoutShippingMethodsSection.next}}" time="30" stepKey="waitForNextButton"/> <click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleByPercentTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleByPercentTest.xml index 8c3d1dad1b2a3..b30fbaee098e4 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleByPercentTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleByPercentTest.xml @@ -63,8 +63,7 @@ <!-- Add the product to cart and check that the price is correct there --> <click stepKey="addToCart" selector="{{StorefrontProductActionSection.addToCart}}"/> <waitForPageLoad stepKey="waitForAddedToCart"/> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCheckout"/> - <waitForPageLoad stepKey="waitForCart"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckout"/> <see stepKey="seeNewPriceInCart" selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$110.70"/> </test> </tests> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/CheckoutSpecificDestinationsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/CheckoutSpecificDestinationsTest.xml index 58a44f5b89f90..6a403001e76e6 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/CheckoutSpecificDestinationsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/CheckoutSpecificDestinationsTest.xml @@ -48,8 +48,7 @@ </actionGroup> <!--Go to shopping cart--> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/> - + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnPageShoppingCart"/> <!--Verify country options in checkout top destination section--> <actionGroup ref="VerifyTopDestinationsCountryActionGroup" stepKey="verifyTopDestinationsCountry"> <argument name="country" value="Bahamas"/> @@ -68,7 +67,7 @@ </actionGroup> <!--Go to shopping cart--> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart2"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnPageShoppingCart2"/> <!--Verify country options is shown by default--> <actionGroup ref="VerifyTopDestinationsCountryActionGroup" stepKey="verifyTopDestinationsCountry2"> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleDynamicProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleDynamicProductFromShoppingCartTest.xml index ef5f5b640b0a2..2f1b1957d9101 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleDynamicProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleDynamicProductFromShoppingCartTest.xml @@ -60,8 +60,7 @@ </actionGroup> <!-- Remove product from cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCart"/> - <waitForPageLoad stepKey="waitForCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> <actionGroup ref="DeleteProductFromShoppingCartActionGroup" stepKey="deleteProduct"> <argument name="productName" value="$$createBundleDynamicProduct.name$$"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleFixedProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleFixedProductFromShoppingCartTest.xml index e141d0628cc4d..a089de795248f 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleFixedProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleFixedProductFromShoppingCartTest.xml @@ -52,8 +52,7 @@ </actionGroup> <!-- Remove product from cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCart"/> - <waitForPageLoad stepKey="waitForCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> <actionGroup ref="DeleteProductFromShoppingCartActionGroup" stepKey="deleteProduct"> <argument name="productName" value="$$createFixedBundleProduct.name$$"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteConfigurableProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteConfigurableProductFromShoppingCartTest.xml index 62fa3063de08a..3ede19a097750 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteConfigurableProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteConfigurableProductFromShoppingCartTest.xml @@ -74,8 +74,7 @@ </actionGroup> <!-- Remove product from cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCart"/> - <waitForPageLoad stepKey="waitForCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> <actionGroup ref="DeleteProductFromShoppingCartActionGroup" stepKey="deleteProduct"> <argument name="productName" value="$$createConfigProduct.name$$"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteDownloadableProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteDownloadableProductFromShoppingCartTest.xml index 988e3b8d3129d..2f67e780f9536 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteDownloadableProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteDownloadableProductFromShoppingCartTest.xml @@ -44,8 +44,7 @@ </actionGroup> <!-- Remove product from cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCart"/> - <waitForPageLoad stepKey="waitForCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> <actionGroup ref="DeleteProductFromShoppingCartActionGroup" stepKey="deleteProduct"> <argument name="productName" value="$$createDownloadableProduct.name$$"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteGroupedProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteGroupedProductFromShoppingCartTest.xml index eb8e753ea0b79..6ef54f4ee180c 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteGroupedProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteGroupedProductFromShoppingCartTest.xml @@ -58,8 +58,7 @@ </actionGroup> <!-- Remove products from cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCart"/> - <waitForPageLoad stepKey="waitForCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> <click selector="{{CheckoutCartProductSection.removeProductByName($$createFirstSimpleProduct.name$$)}}" stepKey="deleteFirstProductFromCheckoutCart"/> <click selector="{{CheckoutCartProductSection.removeProductByName($$createSecondSimpleProduct.name$$)}}" stepKey="deleteSecondProductFromCheckoutCart"/> <click selector="{{CheckoutCartProductSection.removeProductByName($$createThirdSimpleProduct.name$$)}}" stepKey="deleteThirdProductFromCheckoutCart"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteVirtualProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteVirtualProductFromShoppingCartTest.xml index 969a827a8a461..edcad241dfaf8 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteVirtualProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteVirtualProductFromShoppingCartTest.xml @@ -38,8 +38,7 @@ </actionGroup> <!-- Remove product from cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCart"/> - <waitForPageLoad stepKey="waitForCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> <actionGroup ref="DeleteProductFromShoppingCartActionGroup" stepKey="deleteProduct"> <argument name="productName" value="$$createVirtualProduct.name$$"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml index 984f8933efa76..f34d1d101f8b6 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml @@ -115,8 +115,7 @@ <argument name="Customer" value="$$createFirstCustomer$$"/> </actionGroup> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/> - <waitForPageLoad stepKey="waitForCheckoutPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnPageShoppingCart"/> <!-- Assert first products present in shopping cart --> <actionGroup ref="StorefrontCheckCartSimpleProductActionGroup" stepKey="checkFirstProductInCart"> @@ -155,8 +154,7 @@ </actionGroup> <!-- Assert first products present in shopping cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnShoppingCartPage"/> - <waitForPageLoad stepKey="waitForShoppingCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnShoppingCartPage"/> <actionGroup ref="StorefrontCheckCartSimpleProductActionGroup" stepKey="checkProductInCart"> <argument name="product" value="$$createSimpleProduct$$"/> <argument name="productQuantity" value="quoteQty2Price123.qty"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontFreeShippingRecalculationAfterCouponCodeAddedTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontFreeShippingRecalculationAfterCouponCodeAddedTest.xml index 57ed8e442af7c..72c6cebe7748a 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontFreeShippingRecalculationAfterCouponCodeAddedTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontFreeShippingRecalculationAfterCouponCodeAddedTest.xml @@ -64,8 +64,7 @@ <actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart1"/> <waitForPageLoad stepKey="waitForpageLoad1"/> <dontSee selector="{{CheckoutShippingMethodsSection.shippingMethodRowByName('Free')}}" stepKey="dontSeeFreeShipping"/> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToShoppingCartPage"/> - <waitForPageLoad stepKey="waitForShoppingCartPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToShoppingCartPage"/> <conditionalClick selector="{{DiscountSection.DiscountTab}}" dependentSelector="{{DiscountSection.CouponInput}}" visible="false" stepKey="clickIfDiscountTabClosed1"/> <waitForPageLoad stepKey="waitForCouponTabOpen1"/> <click selector="{{DiscountSection.CancelCoupon}}" stepKey="cancelCoupon"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutDataWhenChangeQtyTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutDataWhenChangeQtyTest.xml index 9b536882dc64b..f2e7841327901 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutDataWhenChangeQtyTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutDataWhenChangeQtyTest.xml @@ -65,8 +65,7 @@ <seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/> <!--Go to cart page, update qty and proceed to checkout--> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/> - <waitForPageLoad stepKey="waitForCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> <see userInput="Shopping Cart" stepKey="seeCartPageIsOpened"/> <fillField selector="{{CheckoutCartProductSection.qty($$createProduct.name$$)}}" userInput="2" stepKey="updateProductQty"/> <click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="clickUpdateShoppingCart"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontPersistentDataForGuestCustomerWithPhysicalQuoteTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontPersistentDataForGuestCustomerWithPhysicalQuoteTest.xml index 391cfd254101a..131fe0ce875c7 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontPersistentDataForGuestCustomerWithPhysicalQuoteTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontPersistentDataForGuestCustomerWithPhysicalQuoteTest.xml @@ -35,7 +35,7 @@ <argument name="product" value="$$createProduct$$"/> </actionGroup> <!-- 2. Go to Shopping Cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCheckoutCartIndexPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckoutCartIndexPage"/> <!-- 3. Open "Estimate Shipping and Tax" section and input data --> <actionGroup ref="StorefrontCartEstimateShippingAndTaxActionGroup" stepKey="fillEstimateShippingAndTaxSection"/> <actionGroup ref="StorefrontAssertShippingMethodPresentInCartActionGroup" stepKey="assertShippingMethodFlatRateIsPresentInCart"> @@ -78,7 +78,7 @@ <argument name="shippingMethod" value="Free Shipping"/> </actionGroup> <!-- 11. Go back to the shopping cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCheckoutCartIndexPage1"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckoutCartIndexPage1"/> <actionGroup ref="StorefrontAssertCartEstimateShippingAndTaxActionGroup" stepKey="assertCartEstimateShippingAndTaxAfterGoingBackToShoppingCart"> <argument name="customerData" value="Simple_UK_Customer_For_Shipment"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml index d166bfdac0ba4..10fb22e9d58a0 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml @@ -36,8 +36,7 @@ </after> <!-- Go to the shopping cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/> - <waitForPageLoad stepKey="waitForCheckoutPageLoad1"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnPageShoppingCart"/> <!-- Change the product QTY --> <fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="{{quoteQty3Price123.qty}}" stepKey="changeCartQty"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml index 91a601dc6ef52..e5059e19a4b39 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml @@ -43,8 +43,7 @@ </after> <!-- Go to the shopping cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/> - <waitForPageLoad stepKey="waitForCheckoutPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnPageShoppingCart"/> <!-- Change the product QTY --> <fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="{{quoteQty11Subtotal1320.qty}}" stepKey="changeCartQty"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml index bceabb27e3ae7..b0c8d53d5a4f6 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml @@ -131,8 +131,7 @@ <waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" stepKey="waitForSuccessMessage"/> <!-- Assert configurable product in cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnShoppingCartPage"/> - <waitForPageLoad stepKey="waitForShoppingCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnShoppingCartPage"/> <actionGroup ref="StorefrontCheckCartConfigurableProductActionGroup" stepKey="storefrontCheckCartConfigurableProductActionGroup"> <argument name="product" value="ApiConfigurableProduct"/> <argument name="optionProduct" value="colorConfigurableProductAttribute1"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml index 9bb5b5073215b..9c939a9a66ddb 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml @@ -113,8 +113,7 @@ <waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" stepKey="waitForSuccessMessage"/> <!-- Assert configurable product in cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnShoppingCartPage"/> - <waitForPageLoad stepKey="waitForShoppingCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnShoppingCartPage"/> <actionGroup ref="StorefrontCheckCartConfigurableProductActionGroup" stepKey="storefrontCheckCartConfigurableProductActionGroup"> <argument name="product" value="ApiConfigurableProduct"/> <argument name="optionProduct" value="colorConfigurableProductAttribute1"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml index e983559fb6bcf..42491d3efdba6 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml @@ -65,8 +65,7 @@ <see selector="{{StorefrontProductPageSection.messagesBlock}}" userInput="You added {{BaseConfigurableProduct.name}} to your shopping cart." stepKey="seeSuccessMessage"/> <!--Check item in cart--> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCart"/> - <waitForPageLoad stepKey="waitForCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> <seeElement selector="{{CheckoutCartProductSection.ProductLinkByName(BaseConfigurableProduct.name)}}" stepKey="seeProductInCart"/> <see selector="{{CheckoutCartProductSection.ProductOptionByNameAndAttribute(BaseConfigurableProduct.name, colorProductAttribute.default_label)}}" userInput="{{colorProductAttribute2.name}}" stepKey="seeSelectedOption"/> <see selector="{{CheckoutCartProductSection.ProductOptionByNameAndAttribute(BaseConfigurableProduct.name, ProductOptionFile.title)}}" userInput="{{MagentoLogo.file}}" stepKey="seeCorrectOptionFile"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml index 9ae046210181b..958d798f6476f 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml @@ -97,8 +97,7 @@ </actionGroup> <!-- Assert product price in cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="openShoppingCartPage"/> - <waitForPageLoad stepKey="waitForShoppingCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="openShoppingCartPage"/> <see selector="{{CheckoutCartProductSection.ProductPriceByName(DownloadableProduct.name)}}" userInput="$51.99" stepKey="assertProductPriceInCart"/> </test> </tests> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml index 30e31be6c8ec4..7443a3803ce54 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml @@ -95,8 +95,7 @@ </actionGroup> <!-- Step 4: Open cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="openShoppingCartPage"/> - <waitForPageLoad stepKey="waitForShoppingCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="openShoppingCartPage"/> <see selector="{{CheckoutCartProductSection.ProductPriceByName(DownloadableProduct.name)}}" userInput="$51.99" stepKey="assertProductPriceInCart"/> diff --git a/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontProcessMultishippingCheckoutWhenCartPageIsOpenedInAnotherTabTest.xml b/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontProcessMultishippingCheckoutWhenCartPageIsOpenedInAnotherTabTest.xml index 2925f2c5b1690..f4c58ca498a94 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontProcessMultishippingCheckoutWhenCartPageIsOpenedInAnotherTabTest.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontProcessMultishippingCheckoutWhenCartPageIsOpenedInAnotherTabTest.xml @@ -59,9 +59,8 @@ <argument name="product" value="$$createSecondProduct$$"/> <argument name="productCount" value="2"/> </actionGroup> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnShoppingCartPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnShoppingCartPage"/> <!-- Click 'Check Out with Multiple Addresses' --> - <waitForPageLoad stepKey="waitForSecondPageLoad"/> <actionGroup ref="StorefrontGoCheckoutWithMultipleAddressesActionGroup" stepKey="goCheckoutWithMultipleAddresses"/> <!-- Select different addresses and click 'Go to Shipping Information' --> <actionGroup ref="StorefrontCheckoutShippingSelectMultipleAddressesActionGroup" stepKey="selectMultipleAddresses"> @@ -71,7 +70,7 @@ <waitForPageLoad stepKey="waitPageLoad"/> <!-- Open the Cart page in another browser window and go back --> <openNewTab stepKey="openNewTab"/> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnShoppingCartPageNewTab"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnShoppingCartPageNewTab"/> <actionGroup ref="AssertStorefrontCheckoutCartItemsActionGroup" stepKey="assertFirstProductItemInCheckOutCart"> <argument name="productName" value="$$createFirstProduct.name$$"/> <argument name="productSku" value="$$createFirstProduct.sku$$"/> diff --git a/app/code/Magento/OfflineShipping/Test/Mftf/Test/StorefrontFreeShippingDisplayWithInclTaxOptionTest.xml b/app/code/Magento/OfflineShipping/Test/Mftf/Test/StorefrontFreeShippingDisplayWithInclTaxOptionTest.xml index d2e092283e9bd..487ab5081ee70 100644 --- a/app/code/Magento/OfflineShipping/Test/Mftf/Test/StorefrontFreeShippingDisplayWithInclTaxOptionTest.xml +++ b/app/code/Magento/OfflineShipping/Test/Mftf/Test/StorefrontFreeShippingDisplayWithInclTaxOptionTest.xml @@ -45,8 +45,7 @@ <argument name="product" value="$$createSimpleProduct$$"/> </actionGroup> <!-- Assert that taxes are applied correctly for CA --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCheckout"/> - <waitForPageLoad stepKey="waitForCart"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckout"/> <waitForElementVisible selector="{{CheckoutPaymentSection.tax}}" stepKey="waitForOverviewVisible"/> <waitForElement time="30" selector="{{CheckoutCartSummarySection.estimateShippingAndTaxForm}}" stepKey="waitForEstimateShippingAndTaxForm"/> <waitForElement time="30" selector="{{CheckoutCartSummarySection.shippingMethodForm}}" stepKey="waitForShippingMethodForm"/> diff --git a/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontVerifyThatInformationAboutViewingComparisonWishlistIsPersistedUnderLongTermCookieTest.xml b/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontVerifyThatInformationAboutViewingComparisonWishlistIsPersistedUnderLongTermCookieTest.xml index 159f0c295a5b9..ea72649cf70bb 100644 --- a/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontVerifyThatInformationAboutViewingComparisonWishlistIsPersistedUnderLongTermCookieTest.xml +++ b/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontVerifyThatInformationAboutViewingComparisonWishlistIsPersistedUnderLongTermCookieTest.xml @@ -128,7 +128,7 @@ </actionGroup> <!--Place the order--> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToShoppingCartPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToShoppingCartPage"/> <actionGroup ref="PlaceOrderWithLoggedUserActionGroup" stepKey="placeOrder"> <argument name="shippingMethod" value="Flat Rate"/> </actionGroup> diff --git a/app/code/Magento/Quote/Test/Mftf/Test/StorefrontGuestCheckoutDisabledProductTest.xml b/app/code/Magento/Quote/Test/Mftf/Test/StorefrontGuestCheckoutDisabledProductTest.xml index 12427c2caec25..cbd6b80de4bbb 100644 --- a/app/code/Magento/Quote/Test/Mftf/Test/StorefrontGuestCheckoutDisabledProductTest.xml +++ b/app/code/Magento/Quote/Test/Mftf/Test/StorefrontGuestCheckoutDisabledProductTest.xml @@ -133,7 +133,7 @@ <argument name="product" value="$$createSimpleProduct2$$"/> <argument name="productCount" value="1"/> </actionGroup> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCheckoutCartPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckoutCartPage"/> <!-- Disabled via admin panel --> <openNewTab stepKey="openNewTab2"/> <!-- Find the first simple product that we just created using the product grid and go to its page --> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleEmptyFromDateTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleEmptyFromDateTest.xml index 67e75d63e016e..36cae1fb3d8ce 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleEmptyFromDateTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleEmptyFromDateTest.xml @@ -86,8 +86,7 @@ <click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/> <waitForPageLoad stepKey="waitForAddToCart"/> <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/> - <waitForPageLoad stepKey="waitForCartPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> <actionGroup ref="StorefrontApplyCouponActionGroup" stepKey="applyCoupon"> <argument name="coupon" value="_defaultCoupon"/> </actionGroup> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForCouponCodeTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForCouponCodeTest.xml index 2bf96cf0377d4..983397f672673 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForCouponCodeTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForCouponCodeTest.xml @@ -78,8 +78,7 @@ <click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/> <waitForPageLoad stepKey="waitForAddToCart"/> <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/> - <waitForPageLoad stepKey="waitForCartPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> <actionGroup ref="StorefrontApplyCouponActionGroup" stepKey="applyCoupon"> <argument name="coupon" value="_defaultCoupon"/> </actionGroup> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml index 9833231f8ed84..4e820833dbc31 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml @@ -80,8 +80,7 @@ <click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/> <waitForPageLoad stepKey="waitForAddToCart"/> <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/> - <waitForPageLoad stepKey="waitForCartPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> <conditionalClick selector="{{StorefrontSalesRuleCartCouponSection.couponHeader}}" dependentSelector="{{StorefrontSalesRuleCartCouponSection.discountBlockActive}}" visible="false" stepKey="clickCouponHeader"/> <waitForElementVisible selector="{{StorefrontSalesRuleCartCouponSection.couponField}}" stepKey="waitForCouponField" /> <fillField selector="{{StorefrontSalesRuleCartCouponSection.couponField}}" userInput="{$grabCouponCode}" stepKey="fillCouponField"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleCountryTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleCountryTest.xml index 4cc331eebc4ee..1d23fbccb6032 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleCountryTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleCountryTest.xml @@ -71,8 +71,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <!-- Should not see the discount yet because we have not set country --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/> - <waitForPageLoad stepKey="waitForCartPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> <click selector="{{CheckoutCartSummarySection.shippingHeading}}" stepKey="openEstimateShippingSection"/> <checkOption selector="{{CheckoutCartSummarySection.flatRateShippingMethod}}" stepKey="selectFlatRateShipping"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$123.00" stepKey="seeSubtotal"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRulePostcodeTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRulePostcodeTest.xml index 4d987c00884e1..86187aba4be45 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRulePostcodeTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRulePostcodeTest.xml @@ -75,8 +75,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <!-- Should not see the discount yet because we have not filled in postcode --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/> - <waitForPageLoad stepKey="waitForCartPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> <click selector="{{CheckoutCartSummarySection.shippingHeading}}" stepKey="openEstimateShippingSection"/> <checkOption selector="{{CheckoutCartSummarySection.flatRateShippingMethod}}" stepKey="selectFlatRateShipping"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$123.00" stepKey="seeSubtotal"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleQuantityTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleQuantityTest.xml index ff0e011210785..928c47692764f 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleQuantityTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleQuantityTest.xml @@ -73,8 +73,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <!-- Should not see the discount yet because we have only 1 item in our cart --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/> - <waitForPageLoad stepKey="waitForCartPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$123.00" stepKey="seeSubtotal"/> <dontSeeElement selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="dontSeeDiscount"/> @@ -87,8 +86,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage2"/> <!-- Now we should see the discount because we have more than 1 item --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage2"/> - <waitForPageLoad stepKey="waitForCartPage2"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage2"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$246.00" stepKey="seeSubtotal2"/> <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/> <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$1.00" stepKey="seeDiscountTotal"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleStateTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleStateTest.xml index 036844562af50..58a81997e1474 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleStateTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleStateTest.xml @@ -71,8 +71,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <!-- Should not see the discount yet because we have not filled in postcode --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/> - <waitForPageLoad stepKey="waitForCartPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> <click selector="{{CheckoutCartSummarySection.shippingHeading}}" stepKey="expandShipping"/> <checkOption selector="{{CheckoutCartSummarySection.flatRateShippingMethod}}" stepKey="selectFlatRateShipping"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$123.00" stepKey="seeSubtotal"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleSubtotalTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleSubtotalTest.xml index efd82316f0b0a..b261c2da788fc 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleSubtotalTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleSubtotalTest.xml @@ -71,8 +71,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <!-- Should not see the discount yet because we have not exceeded $200 --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage"/> - <waitForPageLoad stepKey="waitForCartPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$123.00" stepKey="seeSubtotal"/> <dontSeeElement selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="dontSeeDiscount"/> @@ -85,8 +84,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage2"/> <!-- Now we should see the discount because we exceeded $200 --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCartPage2"/> - <waitForPageLoad stepKey="waitForCartPage2"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage2"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$246.00" stepKey="seeSubtotal2"/> <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/> <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$0.01" stepKey="seeDiscountTotal"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml index 172f6b6ba24c6..7217d3975df5a 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml @@ -113,8 +113,7 @@ </actionGroup> <see selector="{{StorefrontMinicartSection.quantity}}" userInput="6" stepKey="seeCartQuantity"/> <!-- Go to the shopping cart page --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/> - <waitForPageLoad stepKey="waitForCheckoutPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnPageShoppingCart"/> <waitForElementVisible selector="{{CheckoutCartSummarySection.orderTotal}}" stepKey="waitForOrderTotalVisible"/> <selectOption selector="{{CheckoutCartSummarySection.country}}" userInput="United States" stepKey="selectCountry"/> <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForOrderTotalUpdate"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontCustomerCanChangeProductOptionsUsingSwatchesTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontCustomerCanChangeProductOptionsUsingSwatchesTest.xml index 32e447f6463c0..39c8d09896f8b 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontCustomerCanChangeProductOptionsUsingSwatchesTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontCustomerCanChangeProductOptionsUsingSwatchesTest.xml @@ -44,7 +44,7 @@ </actionGroup> <!-- Go to shopping cart and update option of configurable product --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="openShoppingCartPage"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="openShoppingCartPage"/> <actionGroup ref="StorefrontUpdateCartConfigurableProductWithSwatchesActionGroup" stepKey="updateConfigurableProductInTheCart"> <argument name="product" value="_defaultProduct"/> <argument name="productOption" value="e74d3c"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchProductWithFileCustomOptionTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchProductWithFileCustomOptionTest.xml index e027a41cd9d2a..03a1723de9530 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchProductWithFileCustomOptionTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchProductWithFileCustomOptionTest.xml @@ -76,8 +76,7 @@ <see selector="{{StorefrontProductPageSection.messagesBlock}}" userInput="You added {{BaseConfigurableProduct.name}} to your shopping cart." stepKey="seeSuccessMessage"/> <!--Check item in cart--> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCart"/> - <waitForPageLoad stepKey="waitForCartPageLoad"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> <seeElement selector="{{CheckoutCartProductSection.ProductLinkByName(BaseConfigurableProduct.name)}}" stepKey="seeProductInCart"/> <see selector="{{CheckoutCartProductSection.ProductOptionByNameAndAttribute(BaseConfigurableProduct.name, visualSwatchAttribute.default_label)}}" userInput="{{visualSwatchOption2.default_label}}" stepKey="seeSelectedSwatch"/> <see selector="{{CheckoutCartProductSection.ProductOptionByNameAndAttribute(BaseConfigurableProduct.name, ProductOptionFile.title)}}" userInput="{{MagentoLogo.file}}" stepKey="seeCorrectOptionFile"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestSimpleTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestSimpleTest.xml index 959aa323308be..705ffbc4a5a25 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestSimpleTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestSimpleTest.xml @@ -82,8 +82,7 @@ <see stepKey="seeSuccess" selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You added"/> <!-- Assert that taxes are applied correctly for CA --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCheckout"/> - <waitForPageLoad stepKey="waitForCart"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckout"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/> <waitForElementVisible stepKey="waitForOverviewVisible" selector="{{CheckoutPaymentSection.tax}}"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestVirtualTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestVirtualTest.xml index c1268638c7104..5963b4ecd7ca5 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestVirtualTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestVirtualTest.xml @@ -82,8 +82,7 @@ <see stepKey="seeSuccess" selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You added"/> <!-- Assert that taxes are applied correctly for NY --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCheckout"/> - <waitForPageLoad stepKey="waitForCart"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckout"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/> <!-- Assert that taxes are applied correctly for CA --> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInSimpleTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInSimpleTest.xml index e43511318f137..426c6e6dfb85d 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInSimpleTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInSimpleTest.xml @@ -96,8 +96,7 @@ <see stepKey="seeSuccess" selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You added"/> <!-- Assert that taxes are applied correctly for NY --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCheckout"/> - <waitForPageLoad stepKey="waitForCart"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckout"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/> <waitForElementVisible stepKey="waitForOverviewVisible" selector="{{CheckoutPaymentSection.tax}}"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInVirtualTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInVirtualTest.xml index 3b92ab3498442..fd2176dc8c713 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInVirtualTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInVirtualTest.xml @@ -95,8 +95,7 @@ <see stepKey="seeSuccess" selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You added"/> <!-- Assert that taxes are applied correctly for NY --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCheckout"/> - <waitForPageLoad stepKey="waitForCart"/> + <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckout"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/> <waitForElementVisible stepKey="waitForOverviewVisible" selector="{{CheckoutPaymentSection.tax}}"/> From 48b65332a658f40e57407f187f38bd4268a0d537 Mon Sep 17 00:00:00 2001 From: Soumya Unnikrishnan <sunnikri@adobe.com> Date: Mon, 13 Apr 2020 11:45:00 -0500 Subject: [PATCH 143/177] MQE-2066: [MTF-to-MFTF] Update Created Integration Entity #751 --- .../Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml | 4 ++-- .../AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml | 4 ++-- .../Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml | 4 ++-- .../Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml | 4 ++-- .../Test/AdminMarketingCreateSitemapFailFolderSaveTest.xml | 4 ++-- .../Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml index 41efc72c35fb4..50aa83bc79eed 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityTest.xml @@ -20,7 +20,7 @@ </annotations> <before> <!-- Login As Admin --> - <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> <!-- Navigate To Integrations Page --> <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToIntegrationsPage"> <argument name="menuUiId" value="{{AdminMenuSystem.dataUiId}}"/> @@ -43,7 +43,7 @@ <actionGroup ref="AdminSearchIntegrationInGridActionGroup" stepKey="searchForIntegration"> <argument name="name" value="{{defaultIntegrationData.name}} Updated"/> </actionGroup> - <actionGroup ref="logout" stepKey="logout"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/> </after> <!-- TEST BODY --> diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml index 403e886ea8209..4be4301146a04 100644 --- a/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml +++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminUpdateIntegrationEntityWithIncorrectPasswordTest.xml @@ -20,7 +20,7 @@ </annotations> <before> <!-- Login As Admin --> - <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> <!-- Navigate To Integrations Page --> <actionGroup ref="AdminNavigateMenuActionGroup" stepKey="navigateToIntegrationsPage"> <argument name="menuUiId" value="{{AdminMenuSystem.dataUiId}}"/> @@ -36,7 +36,7 @@ <actionGroup ref="AdminSubmitNewIntegrationFormActionGroup" stepKey="submitTheForm"/> </before> <after> - <actionGroup ref="logout" stepKey="logout"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/> </after> <!-- TEST BODY --> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml index 16bd135163307..d3ebe3cbc30de 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/AdminMarketingCreateNewsletterTemplateTest.xml @@ -21,7 +21,7 @@ <group value="WYSIWYGDisabled"/> </annotations> <before> - <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> </before> <after> <!-- Delete Created Newsletter Template --> @@ -31,7 +31,7 @@ </actionGroup> <actionGroup ref="AdminMarketingOpenNewsletterTemplateFromGridActionGroup" stepKey="openTemplate"/> <actionGroup ref="AdminMarketingDeleteNewsletterTemplateActionGroup" stepKey="deleteTemplate"/> - <actionGroup ref="logout" stepKey="logout"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/> </after> <!--TEST BODY --> <!-- Navigate To MARKETING > Newsletter Template --> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml index edd20737eb0a7..94f0e0a0487d6 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapEntityTest.xml @@ -19,13 +19,13 @@ <group value="mtf_migrated"/> </annotations> <before> - <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> </before> <after> <actionGroup ref="AdminMarketingSiteDeleteByNameActionGroup" stepKey="deleteCreatedSitemap"> <argument name="filename" value="sitemap.xml"/> </actionGroup> - <actionGroup ref="logout" stepKey="logout"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/> </after> <!--TEST BODY --> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailFolderSaveTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailFolderSaveTest.xml index 530e813ae440a..ae51db561e27c 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailFolderSaveTest.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapFailFolderSaveTest.xml @@ -19,10 +19,10 @@ <group value="mtf_migrated"/> </annotations> <before> - <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> </before> <after> - <actionGroup ref="logout" stepKey="logout"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/> </after> <!--TEST BODY --> diff --git a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml index 656502e09ad63..2300e05adce1d 100644 --- a/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml +++ b/app/code/Magento/Sitemap/Test/Mftf/Test/AdminMarketingCreateSitemapPathErrorTest.xml @@ -19,10 +19,10 @@ <group value="mtf_migrated"/> </annotations> <before> - <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> </before> <after> - <actionGroup ref="logout" stepKey="logout"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/> </after> <!--TEST BODY --> From a80b84d4eb4ee0c53aa0e717377c80f921caf7c8 Mon Sep 17 00:00:00 2001 From: Slava Mankivski <mankivsk@adobe.com> Date: Mon, 13 Apr 2020 13:25:38 -0500 Subject: [PATCH 144/177] Update ObserverTest.php Fixed PHPUnit_Framework_MockObject_MockObject usages --- .../Sitemap/Test/Unit/Model/ObserverTest.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php b/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php index 8ab8cbfb6122b..7d2bdcc93b686 100644 --- a/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php +++ b/app/code/Magento/Sitemap/Test/Unit/Model/ObserverTest.php @@ -28,37 +28,37 @@ class ObserverTest extends \PHPUnit\Framework\TestCase private $observer; /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit\Framework\MockObject\MockObject */ private $scopeConfigMock; /** - * @var \Magento\Sitemap\Model\ResourceModel\Sitemap\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Sitemap\Model\ResourceModel\Sitemap\CollectionFactory|\PHPUnit\Framework\MockObject\MockObject */ private $collectionFactoryMock; /** - * @var \Magento\Sitemap\Model\ResourceModel\Sitemap\Collection|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Sitemap\Model\ResourceModel\Sitemap\Collection|\PHPUnit\Framework\MockObject\MockObject */ private $sitemapCollectionMock; /** - * @var \Magento\Sitemap\Model\Sitemap|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Sitemap\Model\Sitemap|\PHPUnit\Framework\MockObject\MockObject */ private $sitemapMock; /** - * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit\Framework\MockObject\MockObject */ private $objectManagerMock; /** - * @var Emulation|\PHPUnit_Framework_MockObject_MockObject + * @var Emulation|\PHPUnit\Framework\MockObject\MockObject */ private $appEmulationMock; /** - * @var EmailNotification|\PHPUnit_Framework_MockObject_MockObject + * @var EmailNotification|\PHPUnit\Framework\MockObject\MockObject */ private $emailNotificationMock; From 8ad6be2a682e915d09e85f60a19959bae4590c30 Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets <vzaets@magento.com> Date: Tue, 14 Apr 2020 00:24:48 -0500 Subject: [PATCH 145/177] - add bulk operations - add asset-content link entity - refactoring --- .../MediaContent/Model/Content/Config.php | 20 +--- .../Model/Content/Config/Converter.php | 13 ++- .../Model/Content/ConfigInterface.php | 20 ++++ .../MediaContent/Model/ContentAssetLink.php | 110 ++++++++++++++++++ .../Model/DeleteContentAssetLinks.php | 87 ++++++++++++++ .../Model/SaveContentAssetLinks.php | 79 +++++++++++++ app/code/Magento/MediaContent/etc/di.xml | 4 + .../Api/Data/ContentAssetLinkInterface.php | 52 +++++++++ .../Api/DeleteContentAssetLinksInterface.php | 26 +++++ .../Api/SaveContentAssetLinksInterface.php | 26 +++++ .../MediaContentApi/etc/media_content.xsd | 17 ++- 11 files changed, 436 insertions(+), 18 deletions(-) create mode 100644 app/code/Magento/MediaContent/Model/Content/ConfigInterface.php create mode 100644 app/code/Magento/MediaContent/Model/ContentAssetLink.php create mode 100644 app/code/Magento/MediaContent/Model/DeleteContentAssetLinks.php create mode 100644 app/code/Magento/MediaContent/Model/SaveContentAssetLinks.php create mode 100644 app/code/Magento/MediaContentApi/Api/Data/ContentAssetLinkInterface.php create mode 100644 app/code/Magento/MediaContentApi/Api/DeleteContentAssetLinksInterface.php create mode 100644 app/code/Magento/MediaContentApi/Api/SaveContentAssetLinksInterface.php diff --git a/app/code/Magento/MediaContent/Model/Content/Config.php b/app/code/Magento/MediaContent/Model/Content/Config.php index 166a1f8166d7d..63f1668954f76 100644 --- a/app/code/Magento/MediaContent/Model/Content/Config.php +++ b/app/code/Magento/MediaContent/Model/Content/Config.php @@ -12,7 +12,7 @@ /** * Media content configuration */ -class Config +class Config implements ConfigInterface { private const XML_PATH_SEARCH_PATTERNS = 'search/patterns'; @@ -30,24 +30,12 @@ public function __construct(DataInterface $data) } /** - * Get config value by key. - * - * @param string|null $key - * @param string|null $default - * @return array - */ - public function get($key = null, $default = null) - { - return $this->data->get($key, $default); - } - - /** - * Retrieve search regexp patterns for finding media asset paths within content + * Retrieve search RegExp patterns for finding media asset paths within content * * @return array */ public function getSearchPatterns(): array { - return $this->get(self::XML_PATH_SEARCH_PATTERNS); + return $this->data->get(self::XML_PATH_SEARCH_PATTERNS); } -} \ No newline at end of file +} diff --git a/app/code/Magento/MediaContent/Model/Content/Config/Converter.php b/app/code/Magento/MediaContent/Model/Content/Config/Converter.php index 16658d0299b05..854d10c8d9812 100644 --- a/app/code/Magento/MediaContent/Model/Content/Config/Converter.php +++ b/app/code/Magento/MediaContent/Model/Content/Config/Converter.php @@ -14,8 +14,19 @@ */ class Converter implements ConverterInterface { + /* + * Search tag name + */ private const SEARCH_TAG_NAME = 'search'; + + /** + * Patterns tag name + */ private const PATTERNS_TAG_NAME = 'patterns'; + + /** + * Pattern tag name + */ private const PATTERN_TAG_NAME = 'pattern'; /** @@ -29,7 +40,7 @@ public function convert($source) : array $result = []; if (!$source instanceof \DOMDocument) { - return $result; + throw new \InvalidArgumentException('The source should be instance of DOMDocument'); } foreach ($source->getElementsByTagName(self::SEARCH_TAG_NAME) as $search) { diff --git a/app/code/Magento/MediaContent/Model/Content/ConfigInterface.php b/app/code/Magento/MediaContent/Model/Content/ConfigInterface.php new file mode 100644 index 0000000000000..cd3265626784c --- /dev/null +++ b/app/code/Magento/MediaContent/Model/Content/ConfigInterface.php @@ -0,0 +1,20 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\MediaContent\Model\Content; + +/** + * Interface for Media content Config. + */ +interface ConfigInterface +{ + /** + * Retrieve search regexp patterns for finding media asset paths within content + * + * @return array + */ + public function getSearchPatterns() : array; +} diff --git a/app/code/Magento/MediaContent/Model/ContentAssetLink.php b/app/code/Magento/MediaContent/Model/ContentAssetLink.php new file mode 100644 index 0000000000000..8f7727565f3b3 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/ContentAssetLink.php @@ -0,0 +1,110 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\Framework\Model\AbstractExtensibleModel; +use Magento\Framework\Model\Context; +use Magento\Framework\Registry; +use Magento\Framework\Api\ExtensionAttributesFactory; +use Magento\Framework\Api\AttributeValueFactory; +use Magento\Framework\Model\ResourceModel\AbstractResource; +use Magento\MediaContentApi\Api\Data\ContentAssetLinkInterface; +use Magento\Framework\Data\Collection\AbstractDb; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory; + +/** + * Relation of the media asset to the media content + */ +class ContentAssetLink extends AbstractExtensibleModel implements ContentAssetLinkInterface +{ + private const ASSET_ID = 'asset_id'; + private const ENTITY_TYPE = 'entity_type'; + private const ENTITY_ID = 'entity_id'; + private const FIELD = 'field'; + + /** + * @var ContentIdentityInterfaceFactory + */ + private $contentIdentityFactory; + + /** + * @param \Magento\Framework\Model\Context $context + * @param \Magento\Framework\Registry $registry + * @param ExtensionAttributesFactory $extensionFactory + * @param AttributeValueFactory $customAttributeFactory + * @param ContentIdentityInterfaceFactory $contentIdentityFactory + * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource + * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection + * @param array $data + */ + public function __construct( + Context $context, + Registry $registry, + ExtensionAttributesFactory $extensionFactory, + AttributeValueFactory $customAttributeFactory, + ContentIdentityInterfaceFactory $contentIdentityFactory, + AbstractResource $resource = null, + AbstractDb $resourceCollection = null, + array $data = [] + ) { + $this->contentIdentityFactory = $contentIdentityFactory; + parent::__construct( + $context, + $registry, + $extensionFactory, + $customAttributeFactory, + $resource, + $resourceCollection, + $data + ); + } + + /** + * @inheritdoc + */ + public function getAssetId(): int + { + return (int) $this->getData(self::ASSET_ID); + } + + /** + * @inheritdoc + */ + public function getContentId(): ContentIdentityInterface + { + return $this->contentIdentityFactory->create(['data' => [ + self::ENTITY_TYPE => $this->getData(self::ENTITY_TYPE), + self::ENTITY_ID => $this->getData(self::ENTITY_TYPE), + self::FIELD => $this->getData(self::FIELD) + ]]); + } + + /** + * @inheritdoc + */ + public function getField(): string + { + return (string) $this->getData(self::FIELD); + } + + /** + * @inheritdoc + */ + public function getExtensionAttributes(): ContentAssetLinkExtensionInterface + { + return $this->_getExtensionAttributes(); + } + + /** + * @inheritdoc + */ + public function setExtensionAttributes(ContentAssetLinkExtensionInterface $extensionAttributes): void + { + $this->_setExtensionAttributes($extensionAttributes); + } +} diff --git a/app/code/Magento/MediaContent/Model/DeleteContentAssetLinks.php b/app/code/Magento/MediaContent/Model/DeleteContentAssetLinks.php new file mode 100644 index 0000000000000..578d1c584e373 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/DeleteContentAssetLinks.php @@ -0,0 +1,87 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\MediaContentApi\Api\Data\ContentAssetLinkInterface; +use Magento\MediaContentApi\Api\DeleteContentAssetLinksInterface; +use Psr\Log\LoggerInterface; + +/** + * Used to unassign relation of the media asset to the media content where the media asset is used + */ +class DeleteContentAssetLinks implements DeleteContentAssetLinksInterface +{ + private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; + private const ASSET_ID = 'asset_id'; + private const ENTITY_TYPE = 'entity_type'; + private const ENTITY_ID = 'entity_id'; + private const FIELD = 'field'; + + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * @param ResourceConnection $resourceConnection + * @param LoggerInterface $logger + */ + public function __construct(ResourceConnection $resourceConnection, LoggerInterface $logger) + { + $this->resourceConnection = $resourceConnection; + $this->logger = $logger; + } + + /** + * Remove relation between the media asset and the content. I.e media asset no longer part of the content + * + * @param ContentAssetLinkInterface[] $contentAssetsLinks + * @throws CouldNotDeleteException + */ + public function execute(array $contentAssetsLinks): void + { + $failedLinks = []; + foreach ($contentAssetsLinks as $contentAssetLink) { + try { + $connection = $this->resourceConnection->getConnection(); + $tableName = $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME); + $connection->delete( + $tableName, + [ + self::ASSET_ID . ' = ?' => $contentAssetLink->getAssetId(), + self::ENTITY_TYPE . ' = ?' => $contentAssetLink->getContentId()->getEntityType(), + self::ENTITY_ID . ' = ?' => $contentAssetLink->getContentId()->getEntityId(), + self::FIELD . ' = ?' => $contentAssetLink->getField() + ] + ); + } catch (\Exception $exception) { + $this->logger->critical($exception); + $failedLinks[] = self::ASSET_ID . '=' . $contentAssetLink->getAssetId() . + self::ENTITY_TYPE . ' = ' . $contentAssetLink->getContentId()->getEntityType() . + self::ENTITY_ID . ' = ' . $contentAssetLink->getContentId()->getEntityId() . + self::FIELD . ' = ' . $contentAssetLink->getField(); + } + } + + if (!empty($failedLinks)) { + throw new CouldNotDeleteException( + __( + 'An error occurred at deleting link between the media asset and media content. Links: %links', + implode(' ,', $failedLinks) + ) + ); + } + } +} diff --git a/app/code/Magento/MediaContent/Model/SaveContentAssetLinks.php b/app/code/Magento/MediaContent/Model/SaveContentAssetLinks.php new file mode 100644 index 0000000000000..6c6140ba2b076 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/SaveContentAssetLinks.php @@ -0,0 +1,79 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\MediaContentApi\Api\SaveContentAssetLinksInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; +use Magento\MediaContentApi\Api\Data\ContentAssetLinkInterface; +use Psr\Log\LoggerInterface; + +/** + * Used for saving relation between the media asset and media content where the media asset is used + */ +class SaveContentAssetLinks implements SaveContentAssetLinksInterface +{ + private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; + private const ASSET_ID = 'asset_id'; + private const ENTITY_TYPE = 'entity_type'; + private const ENTITY_ID = 'entity_id'; + private const FIELD = 'field'; + + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * @param ResourceConnection $resourceConnection + * @param LoggerInterface $logger + */ + public function __construct(ResourceConnection $resourceConnection, LoggerInterface $logger) + { + $this->resourceConnection = $resourceConnection; + $this->logger = $logger; + } + + /** + * Save a media asset to content relation. Should be executed when media assets is added to the content + * + * @param ContentAssetLinkInterface[] $contentAssetLinks + * @throws \Magento\Framework\Exception\CouldNotSaveException + */ + public function execute(array $contentAssetsLinks): void + { + try { + $connection = $this->resourceConnection->getConnection(); + $tableName = $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME); + $data = []; + + foreach ($contentAssetsLinks as $contentAssetLink) { + $data[] = [ + self::ASSET_ID => $contentAssetLink->getAssetId(), + self::ENTITY_TYPE => $contentAssetLink->getContentId()->getEntityType(), + self::ENTITY_ID => $contentAssetLink->getContentId()->getEntityId(), + self::FIELD => $contentAssetLink->getField() + ]; + } + + $connection->insertMultiple($tableName, $data); + } catch (\Exception $exception) { + $this->logger->critical($exception); + throw new CouldNotSaveException( + __('An error occurred while saving relation between media asset and media content.'), + $exception + ); + } + } +} diff --git a/app/code/Magento/MediaContent/etc/di.xml b/app/code/Magento/MediaContent/etc/di.xml index c4837a687389b..778cbec07989e 100644 --- a/app/code/Magento/MediaContent/etc/di.xml +++ b/app/code/Magento/MediaContent/etc/di.xml @@ -12,7 +12,11 @@ <preference for="Magento\MediaContentApi\Api\GetContentWithAssetsInterface" type="Magento\MediaContent\Model\GetContentWithAssets"/> <preference for="Magento\MediaContentApi\Api\ExtractAssetsFromContentInterface" type="Magento\MediaContent\Model\ExtractAssetsFromContent"/> <preference for="Magento\MediaContentApi\Api\UpdateRelationsInterface" type="Magento\MediaContent\Model\UpdateRelations"/> + <preference for="Magento\MediaContentApi\Api\DeleteContentAssetLinksInterface" type="Magento\MediaContent\Model\DeleteContentAssetLinks"/> + <preference for="Magento\MediaContentApi\Api\SaveContentAssetLinksInterface" type="Magento\MediaContent\Model\SaveContentAssetLinks"/> <preference for="Magento\MediaContentApi\Api\Data\ContentIdentityInterface" type="Magento\MediaContent\Model\ContentIdentity"/> + <preference for="Magento\MediaContentApi\Api\Data\ContentAssetLinkInterface" type="Magento\MediaContent\Model\ContentAssetLink"/> + <preference for="Magento\MediaContent\Model\Content\ConfigInterface" type="Magento\MediaContent\Model\Content\Config"/> <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface"> <plugin name="remove_media_content_after_asset_is_removed_by_path" type="Magento\MediaContent\Model\MediaGalleryAssetDeleteByPath" /> </type> diff --git a/app/code/Magento/MediaContentApi/Api/Data/ContentAssetLinkInterface.php b/app/code/Magento/MediaContentApi/Api/Data/ContentAssetLinkInterface.php new file mode 100644 index 0000000000000..c3869e151f78c --- /dev/null +++ b/app/code/Magento/MediaContentApi/Api/Data/ContentAssetLinkInterface.php @@ -0,0 +1,52 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\MediaContentApi\Api\Data; + +use Magento\MediaContentApi\Api\Data\ContentAssetLinkExtensionInterface; + +/** + * Data interface representing the identificator of content. I.e. short description field of product entity with id 42 + * @api + */ +interface ContentAssetLinkInterface +{ + /** + * Id of the entity containing content with media + * + * @return int + */ + public function getContentId(): ContentIdentityInterface; + + /** + * Array of assets related to the content entity + * + * @return array + */ + public function getAssetId(): int; + + /** + * @return string + */ + public function getField() : string; + + /** + * Retrieve existing extension attributes object or create a new one. + * + * @return \Magento\MediaContentApi\Api\Data\ContentAssetLinkExtensionInterface|null + */ + public function getExtensionAttributes(): ContentAssetLinkExtensionInterface; + + /** + * Set extension attributes + * + * @param \Magento\MediaContentApi\Api\Data\ContentAssetLinkExtensionInterface $extensionAttributes + * @return void + */ + public function setExtensionAttributes(ContentAssetLinkExtensionInterface $extensionAttributes): void; +} diff --git a/app/code/Magento/MediaContentApi/Api/DeleteContentAssetLinksInterface.php b/app/code/Magento/MediaContentApi/Api/DeleteContentAssetLinksInterface.php new file mode 100644 index 0000000000000..9c50793f51303 --- /dev/null +++ b/app/code/Magento/MediaContentApi/Api/DeleteContentAssetLinksInterface.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\MediaContentApi\Api; + +use Magento\MediaContentApi\Api\Data\ContentAssetLinkInterface; + +/** + * Remove the relation between media asset and the piece of content. I.e media asset no longer part of the content + * @api + */ +interface DeleteContentAssetLinksInterface +{ + /** + * Remove relation between the media asset and the content. I.e media asset no longer part of the content + * + * @param ContentAssetLinkInterface[] $contentAssetLinks + * @throws \Magento\Framework\Exception\CouldNotDeleteException + */ + public function execute(array $contentAssetLinks): void; +} diff --git a/app/code/Magento/MediaContentApi/Api/SaveContentAssetLinksInterface.php b/app/code/Magento/MediaContentApi/Api/SaveContentAssetLinksInterface.php new file mode 100644 index 0000000000000..1c86953ce6f84 --- /dev/null +++ b/app/code/Magento/MediaContentApi/Api/SaveContentAssetLinksInterface.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\MediaContentApi\Api; + +use Magento\MediaContentApi\Api\Data\ContentAssetLinkInterface; + +/** + * Save a media asset to content relation. + * @api + */ +interface SaveContentAssetLinksInterface +{ + /** + * Save a media asset to content relation. Should be executed when media assets is added to the content + * + * @param ContentAssetLinkInterface[] $contentAssetLinks + * @throws \Magento\Framework\Exception\CouldNotSaveException + */ + public function execute(array $contentAssetLinks): void; +} diff --git a/app/code/Magento/MediaContentApi/etc/media_content.xsd b/app/code/Magento/MediaContentApi/etc/media_content.xsd index 39312d6bbf93c..bcc7eb1105072 100644 --- a/app/code/Magento/MediaContentApi/etc/media_content.xsd +++ b/app/code/Magento/MediaContentApi/etc/media_content.xsd @@ -16,12 +16,22 @@ </xs:complexType> <xs:complexType name="searchType"> + <xs:annotation> + <xs:documentation> + Search used for find assets in content + </xs:documentation> + </xs:annotation> <xs:sequence> <xs:element type="patternsType" name="patterns" maxOccurs="unbounded" minOccurs="0"/> </xs:sequence> </xs:complexType> <xs:complexType name="patternsType"> + <xs:annotation> + <xs:documentation> + List of RegExp patterns that used for find assets + </xs:documentation> + </xs:annotation> <xs:sequence> <xs:element type="patternType" name="pattern" maxOccurs="unbounded" minOccurs="0"/> </xs:sequence> @@ -29,9 +39,14 @@ <xs:complexType name="patternType"> <xs:simpleContent> + <xs:annotation> + <xs:documentation> + RegExp pattern that used for find assets + </xs:documentation> + </xs:annotation> <xs:extension base="xs:string"> <xs:attribute type="xs:string" name="name" use="required"/> </xs:extension> </xs:simpleContent> </xs:complexType> -</xs:schema> \ No newline at end of file +</xs:schema> From 2234210fdab5ca3ed52ecce378af0652730f34d9 Mon Sep 17 00:00:00 2001 From: "rostyslav.hymon" <rostyslav.hymon@transoftgroup.com> Date: Tue, 14 Apr 2020 11:05:30 +0300 Subject: [PATCH 146/177] MC-33151: Performance issue caused by checking if DB tables exist on every call --- .../Unit/App/Config/Source/RuntimeConfigSourceTest.php | 10 ++++++---- .../Store/Test/Unit/Model/ResourceModel/StoreTest.php | 10 ++++++---- .../Test/Unit/Model/ResourceModel/WebsiteTest.php | 10 ++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Store/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php b/app/code/Magento/Store/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php index 104c1bbba2614..cf1c4c62787a7 100644 --- a/app/code/Magento/Store/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php +++ b/app/code/Magento/Store/Test/Unit/App/Config/Source/RuntimeConfigSourceTest.php @@ -11,15 +11,17 @@ use Magento\Framework\DB\Adapter\TableNotFoundException; use Magento\Framework\DB\Select; use Magento\Store\App\Config\Source\RuntimeConfigSource; +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\MockObject\MockObject; /** * @SuppressWarnings(PHPMD.ExcessiveParameterList) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class RuntimeConfigSourceTest extends \PHPUnit\Framework\TestCase +class RuntimeConfigSourceTest extends TestCase { /** - * @var DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject + * @var DeploymentConfig|MockObject */ private $deploymentConfig; @@ -29,12 +31,12 @@ class RuntimeConfigSourceTest extends \PHPUnit\Framework\TestCase private $configSource; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ private $connection; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ private $resourceConnection; diff --git a/app/code/Magento/Store/Test/Unit/Model/ResourceModel/StoreTest.php b/app/code/Magento/Store/Test/Unit/Model/ResourceModel/StoreTest.php index b4e6c5af7c9f9..731850ba58dcb 100644 --- a/app/code/Magento/Store/Test/Unit/Model/ResourceModel/StoreTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/ResourceModel/StoreTest.php @@ -11,22 +11,24 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Store\Model\ResourceModel\Store; use Magento\Framework\DB\Adapter\AdapterInterface; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; -class StoreTest extends \PHPUnit\Framework\TestCase +class StoreTest extends TestCase { /** @var Store */ protected $model; /** - * @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject + * @var ResourceConnection|MockObject */ protected $resourceMock; - /** @var Select | \PHPUnit_Framework_MockObject_MockObject */ + /** @var Select | MockObject */ protected $select; /** - * @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + * @var AdapterInterface|MockObject */ protected $connectionMock; diff --git a/app/code/Magento/Store/Test/Unit/Model/ResourceModel/WebsiteTest.php b/app/code/Magento/Store/Test/Unit/Model/ResourceModel/WebsiteTest.php index 3238023cd6e09..6e8049e9e37e5 100644 --- a/app/code/Magento/Store/Test/Unit/Model/ResourceModel/WebsiteTest.php +++ b/app/code/Magento/Store/Test/Unit/Model/ResourceModel/WebsiteTest.php @@ -10,22 +10,24 @@ use Magento\Framework\DB\Select; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Store\Model\ResourceModel\Website; +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\MockObject\MockObject; -class WebsiteTest extends \PHPUnit\Framework\TestCase +class WebsiteTest extends TestCase { /** @var Website */ protected $model; /** - * @var \Magento\Framework\App\ResourceConnection|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\App\ResourceConnection|MockObject */ protected $resourceMock; - /** @var Select | \PHPUnit_Framework_MockObject_MockObject */ + /** @var Select | MockObject */ protected $select; /** - * @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\DB\Adapter\AdapterInterface|MockObject */ protected $connectionMock; From 0be17f28475a442ca5e690ef609411accf74c6dc Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Tue, 14 Apr 2020 11:07:28 +0300 Subject: [PATCH 147/177] Changed name of ActionGroup --- .../Bundle/Test/Mftf/Test/StorefrontAdminEditDataTest.xml | 4 ++-- .../Mftf/Test/StorefrontBundleAddToCartSuccessTest.xml | 2 +- .../Test/Mftf/Test/StorefrontEditBundleProductTest.xml | 4 ++-- .../Catalog/Test/Mftf/Test/AddToCartCrossSellTest.xml | 2 +- .../AdminApplyTierPriceToProductTest.xml | 8 ++++---- .../Test/AdminBackorderAllowedAddProductToCartTest.xml | 2 +- .../AssociatedProductToConfigurableOutOfStockTest.xml | 2 +- .../AdminCreateCatalogPriceRuleByPercentTest.xml | 2 +- .../Test/Mftf/Test/StorefrontInactiveCatalogRuleTest.xml | 2 +- ...ionGroup.xml => StorefrontCartPageOpenActionGroup.xml} | 2 +- .../Test/Mftf/Test/CheckoutSpecificDestinationsTest.xml | 4 ++-- .../DeleteBundleDynamicProductFromShoppingCartTest.xml | 2 +- .../Test/DeleteBundleFixedProductFromShoppingCartTest.xml | 2 +- .../DeleteConfigurableProductFromShoppingCartTest.xml | 2 +- .../DeleteDownloadableProductFromShoppingCartTest.xml | 2 +- .../Test/DeleteGroupedProductFromShoppingCartTest.xml | 2 +- .../Test/DeleteVirtualProductFromShoppingCartTest.xml | 2 +- .../ShoppingCartAndMiniShoppingCartPerCustomerTest.xml | 4 ++-- ...tFreeShippingRecalculationAfterCouponCodeAddedTest.xml | 2 +- ...ntCheckPagerShoppingCartWithMoreThan20ProductsTest.xml | 2 +- .../Test/StorefrontCheckoutDisabledBundleProductTest.xml | 2 +- ...orefrontMissingPagerShoppingCartWith20ProductsTest.xml | 2 +- .../StorefrontOnePageCheckoutDataWhenChangeQtyTest.xml | 2 +- ...ersistentDataForGuestCustomerWithPhysicalQuoteTest.xml | 4 ++-- ...ShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml | 2 +- .../StorefrontUpdateShoppingCartSimpleProductQtyTest.xml | 2 +- ...eShoppingCartSimpleWithCustomOptionsProductQtyTest.xml | 2 +- ...gurableProductWithTwoOptionsAssignedToCategoryTest.xml | 2 +- ...ProductWithTwoOptionsWithoutAssignedToCategoryTest.xml | 2 +- ...refrontConfigurableProductWithFileCustomOptionTest.xml | 2 +- .../Test/AdminCreateDownloadableProductWithLinkTest.xml | 2 +- ...itDownloadableProductWithSeparateLinksFromCartTest.xml | 2 +- ...ippingCheckoutWhenCartPageIsOpenedInAnotherTabTest.xml | 4 ++-- ...StorefrontFreeShippingDisplayWithInclTaxOptionTest.xml | 2 +- ...mparisonWishlistIsPersistedUnderLongTermCookieTest.xml | 2 +- .../Test/StorefrontGuestCheckoutDisabledProductTest.xml | 2 +- .../Test/AdminCreateCartPriceRuleEmptyFromDateTest.xml | 2 +- .../Test/AdminCreateCartPriceRuleForCouponCodeTest.xml | 2 +- .../AdminCreateCartPriceRuleForGeneratedCouponTest.xml | 2 +- .../Test/Mftf/Test/StorefrontCartPriceRuleCountryTest.xml | 2 +- .../Mftf/Test/StorefrontCartPriceRulePostcodeTest.xml | 2 +- .../Mftf/Test/StorefrontCartPriceRuleQuantityTest.xml | 4 ++-- .../Test/Mftf/Test/StorefrontCartPriceRuleStateTest.xml | 2 +- .../Mftf/Test/StorefrontCartPriceRuleSubtotalTest.xml | 4 ++-- ...ontCartTotalValueWithFullDiscountUsingCartRuleTest.xml | 2 +- ...ntCustomerCanChangeProductOptionsUsingSwatchesTest.xml | 2 +- .../StorefrontSwatchProductWithFileCustomOptionTest.xml | 2 +- .../StorefrontTaxQuoteCartGuestSimpleTest.xml | 2 +- .../StorefrontTaxQuoteCartGuestVirtualTest.xml | 2 +- .../StorefrontTaxQuoteCartLoggedInSimpleTest.xml | 2 +- .../StorefrontTaxQuoteCartLoggedInVirtualTest.xml | 2 +- 51 files changed, 62 insertions(+), 62 deletions(-) rename app/code/Magento/Checkout/Test/Mftf/ActionGroup/{StorefrontOpenCartPageActionGroup.xml => StorefrontCartPageOpenActionGroup.xml} (89%) diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdminEditDataTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdminEditDataTest.xml index 5bdecea1cfe63..8e8df1f4f16f0 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdminEditDataTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdminEditDataTest.xml @@ -80,7 +80,7 @@ <waitForPageLoad stepKey="waitForElementAdded"/> <!-- Go to the shopping cart page and grab the value of the option title --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="onPageShoppingCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="onPageShoppingCart"/> <grabTextFrom selector="{{CheckoutCartProductSection.nthBundleOptionName('1')}}" stepKey="grabTotalBefore"/> <!-- Find the product that we just created using the product grid --> @@ -100,7 +100,7 @@ <see stepKey="assertSuccess2" selector="{{AdminProductMessagesSection.successMessage}}" userInput="You saved the product."/> <!-- Go to the shopping cart page and make sure the title has changed --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="onPageShoppingCart1"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="onPageShoppingCart1"/> <grabTextFrom selector="{{CheckoutCartProductSection.nthBundleOptionName('1')}}" stepKey="grabTotalAfter"/> <assertNotEquals stepKey="assertNotEquals"> <actualResult type="string">{$grabTotalAfter}</actualResult> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartSuccessTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartSuccessTest.xml index 784e7d8a4a308..e6f8834336683 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartSuccessTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartSuccessTest.xml @@ -100,7 +100,7 @@ <see selector="{{StorefrontMessagesSection.success}}" userInput="You added {{BundleProduct.name}} to your shopping cart." stepKey="seeAddToCartSuccessMessage"/> <!-- Verify cart contents --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCart"/> <see selector="{{StorefrontBundledSection.nthItemOptionsTitle('1')}}" userInput="Option One" stepKey="seeOption1"/> <see selector="{{StorefrontBundledSection.nthItemOptionsTitle('2')}}" userInput="Option Two" stepKey="seeOption2"/> <see selector="{{StorefrontBundledSection.nthItemOptionsTitle('3')}}" userInput="Option Three" stepKey="seeOption3"/> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontEditBundleProductTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontEditBundleProductTest.xml index 5fdc9f0a26af3..161d308044b4a 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontEditBundleProductTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontEditBundleProductTest.xml @@ -89,7 +89,7 @@ <waitForPageLoad stepKey="waitForElementAdded2"/> <!-- Go to the shopping cart page and edit the first product --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="onPageShoppingCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="onPageShoppingCart"/> <waitForElementVisible stepKey="waitForInfoDropdown" selector="{{CheckoutCartSummarySection.total}}"/> <waitForPageLoad stepKey="waitForCartPageLoad3"/> <grabTextFrom selector="{{CheckoutCartSummarySection.total}}" stepKey="grabTotalBefore"/> @@ -106,7 +106,7 @@ <waitForPageLoad stepKey="waitForElementAdded3"/> <!-- Go to the shopping cart page --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="onPageShoppingCart2"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="onPageShoppingCart2"/> <!-- Assert that the options are both there and the proce no longer matches --> <see stepKey="assertBothOptions" selector="{{CheckoutCartProductSection.nthItemOption('2')}}" userInput="$$simpleProduct1.sku$$"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AddToCartCrossSellTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AddToCartCrossSellTest.xml index d7dea954ef6b0..e00b3fe2994eb 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AddToCartCrossSellTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AddToCartCrossSellTest.xml @@ -77,7 +77,7 @@ </actionGroup> <!-- Check that cart page contains cross-sell to simpleProduct2 and simpleProduct3--> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart1"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCart1"/> <waitForElementVisible selector="{{CheckoutCartCrossSellSection.products}}" stepKey="waitForCrossSellLoading"/> <see stepKey="seeProduct2InCrossSell" selector="{{CheckoutCartCrossSellSection.products}}" userInput="$simpleProduct2.name$"/> <see stepKey="seeProduct3InCrossSell" selector="{{CheckoutCartCrossSellSection.products}}" userInput="$simpleProduct3.name$"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminApplyTierPriceToProductTest/AdminApplyTierPriceToProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminApplyTierPriceToProductTest/AdminApplyTierPriceToProductTest.xml index f56ef530c6851..cbbd496e8cb34 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminApplyTierPriceToProductTest/AdminApplyTierPriceToProductTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminApplyTierPriceToProductTest/AdminApplyTierPriceToProductTest.xml @@ -171,7 +171,7 @@ <fillField selector="{{AdminProductFormAdvancedPricingSection.productTierPricePercentageValuePriceInput('1')}}" userInput="25" stepKey="selectProductTierPricePercentageValue2"/> <click selector="{{AdminProductFormAdvancedPricingSection.doneButton}}" stepKey="clickDoneButton4"/> <actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct4"/> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToShoppingCartPage1"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToShoppingCartPage1"/> <seeInField userInput="20" selector="{{CheckoutCartProductSection.ProductQuantityByName($$createSimpleProduct.name$$)}}" stepKey="seeInQtyField20"/> <grabTextFrom selector="{{CheckoutCartProductSection.productSubtotalByName($$createSimpleProduct.name$$)}}" stepKey="grabTextFromSubtotalField4"/> <assertEquals message="Shopping cart should contain subtotal $1,500" stepKey="assertSubtotalField4"> @@ -197,7 +197,7 @@ <click selector="{{AdminConfigSection.saveButton}}" stepKey="saveConfig1"/> <see selector="{{AdminMessagesSection.success}}" userInput="You saved the configuration." stepKey="seeConfigSuccessMessage1"/> <actionGroup ref="ClearCacheActionGroup" stepKey="flushCache1"/> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToShoppingCartPage2"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToShoppingCartPage2"/> <seeInField userInput="20" selector="{{CheckoutCartProductSection.ProductQuantityByName($$createSimpleProduct.name$$)}}" stepKey="seeInQtyField20_2"/> <grabTextFrom selector="{{CheckoutCartProductSection.productSubtotalByName($$createSimpleProduct.name$$)}}" stepKey="grabTextFromSubtotalField5"/> <assertEquals message="Shopping cart should contain subtotal $1,500" stepKey="assertSubtotalField5"> @@ -210,7 +210,7 @@ <click selector="{{AdminConfigSection.saveButton}}" stepKey="saveConfig2"/> <see selector="{{AdminMessagesSection.success}}" userInput="You saved the configuration." stepKey="seeConfigSuccessMessage2"/> <actionGroup ref="ClearCacheActionGroup" stepKey="flushCache2"/> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToShoppingCartPage3"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToShoppingCartPage3"/> <seeInField userInput="20" selector="{{CheckoutCartProductSection.ProductQuantityByName($$createSimpleProduct.name$$)}}" stepKey="seeInQtyField20_3"/> <grabTextFrom selector="{{CheckoutCartProductSection.productSubtotalByName($$createSimpleProduct.name$$)}}" stepKey="grabTextFromSubtotalField6"/> <assertEquals message="Shopping cart should contain subtotal $1,500" stepKey="assertSubtotalField6"> @@ -247,7 +247,7 @@ <waitForElementVisible selector="{{AdminProductFormSection.productPrice}}" stepKey="waitForAdminProductFormSectionProductPriceInput"/> <fillField selector="{{AdminProductFormSection.productPrice}}" userInput="200" stepKey="fillProductPrice200"/> <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveButton"/> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToShoppingCartPage4"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToShoppingCartPage4"/> <grabTextFrom selector="{{CheckoutCartProductSection.productSubtotalByName($$createSimpleProduct.name$$)}}" stepKey="grabTextFromSubtotalField7"/> <assertEquals message="Shopping cart should contain subtotal $4,000" stepKey="assertSubtotalField7"> <expectedResult type="string">$4,000.00</expectedResult> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminBackorderAllowedAddProductToCartTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminBackorderAllowedAddProductToCartTest.xml index c96636d5f9dcd..96d0c209aba34 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminBackorderAllowedAddProductToCartTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminBackorderAllowedAddProductToCartTest.xml @@ -41,7 +41,7 @@ </actionGroup> <!-- Go to the cart page and verify we see the product --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="gotoCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="gotoCart"/> <actionGroup ref="AssertStorefrontCheckoutCartItemsActionGroup" stepKey="assertProductItemInCheckOutCart"> <argument name="productName" value="$$createProduct.name$$"/> <argument name="productSku" value="$$createProduct.sku$$"/> diff --git a/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml b/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml index d11a0d8860f00..a987847caa1e7 100644 --- a/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml +++ b/app/code/Magento/CatalogInventory/Test/Mftf/Test/AssociatedProductToConfigurableOutOfStockTest.xml @@ -103,7 +103,7 @@ <selectOption userInput="$$createConfigProductAttributeOption1.option[store_labels][1][label]$$" selector="{{StorefrontProductInfoMainSection.optionByAttributeId($$createConfigProductAttribute.attribute_id$$)}}" stepKey="configProductFillOption" /> <click stepKey="addSimpleProductToCart" selector="{{StorefrontProductActionSection.addToCart}}"/> <waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" time="30" stepKey="waitForProductAdded"/> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToShoppingCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToShoppingCartPage"/> <actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/> <waitForElement selector="{{CheckoutShippingMethodsSection.next}}" time="30" stepKey="waitForNextButton"/> <click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleByPercentTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleByPercentTest.xml index b30fbaee098e4..fcae0065f1b53 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleByPercentTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleByPercentTest.xml @@ -63,7 +63,7 @@ <!-- Add the product to cart and check that the price is correct there --> <click stepKey="addToCart" selector="{{StorefrontProductActionSection.addToCart}}"/> <waitForPageLoad stepKey="waitForAddedToCart"/> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckout"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCheckout"/> <see stepKey="seeNewPriceInCart" selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$110.70"/> </test> </tests> diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/StorefrontInactiveCatalogRuleTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/StorefrontInactiveCatalogRuleTest.xml index 46ba6e30100b1..2df891b24223b 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/StorefrontInactiveCatalogRuleTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/StorefrontInactiveCatalogRuleTest.xml @@ -60,7 +60,7 @@ <actionGroup ref="AddToCartFromStorefrontProductPageActionGroup" stepKey="addToCartFromStorefrontProductPage"> <argument name="productName" value="$createProduct.name$"/> </actionGroup> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="openCartPage" /> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openCartPage" /> <waitForElementVisible selector="{{CheckoutCartSummarySection.subtotal}}" stepKey="waitForSubtotalAppears"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$createProduct.price$" stepKey="seeProductPriceOnCartPage"/> </test> diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCartPageActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontCartPageOpenActionGroup.xml similarity index 89% rename from app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCartPageActionGroup.xml rename to app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontCartPageOpenActionGroup.xml index fe1e48e00c5bb..67301ce96c40b 100644 --- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCartPageActionGroup.xml +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontCartPageOpenActionGroup.xml @@ -7,7 +7,7 @@ --> <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="StorefrontOpenCartPageActionGroup"> + <actionGroup name="StorefrontCartPageOpenActionGroup"> <amOnPage url="{{CheckoutCartPage.url}}" stepKey="openCartPage" /> <waitForPageLoad stepKey="waitForPageLoaded" /> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/CheckoutSpecificDestinationsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/CheckoutSpecificDestinationsTest.xml index 6a403001e76e6..561e73bc24f61 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/CheckoutSpecificDestinationsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/CheckoutSpecificDestinationsTest.xml @@ -48,7 +48,7 @@ </actionGroup> <!--Go to shopping cart--> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnPageShoppingCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="amOnPageShoppingCart"/> <!--Verify country options in checkout top destination section--> <actionGroup ref="VerifyTopDestinationsCountryActionGroup" stepKey="verifyTopDestinationsCountry"> <argument name="country" value="Bahamas"/> @@ -67,7 +67,7 @@ </actionGroup> <!--Go to shopping cart--> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnPageShoppingCart2"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="amOnPageShoppingCart2"/> <!--Verify country options is shown by default--> <actionGroup ref="VerifyTopDestinationsCountryActionGroup" stepKey="verifyTopDestinationsCountry2"> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleDynamicProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleDynamicProductFromShoppingCartTest.xml index 2f1b1957d9101..5fd201290655a 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleDynamicProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleDynamicProductFromShoppingCartTest.xml @@ -60,7 +60,7 @@ </actionGroup> <!-- Remove product from cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCart"/> <actionGroup ref="DeleteProductFromShoppingCartActionGroup" stepKey="deleteProduct"> <argument name="productName" value="$$createBundleDynamicProduct.name$$"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleFixedProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleFixedProductFromShoppingCartTest.xml index a089de795248f..603ee1ecea4df 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleFixedProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleFixedProductFromShoppingCartTest.xml @@ -52,7 +52,7 @@ </actionGroup> <!-- Remove product from cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCart"/> <actionGroup ref="DeleteProductFromShoppingCartActionGroup" stepKey="deleteProduct"> <argument name="productName" value="$$createFixedBundleProduct.name$$"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteConfigurableProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteConfigurableProductFromShoppingCartTest.xml index 3ede19a097750..e7b61415723cc 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteConfigurableProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteConfigurableProductFromShoppingCartTest.xml @@ -74,7 +74,7 @@ </actionGroup> <!-- Remove product from cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCart"/> <actionGroup ref="DeleteProductFromShoppingCartActionGroup" stepKey="deleteProduct"> <argument name="productName" value="$$createConfigProduct.name$$"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteDownloadableProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteDownloadableProductFromShoppingCartTest.xml index 2f67e780f9536..93fd115ae8577 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteDownloadableProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteDownloadableProductFromShoppingCartTest.xml @@ -44,7 +44,7 @@ </actionGroup> <!-- Remove product from cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCart"/> <actionGroup ref="DeleteProductFromShoppingCartActionGroup" stepKey="deleteProduct"> <argument name="productName" value="$$createDownloadableProduct.name$$"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteGroupedProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteGroupedProductFromShoppingCartTest.xml index 6ef54f4ee180c..b82df28ebb95f 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteGroupedProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteGroupedProductFromShoppingCartTest.xml @@ -58,7 +58,7 @@ </actionGroup> <!-- Remove products from cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCart"/> <click selector="{{CheckoutCartProductSection.removeProductByName($$createFirstSimpleProduct.name$$)}}" stepKey="deleteFirstProductFromCheckoutCart"/> <click selector="{{CheckoutCartProductSection.removeProductByName($$createSecondSimpleProduct.name$$)}}" stepKey="deleteSecondProductFromCheckoutCart"/> <click selector="{{CheckoutCartProductSection.removeProductByName($$createThirdSimpleProduct.name$$)}}" stepKey="deleteThirdProductFromCheckoutCart"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteVirtualProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteVirtualProductFromShoppingCartTest.xml index edcad241dfaf8..39b4e66ef9f07 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteVirtualProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteVirtualProductFromShoppingCartTest.xml @@ -38,7 +38,7 @@ </actionGroup> <!-- Remove product from cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCart"/> <actionGroup ref="DeleteProductFromShoppingCartActionGroup" stepKey="deleteProduct"> <argument name="productName" value="$$createVirtualProduct.name$$"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml index f34d1d101f8b6..571aa24209389 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/ShoppingCartAndMiniShoppingCartPerCustomerTest.xml @@ -115,7 +115,7 @@ <argument name="Customer" value="$$createFirstCustomer$$"/> </actionGroup> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnPageShoppingCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="amOnPageShoppingCart"/> <!-- Assert first products present in shopping cart --> <actionGroup ref="StorefrontCheckCartSimpleProductActionGroup" stepKey="checkFirstProductInCart"> @@ -154,7 +154,7 @@ </actionGroup> <!-- Assert first products present in shopping cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnShoppingCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="amOnShoppingCartPage"/> <actionGroup ref="StorefrontCheckCartSimpleProductActionGroup" stepKey="checkProductInCart"> <argument name="product" value="$$createSimpleProduct$$"/> <argument name="productQuantity" value="quoteQty2Price123.qty"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontFreeShippingRecalculationAfterCouponCodeAddedTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontFreeShippingRecalculationAfterCouponCodeAddedTest.xml index 72c6cebe7748a..af3a2e6870cd7 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontFreeShippingRecalculationAfterCouponCodeAddedTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontFreeShippingRecalculationAfterCouponCodeAddedTest.xml @@ -64,7 +64,7 @@ <actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart1"/> <waitForPageLoad stepKey="waitForpageLoad1"/> <dontSee selector="{{CheckoutShippingMethodsSection.shippingMethodRowByName('Free')}}" stepKey="dontSeeFreeShipping"/> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToShoppingCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToShoppingCartPage"/> <conditionalClick selector="{{DiscountSection.DiscountTab}}" dependentSelector="{{DiscountSection.CouponInput}}" visible="false" stepKey="clickIfDiscountTabClosed1"/> <waitForPageLoad stepKey="waitForCouponTabOpen1"/> <click selector="{{DiscountSection.CancelCoupon}}" stepKey="cancelCoupon"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml index caec34c5ef1aa..93d1c4092c05e 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml @@ -131,7 +131,7 @@ <deleteData createDataKey="simpleProduct20" stepKey="deleteCartItem20"/> <deleteData createDataKey="simpleProduct21" stepKey="deleteCartItem21"/> </after> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage" /> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage" /> <actionGroup ref="AssertToolbarTextIsVisibleInCartActionGroup" stepKey="VerifyPagerText"> <argument name="text" value="Items 1 to 20 of 21 total"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutDisabledBundleProductTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutDisabledBundleProductTest.xml index 444ebf653b94f..27d4e4c207ae7 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutDisabledBundleProductTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutDisabledBundleProductTest.xml @@ -71,7 +71,7 @@ </actionGroup> <closeTab stepKey="closeTab"/> <!-- Go to cart page--> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="openCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openCartPage"/> <!-- Assert checkout button exists on the page--> <seeElement selector="{{CheckoutCartSummarySection.proceedToCheckout}}" stepKey="seeCheckoutButton"/> <!-- Assert no error message is not shown on the page--> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml index 32b0985c290a3..a5a3675ea0a0b 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml @@ -126,7 +126,7 @@ <deleteData createDataKey="simpleProduct20" stepKey="deleteCartItem20"/> </after> <!-- Go to the shopping cart and check if the pager is missing--> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage" /> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage" /> <actionGroup ref="AssertPagerTextIsNotVisibleActionGroup" stepKey="VerifyMissingPagerText" > <argument name="text" value="Items 1 to 20"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutDataWhenChangeQtyTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutDataWhenChangeQtyTest.xml index f2e7841327901..5df8338030efc 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutDataWhenChangeQtyTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontOnePageCheckoutDataWhenChangeQtyTest.xml @@ -65,7 +65,7 @@ <seeInCurrentUrl url="{{CheckoutPage.url}}/#payment" stepKey="assertCheckoutPaymentUrl"/> <!--Go to cart page, update qty and proceed to checkout--> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage"/> <see userInput="Shopping Cart" stepKey="seeCartPageIsOpened"/> <fillField selector="{{CheckoutCartProductSection.qty($$createProduct.name$$)}}" userInput="2" stepKey="updateProductQty"/> <click selector="{{CheckoutCartProductSection.updateShoppingCartButton}}" stepKey="clickUpdateShoppingCart"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontPersistentDataForGuestCustomerWithPhysicalQuoteTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontPersistentDataForGuestCustomerWithPhysicalQuoteTest.xml index 131fe0ce875c7..9aea4ac79312a 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontPersistentDataForGuestCustomerWithPhysicalQuoteTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontPersistentDataForGuestCustomerWithPhysicalQuoteTest.xml @@ -35,7 +35,7 @@ <argument name="product" value="$$createProduct$$"/> </actionGroup> <!-- 2. Go to Shopping Cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckoutCartIndexPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCheckoutCartIndexPage"/> <!-- 3. Open "Estimate Shipping and Tax" section and input data --> <actionGroup ref="StorefrontCartEstimateShippingAndTaxActionGroup" stepKey="fillEstimateShippingAndTaxSection"/> <actionGroup ref="StorefrontAssertShippingMethodPresentInCartActionGroup" stepKey="assertShippingMethodFlatRateIsPresentInCart"> @@ -78,7 +78,7 @@ <argument name="shippingMethod" value="Free Shipping"/> </actionGroup> <!-- 11. Go back to the shopping cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckoutCartIndexPage1"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCheckoutCartIndexPage1"/> <actionGroup ref="StorefrontAssertCartEstimateShippingAndTaxActionGroup" stepKey="assertCartEstimateShippingAndTaxAfterGoingBackToShoppingCart"> <argument name="customerData" value="Simple_UK_Customer_For_Shipment"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml index 2691dc2b9fd06..1bab01aac4641 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml @@ -37,7 +37,7 @@ <deleteData createDataKey="createSimpleProduct1" stepKey="deleteProduct1"/> <deleteData createDataKey="createSimpleProduct2" stepKey="deleteProduct2"/> </after> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage" /> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage" /> <actionGroup ref="AssertToolbarTextIsVisibleInCartActionGroup" stepKey="VerifyPagerTextWithChangedConfiguration"> <argument name="text" value="Items 1 to 1 of 2 total"/> </actionGroup> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml index 10fb22e9d58a0..f0c3a23a8d39c 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleProductQtyTest.xml @@ -36,7 +36,7 @@ </after> <!-- Go to the shopping cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnPageShoppingCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="amOnPageShoppingCart"/> <!-- Change the product QTY --> <fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="{{quoteQty3Price123.qty}}" stepKey="changeCartQty"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml index e5059e19a4b39..afb4ff03a4fc9 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUpdateShoppingCartSimpleWithCustomOptionsProductQtyTest.xml @@ -43,7 +43,7 @@ </after> <!-- Go to the shopping cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnPageShoppingCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="amOnPageShoppingCart"/> <!-- Change the product QTY --> <fillField selector="{{CheckoutCartProductSection.ProductQuantityByName($$createProduct.name$$)}}" userInput="{{quoteQty11Subtotal1320.qty}}" stepKey="changeCartQty"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml index b0c8d53d5a4f6..f2a8e78523758 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsAssignedToCategoryTest.xml @@ -131,7 +131,7 @@ <waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" stepKey="waitForSuccessMessage"/> <!-- Assert configurable product in cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnShoppingCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="amOnShoppingCartPage"/> <actionGroup ref="StorefrontCheckCartConfigurableProductActionGroup" stepKey="storefrontCheckCartConfigurableProductActionGroup"> <argument name="product" value="ApiConfigurableProduct"/> <argument name="optionProduct" value="colorConfigurableProductAttribute1"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml index 9c939a9a66ddb..273e37089973b 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTwoOptionsWithoutAssignedToCategoryTest.xml @@ -113,7 +113,7 @@ <waitForElementVisible selector="{{StorefrontCategoryMainSection.SuccessMsg}}" stepKey="waitForSuccessMessage"/> <!-- Assert configurable product in cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnShoppingCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="amOnShoppingCartPage"/> <actionGroup ref="StorefrontCheckCartConfigurableProductActionGroup" stepKey="storefrontCheckCartConfigurableProductActionGroup"> <argument name="product" value="ApiConfigurableProduct"/> <argument name="optionProduct" value="colorConfigurableProductAttribute1"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml index 42491d3efdba6..bbd5dbd8068f7 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml @@ -65,7 +65,7 @@ <see selector="{{StorefrontProductPageSection.messagesBlock}}" userInput="You added {{BaseConfigurableProduct.name}} to your shopping cart." stepKey="seeSuccessMessage"/> <!--Check item in cart--> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCart"/> <seeElement selector="{{CheckoutCartProductSection.ProductLinkByName(BaseConfigurableProduct.name)}}" stepKey="seeProductInCart"/> <see selector="{{CheckoutCartProductSection.ProductOptionByNameAndAttribute(BaseConfigurableProduct.name, colorProductAttribute.default_label)}}" userInput="{{colorProductAttribute2.name}}" stepKey="seeSelectedOption"/> <see selector="{{CheckoutCartProductSection.ProductOptionByNameAndAttribute(BaseConfigurableProduct.name, ProductOptionFile.title)}}" userInput="{{MagentoLogo.file}}" stepKey="seeCorrectOptionFile"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml index 958d798f6476f..317f2abdf2f23 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml @@ -97,7 +97,7 @@ </actionGroup> <!-- Assert product price in cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="openShoppingCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage"/> <see selector="{{CheckoutCartProductSection.ProductPriceByName(DownloadableProduct.name)}}" userInput="$51.99" stepKey="assertProductPriceInCart"/> </test> </tests> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml index 7443a3803ce54..0ac2dc9b04825 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/EditDownloadableProductWithSeparateLinksFromCartTest.xml @@ -95,7 +95,7 @@ </actionGroup> <!-- Step 4: Open cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="openShoppingCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage"/> <see selector="{{CheckoutCartProductSection.ProductPriceByName(DownloadableProduct.name)}}" userInput="$51.99" stepKey="assertProductPriceInCart"/> diff --git a/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontProcessMultishippingCheckoutWhenCartPageIsOpenedInAnotherTabTest.xml b/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontProcessMultishippingCheckoutWhenCartPageIsOpenedInAnotherTabTest.xml index f4c58ca498a94..caf0ce3a51bae 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontProcessMultishippingCheckoutWhenCartPageIsOpenedInAnotherTabTest.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/Test/StorefrontProcessMultishippingCheckoutWhenCartPageIsOpenedInAnotherTabTest.xml @@ -59,7 +59,7 @@ <argument name="product" value="$$createSecondProduct$$"/> <argument name="productCount" value="2"/> </actionGroup> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnShoppingCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="amOnShoppingCartPage"/> <!-- Click 'Check Out with Multiple Addresses' --> <actionGroup ref="StorefrontGoCheckoutWithMultipleAddressesActionGroup" stepKey="goCheckoutWithMultipleAddresses"/> <!-- Select different addresses and click 'Go to Shipping Information' --> @@ -70,7 +70,7 @@ <waitForPageLoad stepKey="waitPageLoad"/> <!-- Open the Cart page in another browser window and go back --> <openNewTab stepKey="openNewTab"/> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnShoppingCartPageNewTab"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="amOnShoppingCartPageNewTab"/> <actionGroup ref="AssertStorefrontCheckoutCartItemsActionGroup" stepKey="assertFirstProductItemInCheckOutCart"> <argument name="productName" value="$$createFirstProduct.name$$"/> <argument name="productSku" value="$$createFirstProduct.sku$$"/> diff --git a/app/code/Magento/OfflineShipping/Test/Mftf/Test/StorefrontFreeShippingDisplayWithInclTaxOptionTest.xml b/app/code/Magento/OfflineShipping/Test/Mftf/Test/StorefrontFreeShippingDisplayWithInclTaxOptionTest.xml index 487ab5081ee70..114c53d215647 100644 --- a/app/code/Magento/OfflineShipping/Test/Mftf/Test/StorefrontFreeShippingDisplayWithInclTaxOptionTest.xml +++ b/app/code/Magento/OfflineShipping/Test/Mftf/Test/StorefrontFreeShippingDisplayWithInclTaxOptionTest.xml @@ -45,7 +45,7 @@ <argument name="product" value="$$createSimpleProduct$$"/> </actionGroup> <!-- Assert that taxes are applied correctly for CA --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckout"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCheckout"/> <waitForElementVisible selector="{{CheckoutPaymentSection.tax}}" stepKey="waitForOverviewVisible"/> <waitForElement time="30" selector="{{CheckoutCartSummarySection.estimateShippingAndTaxForm}}" stepKey="waitForEstimateShippingAndTaxForm"/> <waitForElement time="30" selector="{{CheckoutCartSummarySection.shippingMethodForm}}" stepKey="waitForShippingMethodForm"/> diff --git a/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontVerifyThatInformationAboutViewingComparisonWishlistIsPersistedUnderLongTermCookieTest.xml b/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontVerifyThatInformationAboutViewingComparisonWishlistIsPersistedUnderLongTermCookieTest.xml index ea72649cf70bb..e6fae229d29b1 100644 --- a/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontVerifyThatInformationAboutViewingComparisonWishlistIsPersistedUnderLongTermCookieTest.xml +++ b/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontVerifyThatInformationAboutViewingComparisonWishlistIsPersistedUnderLongTermCookieTest.xml @@ -128,7 +128,7 @@ </actionGroup> <!--Place the order--> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToShoppingCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToShoppingCartPage"/> <actionGroup ref="PlaceOrderWithLoggedUserActionGroup" stepKey="placeOrder"> <argument name="shippingMethod" value="Flat Rate"/> </actionGroup> diff --git a/app/code/Magento/Quote/Test/Mftf/Test/StorefrontGuestCheckoutDisabledProductTest.xml b/app/code/Magento/Quote/Test/Mftf/Test/StorefrontGuestCheckoutDisabledProductTest.xml index cbd6b80de4bbb..06ebb0ccf2ee3 100644 --- a/app/code/Magento/Quote/Test/Mftf/Test/StorefrontGuestCheckoutDisabledProductTest.xml +++ b/app/code/Magento/Quote/Test/Mftf/Test/StorefrontGuestCheckoutDisabledProductTest.xml @@ -133,7 +133,7 @@ <argument name="product" value="$$createSimpleProduct2$$"/> <argument name="productCount" value="1"/> </actionGroup> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckoutCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCheckoutCartPage"/> <!-- Disabled via admin panel --> <openNewTab stepKey="openNewTab2"/> <!-- Find the first simple product that we just created using the product grid and go to its page --> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleEmptyFromDateTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleEmptyFromDateTest.xml index 36cae1fb3d8ce..221f80b887fe5 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleEmptyFromDateTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleEmptyFromDateTest.xml @@ -86,7 +86,7 @@ <click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/> <waitForPageLoad stepKey="waitForAddToCart"/> <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage"/> <actionGroup ref="StorefrontApplyCouponActionGroup" stepKey="applyCoupon"> <argument name="coupon" value="_defaultCoupon"/> </actionGroup> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForCouponCodeTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForCouponCodeTest.xml index 983397f672673..e2a65685bd97e 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForCouponCodeTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForCouponCodeTest.xml @@ -78,7 +78,7 @@ <click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/> <waitForPageLoad stepKey="waitForAddToCart"/> <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage"/> <actionGroup ref="StorefrontApplyCouponActionGroup" stepKey="applyCoupon"> <argument name="coupon" value="_defaultCoupon"/> </actionGroup> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml index 4e820833dbc31..24c3a7cd44bc8 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml @@ -80,7 +80,7 @@ <click selector="{{StorefrontProductActionSection.addToCart}}" stepKey="addProductToCart"/> <waitForPageLoad stepKey="waitForAddToCart"/> <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage"/> <conditionalClick selector="{{StorefrontSalesRuleCartCouponSection.couponHeader}}" dependentSelector="{{StorefrontSalesRuleCartCouponSection.discountBlockActive}}" visible="false" stepKey="clickCouponHeader"/> <waitForElementVisible selector="{{StorefrontSalesRuleCartCouponSection.couponField}}" stepKey="waitForCouponField" /> <fillField selector="{{StorefrontSalesRuleCartCouponSection.couponField}}" userInput="{$grabCouponCode}" stepKey="fillCouponField"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleCountryTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleCountryTest.xml index 1d23fbccb6032..51e25d3a7e255 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleCountryTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleCountryTest.xml @@ -71,7 +71,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <!-- Should not see the discount yet because we have not set country --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage"/> <click selector="{{CheckoutCartSummarySection.shippingHeading}}" stepKey="openEstimateShippingSection"/> <checkOption selector="{{CheckoutCartSummarySection.flatRateShippingMethod}}" stepKey="selectFlatRateShipping"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$123.00" stepKey="seeSubtotal"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRulePostcodeTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRulePostcodeTest.xml index 86187aba4be45..420bc37d5c1b2 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRulePostcodeTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRulePostcodeTest.xml @@ -75,7 +75,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <!-- Should not see the discount yet because we have not filled in postcode --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage"/> <click selector="{{CheckoutCartSummarySection.shippingHeading}}" stepKey="openEstimateShippingSection"/> <checkOption selector="{{CheckoutCartSummarySection.flatRateShippingMethod}}" stepKey="selectFlatRateShipping"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$123.00" stepKey="seeSubtotal"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleQuantityTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleQuantityTest.xml index 928c47692764f..279747f87d66d 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleQuantityTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleQuantityTest.xml @@ -73,7 +73,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <!-- Should not see the discount yet because we have only 1 item in our cart --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$123.00" stepKey="seeSubtotal"/> <dontSeeElement selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="dontSeeDiscount"/> @@ -86,7 +86,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage2"/> <!-- Now we should see the discount because we have more than 1 item --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage2"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage2"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$246.00" stepKey="seeSubtotal2"/> <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/> <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$1.00" stepKey="seeDiscountTotal"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleStateTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleStateTest.xml index 58a81997e1474..a3f32c0781a52 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleStateTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleStateTest.xml @@ -71,7 +71,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <!-- Should not see the discount yet because we have not filled in postcode --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage"/> <click selector="{{CheckoutCartSummarySection.shippingHeading}}" stepKey="expandShipping"/> <checkOption selector="{{CheckoutCartSummarySection.flatRateShippingMethod}}" stepKey="selectFlatRateShipping"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$123.00" stepKey="seeSubtotal"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleSubtotalTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleSubtotalTest.xml index b261c2da788fc..39ac14315110e 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleSubtotalTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleSubtotalTest.xml @@ -71,7 +71,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage"/> <!-- Should not see the discount yet because we have not exceeded $200 --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$123.00" stepKey="seeSubtotal"/> <dontSeeElement selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="dontSeeDiscount"/> @@ -84,7 +84,7 @@ <waitForElementVisible selector="{{StorefrontMessagesSection.success}}" stepKey="waitForSuccessMessage2"/> <!-- Now we should see the discount because we exceeded $200 --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCartPage2"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage2"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$246.00" stepKey="seeSubtotal2"/> <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/> <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$0.01" stepKey="seeDiscountTotal"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml index 7217d3975df5a..9b5f8fbb2912d 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml @@ -113,7 +113,7 @@ </actionGroup> <see selector="{{StorefrontMinicartSection.quantity}}" userInput="6" stepKey="seeCartQuantity"/> <!-- Go to the shopping cart page --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="amOnPageShoppingCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="amOnPageShoppingCart"/> <waitForElementVisible selector="{{CheckoutCartSummarySection.orderTotal}}" stepKey="waitForOrderTotalVisible"/> <selectOption selector="{{CheckoutCartSummarySection.country}}" userInput="United States" stepKey="selectCountry"/> <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForOrderTotalUpdate"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontCustomerCanChangeProductOptionsUsingSwatchesTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontCustomerCanChangeProductOptionsUsingSwatchesTest.xml index 39c8d09896f8b..ab532538cc3f3 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontCustomerCanChangeProductOptionsUsingSwatchesTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontCustomerCanChangeProductOptionsUsingSwatchesTest.xml @@ -44,7 +44,7 @@ </actionGroup> <!-- Go to shopping cart and update option of configurable product --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="openShoppingCartPage"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="openShoppingCartPage"/> <actionGroup ref="StorefrontUpdateCartConfigurableProductWithSwatchesActionGroup" stepKey="updateConfigurableProductInTheCart"> <argument name="product" value="_defaultProduct"/> <argument name="productOption" value="e74d3c"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchProductWithFileCustomOptionTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchProductWithFileCustomOptionTest.xml index 03a1723de9530..1b77e773ef283 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchProductWithFileCustomOptionTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchProductWithFileCustomOptionTest.xml @@ -76,7 +76,7 @@ <see selector="{{StorefrontProductPageSection.messagesBlock}}" userInput="You added {{BaseConfigurableProduct.name}} to your shopping cart." stepKey="seeSuccessMessage"/> <!--Check item in cart--> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCart"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCart"/> <seeElement selector="{{CheckoutCartProductSection.ProductLinkByName(BaseConfigurableProduct.name)}}" stepKey="seeProductInCart"/> <see selector="{{CheckoutCartProductSection.ProductOptionByNameAndAttribute(BaseConfigurableProduct.name, visualSwatchAttribute.default_label)}}" userInput="{{visualSwatchOption2.default_label}}" stepKey="seeSelectedSwatch"/> <see selector="{{CheckoutCartProductSection.ProductOptionByNameAndAttribute(BaseConfigurableProduct.name, ProductOptionFile.title)}}" userInput="{{MagentoLogo.file}}" stepKey="seeCorrectOptionFile"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestSimpleTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestSimpleTest.xml index 705ffbc4a5a25..b1e91886960c5 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestSimpleTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestSimpleTest.xml @@ -82,7 +82,7 @@ <see stepKey="seeSuccess" selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You added"/> <!-- Assert that taxes are applied correctly for CA --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckout"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCheckout"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/> <waitForElementVisible stepKey="waitForOverviewVisible" selector="{{CheckoutPaymentSection.tax}}"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestVirtualTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestVirtualTest.xml index 5963b4ecd7ca5..8a04156f3d857 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestVirtualTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartGuestVirtualTest.xml @@ -82,7 +82,7 @@ <see stepKey="seeSuccess" selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You added"/> <!-- Assert that taxes are applied correctly for NY --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckout"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCheckout"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/> <!-- Assert that taxes are applied correctly for CA --> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInSimpleTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInSimpleTest.xml index 426c6e6dfb85d..b76f015679ae2 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInSimpleTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInSimpleTest.xml @@ -96,7 +96,7 @@ <see stepKey="seeSuccess" selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You added"/> <!-- Assert that taxes are applied correctly for NY --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckout"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCheckout"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/> <waitForElementVisible stepKey="waitForOverviewVisible" selector="{{CheckoutPaymentSection.tax}}"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInVirtualTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInVirtualTest.xml index fd2176dc8c713..5f98093ec874f 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInVirtualTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/StorefrontTaxQuoteCartTest/StorefrontTaxQuoteCartLoggedInVirtualTest.xml @@ -95,7 +95,7 @@ <see stepKey="seeSuccess" selector="{{AdminCategoryMessagesSection.SuccessMessage}}" userInput="You added"/> <!-- Assert that taxes are applied correctly for NY --> - <actionGroup ref="StorefrontOpenCartPageActionGroup" stepKey="goToCheckout"/> + <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCheckout"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMask"/> <waitForElementVisible stepKey="waitForOverviewVisible" selector="{{CheckoutPaymentSection.tax}}"/> From c13a5fb186e69e89006398a62216ff421d612324 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Tue, 14 Apr 2020 11:11:20 +0100 Subject: [PATCH 148/177] magento/magento#227499: Intorduced ConfigInterface --- .../MediaGallery/Model/Directory/Config.php | 16 ++------------ .../Model/Directory/ConfigInterface.php | 21 +++++++++++++++++++ .../Model/Directory/IsBlacklisted.php | 6 +++--- app/code/Magento/MediaGallery/etc/di.xml | 2 ++ .../Magento/MediaGalleryApi/etc/directory.xsd | 2 +- 5 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 app/code/Magento/MediaGallery/Model/Directory/ConfigInterface.php diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config.php b/app/code/Magento/MediaGallery/Model/Directory/Config.php index 46314be9edfc1..610457ed50de4 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Config.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Config.php @@ -12,7 +12,7 @@ /** * Media gallery directory config */ -class Config +class Config implements ConfigInterface { private const XML_PATH_BLACKLIST_PATTERNS = 'blacklist/patterns'; @@ -29,18 +29,6 @@ public function __construct(DataInterface $data) $this->data = $data; } - /** - * Get config value by key. - * - * @param string|null $key - * @param string|null $default - * @return array - */ - public function get($key = null, $default = null) - { - return $this->data->get($key, $default); - } - /** * Returns list of blacklist regexp patterns * @@ -48,6 +36,6 @@ public function get($key = null, $default = null) */ public function getBlacklistPatterns() : array { - return $this->get(self::XML_PATH_BLACKLIST_PATTERNS); + return $this->data->get(self::XML_PATH_BLACKLIST_PATTERNS); } } diff --git a/app/code/Magento/MediaGallery/Model/Directory/ConfigInterface.php b/app/code/Magento/MediaGallery/Model/Directory/ConfigInterface.php new file mode 100644 index 0000000000000..80d6c0be6b746 --- /dev/null +++ b/app/code/Magento/MediaGallery/Model/Directory/ConfigInterface.php @@ -0,0 +1,21 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaGallery\Model\Directory; + +/** + * Media gallery directory config + */ +interface ConfigInterface +{ + /** + * Returns list of blacklist RegEx patterns + * + * @return array + */ + public function getBlacklistPatterns(): array; +} diff --git a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php index d2e59b5613b4a..5b9836221fcd1 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php +++ b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php @@ -15,14 +15,14 @@ class IsBlacklisted implements IsPathBlacklistedInterface { /** - * @var Config + * @var ConfigInterface */ private $config; /** - * @param Config $config + * @param ConfigInterface $config */ - public function __construct(Config $config) + public function __construct(ConfigInterface $config) { $this->config = $config; } diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index 4fcc18e29726c..6d41971060ddc 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -10,6 +10,8 @@ <preference for="Magento\MediaGalleryApi\Api\Data\AssetInterface" type="Magento\MediaGallery\Model\Asset"/> <preference for="Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface" type="Magento\MediaGallery\Model\AssetKeywords"/> + <preference for="Magento\MediaGallery\Model\Directory\ConfigInterface" type="Magento\MediaGallery\Model\Directory\Config"/> + <preference for="Magento\MediaGalleryApi\Model\Asset\Command\GetByIdInterface" type="Magento\MediaGallery\Model\Asset\Command\GetById"/> <preference for="Magento\MediaGalleryApi\Model\Asset\Command\SaveInterface" type="Magento\MediaGallery\Model\Asset\Command\Save"/> <preference for="Magento\MediaGalleryApi\Model\Asset\Command\GetByPathInterface" type="Magento\MediaGallery\Model\Asset\Command\GetByPath"/> diff --git a/app/code/Magento/MediaGalleryApi/etc/directory.xsd b/app/code/Magento/MediaGalleryApi/etc/directory.xsd index 51ca17809ab78..2ad76c8fcc9f2 100644 --- a/app/code/Magento/MediaGalleryApi/etc/directory.xsd +++ b/app/code/Magento/MediaGalleryApi/etc/directory.xsd @@ -29,7 +29,7 @@ <xs:complexType name="patternsType"> <xs:annotation> <xs:documentation> - List of directory paths regexp patterns + List of directory paths RegExp patterns </xs:documentation> </xs:annotation> <xs:sequence> From c0dd36506679daf3fce55c061e6610d92723b1d3 Mon Sep 17 00:00:00 2001 From: engcom-Echo <engcom-vendorworker-echo@adobe.com> Date: Tue, 14 Apr 2020 13:58:49 +0300 Subject: [PATCH 149/177] Resolve conflict --- .../Test/Unit/Model/EmailNotificationTest.php | 261 +++++++++++------- 1 file changed, 158 insertions(+), 103 deletions(-) diff --git a/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php b/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php index a8bf94247fd6d..ab90eacbb6032 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php @@ -3,22 +3,29 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - declare(strict_types=1); namespace Magento\Customer\Test\Unit\Model; use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Customer\Helper\View; +use Magento\Customer\Model\CustomerRegistry; +use Magento\Customer\Model\Data\CustomerSecure; use Magento\Customer\Model\EmailNotification; use Magento\Framework\App\Area; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\Helper\Context; use Magento\Framework\Mail\Template\SenderResolverInterface; +use Magento\Framework\Mail\Template\TransportBuilder; +use Magento\Framework\Mail\TransportInterface; +use Magento\Framework\Reflection\DataObjectProcessor; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use Magento\Store\Model\ScopeInterface; -use PHPUnit\Framework\TestCase; -use PHPUnit\Framework\MockObject\MockObject; use Magento\Store\Model\Store; -use Magento\Customer\Model\Data\CustomerSecure; +use Magento\Store\Model\StoreManagerInterface; use Magento\Store\Model\Website; -use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; /** * Unit test for \Magento\Customer\Model\EmailNotification @@ -32,11 +39,6 @@ class EmailNotificationTest extends TestCase */ private const STUB_CUSTOMER_ID = 1; - /** - * @var int - */ - private const STUB_CUSTOMER_STORE_ID = 2; - /** * @var int */ @@ -63,27 +65,27 @@ class EmailNotificationTest extends TestCase private const STUB_SENDER = 'Sender'; /** - * @var \Magento\Customer\Model\CustomerRegistry|MockObject + * @var CustomerRegistry|MockObject */ private $customerRegistryMock; /** - * @var \Magento\Store\Model\StoreManagerInterface|MockObject + * @var StoreManagerInterface|MockObject */ private $storeManagerMock; /** - * @var \Magento\Framework\Mail\Template\TransportBuilder|MockObject + * @var TransportBuilder|MockObject */ private $transportBuilderMock; /** - * @var \Magento\Customer\Helper\View|MockObject + * @var View|MockObject */ private $customerViewHelperMock; /** - * @var \Magento\Framework\Reflection\DataObjectProcessor|MockObject + * @var DataObjectProcessor|MockObject */ private $dataProcessorMock; @@ -93,12 +95,12 @@ class EmailNotificationTest extends TestCase private $customerSecureMock; /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface|MockObject + * @var ScopeConfigInterface|MockObject */ private $scopeConfigMock; /** - * @var \Magento\Store\Model\Store|MockObject + * @var Store|MockObject */ private $storeMock; @@ -115,22 +117,18 @@ class EmailNotificationTest extends TestCase /** * @inheritdoc */ - public function setUp(): void + public function setUp():void { - $this->customerRegistryMock = $this->createMock(\Magento\Customer\Model\CustomerRegistry::class); - - $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class); - - $this->transportBuilderMock = $this->createMock(\Magento\Framework\Mail\Template\TransportBuilder::class); - - $this->customerViewHelperMock = $this->createMock(\Magento\Customer\Helper\View::class); - - $this->dataProcessorMock = $this->createMock(\Magento\Framework\Reflection\DataObjectProcessor::class); + $this->customerRegistryMock = $this->createMock(CustomerRegistry::class); + $this->storeManagerMock = $this->createMock(StoreManagerInterface::class); + $this->transportBuilderMock = $this->createMock(TransportBuilder::class); + $this->customerViewHelperMock = $this->createMock(View::class); + $this->dataProcessorMock = $this->createMock(DataObjectProcessor::class); - $contextMock = $this->createPartialMock(\Magento\Framework\App\Helper\Context::class, ['getScopeConfig']); + $contextMock = $this->createPartialMock(Context::class, ['getScopeConfig']); $this->scopeConfigMock = $this->createPartialMock( - \Magento\Framework\App\Config\ScopeConfigInterface::class, + ScopeConfigInterface::class, ['getValue', 'isSetFlag'] ); @@ -167,15 +165,22 @@ public function setUp(): void * Test email notify when credentials changed * * @param int $testNumber + * @param int $customerStoreId * @param string $oldEmail * @param string $newEmail * @param bool $isPasswordChanged - * * @dataProvider sendNotificationEmailsDataProvider + * + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testEmailNotifyWhenCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPasswordChanged): void - { + public function testEmailNotifyWhenCredentialsChanged( + $testNumber, + $customerStoreId, + $oldEmail, + $newEmail, + $isPasswordChanged + ):void { $customerData = ['key' => 'value']; $senderValues = ['name' => self::STUB_SENDER, 'email' => self::STUB_SENDER]; @@ -199,27 +204,26 @@ public function testEmailNotifyWhenCredentialsChanged($testNumber, $oldEmail, $n $this->senderResolverMock ->expects($expects) ->method('resolve') - ->with(self::STUB_SENDER, self::STUB_CUSTOMER_STORE_ID) + ->with(self::STUB_SENDER, $customerStoreId) ->willReturn($senderValues); /** - * @var MockObject $origCustomer + * @var MockObject $origCustomerMock */ - $origCustomer = $this->createMock(CustomerInterface::class); - $origCustomer->expects($this->any()) + $origCustomerMock = $this->createMock(CustomerInterface::class); + $origCustomerMock->expects($this->any()) ->method('getStoreId') - ->willReturn(0); - $origCustomer->expects($this->any()) + ->willReturn($customerStoreId); + $origCustomerMock->expects($this->any()) ->method('getId') ->willReturn(self::STUB_CUSTOMER_ID); - $origCustomer->expects($this->any()) - ->method('getWebsiteId') - ->willReturn(self::STUB_CUSTOMER_WEBSITE_ID); + $origCustomerMock->expects($this->never()) + ->method('getWebsiteId'); $storeMock = $this->createMock(Store::class); $storeMock->expects($this->any()) ->method('getId') - ->willReturn(self::STUB_CUSTOMER_STORE_ID); + ->willReturn($customerStoreId); $this->storeManagerMock->expects(clone $expects) ->method('getStore') @@ -228,12 +232,10 @@ public function testEmailNotifyWhenCredentialsChanged($testNumber, $oldEmail, $n $websiteMock = $this->createPartialMock(Website::class, ['getStoreIds']); $websiteMock->expects($this->any()) ->method('getStoreIds') - ->willReturn([self::STUB_CUSTOMER_STORE_ID]); + ->willReturn([$customerStoreId]); - $this->storeManagerMock->expects(clone $expects) - ->method('getWebsite') - ->with(self::STUB_CUSTOMER_WEBSITE_ID) - ->willReturn($websiteMock); + $this->storeManagerMock->expects($this->never()) + ->method('getWebsite'); $customerSecureMock = $this->createMock(CustomerSecure::class); $this->customerRegistryMock->expects(clone $expects) @@ -243,12 +245,12 @@ public function testEmailNotifyWhenCredentialsChanged($testNumber, $oldEmail, $n $this->dataProcessorMock->expects(clone $expects) ->method('buildOutputDataArray') - ->with($origCustomer, CustomerInterface::class) + ->with($origCustomerMock, CustomerInterface::class) ->willReturn($customerData); $this->customerViewHelperMock->expects($this->any()) ->method('getCustomerName') - ->with($origCustomer) + ->with($origCustomerMock) ->willReturn(self::STUB_CUSTOMER_NAME); $customerSecureMock->expects(clone $expects) @@ -263,9 +265,9 @@ public function testEmailNotifyWhenCredentialsChanged($testNumber, $oldEmail, $n /** * @var CustomerInterface|MockObject $savedCustomer */ - $savedCustomer = clone $origCustomer; + $savedCustomer = clone $origCustomerMock; - $origCustomer->expects($this->any()) + $origCustomerMock->expects($this->any()) ->method('getEmail') ->willReturn($oldEmail); @@ -279,22 +281,22 @@ public function testEmailNotifyWhenCredentialsChanged($testNumber, $oldEmail, $n [ $xmlPathTemplate, ScopeInterface::SCOPE_STORE, - self::STUB_CUSTOMER_STORE_ID + $customerStoreId ], [ EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, - self::STUB_CUSTOMER_STORE_ID + $customerStoreId ], [ $xmlPathTemplate, ScopeInterface::SCOPE_STORE, - self::STUB_CUSTOMER_STORE_ID + $customerStoreId ], [ EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, - self::STUB_CUSTOMER_STORE_ID + $customerStoreId ] )->willReturnOnConsecutiveCalls( self::STUB_EMAIL_IDENTIFIER, @@ -309,7 +311,7 @@ public function testEmailNotifyWhenCredentialsChanged($testNumber, $oldEmail, $n ->willReturnSelf(); $this->transportBuilderMock->expects(clone $expects) ->method('setTemplateOptions') - ->with(['area' => Area::AREA_FRONTEND, 'store' => self::STUB_CUSTOMER_STORE_ID]) + ->with(['area' => Area::AREA_FRONTEND, 'store' => $customerStoreId]) ->willReturnSelf(); $this->transportBuilderMock->expects(clone $expects) ->method('setTemplateVars') @@ -325,7 +327,7 @@ public function testEmailNotifyWhenCredentialsChanged($testNumber, $oldEmail, $n ->withConsecutive([$oldEmail, self::STUB_CUSTOMER_NAME], [$newEmail, self::STUB_CUSTOMER_NAME]) ->willReturnSelf(); - $transport = $this->createMock(\Magento\Framework\Mail\TransportInterface::class); + $transport = $this->createMock(TransportInterface::class); $this->transportBuilderMock->expects(clone $expects) ->method('getTransport') @@ -348,18 +350,42 @@ public function sendNotificationEmailsDataProvider(): array return [ [ 'test_number' => 1, + 'customerStoreId' => 0, + 'old_email' => 'test@example.com', + 'new_email' => 'test@example.com', + 'is_password_changed' => true + ], + [ + 'test_number' => 1, + 'customerStoreId' => 2, 'old_email' => 'test@example.com', 'new_email' => 'test@example.com', 'is_password_changed' => true ], [ 'test_number' => 2, + 'customerStoreId' => 0, 'old_email' => 'test1@example.com', 'new_email' => 'test2@example.com', 'is_password_changed' => false ], + [ + 'test_number' => 2, + 'customerStoreId' => 2, + 'old_email' => 'test1@example.com', + 'new_email' => 'test2@example.com', + 'is_password_changed' => false + ], + [ + 'test_number' => 3, + 'customerStoreId' => 0, + 'old_email' => 'test1@example.com', + 'new_email' => 'test2@example.com', + 'is_password_changed' => true + ], [ 'test_number' => 3, + 'customerStoreId' => 2, 'old_email' => 'test1@example.com', 'new_email' => 'test2@example.com', 'is_password_changed' => true @@ -370,9 +396,12 @@ public function sendNotificationEmailsDataProvider(): array /** * Test Password Reminder Email Notify * + * @param int $customerStoreId + * @dataProvider customerStoreIdDataProvider + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testPasswordReminder(): void + public function testPasswordReminder($customerStoreId):void { $customerData = ['key' => 'value']; $senderValues = ['name' => self::STUB_SENDER, 'email' => self::STUB_SENDER]; @@ -381,29 +410,31 @@ public function testPasswordReminder(): void $this->senderResolverMock ->expects($this->once()) ->method('resolve') - ->with(self::STUB_SENDER, self::STUB_CUSTOMER_STORE_ID) + ->with(self::STUB_SENDER, $customerStoreId) ->willReturn($senderValues); /** - * @var CustomerInterface|MockObject $customer + * @var CustomerInterface|MockObject $customerMock */ - $customer = $this->createMock(CustomerInterface::class); - $customer->expects($this->any()) + $customerMock = $this->createMock(CustomerInterface::class); + $customerMock->expects($this->never()) + ->method('getWebsiteId'); + $customerMock->expects($this->any()) ->method('getWebsiteId') ->willReturn(self::STUB_CUSTOMER_WEBSITE_ID); - $customer->expects($this->any()) + $customerMock->expects($this->any()) ->method('getStoreId') - ->willReturn(self::STUB_CUSTOMER_STORE_ID); - $customer->expects($this->any()) + ->willReturn($customerStoreId); + $customerMock->expects($this->any()) ->method('getId') ->willReturn(self::STUB_CUSTOMER_ID); - $customer->expects($this->any()) + $customerMock->expects($this->any()) ->method('getEmail') ->willReturn(self::STUB_CUSTOMER_EMAIL); $this->storeMock->expects($this->any()) ->method('getId') - ->willReturn(self::STUB_CUSTOMER_STORE_ID); + ->willReturn($customerStoreId); $this->storeManagerMock->expects($this->at(0)) ->method('getStore') @@ -426,12 +457,12 @@ public function testPasswordReminder(): void $this->dataProcessorMock->expects($this->once()) ->method('buildOutputDataArray') - ->with($customer, CustomerInterface::class) + ->with($customerMock, CustomerInterface::class) ->willReturn($customerData); $this->customerViewHelperMock->expects($this->any()) ->method('getCustomerName') - ->with($customer) + ->with($customerMock) ->willReturn(self::STUB_CUSTOMER_NAME); $this->customerSecureMock->expects($this->once()) @@ -448,26 +479,26 @@ public function testPasswordReminder(): void ->with( EmailNotification::XML_PATH_REMIND_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, - self::STUB_CUSTOMER_STORE_ID + $customerStoreId )->willReturn(self::STUB_EMAIL_IDENTIFIER); $this->scopeConfigMock->expects($this->at(1)) ->method('getValue') ->with( EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, - self::STUB_CUSTOMER_STORE_ID + $customerStoreId )->willReturn(self::STUB_SENDER); $this->mockDefaultTransportBuilder( self::STUB_EMAIL_IDENTIFIER, - self::STUB_CUSTOMER_STORE_ID, + $customerStoreId, $senderValues, self::STUB_CUSTOMER_EMAIL, self::STUB_CUSTOMER_NAME, ['customer' => $this->customerSecureMock, 'store' => $this->storeMock] ); - $this->model->passwordReminder($customer); + $this->model->passwordReminder($customerMock); } /** @@ -475,7 +506,7 @@ public function testPasswordReminder(): void * * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testPasswordReminderCustomerWithoutStoreId(): void + public function testPasswordReminderCustomerWithoutStoreId():void { $customerStoreId = null; $customerData = ['key' => 'value']; @@ -570,9 +601,12 @@ public function testPasswordReminderCustomerWithoutStoreId(): void /** * Test email notify for password reset confirm * + * @dataProvider customerStoreIdDataProvider + * @param int $customerStoreId + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testPasswordResetConfirmation(): void + public function testPasswordResetConfirmation($customerStoreId):void { $customerData = ['key' => 'value']; $senderValues = ['name' => self::STUB_SENDER, 'email' => self::STUB_SENDER]; @@ -580,26 +614,30 @@ public function testPasswordResetConfirmation(): void $this->senderResolverMock ->expects($this->once()) ->method('resolve') - ->with(self::STUB_SENDER, self::STUB_CUSTOMER_STORE_ID) + ->with(self::STUB_SENDER, $customerStoreId) ->willReturn($senderValues); /** - * @var CustomerInterface|MockObject $customer + * @var CustomerInterface|MockObject $customerMock */ - $customer = $this->createMock(CustomerInterface::class); - $customer->expects($this->once()) + $customerMock = $this->createMock(CustomerInterface::class); + + $customerMock->expects($this->never()) + ->method('getWebsiteId'); + + $customerMock->expects($this->once()) ->method('getStoreId') - ->willReturn(self::STUB_CUSTOMER_STORE_ID); - $customer->expects($this->any()) + ->willReturn($customerStoreId); + $customerMock->expects($this->any()) ->method('getId') ->willReturn(self::STUB_CUSTOMER_ID); - $customer->expects($this->any()) + $customerMock->expects($this->any()) ->method('getEmail') ->willReturn(self::STUB_CUSTOMER_EMAIL); $this->storeMock->expects($this->any()) ->method('getId') - ->willReturn(self::STUB_CUSTOMER_STORE_ID); + ->willReturn($customerStoreId); $this->storeManagerMock->expects($this->at(0)) ->method('getStore') @@ -612,12 +650,12 @@ public function testPasswordResetConfirmation(): void $this->dataProcessorMock->expects($this->once()) ->method('buildOutputDataArray') - ->with($customer, CustomerInterface::class) + ->with($customerMock, CustomerInterface::class) ->willReturn($customerData); $this->customerViewHelperMock->expects($this->any()) ->method('getCustomerName') - ->with($customer) + ->with($customerMock) ->willReturn(self::STUB_CUSTOMER_NAME); $this->customerSecureMock->expects($this->once()) @@ -634,35 +672,37 @@ public function testPasswordResetConfirmation(): void ->with( EmailNotification::XML_PATH_FORGOT_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, - self::STUB_CUSTOMER_STORE_ID + $customerStoreId )->willReturn(self::STUB_EMAIL_IDENTIFIER); $this->scopeConfigMock->expects($this->at(1)) ->method('getValue') ->with( EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, - self::STUB_CUSTOMER_STORE_ID + $customerStoreId )->willReturn(self::STUB_SENDER); $this->mockDefaultTransportBuilder( self::STUB_EMAIL_IDENTIFIER, - self::STUB_CUSTOMER_STORE_ID, + $customerStoreId, $senderValues, self::STUB_CUSTOMER_EMAIL, self::STUB_CUSTOMER_NAME, ['customer' => $this->customerSecureMock, 'store' => $this->storeMock] ); - $this->model->passwordResetConfirmation($customer); + $this->model->passwordResetConfirmation($customerMock); } /** * Test email notify with new account * - * @param void + * @dataProvider customerStoreIdDataProvider + * @param int $customerStoreId + * @return void * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function testNewAccount(): void + public function testNewAccount($customerStoreId):void { $customerData = ['key' => 'value']; $senderValues = ['name' => self::STUB_SENDER, 'email' => self::STUB_SENDER]; @@ -670,16 +710,18 @@ public function testNewAccount(): void $this->senderResolverMock ->expects($this->once()) ->method('resolve') - ->with(self::STUB_SENDER, self::STUB_CUSTOMER_STORE_ID) + ->with(self::STUB_SENDER, $customerStoreId) ->willReturn($senderValues); /** * @var CustomerInterface|MockObject $customer */ $customer = $this->createMock(CustomerInterface::class); + $customer->expects($this->never()) + ->method('getWebsiteId'); $customer->expects($this->any()) ->method('getStoreId') - ->willReturn(self::STUB_CUSTOMER_STORE_ID); + ->willReturn($customerStoreId); $customer->expects($this->any()) ->method('getId') ->willReturn(self::STUB_CUSTOMER_ID); @@ -689,11 +731,11 @@ public function testNewAccount(): void $this->storeMock->expects($this->any()) ->method('getId') - ->willReturn(self::STUB_CUSTOMER_STORE_ID); + ->willReturn($customerStoreId); $this->storeManagerMock->expects($this->once()) ->method('getStore') - ->with(self::STUB_CUSTOMER_STORE_ID) + ->with($customerStoreId) ->willReturn($this->storeMock); $this->customerRegistryMock->expects($this->once()) @@ -725,19 +767,19 @@ public function testNewAccount(): void ->with( EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, - self::STUB_CUSTOMER_STORE_ID + $customerStoreId )->willReturn(self::STUB_EMAIL_IDENTIFIER); $this->scopeConfigMock->expects($this->at(1)) ->method('getValue') ->with( EmailNotification::XML_PATH_REGISTER_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, - self::STUB_CUSTOMER_STORE_ID + $customerStoreId )->willReturn(self::STUB_SENDER); $this->mockDefaultTransportBuilder( self::STUB_EMAIL_IDENTIFIER, - self::STUB_CUSTOMER_STORE_ID, + $customerStoreId, $senderValues, self::STUB_CUSTOMER_EMAIL, self::STUB_CUSTOMER_NAME, @@ -748,10 +790,23 @@ public function testNewAccount(): void $customer, EmailNotification::NEW_ACCOUNT_EMAIL_REGISTERED, '', - self::STUB_CUSTOMER_STORE_ID + $customerStoreId ); } + /** + * DataProvider customer store + * + * @return array + */ + public function customerStoreIdDataProvider():array + { + return [ + ['customerStoreId' => 0], + ['customerStoreId' => 2] + ]; + } + /** * Create default mock for $this->transportBuilderMock. * @@ -771,8 +826,8 @@ private function mockDefaultTransportBuilder( string $customerEmail, string $customerName, array $templateVars = [] - ): void { - $transport = $this->createMock(\Magento\Framework\Mail\TransportInterface::class); + ):void { + $transportMock = $this->createMock(TransportInterface::class); $this->transportBuilderMock->expects($this->once()) ->method('setTemplateIdentifier') @@ -796,9 +851,9 @@ private function mockDefaultTransportBuilder( ->willReturnSelf(); $this->transportBuilderMock->expects($this->once()) ->method('getTransport') - ->willReturn($transport); + ->willReturn($transportMock); - $transport->expects($this->once()) + $transportMock->expects($this->once()) ->method('sendMessage'); } } From 03e561efb665f3136c3405cc406e0c39b608047c Mon Sep 17 00:00:00 2001 From: Mykhailo Matiola <mykhailo.matiola@transoftgroup.com> Date: Tue, 14 Apr 2020 17:41:29 +0300 Subject: [PATCH 150/177] MC-32691: Fix integration test Magento\CatalogImportExport\Model\ProductStagingTest::testImportExport --- .../Model/Export/ProductTest.php | 98 +++++++++++++------ .../_files/product_export_data.php | 2 - 2 files changed, 68 insertions(+), 32 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php index 508560d000271..1daa794165873 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php @@ -84,8 +84,10 @@ protected function setUp() /** * @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data.php * @magentoDbIsolation enabled + * + * @return void */ - public function testExport() + public function testExport(): void { $this->model->setWriter( $this->objectManager->create( @@ -109,8 +111,10 @@ public function testExport() /** * @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data_special_chars.php * @magentoDbIsolation enabled + * + * @return void */ - public function testExportSpecialChars() + public function testExportSpecialChars(): void { $this->model->setWriter( $this->objectManager->create( @@ -125,8 +129,10 @@ public function testExportSpecialChars() /** * @magentoDataFixture Magento/CatalogImportExport/_files/product_export_with_product_links_data.php * @magentoDbIsolation enabled + * + * @return void */ - public function testExportWithProductLinks() + public function testExportWithProductLinks(): void { $this->model->setWriter( \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( @@ -143,8 +149,10 @@ public function testExportWithProductLinks() * @magentoDbIsolation enabled * @covers \Magento\CatalogImportExport\Model\Export\Product::export * @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data.php + * + * @return void */ - public function testExportStockItemAttributesAreFilled() + public function testExportStockItemAttributesAreFilled(): void { $this->markTestSkipped('Test needs to be skipped.'); $fileWrite = $this->createMock(\Magento\Framework\Filesystem\File\Write::class); @@ -176,8 +184,9 @@ public function testExportStockItemAttributesAreFilled() * Verify header columns (that stock item attributes column headers are present) * * @param array $headerColumns + * @return void */ - public function verifyHeaderColumns(array $headerColumns) + public function verifyHeaderColumns(array $headerColumns): void { foreach (self::$stockItemAttributes as $stockItemAttribute) { $this->assertContains( @@ -192,8 +201,9 @@ public function verifyHeaderColumns(array $headerColumns) * Verify row data (stock item attribute values) * * @param array $rowData + * @return void */ - public function verifyRow(array $rowData) + public function verifyRow(array $rowData): void { foreach (self::$stockItemAttributes as $stockItemAttribute) { $this->assertNotSame( @@ -208,8 +218,10 @@ public function verifyRow(array $rowData) * Verifies if exception processing works properly * @magentoDbIsolation enabled * @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data.php + * + * @return void */ - public function testExceptionInGetExportData() + public function testExceptionInGetExportData(): void { $this->markTestSkipped('Test needs to be skipped.'); $exception = new \Exception('Error'); @@ -258,8 +270,10 @@ public function testExceptionInGetExportData() * Verify if fields wrapping works correct when "Fields Enclosure" option enabled * * @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data.php + * + * @return void */ - public function testExportWithFieldsEnclosure() + public function testExportWithFieldsEnclosure(): void { $this->model->setParameters( [ @@ -284,8 +298,10 @@ public function testExportWithFieldsEnclosure() * Verify that "category ids" filter correctly applies to export result * * @magentoDataFixture Magento/CatalogImportExport/_files/product_export_with_categories.php + * + * @return void */ - public function testCategoryIdsFilter() + public function testCategoryIdsFilter(): void { $this->model->setWriter( $this->objectManager->create( @@ -313,8 +329,10 @@ public function testCategoryIdsFilter() * Verify that export processed successfully with wrong category path * * @magentoDataFixture Magento/CatalogImportExport/_files/product_export_with_broken_categories_path.php + * + * @return void */ - public function testExportWithWrongCategoryPath() + public function testExportWithWrongCategoryPath(): void { $this->model->setWriter( $this->objectManager->create( @@ -329,8 +347,10 @@ public function testExportWithWrongCategoryPath() * Test 'hide from product page' export for non-default store. * * @magentoDataFixture Magento/CatalogImportExport/_files/product_export_with_images.php + * + * @return void */ - public function testExportWithMedia() + public function testExportWithMedia(): void { /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ $productRepository = $this->objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class); @@ -359,6 +379,7 @@ public function testExportWithMedia() /** * @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data.php + * * @return void */ public function testExportWithCustomOptions(): void @@ -403,12 +424,19 @@ public function testExportWithCustomOptions(): void /** @var \Magento\Framework\File\Csv $csv */ $csv = $this->objectManager->get(\Magento\Framework\File\Csv::class); $data = $csv->getData($varDirectory->getAbsolutePath('test_product_with_custom_options_and_second_store.csv')); + $keys = array_shift($data); + $products = []; + foreach ($data as $productData) { + $products[] = array_combine($keys, $productData); + } + $products = array_filter($products, function (array $product) { + return $product['sku'] === 'simple'; + }); $customOptionData = []; - foreach ($data[0] as $columnNumber => $columnName) { - if ($columnName === 'custom_options') { - $customOptionData['admin_store'] = $this->parseExportedCustomOption($data[1][$columnNumber]); - $customOptionData[$storeCode] = $this->parseExportedCustomOption($data[2][$columnNumber]); - } + + foreach ($products as $product) { + $storeCode = $product['store_view_code'] ?: 'admin_store'; + $customOptionData[$storeCode] = $this->parseExportedCustomOption($product['custom_options']); } self::assertSame($expectedData, $customOptionData); @@ -418,8 +446,10 @@ public function testExportWithCustomOptions(): void * Check that no duplicate entities when multiple custom options used * * @magentoDataFixture Magento/Catalog/_files/product_simple_with_options.php + * + * @return void */ - public function testExportWithMultipleOptions() + public function testExportWithMultipleOptions(): void { $expectedCount = 1; $resultsFilename = 'export_results.csv'; @@ -442,6 +472,8 @@ public function testExportWithMultipleOptions() } /** + * Parse exported custom options + * * @param string $exportedCustomOption * @return array */ @@ -476,8 +508,10 @@ function ($input) { * @magentoConfigFixture current_store catalog/price/scope 1 * @magentoDbIsolation disabled * @magentoAppArea adminhtml + * + * @return void */ - public function testExportProductWithTwoWebsites() + public function testExportProductWithTwoWebsites(): void { $globalStoreCode = 'admin'; $secondStoreCode = 'fixture_second_store'; @@ -539,17 +573,19 @@ public function testExportProductWithTwoWebsites() /** * Verify that "stock status" filter correctly applies to export result * + * @magentoDataFixture Magento/Catalog/_files/multiple_products_with_few_out_of_stock.php + * @dataProvider filterByQuantityAndStockStatusDataProvider + * * @param string $value * @param array $productsIncluded * @param array $productsNotIncluded - * @magentoDataFixture Magento/Catalog/_files/multiple_products_with_few_out_of_stock.php - * @dataProvider filterByQuantityAndStockStatusDataProvider + * @return void */ public function testFilterByQuantityAndStockStatus( string $value, array $productsIncluded, array $productsNotIncluded - ) { + ): void { $exportData = $this->doExport(['quantity_and_stock_status' => $value]); foreach ($productsIncluded as $productName) { $this->assertContains($productName, $exportData); @@ -569,35 +605,37 @@ public function filterByQuantityAndStockStatusDataProvider(): array [ 'Simple Product OOS', 'Simple Product Not Visible', - 'Simple Product Visible and InStock' + 'Simple Product Visible and InStock', ], [ - ] + ], ], [ '1', [ 'Simple Product Not Visible', - 'Simple Product Visible and InStock' + 'Simple Product Visible and InStock', ], [ - 'Simple Product OOS' - ] + 'Simple Product OOS', + ], ], [ '0', [ - 'Simple Product OOS' + 'Simple Product OOS', ], [ 'Simple Product Not Visible', - 'Simple Product Visible and InStock' - ] - ] + 'Simple Product Visible and InStock', + ], + ], ]; } /** + * Perform export + * * @param array $filters * @return string */ diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/_files/product_export_data.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/_files/product_export_data.php index 477494626b9fb..865cba4998e30 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/_files/product_export_data.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/_files/product_export_data.php @@ -59,8 +59,6 @@ $productModel->setTypeId( \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE -)->setId( - 1 )->setAttributeSetId( 4 )->setName( From 30ce748b8dc0b0e61fcd86f65b19014be91ffea4 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Tue, 14 Apr 2020 15:38:52 -0500 Subject: [PATCH 151/177] magento/magento2#27499: Code review fixes --- .../MediaGallery/Model/Asset/Command/Save.php | 47 +++++-------------- .../MediaGallery/Model/Directory/Config.php | 19 ++------ .../Model/Directory/IsBlacklisted.php | 11 +++-- .../Model/ResourceModel/SaveAssets.php | 45 +++++------------- .../Model/Directory/IsBlacklistedTest.php | 7 +-- app/code/Magento/MediaGallery/etc/di.xml | 2 + .../Api/CreateDirectoriesByPathsInterface.php | 1 + .../Api/DeleteDirectoriesByPathsInterface.php | 1 + .../Api/IsPathBlacklistedInterface.php | 4 +- .../Api/SaveAssetsInterface.php | 1 + .../Api/SaveAssetsKeywordsInterface.php | 1 + .../BlacklistPatternsConfigInterface.php | 20 ++++++++ ...or.php => RemoveAssetAfterRemoveImage.php} | 2 +- ...hp => RemoveAssetAfterRemoveImageTest.php} | 8 ++-- .../Magento/MediaGalleryCatalog/etc/di.xml | 3 +- 15 files changed, 74 insertions(+), 98 deletions(-) create mode 100644 app/code/Magento/MediaGalleryApi/Model/BlacklistPatternsConfigInterface.php rename app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/{Processor.php => RemoveAssetAfterRemoveImage.php} (98%) rename app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/{ProcessorTest.php => RemoveAssetAfterRemoveImageTest.php} (94%) diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php index 0ce0d0c18e6d2..b445e9000313c 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php @@ -28,11 +28,6 @@ class Save implements SaveInterface */ private $resourceConnection; - /** - * @var DataObjectProcessor - */ - private $objectProcessor; - /** * @var LoggerInterface */ @@ -42,16 +37,13 @@ class Save implements SaveInterface * Save constructor. * * @param ResourceConnection $resourceConnection - * @param DataObjectProcessor $objectProcessor * @param LoggerInterface $logger */ public function __construct( ResourceConnection $resourceConnection, - DataObjectProcessor $objectProcessor, LoggerInterface $logger ) { $this->resourceConnection = $resourceConnection; - $this->objectProcessor = $objectProcessor; $this->logger = $logger; } @@ -72,37 +64,24 @@ public function execute(AssetInterface $mediaAsset): int $connection->insertOnDuplicate( $tableName, - $this->filterData($this->objectProcessor->buildOutputDataArray($mediaAsset, AssetInterface::class)) + [ + 'id' => $mediaAsset->getId(), + 'path' => $mediaAsset->getPath(), + 'title' => $mediaAsset->getTitle(), + 'source' => $mediaAsset->getSource(), + 'content_type' => $mediaAsset->getContentType(), + 'width' => $mediaAsset->getWidth(), + 'height' => $mediaAsset->getHeight(), + 'size' => $mediaAsset->getSize(), + 'created_at' => $mediaAsset->getCreatedAt(), + 'updated_at' => $mediaAsset->getUpdatedAt(), + ] ); - return (int) $connection->lastInsertId($tableName); + return (int)$connection->lastInsertId($tableName); } catch (\Exception $exception) { $this->logger->critical($exception); $message = __('An error occurred during media asset save: %1', $exception->getMessage()); throw new CouldNotSaveException($message, $exception); } } - - /** - * Filter data to get flat array without null values - * - * @param array $data - * @return array - */ - private function filterData(array $data): array - { - $filteredData = []; - foreach ($data as $key => $value) { - if ($value === null) { - continue; - } - if (is_array($value)) { - continue; - } - if (is_object($value)) { - continue; - } - $filteredData[$key] = $value; - } - return $filteredData; - } } diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config.php b/app/code/Magento/MediaGallery/Model/Directory/Config.php index 46314be9edfc1..67695080b185f 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Config.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Config.php @@ -8,11 +8,12 @@ namespace Magento\MediaGallery\Model\Directory; use Magento\Framework\Config\DataInterface; +use Magento\MediaGalleryApi\Model\BlacklistPatternsConfigInterface; /** * Media gallery directory config */ -class Config +class Config implements BlacklistPatternsConfigInterface { private const XML_PATH_BLACKLIST_PATTERNS = 'blacklist/patterns'; @@ -29,25 +30,13 @@ public function __construct(DataInterface $data) $this->data = $data; } - /** - * Get config value by key. - * - * @param string|null $key - * @param string|null $default - * @return array - */ - public function get($key = null, $default = null) - { - return $this->data->get($key, $default); - } - /** * Returns list of blacklist regexp patterns * * @return array */ - public function getBlacklistPatterns() : array + public function get() : array { - return $this->get(self::XML_PATH_BLACKLIST_PATTERNS); + return $this->data->get(self::XML_PATH_BLACKLIST_PATTERNS); } } diff --git a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php index d2e59b5613b4a..4ca7527ef724b 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php +++ b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php @@ -8,6 +8,7 @@ namespace Magento\MediaGallery\Model\Directory; use Magento\MediaGalleryApi\Api\IsPathBlacklistedInterface; +use Magento\MediaGalleryApi\Model\BlacklistPatternsConfigInterface; /** * Check if the path is blacklisted for media gallery. Directory path may be blacklisted if it's reserved by the system @@ -15,14 +16,14 @@ class IsBlacklisted implements IsPathBlacklistedInterface { /** - * @var Config + * @var BlacklistPatternsConfigInterface */ private $config; - /** - * @param Config $config + /* + * @param BlacklistPatternsConfigInterface $config */ - public function __construct(Config $config) + public function __construct(BlacklistPatternsConfigInterface $config) { $this->config = $config; } @@ -35,7 +36,7 @@ public function __construct(Config $config) */ public function execute(string $path): bool { - foreach ($this->config->getBlacklistPatterns() as $pattern) { + foreach ($this->config->get() as $pattern) { if (empty($pattern)) { continue; } diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php b/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php index 64689d0ab4275..33b5403fda497 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php @@ -26,11 +26,6 @@ class SaveAssets implements SaveAssetsInterface */ private $resourceConnection; - /** - * @var DataObjectProcessor - */ - private $objectProcessor; - /** * @var LoggerInterface */ @@ -40,16 +35,13 @@ class SaveAssets implements SaveAssetsInterface * Save constructor. * * @param ResourceConnection $resourceConnection - * @param DataObjectProcessor $objectProcessor * @param LoggerInterface $logger */ public function __construct( ResourceConnection $resourceConnection, - DataObjectProcessor $objectProcessor, LoggerInterface $logger ) { $this->resourceConnection = $resourceConnection; - $this->objectProcessor = $objectProcessor; $this->logger = $logger; } @@ -66,7 +58,18 @@ public function execute(array $assets): void try { $connection->insertOnDuplicate( $tableName, - $this->filterData($this->objectProcessor->buildOutputDataArray($asset, AssetInterface::class)) + [ + 'id' => $asset->getId(), + 'path' => $asset->getPath(), + 'title' => $asset->getTitle(), + 'source' => $asset->getSource(), + 'content_type' => $asset->getContentType(), + 'width' => $asset->getWidth(), + 'height' => $asset->getHeight(), + 'size' => $asset->getSize(), + 'created_at' => $asset->getCreatedAt(), + 'updated_at' => $asset->getUpdatedAt(), + ] ); } catch (\Exception $exception) { $this->logger->critical($exception); @@ -85,28 +88,4 @@ public function execute(array $assets): void ); } } - - /** - * Filter data to get flat array without null values - * - * @param array $data - * @return array - */ - private function filterData(array $data): array - { - $filteredData = []; - foreach ($data as $key => $value) { - if ($value === null) { - continue; - } - if (is_array($value)) { - continue; - } - if (is_object($value)) { - continue; - } - $filteredData[$key] = $value; - } - return $filteredData; - } } diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php index 84240fb9e3fe7..549974d27b58f 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php @@ -10,6 +10,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\MediaGallery\Model\Directory\IsBlacklisted; use Magento\MediaGallery\Model\Directory\Config; +use Magento\MediaGalleryApi\Model\BlacklistPatternsConfigInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -24,7 +25,7 @@ class IsBlacklistedTest extends TestCase private $object; /** - * @var Config|MockObject + * @var BlacklistPatternsConfigInterface|MockObject */ private $config; @@ -33,8 +34,8 @@ class IsBlacklistedTest extends TestCase */ protected function setUp(): void { - $this->config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); - $this->config->expects($this->at(0))->method('getBlacklistPatterns')->willReturn([ + $this->config = $this->getMockBuilder(BlacklistPatternsConfigInterface::class)->disableOriginalConstructor()->getMock(); + $this->config->expects($this->at(0))->method('get')->willReturn([ 'tmp' => '/pub\/media\/tmp/', 'captcha' => '/pub\/media\/captcha/' ]); diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index 4fcc18e29726c..73360197bed77 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -56,4 +56,6 @@ <argument name="data" xsi:type="object">Magento\MediaGallery\Model\Directory\Config\Data</argument> </arguments> </type> + + <preference for="Magento\MediaGalleryApi\Model\BlacklistPatternsConfigInterface" type="Magento\MediaGallery\Model\Directory\Config"/> </config> diff --git a/app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php b/app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php index 65115b940a900..a0a1ec891237f 100644 --- a/app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/CreateDirectoriesByPathsInterface.php @@ -17,6 +17,7 @@ interface CreateDirectoriesByPathsInterface * Create new directories by provided paths * * @param string[] $paths + * @return void * @throws \Magento\Framework\Exception\CouldNotSaveException */ public function execute(array $paths): void; diff --git a/app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php b/app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php index 5e04976e32c60..fe3be88fa0073 100644 --- a/app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/DeleteDirectoriesByPathsInterface.php @@ -17,6 +17,7 @@ interface DeleteDirectoriesByPathsInterface * Deletes the existing folders * * @param string[] $paths + * @return void * @throws \Magento\Framework\Exception\CouldNotDeleteException */ public function execute(array $paths): void; diff --git a/app/code/Magento/MediaGalleryApi/Api/IsPathBlacklistedInterface.php b/app/code/Magento/MediaGalleryApi/Api/IsPathBlacklistedInterface.php index b2e5afabee11e..cbd23ec3fbde7 100644 --- a/app/code/Magento/MediaGalleryApi/Api/IsPathBlacklistedInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/IsPathBlacklistedInterface.php @@ -8,7 +8,9 @@ namespace Magento\MediaGalleryApi\Api; /** - * Directory paths that are reserved by system and not be included in the media gallery + * Check if the path is blacklisted for media gallery. + * + * Directory path may be blacklisted if it's reserved by the system. * @api */ interface IsPathBlacklistedInterface diff --git a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php index eb9f7d70bbccf..c63f7bd8c0818 100644 --- a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsInterface.php @@ -18,6 +18,7 @@ interface SaveAssetsInterface * Save media asset. The saved asset can later be retrieved by path * * @param \Magento\MediaGalleryApi\Api\Data\AssetInterface[] $assets + * @return void * @throws \Magento\Framework\Exception\CouldNotSaveException */ public function execute(array $assets): void; diff --git a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php index 072ae7a4ec6d5..04efe7d32ccc1 100644 --- a/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/SaveAssetsKeywordsInterface.php @@ -17,6 +17,7 @@ interface SaveAssetsKeywordsInterface * Save assets keywords * * @param \Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface[] $assetKeywords + * @return void * @throws \Magento\Framework\Exception\CouldNotSaveException */ public function execute(array $assetKeywords): void; diff --git a/app/code/Magento/MediaGalleryApi/Model/BlacklistPatternsConfigInterface.php b/app/code/Magento/MediaGalleryApi/Model/BlacklistPatternsConfigInterface.php new file mode 100644 index 0000000000000..b4710f32e0c46 --- /dev/null +++ b/app/code/Magento/MediaGalleryApi/Model/BlacklistPatternsConfigInterface.php @@ -0,0 +1,20 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +namespace Magento\MediaGalleryApi\Model; + +/** + * Returns list of blacklist regexp patterns + */ +interface BlacklistPatternsConfigInterface +{ + /** + * Get regexp patterns + * + * @return array + */ + public function get(): array; +} diff --git a/app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/Processor.php b/app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/RemoveAssetAfterRemoveImage.php similarity index 98% rename from app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/Processor.php rename to app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/RemoveAssetAfterRemoveImage.php index c595d43009dd4..865b40ce90a18 100644 --- a/app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/Processor.php +++ b/app/code/Magento/MediaGalleryCatalog/Plugin/Product/Gallery/RemoveAssetAfterRemoveImage.php @@ -15,7 +15,7 @@ /** * Ensures that metadata is removed from the database when an image has been deleted (from legacy media gallery) */ -class Processor +class RemoveAssetAfterRemoveImage { /** * @var DeleteAssetsByPathsInterface diff --git a/app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php b/app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/RemoveAssetAfterRemoveImageTest.php similarity index 94% rename from app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php rename to app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/RemoveAssetAfterRemoveImageTest.php index 3a8c9294259f9..7cb071a5aebe4 100644 --- a/app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/ProcessorTest.php +++ b/app/code/Magento/MediaGalleryCatalog/Test/Unit/Plugin/Product/Gallery/RemoveAssetAfterRemoveImageTest.php @@ -10,7 +10,7 @@ use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Gallery\Processor as ProcessorSubject; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; -use Magento\MediaGalleryCatalog\Plugin\Product\Gallery\Processor; +use Magento\MediaGalleryCatalog\Plugin\Product\Gallery\RemoveAssetAfterRemoveImage; use Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -19,7 +19,7 @@ /** * Unit test for \Magento\MediaGalleryCatalog\Plugin\Product\Gallery\Processor */ -class ProcessorTest extends TestCase +class RemoveAssetAfterRemoveImageTest extends TestCase { private const STUB_FILE_NAME = 'file'; @@ -44,7 +44,7 @@ class ProcessorTest extends TestCase private $productMock; /** - * @var Processor + * @var RemoveAssetAfterRemoveImage */ private $plugin; @@ -60,7 +60,7 @@ protected function setUp() $this->loggerMock = $this->createMock(LoggerInterface::class); $this->plugin = (new ObjectManagerHelper($this))->getObject( - Processor::class, + RemoveAssetAfterRemoveImage::class, [ 'deleteByPaths' => $this->deleteMediaAssetByPathMock, 'logger' => $this->loggerMock diff --git a/app/code/Magento/MediaGalleryCatalog/etc/di.xml b/app/code/Magento/MediaGalleryCatalog/etc/di.xml index 41dfeaf14aace..8145134025990 100644 --- a/app/code/Magento/MediaGalleryCatalog/etc/di.xml +++ b/app/code/Magento/MediaGalleryCatalog/etc/di.xml @@ -7,7 +7,6 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Catalog\Model\Product\Gallery\Processor"> - <plugin name="media_gallery_image_remove_metadata" type="Magento\MediaGallery\Plugin\Product\Gallery\Processor" - sortOrder="10" disabled="false"/> + <plugin name="media_gallery_image_remove_metadata" type="Magento\MediaGallery\Plugin\Product\Gallery\RemoveAssetAfterRemoveImage"/> </type> </config> From 6a94b59b22a17d20459a66c82df8515dacd09c98 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Tue, 14 Apr 2020 15:44:18 -0500 Subject: [PATCH 152/177] magento/magento2#27499: Code review fixes --- ...Config.php => BlacklistPatternsConfig.php} | 2 +- .../Model/Directory/ConfigInterface.php | 21 ------------------- .../Model/Directory/IsBlacklistedTest.php | 1 - app/code/Magento/MediaGallery/etc/di.xml | 7 ++----- 4 files changed, 3 insertions(+), 28 deletions(-) rename app/code/Magento/MediaGallery/Model/Directory/{Config.php => BlacklistPatternsConfig.php} (91%) delete mode 100644 app/code/Magento/MediaGallery/Model/Directory/ConfigInterface.php diff --git a/app/code/Magento/MediaGallery/Model/Directory/Config.php b/app/code/Magento/MediaGallery/Model/Directory/BlacklistPatternsConfig.php similarity index 91% rename from app/code/Magento/MediaGallery/Model/Directory/Config.php rename to app/code/Magento/MediaGallery/Model/Directory/BlacklistPatternsConfig.php index 67695080b185f..8fdd4f70d5060 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Config.php +++ b/app/code/Magento/MediaGallery/Model/Directory/BlacklistPatternsConfig.php @@ -13,7 +13,7 @@ /** * Media gallery directory config */ -class Config implements BlacklistPatternsConfigInterface +class BlacklistPatternsConfig implements BlacklistPatternsConfigInterface { private const XML_PATH_BLACKLIST_PATTERNS = 'blacklist/patterns'; diff --git a/app/code/Magento/MediaGallery/Model/Directory/ConfigInterface.php b/app/code/Magento/MediaGallery/Model/Directory/ConfigInterface.php deleted file mode 100644 index 80d6c0be6b746..0000000000000 --- a/app/code/Magento/MediaGallery/Model/Directory/ConfigInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaGallery\Model\Directory; - -/** - * Media gallery directory config - */ -interface ConfigInterface -{ - /** - * Returns list of blacklist RegEx patterns - * - * @return array - */ - public function getBlacklistPatterns(): array; -} diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php index 549974d27b58f..a60c4d75aee7d 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php @@ -9,7 +9,6 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\MediaGallery\Model\Directory\IsBlacklisted; -use Magento\MediaGallery\Model\Directory\Config; use Magento\MediaGalleryApi\Model\BlacklistPatternsConfigInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; diff --git a/app/code/Magento/MediaGallery/etc/di.xml b/app/code/Magento/MediaGallery/etc/di.xml index 31c89528c96c9..a85c26e275226 100644 --- a/app/code/Magento/MediaGallery/etc/di.xml +++ b/app/code/Magento/MediaGallery/etc/di.xml @@ -9,9 +9,6 @@ <preference for="Magento\MediaGalleryApi\Api\Data\KeywordInterface" type="Magento\MediaGallery\Model\Keyword"/> <preference for="Magento\MediaGalleryApi\Api\Data\AssetInterface" type="Magento\MediaGallery\Model\Asset"/> <preference for="Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface" type="Magento\MediaGallery\Model\AssetKeywords"/> - - <preference for="Magento\MediaGallery\Model\Directory\ConfigInterface" type="Magento\MediaGallery\Model\Directory\Config"/> - <preference for="Magento\MediaGalleryApi\Model\Asset\Command\GetByIdInterface" type="Magento\MediaGallery\Model\Asset\Command\GetById"/> <preference for="Magento\MediaGalleryApi\Model\Asset\Command\SaveInterface" type="Magento\MediaGallery\Model\Asset\Command\Save"/> <preference for="Magento\MediaGalleryApi\Model\Asset\Command\GetByPathInterface" type="Magento\MediaGallery\Model\Asset\Command\GetByPath"/> @@ -53,11 +50,11 @@ <argument name="cacheId" xsi:type="string">Media_Gallery_Patterns_CacheId</argument> </arguments> </virtualType> - <type name="Magento\MediaGallery\Model\Directory\Config"> + <type name="Magento\MediaGallery\Model\Directory\BlacklistPatternsConfig"> <arguments> <argument name="data" xsi:type="object">Magento\MediaGallery\Model\Directory\Config\Data</argument> </arguments> </type> - <preference for="Magento\MediaGalleryApi\Model\BlacklistPatternsConfigInterface" type="Magento\MediaGallery\Model\Directory\Config"/> + <preference for="Magento\MediaGalleryApi\Model\BlacklistPatternsConfigInterface" type="Magento\MediaGallery\Model\Directory\BlacklistPatternsConfig"/> </config> From a3fb28a1086e5431714fd97fdc67fbff35da03da Mon Sep 17 00:00:00 2001 From: Hwashiang Yu <hwyu@adobe.com> Date: Tue, 14 Apr 2020 20:35:09 -0500 Subject: [PATCH 153/177] MC-30175: UI component rendering config - Added CE changes --- .../Product/Form/Modifier/BundlePriceTest.php | 3 ++- .../Form/Modifier/BundleWeightTest.php | 1 + .../Form/Modifier/BundleAdvancedPricing.php | 10 +++++--- .../Form/Modifier/BundleCustomOptions.php | 6 +++-- .../Product/Form/Modifier/BundlePanel.php | 23 +++++++++++++---- .../Product/Form/Modifier/BundlePrice.php | 6 +++-- .../Product/Form/Modifier/BundleWeight.php | 7 +++--- .../Model/Product/AttributeSet/Options.php | 18 +++++++------ .../Unit/Ui/Component/ColumnFactoryTest.php | 2 -- .../Ui/Component/Product/MassActionTest.php | 10 +------- .../Product/Form/Modifier/EavTest.php | 7 ------ .../Catalog/Ui/Component/ColumnFactory.php | 1 - .../Listing/Columns/ProductActions.php | 3 +-- .../Ui/Component/Product/MassAction.php | 4 +-- .../Product/Form/Modifier/AdvancedPricing.php | 4 ++- .../Product/Form/Modifier/AttributeSet.php | 7 ------ .../Product/Form/Modifier/Attributes.php | 18 ++++++++++--- .../Product/Form/Modifier/Categories.php | 1 + .../Product/Form/Modifier/CustomOptions.php | 15 ++++++++--- .../Product/Form/Modifier/Eav.php | 2 -- .../Product/Form/Modifier/General.php | 3 ++- .../Product/Form/Modifier/Related.php | 13 +++++++--- .../Product/Form/Modifier/TierPrice.php | 4 +++ .../Product/Form/Modifier/Websites.php | 3 ++- .../web/js/tier-price/value-type-select.js | 5 ++-- .../Form/Modifier/AdvancedInventory.php | 2 ++ .../Form/Modifier/ProductUrlRewrite.php | 1 + .../Block/Checkout/LayoutProcessor.php | 2 ++ .../Block/Checkout/LayoutProcessorTest.php | 1 + .../Listing/Column/BlockActionsTest.php | 2 -- .../Listing/Column/PageActionsTest.php | 4 --- .../Component/Listing/Column/BlockActions.php | 2 -- .../Component/Listing/Column/PageActions.php | 4 --- .../Model/Config/Source/Email/Template.php | 6 ----- .../Config/Source/Email/TemplateTest.php | 3 --- .../Edit/Tab/Variations/Config/Matrix.php | 3 +++ .../ConfigurableAttributeSetHandler.php | 6 +++-- .../Form/Modifier/ConfigurablePanel.php | 25 ++++++++++++++++--- .../Form/Modifier/ConfigurablePrice.php | 5 ++-- .../Product/Form/Modifier/CustomOptions.php | 8 +++--- .../Form/Modifier/Data/AssociatedProducts.php | 5 ---- .../Product/Form/Modifier/StockData.php | 1 + .../Model/Customer/Attribute/Source/Group.php | 7 ------ .../Customer/Model/Customer/DataProvider.php | 3 ++- .../Unit/Model/Customer/DataProviderTest.php | 2 ++ .../Unit/Ui/Component/ColumnFactoryTest.php | 1 - .../Unit/Ui/Component/FilterFactoryTest.php | 1 - .../Component/Listing/Column/ActionsTest.php | 3 +-- .../Listing/Column/GroupActionsTest.php | 4 --- .../Customer/Ui/Component/ColumnFactory.php | 1 - .../Customer/Ui/Component/FilterFactory.php | 1 - .../Ui/Component/Listing/Column/Actions.php | 1 - .../Component/Listing/Column/GroupActions.php | 2 -- .../Ui/Component/MassAction/Group/Options.php | 4 ++- .../Form/Modifier/DownloadablePanel.php | 11 +++++--- .../Product/Form/Modifier/Links.php | 4 ++- .../Product/Form/Modifier/UsedDefault.php | 9 +++++-- .../Product/Modifier/GiftMessage.php | 2 ++ .../Product/Form/Modifier/Grouped.php | 7 +++++- .../Listing/Column/Method/Options.php | 9 +------ .../DataProvider/Modifier/Notifications.php | 8 ++++-- .../Product/Form/Modifier/Review.php | 6 +++-- .../Listing/Column/Status/OptionsTest.php | 3 +-- .../Listing/Column/Status/Options.php | 10 +------- .../Listing/Column/SynonymActionsTest.php | 2 -- .../Listing/Column/SynonymActions.php | 2 -- .../Listing/Column/EditActionTest.php | 3 +-- .../Listing/Column/ViewActionTest.php | 2 -- .../Config/SearchRobots/ResetButton.php | 1 + .../Component/Listing/Column/EditAction.php | 3 +-- .../Component/Listing/Column/ViewAction.php | 3 +-- app/code/Magento/Ui/Component/MassAction.php | 2 +- .../Ui/Test/Unit/Component/MassActionTest.php | 4 +-- .../Config/Source/Group/MultiselectTest.php | 5 +--- 74 files changed, 201 insertions(+), 181 deletions(-) diff --git a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundlePriceTest.php b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundlePriceTest.php index b0519f1ebddba..5d06150d197a9 100644 --- a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundlePriceTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundlePriceTest.php @@ -68,7 +68,8 @@ public function testModifyMeta() ]; $priceParams = [ 'imports' => [ - 'disabled' => 'ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked' + 'disabled' => 'ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['disabled' => false], ] ]; $priceMeta = [ diff --git a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundleWeightTest.php b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundleWeightTest.php index 8c89a18c292f6..c826bba4dbabb 100644 --- a/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundleWeightTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Ui/DataProvider/Product/Form/Modifier/BundleWeightTest.php @@ -58,6 +58,7 @@ public function testModifyMeta() $weightParams = [ 'imports' => [ 'disabled' => 'ns = ${ $.ns }, index = ' . BundleWeight::CODE_WEIGHT_TYPE . ':checked', + '__disableTmpl' => ['disabled' => false], ] ]; $hasWeightParams = [ diff --git a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleAdvancedPricing.php b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleAdvancedPricing.php index 1b04bdc4f8104..312a812402e97 100644 --- a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleAdvancedPricing.php +++ b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleAdvancedPricing.php @@ -34,7 +34,7 @@ public function __construct(ArrayManager $arrayManager) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -63,7 +63,7 @@ public function modifyMeta(array $meta) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { @@ -88,7 +88,8 @@ private function modifyMsrpMeta(array $meta) $meta, [ 'imports' => [ - 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked' + 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['disabled' => false], ] ] ); @@ -103,7 +104,8 @@ private function modifyMsrpMeta(array $meta) $meta, [ 'imports' => [ - 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked' + 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['disabled' => false], ] ] ); diff --git a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleCustomOptions.php b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleCustomOptions.php index 1a0e08bd07255..b25fad0a40677 100644 --- a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleCustomOptions.php +++ b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleCustomOptions.php @@ -15,7 +15,7 @@ class BundleCustomOptions extends AbstractModifier { /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -55,6 +55,7 @@ public function modifyCustomOptionsButton(array $meta, $group, $container, $butt if (!empty($meta[$group]['children'][$container]['children'][$button])) { $meta[$group]['children'][$container]['children'][$button]['arguments']['data']['config']['imports'] = [ 'visible' => '!ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['visible' => false], ]; } return $meta; @@ -79,6 +80,7 @@ public function getErrorMessage($sortOrder) 'sortOrder' => $sortOrder, 'imports' => [ 'visible' => 'ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['visible' => false], ], ], ], @@ -87,7 +89,7 @@ public function getErrorMessage($sortOrder) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { diff --git a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php index 18f970069c3c9..5ff9e674acad9 100644 --- a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php +++ b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php @@ -319,6 +319,7 @@ protected function getBundleHeader() * Get Bundle Options structure * * @return array + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function getBundleOptions() { @@ -348,7 +349,8 @@ protected function getBundleOptions() 'component' => 'Magento_Ui/js/dynamic-rows/record', 'positionProvider' => 'product_bundle_container.position', 'imports' => [ - 'label' => '${ $.name }' . '.product_bundle_container.option_info.title:value' + 'label' => '${ $.name }' . '.product_bundle_container.option_info.title:value', + '__disableTmpl' => ['label' => false], ], ], ], @@ -381,6 +383,7 @@ protected function getBundleOptions() 'template' => 'ui/dynamic-rows/templates/default', 'provider' => 'product_form.product_form_data_source', 'dataProvider' => '${ $.dataScope }' . '.bundle_button_proxy', + '__disableTmpl' => ['dataProvider' => false], 'identificationDRProperty' => 'product_id', 'identificationProperty' => 'product_id', 'map' => [ @@ -395,9 +398,13 @@ protected function getBundleOptions() 'selection_price_value' => '', 'selection_qty' => '', ], - 'links' => ['insertData' => '${ $.provider }:${ $.dataProvider }'], + 'links' => [ + 'insertData' => '${ $.provider }:${ $.dataProvider }', + '__disableTmpl' => ['insertData' => false], + ], 'imports' => [ 'inputType' => '${$.provider}:${$.dataScope}.type', + '__disableTmpl' => ['inputType' => false], ], 'source' => 'product', ], @@ -619,9 +626,11 @@ protected function getBundleSelections() 'is_collection' => true, 'imports' => [ 'inputType' => '${$.parentName}:inputType', + '__disableTmpl' => ['inputType' => false], ], 'exports' => [ 'isDefaultValue' => '${$.parentName}:isDefaultValue.${$.index}', + '__disableTmpl' => ['isDefaultValue' => false], ], ], ], @@ -702,7 +711,8 @@ protected function getBundleSelections() 'validate-greater-than-zero' => true ], 'imports' => [ - 'isInteger' => '${ $.provider }:${ $.parentScope }.selection_qty_is_integer' + 'isInteger' => '${ $.provider }:${ $.parentScope }.selection_qty_is_integer', + '__disableTmpl' => ['isInteger' => false], ], ], ], @@ -723,6 +733,7 @@ protected function getBundleSelections() 'sortOrder' => 110, 'imports' => [ 'inputType' => '${$.parentName}:inputType', + '__disableTmpl' => ['inputType' => false], ], ], ], @@ -764,7 +775,8 @@ protected function getSelectionPriceValue() 'dataScope' => 'selection_price_value', 'value' => '0.00', 'imports' => [ - 'visible' => '!ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked' + 'visible' => '!ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['visible' => false], ], 'sortOrder' => 80, ], @@ -801,7 +813,8 @@ protected function getSelectionPriceType() ] ], 'imports' => [ - 'visible' => '!ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked' + 'visible' => '!ns = ${ $.ns }, index = ' . BundlePrice::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['visible' => false], ], 'sortOrder' => 90, ], diff --git a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php index d7da7513c3aac..598b762c061a1 100644 --- a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php +++ b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePrice.php @@ -71,7 +71,8 @@ public function modifyMeta(array $meta) $meta, [ 'imports' => [ - 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked' + 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['disabled' => false], ] ] ); @@ -86,7 +87,8 @@ public function modifyMeta(array $meta) $meta, [ 'imports' => [ - 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked' + 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_PRICE_TYPE . ':checked', + '__disableTmpl' => ['disabled' => false], ] ] ); diff --git a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleWeight.php b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleWeight.php index 83e045d3562cf..39e9b3d7b5cd4 100644 --- a/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleWeight.php +++ b/app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundleWeight.php @@ -30,7 +30,7 @@ public function __construct(ArrayManager $arrayManager) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -73,15 +73,16 @@ public function modifyMeta(array $meta) [ 'imports' => [ 'disabled' => 'ns = ${ $.ns }, index = ' . static::CODE_WEIGHT_TYPE . ':checked', + '__disableTmpl' => ['disabled' => false], ] ] ); - + return $meta; } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { diff --git a/app/code/Magento/Catalog/Model/Product/AttributeSet/Options.php b/app/code/Magento/Catalog/Model/Product/AttributeSet/Options.php index 57d08916bcd40..89c550d4e0ab3 100644 --- a/app/code/Magento/Catalog/Model/Product/AttributeSet/Options.php +++ b/app/code/Magento/Catalog/Model/Product/AttributeSet/Options.php @@ -10,11 +10,22 @@ */ class Options implements \Magento\Framework\Data\OptionSourceInterface { + /** * @var array */ protected $options; + /** + * @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory + */ + protected $collectionFactory; + + /** + * @var \Magento\Catalog\Model\ResourceModel\Product + */ + protected $product; + /** * @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $collectionFactory * @param \Magento\Catalog\Model\ResourceModel\Product $product @@ -36,13 +47,6 @@ public function toOptionArray() $this->options = $this->collectionFactory->create() ->setEntityTypeFilter($this->product->getTypeId()) ->toOptionArray(); - - array_walk( - $this->options, - function (&$option) { - $option['__disableTmpl'] = true; - } - ); } return $this->options; diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php index b3acaa4b8bbed..ba81d42e75c76 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php @@ -129,7 +129,6 @@ public function testCreateWithNotFilterableInGridAttribute(array $filterModifier 'visible' => null, 'filter' => $filter, 'component' => 'Magento_Ui/js/grid/columns/column', - '__disableTmpl' => ['label' => true] ], ], 'context' => $this->context, @@ -206,7 +205,6 @@ public function testCreateDateColumn( 'component' => 'Magento_Ui/js/grid/columns/date', 'timezone' => $expectedTimezone, 'dateFormat' => $expectedDateFormat, - '__disableTmpl' => ['label' => true], 'options' => [ 'showsTime' => $showsTime ] diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php index c704d9f89581d..966d5bc308c09 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php @@ -13,7 +13,7 @@ use Magento\Framework\View\Element\UiComponent\ContextInterface; /** - * MassAction test + * MassAction test for Component Product */ class MassActionTest extends \PHPUnit\Framework\TestCase { @@ -107,7 +107,6 @@ public function getPrepareDataProvider() : array 'type' => 'first_action', 'label' => 'First Action', 'url' => '/module/controller/firstAction', - '__disableTmpl' => true ], ], [ @@ -127,7 +126,6 @@ public function getPrepareDataProvider() : array 'url' => '/module/controller/secondSubAction2' ], ], - '__disableTmpl' => true ], ], [ @@ -147,7 +145,6 @@ public function getPrepareDataProvider() : array 'url' => '/module/controller/disable' ], ], - '__disableTmpl' => true ], ], [ @@ -167,7 +164,6 @@ public function getPrepareDataProvider() : array 'url' => '/module/controller/disable' ], ], - '__disableTmpl' => true ], false, false @@ -178,7 +174,6 @@ public function getPrepareDataProvider() : array 'type' => 'delete', 'label' => 'First Action', 'url' => '/module/controller/delete', - '__disableTmpl' => true ], ], [ @@ -187,7 +182,6 @@ public function getPrepareDataProvider() : array 'type' => 'delete', 'label' => 'First Action', 'url' => '/module/controller/delete', - '__disableTmpl' => true ], false, false @@ -198,7 +192,6 @@ public function getPrepareDataProvider() : array 'type' => 'delete', 'label' => 'First Action', 'url' => '/module/controller/attributes', - '__disableTmpl' => true ], ], [ @@ -207,7 +200,6 @@ public function getPrepareDataProvider() : array 'type' => 'delete', 'label' => 'First Action', 'url' => '/module/controller/attributes', - '__disableTmpl' => true ], false, false diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php index 91e22407acc43..917ef2bd522f8 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php @@ -570,7 +570,6 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, - '__disableTmpl' => ['label' => true, 'code' => true] ], ], 'default_null_prod_not_new_locked_and_required' => [ @@ -590,7 +589,6 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, - '__disableTmpl' => ['label' => true, 'code' => true] ], 'locked' => true, ], @@ -611,7 +609,6 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, - '__disableTmpl' => ['label' => true, 'code' => true] ], ], 'default_null_prod_new_and_not_required' => [ @@ -631,7 +628,6 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, - '__disableTmpl' => ['label' => true, 'code' => true] ], ], 'default_null_prod_new_locked_and_not_required' => [ @@ -651,7 +647,6 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, - '__disableTmpl' => ['label' => true, 'code' => true] ], 'locked' => true, ], @@ -672,7 +667,6 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, - '__disableTmpl' => ['label' => true, 'code' => true] ], ], 'datetime_null_prod_not_new_and_required' => [ @@ -692,7 +686,6 @@ public function setupAttributeMetaDataProvider() 'scopeLabel' => '', 'globalScope' => false, 'sortOrder' => 0, - '__disableTmpl' => ['label' => true, 'code' => true] ], 'locked' => false, 'frontendInput' => 'datetime', diff --git a/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php b/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php index b902e741c006c..c7afc61e38ca4 100644 --- a/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php +++ b/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php @@ -92,7 +92,6 @@ public function create($attribute, $context, array $config = []) 'filter' => ($attribute->getIsFilterableInGrid() || array_key_exists($columnName, $filterModifiers)) ? $this->getFilterType($attribute->getFrontendInput()) : null, - '__disableTmpl' => ['label' => true], ], $config ); diff --git a/app/code/Magento/Catalog/Ui/Component/Listing/Columns/ProductActions.php b/app/code/Magento/Catalog/Ui/Component/Listing/Columns/ProductActions.php index 596b0f4118599..c54cfa28fcda0 100644 --- a/app/code/Magento/Catalog/Ui/Component/Listing/Columns/ProductActions.php +++ b/app/code/Magento/Catalog/Ui/Component/Listing/Columns/ProductActions.php @@ -11,7 +11,7 @@ use Magento\Framework\UrlInterface; /** - * Class ProductActions + * Class ProductActions for Listing Columns * * @api * @since 100.0.2 @@ -60,7 +60,6 @@ public function prepareDataSource(array $dataSource) ), 'label' => __('Edit'), 'hidden' => false, - '__disableTmpl' => true ]; } } diff --git a/app/code/Magento/Catalog/Ui/Component/Product/MassAction.php b/app/code/Magento/Catalog/Ui/Component/Product/MassAction.php index f770f6b9c497f..be6de45e20de2 100644 --- a/app/code/Magento/Catalog/Ui/Component/Product/MassAction.php +++ b/app/code/Magento/Catalog/Ui/Component/Product/MassAction.php @@ -13,7 +13,7 @@ use Magento\Ui\Component\AbstractComponent; /** - * Class MassAction + * Class MassAction for Component Product */ class MassAction extends AbstractComponent { @@ -53,7 +53,7 @@ public function prepare() : void $actionType = $actionComponent->getConfiguration()['type']; if ($this->isActionAllowed($actionType)) { // phpcs:ignore Magento2.Performance.ForeachArrayMerge - $config['actions'][] = array_merge($actionComponent->getConfiguration(), ['__disableTmpl' => true]); + $config['actions'][] = array_merge($actionComponent->getConfiguration()); } } $origConfig = $this->getConfiguration(); diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php index f19f5abd0b423..174a01b72a109 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php @@ -26,7 +26,7 @@ use Magento\Framework\Stdlib\ArrayManager; /** - * Class AdvancedPricing + * Class for Product Modifier Advanced Pricing * * @api * @@ -559,6 +559,7 @@ private function getTierPriceStructure($tierPricePath) ], 'imports' => [ 'priceValue' => '${ $.provider }:data.product.price', + '__disableTmpl' => ['priceValue' => false], ], ], ], @@ -664,6 +665,7 @@ private function customizeAdvancedPricing() 'actions' => [ [ 'targetName' => '${ $.name }', + '__disableTmpl' => ['targetName' => false], 'actionName' => 'actionDone' ] ] diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php index 53c9595b59e76..cb87e4dc9910f 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AttributeSet.php @@ -80,13 +80,6 @@ public function getOptions() $collectionData = $collection->getData() ?? []; - array_walk( - $collectionData, - function (&$attribute) { - $attribute['__disableTmpl'] = true; - } - ); - return $collectionData; } diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php index a6b9856a4a0ed..5690e4af72375 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Attributes.php @@ -13,7 +13,7 @@ use Magento\Ui\Component\Container; /** - * Class Attributes + * Class for Product Modifier Attributes * * @api * @since 101.0.0 @@ -138,6 +138,7 @@ private function customizeAddAttributeModal(array $meta) 'actions' => [ [ 'targetName' => '${ $.name }', + '__disableTmpl' => ['targetName' => false], 'actionName' => 'actionCancel' ] ] @@ -148,6 +149,7 @@ private function customizeAddAttributeModal(array $meta) 'actions' => [ [ 'targetName' => '${ $.name }.product_attributes_grid', + '__disableTmpl' => ['targetName' => false], 'actionName' => 'save' ], [ @@ -271,6 +273,7 @@ private function customizeCreateAttributeModal(array $meta) 'externalProvider' => 'product_attribute_add_form' . '.product_attribute_add_form_data_source', 'toolbarContainer' => '${ $.parentName }', + '__disableTmpl' => ['toolbarContainer' => false], 'formSubmitType' => 'ajax', 'saveUrl' => $this->urlBuilder->getUrl('catalog/product_attribute/save', $params), 'validateUrl' => $this->urlBuilder->getUrl( @@ -281,11 +284,17 @@ private function customizeCreateAttributeModal(array $meta) 'productType' => $this->locator->getProduct()->getTypeId(), 'imports' => [ 'attributeSetId' => '${ $.provider }:data.product.attribute_set_id', + '__disableTmpl' => ['attributeSetId' => false], ], 'exports' => [ 'saveUrl' => '${ $.externalProvider }:client.urls.save', 'validateUrl' => '${ $.externalProvider }:client.urls.beforeSave', 'attributeSetId' => '${ $.externalProvider }:params.set', + '__disableTmpl' => [ + 'saveUrl' => false, + 'validateUrl' => false, + 'attributeSetId' => false + ], ] ] ] @@ -321,6 +330,7 @@ private function customizeAttributesGrid(array $meta) 'externalFilterMode' => true, 'dataLinks' => ['imports' => false, 'exports' => false], 'formProvider' => 'ns = ${ $.namespace }, index = product_form', + '__disableTmpl' => ['selectionsProvider' => false, 'formProvider' => false], 'groupCode' => static::GROUP_CODE, 'groupName' => static::GROUP_NAME, 'groupSortOrder' => static::GROUP_SORT_ORDER, @@ -330,10 +340,12 @@ private function customizeAttributesGrid(array $meta) 'productType' => $this->locator->getProduct()->getTypeId(), 'loading' => false, 'imports' => [ - 'attributeSetId' => '${ $.provider }:data.product.attribute_set_id' + 'attributeSetId' => '${ $.provider }:data.product.attribute_set_id', + '__disableTmpl' => ['attributeSetId' => false], ], 'exports' => [ - 'attributeSetId' => '${ $.externalProvider }:params.template_id' + 'attributeSetId' => '${ $.externalProvider }:params.template_id', + '__disableTmpl' => ['attributeSetId' => false], ] ], ], diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php index cd1f8e8e3379b..7608173c8edfc 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php @@ -210,6 +210,7 @@ protected function createNewCategoryModal(array $meta) 'ns' => 'new_category_form', 'externalProvider' => 'new_category_form.new_category_form_data_source', 'toolbarContainer' => '${ $.parentName }', + '__disableTmpl' => ['toolbarContainer' => false], 'formSubmitType' => 'ajax', ], ], diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php index 65792b395dc06..2e1ea59573c3b 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php @@ -351,6 +351,7 @@ protected function getHeaderContainerConfig($sortOrder) [ 'targetName' => '${ $.ns }.${ $.ns }.' . static::GROUP_CUSTOM_OPTIONS_NAME . '.' . static::GRID_OPTIONS_NAME, + '__disableTmpl' => ['targetName' => false], 'actionName' => 'processingAddChild', ] ] @@ -388,7 +389,10 @@ protected function getOptionsGridConfig($sortOrder) 'collapsibleHeader' => true, 'sortOrder' => $sortOrder, 'dataProvider' => static::CUSTOM_OPTIONS_LISTING, - 'imports' => ['insertData' => '${ $.provider }:${ $.dataProvider }'], + 'imports' => [ + 'insertData' => '${ $.provider }:${ $.dataProvider }', + '__disableTmpl' => ['insertData' => false], + ], ], ], ], @@ -513,7 +517,8 @@ protected function getImportOptionsModalConfig() 'exports' => true ], 'exports' => [ - 'currentProductId' => '${ $.externalProvider }:params.current_product_id' + 'currentProductId' => '${ $.externalProvider }:params.current_product_id', + '__disableTmpl' => ['currentProductId' => false], ] ], ], @@ -559,7 +564,8 @@ protected function getCommonContainerConfig($sortOrder) 'valueUpdate' => 'input', 'imports' => [ 'optionId' => '${ $.provider }:${ $.parentScope }.option_id', - 'isUseDefault' => '${ $.provider }:${ $.parentScope }.is_use_default' + 'isUseDefault' => '${ $.provider }:${ $.parentScope }.is_use_default', + '__disableTmpl' => ['optionId' => false, 'isUseDefault' => false], ] ], ], @@ -638,7 +644,8 @@ protected function getSelectTypeGridConfig($sortOrder) 'imports' => [ 'optionId' => '${ $.provider }:${ $.parentScope }.option_id', 'optionTypeId' => '${ $.provider }:${ $.parentScope }.option_type_id', - 'isUseDefault' => '${ $.provider }:${ $.parentScope }.is_use_default' + 'isUseDefault' => '${ $.provider }:${ $.parentScope }.is_use_default', + '__disableTmpl' => ['optionId' => false, 'optionTypeId' => false, 'isUseDefault' => false], ], 'service' => [ 'template' => 'Magento_Catalog/form/element/helper/custom-option-type-service', diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php index 25e816f79639a..0295e778f2b9b 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php @@ -686,7 +686,6 @@ public function setupAttributeMeta(ProductAttributeInterface $attribute, $groupC 'scopeLabel' => $this->getScopeLabel($attribute), 'globalScope' => $this->isScopeGlobal($attribute), 'sortOrder' => $sortOrder * self::SORT_ORDER_MULTIPLIER, - '__disableTmpl' => ['label' => true, 'code' => true] ] ); $product = $this->locator->getProduct(); @@ -861,7 +860,6 @@ public function setupAttributeContainerMeta(ProductAttributeInterface $attribute 'breakLine' => false, 'label' => $attribute->getDefaultFrontendLabel(), 'required' => $attribute->getIsRequired(), - '__disableTmpl' => ['label' => true] ] ); diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php index ebc0425be0188..371022e70123d 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php @@ -228,7 +228,8 @@ protected function customizeWeightField(array $meta) 'addafter' => $this->locator->getStore()->getConfig('general/locale/weight_unit'), 'imports' => $disabled ? [] : [ 'disabled' => '!${$.provider}:' . self::DATA_SCOPE_PRODUCT - . '.product_has_weight:value' + . '.product_has_weight:value', + '__disableTmpl' => ['disabled' => false], ] ] ); diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Related.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Related.php index b4acb93dcd14f..fb1c310a8a2b4 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Related.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Related.php @@ -25,7 +25,7 @@ use Magento\Catalog\Model\Product\Attribute\Source\Status; /** - * Class Related + * Class for Product Modifier Related * * @api * @@ -143,7 +143,8 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc + * * @since 101.0.0 */ public function modifyMeta(array $meta) @@ -182,7 +183,8 @@ public function modifyMeta(array $meta) } /** - * {@inheritdoc} + * @inheritdoc + * * @since 101.0.0 */ public function modifyData(array $data) @@ -528,10 +530,12 @@ protected function getGenericModal(Phrase $title, $scope) 'imports' => [ 'productId' => '${ $.provider }:data.product.current_product_id', 'storeId' => '${ $.provider }:data.product.current_store_id', + '__disableTmpl' => ['productId' => false, 'storeId' => false], ], 'exports' => [ 'productId' => '${ $.externalProvider }:params.current_product_id', 'storeId' => '${ $.externalProvider }:params.current_store_id', + '__disableTmpl' => ['productId' => false, 'storeId' => false], ] ], ], @@ -582,7 +586,8 @@ protected function getGrid($scope) 'thumbnail' => 'thumbnail_src', ], 'links' => [ - 'insertData' => '${ $.provider }:${ $.dataProvider }' + 'insertData' => '${ $.provider }:${ $.dataProvider }', + '__disableTmpl' => ['insertData' => false], ], 'sortOrder' => 2, ], diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php index 9c5fffc5db9b9..c64d3e2e4effb 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php @@ -138,6 +138,10 @@ private function getUpdatedTierPriceStructure(array $priceMeta) . ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE, ProductPriceOptionsInterface::VALUE_PERCENT => '${ $.parentName }.' . ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PERCENTAGE_VALUE, + '__disableTmpl' => [ + ProductPriceOptionsInterface::VALUE_FIXED => false, + ProductPriceOptionsInterface::VALUE_PERCENT => false, + ], ], ], ], diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Websites.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Websites.php index de204b312a3fd..430b6c004e772 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Websites.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Websites.php @@ -259,7 +259,8 @@ protected function getDynamicRow($websiteId, $sortOrder) 'columnsHeader' => true, 'dndConfig' => ['enabled' => false], 'imports' => [ - 'visible' => '${$.namespace}.${$.namespace}.websites.' . $websiteId . ':checked' + 'visible' => '${$.namespace}.${$.namespace}.websites.' . $websiteId . ':checked', + '__disableTmpl' => ['visible' => false], ], 'itemTemplate' => 'record', 'dataScope' => '', diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/tier-price/value-type-select.js b/app/code/Magento/Catalog/view/adminhtml/web/js/tier-price/value-type-select.js index e1a15a93e793d..ff8a3586d0077 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/tier-price/value-type-select.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/tier-price/value-type-select.js @@ -19,8 +19,9 @@ define([ * {@inheritdoc} */ initialize: function () { - this._super() - .prepareForm(); + this._super(); + delete this.prices.__disableTmpl; + this.prepareForm(); }, /** diff --git a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php index 38a33b75f552a..c8509f665876d 100644 --- a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php +++ b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php @@ -197,6 +197,7 @@ private function prepareMeta() 'scopeLabel' => '[GLOBAL]', 'imports' => [ 'visible' => '${$.provider}:data.product.stock_data.manage_stock', + '__disableTmpl' => ['visible' => false], ], ] ); @@ -240,6 +241,7 @@ private function prepareMeta() ], 'imports' => [ 'handleChanges' => '${$.provider}:data.product.stock_data.is_qty_decimal', + '__disableTmpl' => ['handleChanges' => false], ], 'sortOrder' => 10, 'disabled' => $this->locator->getProduct()->isLockedAttribute($fieldCode), diff --git a/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php b/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php index 10791eae5405f..9567f78414d78 100644 --- a/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php +++ b/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php @@ -125,6 +125,7 @@ protected function addUrlRewriteCheckbox(array $meta) 'handleUseDefault' => '${ $.parentName }.url_key:isUseDefault', 'handleChanges' => '${ $.provider }:data.product.' . ProductAttributeInterface::CODE_SEO_FIELD_URL_KEY, + '__disableTmpl' => ['urlKey' => false, 'handleUseDefault' => false, 'handleChanges' => false], ], 'description' => __('Create Permanent Redirect for old URL'), 'dataScope' => 'url_key_create_redirect', diff --git a/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php b/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php index 00cc06ea0ff47..16450ec6ff2c2 100644 --- a/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php +++ b/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php @@ -299,6 +299,7 @@ private function getBillingAddressComponent($paymentCode, $elements) 'deps' => 'checkoutProvider', 'dataScopePrefix' => 'billingAddress' . $paymentCode, 'billingAddressListProvider' => '${$.name}.billingAddressList', + '__disableTmpl' => ['billingAddressListProvider' => false], 'sortOrder' => 1, 'children' => [ 'billingAddressList' => [ @@ -329,6 +330,7 @@ private function getBillingAddressComponent($paymentCode, $elements) ], 'filterBy' => [ 'target' => '${ $.provider }:${ $.parentScope }.country_id', + '__disableTmpl' => ['target' => false], 'field' => 'country_id', ], ], diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Checkout/LayoutProcessorTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Checkout/LayoutProcessorTest.php index 9fff4b622e596..7b7d956f457f0 100644 --- a/app/code/Magento/Checkout/Test/Unit/Block/Checkout/LayoutProcessorTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Block/Checkout/LayoutProcessorTest.php @@ -255,6 +255,7 @@ private function getBillingComponent($paymentCode) ], 'filterBy' => [ 'target' => '${ $.provider }:${ $.parentScope }.country_id', + '__disableTmpl' => ['target' => false], 'field' => 'country_id', ], ], diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php index 4ffe4a6ad8774..e38f7b7fc6704 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php @@ -96,7 +96,6 @@ public function testPrepareDataSource() 'edit' => [ 'href' => 'test/url/edit', 'label' => __('Edit'), - '__disableTmpl' => true, ], 'delete' => [ 'href' => 'test/url/delete', @@ -106,7 +105,6 @@ public function testPrepareDataSource() 'message' => __('Are you sure you want to delete a %1 record?', $title), ], 'post' => true, - '__disableTmpl' => true, ], ], ], diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php index 781d6d31246ca..a6c0c4349707e 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php @@ -176,7 +176,6 @@ public function configDataProvider():array 'edit' => [ 'href' => 'test/url/edit', 'label' => __('Edit'), - '__disableTmpl' => true, ], 'delete' => [ 'href' => 'test/url/delete', @@ -184,15 +183,12 @@ public function configDataProvider():array 'confirm' => [ 'title' => __('Delete %1', $title), 'message' => __('Are you sure you want to delete a %1 record?', $title), - '__disableTmpl' => true, ], 'post' => true, - '__disableTmpl' => true, ], 'preview' => [ 'href' => 'test/url/view', 'label' => __('View'), - '__disableTmpl' => true, 'target' => '_blank' ] ], diff --git a/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php b/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php index 65940c5d7b4f9..6e9eef47281c0 100644 --- a/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php +++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/BlockActions.php @@ -70,7 +70,6 @@ public function prepareDataSource(array $dataSource) ] ), 'label' => __('Edit'), - '__disableTmpl' => true, ], 'delete' => [ 'href' => $this->urlBuilder->getUrl( @@ -85,7 +84,6 @@ public function prepareDataSource(array $dataSource) 'message' => __('Are you sure you want to delete a %1 record?', $title), ], 'post' => true, - '__disableTmpl' => true, ], ]; } diff --git a/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php b/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php index 0c6000bdbab84..7c04ce3e2e09e 100644 --- a/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php +++ b/app/code/Magento/Cms/Ui/Component/Listing/Column/PageActions.php @@ -87,7 +87,6 @@ public function prepareDataSource(array $dataSource) $item[$name]['edit'] = [ 'href' => $this->urlBuilder->getUrl($this->editUrl, ['page_id' => $item['page_id']]), 'label' => __('Edit'), - '__disableTmpl' => true, ]; $title = $this->getEscaper()->escapeHtml($item['title']); $item[$name]['delete'] = [ @@ -96,10 +95,8 @@ public function prepareDataSource(array $dataSource) 'confirm' => [ 'title' => __('Delete %1', $title), 'message' => __('Are you sure you want to delete a %1 record?', $title), - '__disableTmpl' => true, ], 'post' => true, - '__disableTmpl' => true, ]; } if (isset($item['identifier'])) { @@ -110,7 +107,6 @@ public function prepareDataSource(array $dataSource) isset($item['store_code']) ? $item['store_code'] : null ), 'label' => __('View'), - '__disableTmpl' => true, 'target' => '_blank' ]; } diff --git a/app/code/Magento/Config/Model/Config/Source/Email/Template.php b/app/code/Magento/Config/Model/Config/Source/Email/Template.php index e4f1ae65bcacd..ac168f16ca182 100644 --- a/app/code/Magento/Config/Model/Config/Source/Email/Template.php +++ b/app/code/Magento/Config/Model/Config/Source/Email/Template.php @@ -64,12 +64,6 @@ public function toOptionArray() $templateLabel = $this->_emailConfig->getTemplateLabel($templateId); $templateLabel = __('%1 (Default)', $templateLabel); array_unshift($options, ['value' => $templateId, 'label' => $templateLabel]); - array_walk( - $options, - function (&$item) { - $item['__disableTmpl'] = true; - } - ); return $options; } } diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php index 9fabe6fef0c8e..76b9032de84e2 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php @@ -82,17 +82,14 @@ public function testToOptionArray() [ 'value' => 'template_new', 'label' => 'Template New (Default)', - '__disableTmpl' => true ], [ 'value' => 'template_one', 'label' => 'Template One', - '__disableTmpl' => true ], [ 'value' => 'template_two', 'label' => 'Template Two', - '__disableTmpl' => true ], ]; $this->_model->setPath('template/new'); diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php index b9fcf307b613f..e9d95c36ad9bb 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php @@ -12,6 +12,9 @@ /** * Product variations matrix block + * All disableTmpl flag are required here for configurable products + * + * All disableTmpl flag are required here for configurable products * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableAttributeSetHandler.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableAttributeSetHandler.php index 67773f019be8c..82bc6faac6bcc 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableAttributeSetHandler.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableAttributeSetHandler.php @@ -33,7 +33,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { @@ -41,7 +41,7 @@ public function modifyData(array $data) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -204,6 +204,7 @@ protected function getNewAttributeSet() 'visible' => 'ns = ${ $.ns }, index = affectedAttributeSetNew:checked', 'disabled' => '!ns = ${ $.ns }, index = affectedAttributeSetNew:checked', + '__disableTmpl' => ['disabled' => false, 'visible' => false], ] ], ], @@ -243,6 +244,7 @@ protected function getExistingAttributeSet($meta) 'visible' => 'ns = ${ $.ns }, index = affectedAttributeSetExisting:checked', 'disabled' => '!ns = ${ $.ns }, index = affectedAttributeSetExisting:checked', + '__disableTmpl' => ['disabled' => false, 'value' => false, 'visible' => false], ], ], ], diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php index 16119dcb5c866..4e11c49f10162 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePanel.php @@ -167,6 +167,7 @@ public function modifyMeta(array $meta) 'imports' => [ 'visible' => '!ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty', + '__disableTmpl' => ['visible' => false], ], ], ], @@ -185,6 +186,7 @@ public function modifyMeta(array $meta) 'imports' => [ 'visible' => 'ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty', + '__disableTmpl' => ['visible' => false], ], ], ], @@ -284,6 +286,7 @@ protected function getButtonSet() ), 'template' => 'ui/form/components/complex', 'createConfigurableButton' => 'ns = ${ $.ns }, index = create_configurable_products_button', + '__disableTmpl' => ['createConfigurableButton' => false], ], ], ], @@ -314,6 +317,7 @@ protected function getButtonSet() 'imports' => [ 'visible' => 'ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isShowAddProductButton', + '__disableTmpl' => ['visible' => false], ], ], ], @@ -392,6 +396,11 @@ protected function getGrid() 'insertDataFromGrid' => '${$.provider}:${$.dataProviderFromGrid}', 'insertDataFromWizard' => '${$.provider}:${$.dataProviderFromWizard}', 'changeDataFromGrid' => '${$.provider}:${$.dataProviderChangeFromGrid}', + '__disableTmpl' => [ + 'insertDataFromGrid' => false, + 'insertDataFromWizard' => false, + 'changeDataFromGrid' => false + ], ], 'sortOrder' => 20, 'columnsHeader' => false, @@ -445,6 +454,11 @@ protected function getRows() 'thumbnailUrl' => '${$.provider}:${$.parentScope}.thumbnail_image', 'thumbnail' => '${$.provider}:${$.parentScope}.thumbnail', 'smallImage' => '${$.provider}:${$.parentScope}.small_image', + '__disableTmpl' => [ + 'thumbnailUrl' => false, + 'thumbnail' => false, + 'smallImage' => false + ], ], 'uploaderConfig' => [ 'url' => $this->urlBuilder->getUrl( @@ -482,7 +496,10 @@ protected function getRows() 'price', __('Price'), [ - 'imports' => ['addbefore' => '${$.provider}:${$.parentScope}.price_currency'], + 'imports' => [ + 'addbefore' => '${$.provider}:${$.parentScope}.price_currency', + '__disableTmpl' => ['addbefore' => false], + ], 'validation' => ['validate-zero-or-greater' => true] ], ['dataScope' => 'price_string'] @@ -564,7 +581,8 @@ protected function getColumn( 'fit' => true, 'visibleIfCanEdit' => true, 'imports' => [ - 'visible' => '${$.provider}:${$.parentScope}.canEdit' + 'visible' => '${$.provider}:${$.parentScope}.canEdit', + '__disableTmpl' => ['visible' => false], ], ]; $fieldText['arguments']['data']['config'] = [ @@ -576,7 +594,8 @@ protected function getColumn( 'visibleIfCanEdit' => false, 'labelVisible' => false, 'imports' => [ - 'visible' => '!${$.provider}:${$.parentScope}.canEdit' + 'visible' => '!${$.provider}:${$.parentScope}.canEdit', + '__disableTmpl' => ['visible' => false], ], ]; $fieldEdit['arguments']['data']['config'] = array_replace_recursive( diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePrice.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePrice.php index d3129a09d0056..241798a5a0fb2 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePrice.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurablePrice.php @@ -37,7 +37,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { @@ -45,7 +45,7 @@ public function modifyData(array $data) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -82,6 +82,7 @@ public function modifyMeta(array $meta) 'imports' => [ 'visible' => 'ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty', + '__disableTmpl' => ['visible' => false], ] ]; $config = $visibilityConfig; diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php index 636d832842f92..d791db2ff78b9 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php @@ -40,7 +40,7 @@ public function __construct(LocatorInterface $locator, ArrayManager $arrayManage } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { @@ -48,7 +48,7 @@ public function modifyData(array $data) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -92,7 +92,8 @@ private function addPriceTypeWarning(array $meta) ), 'imports' => [ 'updateVisibility' => 'ns = ${ $.ns }, index = ' - . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty' + . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty', + '__disableTmpl' => ['updateVisibility' => false], ] ] ); @@ -128,6 +129,7 @@ private function modifyPriceTypeFields(array $meta) 'imports' => [ 'updateOptions' => 'ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty', + '__disableTmpl' => ['updateOptions' => false], ], ] ); diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php index ec69baeb92cb9..7815408321ed4 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/Data/AssociatedProducts.php @@ -215,7 +215,6 @@ public function getConfigurableAttributesData() 'code' => $attribute['code'], 'label' => $attribute['label'], 'position' => $attribute['position'], - '__disableTmpl' => true ]; foreach ($attribute['chosen'] as $chosenOption) { @@ -266,7 +265,6 @@ protected function prepareVariations() 'id' => $attribute->getAttributeId(), 'position' => $configurableAttributes[$attribute->getAttributeId()]['position'], 'chosen' => [], - '__disableTmpl' => true ]; $options = $attribute->usesSource() ? $attribute->getSource()->getAllOptions() : []; foreach ($options as $option) { @@ -277,7 +275,6 @@ protected function prepareVariations() 'id' => $option['value'], 'label' => $option['label'], 'value' => $option['value'], - '__disableTmpl' => true ]; } } @@ -289,7 +286,6 @@ protected function prepareVariations() 'id' => $optionId, 'label' => $variation[$attribute->getId()]['label'], 'value' => $optionId, - '__disableTmpl' => true ]; $variationOptions[] = $variationOption; $attributes[$attribute->getAttributeId()]['chosen'][$optionId] = $variationOption; @@ -315,7 +311,6 @@ protected function prepareVariations() 'newProduct' => 0, 'attributes' => $this->getTextAttributes($variationOptions), 'thumbnail_image' => $this->imageHelper->init($product, 'product_thumbnail_image')->getUrl(), - '__disableTmpl' => true ]; $productIds[] = $product->getId(); } diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/StockData.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/StockData.php index db51e7eebefc4..32b92a197f7d9 100644 --- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/StockData.php +++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/StockData.php @@ -69,6 +69,7 @@ public function modifyMeta(array $meta) 'imports' => [ 'disabled' => '!ns = ${ $.ns }, index = ' . ConfigurablePanel::CONFIGURABLE_MATRIX . ':isEmpty', + '__disableTmpl' => ['disabled' => false], ], ]; diff --git a/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php b/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php index 296d2877df8ea..83aa29ea45265 100644 --- a/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php +++ b/app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php @@ -50,13 +50,6 @@ public function getAllOptions($withEmpty = true, $defaultValues = false) $groups = $this->_groupManagement->getLoggedInGroups(); $this->_options = $this->_converter->toOptionArray($groups, 'id', 'code'); - - array_walk( - $this->_options, - function (&$item) { - $item['__disableTmpl'] = true; - } - ); } return $this->_options; diff --git a/app/code/Magento/Customer/Model/Customer/DataProvider.php b/app/code/Magento/Customer/Model/Customer/DataProvider.php index 0b7c618e6a18b..38e597e4e0fe7 100644 --- a/app/code/Magento/Customer/Model/Customer/DataProvider.php +++ b/app/code/Magento/Customer/Model/Customer/DataProvider.php @@ -365,6 +365,7 @@ private function processWebsiteMeta(&$meta) if (isset($meta[AddressInterface::COUNTRY_ID]) && !$this->getShareConfig()->isGlobalScope()) { $meta[AddressInterface::COUNTRY_ID]['arguments']['data']['config']['filterBy'] = [ 'target' => '${ $.provider }:data.customer.website_id', + '__disableTmpl' => ['target' => false], 'field' => 'website_ids' ]; } @@ -375,7 +376,7 @@ private function processWebsiteMeta(&$meta) * * @param AttributeInterface $attribute * @param array $meta - * @return array + * @return void */ private function processFrontendInput(AttributeInterface $attribute, array &$meta) { diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php index 8ad7363a1c310..30fa27a48de70 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php @@ -243,6 +243,7 @@ public function getAttributesMetaDataProvider() 'componentType' => Field::NAME, 'filterBy' => [ 'target' => '${ $.provider }:data.customer.website_id', + '__disableTmpl' => ['target' => false], 'field' => 'website_ids', ], ], @@ -1280,6 +1281,7 @@ private function getExpectationForVisibleAttributes() 'componentType' => Field::NAME, 'filterBy' => [ 'target' => '${ $.provider }:data.customer.website_id', + '__disableTmpl' => ['target' => false], 'field' => 'website_ids', ], ], diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php index d917cc4908ac8..0d46cde3f6df5 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php @@ -93,7 +93,6 @@ public function testCreate() ] ], 'component' => 'Magento_Ui/js/grid/columns/column', - '__disableTmpl' => 'true' ], ], 'context' => $this->context, diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php index f3c0a56262622..6398d5af772ef 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php @@ -72,7 +72,6 @@ public function testCreate() 'config' => [ 'dataScope' => $filterName, 'label' => __('Label'), - '__disableTmpl' => 'true', 'options' => [['value' => 'Value', 'label' => 'Label']], 'caption' => __('Select...'), ], diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php index 4a16acd98d827..576881bf37dae 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php @@ -8,7 +8,7 @@ use Magento\Customer\Ui\Component\Listing\Column\Actions; /** - * Class ActionsTest + * Class Actions test for Listing Colummn */ class ActionsTest extends \PHPUnit\Framework\TestCase { @@ -68,7 +68,6 @@ public function testPrepareDataSource() 'href' => 'http://magento.com/customer/index/edit', 'label' => new \Magento\Framework\Phrase('Edit'), 'hidden' => false, - '__disableTmpl' => true, ] ] ], diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/GroupActionsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/GroupActionsTest.php index 02cacea5c2601..deec8ab7f7281 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/GroupActionsTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/GroupActionsTest.php @@ -202,7 +202,6 @@ public function testPrepareDataSourceWithDefaultGroup() 'edit' => [ 'href' => static::STUB_GROUP_EDIT_URL, 'label' => __('Edit'), - '__disableTmpl' => true, ] ] ], @@ -213,7 +212,6 @@ public function testPrepareDataSourceWithDefaultGroup() 'edit' => [ 'href' => static::STUB_GROUP_EDIT_URL, 'label' => __('Edit'), - '__disableTmpl' => true, ] ] ] @@ -289,13 +287,11 @@ public function customerGroupsDataProvider(): array 'edit' => [ 'href' => static::STUB_GROUP_EDIT_URL, 'label' => __('Edit'), - '__disableTmpl' => true, ], 'delete' => [ 'href' => static::STUB_GROUP_DELETE_URL, 'label' => __('Delete'), 'post' => true, - '__disableTmpl' => true, 'confirm' => [ 'title' => __('Delete %1', 'General'), 'message' => __( diff --git a/app/code/Magento/Customer/Ui/Component/ColumnFactory.php b/app/code/Magento/Customer/Ui/Component/ColumnFactory.php index a69e84ab41a2c..22f1a3315595b 100644 --- a/app/code/Magento/Customer/Ui/Component/ColumnFactory.php +++ b/app/code/Magento/Customer/Ui/Component/ColumnFactory.php @@ -77,7 +77,6 @@ public function create(array $attributeData, $columnName, $context, array $confi 'component' => $this->getJsComponent( $this->getDataType($attributeData[AttributeMetadata::FRONTEND_INPUT]) ), - '__disableTmpl' => 'true' ], $config ); diff --git a/app/code/Magento/Customer/Ui/Component/FilterFactory.php b/app/code/Magento/Customer/Ui/Component/FilterFactory.php index 3e57db06246d4..7575062dd23db 100644 --- a/app/code/Magento/Customer/Ui/Component/FilterFactory.php +++ b/app/code/Magento/Customer/Ui/Component/FilterFactory.php @@ -48,7 +48,6 @@ public function create(array $attributeData, $context) $config = [ 'dataScope' => $attributeData[AttributeMetadata::ATTRIBUTE_CODE], 'label' => __($attributeData[AttributeMetadata::FRONTEND_LABEL]), - '__disableTmpl' => 'true' ]; if ($attributeData[AttributeMetadata::OPTIONS]) { $config['options'] = $attributeData[AttributeMetadata::OPTIONS]; diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php index 9441beeb7dc61..d6a4067ef3db6 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php @@ -60,7 +60,6 @@ public function prepareDataSource(array $dataSource) ), 'label' => __('Edit'), 'hidden' => false, - '__disableTmpl' => true ]; } } diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php index e5a536dc6ecd6..459ac3e29e993 100644 --- a/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php +++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php @@ -96,7 +96,6 @@ public function prepareDataSource(array $dataSource) ] ), 'label' => __('Edit'), - '__disableTmpl' => true ], ]; @@ -117,7 +116,6 @@ public function prepareDataSource(array $dataSource) ) ], 'post' => true, - '__disableTmpl' => true ]; } } diff --git a/app/code/Magento/Customer/Ui/Component/MassAction/Group/Options.php b/app/code/Magento/Customer/Ui/Component/MassAction/Group/Options.php index e5739317bca8d..16caf346c808c 100644 --- a/app/code/Magento/Customer/Ui/Component/MassAction/Group/Options.php +++ b/app/code/Magento/Customer/Ui/Component/MassAction/Group/Options.php @@ -10,7 +10,9 @@ use Magento\Customer\Model\ResourceModel\Group\CollectionFactory; /** - * Class Options + * Class Options for Mass Action Group + * + * Disable template needed for customers */ class Options implements \JsonSerializable { diff --git a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php index a34ef79d70d30..813fcaf863412 100644 --- a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php +++ b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/DownloadablePanel.php @@ -45,7 +45,7 @@ public function __construct(LocatorInterface $locator, ArrayManager $arrayManage } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { @@ -58,7 +58,7 @@ public function modifyData(array $data) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -97,7 +97,8 @@ protected function addMessageBox() 'visible' => false, 'imports' => [ 'visible' => '${$.provider}:' . self::DATA_SCOPE_PRODUCT . '.' - . ProductAttributeInterface::CODE_HAS_WEIGHT + . ProductAttributeInterface::CODE_HAS_WEIGHT, + '__disableTmpl' => ['visible' => false], ], ]; @@ -122,7 +123,8 @@ protected function addCheckboxIsDownloadable() 'sortOrder' => 10, 'imports' => [ 'disabled' => '${$.provider}:' . self::DATA_SCOPE_PRODUCT . '.' - . ProductAttributeInterface::CODE_HAS_WEIGHT + . ProductAttributeInterface::CODE_HAS_WEIGHT, + '__disableTmpl' => ['disabled' => false], ], 'valueMap' => [ 'false' => '0', @@ -130,6 +132,7 @@ protected function addCheckboxIsDownloadable() ], 'samplesFieldset' => 'ns = ${ $.ns }, index=' . Composite::CONTAINER_SAMPLES, 'linksFieldset' => 'ns = ${ $.ns }, index=' . Composite::CONTAINER_LINKS, + '__disableTmpl' => ['samplesFieldset' => false, 'linksFieldset' => false], ]; $this->meta = $this->arrayManager->set($checkboxPath, $this->meta, $checkboxConfig); diff --git a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Links.php b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Links.php index 8c98d871a12d2..d4c81763c7d11 100644 --- a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Links.php +++ b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/Links.php @@ -287,7 +287,8 @@ protected function getPriceColumn() 'imports' => [ 'linksPurchasedSeparately' => '${$.provider}:data.product' . '.links_purchased_separately', - 'useDefaultPrice' => '${$.parentName}.use_default_price:checked' + 'useDefaultPrice' => '${$.parentName}.use_default_price:checked', + '__disableTmpl' => ['linksPurchasedSeparately' => false, 'useDefaultPrice' => false], ], ]; @@ -485,6 +486,7 @@ protected function getMaxDownloadsColumn() ], 'exports' => [ 'checked' => '${$.parentName}.number_of_downloads:disabled', + '__disableTmpl' => ['checked' => false], ], ]; diff --git a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/UsedDefault.php b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/UsedDefault.php index d0e24ce7c4aca..b00dfef81a705 100644 --- a/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/UsedDefault.php +++ b/app/code/Magento/Downloadable/Ui/DataProvider/Product/Form/Modifier/UsedDefault.php @@ -11,6 +11,9 @@ use Magento\Framework\Stdlib\ArrayManager; use Magento\Ui\Component\Form; +/** + * Class for Product Form Modifier User Default + */ class UsedDefault extends AbstractModifier { /** @@ -49,7 +52,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { @@ -57,7 +60,7 @@ public function modifyData(array $data) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -124,6 +127,7 @@ protected function priceUsedDefault() ], 'imports' => [ 'linksPurchasedSeparately' => '${$.provider}:data.product.links_purchased_separately', + '__disableTmpl' => ['linksPurchasedSeparately' => false], ], ]; $this->meta = $this->arrayManager->set($checkboxPath, $this->meta, $useDefaultConfig); @@ -159,6 +163,7 @@ protected function titleUsedDefaultInGrid($indexTitle) ], 'exports' => [ 'checked' => '${$.parentName}.' . $indexTitle . ':disabled', + '__disableTmpl' => ['checked' => false], ], ]; $this->meta = $this->arrayManager->set($checkboxPath, $this->meta, $useDefaultConfig); diff --git a/app/code/Magento/GiftMessage/Ui/DataProvider/Product/Modifier/GiftMessage.php b/app/code/Magento/GiftMessage/Ui/DataProvider/Product/Modifier/GiftMessage.php index fe2479d778992..63bf6705854f3 100644 --- a/app/code/Magento/GiftMessage/Ui/DataProvider/Product/Modifier/GiftMessage.php +++ b/app/code/Magento/GiftMessage/Ui/DataProvider/Product/Modifier/GiftMessage.php @@ -161,10 +161,12 @@ protected function customizeAllowGiftMessageField(array $meta) 'exports' => [ 'checked' => '${$.parentName}.' . static::FIELD_MESSAGE_AVAILABLE . ':isUseConfig', + '__disableTmpl' => ['checked' => false], ], 'imports' => [ 'disabled' => '${$.parentName}.' . static::FIELD_MESSAGE_AVAILABLE . ':isUseDefault', + '__disableTmpl' => ['disabled' => false], ] ], ], diff --git a/app/code/Magento/GroupedProduct/Ui/DataProvider/Product/Form/Modifier/Grouped.php b/app/code/Magento/GroupedProduct/Ui/DataProvider/Product/Form/Modifier/Grouped.php index 2ea622c1c2b8f..3ea8c6eb3c2b9 100644 --- a/app/code/Magento/GroupedProduct/Ui/DataProvider/Product/Form/Modifier/Grouped.php +++ b/app/code/Magento/GroupedProduct/Ui/DataProvider/Product/Form/Modifier/Grouped.php @@ -394,9 +394,11 @@ protected function getListing() 'externalFilterMode' => true, 'imports' => [ 'storeId' => '${ $.provider }:data.product.current_store_id', + '__disableTmpl' => ['storeId' => false], ], 'exports' => [ 'storeId' => '${ $.externalProvider }:params.current_store_id', + '__disableTmpl' => ['storeId' => false], ], ], ], @@ -499,7 +501,10 @@ protected function getGrid() 'attribute_set' => 'attribute_set_text', 'thumbnail' => 'thumbnail_src', ], - 'links' => ['insertData' => '${ $.provider }:${ $.dataProvider }'], + 'links' => [ + 'insertData' => '${ $.provider }:${ $.dataProvider }', + '__disableTmpl' => ['insertData' => false], + ], 'sortOrder' => 20, 'columnsHeader' => false, 'columnsHeaderAfterRender' => true, diff --git a/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php b/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php index 71e0384c72f79..b97cf2aa1fc2a 100644 --- a/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php +++ b/app/code/Magento/Payment/Ui/Component/Listing/Column/Method/Options.php @@ -7,7 +7,7 @@ namespace Magento\Payment\Ui\Component\Listing\Column\Method; /** - * Class Options + * Class Options for Listing Column Method */ class Options implements \Magento\Framework\Data\OptionSourceInterface { @@ -43,13 +43,6 @@ public function toOptionArray() $this->options = $this->paymentHelper->getPaymentMethodList(true, true); } - array_walk( - $this->options, - function (&$item) { - $item['__disableTmpl'] = true; - } - ); - return $this->options; } } diff --git a/app/code/Magento/ReleaseNotification/Ui/DataProvider/Modifier/Notifications.php b/app/code/Magento/ReleaseNotification/Ui/DataProvider/Modifier/Notifications.php index e82d61d499663..f42aedd9634b5 100644 --- a/app/code/Magento/ReleaseNotification/Ui/DataProvider/Modifier/Notifications.php +++ b/app/code/Magento/ReleaseNotification/Ui/DataProvider/Modifier/Notifications.php @@ -18,6 +18,8 @@ /** * Modifies the metadata returning to the Release Notification data provider + * + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) */ class Notifications implements ModifierInterface { @@ -91,7 +93,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyData(array $data) { @@ -99,7 +101,7 @@ public function modifyData(array $data) } /** - * {@inheritdoc} + * @inheritdoc */ public function modifyMeta(array $meta) { @@ -149,6 +151,7 @@ private function buildNotificationMeta(array $meta, array $page, $isLastPage) 'actions' => [ [ 'targetName' => '${ $.name }', + '__disableTmpl' => ['targetName' => false], 'actionName' => 'closeReleaseNotes' ] ], @@ -232,6 +235,7 @@ private function unserializeContent($modalContent) /** * Returns the current Magento version used to retrieve the release notification content. + * * Version information after the dash (-) character is removed (ex. -dev or -rc). * * @return string diff --git a/app/code/Magento/Review/Ui/DataProvider/Product/Form/Modifier/Review.php b/app/code/Magento/Review/Ui/DataProvider/Product/Form/Modifier/Review.php index 5f1401a201e3f..13f726f711219 100644 --- a/app/code/Magento/Review/Ui/DataProvider/Product/Form/Modifier/Review.php +++ b/app/code/Magento/Review/Ui/DataProvider/Product/Form/Modifier/Review.php @@ -85,10 +85,12 @@ public function modifyMeta(array $meta) 'behaviourType' => 'simple', 'externalFilterMode' => true, 'imports' => [ - 'productId' => '${ $.provider }:data.product.current_product_id' + 'productId' => '${ $.provider }:data.product.current_product_id', + '__disableTmpl' => ['productId' => false], ], 'exports' => [ - 'productId' => '${ $.externalProvider }:params.current_product_id' + 'productId' => '${ $.externalProvider }:params.current_product_id', + '__disableTmpl' => ['productId' => false], ], ], ], diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php index fe285d29d703b..b3a419b1b6d97 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php @@ -10,7 +10,7 @@ use Magento\Sales\Ui\Component\Listing\Column\Status\Options; /** - * Class OptionsTest + * Class Options test for Listing Column Status */ class OptionsTest extends \PHPUnit\Framework\TestCase { @@ -54,7 +54,6 @@ public function testToOptionArray() [ 'value' => '1', 'label' => 'Label', - '__disableTmpl' => true ] ]; diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/Status/Options.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/Status/Options.php index 14964f16b701e..680064596d0a7 100644 --- a/app/code/Magento/Sales/Ui/Component/Listing/Column/Status/Options.php +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/Status/Options.php @@ -9,7 +9,7 @@ use Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory; /** - * Class Options + * Class Options for Listing Column Status */ class Options implements OptionSourceInterface { @@ -42,14 +42,6 @@ public function toOptionArray() { if ($this->options === null) { $options = $this->collectionFactory->create()->toOptionArray(); - - array_walk( - $options, - function (&$option) { - $option['__disableTmpl'] = true; - } - ); - $this->options = $options; } return $this->options; diff --git a/app/code/Magento/Search/Test/Unit/Ui/Component/Listing/Column/SynonymActionsTest.php b/app/code/Magento/Search/Test/Unit/Ui/Component/Listing/Column/SynonymActionsTest.php index d5563ec1cb289..5cf11e9babc25 100644 --- a/app/code/Magento/Search/Test/Unit/Ui/Component/Listing/Column/SynonymActionsTest.php +++ b/app/code/Magento/Search/Test/Unit/Ui/Component/Listing/Column/SynonymActionsTest.php @@ -112,7 +112,6 @@ public function testPrepareDataSourceWithItems() self::STUB_SYNONYM_GROUP_ID ) ], - '__disableTmpl' => true ], 'edit' => [ 'href' => sprintf( @@ -120,7 +119,6 @@ public function testPrepareDataSourceWithItems() self::STUB_SYNONYM_GROUP_ID ), 'label' => (string)__('View/Edit'), - '__disableTmpl' => true ] ] ] diff --git a/app/code/Magento/Search/Ui/Component/Listing/Column/SynonymActions.php b/app/code/Magento/Search/Ui/Component/Listing/Column/SynonymActions.php index f42ce50d2804b..2fd569642375e 100644 --- a/app/code/Magento/Search/Ui/Component/Listing/Column/SynonymActions.php +++ b/app/code/Magento/Search/Ui/Component/Listing/Column/SynonymActions.php @@ -64,12 +64,10 @@ public function prepareDataSource(array $dataSource) 'title' => __('Delete'), 'message' => __('Are you sure you want to delete synonym group with id: %1?', $item['group_id']) ], - '__disableTmpl' => true ]; $item[$name]['edit'] = [ 'href' => $this->urlBuilder->getUrl(self::SYNONYM_URL_PATH_EDIT, ['group_id' => $item['group_id']]), 'label' => __('View/Edit'), - '__disableTmpl' => true ]; } } diff --git a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php index 22cc1c9e89fbe..8d9b11771bb44 100644 --- a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php +++ b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php @@ -10,7 +10,7 @@ use Magento\Theme\Ui\Component\Listing\Column\EditAction; /** - * Class EditActionTest + * Class EditAction test for Listing Column */ class EditActionTest extends \PHPUnit\Framework\TestCase { @@ -67,7 +67,6 @@ public function testPrepareDataSource($dataSourceItem, $scope, $scopeId) 'edit' => [ 'href' => 'http://magento.com/theme/design_config/edit', 'label' => new \Magento\Framework\Phrase('Edit'), - '__disableTmpl' => true, ] ], ]; diff --git a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php index 5e2fe51043885..5995b84ef6874 100644 --- a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php +++ b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php @@ -112,7 +112,6 @@ public function getPrepareDataSourceDataProvider() 'view' => [ 'href' => 'url', 'label' => __('View'), - '__disableTmpl' => true, ] ], 'entity_id' => 1 @@ -139,7 +138,6 @@ public function getPrepareDataSourceDataProvider() 'view' => [ 'href' => 'url', 'label' => __('View'), - '__disableTmpl' => true, ] ], 'theme_id' => 2 diff --git a/app/code/Magento/Theme/Ui/Component/Design/Config/SearchRobots/ResetButton.php b/app/code/Magento/Theme/Ui/Component/Design/Config/SearchRobots/ResetButton.php index 5a8829851e8cf..4b71fc6faba15 100644 --- a/app/code/Magento/Theme/Ui/Component/Design/Config/SearchRobots/ResetButton.php +++ b/app/code/Magento/Theme/Ui/Component/Design/Config/SearchRobots/ResetButton.php @@ -76,6 +76,7 @@ public function prepare() [ 'actionName' => 'reset', 'targetName' => '${ $.name }', + '__disableTmpl' => ['targetName' => false], 'params' => [ json_encode($this->getRobotsDefaultCustomInstructions()) ] diff --git a/app/code/Magento/Theme/Ui/Component/Listing/Column/EditAction.php b/app/code/Magento/Theme/Ui/Component/Listing/Column/EditAction.php index 1eeeaccff88ce..821eee8114bae 100644 --- a/app/code/Magento/Theme/Ui/Component/Listing/Column/EditAction.php +++ b/app/code/Magento/Theme/Ui/Component/Listing/Column/EditAction.php @@ -13,7 +13,7 @@ use Magento\Ui\Component\Listing\Columns\Column; /** - * Class EditAction + * Class EditAction for Listing Column */ class EditAction extends Column { @@ -74,7 +74,6 @@ public function prepareDataSource(array $dataSource) ] ), 'label' => __('Edit'), - '__disableTmpl' => true, ] ]; } diff --git a/app/code/Magento/Theme/Ui/Component/Listing/Column/ViewAction.php b/app/code/Magento/Theme/Ui/Component/Listing/Column/ViewAction.php index 9e47e2c52bddf..a49e622b9d42a 100644 --- a/app/code/Magento/Theme/Ui/Component/Listing/Column/ViewAction.php +++ b/app/code/Magento/Theme/Ui/Component/Listing/Column/ViewAction.php @@ -14,7 +14,7 @@ use Magento\Ui\Component\Listing\Columns\Column; /** - * Class ViewAction + * Class ViewAction for Listing Column */ class ViewAction extends Column { @@ -66,7 +66,6 @@ public function prepareDataSource(array $dataSource) : array ] ), 'label' => __('View'), - '__disableTmpl' => true, ] ]; } diff --git a/app/code/Magento/Ui/Component/MassAction.php b/app/code/Magento/Ui/Component/MassAction.php index 5af263dd861ce..4cca8d4c012bb 100644 --- a/app/code/Magento/Ui/Component/MassAction.php +++ b/app/code/Magento/Ui/Component/MassAction.php @@ -28,7 +28,7 @@ public function prepare() if ($disabledAction) { continue; } - $config['actions'][] = array_merge($componentConfig, ['__disableTmpl' => true]); + $config['actions'][] = $componentConfig; } $origConfig = $this->getConfiguration(); diff --git a/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php b/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php index c2e064bb3b069..f8560988168e6 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php @@ -10,7 +10,7 @@ use Magento\Framework\View\Element\UiComponent\ContextInterface; /** - * Class MassActionTest + * Class MassAction test for Component */ class MassActionTest extends \PHPUnit\Framework\TestCase { @@ -105,7 +105,6 @@ public function getPrepareDataProvider() 'type' => 'first_action', 'label' => 'First Action', 'url' => '/module/controller/firstAction', - '__disableTmpl' => true ], ], [ @@ -125,7 +124,6 @@ public function getPrepareDataProvider() 'url' => '/module/controller/secondSubAction2' ], ], - '__disableTmpl' => true ], ], ]; diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php index 9f121268135f8..7ca0e759c8408 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Config/Source/Group/MultiselectTest.php @@ -23,6 +23,7 @@ public function testToOptionArray() $optionsToCompare = []; foreach ($options as $option) { if (is_array($option['value'])) { + //phpcs:ignore Magento2.Performance.ForeachArrayMerge $optionsToCompare = array_merge($optionsToCompare, $option['value']); } else { $optionsToCompare[] = $option; @@ -36,22 +37,18 @@ public function testToOptionArray() [ 'value' => 1, 'label' => 'Default (General)', - '__disableTmpl' => true, ], [ 'value' => 1, 'label' => 'General', - '__disableTmpl' => true, ], [ 'value' => 2, 'label' => 'Wholesale', - '__disableTmpl' => true, ], [ 'value' => 3, 'label' => 'Retailer', - '__disableTmpl' => true, ], ] ); From 550ce14ed21b2541daeb149c45b900c403656a65 Mon Sep 17 00:00:00 2001 From: Hwashiang Yu <hwyu@adobe.com> Date: Tue, 14 Apr 2020 20:45:20 -0500 Subject: [PATCH 154/177] MC-30175: UI component rendering config - Resolved static and unit test failures --- .../Unit/Ui/Component/Product/MassActionTest.php | 5 +++-- .../Product/Form/Modifier/AdvancedInventory.php | 2 -- .../Component/Listing/Column/BlockActionsTest.php | 2 +- .../Component/Listing/Column/PageActionsTest.php | 2 +- .../Model/Config/Source/Email/TemplateTest.php | 6 ++++-- .../Test/Unit/Model/Customer/DataProviderTest.php | 2 +- .../Test/Unit/Ui/Component/ColumnFactoryTest.php | 13 +++++++------ .../Test/Unit/Ui/Component/FilterFactoryTest.php | 11 ++++++----- .../Ui/Component/Listing/Column/ActionsTest.php | 7 ++++--- .../Listing/Column/Status/OptionsTest.php | 3 ++- .../Component/Listing/Column/EditActionTest.php | 7 ++++--- .../Component/Listing/Column/ViewActionTest.php | 3 ++- .../Ui/Test/Unit/Component/MassActionTest.php | 3 ++- .../Unit/View/Element/UiComponentFactoryTest.php | 15 ++++++++------- 14 files changed, 45 insertions(+), 36 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php index 966d5bc308c09..f34ebd2e1cf4d 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/Product/MassActionTest.php @@ -11,6 +11,7 @@ use Magento\Framework\AuthorizationInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\View\Element\UiComponent\ContextInterface; +use PHPUnit\Framework\MockObject\MockObject; /** * MassAction test for Component Product @@ -18,7 +19,7 @@ class MassActionTest extends \PHPUnit\Framework\TestCase { /** - * @var ContextInterface|\PHPUnit_Framework_MockObject_MockObject + * @var ContextInterface|MockObject */ private $contextMock; @@ -28,7 +29,7 @@ class MassActionTest extends \PHPUnit\Framework\TestCase private $objectManager; /** - * @var AuthorizationInterface|\PHPUnit_Framework_MockObject_MockObject + * @var AuthorizationInterface|MockObject */ private $authorizationMock; diff --git a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php index c8509f665876d..64db51132dc36 100644 --- a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php +++ b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php @@ -186,7 +186,6 @@ private function prepareMeta() if ($pathField) { $fieldsetPath = $this->arrayManager->slicePath($pathField, 0, -4); - $this->meta = $this->arrayManager->merge( $pathField . '/arguments/data/config', $this->meta, @@ -271,7 +270,6 @@ private function prepareMeta() 'qty' => $qty, 'advanced_inventory_button' => $advancedInventoryButton, ]; - $this->meta = $this->arrayManager->merge( $fieldsetPath . '/children', $this->meta, diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php index e38f7b7fc6704..e036e2a8ad200 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/BlockActionsTest.php @@ -11,7 +11,7 @@ use Magento\Framework\UrlInterface; use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponent\Processor; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; /** * BlockActionsTest contains unit tests for \Magento\Cms\Ui\Component\Listing\Column\BlockActions class. diff --git a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php index a6c0c4349707e..e187534f46ad5 100644 --- a/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php +++ b/app/code/Magento/Cms/Test/Unit/Ui/Component/Listing/Column/PageActionsTest.php @@ -15,7 +15,7 @@ use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponent\Processor; use PHPUnit\Framework\TestCase; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; /** * Test for Magento\Cms\Ui\Component\Listing\Column\PageActions class. diff --git a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php index 76b9032de84e2..1fc730ccef30e 100644 --- a/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php +++ b/app/code/Magento/Config/Test/Unit/Model/Config/Source/Email/TemplateTest.php @@ -6,6 +6,8 @@ namespace Magento\Config\Test\Unit\Model\Config\Source\Email; +use PHPUnit\Framework\MockObject\MockObject; + /** * Test class for Template. */ @@ -17,12 +19,12 @@ class TemplateTest extends \PHPUnit\Framework\TestCase protected $_model; /** - * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Framework\Registry|MockObject */ protected $_coreRegistry; /** - * @var \Magento\Email\Model\Template\Config|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Email\Model\Template\Config|MockObject */ protected $_emailConfig; diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php index 30fa27a48de70..f98759d3f067a 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php @@ -26,7 +26,7 @@ use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Ui\Component\Form\Field; use Magento\Ui\DataProvider\EavValidationRules; -use PHPUnit_Framework_MockObject_MockObject as MockObject; +use PHPUnit\Framework\MockObject\MockObject; /** * Unit tests for \Magento\Customer\Model\Customer\DataProvider class. diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php index 0d46cde3f6df5..8b926e8dfdec8 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php @@ -6,28 +6,29 @@ namespace Magento\Customer\Test\Unit\Ui\Component; use Magento\Customer\Ui\Component\ColumnFactory; +use PHPUnit\Framework\MockObject\MockObject; /** * Test ColumnFactory Class */ class ColumnFactoryTest extends \PHPUnit\Framework\TestCase { - /** @var \Magento\Customer\Api\Data\OptionInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Customer\Api\Data\OptionInterface|MockObject */ protected $attributeOption; - /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|MockObject */ protected $context; - /** @var \Magento\Framework\View\Element\UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponentFactory|MockObject */ protected $componentFactory; - /** @var \Magento\Customer\Api\Data\AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Customer\Api\Data\AttributeMetadataInterface|MockObject */ protected $attributeMetadata; - /** @var \Magento\Ui\Component\Listing\Columns\ColumnInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Ui\Component\Listing\Columns\ColumnInterface|MockObject */ protected $column; - /** @var \Magento\Customer\Ui\Component\Listing\Column\InlineEditUpdater|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Customer\Ui\Component\Listing\Column\InlineEditUpdater|MockObject */ protected $inlineEditUpdater; /** @var ColumnFactory */ diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php index 6398d5af772ef..3a23cf66faddc 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php @@ -6,25 +6,26 @@ namespace Magento\Customer\Test\Unit\Ui\Component; use Magento\Customer\Ui\Component\FilterFactory; +use PHPUnit\Framework\MockObject\MockObject; /** * Test FilterFactory Class */ class FilterFactoryTest extends \PHPUnit\Framework\TestCase { - /** @var \Magento\Customer\Api\Data\OptionInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Customer\Api\Data\OptionInterface|MockObject */ protected $attributeOption; - /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|MockObject */ protected $context; - /** @var \Magento\Framework\View\Element\UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponentFactory|MockObject */ protected $componentFactory; - /** @var \Magento\Customer\Api\Data\AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Customer\Api\Data\AttributeMetadataInterface|MockObject */ protected $attributeMetadata; - /** @var \Magento\Ui\Component\Listing\Columns\ColumnInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Ui\Component\Listing\Columns\ColumnInterface|MockObject */ protected $filter; /** @var FilterFactory */ diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php index 576881bf37dae..3792f0d214537 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php @@ -6,6 +6,7 @@ namespace Magento\Customer\Test\Unit\Ui\Component\Listing\Column; use Magento\Customer\Ui\Component\Listing\Column\Actions; +use PHPUnit\Framework\MockObject\MockObject; /** * Class Actions test for Listing Colummn @@ -15,13 +16,13 @@ class ActionsTest extends \PHPUnit\Framework\TestCase /** @var Actions */ protected $component; - /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|MockObject */ protected $context; - /** @var \Magento\Framework\View\Element\UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponentFactory|MockObject */ protected $uiComponentFactory; - /** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\UrlInterface|MockObject */ protected $urlBuilder; public function setup() diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php index b3a419b1b6d97..a62d62f96c560 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/Status/OptionsTest.php @@ -8,6 +8,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory; use Magento\Sales\Ui\Component\Listing\Column\Status\Options; +use PHPUnit\Framework\MockObject\MockObject; /** * Class Options test for Listing Column Status @@ -20,7 +21,7 @@ class OptionsTest extends \PHPUnit\Framework\TestCase protected $model; /** - * @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject + * @var CollectionFactory|MockObject */ protected $collectionFactoryMock; diff --git a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php index 8d9b11771bb44..5cd27c58d6665 100644 --- a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php +++ b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/EditActionTest.php @@ -8,6 +8,7 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Store\Model\ScopeInterface; use Magento\Theme\Ui\Component\Listing\Column\EditAction; +use PHPUnit\Framework\MockObject\MockObject; /** * Class EditAction test for Listing Column @@ -17,13 +18,13 @@ class EditActionTest extends \PHPUnit\Framework\TestCase /** @var EditAction */ protected $component; - /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|MockObject */ protected $context; - /** @var \Magento\Framework\View\Element\UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponentFactory|MockObject */ protected $uiComponentFactory; - /** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\UrlInterface|MockObject */ protected $urlBuilder; public function setup() diff --git a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php index 5995b84ef6874..a7b5624236b2f 100644 --- a/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php +++ b/app/code/Magento/Theme/Test/Unit/Ui/Component/Listing/Column/ViewActionTest.php @@ -11,6 +11,7 @@ use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\UrlInterface; use Magento\Theme\Ui\Component\Listing\Column\ViewAction; +use PHPUnit\Framework\MockObject\MockObject; /** * Class ViewActionTest contains unit tests for \Magento\Theme\Ui\Component\Listing\Column\ViewAction class @@ -25,7 +26,7 @@ class ViewActionTest extends \PHPUnit\Framework\TestCase protected $model; /** - * @var UrlInterface|\PHPUnit_Framework_MockObject_MockObject + * @var UrlInterface|MockObject */ protected $urlBuilder; diff --git a/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php b/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php index f8560988168e6..5922055328fc1 100644 --- a/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php +++ b/app/code/Magento/Ui/Test/Unit/Component/MassActionTest.php @@ -8,6 +8,7 @@ use Magento\Ui\Component\MassAction; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\View\Element\UiComponent\ContextInterface; +use PHPUnit\Framework\MockObject\MockObject; /** * Class MassAction test for Component @@ -15,7 +16,7 @@ class MassActionTest extends \PHPUnit\Framework\TestCase { /** - * @var ContextInterface|\PHPUnit_Framework_MockObject_MockObject + * @var ContextInterface|MockObject */ protected $contextMock; diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php index 4f5c332269cf0..b4dddae673090 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php @@ -6,6 +6,7 @@ namespace Magento\Framework\Test\Unit\View\Element; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use PHPUnit\Framework\MockObject\MockObject; class UiComponentFactoryTest extends \PHPUnit\Framework\TestCase { @@ -15,25 +16,25 @@ class UiComponentFactoryTest extends \PHPUnit\Framework\TestCase /** @var ObjectManagerHelper */ protected $objectManagerHelper; - /** @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\ObjectManagerInterface|MockObject */ protected $objectManagerMock; - /** @var \Magento\Framework\Data\Argument\InterpreterInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\Data\Argument\InterpreterInterface|MockObject */ protected $interpreterMock; - /** @var \Magento\Framework\View\Element\UiComponent\ContextFactory|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\View\Element\UiComponent\ContextFactory|MockObject */ protected $contextFactoryMock; - /** @var \Magento\Framework\Config\DataInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Framework\Config\DataInterfaceFactory|MockObject */ protected $dataInterfaceFactoryMock; - /** @var \SafeReflectionClass|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \SafeReflectionClass|MockObject */ protected $safeReflectionClassMock; - /** @var \SafeReflectionClass|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \SafeReflectionClass|MockObject */ protected $safeReflectionClassMock2; - /** @var \Magento\Ui\Config\Reader\Definition\Data|\PHPUnit_Framework_MockObject_MockObject */ + /** @var \Magento\Ui\Config\Reader\Definition\Data|MockObject */ protected $dataMock; protected function setUp() From 99924e5c8260752d6be82b964edcde4ad062c75d Mon Sep 17 00:00:00 2001 From: Hwashiang Yu <hwyu@adobe.com> Date: Tue, 14 Apr 2020 20:57:21 -0500 Subject: [PATCH 155/177] MC-30175: UI component rendering config - Added changes from MC-21979 --- .../Form/Element/AbstractOptionsField.php | 22 ++- .../View/Element/UiComponent/ContextTest.php | 101 ++++++++++ .../View/Element/UiComponentFactoryTest.php | 168 ++++++++++++++++ .../View/Element/UiComponentFactoryTest.php | 7 +- .../Form/Element/MultiSelectTest.php | 89 +++++++++ .../View/Element/UiComponent/Context.php | 19 +- .../UiComponent/DataProvider/Sanitizer.php | 102 ++++++++++ .../View/Element/UiComponentFactory.php | 25 ++- .../DataProvider/SanitizerTest.php | 185 ++++++++++++++++++ 9 files changed, 700 insertions(+), 18 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponent/ContextTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponentFactoryTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Ui/Component/Form/Element/MultiSelectTest.php create mode 100644 lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/Sanitizer.php create mode 100644 lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/DataProvider/SanitizerTest.php diff --git a/app/code/Magento/Ui/Component/Form/Element/AbstractOptionsField.php b/app/code/Magento/Ui/Component/Form/Element/AbstractOptionsField.php index 586d76828ba3a..f1ff9db2dfde6 100644 --- a/app/code/Magento/Ui/Component/Form/Element/AbstractOptionsField.php +++ b/app/code/Magento/Ui/Component/Form/Element/AbstractOptionsField.php @@ -7,6 +7,7 @@ use Magento\Framework\Data\OptionSourceInterface; use Magento\Framework\View\Element\UiComponent\ContextInterface; +use Magento\Framework\View\Element\UiComponent\DataProvider\Sanitizer; /** * Base abstract form element. @@ -23,6 +24,11 @@ abstract class AbstractOptionsField extends AbstractElement */ protected $options; + /** + * @var Sanitizer + */ + private $sanitizer; + /** * Constructor * @@ -30,14 +36,17 @@ abstract class AbstractOptionsField extends AbstractElement * @param array|OptionSourceInterface|null $options * @param array $components * @param array $data + * @param Sanitizer|null $sanitizer */ public function __construct( ContextInterface $context, $options = null, array $components = [], - array $data = [] + array $data = [], + ?Sanitizer $sanitizer = null ) { $this->options = $options; + $this->sanitizer = $sanitizer ?? \Magento\Framework\App\ObjectManager::getInstance()->get(Sanitizer::class); parent::__construct($context, $components, $data); } @@ -62,13 +71,10 @@ public function prepare() if (empty($config['rawOptions'])) { $options = $this->convertOptionsValueToString($options); } - - array_walk( - $options, - function (&$item) { - $item['__disableTmpl'] = true; - } - ); + foreach ($options as &$option) { + //Options contain static or dynamic entity data that is not supposed to contain templates. + $option = $this->sanitizer->sanitize($option); + } $config['options'] = array_values(array_replace_recursive($config['options'], $options)); } diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponent/ContextTest.php b/dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponent/ContextTest.php new file mode 100644 index 0000000000000..b6c56795ebefe --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponent/ContextTest.php @@ -0,0 +1,101 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Framework\View\Element\UiComponent; + +use Magento\Framework\Api\Search\SearchCriteria; +use Magento\Framework\App\RequestInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Magento\Ui\Component\Form; +use Magento\Ui\Component\FormFactory; +use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface; + +/** + * Test UI component context. + */ +class ContextTest extends TestCase +{ + /** + * @var RequestInterface + */ + private $request; + + /** + * @var ContextFactory + */ + private $contextFactory; + + /** + * @var FormFactory + */ + private $componentFactory; + + /** + * @inheritDoc + */ + protected function setUp() + { + $this->request = Bootstrap::getObjectManager()->get(RequestInterface::class); + $this->contextFactory = Bootstrap::getObjectManager()->get(ContextFactory::class); + $this->componentFactory = Bootstrap::getObjectManager()->get(FormFactory::class); + } + + /** + * Generate provider for the test. + * + * @return DataProviderInterface + */ + private function generateMockProvider(): DataProviderInterface + { + /** @var DataProviderInterface|MockObject $mock */ + $mock = $this->getMockForAbstractClass(DataProviderInterface::class); + $mock->method('getName')->willReturn('test'); + $mock->method('getPrimaryFieldName')->willReturn('id'); + $mock->method('getRequestFieldName')->willReturn('id'); + $mock->method('getData')->willReturn(['id' => ['some_field' => '${\'some_value\'}']]); + $mock->method('getConfigData')->willReturn([]); + $mock->method('getFieldMetaInfo')->willReturn([]); + $mock->method('getFieldSetMetaInfo')->willReturn('id'); + $mock->method('getFieldsMetaInfo')->willReturn('id'); + $mock->method('getSearchCriteria')->willReturn(new SearchCriteria()); + $mock->method('getSearchResult')->willReturn([]); + + return $mock; + } + + /** + * Check processed provider data. + * + * @return void + */ + public function testGetDataSourceData(): void + { + $dataProvider = $this->generateMockProvider(); + $context = $this->contextFactory->create(['dataProvider' => $dataProvider]); + /** @var Form $component */ + $component = $this->componentFactory->create(['context' => $context]); + $this->request->setParams(['id' => 'id']); + + $data = $context->getDataSourceData($component); + $this->assertEquals( + [ + 'test' => [ + 'type' => 'dataSource', + 'name' => 'test', + 'dataScope' => null, + 'config' => [ + 'data' => ['some_field' => '${\'some_value\'}', '__disableTmpl' => ['some_field' => true]], + 'params' => ['namespace' => null]] + ] + ], + $data + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponentFactoryTest.php b/dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponentFactoryTest.php new file mode 100644 index 0000000000000..8a1064ffe6663 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Framework/View/Element/UiComponentFactoryTest.php @@ -0,0 +1,168 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Framework\View\Element; + +use Magento\Framework\Api\Search\SearchCriteria; +use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; +use Magento\Framework\Config\DataInterface as ConfigData; +use Magento\Framework\Config\DataInterfaceFactory as ConfigDataFactory; + +/** + * Test the component factory. + */ +class UiComponentFactoryTest extends TestCase +{ + /** + * @var UiComponentFactoryFactory + */ + private $factory; + + /** + * @inheritDoc + */ + protected function setUp() + { + $this->factory = Bootstrap::getObjectManager()->get(UiComponentFactoryFactory::class); + } + + /** + * Create factory with mock config provided. + * + * @param array $mockConfig + * @return UiComponentFactory + */ + private function createFactory(array $mockConfig): UiComponentFactory + { + $dataMock = $this->getMockForAbstractClass(ConfigData::class); + $dataMock->method('get')->willReturnCallback( + function (string $id) use ($mockConfig) : array { + return $mockConfig[$id]; + } + ); + $dataFactoryMock = $this->getMockBuilder(ConfigDataFactory::class) + ->disableOriginalConstructor() + ->getMock(); + $dataFactoryMock->method('create')->willReturn($dataMock); + + return $this->factory->create(['configFactory' => $dataFactoryMock]); + } + + /** + * Test creating a component. + * + * @return void + * @magentoAppArea adminhtml + */ + public function testCreate(): void + { + //Mocking component config. + $factory = $this->createFactory([ + 'test' => [ + 'arguments' => ['data' => ['config' => ['component' => 'uiComponent']]], + 'attributes' => [ + 'name' => 'test', + 'sorting' => true, + 'class' => 'Magento\Ui\Component\Listing', + 'component' => 'uiComponent' + ], + 'children' => [ + 'test_child' => [ + 'arguments' => [ + 'data' => ['config' => ['component' => 'uiComponent']], + 'dataProvider' => $this->generateMockProvider() + ], + 'attributes' => [ + 'name' => 'test_child', + 'sorting' => true, + 'class' => 'Magento\Ui\Component\Listing', + 'component' => 'uiComponent' + ], + 'children' => [] + ] + ] + ], + 'test_child_child' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'component' => 'uiComponent', + 'label' => '${\'Label\'}', + 'componentType' => 'component' + ] + ], + ], + 'attributes' => [ + 'name' => 'test_child_child', + 'sorting' => true, + 'class' => 'Magento\Ui\Component\Listing', + 'component' => 'uiComponent' + ], + 'children' => [] + ] + ]); + $component = $factory->create('test', null, ['data' => ['label' => '${\'Label\'}']]); + + $componentData = $component->getData(); + //Arguments passed must be sanitized + $this->assertArrayHasKey('__disableTmpl', $componentData); + $this->assertEquals(['label' => true], $componentData['__disableTmpl']); + //Metadata provided by the dataProvider must be sanitized as well. + $this->assertArrayHasKey('test_child_child', $childData = $component->getChildComponents()); + $childData = $component->getChildComponents()['test_child_child']->getData()['config']; + $this->assertArrayHasKey('__disableTmpl', $childData); + $this->assertEquals(['label' => true], $childData['__disableTmpl']); + } + + /** + * Generate provider for the test. + * + * @return DataProviderInterface + */ + private function generateMockProvider(): DataProviderInterface + { + /** @var DataProviderInterface|MockObject $mock */ + $mock = $this->getMockForAbstractClass(DataProviderInterface::class); + $mock->method('getName')->willReturn('test'); + $mock->method('getPrimaryFieldName')->willReturn('id'); + $mock->method('getRequestFieldName')->willReturn('id'); + $mock->method('getData')->willReturn([]); + $mock->method('getConfigData')->willReturn([]); + $mock->method('getFieldMetaInfo')->willReturn([]); + $mock->method('getFieldSetMetaInfo')->willReturn('id'); + $mock->method('getFieldsMetaInfo')->willReturn('id'); + $mock->method('getSearchCriteria')->willReturn(new SearchCriteria()); + $mock->method('getSearchResult')->willReturn([]); + $mock->method('getMeta')->willReturn( + [ + 'test_child_child' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'component' => 'uiComponent', + 'label' => '${\'Label\'}', + 'componentType' => 'component' + ] + ], + ], + 'attributes' => [ + 'name' => 'test_child_child', + 'sorting' => true, + 'class' => 'Magento\Ui\Component\Listing', + 'component' => 'uiComponent' + ] + ] + ] + ); + + return $mock; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php index b4dddae673090..05c12eee3418a 100644 --- a/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php +++ b/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/lib/internal/Magento/Framework/Test/Unit/View/Element/UiComponentFactoryTest.php @@ -6,6 +6,7 @@ namespace Magento\Framework\Test\Unit\View\Element; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Framework\View\Element\UiComponent\DataProvider\Sanitizer; use PHPUnit\Framework\MockObject\MockObject; class UiComponentFactoryTest extends \PHPUnit\Framework\TestCase @@ -59,6 +60,9 @@ protected function setUp() ->disableOriginalConstructor() ->getMock(); $this->dataMock = $this->createMock(\Magento\Framework\Config\DataInterface::class); + $sanitizerMock = $this->createMock(Sanitizer::class); + $sanitizerMock->method('sanitize')->willReturnArgument(0); + $sanitizerMock->method('sanitizeComponentMetadata')->willReturnArgument(0); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->model = $this->objectManagerHelper->getObject( \Magento\Framework\View\Element\UiComponentFactory::class, @@ -69,7 +73,8 @@ protected function setUp() 'configFactory' => $this->dataInterfaceFactoryMock, 'data' => [], 'componentChildFactories' => [], - 'definitionData' => $this->dataMock + 'definitionData' => $this->dataMock, + 'sanitizer' => $sanitizerMock ] ); } diff --git a/dev/tests/integration/testsuite/Magento/Ui/Component/Form/Element/MultiSelectTest.php b/dev/tests/integration/testsuite/Magento/Ui/Component/Form/Element/MultiSelectTest.php new file mode 100644 index 0000000000000..6c7e369419a55 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Ui/Component/Form/Element/MultiSelectTest.php @@ -0,0 +1,89 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Ui\Component\Form\Element; + +use Magento\Framework\Data\OptionSourceInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Test MultiSelect component. + */ +class MultiSelectTest extends TestCase +{ + /** + * @var MultiSelectFactory + */ + private $factory; + + /** + * @inheritDoc + */ + protected function setUp() + { + $this->factory = Bootstrap::getObjectManager()->get(MultiSelectFactory::class); + } + + /** + * Options data to verify + * + * @return array + */ + public function getTestOptions(): array + { + return [ + 'List' => [ + [ + ['value' => '${\'my-value\'}', 'label' => 'My label'], + ['value' => '1', 'label' => 'Label'], + ['value' => '${\'my-value-2\'}', 'label' => 'This is ${\'My label\'}'] + ], + [ + ['value' => '${\'my-value\'}', 'label' => 'My label', '__disableTmpl' => ['value' => true]], + ['value' => '1', 'label' => 'Label'], + [ + 'value' => '${\'my-value-2\'}', + 'label' => 'This is ${\'My label\'}', + '__disableTmpl' => ['value' => true, 'label' => true] + ] + ] + ], + 'provider' => [ + new class implements OptionSourceInterface + { + /** + * @inheritDoc + */ + public function toOptionArray() + { + return [['value' => '${\'value\'}', 'label' => 'Test']]; + } + }, + [['value' => '${\'value\'}', 'label' => 'Test', '__disableTmpl' => ['value' => true]]] + ] + ]; + } + + /** + * Check that options received from an options provider properly initiated. + * + * @param array|OptionSourceInterface $options Options provided + * @param array $expected Expected initialized options + * @return void + * @dataProvider getTestOptions + */ + public function testOptions($options, array $expected): void + { + /** @var MultiSelect $component */ + $component = $this->factory->create(['options' => $options]); + $component->prepare(); + + $this->assertEquals($expected, $component->getData('config')['options']); + } +} diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php index fbb84712b2afd..8f980d82d4be0 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php @@ -15,12 +15,13 @@ use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderFactory; use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface; use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface; +use Magento\Framework\View\Element\UiComponent\DataProvider\Sanitizer; use Magento\Framework\View\Element\UiComponentFactory; use Magento\Framework\View\Element\UiComponentInterface; use Magento\Framework\View\LayoutInterface as PageLayoutInterface; /** - * Class Context + * Request context for UI components to utilize. * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ @@ -101,6 +102,11 @@ class Context implements ContextInterface */ private $authorization; + /** + * @var Sanitizer + */ + private $sanitizer; + /** * @param PageLayoutInterface $pageLayout * @param RequestInterface $request @@ -113,6 +119,7 @@ class Context implements ContextInterface * @param DataProviderInterface|null $dataProvider * @param string $namespace * @param AuthorizationInterface|null $authorization + * @param Sanitizer|null $sanitizer * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -126,7 +133,8 @@ public function __construct( UiComponentFactory $uiComponentFactory, DataProviderInterface $dataProvider = null, $namespace = null, - AuthorizationInterface $authorization = null + AuthorizationInterface $authorization = null, + ?Sanitizer $sanitizer = null ) { $this->namespace = $namespace; $this->request = $request; @@ -141,6 +149,7 @@ public function __construct( $this->authorization = $authorization ?: ObjectManager::getInstance()->get( AuthorizationInterface::class ); + $this->sanitizer = $sanitizer ?? ObjectManager::getInstance()->get(Sanitizer::class); $this->setAcceptType(); } @@ -241,16 +250,20 @@ public function getDataProvider() */ public function getDataSourceData(UiComponentInterface $component) { + //Getting dynamic data for the component $dataSource = $component->getDataSourceData(); $this->prepareDataSource($dataSource, $component); $dataProviderConfig = $this->getDataProvider()->getConfigData(); + //Dynamic UI component data should not contain templates. + $config = $this->sanitizer->sanitize(array_merge($dataSource, $dataProviderConfig)); + return [ $this->getDataProvider()->getName() => [ 'type' => 'dataSource', 'name' => $this->getDataProvider()->getName(), 'dataScope' => $this->getNamespace(), 'config' => array_replace_recursive( - array_merge($dataSource, $dataProviderConfig), + $config, [ 'params' => [ 'namespace' => $this->getNamespace() diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/Sanitizer.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/Sanitizer.php new file mode 100644 index 0000000000000..27a42fb337ce8 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/Sanitizer.php @@ -0,0 +1,102 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +namespace Magento\Framework\View\Element\UiComponent\DataProvider; + +use Magento\Framework\Phrase; + +/** + * Sanitizes data received from UI data providers. + */ +class Sanitizer +{ + /** + * Extract rendering config from given UI data. + * + * @param array $data + * @return bool|array + */ + private function extractConfig(array $data) + { + /** @var array|bool $config */ + $config = []; + if (array_key_exists('__disableTmpl', $data)) { + //UI data provider has explicitly provided rendering config. + $config = $data['__disableTmpl']; + unset($data['__disableTmpl']); + } + + return $config; + } + + /** + * Sanitizes data from a UI data provider. + * + * @param array $data + * @return array + */ + public function sanitize(array $data): array + { + $config = $this->extractConfig($data); + $toProcess = []; + array_walk( + $data, + function ($datum, string $key) use (&$config, &$toProcess) : void { + if (is_array($datum)) { + //Each array must have it's own __disableTmpl property + $toProcess[$key] = $datum; + } elseif (( + !is_bool($config) && !array_key_exists($key, $config) + ) + && (is_string($datum) || $datum instanceof Phrase) + && preg_match('/\$\{.+\}/', (string)$datum) + ) { + //Templating is not disabled for all properties or for this property specifically + //Property is a string that contains template syntax so we are disabling it's rendering + $config[$key] = true; + } + } + ); + if ($toProcess) { + //Processing sub-arrays + $data = array_replace($data, array_map([$this, 'sanitize'], $toProcess)); + } + if ($config !== []) { + //Some properties require rendering configuration. + $data['__disableTmpl'] = $config; + } + + return $data; + } + + /** + * Sanitize a component's metadata. + * + * Will sanitize full component's metadata as well as metadata of it's child components. + * + * @param array $meta + * @return array + */ + public function sanitizeComponentMetadata(array $meta): array + { + if (array_key_exists('arguments', $meta) + && is_array($meta['arguments']) + && array_key_exists('data', $meta['arguments']) + && is_array($meta['arguments']['data']) + && array_key_exists('config', $meta['arguments']['data']) + && is_array($meta['arguments']['data']['config']) + ) { + $meta['arguments']['data']['config'] = $this->sanitize($meta['arguments']['data']['config']); + } + if (array_key_exists('children', $meta) && is_array($meta['children'])) { + $meta['children'] = array_map([$this, 'sanitizeComponentMetadata'], $meta['children']); + } + + return $meta; + } +} diff --git a/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php b/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php index b395e95f0baaf..16c06fe3abf3a 100644 --- a/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php +++ b/lib/internal/Magento/Framework/View/Element/UiComponentFactory.php @@ -17,10 +17,11 @@ use Magento\Framework\View\Element\UiComponent\ContextFactory; use Magento\Framework\Phrase; use Magento\Framework\View\Element\UiComponent\DataProvider\DataProviderInterface; +use Magento\Framework\View\Element\UiComponent\DataProvider\Sanitizer; use Magento\Framework\View\Element\UiComponent\Factory\ComponentFactoryInterface; /** - * Class UiComponentFactory + * Factory that creates UI component descriptor based on configuration provided. * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -69,6 +70,11 @@ class UiComponentFactory extends DataObject */ private $definitionData; + /** + * @var Sanitizer + */ + private $sanitizer; + /** * @param ObjectManagerInterface $objectManager * @param ManagerInterface $componentManager @@ -78,6 +84,7 @@ class UiComponentFactory extends DataObject * @param array $componentChildFactories * @param DataInterface $definitionData * @param DataInterfaceFactory $configFactory + * @param Sanitizer|null $sanitizer */ public function __construct( ObjectManagerInterface $objectManager, @@ -87,7 +94,8 @@ public function __construct( array $data = [], array $componentChildFactories = [], DataInterface $definitionData = null, - DataInterfaceFactory $configFactory = null + DataInterfaceFactory $configFactory = null, + ?Sanitizer $sanitizer = null ) { $this->objectManager = $objectManager; $this->componentManager = $componentManager; @@ -98,6 +106,7 @@ public function __construct( parent::__construct($data); $this->definitionData = $definitionData ?: $this->objectManager->get(DataInterface::class); + $this->sanitizer = $sanitizer ?? $this->objectManager->get(Sanitizer::class); } /** @@ -198,8 +207,12 @@ protected function argumentsResolver($identifier, array $componentData) */ public function create($identifier, $name = null, array $arguments = []) { + //$argument contain dynamic data generated by UI component classes which should not contain templates. + $arguments = $this->sanitizer->sanitize($arguments); if ($name === null) { - $componentData = $this->configFactory->create(['componentName' => $identifier])->get($identifier); + /** @var DataInterface $config */ + $config = $this->configFactory->create(['componentName' => $identifier]); + $componentData = $config->get($identifier); $bundleComponents = [$identifier => $componentData]; list($className, $componentArguments) = $this->argumentsResolver( @@ -312,10 +325,10 @@ protected function mergeMetadata($identifier, array $bundleComponents, $reverseM { $dataProvider = $this->getDataProvider($identifier, $bundleComponents); if ($dataProvider instanceof DataProviderInterface) { + //Dynamic meta from data providers should not contain templates. + $metadata = $dataProvider->getMeta(); $metadata = [ - $identifier => [ - 'children' => $dataProvider->getMeta(), - ], + $identifier => $this->sanitizer->sanitizeComponentMetadata(['children' => $metadata]) ]; $bundleComponents = $this->mergeMetadataItem($bundleComponents, $metadata, $reverseMerge); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/DataProvider/SanitizerTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/DataProvider/SanitizerTest.php new file mode 100644 index 0000000000000..75fbfd868cfc1 --- /dev/null +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/UiComponent/DataProvider/SanitizerTest.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\View\Test\Unit\Element\UiComponent\DataProvider; + +use Magento\Framework\View\Element\UiComponent\DataProvider\Sanitizer; +use PHPUnit\Framework\TestCase; + +/** + * Test sanitizer for different kind of scenarios. + */ +class SanitizerTest extends TestCase +{ + /** + * @var Sanitizer + */ + private $sanitizer; + + /** + * @inheritDoc + */ + protected function setUp() + { + $this->sanitizer = new Sanitizer(); + } + + /** + * Data sets to sanitize. + * + * @return array + */ + public function getSanitizeDataSets(): array + { + return [ + 'simpleSet' => [ + ['foo' => '${\'bar\'}', 'xyz' => 42], + ['foo' => '${\'bar\'}', 'xyz' => 42, '__disableTmpl' => ['foo' => true]] + ], + 'configuredSet' => [ + ['foo' => 'bar', 'xyz' => '${\'zyx\'}', '__disableTmpl' => true], + ['foo' => 'bar', 'xyz' => '${\'zyx\'}', '__disableTmpl' => true] + ], + 'partiallyConfiguredSet' => [ + ['foo' => '${\'bar\'}', 'xyz' => '${\'zyx\'}', '__disableTmpl' => ['foo' => false]], + ['foo' => '${\'bar\'}', 'xyz' => '${\'zyx\'}', '__disableTmpl' => ['foo' => false, 'xyz' => true]] + ], + 'enabledSet' => [ + ['foo' => 'bar', 'xyz' => '${\'zyx\'}', '__disableTmpl' => false], + ['foo' => 'bar', 'xyz' => '${\'zyx\'}', '__disableTmpl' => false] + ], + 'complexSet' => [ + [ + 'foo' => 'bar', + 'sub1' => ['foo' => '${\'bar\'}'], + 'sub2' => [ + 'field' => '${\'value\'}', + 'subSub1' => ['foo' => 'bar'], + 'subSub2' => ['foo' => '${\'bar\'}', '__disableTmpl' => false], + 'subSub3' => [ + 'fooSub' => [ + 'foo' => '${\'bar\'}', + '__disableTmpl' => false, + 'subSubSub1' => ['field' => '${\'value\'}'] + ] + ], + 'subSub4' => [['foo' => '${\'bar\'}'], ['foo' => '${\'bar\'}', 'xyz' => '${\'zyx\'}']] + ] + ], + [ + 'foo' => 'bar', + 'sub1' => ['foo' => '${\'bar\'}', '__disableTmpl' => ['foo' => true]], + 'sub2' => [ + 'field' => '${\'value\'}', + 'subSub1' => ['foo' => 'bar'], + 'subSub2' => ['foo' => '${\'bar\'}', '__disableTmpl' => false], + 'subSub3' => [ + 'fooSub' => [ + 'foo' => '${\'bar\'}', + '__disableTmpl' => false, + 'subSubSub1' => ['field' => '${\'value\'}', '__disableTmpl' => ['field' => true]] + ] + ], + 'subSub4' => [ + ['foo' => '${\'bar\'}', '__disableTmpl' => ['foo' => true]], + [ + 'foo' => '${\'bar\'}', + 'xyz' => '${\'zyx\'}', + '__disableTmpl' => ['foo' => true, 'xyz' => true] + ] + ], + '__disableTmpl' => ['field' => true] + ] + ] + ] + ]; + } + + /** + * Test sanitize method for different data sets. + * + * @param array $input + * @param array $expectedOutput + * @return void + * @dataProvider getSanitizeDataSets + */ + public function testSanitize(array $input, array $expectedOutput): void + { + $this->assertEquals($expectedOutput, $this->sanitizer->sanitize($input)); + } + + /** + * Full UI component data sets to sanitize. + * + * @return array + */ + public function getSanitizeComponentDataSets(): array + { + return [ + 'simpleComponent' => [ + [ + 'arguments' => ['data' => ['config' => ['foo' => '${\'bar\'}', 'xyz' => 42]]], + 'children' => [ + 'child_component' => [ + 'arguments' => ['data' => ['config' => ['foo' => '${\'bar\'}', 'xyz' => '${\'xyz\'}']]] + ] + ] + ], + [ + 'arguments' => [ + 'data' => [ + 'config' => ['foo' => '${\'bar\'}', 'xyz' => 42, '__disableTmpl' => ['foo' => true]] + ] + ], + 'children' => [ + 'child_component' => [ + 'arguments' => [ + 'data' => [ + 'config' => [ + 'foo' => '${\'bar\'}', + 'xyz' => '${\'xyz\'}', + '__disableTmpl' => ['foo' => true, 'xyz' => true] + ] + ] + ] + ] + ] + ] + ], + 'argumentsOnly' => [ + ['arguments' => ['data' => ['config' => ['foo' => '${\'bar\'}']]]], + ['arguments' => ['data' => ['config' => ['foo' => '${\'bar\'}', '__disableTmpl' => ['foo' => true]]]]] + ], + 'childrenOnly' => [ + ['children' => ['child1' => ['arguments' => ['data' => ['config' => ['foo' => '${\'bar\'}']]]]]], + [ + 'children' => [ + 'child1' => [ + 'arguments' => [ + 'data' => ['config' => ['foo' => '${\'bar\'}', '__disableTmpl' => ['foo' => true]]] + ] + ] + ] + ] + ] + ]; + } + + /** + * Test sanitizeComponentMetadata method for different data sets. + * + * @param array $input + * @param array $expectedOutput + * @return void + * @dataProvider getSanitizeComponentDataSets + */ + public function testSanitizeComponentMetadata(array $input, array $expectedOutput): void + { + $this->assertEquals($expectedOutput, $this->sanitizer->sanitizeComponentMetadata($input)); + } +} From 1b75f0c1895953fde433973a59b1a6fa8079197e Mon Sep 17 00:00:00 2001 From: Hwashiang Yu <hwyu@adobe.com> Date: Wed, 15 Apr 2020 09:29:41 -0500 Subject: [PATCH 156/177] MC-30175: UI component rendering config - Resolved mftf test failure --- .../Mftf/ActionGroup/ApplyCouponOnPaymentPageActionGroup.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Payment/Test/Mftf/ActionGroup/ApplyCouponOnPaymentPageActionGroup.xml b/app/code/Magento/Payment/Test/Mftf/ActionGroup/ApplyCouponOnPaymentPageActionGroup.xml index 0f22222b5f767..f069e6ac4a4d5 100644 --- a/app/code/Magento/Payment/Test/Mftf/ActionGroup/ApplyCouponOnPaymentPageActionGroup.xml +++ b/app/code/Magento/Payment/Test/Mftf/ActionGroup/ApplyCouponOnPaymentPageActionGroup.xml @@ -20,6 +20,7 @@ <fillField selector="{{ProductCardSection.addCode}}" userInput="{{couponCode}}" stepKey="TypeDiscountCode"/> <click selector="{{ProductCardSection.applyDiscount}}" stepKey="clickToApplyDiscount"/> <waitForPageLoad stepKey="WaitForDiscountToBeAdded"/> - <see selector="{{ProductCardSection.discountVerificationMsg}}" userInput="Your coupon was successfully applied" stepKey="discountApplyMessage"/> + <!-- Success message will change to display none so will check DOM instead --> + <seeElementInDOM selector="{{ProductCardSection.discountSuccessMsgInDOM}}" stepKey="discountApplyMessage"/> </actionGroup> </actionGroups> From 699e35bb40c58b610c0a2e346399cc2f87f48f66 Mon Sep 17 00:00:00 2001 From: Hwashiang Yu <hwyu@adobe.com> Date: Wed, 15 Apr 2020 13:34:18 -0500 Subject: [PATCH 157/177] MC-30175: UI component rendering config - Resolved duplicated docblock typo --- .../Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php index e9d95c36ad9bb..e64a92a8bd6f4 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php +++ b/app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Edit/Tab/Variations/Config/Matrix.php @@ -14,8 +14,6 @@ * Product variations matrix block * All disableTmpl flag are required here for configurable products * - * All disableTmpl flag are required here for configurable products - * * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @since 100.0.2 From 694f15bb1425a79be7e905cd77d4b8363faf4613 Mon Sep 17 00:00:00 2001 From: Alex Paliarush <paliarus@adobe.com> Date: Wed, 15 Apr 2020 14:59:17 -0500 Subject: [PATCH 158/177] ECP-530: Static test to detect external project dependencies --- .../AsynchronousOperations/composer.json | 1 + app/code/Magento/MediaStorage/composer.json | 1 + app/code/Magento/MessageQueue/composer.json | 1 + app/code/Magento/MysqlMq/composer.json | 1 + app/code/Magento/WebapiAsync/composer.json | 1 + .../Dependency/AnalyticsConfigRule.php | 2 +- .../TestFramework/Dependency/DbRule.php | 4 +- .../TestFramework/Dependency/DiRule.php | 2 +- .../TestFramework/Dependency/LayoutRule.php | 109 +++--- .../TestFramework/Dependency/PhpRule.php | 32 +- .../Dependency/ReportsConfigRule.php | 2 +- .../Dependency/Route/RouteMapper.php | 2 +- .../Magento/Test/Integrity/ClassesTest.php | 6 +- .../Magento/Test/Integrity/DependencyTest.php | 346 +++++++++++++++--- .../blacklist/external_dependency/ce.php | 10 + .../blacklist/undeclared_dependency/ce.php | 10 + .../_files/dependency_test/tables_ce.php | 304 --------------- 17 files changed, 402 insertions(+), 432 deletions(-) create mode 100644 dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/external_dependency/ce.php create mode 100644 dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/undeclared_dependency/ce.php delete mode 100644 dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php diff --git a/app/code/Magento/AsynchronousOperations/composer.json b/app/code/Magento/AsynchronousOperations/composer.json index 4ac67ac6aa645..8a7a4f07a96cd 100644 --- a/app/code/Magento/AsynchronousOperations/composer.json +++ b/app/code/Magento/AsynchronousOperations/composer.json @@ -6,6 +6,7 @@ }, "require": { "magento/framework": "*", + "magento/framework-message-queue": "*", "magento/framework-bulk": "*", "magento/module-authorization": "*", "magento/module-backend": "*", diff --git a/app/code/Magento/MediaStorage/composer.json b/app/code/Magento/MediaStorage/composer.json index ce97eec97f7c3..caee2bb9a802a 100644 --- a/app/code/Magento/MediaStorage/composer.json +++ b/app/code/Magento/MediaStorage/composer.json @@ -7,6 +7,7 @@ "require": { "php": "~7.1.3||~7.2.0||~7.3.0", "magento/framework": "*", + "magento/framework-bulk": "*", "magento/module-backend": "*", "magento/module-config": "*", "magento/module-store": "*", diff --git a/app/code/Magento/MessageQueue/composer.json b/app/code/Magento/MessageQueue/composer.json index 92744126900a4..14cf0eaaee0c6 100644 --- a/app/code/Magento/MessageQueue/composer.json +++ b/app/code/Magento/MessageQueue/composer.json @@ -6,6 +6,7 @@ }, "require": { "magento/framework": "*", + "magento/framework-message-queue": "*", "magento/magento-composer-installer": "*", "php": "~7.1.3||~7.2.0||~7.3.0" }, diff --git a/app/code/Magento/MysqlMq/composer.json b/app/code/Magento/MysqlMq/composer.json index 413195c6f6d7c..a4e7443bf51f4 100644 --- a/app/code/Magento/MysqlMq/composer.json +++ b/app/code/Magento/MysqlMq/composer.json @@ -6,6 +6,7 @@ }, "require": { "magento/framework": "*", + "magento/framework-message-queue": "*", "magento/magento-composer-installer": "*", "magento/module-store": "*", "php": "~7.1.3||~7.2.0||~7.3.0" diff --git a/app/code/Magento/WebapiAsync/composer.json b/app/code/Magento/WebapiAsync/composer.json index d076897d61e2e..b37b5de12ca0d 100644 --- a/app/code/Magento/WebapiAsync/composer.json +++ b/app/code/Magento/WebapiAsync/composer.json @@ -7,6 +7,7 @@ "require": { "php": "~7.1.3||~7.2.0||~7.3.0", "magento/framework": "*", + "magento/framework-message-queue": "*", "magento/module-webapi": "*", "magento/module-asynchronous-operations": "*" }, diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/AnalyticsConfigRule.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/AnalyticsConfigRule.php index b1a6da5e43822..d6f9ba6268cf9 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Dependency/AnalyticsConfigRule.php +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/AnalyticsConfigRule.php @@ -30,7 +30,7 @@ public function getDependencyInfo($currentModule, $fileType, $file, &$contents) $module = implode('\\', array_slice($classParts, 0, 2)); if (strtolower($currentModule) !== strtolower($module)) { $dependenciesInfo[] = [ - 'module' => $module, + 'modules' => [$module], 'type' => RuleInterface::TYPE_HARD, 'source' => $file, ]; diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/DbRule.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/DbRule.php index 3e3fa7686a296..cb3a9e2cc9c35 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Dependency/DbRule.php +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/DbRule.php @@ -52,7 +52,7 @@ public function getDependencyInfo($currentModule, $fileType, $file, &$contents) } if (strtolower($currentModule) !== strtolower($this->_moduleTableMap[$table])) { $dependenciesInfo[] = [ - 'module' => $this->_moduleTableMap[$table], + 'modules' => [$this->_moduleTableMap[$table]], 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_HARD, 'source' => $table, ]; @@ -61,7 +61,7 @@ public function getDependencyInfo($currentModule, $fileType, $file, &$contents) } foreach ($unKnowTables as $tables) { foreach ($tables as $table) { - $dependenciesInfo[] = ['module' => 'Unknown', 'source' => $table]; + $dependenciesInfo[] = ['modules' => ['Unknown'], 'source' => $table]; } } return $dependenciesInfo; diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/DiRule.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/DiRule.php index b3ee0a2880308..122c3da3afcb1 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Dependency/DiRule.php +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/DiRule.php @@ -93,7 +93,7 @@ public function getDependencyInfo($currentModule, $fileType, $file, &$contents) continue; } $dependenciesInfo[] = [ - 'module' => $referenceModule, + 'modules' => [$referenceModule], 'type' => $type, 'source' => $matches['class'], ]; diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/LayoutRule.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/LayoutRule.php index 27017c6069538..75825077e03ec 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Dependency/LayoutRule.php +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/LayoutRule.php @@ -133,8 +133,8 @@ public function getDependencyInfo($currentModule, $fileType, $file, &$contents) * * Ex.: <element module="{module}"> * - * @param $currentModule - * @param $contents + * @param string $currentModule + * @param string $contents * @return array */ protected function _caseAttributeModule($currentModule, &$contents) @@ -154,8 +154,8 @@ protected function _caseAttributeModule($currentModule, &$contents) * Ex.: <block class="{name}"> * <block template="{path}"> * - * @param $currentModule - * @param $contents + * @param string $currentModule + * @param string $contents * @return array */ protected function _caseElementBlock($currentModule, &$contents) @@ -182,8 +182,8 @@ protected function _caseElementBlock($currentModule, &$contents) * <file>{path} * <element helper="{name}"> * - * @param $currentModule - * @param $contents + * @param string $currentModule + * @param string $contents * @return array */ protected function _caseElementAction($currentModule, &$contents) @@ -218,9 +218,9 @@ protected function _caseElementAction($currentModule, &$contents) * * Ex.: <layout><{name}>...</layout> * - * @param $currentModule - * @param $file - * @param $contents + * @param string $currentModule + * @param string $file + * @param string $contents * @return array */ protected function _caseLayoutHandle($currentModule, $file, &$contents) @@ -235,11 +235,8 @@ protected function _caseLayoutHandle($currentModule, $file, &$contents) $result = []; foreach ((array)$xml->xpath('/layout/child::*') as $element) { $check = $this->_checkDependencyLayoutHandle($currentModule, $area, $element->getName()); - $modules = isset($check['module']) ? $check['module'] : null; + $modules = isset($check['modules']) ? $check['modules'] : null; if ($modules) { - if (!is_array($modules)) { - $modules = [$modules]; - } foreach ($modules as $module) { $result[$module] = [ 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_SOFT, @@ -256,9 +253,9 @@ protected function _caseLayoutHandle($currentModule, $file, &$contents) * * Ex.: <layout_name parent="{name}"> * - * @param $currentModule - * @param $file - * @param $contents + * @param string $currentModule + * @param string $file + * @param string $contents * @return array */ protected function _caseLayoutHandleParent($currentModule, $file, &$contents) @@ -273,11 +270,8 @@ protected function _caseLayoutHandleParent($currentModule, $file, &$contents) $result = []; foreach ((array)$xml->xpath('/layout/child::*/@parent') as $element) { $check = $this->_checkDependencyLayoutHandle($currentModule, $area, (string)$element); - $modules = isset($check['module']) ? $check['module'] : null; + $modules = isset($check['modules']) ? $check['modules'] : null; if ($modules) { - if (!is_array($modules)) { - $modules = [$modules]; - } foreach ($modules as $module) { $result[$module] = [ 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_HARD, @@ -294,9 +288,9 @@ protected function _caseLayoutHandleParent($currentModule, $file, &$contents) * * Ex.: <update handle="{name}" /> * - * @param $currentModule - * @param $file - * @param $contents + * @param string $currentModule + * @param string $file + * @param string $contents * @return array */ protected function _caseLayoutHandleUpdate($currentModule, $file, &$contents) @@ -311,11 +305,8 @@ protected function _caseLayoutHandleUpdate($currentModule, $file, &$contents) $result = []; foreach ((array)$xml->xpath('//update/@handle') as $element) { $check = $this->_checkDependencyLayoutHandle($currentModule, $area, (string)$element); - $modules = isset($check['module']) ? $check['module'] : null; + $modules = isset($check['modules']) ? $check['modules'] : null; if ($modules) { - if (!is_array($modules)) { - $modules = [$modules]; - } foreach ($modules as $module) { $result[$module] = [ 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_SOFT, @@ -332,9 +323,9 @@ protected function _caseLayoutHandleUpdate($currentModule, $file, &$contents) * * Ex.: <reference name="{name}"> * - * @param $currentModule - * @param $file - * @param $contents + * @param string $currentModule + * @param string $file + * @param string $contents * @return array */ protected function _caseLayoutReference($currentModule, $file, &$contents) @@ -349,12 +340,14 @@ protected function _caseLayoutReference($currentModule, $file, &$contents) $result = []; foreach ((array)$xml->xpath('//reference/@name') as $element) { $check = $this->_checkDependencyLayoutBlock($currentModule, $area, (string)$element); - $module = isset($check['module']) ? $check['module'] : null; - if ($module) { - $result[$module] = [ - 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_SOFT, - 'source' => (string)$element, - ]; + $modules = isset($check['modules']) ? $check['modules'] : null; + if ($modules) { + foreach ($modules as $module) { + $result[$module] = [ + 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_SOFT, + 'source' => (string)$element, + ]; + } } } return $this->_getUniqueDependencies($result); @@ -363,8 +356,8 @@ protected function _caseLayoutReference($currentModule, $file, &$contents) /** * Search dependencies by defined regexp patterns * - * @param $currentModule - * @param $contents + * @param string $currentModule + * @param string $contents * @param array $patterns * @return array */ @@ -390,14 +383,14 @@ protected function _checkDependenciesByRegexp($currentModule, &$contents, $patte * Check layout handle dependency * * Return: array( - * 'module' // dependent module + * 'modules' // dependent modules * 'source' // source text * ) * - * @param $currentModule - * @param $area - * @param $handle - * @return array + * @param admin $currentModule + * @param string $area + * @param string $handle + * @return string[] */ protected function _checkDependencyLayoutHandle($currentModule, $area, $handle) { @@ -411,7 +404,7 @@ protected function _checkDependencyLayoutHandle($currentModule, $area, $handle) // CASE 1: Single dependency $modules = $this->_mapRouters[$router]; if (!in_array($currentModule, $modules)) { - return ['module' => $modules]; + return ['modules' => $modules]; } } @@ -419,18 +412,18 @@ protected function _checkDependencyLayoutHandle($currentModule, $area, $handle) // CASE 2: No dependencies $modules = $this->_mapLayoutHandles[$area][$handle]; if (isset($modules[$currentModule])) { - return ['module' => null]; + return ['modules' => []]; } // CASE 3: Single dependency if (1 == count($modules)) { - return ['module' => current($modules)]; + return ['modules' => $modules]; } // CASE 4: Default module dependency $defaultModule = $this->_getDefaultModuleName($area); if (isset($modules[$defaultModule])) { - return ['module' => $defaultModule]; + return ['modules' => [$defaultModule]]; } } @@ -441,14 +434,14 @@ protected function _checkDependencyLayoutHandle($currentModule, $area, $handle) * Check layout block dependency * * Return: array( - * 'module' // dependent module + * 'modules' // dependent modules * 'source' // source text * ) * - * @param $currentModule - * @param $area - * @param $block - * @return array + * @param string $currentModule + * @param string $area + * @param string $block + * @return string[] */ protected function _checkDependencyLayoutBlock($currentModule, $area, $block) { @@ -456,18 +449,18 @@ protected function _checkDependencyLayoutBlock($currentModule, $area, $block) // CASE 1: No dependencies $modules = $this->_mapLayoutBlocks[$area][$block]; if (isset($modules[$currentModule])) { - return ['module' => null]; + return ['modules' => []]; } // CASE 2: Single dependency if (1 == count($modules)) { - return ['module' => current($modules)]; + return ['modules' => $modules]; } // CASE 3: Default module dependency $defaultModule = $this->_getDefaultModuleName($area); if (isset($modules[$defaultModule])) { - return ['module' => $defaultModule]; + return ['modules' => [$defaultModule]]; } } return []; @@ -476,7 +469,7 @@ protected function _checkDependencyLayoutBlock($currentModule, $area, $block) /** * Get area from file path * - * @param $file + * @param string $file * @return string */ protected function _getAreaByFile($file) @@ -498,7 +491,7 @@ protected function _getUniqueDependencies($dependencies = []) { $result = []; foreach ($dependencies as $module => $value) { - $result[] = ['module' => $module, 'type' => $value['type'], 'source' => $value['source']]; + $result[] = ['modules' => [$module], 'type' => $value['type'], 'source' => $value['source']]; } return $result; } @@ -507,7 +500,7 @@ protected function _getUniqueDependencies($dependencies = []) * Retrieve default module name (by area) * * @param string $area - * @return null + * @return string|null */ protected function _getDefaultModuleName($area = 'default') { diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php index 913cc9448b978..7ae854885affa 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/PhpRule.php @@ -94,7 +94,6 @@ public function __construct( ) { $this->_mapRouters = $mapRouters; $this->_mapLayoutBlocks = $mapLayoutBlocks; - $this->_namespaces = implode('|', \Magento\Framework\App\Utility\Files::init()->getNamespaces()); $this->pluginMap = $pluginMap ?: null; $this->routeMapper = new RouteMapper(); $this->whitelists = $whitelists; @@ -184,7 +183,7 @@ private function caseClassesAndIdentifiers($currentModule, $file, &$contents) } $dependenciesInfo[] = [ - 'module' => $referenceModule, + 'modules' => [$referenceModule], 'type' => $dependencyType, 'source' => $dependencyClass, ]; @@ -317,11 +316,8 @@ protected function _caseGetUrl(string $currentModule, string &$contents): array $actionName ); if (!in_array($currentModule, $modules)) { - if (count($modules) === 1) { - $modules = reset($modules); - } $dependencies[] = [ - 'module' => $modules, + 'modules' => $modules, 'type' => RuleInterface::TYPE_HARD, 'source' => $item['source'], ]; @@ -361,12 +357,14 @@ protected function _caseLayoutBlock(string $currentModule, string $fileType, str continue; } $check = $this->_checkDependencyLayoutBlock($currentModule, $area, $match['block']); - $module = isset($check['module']) ? $check['module'] : null; - if ($module) { - $result[$module] = [ - 'type' => RuleInterface::TYPE_HARD, - 'source' => $match['source'], - ]; + $modules = isset($check['modules']) ? $check['modules'] : null; + if ($modules) { + foreach ($modules as $module) { + $result[$module] = [ + 'type' => RuleInterface::TYPE_HARD, + 'source' => $match['source'], + ]; + } } } return $this->_getUniqueDependencies($result); @@ -395,7 +393,7 @@ protected function _getAreaByFile(string $file, string $fileType): ?string * Check layout block dependency * * Return: array( - * 'module' // dependent module + * 'modules' // dependent modules * 'source' // source text * ) * @@ -419,16 +417,16 @@ protected function _checkDependencyLayoutBlock(string $currentModule, ?string $a $modules = $this->_mapLayoutBlocks[$area][$block]; } if (isset($modules[$currentModule])) { - return ['module' => null]; + return ['modules' => []]; } // CASE 2: Single dependency if (1 == count($modules)) { - return ['module' => current($modules)]; + return ['modules' => $modules]; } // CASE 3: Default module dependency $defaultModule = $this->_getDefaultModuleName($area); if (isset($modules[$defaultModule])) { - return ['module' => $defaultModule]; + return ['modules' => [$defaultModule]]; } } // CASE 4: \Exception - Undefined block @@ -459,7 +457,7 @@ protected function _getUniqueDependencies($dependencies = []) { $result = []; foreach ($dependencies as $module => $value) { - $result[] = ['module' => $module, 'type' => $value['type'], 'source' => $value['source']]; + $result[] = ['modules' => [$module], 'type' => $value['type'], 'source' => $value['source']]; } return $result; } diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/ReportsConfigRule.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/ReportsConfigRule.php index ab450fba5781d..4c8daaebdd698 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Dependency/ReportsConfigRule.php +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/ReportsConfigRule.php @@ -43,7 +43,7 @@ public function getDependencyInfo($currentModule, $fileType, $file, &$contents) } if (strtolower($currentModule) !== strtolower($this->moduleTableMap[$table])) { $dependenciesInfo[] = [ - 'module' => $this->moduleTableMap[$table], + 'modules' => [$this->moduleTableMap[$table]], 'type' => RuleInterface::TYPE_HARD, 'source' => $table, ]; diff --git a/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php b/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php index 315bb2ae26b02..6cc55b49edcca 100644 --- a/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php +++ b/dev/tests/static/framework/Magento/TestFramework/Dependency/Route/RouteMapper.php @@ -154,7 +154,7 @@ function (&$modules) { * @param string $routeId * @param string $controllerName * @param string $actionName - * @return array + * @return string[] * @throws NoSuchActionException * @throws \Exception */ diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php index c5447ef716eb2..c53586599ef00 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php @@ -306,6 +306,8 @@ private function assertClassNamespace(string $file, string $relativePath, string public function testClassReferences() { + $this->markTestSkipped("To be fixed in MC-33329. The test is not working properly " + . "after blacklisting logic was fixed. Previously it was ignoring all files."); $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this); $invoker( /** @@ -427,9 +429,9 @@ private function handleAliasClasses(array $aliasClasses, array $badClasses): arr private function referenceBlacklistFilter(array $classes): array { // exceptions made for the files from the blacklist - $classes = $this->getReferenceBlacklist(); + $blacklistClasses = $this->getReferenceBlacklist(); foreach ($classes as $class) { - if (in_array($class, $this->referenceBlackList)) { + if (in_array($class, $blacklistClasses)) { unset($classes[array_search($class, $classes)]); } } diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php index 60855043a8c4e..302894c3cface 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php @@ -166,6 +166,21 @@ class DependencyTest extends \PHPUnit\Framework\TestCase */ private static $routeMapper = null; + /** + * @var ComponentRegistrar + */ + private static $componentRegistrar = null; + + /** + * @var array + */ + private $externalDependencyBlacklist; + + /** + * @var array + */ + private $undeclaredDependencyBlacklist; + /** * Sets up data * @@ -258,13 +273,11 @@ protected static function _initThemes() */ protected static function _initRules() { - $replaceFilePattern = str_replace('\\', '/', realpath(__DIR__)) - . '/_files/dependency_test/tables_*.php'; - $dbRuleTables = []; - foreach (glob($replaceFilePattern) as $fileName) { - //phpcs:ignore Magento2.Performance.ForeachArrayMerge - $dbRuleTables = array_merge($dbRuleTables, include $fileName); - } + $tableToPrimaryModuleMap= self::getTableToPrimaryModuleMap(); + $tableToAnyModuleMap = self::getTableToAnyModuleMap(); + // In case primary module declaring the table cannot be identified, use any module referencing this table + $tableToModuleMap = array_merge($tableToAnyModuleMap, $tableToPrimaryModuleMap); + self::$_rulesInstances = [ new PhpRule( self::$routeMapper->getRoutes(), @@ -272,14 +285,14 @@ protected static function _initRules() [], ['routes' => self::getRoutesWhitelist()] ), - new DbRule($dbRuleTables), + new DbRule($tableToModuleMap), new LayoutRule( self::$routeMapper->getRoutes(), self::$_mapLayoutBlocks, self::$_mapLayoutHandles ), new DiRule(new VirtualTypeMapper()), - new ReportsConfigRule($dbRuleTables), + new ReportsConfigRule($tableToModuleMap), new AnalyticsConfigRule(), ]; } @@ -303,6 +316,78 @@ private static function getRoutesWhitelist(): array return self::$routesWhitelist; } + /** + * Get full path to app/code directory, assuming these tests are run from the dev/tests directory. + * + * @return string + * @throws \LogicException + */ + private static function getAppCodeDir() + { + $appCode = BP . '/app/code'; + if (!$appCode) { + throw new \LogicException('app/code directory cannot be located'); + } + return $appCode; + } + + /** + * Get a map of tables to primary modules. + * + * Primary module is the one which initially defines the table (versus the module extending its declaration). + * + * @see getTableToAnyModuleMap + * + * @return array + */ + private static function getTableToPrimaryModuleMap(): array + { + $appCode = self::getAppCodeDir(); + $tableToPrimaryModuleMap = []; + foreach (glob($appCode . '/*/*/etc/db_schema_whitelist.json') as $file) { + $dbSchemaWhitelist = (array)json_decode(file_get_contents($file)); + preg_match('|.*/(.*)/(.*)/etc/db_schema_whitelist.json|', $file, $matches); + $moduleName = $matches[1] . '\\' . $matches[2]; + $isStagingModule = (substr_compare($moduleName, 'Staging', -strlen('Staging')) === 0); + if ($isStagingModule) { + // even though staging modules modify the constraints, they almost never declare new tables + continue; + } + foreach ($dbSchemaWhitelist as $tableName => $tableMetadata) { + if (isset($tableMetadata->constraint)) { + $tableToPrimaryModuleMap[$tableName] = $moduleName; + } + } + } + return $tableToPrimaryModuleMap; + } + + /** + * Get a map of tables matching to module names. + * + * Every table will have a module associated with it, + * even if the primary module cannot be defined based on declared constraints. + * + * @see getTableToPrimaryModuleMap + * + * @return array + */ + private static function getTableToAnyModuleMap(): array + { + $appCode = self::getAppCodeDir(); + $tableToAnyModuleMap = []; + foreach (glob($appCode . '/*/*/etc/db_schema_whitelist.json') as $file) { + $dbSchemaWhitelist = (array)json_decode(file_get_contents($file)); + $tables = array_keys($dbSchemaWhitelist); + preg_match('|.*/(.*)/(.*)/etc/db_schema_whitelist.json|', $file, $matches); + $moduleName = $matches[1] . '\\' . $matches[2]; + foreach ($tables as $table) { + $tableToAnyModuleMap[$table] = $moduleName; + } + } + return $tableToAnyModuleMap; + } + /** * Return cleaned file contents * @@ -353,6 +438,7 @@ function ($matches) use ($contents, &$contentsWithoutHtml) { public function testUndeclared() { $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this); + $blackList = $this->getUndeclaredDependencyBlacklist(); $invoker( /** * Check undeclared modules dependencies for specified file @@ -360,27 +446,12 @@ public function testUndeclared() * @param string $fileType * @param string $file */ - function ($fileType, $file) { - // Validates file when it is belonged to default themes - $componentRegistrar = new ComponentRegistrar(); - foreach ($componentRegistrar->getPaths(ComponentRegistrar::THEME) as $themeDir) { - if (strpos($file, $themeDir . '/') !== false) { - return; - } - } - - $foundModuleName = ''; - foreach ($componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $moduleName => $moduleDir) { - if (strpos($file, $moduleDir . '/') !== false) { - $foundModuleName = str_replace('_', '\\', $moduleName); - break; - } - } - if (empty($foundModuleName)) { + function ($fileType, $file) use ($blackList) { + $module = $this->getModuleNameForRelevantFile($file); + if (!$module) { return; } - $module = $foundModuleName; $contents = $this->_getCleanedFileContents($fileType, $file); $dependencies = $this->getDependenciesFromFiles($module, $fileType, $file, $contents); @@ -390,7 +461,9 @@ function ($fileType, $file) { // Prepare output message $result = []; + foreach ($undeclaredDependency as $type => $modules) { + $modules = $this->filterOutBlacklistedDependencies($file, $modules, $blackList); $modules = array_unique($modules); if (empty($modules)) { continue; @@ -405,6 +478,180 @@ function ($fileType, $file) { ); } + /** + * Filter out list of module dependencies based on the provided blacklist. + * + * Always exclude dependency on Setup because it is part of base Magento package. + * + * @param string $filePath + * @param string[] $modules + * @param array $blackList + * @return string[] + */ + private function filterOutBlacklistedDependencies($filePath, $modules, array $blackList): array + { + $relativeFilePath = substr_replace($filePath, '', 0, strlen(BP . '/')); + foreach ($modules as $moduleKey => $module) { + if ($module == 'Magento\Setup') { + unset($modules[$moduleKey]); + } + if (isset($blackList[$relativeFilePath]) + && in_array($module, $blackList[$relativeFilePath]) + ) { + unset($modules[$moduleKey]); + } + } + return $modules; + } + + /** + * Identify dependencies on the components which are not part of the current project. + * + * For example, such test allows to prevent invalid dependencies from the storefront application to the monolith. + * + * @throws \Exception + */ + public function testExternalDependencies() + { + $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this); + $blackList = $this->getExternalDependencyBlacklist(); + $invoker( + /** + * Check external modules dependencies for specified file + * + * @param string $fileType + * @param string $file + */ + function ($fileType, $file) use ($blackList) { + $module = $this->getModuleNameForRelevantFile($file); + if (!$module) { + return; + } + $externalDependencies = $this->collectExternalDependencies($file, $fileType, $module); + // Prepare output message + $result = []; + foreach ($externalDependencies as $type => $modules) { + $modules = $this->filterOutBlacklistedDependencies($file, $modules, $blackList); + $modules = array_unique($modules); + if (empty($modules)) { + continue; + } + $result[] = sprintf("%s [%s]", $type, implode(', ', $modules)); + } + if (!empty($result)) { + $this->fail('Module ' . $module . ' has external dependencies: ' . implode(', ', $result)); + } + }, + $this->getAllFiles() + ); + } + + /** + * Return module name for the file being tested if it should be tested. Return empty string otherwise. + * + * @param string $file + * @return string + */ + private function getModuleNameForRelevantFile($file) + { + if (!isset(self::$componentRegistrar)) { + self::$componentRegistrar = new ComponentRegistrar(); + } + // Validates file when it belongs to default themes + foreach (self::$componentRegistrar->getPaths(ComponentRegistrar::THEME) as $themeDir) { + if (strpos($file, $themeDir . '/') !== false) { + return ''; + } + } + + $foundModuleName = ''; + foreach (self::$componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $moduleName => $moduleDir) { + if (strpos($file, $moduleDir . '/') !== false) { + $foundModuleName = str_replace('_', '\\', $moduleName); + break; + } + } + if (empty($foundModuleName)) { + return ''; + } + + return $foundModuleName; + } + + /** + * Collect a list of external dependencies of the specified file. + * + * Dependency is considered external if it cannot be traced withing current codebase. + * + * @param string $file + * @param string $fileType + * @param string $module + * @return array + * @throws LocalizedException + */ + private function collectExternalDependencies($file, $fileType, $module) + { + $contents = $this->_getCleanedFileContents($fileType, $file); + + $dependencies = $this->getDependenciesFromFiles($module, $fileType, $file, $contents); + $externalDependencies = []; + foreach ($dependencies as $dependency) { + $dependencyModules = $dependency['modules']; + foreach ($dependencyModules as $dependencyModule) { + if ($dependency['type'] !== 'soft' + && !isset(self::$mapDependencies[$dependencyModule]) + && (strpos($dependencyModule, 'Magento\Framework') !== 0) + ) { + $dependencySummary = ($dependencyModule !== 'Unknown') + ? $dependencyModule + : $dependency['source']; + $externalDependencies[$dependency['type']][] = $dependencySummary; + } + } + } + return $externalDependencies; + } + + /** + * Return a list of blacklisted external dependencies. + * + * @return array + */ + private function getExternalDependencyBlacklist(): array + { + if (!isset($this->externalDependencyBlacklist)) { + $this->externalDependencyBlacklist = []; + foreach (glob(__DIR__ . '/_files/blacklist/external_dependency/*.php') as $filename) { + $this->externalDependencyBlacklist = array_merge_recursive( + $this->externalDependencyBlacklist, + include $filename + ); + } + } + + return $this->externalDependencyBlacklist; + } + + /** + * Return a list of blacklisted undeclared dependencies. + * + * @return array + */ + private function getUndeclaredDependencyBlacklist(): array + { + if (!isset($this->undeclaredDependencyBlacklist)) { + $this->undeclaredDependencyBlacklist = []; + foreach (glob(__DIR__ . '/_files/blacklist/undeclared_dependency/*.php') as $filename) { + $this->undeclaredDependencyBlacklist = array_merge_recursive( + $this->undeclaredDependencyBlacklist, + include $filename + ); + } + } + + return $this->undeclaredDependencyBlacklist; + } + /** * Retrieve dependencies from files * @@ -412,7 +659,14 @@ function ($fileType, $file) { * @param string $fileType * @param string $file * @param string $contents - * @return string[] + * @return array [ + * [ + * 'modules' => string[], + * 'type' => string + * 'source' => string + * ], + * ... + * ] * @throws LocalizedException */ protected function getDependenciesFromFiles($module, $fileType, $file, $contents) @@ -425,14 +679,20 @@ protected function getDependenciesFromFiles($module, $fileType, $file, $contents //phpcs:ignore Magento2.Performance.ForeachArrayMerge $dependencies = array_merge($dependencies, $newDependencies); } - foreach ($dependencies as $key => $dependency) { + + foreach ($dependencies as $dependencyKey => $dependency) { foreach (self::$whiteList as $namespace) { if (strpos($dependency['source'], $namespace) !== false) { - $dependency['module'] = $namespace; - $dependencies[$key] = $dependency; + $dependency['modules'] = [$namespace]; + $dependencies[$dependencyKey] = $dependency; } } + $dependency['type'] = $dependency['type'] ?? 'type is unknown'; + if (empty($dependency['modules'])) { + unset($dependencies[$dependencyKey]); + } } + return $dependencies; } @@ -471,20 +731,8 @@ private function collectDependency($dependency, $currentModule, &$undeclared) $declared = $type == self::TYPE_SOFT ? array_merge($soft, $hard) : $hard; - $module = $dependency['module']; - if (is_array($module)) { - $this->collectConditionalDependencies($module, $type, $currentModule, $declared, $undeclared); - } else { - $nsModule = str_replace('_', '\\', $module); - - if (!in_array($nsModule, $declared) && !$this->_isFake($nsModule)) { - $undeclared[$type][] = $module; - } elseif (in_array($nsModule, $declared) && $this->_isFake($nsModule)) { - $this->_setDependencies($currentModule, $type, self::MAP_TYPE_REDUNDANT, $module); - } - - $this->addDependency($currentModule, $type, self::MAP_TYPE_FOUND, $nsModule); - } + $modules = $dependency['modules']; + $this->collectConditionalDependencies($modules, $type, $currentModule, $declared, $undeclared); } /** @@ -746,6 +994,14 @@ protected static function convertModuleName(string $jsonName, array $packageModu return $moduleName; } + // convert names of the modules not registered in any composer.json + preg_match('|magento/module-(.*)|', $jsonName, $matches); + if (isset($matches[1])) { + $moduleNameHyphenated = $matches[1]; + $moduleNameUpperCamelCase = 'Magento\\' . str_replace('-', '', ucwords($moduleNameHyphenated, '-')); + return $moduleNameUpperCamelCase; + } + return $jsonName; } diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/external_dependency/ce.php b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/external_dependency/ce.php new file mode 100644 index 0000000000000..3330b5a941207 --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/external_dependency/ce.php @@ -0,0 +1,10 @@ +<?php +/** + * Black list for the @see \Magento\Test\Integrity\DependencyTest::testExternalDependencies() + * + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +return [ + 'app/code/Magento/Paypal/Model/AbstractConfig.php' => ['Magento\Cart'], +]; diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/undeclared_dependency/ce.php b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/undeclared_dependency/ce.php new file mode 100644 index 0000000000000..3a8c59c07848b --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/undeclared_dependency/ce.php @@ -0,0 +1,10 @@ +<?php +/** + * Black list for the @see \Magento\Test\Integrity\DependencyTest::testUndeclared() + * + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +return [ + 'app/code/Magento/Paypal/Model/AbstractConfig.php' => ['Magento\Cart'], +]; diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php deleted file mode 100644 index b120c65d3a759..0000000000000 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/dependency_test/tables_ce.php +++ /dev/null @@ -1,304 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -return [ - 'admin_assert' => 'Magento\Backend', - 'authorization_role' => 'Magento\Authorization', - 'authorization_rule' => 'Magento\Authorization', - 'admin_user' => 'Magento\User', - 'adminnotification_inbox' => 'Magento\AdminNotification', - 'catalog_category_entity_datetime' => 'Magento\Catalog', - 'catalog_category_entity_decimal' => 'Magento\Catalog', - 'catalog_category_entity_int' => 'Magento\Catalog', - 'catalog_category_entity_text' => 'Magento\Catalog', - 'catalog_category_entity_varchar' => 'Magento\Catalog', - 'catalog_product_entity_datetime' => 'Magento\Catalog', - 'catalog_product_entity_decimal' => 'Magento\Catalog', - 'catalog_product_entity_gallery' => 'Magento\Catalog', - 'catalog_product_entity_int' => 'Magento\Catalog', - 'catalog_product_entity_text' => 'Magento\Catalog', - 'catalog_product_entity_varchar' => 'Magento\Catalog', - 'catalog_product_bundle_option' => 'Magento\Bundle', - 'catalog_product_index_price_bundle_opt_idx' => 'Magento\Bundle', - 'catalog_product_index_price_bundle_opt_tmp' => 'Magento\Bundle', - 'catalog_product_bundle_option_value' => 'Magento\Bundle', - 'catalog_product_bundle_price_index' => 'Magento\Bundle', - 'catalog_product_index_price_bundle_idx' => 'Magento\Bundle', - 'catalog_product_index_price_bundle_tmp' => 'Magento\Bundle', - 'catalog_product_bundle_selection' => 'Magento\Bundle', - 'catalog_product_index_price_bundle_sel_idx' => 'Magento\Bundle', - 'catalog_product_index_price_bundle_sel_tmp' => 'Magento\Bundle', - 'catalog_product_bundle_selection_price' => 'Magento\Bundle', - 'catalog_product_bundle_stock_index' => 'Magento\Bundle', - 'captcha_log' => 'Magento\Captcha', - 'catalog_category_entity' => 'Magento\Catalog', - 'catalog_category_flat' => 'Magento\Catalog', - 'catalog_category_product' => 'Magento\Catalog', - 'catalog_category_product_index' => 'Magento\Catalog', - 'catalog_compare_item' => 'Magento\Catalog', - 'catalog_eav_attribute' => 'Magento\Catalog', - 'catalog_product_entity' => 'Magento\Catalog', - 'catalog_product_entity_media_gallery' => 'Magento\Catalog', - 'catalog_product_entity_media_gallery_value' => 'Magento\Catalog', - 'catalog_product_entity_tier_price' => 'Magento\Catalog', - 'catalog_product_index_eav_decimal_idx' => 'Magento\Catalog', - 'catalog_product_index_eav_decimal_tmp' => 'Magento\Catalog', - 'catalog_product_index_eav_idx' => 'Magento\Catalog', - 'catalog_product_index_eav_tmp' => 'Magento\Catalog', - 'catalog_product_flat' => 'Magento\Catalog', - 'catalog_product_index_eav' => 'Magento\Catalog', - 'catalog_product_index_eav_decimal' => 'Magento\Catalog', - 'catalog_product_index_price' => 'Magento\Catalog', - 'catalog_product_index_tier_price' => 'Magento\Catalog', - 'catalog_product_index_website' => 'Magento\Catalog', - 'catalog_product_link' => 'Magento\Catalog', - 'catalog_product_link_attribute' => 'Magento\Catalog', - 'catalog_product_link_attribute_decimal' => 'Magento\Catalog', - 'catalog_product_link_attribute_int' => 'Magento\Catalog', - 'catalog_product_link_attribute_varchar' => 'Magento\Catalog', - 'catalog_product_link_type' => 'Magento\Catalog', - 'catalog_product_option' => 'Magento\Catalog', - 'catalog_product_option_price' => 'Magento\Catalog', - 'catalog_product_option_title' => 'Magento\Catalog', - 'catalog_product_option_type_price' => 'Magento\Catalog', - 'catalog_product_option_type_title' => 'Magento\Catalog', - 'catalog_product_option_type_value' => 'Magento\Catalog', - 'catalog_product_index_price_cfg_opt_agr_idx' => 'Magento\Catalog', - 'catalog_product_index_price_cfg_opt_agr_tmp' => 'Magento\Catalog', - 'catalog_product_index_price_cfg_opt_idx' => 'Magento\Catalog', - 'catalog_product_index_price_cfg_opt_tmp' => 'Magento\Catalog', - 'catalog_product_index_price_final_idx' => 'Magento\Catalog', - 'catalog_product_index_price_final_tmp' => 'Magento\Catalog', - 'catalog_product_index_price_idx' => 'Magento\Catalog', - 'catalog_product_index_price_opt_agr_idx' => 'Magento\Catalog', - 'catalog_product_index_price_opt_agr_tmp' => 'Magento\Catalog', - 'catalog_product_index_price_opt_idx' => 'Magento\Catalog', - 'catalog_product_index_price_opt_tmp' => 'Magento\Catalog', - 'catalog_product_index_price_tmp' => 'Magento\Catalog', - 'catalog_product_relation' => 'Magento\Catalog', - 'catalog_product_super_attribute' => 'Magento\Catalog', - 'catalog_product_super_attribute_label' => 'Magento\Catalog', - 'catalog_product_super_attribute_pricing' => 'Magento\Catalog', - 'catalog_product_super_link' => 'Magento\Catalog', - 'catalog_product_website' => 'Magento\Catalog', - 'cataloginventory_stock' => 'Magento\CatalogInventory', - 'cataloginventory_stock_item' => 'Magento\CatalogInventory', - 'cataloginventory_stock_status' => 'Magento\CatalogInventory', - 'cataloginventory_stock_status_idx' => 'Magento\CatalogInventory', - 'cataloginventory_stock_status_tmp' => 'Magento\CatalogInventory', - 'catalogrule_customer_group' => 'Magento\CatalogRule', - 'catalogrule' => 'Magento\CatalogRule', - 'catalogrule_group_website' => 'Magento\CatalogRule', - 'catalogrule_product' => 'Magento\CatalogRule', - 'catalogrule_product_price' => 'Magento\CatalogRule', - 'catalogrule_website' => 'Magento\CatalogRule', - 'catalogsearch_fulltext' => 'Magento\CatalogSearch', - 'catalogsearch_result' => 'Magento\CatalogSearch', - 'search_query' => 'Magento\Search', - 'checkout_agreement' => 'Magento\Checkout', - 'checkout_agreement_store' => 'Magento\Checkout', - 'cms_block' => 'Magento\Cms', - 'cms_block_store' => 'Magento\Cms', - 'cms_page' => 'Magento\Cms', - 'cms_page_store' => 'Magento\Cms', - 'core_config_data' => 'Magento\Config', - 'design_change' => 'Magento\Theme', - 'media_storage_directory_storage' => 'Magento\MediaStorage', - 'email_template' => 'Magento\Email', - 'media_storage_file_storage' => 'Magento\MediaStorage', - 'store' => 'Magento\Store', - 'store_group' => 'Magento\Store', - 'store_website' => 'Magento\Store', - 'cron_schedule' => 'Magento\Cron', - 'customer_address_entity' => 'Magento\Customer', - 'customer_group' => 'Magento\Customer', - 'customer_eav_attribute' => 'Magento\Customer', - 'customer_eav_attribute_website' => 'Magento\Customer', - 'customer_entity' => 'Magento\Customer', - 'customer_form_attribute' => 'Magento\Customer', - 'customer_address_entity_datetime' => 'Magento\Customer', - 'customer_address_entity_decimal' => 'Magento\Customer', - 'customer_address_entity_int' => 'Magento\Customer', - 'customer_address_entity_text' => 'Magento\Customer', - 'customer_address_entity_varchar' => 'Magento\Customer', - 'customer_entity_datetime' => 'Magento\Customer', - 'customer_entity_decimal' => 'Magento\Customer', - 'customer_entity_int' => 'Magento\Customer', - 'customer_entity_text' => 'Magento\Customer', - 'customer_entity_varchar' => 'Magento\Customer', - 'customer_visitor' => 'Magento\Customer', - 'directory_country' => 'Magento\Directory', - 'directory_country_format' => 'Magento\Directory', - 'directory_country_name' => 'Magento\Directory', - 'directory_country_region' => 'Magento\Directory', - 'directory_country_region_name' => 'Magento\Directory', - 'directory_currency_rate' => 'Magento\Directory', - 'downloadable_link' => 'Magento\Downloadable', - 'downloadable_link_price' => 'Magento\Downloadable', - 'downloadable_link_purchased' => 'Magento\Downloadable', - 'downloadable_link_purchased_item' => 'Magento\Downloadable', - 'downloadable_link_title' => 'Magento\Downloadable', - 'catalog_product_index_price_downlod_idx' => 'Magento\Downloadable', - 'catalog_product_index_price_downlod_tmp' => 'Magento\Downloadable', - 'downloadable_sample' => 'Magento\Downloadable', - 'downloadable_sample_title' => 'Magento\Downloadable', - 'eav_attribute' => 'Magento\Eav', - 'eav_attribute_group' => 'Magento\Eav', - 'eav_attribute_label' => 'Magento\Eav', - 'eav_attribute_option' => 'Magento\Eav', - 'eav_attribute_option_value' => 'Magento\Eav', - 'eav_attribute_set' => 'Magento\Eav', - 'eav_entity' => 'Magento\Eav', - 'eav_entity_attribute' => 'Magento\Eav', - 'eav_entity_attribute_source_table' => 'Magento\Eav', - 'eav_entity_store' => 'Magento\Eav', - 'eav_entity_type' => 'Magento\Eav', - 'eav_form_element' => 'Magento\Eav', - 'eav_form_fieldset' => 'Magento\Eav', - 'eav_form_fieldset_label' => 'Magento\Eav', - 'eav_form_type' => 'Magento\Eav', - 'eav_form_type_entity' => 'Magento\Eav', - 'eav_entity_datetime' => 'Magento\Eav', - 'eav_entity_decimal' => 'Magento\Eav', - 'eav_entity_int' => 'Magento\Eav', - 'eav_entity_text' => 'Magento\Eav', - 'eav_entity_varchar' => 'Magento\Eav', - 'find_feed_import_codes' => 'Find\Feed', - 'gift_message' => 'Magento\GiftMessage', - 'googleoptimizer_code' => 'Magento\GoogleOptimizer', - 'importexport_importdata' => 'Magento\ImportExport', - 'integration' => 'Magento\Integration', - 'layout_link' => 'Magento\Widget', - 'layout_update' => 'Magento\Widget', - 'log_customer' => 'Magento\Log', - 'log_quote' => 'Magento\Log', - 'log_summary' => 'Magento\Log', - 'log_summary_type' => 'Magento\Log', - 'log_url_info' => 'Magento\Log', - 'log_url' => 'Magento\Log', - 'log_visitor' => 'Magento\Log', - 'log_visitor_info' => 'Magento\Log', - 'log_visitor_online' => 'Magento\Log', - 'newsletter_problem' => 'Magento\Newsletter', - 'newsletter_queue' => 'Magento\Newsletter', - 'newsletter_queue_link' => 'Magento\Newsletter', - 'newsletter_queue_store_link' => 'Magento\Newsletter', - 'newsletter_subscriber' => 'Magento\Newsletter', - 'newsletter_template' => 'Magento\Newsletter', - 'oauth_consumer' => 'Magento\Integration', - 'oauth_nonce' => 'Magento\Integration', - 'oauth_token' => 'Magento\Integration', - 'admin_passwords' => 'Magento\User', - 'paypal_cert' => 'Magento\Paypal', - 'paypal_payment_transaction' => 'Magento\Paypal', - 'paypal_settlement_report' => 'Magento\Paypal', - 'paypal_settlement_report_row' => 'Magento\Paypal', - 'persistent_session' => 'Magento\Persistent', - 'product_alert_price' => 'Magento\ProductAlert', - 'product_alert_stock' => 'Magento\ProductAlert', - 'rating' => 'Magento\Review', - 'rating_entity' => 'Magento\Review', - 'rating_option' => 'Magento\Review', - 'rating_option_vote' => 'Magento\Review', - 'rating_store' => 'Magento\Review', - 'rating_title' => 'Magento\Review', - 'rating_option_vote_aggregated' => 'Magento\Review', - 'report_compared_product_index' => 'Magento\Reports', - 'report_event' => 'Magento\Reports', - 'report_event_types' => 'Magento\Reports', - 'report_viewed_product_index' => 'Magento\Reports', - 'review' => 'Magento\Review', - 'review_entity_summary' => 'Magento\Review', - 'review_detail' => 'Magento\Review', - 'review_entity' => 'Magento\Review', - 'review_status' => 'Magento\Review', - 'review_store' => 'Magento\Review', - 'sales_bestsellers_aggregated_daily' => 'Magento\Sales', - 'sales_bestsellers_aggregated_monthly' => 'Magento\Sales', - 'sales_bestsellers_aggregated_yearly' => 'Magento\Sales', - 'paypal_billing_agreement' => 'Magento\Paypal', - 'paypal_billing_agreement_order' => 'Magento\Paypal', - 'sales_creditmemo' => 'Magento\Sales', - 'sales_creditmemo_comment' => 'Magento\Sales', - 'sales_creditmemo_grid' => 'Magento\Sales', - 'sales_creditmemo_item' => 'Magento\Sales', - 'sales_invoice' => 'Magento\Sales', - 'sales_invoice_comment' => 'Magento\Sales', - 'sales_invoice_grid' => 'Magento\Sales', - 'sales_invoice_item' => 'Magento\Sales', - 'sales_invoiced_aggregated' => 'Magento\Sales', - 'sales_invoiced_aggregated_order' => 'Magento\Sales', - 'sales_order' => 'Magento\Sales', - 'sales_order_address' => 'Magento\Sales', - 'sales_order_aggregated_created' => 'Magento\Sales', - 'sales_order_aggregated_updated' => 'Magento\Sales', - 'sales_order_grid' => 'Magento\Sales', - 'sales_order_item' => 'Magento\Sales', - 'sales_order_item_option' => 'Magento\Sales', - 'sales_order_payment' => 'Magento\Sales', - 'sales_order_status' => 'Magento\Sales', - 'sales_order_status_history' => 'Magento\Sales', - 'sales_order_status_label' => 'Magento\Sales', - 'sales_order_status_state' => 'Magento\Sales', - 'sales_order_tax' => 'Magento\Tax', - 'sales_payment_transaction' => 'Magento\Sales', - 'quote' => 'Magento\Quote', - 'quote_address' => 'Magento\Quote', - 'quote_address_item' => 'Magento\Quote', - 'quote_shipping_rate' => 'Magento\Quote', - 'quote_item' => 'Magento\Quote', - 'quote_item_option' => 'Magento\Quote', - 'quote_payment' => 'Magento\Quote', - 'sales_refunded_aggregated' => 'Magento\Sales', - 'sales_refunded_aggregated_order' => 'Magento\Sales', - 'sales_shipment' => 'Magento\Sales', - 'sales_shipment_comment' => 'Magento\Sales', - 'sales_shipment_grid' => 'Magento\Sales', - 'sales_shipment_item' => 'Magento\Sales', - 'sales_shipment_track' => 'Magento\Sales', - 'sales_shipping_aggregated' => 'Magento\Sales', - 'sales_shipping_aggregated_order' => 'Magento\Sales', - 'quote_entity' => 'Magento\Quote', - 'quote_temp' => 'Magento\Quote', - 'salesrule_coupon' => 'Magento\SalesRule', - 'coupon_aggregated' => 'Magento\SalesRule', - 'coupon_aggregated_order' => 'Magento\SalesRule', - 'coupon_aggregated_updated' => 'Magento\SalesRule', - 'salesrule_coupon_usage' => 'Magento\SalesRule', - 'salesrule_website' => 'Magento\SalesRule', - 'salesrule_label' => 'Magento\SalesRule', - 'salesrule_product_attribute' => 'Magento\SalesRule', - 'salesrule' => 'Magento\SalesRule', - 'salesrule_customer' => 'Magento\SalesRule', - 'salesrule_customer_group' => 'Magento\SalesRule', - 'sendfriend_log' => 'Magento\sendfriend', - 'shipping_tablerate' => 'Magento\shipping', - 'sitemap' => 'Magento\Sitemap', - 'social_facebook_actions' => 'Social\Facebook', - 'sales_order_tax_item' => 'Magento\Tax', - 'tax_calculation' => 'Magento\Tax', - 'tax_calculation_rate' => 'Magento\Tax', - 'tax_calculation_rate_title' => 'Magento\Tax', - 'tax_calculation_rule' => 'Magento\Tax', - 'tax_class' => 'Magento\Tax', - 'tax_order_aggregated_created' => 'Magento\Tax', - 'tax_order_aggregated_updated' => 'Magento\Tax', - 'translation' => 'Magento\Translation', - 'weee_tax' => 'Magento\Weee', - 'widget' => 'Magento\Widget', - 'widget_instance' => 'Magento\Widget', - 'widget_instance_page' => 'Magento\Widget', - 'widget_instance_page_layout' => 'Magento\Widget', - 'wishlist_item' => 'Magento\Wishlist', - 'wishlist_item_option' => 'Magento\Wishlist', - 'wishlist' => 'Magento\Wishlist', - 'admin_system_messages' => 'Magento\AdminNotification', - 'theme' => 'Magento\Theme', - 'theme_files' => 'Magento\Theme', - 'variable' => 'Magento\Variable', - 'variable_value' => 'Magento\Variable', - 'job_queue' => 'Magento\Queue', - 'catalogsearch_recommendations' => 'Magento\AdvancedSearch', -]; From e3ea27dfe78b6e7c7b5996ce668f008dc61926b2 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Wed, 15 Apr 2020 15:46:29 -0500 Subject: [PATCH 159/177] magento/magento2#27499: Code review fixes. --- .../MediaGallery/Model/Asset/Command/Save.php | 34 ++++++++++-------- .../Model/ResourceModel/SaveAssets.php | 35 +++++++++++-------- .../Magento/MediaGallery/etc/db_schema.xml | 3 ++ 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php index b445e9000313c..168fb479d3cdd 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php @@ -61,22 +61,26 @@ public function execute(AssetInterface $mediaAsset): int /** @var \Magento\Framework\DB\Adapter\Pdo\Mysql $connection */ $connection = $this->resourceConnection->getConnection(); $tableName = $this->resourceConnection->getTableName(self::TABLE_MEDIA_GALLERY_ASSET); + $record = [ + 'id' => $mediaAsset->getId(), + 'path' => $mediaAsset->getPath(), + 'title' => $mediaAsset->getTitle(), + 'source' => $mediaAsset->getSource(), + 'content_type' => $mediaAsset->getContentType(), + 'width' => $mediaAsset->getWidth(), + 'height' => $mediaAsset->getHeight(), + 'size' => $mediaAsset->getSize(), + ]; - $connection->insertOnDuplicate( - $tableName, - [ - 'id' => $mediaAsset->getId(), - 'path' => $mediaAsset->getPath(), - 'title' => $mediaAsset->getTitle(), - 'source' => $mediaAsset->getSource(), - 'content_type' => $mediaAsset->getContentType(), - 'width' => $mediaAsset->getWidth(), - 'height' => $mediaAsset->getHeight(), - 'size' => $mediaAsset->getSize(), - 'created_at' => $mediaAsset->getCreatedAt(), - 'updated_at' => $mediaAsset->getUpdatedAt(), - ] - ); + if ($mediaAsset->getCreatedAt()) { + $record['created_at'] = $mediaAsset->getCreatedAt(); + } + + if ($mediaAsset->getUpdatedAt()) { + $record['updated_at'] = $mediaAsset->getUpdatedAt(); + } + + $connection->insertOnDuplicate($tableName, $record); return (int)$connection->lastInsertId($tableName); } catch (\Exception $exception) { $this->logger->critical($exception); diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php b/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php index 33b5403fda497..ec08addf93462 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/SaveAssets.php @@ -56,21 +56,26 @@ public function execute(array $assets): void $failedAssets = []; foreach ($assets as $asset) { try { - $connection->insertOnDuplicate( - $tableName, - [ - 'id' => $asset->getId(), - 'path' => $asset->getPath(), - 'title' => $asset->getTitle(), - 'source' => $asset->getSource(), - 'content_type' => $asset->getContentType(), - 'width' => $asset->getWidth(), - 'height' => $asset->getHeight(), - 'size' => $asset->getSize(), - 'created_at' => $asset->getCreatedAt(), - 'updated_at' => $asset->getUpdatedAt(), - ] - ); + $record = [ + 'id' => $asset->getId(), + 'path' => $asset->getPath(), + 'title' => $asset->getTitle(), + 'source' => $asset->getSource(), + 'content_type' => $asset->getContentType(), + 'width' => $asset->getWidth(), + 'height' => $asset->getHeight(), + 'size' => $asset->getSize(), + ]; + + if ($asset->getCreatedAt()) { + $record['created_at'] = $asset->getCreatedAt(); + } + + if ($asset->getUpdatedAt()) { + $record['updated_at'] = $asset->getUpdatedAt(); + } + + $connection->insertOnDuplicate($tableName, $record); } catch (\Exception $exception) { $this->logger->critical($exception); $failedAssets[] = $asset; diff --git a/app/code/Magento/MediaGallery/etc/db_schema.xml b/app/code/Magento/MediaGallery/etc/db_schema.xml index 8bcad28de2a8e..13e619dd9e74a 100644 --- a/app/code/Magento/MediaGallery/etc/db_schema.xml +++ b/app/code/Magento/MediaGallery/etc/db_schema.xml @@ -26,6 +26,9 @@ <constraint xsi:type="unique" referenceId="MEDIA_GALLERY_ID_PATH_TITLE_CONTENT_TYPE_WIDTH_HEIGHT"> <column name="path"/> </constraint> + <index referenceId="MEDIA_GALLERY_ASSET_TITLE" indexType="fulltext"> + <column name="title"/> + </index> </table> <table name="media_gallery_keyword" resource="default" engine="innodb" comment="Media Gallery Keyword"> <column xsi:type="int" name="id" padding="10" unsigned="true" nullable="false" identity="true" comment="Keyword ID"/> From 90e2924b753cbd5489d48afc4c641c4449464a0b Mon Sep 17 00:00:00 2001 From: Alex Paliarush <paliarus@adobe.com> Date: Wed, 15 Apr 2020 17:06:26 -0500 Subject: [PATCH 160/177] ECP-530: Static test to detect external project dependencies --- .../TestFramework/Dependency/DbRuleTest.php | 4 ++-- .../TestFramework/Dependency/DiRuleTest.php | 16 +++++++------- .../Dependency/LayoutRuleTest.php | 22 +++++++++---------- .../TestFramework/Dependency/PhpRuleTest.php | 18 +++++++-------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/DbRuleTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/DbRuleTest.php index 986ddf72ec3d3..9a617ba9b8da2 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/DbRuleTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/DbRuleTest.php @@ -37,7 +37,7 @@ public function getDependencyInfoDataProvider() 'any', '/app/some/path/Setup/some-file.php', '$install->getTableName("unknown_table")', - [['module' => 'Unknown', 'source' => 'unknown_table']] + [['modules' => ['Unknown'], 'source' => 'unknown_table']] ], [ 'SomeModule', @@ -51,7 +51,7 @@ public function getDependencyInfoDataProvider() '$install->getTableName("some_table")', [ [ - 'module' => 'SomeModule', + 'modules' => ['SomeModule'], 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_HARD, 'source' => 'some_table', ] diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/DiRuleTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/DiRuleTest.php index 1f4c11f17e9e5..aa69b72ef6419 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/DiRuleTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/DiRuleTest.php @@ -48,32 +48,32 @@ public function getDependencyInfoDataProvider() $this->getFileContent('di_external_dependency.xml'), [ [ - 'module' => 'Magento\ExternalModule3', + 'modules' => ['Magento\ExternalModule3'], 'type' => RuleInterface::TYPE_SOFT, 'source' => 'Magento\ExternalModule3\Some\Another\Class' ], [ - 'module' => 'Magento\ExternalModule5', + 'modules' => ['Magento\ExternalModule5'], 'type' => RuleInterface::TYPE_SOFT, 'source' => 'Magento\ExternalModule5\Some\Another\Class' ], [ - 'module' => 'Magento\ExternalModule6', + 'modules' => ['Magento\ExternalModule6'], 'type' => RuleInterface::TYPE_SOFT, 'source' => 'Magento\ExternalModule6\Some\Plugin\Class' ], [ - 'module' => 'Magento\ExternalModule1', + 'modules' => ['Magento\ExternalModule1'], 'type' => RuleInterface::TYPE_HARD, 'source' => 'Magento\ExternalModule1\Some\Argument1' ], [ - 'module' => 'Magento\ExternalModule2', + 'modules' => ['Magento\ExternalModule2'], 'type' => RuleInterface::TYPE_HARD, 'source' => 'Magento\ExternalModule2\Some\Argument2' ], [ - 'module' => 'Magento\ExternalModule4', + 'modules' => ['Magento\ExternalModule4'], 'type' => RuleInterface::TYPE_HARD, 'source' => 'Magento\ExternalModule4\Some\Argument3' ] @@ -84,12 +84,12 @@ public function getDependencyInfoDataProvider() $this->getFileContent('di_virtual_dependency.xml'), [ [ - 'module' => 'Magento\AnotherModule', + 'modules' => ['Magento\AnotherModule'], 'type' => RuleInterface::TYPE_HARD, 'source' => 'Magento\AnotherModule\Some\Class1', ], [ - 'module' => 'Magento\AnotherModule', + 'modules' => ['Magento\AnotherModule'], 'type' => RuleInterface::TYPE_HARD, 'source' => 'Magento\AnotherModule\Some\Class2', ] diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/LayoutRuleTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/LayoutRuleTest.php index dd0e90eefe4f5..1ee2e8ca24791 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/LayoutRuleTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/LayoutRuleTest.php @@ -32,7 +32,7 @@ public function getDependencyInfoDataProvider() '<element module="Magento\AnotherModule"/>', [ [ - 'module' => 'Magento\AnotherModule', + 'modules' => ['Magento\AnotherModule'], 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_SOFT, 'source' => '<element module="Magento\AnotherModule"/>', ] @@ -43,7 +43,7 @@ public function getDependencyInfoDataProvider() '<block class="Magento\AnotherModule\Several\Chunks"/>', [ [ - 'module' => 'Magento\AnotherModule', + 'modules' => ['Magento\AnotherModule'], 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_HARD, 'source' => '<block class="Magento\AnotherModule\Several\Chunks"/>', ] @@ -56,7 +56,7 @@ public function getDependencyInfoDataProvider() </any>', [ [ - 'module' => 'Magento\AnotherModule', + 'modules' => ['Magento\AnotherModule'], 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_SOFT, 'source' => '<block template="Magento_AnotherModule::template/path.phtml"/>', ] @@ -67,7 +67,7 @@ public function getDependencyInfoDataProvider() '<block>Magento\AnotherModule\Several\Chunks</block>', [ [ - 'module' => 'Magento\AnotherModule', + 'modules' => ['Magento\AnotherModule'], 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_SOFT, 'source' => '<block>Magento\AnotherModule\Several\Chunks</block>', ] @@ -78,7 +78,7 @@ public function getDependencyInfoDataProvider() '<template>Magento_AnotherModule::template/path.phtml</template>', [ [ - 'module' => 'Magento\AnotherModule', + 'modules' => ['Magento\AnotherModule'], 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_SOFT, 'source' => '<template>Magento_AnotherModule::template/path.phtml</template>', ] @@ -89,7 +89,7 @@ public function getDependencyInfoDataProvider() '<file>Magento_AnotherModule::file/path.txt</file>', [ [ - 'module' => 'Magento\AnotherModule', + 'modules' => ['Magento\AnotherModule'], 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_SOFT, 'source' => '<file>Magento_AnotherModule::file/path.txt</file>', ] @@ -100,7 +100,7 @@ public function getDependencyInfoDataProvider() '<any helper="Magento\AnotherModule\Several\Chunks::text"/>', [ [ - 'module' => 'Magento\AnotherModule', + 'modules' => ['Magento\AnotherModule'], 'type' => \Magento\Test\Integrity\DependencyTest::TYPE_SOFT, 'source' => '<any helper="Magento\AnotherModule\Several\Chunks::text"/>', ] @@ -120,7 +120,7 @@ public function testUpdatesRouterGetDependencyInfo($contents, $type) $model = new LayoutRule(['router_name' => ['Magento\RouterModule']], [], []); $this->assertEquals([], $model->getDependencyInfo('Magento\RouterModule', 'layout', 'any', $contents)); $this->assertEquals( - [['module' => 'Magento\RouterModule', 'type' => $type, 'source' => 'router_name_action']], + [['modules' => ['Magento\RouterModule'], 'type' => $type, 'source' => 'router_name_action']], $model->getDependencyInfo('Magento\AnotherModule', 'layout', 'any', $contents) ); } @@ -148,11 +148,11 @@ public function testLayoutGetDependencyInfo($contents, $type, $isHandle) $model->getDependencyInfo('Magento\DefaultHandleModule', 'layout', 'any', $contents) ); $this->assertEquals( - [['module' => 'Magento\DefaultHandleModule', 'type' => $type, 'source' => 'singlechunk']], + [['modules' => ['Magento\DefaultHandleModule'], 'type' => $type, 'source' => 'singlechunk']], $model->getDependencyInfo('any', 'layout', 'any', $contents) ); $this->assertEquals( - [['module' => 'Magento\AnyHandleModule', 'type' => $type, 'source' => 'any_handle_name']], + [['modules' => ['Magento\AnyHandleModule'], 'type' => $type, 'source' => 'any_handle_name']], $model->getDependencyInfo('any', 'layout', 'path/frontend/file.txt', $contents) ); // test several modules @@ -166,7 +166,7 @@ public function testLayoutGetDependencyInfo($contents, $type, $isHandle) ]; $model = $isHandle ? new LayoutRule([], [], $data) : new LayoutRule([], $data, []); $this->assertEquals( - [['module' => 'Magento\Theme', 'type' => $type, 'source' => 'any_handle_name']], + [['modules' => ['Magento\Theme'], 'type' => $type, 'source' => 'any_handle_name']], $model->getDependencyInfo('any', 'layout', 'path/frontend/file.txt', $contents) ); $this->assertEquals( diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/PhpRuleTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/PhpRuleTest.php index a636aa81800d1..d1350d1b54db9 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/PhpRuleTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/Dependency/PhpRuleTest.php @@ -89,7 +89,7 @@ public function getDependencyInfoDataProvider() 'something extends \Magento\SomeModule\Any\ClassName {', [ [ - 'module' => 'Magento\SomeModule', + 'modules' => ['Magento\SomeModule'], 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_HARD, 'source' => 'Magento\SomeModule\Any\ClassName', ] @@ -105,7 +105,7 @@ public function getDependencyInfoDataProvider() '$this->getViewFileUrl("Magento_SomeModule::js/order-by-sku-failure.js")', [ [ - 'module' => 'Magento\SomeModule', + 'modules' => ['Magento\SomeModule'], 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_HARD, 'source' => 'Magento_SomeModule', ] @@ -121,7 +121,7 @@ public function getDependencyInfoDataProvider() '$this->helper("Magento\SomeModule\Any\ClassName")', [ [ - 'module' => 'Magento\SomeModule', + 'modules' => ['Magento\SomeModule'], 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_HARD, 'source' => 'Magento\SomeModule\Any\ClassName', ] @@ -136,7 +136,7 @@ public function getDependencyInfoDataProvider() '$this->getLayout()->getBlock(\'block.name\');', [ [ - 'module' => 'Magento\SomeModule', + 'modules' => ['Magento\SomeModule'], 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_HARD, 'source' => 'getBlock(\'block.name\')', ] @@ -157,7 +157,7 @@ public function getDependencyInfoDataProvider() 'Magento\Module2\Subject', [ [ - 'module' => 'Magento\Module2', + 'modules' => ['Magento\Module2'], 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_SOFT, 'source' => 'Magento\Module2\Subject', ] @@ -168,7 +168,7 @@ public function getDependencyInfoDataProvider() 'Magento\Module2\NotSubject', [ [ - 'module' => 'Magento\Module2', + 'modules' => ['Magento\Module2'], 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_SOFT, 'source' => 'Magento\Module2\NotSubject', ] @@ -179,7 +179,7 @@ public function getDependencyInfoDataProvider() 'Magento\OtherModule\NotSubject', [ [ - 'module' => 'Magento\OtherModule', + 'modules' => ['Magento\OtherModule'], 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_HARD, 'source' => 'Magento\OtherModule\NotSubject', ] @@ -222,7 +222,7 @@ public function getDependencyInfoDataCaseGetUrlDataProvider() '$this->getUrl("cms/index/index")', [ [ - 'module' => 'Magento\Cms', + 'modules' => ['Magento\Cms'], 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_HARD, 'source' => 'getUrl("cms/index/index"', ] @@ -295,7 +295,7 @@ public function getDefaultModelDependencyDataProvider() '$this->getLayout()->getBlock(\'block.name\');', [ [ - 'module' => 'Magento\SomeModule', + 'modules' => ['Magento\SomeModule'], 'type' => \Magento\TestFramework\Dependency\RuleInterface::TYPE_HARD, 'source' => 'getBlock(\'block.name\')', ] From 73fb878a6b6f976807d48052804dcae9a057984d Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets <vzaets@magento.com> Date: Wed, 15 Apr 2020 23:52:59 -0500 Subject: [PATCH 161/177] Changes according to review --- .../MediaContent/Model/AssignAssets.php | 73 ---------- .../{Config.php => SearchPatternConfig.php} | 5 +- .../MediaContent/Model/ContentAssetLink.php | 86 ++++-------- .../MediaContent/Model/ContentIdentity.php | 45 +++--- .../Model/DeleteContentAssetLinks.php | 64 +++++---- ... => DeleteContentAssetLinksByAssetIds.php} | 7 +- .../Model/ExtractAssetsFromContent.php | 14 +- ...t.php => GetAssetIdsByContentIdentity.php} | 4 +- ...ithAssets.php => GetContentByAssetIds.php} | 8 +- .../Model/SaveContentAssetLinks.php | 10 +- .../MediaContent/Model/UnassignAssets.php | 72 ---------- .../Model/UpdateContentAssetLinks.php | 131 ++++++++++++++++++ .../MediaContent/Model/UpdateRelations.php | 111 --------------- ...MediaGalleryAssetDeleteByDirectoryPath.php | 14 +- .../Plugin/MediaGalleryAssetDeleteByPath.php | 14 +- .../Magento/MediaContent/etc/db_schema.xml | 9 +- .../MediaContent/etc/db_schema_whitelist.json | 7 +- app/code/Magento/MediaContent/etc/di.xml | 12 +- .../Api/AssignAssetsInterface.php | 27 ---- .../Api/Data/ContentAssetLinkInterface.php | 24 +--- .../Api/Data/ContentIdentityInterface.php | 11 +- ...eContentAssetLinksByAssetIdsInterface.php} | 11 +- ...ractAssetsFromContentEntitiesInterface.php | 25 ++++ ...GetAssetIdsByContentIdentityInterface.php} | 2 +- ....php => GetContentByAssetIdsInterface.php} | 2 +- ...p => UpdateContentAssetLinksInterface.php} | 2 +- .../Model/SearchPatternConfigInterface.php} | 8 +- .../MediaContentCatalog/Observer/Category.php | 26 ++-- .../MediaContentCatalog/Observer/Product.php | 21 ++- .../MediaContentCms/Observer/Block.php | 26 ++-- .../Magento/MediaContentCms/Observer/Page.php | 26 ++-- .../Model/AssignGetUnassignTest.php | 67 +++++---- .../Model/UpdateRelationsTest.php | 12 +- 33 files changed, 408 insertions(+), 568 deletions(-) delete mode 100644 app/code/Magento/MediaContent/Model/AssignAssets.php rename app/code/Magento/MediaContent/Model/Content/{Config.php => SearchPatternConfig.php} (82%) rename app/code/Magento/MediaContent/Model/{RemoveRelationsForAssetIds.php => DeleteContentAssetLinksByAssetIds.php} (83%) rename app/code/Magento/MediaContent/Model/{GetAssetIdsUsedInContent.php => GetAssetIdsByContentIdentity.php} (93%) rename app/code/Magento/MediaContent/Model/{GetContentWithAssets.php => GetContentByAssetIds.php} (87%) delete mode 100644 app/code/Magento/MediaContent/Model/UnassignAssets.php create mode 100644 app/code/Magento/MediaContent/Model/UpdateContentAssetLinks.php delete mode 100644 app/code/Magento/MediaContent/Model/UpdateRelations.php delete mode 100644 app/code/Magento/MediaContentApi/Api/AssignAssetsInterface.php rename app/code/Magento/MediaContentApi/Api/{UnassignAssetsInterface.php => DeleteContentAssetLinksByAssetIdsInterface.php} (52%) create mode 100644 app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentEntitiesInterface.php rename app/code/Magento/MediaContentApi/Api/{GetAssetIdsUsedInContentInterface.php => GetAssetIdsByContentIdentityInterface.php} (93%) rename app/code/Magento/MediaContentApi/Api/{GetContentWithAssetsInterface.php => GetContentByAssetIdsInterface.php} (94%) rename app/code/Magento/MediaContentApi/Api/{UpdateRelationsInterface.php => UpdateContentAssetLinksInterface.php} (94%) rename app/code/Magento/{MediaContent/Model/Content/ConfigInterface.php => MediaContentApi/Model/SearchPatternConfigInterface.php} (54%) diff --git a/app/code/Magento/MediaContent/Model/AssignAssets.php b/app/code/Magento/MediaContent/Model/AssignAssets.php deleted file mode 100644 index bb26f2f66e3f7..0000000000000 --- a/app/code/Magento/MediaContent/Model/AssignAssets.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaContent\Model; - -use Magento\Framework\App\ResourceConnection; -use Magento\Framework\Exception\CouldNotSaveException; -use Magento\MediaContentApi\Api\AssignAssetsInterface; -use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; -use Psr\Log\LoggerInterface; - -/** - * Used for saving relation between the media asset and media content where the media asset is used - */ -class AssignAssets implements AssignAssetsInterface -{ - private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; - private const ASSET_ID = 'asset_id'; - private const ENTITY_TYPE = 'entity_type'; - private const ENTITY_ID = 'entity_id'; - private const FIELD = 'field'; - - /** - * @var ResourceConnection - */ - private $resourceConnection; - - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @param ResourceConnection $resourceConnection - * @param LoggerInterface $logger - */ - public function __construct(ResourceConnection $resourceConnection, LoggerInterface $logger) - { - $this->resourceConnection = $resourceConnection; - $this->logger = $logger; - } - - /** - * @inheritdoc - */ - public function execute(ContentIdentityInterface $contentIdentity, array $assetIds): void - { - try { - $connection = $this->resourceConnection->getConnection(); - $tableName = $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME); - $data = []; - foreach ($assetIds as $assetId) { - $data[] = [ - self::ASSET_ID => $assetId, - self::ENTITY_TYPE => $contentIdentity->getEntityType(), - self::ENTITY_ID => $contentIdentity->getEntityId(), - self::FIELD => $contentIdentity->getField() - ]; - } - $connection->insertMultiple($tableName, $data); - } catch (\Exception $exception) { - $this->logger->critical($exception); - throw new CouldNotSaveException( - __('An error occurred while saving relation between media asset and media content.'), - $exception - ); - } - } -} diff --git a/app/code/Magento/MediaContent/Model/Content/Config.php b/app/code/Magento/MediaContent/Model/Content/SearchPatternConfig.php similarity index 82% rename from app/code/Magento/MediaContent/Model/Content/Config.php rename to app/code/Magento/MediaContent/Model/Content/SearchPatternConfig.php index 63f1668954f76..32c667a3d6069 100644 --- a/app/code/Magento/MediaContent/Model/Content/Config.php +++ b/app/code/Magento/MediaContent/Model/Content/SearchPatternConfig.php @@ -8,11 +8,12 @@ namespace Magento\MediaContent\Model\Content; use Magento\Framework\Config\DataInterface; +use Magento\MediaContentApi\Model\SearchPatternConfigInterface; /** * Media content configuration */ -class Config implements ConfigInterface +class SearchPatternConfig implements SearchPatternConfigInterface { private const XML_PATH_SEARCH_PATTERNS = 'search/patterns'; @@ -34,7 +35,7 @@ public function __construct(DataInterface $data) * * @return array */ - public function getSearchPatterns(): array + public function get(): array { return $this->data->get(self::XML_PATH_SEARCH_PATTERNS); } diff --git a/app/code/Magento/MediaContent/Model/ContentAssetLink.php b/app/code/Magento/MediaContent/Model/ContentAssetLink.php index 8f7727565f3b3..5f0f2b0c01c8b 100644 --- a/app/code/Magento/MediaContent/Model/ContentAssetLink.php +++ b/app/code/Magento/MediaContent/Model/ContentAssetLink.php @@ -7,104 +7,68 @@ namespace Magento\MediaContent\Model; -use Magento\Framework\Model\AbstractExtensibleModel; -use Magento\Framework\Model\Context; -use Magento\Framework\Registry; -use Magento\Framework\Api\ExtensionAttributesFactory; -use Magento\Framework\Api\AttributeValueFactory; -use Magento\Framework\Model\ResourceModel\AbstractResource; use Magento\MediaContentApi\Api\Data\ContentAssetLinkInterface; -use Magento\Framework\Data\Collection\AbstractDb; -use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory; +use Magento\MediaContentApi\Api\Data\ContentAssetLinkExtensionInterface; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; /** * Relation of the media asset to the media content */ -class ContentAssetLink extends AbstractExtensibleModel implements ContentAssetLinkInterface +class ContentAssetLink implements ContentAssetLinkInterface { private const ASSET_ID = 'asset_id'; - private const ENTITY_TYPE = 'entity_type'; - private const ENTITY_ID = 'entity_id'; - private const FIELD = 'field'; + private const CONTENT_IDENTITY = 'content_identity'; /** - * @var ContentIdentityInterfaceFactory + * @var ContentAssetLinkExtensionInterface|null */ - private $contentIdentityFactory; + private $extensionAttributes; /** - * @param \Magento\Framework\Model\Context $context - * @param \Magento\Framework\Registry $registry - * @param ExtensionAttributesFactory $extensionFactory - * @param AttributeValueFactory $customAttributeFactory - * @param ContentIdentityInterfaceFactory $contentIdentityFactory - * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource - * @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection - * @param array $data + * @var ContentIdentityInterface */ - public function __construct( - Context $context, - Registry $registry, - ExtensionAttributesFactory $extensionFactory, - AttributeValueFactory $customAttributeFactory, - ContentIdentityInterfaceFactory $contentIdentityFactory, - AbstractResource $resource = null, - AbstractDb $resourceCollection = null, - array $data = [] - ) { - $this->contentIdentityFactory = $contentIdentityFactory; - parent::__construct( - $context, - $registry, - $extensionFactory, - $customAttributeFactory, - $resource, - $resourceCollection, - $data - ); - } + private $contentIdentity; /** - * @inheritdoc + * @var int */ - public function getAssetId(): int - { - return (int) $this->getData(self::ASSET_ID); - } + private $assetId; /** - * @inheritdoc + * @param ContentAssetLinkExtensionInterface|null $extensionAttributes */ - public function getContentId(): ContentIdentityInterface + public function __construct( + int $assetId, + ContentIdentityInterface $contentIdentity, + ?ContentAssetLinkExtensionInterface $extensionAttributes = null + ) { - return $this->contentIdentityFactory->create(['data' => [ - self::ENTITY_TYPE => $this->getData(self::ENTITY_TYPE), - self::ENTITY_ID => $this->getData(self::ENTITY_TYPE), - self::FIELD => $this->getData(self::FIELD) - ]]); + $this->assetId = $assetId; + $this->contentIdentity = $contentIdentity; + $this->extensionAttributes = $extensionAttributes; } /** * @inheritdoc */ - public function getField(): string + public function getAssetId(): int { - return (string) $this->getData(self::FIELD); + return $this->assetId; } /** * @inheritdoc */ - public function getExtensionAttributes(): ContentAssetLinkExtensionInterface + public function getContentId(): ContentIdentityInterface { - return $this->_getExtensionAttributes(); + return $this->contentIdentity; } /** * @inheritdoc */ - public function setExtensionAttributes(ContentAssetLinkExtensionInterface $extensionAttributes): void + public function getExtensionAttributes(): ?ContentAssetLinkExtensionInterface { - $this->_setExtensionAttributes($extensionAttributes); + return $this->extensionAttributes; } } diff --git a/app/code/Magento/MediaContent/Model/ContentIdentity.php b/app/code/Magento/MediaContent/Model/ContentIdentity.php index 9f1e5038f98a6..752db82703ff8 100644 --- a/app/code/Magento/MediaContent/Model/ContentIdentity.php +++ b/app/code/Magento/MediaContent/Model/ContentIdentity.php @@ -7,56 +7,67 @@ namespace Magento\MediaContent\Model; -use Magento\Framework\Model\AbstractExtensibleModel; use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; use Magento\MediaContentApi\Api\Data\ContentIdentityExtensionInterface; /** * @inheritdoc */ -class ContentIdentity extends AbstractExtensibleModel implements ContentIdentityInterface +class ContentIdentity implements ContentIdentityInterface { - private const ENTITY_TYPE = 'entity_type'; - private const ENTITY_ID = 'entity_id'; - private const FIELD = 'field'; + private $entityType; + private $entityId; + private $field; + private $extensionAttributes; /** - * @inheritdoc + * ContentIdentity constructor. + * @param string $entityType + * @param string $entityId + * @param string $field + * @param ContentIdentityExtensionInterface|null $extensionAttributes */ - public function getEntityType(): string - { - return (string) $this->getData(self::ENTITY_TYPE); + public function __construct( + string $entityType, + string $entityId, + string $field, + ?ContentIdentityExtensionInterface $extensionAttributes = null + ) { + $this->entityType = $entityType; + $this->entityId= $entityId; + $this->field = $field; + $this->extensionAttributes = $extensionAttributes; } /** * @inheritdoc */ - public function getEntityId(): string + public function getEntityType(): string { - return (string) $this->getData(self::ENTITY_ID); + return $this->entityType; } /** * @inheritdoc */ - public function getField(): string + public function getEntityId(): string { - return (string) $this->getData(self::FIELD); + return $this->entityId; } /** * @inheritdoc */ - public function getExtensionAttributes(): ContentIdentityExtensionInterface + public function getField(): string { - return $this->_getExtensionAttributes(); + return $this->field; } /** * @inheritdoc */ - public function setExtensionAttributes(ContentIdentityExtensionInterface $extensionAttributes): void + public function getExtensionAttributes(): ContentIdentityExtensionInterface { - $this->_setExtensionAttributes($extensionAttributes); + return $this->extensionAttributes; } } diff --git a/app/code/Magento/MediaContent/Model/DeleteContentAssetLinks.php b/app/code/Magento/MediaContent/Model/DeleteContentAssetLinks.php index 578d1c584e373..6abe9c6217106 100644 --- a/app/code/Magento/MediaContent/Model/DeleteContentAssetLinks.php +++ b/app/code/Magento/MediaContent/Model/DeleteContentAssetLinks.php @@ -14,7 +14,7 @@ use Psr\Log\LoggerInterface; /** - * Used to unassign relation of the media asset to the media content where the media asset is used + * Used to delete links of the media asset to the media content */ class DeleteContentAssetLinks implements DeleteContentAssetLinksInterface { @@ -47,41 +47,45 @@ public function __construct(ResourceConnection $resourceConnection, LoggerInterf /** * Remove relation between the media asset and the content. I.e media asset no longer part of the content * - * @param ContentAssetLinkInterface[] $contentAssetsLinks + * @param ContentAssetLinkInterface[] $contentAssetLinks * @throws CouldNotDeleteException */ - public function execute(array $contentAssetsLinks): void + public function execute(array $contentAssetLinks): void { - $failedLinks = []; - foreach ($contentAssetsLinks as $contentAssetLink) { - try { - $connection = $this->resourceConnection->getConnection(); - $tableName = $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME); - $connection->delete( - $tableName, - [ - self::ASSET_ID . ' = ?' => $contentAssetLink->getAssetId(), - self::ENTITY_TYPE . ' = ?' => $contentAssetLink->getContentId()->getEntityType(), - self::ENTITY_ID . ' = ?' => $contentAssetLink->getContentId()->getEntityId(), - self::FIELD . ' = ?' => $contentAssetLink->getField() - ] - ); - } catch (\Exception $exception) { - $this->logger->critical($exception); - $failedLinks[] = self::ASSET_ID . '=' . $contentAssetLink->getAssetId() . - self::ENTITY_TYPE . ' = ' . $contentAssetLink->getContentId()->getEntityType() . - self::ENTITY_ID . ' = ' . $contentAssetLink->getContentId()->getEntityId() . - self::FIELD . ' = ' . $contentAssetLink->getField(); - } + try { + $connection = $this->resourceConnection->getConnection(); + $tableName = $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME); + $whereSql = $this->buildWhereSqlPart($contentAssetLinks); + $connection->delete($tableName, $whereSql); + } catch (\Exception $exception) { + $this->logger->critical($exception); + throw new CouldNotDeleteException( + __('An error occurred at deleting links between the media asset and media content.') + ); } + } - if (!empty($failedLinks)) { - throw new CouldNotDeleteException( - __( - 'An error occurred at deleting link between the media asset and media content. Links: %links', - implode(' ,', $failedLinks) - ) + /** + * @param ContentAssetLinkInterface[] $contentAssetLinks + * @return string + */ + private function buildWhereSqlPart(array $contentAssetLinks): string + { + $connection = $this->resourceConnection->getConnection(); + $condition = []; + foreach ($contentAssetLinks as $contentAssetLink) { + $assetId = $connection->quoteInto(self::ASSET_ID . ' = ?', $contentAssetLink->getAssetId()); + $entityId = $connection->quoteInto( + self::ENTITY_ID . ' = ?', $contentAssetLink->getContentId()->getEntityId() + ); + $entityType = $connection->quoteInto( + self::ENTITY_TYPE . ' = ?', $contentAssetLink->getContentId()->getEntityType() + ); + $field = $connection->quoteInto( + self::FIELD . ' = ?', $contentAssetLink->getContentId()->getField() ); + $condition[] = '(' . $assetId . ' AND ' . $entityId . ' AND ' . $entityType . ' AND ' . $field . ')'; } + return implode(' OR ', $condition); } } diff --git a/app/code/Magento/MediaContent/Model/RemoveRelationsForAssetIds.php b/app/code/Magento/MediaContent/Model/DeleteContentAssetLinksByAssetIds.php similarity index 83% rename from app/code/Magento/MediaContent/Model/RemoveRelationsForAssetIds.php rename to app/code/Magento/MediaContent/Model/DeleteContentAssetLinksByAssetIds.php index c265d83f8f488..68495adb468d7 100644 --- a/app/code/Magento/MediaContent/Model/RemoveRelationsForAssetIds.php +++ b/app/code/Magento/MediaContent/Model/DeleteContentAssetLinksByAssetIds.php @@ -8,13 +8,14 @@ namespace Magento\MediaContent\Model; use Magento\Framework\App\ResourceConnection; +use Magento\MediaContentApi\Api\DeleteContentAssetLinksByAssetIdsInterface; use Magento\Framework\Exception\CouldNotDeleteException; use Psr\Log\LoggerInterface; /** - * Used for saving relation between the media asset and media content where the media asset is used + * Delete the relation between media asset and the piece of content. I.e media asset no longer part of the content */ -class RemoveRelationsForAssetIds +class DeleteContentAssetLinksByAssetIds implements DeleteContentAssetLinksByAssetIdsInterface { private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; private const ASSET_ID = 'asset_id'; @@ -40,7 +41,7 @@ public function __construct(ResourceConnection $resourceConnection, LoggerInterf } /** - * Remove media content relations for media asset ids + * Delete media content relations by media asset ids * * @param array $assetIds * @throws CouldNotDeleteException diff --git a/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php b/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php index 1a71c50291c93..97d9b1ad65c22 100644 --- a/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php +++ b/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php @@ -7,7 +7,7 @@ namespace Magento\MediaContent\Model; -use Magento\MediaContent\Model\Content\Config; +use Magento\MediaContentApi\Model\SearchPatternConfigInterface; use Magento\MediaContentApi\Api\ExtractAssetsFromContentInterface; use Magento\MediaGalleryApi\Api\Data\AssetInterface; use Magento\MediaGalleryApi\Model\Asset\Command\GetByPathInterface; @@ -19,9 +19,9 @@ class ExtractAssetsFromContent implements ExtractAssetsFromContentInterface { /** - * @var Config + * @var SearchPatternConfigInterface */ - private $config; + private $searchPatternConfig; /** * @var GetByPathInterface @@ -34,16 +34,16 @@ class ExtractAssetsFromContent implements ExtractAssetsFromContentInterface private $logger; /** - * @param Config $config + * @param SearchPatternConfigInterface $searchPatternConfig * @param GetByPathInterface $getMediaAssetByPath * @param LoggerInterface $logger */ public function __construct( - Config $config, + SearchPatternConfigInterface $searchPatternConfig, GetByPathInterface $getMediaAssetByPath, LoggerInterface $logger ) { - $this->config = $config; + $this->searchPatternConfig = $searchPatternConfig; $this->getMediaAssetByPath = $getMediaAssetByPath; $this->logger = $logger; } @@ -55,7 +55,7 @@ public function execute(string $content): array { $paths = []; - foreach ($this->config->getSearchPatterns() as $pattern) { + foreach ($this->searchPatternConfig->get() as $pattern) { if (empty($pattern)) { continue; } diff --git a/app/code/Magento/MediaContent/Model/GetAssetIdsUsedInContent.php b/app/code/Magento/MediaContent/Model/GetAssetIdsByContentIdentity.php similarity index 93% rename from app/code/Magento/MediaContent/Model/GetAssetIdsUsedInContent.php rename to app/code/Magento/MediaContent/Model/GetAssetIdsByContentIdentity.php index d33c8e6d2eb90..55f357d4ff1b2 100644 --- a/app/code/Magento/MediaContent/Model/GetAssetIdsUsedInContent.php +++ b/app/code/Magento/MediaContent/Model/GetAssetIdsByContentIdentity.php @@ -10,13 +10,13 @@ use Magento\Framework\App\ResourceConnection; use Magento\Framework\Exception\IntegrationException; use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; -use Magento\MediaContentApi\Api\GetAssetIdsUsedInContentInterface; +use Magento\MediaContentApi\Api\GetAssetIdsByContentIdentityInterface; use Psr\Log\LoggerInterface; /** * Used to return media asset id list which is used in the specified media content */ -class GetAssetIdsUsedInContent implements GetAssetIdsUsedInContentInterface +class GetAssetIdsByContentIdentity implements GetAssetIdsByContentIdentityInterface { private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; private const ASSET_ID = 'asset_id'; diff --git a/app/code/Magento/MediaContent/Model/GetContentWithAssets.php b/app/code/Magento/MediaContent/Model/GetContentByAssetIds.php similarity index 87% rename from app/code/Magento/MediaContent/Model/GetContentWithAssets.php rename to app/code/Magento/MediaContent/Model/GetContentByAssetIds.php index 12cba0d141fc8..e5a428b7ccae5 100644 --- a/app/code/Magento/MediaContent/Model/GetContentWithAssets.php +++ b/app/code/Magento/MediaContent/Model/GetContentByAssetIds.php @@ -10,13 +10,13 @@ use Magento\Framework\App\ResourceConnection; use Magento\Framework\Exception\IntegrationException; use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory; -use Magento\MediaContentApi\Api\GetContentWithAssetsInterface; +use Magento\MediaContentApi\Api\GetContentByAssetIdsInterface; use Psr\Log\LoggerInterface; /** * Used to return media asset list for the specified asset. */ -class GetContentWithAssets implements GetContentWithAssetsInterface +class GetContentByAssetIds implements GetContentByAssetIdsInterface { private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; private const ASSET_ID = 'asset_id'; @@ -65,13 +65,13 @@ public function execute(array $assetIds): array ->distinct() ->from( $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME), - [self::ENTITY_TYPE, self::ENTITY_ID, self::FIELD] + ['entityType' => self::ENTITY_TYPE, 'entityId' => self::ENTITY_ID, self::FIELD] ) ->where(self::ASSET_ID . ' IN (?)', $assetIds); $contentIdentities = []; foreach ($connection->fetchAssoc($select) as $contentIdentityData) { - $contentIdentities[] = $this->factory->create(['data' => $contentIdentityData]); + $contentIdentities[] = $this->factory->create($contentIdentityData); } return $contentIdentities; } catch (\Exception $exception) { diff --git a/app/code/Magento/MediaContent/Model/SaveContentAssetLinks.php b/app/code/Magento/MediaContent/Model/SaveContentAssetLinks.php index 6c6140ba2b076..9c5c8879b00c5 100644 --- a/app/code/Magento/MediaContent/Model/SaveContentAssetLinks.php +++ b/app/code/Magento/MediaContent/Model/SaveContentAssetLinks.php @@ -46,27 +46,25 @@ public function __construct(ResourceConnection $resourceConnection, LoggerInterf } /** - * Save a media asset to content relation. Should be executed when media assets is added to the content + * Save a media asset to content link. * * @param ContentAssetLinkInterface[] $contentAssetLinks * @throws \Magento\Framework\Exception\CouldNotSaveException */ - public function execute(array $contentAssetsLinks): void + public function execute(array $contentAssetLinks): void { try { $connection = $this->resourceConnection->getConnection(); $tableName = $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME); $data = []; - - foreach ($contentAssetsLinks as $contentAssetLink) { + foreach ($contentAssetLinks as $contentAssetLink) { $data[] = [ self::ASSET_ID => $contentAssetLink->getAssetId(), self::ENTITY_TYPE => $contentAssetLink->getContentId()->getEntityType(), self::ENTITY_ID => $contentAssetLink->getContentId()->getEntityId(), - self::FIELD => $contentAssetLink->getField() + self::FIELD => $contentAssetLink->getContentId()->getField() ]; } - $connection->insertMultiple($tableName, $data); } catch (\Exception $exception) { $this->logger->critical($exception); diff --git a/app/code/Magento/MediaContent/Model/UnassignAssets.php b/app/code/Magento/MediaContent/Model/UnassignAssets.php deleted file mode 100644 index d553b2d0a7258..0000000000000 --- a/app/code/Magento/MediaContent/Model/UnassignAssets.php +++ /dev/null @@ -1,72 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaContent\Model; - -use Magento\Framework\App\ResourceConnection; -use Magento\Framework\Exception\CouldNotDeleteException; -use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; -use Magento\MediaContentApi\Api\UnassignAssetsInterface; -use Psr\Log\LoggerInterface; - -/** - * Used to unassign relation of the media asset to the media content where the media asset is used - */ -class UnassignAssets implements UnassignAssetsInterface -{ - private const MEDIA_CONTENT_ASSET_TABLE_NAME = 'media_content_asset'; - private const ASSET_ID = 'asset_id'; - private const ENTITY_TYPE = 'entity_type'; - private const ENTITY_ID = 'entity_id'; - private const FIELD = 'field'; - - /** - * @var ResourceConnection - */ - private $resourceConnection; - - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @param ResourceConnection $resourceConnection - * @param LoggerInterface $logger - */ - public function __construct(ResourceConnection $resourceConnection, LoggerInterface $logger) - { - $this->resourceConnection = $resourceConnection; - $this->logger = $logger; - } - - /** - * @inheritdoc - */ - public function execute(ContentIdentityInterface $contentIdentity, array $assetIds): void - { - try { - $connection = $this->resourceConnection->getConnection(); - $tableName = $this->resourceConnection->getTableName(self::MEDIA_CONTENT_ASSET_TABLE_NAME); - $connection->delete( - $tableName, - [ - self::ASSET_ID . ' IN (?)' => $assetIds, - self::ENTITY_TYPE . ' = ?' => $contentIdentity->getEntityType(), - self::ENTITY_ID . ' = ?' => $contentIdentity->getEntityId(), - self::FIELD . ' = ?' => $contentIdentity->getField() - ] - ); - } catch (\Exception $exception) { - $this->logger->critical($exception); - throw new CouldNotDeleteException( - __('An error occurred at unassign relation between the media asset and media content.'), - $exception - ); - } - } -} diff --git a/app/code/Magento/MediaContent/Model/UpdateContentAssetLinks.php b/app/code/Magento/MediaContent/Model/UpdateContentAssetLinks.php new file mode 100644 index 0000000000000..d71978d3ca092 --- /dev/null +++ b/app/code/Magento/MediaContent/Model/UpdateContentAssetLinks.php @@ -0,0 +1,131 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContent\Model; + +use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\IntegrationException; +use Magento\MediaContentApi\Api\SaveContentAssetLinksInterface; +use Magento\MediaContentApi\Api\DeleteContentAssetLinksInterface; +use Magento\MediaContentApi\Api\Data\ContentAssetLinkInterfaceFactory; +use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; +use Magento\MediaContentApi\Api\ExtractAssetsFromContentInterface; +use Magento\MediaContentApi\Api\GetAssetIdsByContentIdentityInterface; +use Magento\MediaContentApi\Api\UpdateContentAssetLinksInterface; +use Magento\MediaGalleryApi\Api\Data\AssetInterface; +use Psr\Log\LoggerInterface; + +/** + * Process relation managing between media asset and content: create or delete link if exists. + */ +class UpdateContentAssetLinks implements UpdateContentAssetLinksInterface +{ + private const ASSET_ID = 'assetId'; + private const CONTENT_IDENTITY = 'contentIdentity'; + + /** + * @var ExtractAssetsFromContentInterface + */ + private $extractAssetFromContent; + + /** + * @var SaveContentAssetLinksInterface + */ + private $saveContentAssetLinks; + + /** + * @var DeleteContentAssetLinksInterface + */ + private $deleteContentAssetLinks; + + /** + * @var ContentAssetLinkInterfaceFactory + */ + private $contentAssetLinkFactory; + + /** + * @var GetAssetIdsByContentIdentityInterface + */ + private $getAssetIdsByContentIdentity; + + /** + * @var LoggerInterface + */ + private $logger; + + /** + * @param ExtractAssetsFromContentInterface $extractAssetFromContent + * @param SaveContentAssetLinksInterface $saveContentAssetLinks + * @param DeleteContentAssetLinksInterface $deleteContentAssetLinks + * @param ContentAssetLinkInterfaceFactory $contentAssetLinkFactory + * @param GetAssetIdsByContentIdentityInterface $getAssetIdsByContentIdentity + * @param LoggerInterface $logger + */ + public function __construct( + ExtractAssetsFromContentInterface $extractAssetFromContent, + SaveContentAssetLinksInterface $saveContentAssetLinks, + DeleteContentAssetLinksInterface $deleteContentAssetLinks, + ContentAssetLinkInterfaceFactory $contentAssetLinkFactory, + GetAssetIdsByContentIdentityInterface $getAssetIdsByContentIdentity, + LoggerInterface $logger + ) { + $this->extractAssetFromContent = $extractAssetFromContent; + $this->saveContentAssetLinks = $saveContentAssetLinks; + $this->deleteContentAssetLinks = $deleteContentAssetLinks; + $this->contentAssetLinkFactory = $contentAssetLinkFactory; + $this->getAssetIdsByContentIdentity = $getAssetIdsByContentIdentity; + $this->logger = $logger; + } + + /** + * @inheritdoc + */ + public function execute(ContentIdentityInterface $contentIdentity, string $data): void + { + try { + $this->updateRelation($contentIdentity, $data); + } catch (\Exception $exception) { + $this->logger->critical($exception); + } + } + + /** + * Find out which relations are obsolete and which are new and update them + * + * @param ContentIdentityInterface $contentIdentity + * @param string $data + * @throws CouldNotDeleteException + * @throws CouldNotSaveException + * @throws IntegrationException + */ + private function updateRelation(ContentIdentityInterface $contentIdentity, string $data) + { + $existingAssetIds = $this->getAssetIdsByContentIdentity->execute($contentIdentity); + $currentAssets = $this->extractAssetFromContent->execute($data); + /** @var AssetInterface $asset */ + foreach ($currentAssets as $asset) { + if (!in_array($asset->getId(), $existingAssetIds)) { + $contentAssetLink = $this->contentAssetLinkFactory->create([ + self::ASSET_ID => $asset->getId(), + self::CONTENT_IDENTITY => $contentIdentity + ]); + $this->saveContentAssetLinks->execute([$contentAssetLink]); + } + } + + foreach ($existingAssetIds as $assetId) { + if (!isset($currentAssets[$assetId])) { + $contentAssetLink = $this->contentAssetLinkFactory->create([ + self::ASSET_ID => $assetId, + self::CONTENT_IDENTITY => $contentIdentity + ]); + $this->deleteContentAssetLinks->execute([$contentAssetLink]); + } + } + } +} diff --git a/app/code/Magento/MediaContent/Model/UpdateRelations.php b/app/code/Magento/MediaContent/Model/UpdateRelations.php deleted file mode 100644 index d878f10e47e42..0000000000000 --- a/app/code/Magento/MediaContent/Model/UpdateRelations.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaContent\Model; - -use Magento\Framework\Exception\CouldNotDeleteException; -use Magento\Framework\Exception\CouldNotSaveException; -use Magento\Framework\Exception\IntegrationException; -use Magento\MediaContentApi\Api\AssignAssetsInterface; -use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; -use Magento\MediaContentApi\Api\ExtractAssetsFromContentInterface; -use Magento\MediaContentApi\Api\GetAssetIdsUsedInContentInterface; -use Magento\MediaContentApi\Api\UnassignAssetsInterface; -use Magento\MediaContentApi\Api\UpdateRelationsInterface; -use Magento\MediaGalleryApi\Api\Data\AssetInterface; -use Psr\Log\LoggerInterface; - -/** - * Process relation managing between media asset and content: assign or unassign relation if exists. - */ -class UpdateRelations implements UpdateRelationsInterface -{ - /** - * @var ExtractAssetsFromContentInterface - */ - private $extractAssetFromContent; - - /** - * @var AssignAssetsInterface - */ - private $assignAsset; - - /** - * @var GetAssetIdsUsedInContentInterface - */ - private $getAssetsUsedInContent; - - /** - * @var UnassignAssetsInterface - */ - private $unassignAsset; - - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @param ExtractAssetsFromContentInterface $extractAssetFromContent - * @param AssignAssetsInterface $assignAsset - * @param GetAssetIdsUsedInContentInterface $getAssetsUsedInContent - * @param UnassignAssetsInterface $unassignAsset - * @param LoggerInterface $logger - */ - public function __construct( - ExtractAssetsFromContentInterface $extractAssetFromContent, - AssignAssetsInterface $assignAsset, - GetAssetIdsUsedInContentInterface $getAssetsUsedInContent, - UnassignAssetsInterface $unassignAsset, - LoggerInterface $logger - ) { - $this->extractAssetFromContent = $extractAssetFromContent; - $this->assignAsset = $assignAsset; - $this->getAssetsUsedInContent = $getAssetsUsedInContent; - $this->unassignAsset = $unassignAsset; - $this->logger = $logger; - } - - /** - * @inheritdoc - */ - public function execute(ContentIdentityInterface $contentIdentity, string $data): void - { - try { - $this->updateRelation($contentIdentity, $data); - } catch (\Exception $exception) { - $this->logger->critical($exception); - } - } - - /** - * Find out which relations are obsolete and which are new and update them - * - * @param ContentIdentityInterface $contentIdentity - * @param string $data - * @throws CouldNotDeleteException - * @throws CouldNotSaveException - * @throws IntegrationException - */ - private function updateRelation(ContentIdentityInterface $contentIdentity, string $data) - { - $existingAssetIds = $this->getAssetsUsedInContent->execute($contentIdentity); - $currentAssets = $this->extractAssetFromContent->execute($data); - /** @var AssetInterface $asset */ - foreach ($currentAssets as $asset) { - if (!in_array($asset->getId(), $existingAssetIds)) { - $this->assignAsset->execute($contentIdentity, [$asset->getId()]); - } - } - - foreach ($existingAssetIds as $assetId) { - if (!isset($currentAssets[$assetId])) { - $this->unassignAsset->execute($contentIdentity, [$assetId]); - } - } - } -} diff --git a/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php index 3401fade27c06..180ededa66ce5 100644 --- a/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php +++ b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php @@ -10,7 +10,7 @@ use Magento\Framework\App\ResourceConnection; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\Exception\CouldNotDeleteException; -use Magento\MediaContent\Model\RemoveRelationsForAssetIds; +use Magento\MediaContentApi\Api\DeleteContentAssetLinksByAssetIdsInterface; use Magento\MediaGalleryApi\Model\Asset\Command\DeleteByDirectoryPathInterface; use Psr\Log\LoggerInterface; @@ -32,21 +32,21 @@ class MediaGalleryAssetDeleteByDirectoryPath private $logger; /** - * @var RemoveRelationsForAssetIds + * @var DeleteContentAssetLinksByAssetIdsInterface */ - private $removeRelationsForAssetIds; + private $deleteContentAssetLinksByAssetIds; /** - * @param RemoveRelationsForAssetIds $removeRelationsForAssetIds + * @param DeleteContentAssetLinksByAssetIdsInterface $deleteContentAssetLinksByAssetIds * @param ResourceConnection $resourceConnection * @param LoggerInterface $logger */ public function __construct( - RemoveRelationsForAssetIds $removeRelationsForAssetIds, + DeleteContentAssetLinksByAssetIdsInterface $deleteContentAssetLinksByAssetIds, ResourceConnection $resourceConnection, LoggerInterface $logger ) { - $this->removeRelationsForAssetIds = $removeRelationsForAssetIds; + $this->deleteContentAssetLinksByAssetIds = $deleteContentAssetLinksByAssetIds; $this->resourceConnection = $resourceConnection; $this->logger = $logger; } @@ -69,7 +69,7 @@ public function aroundExecute( $proceed($directoryPath); - $this->removeRelationsForAssetIds->execute($assetIds); + $this->deleteContentAssetLinksByAssetIds->execute($assetIds); } /** diff --git a/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php index c088e9928f9b9..e19d24eda783d 100644 --- a/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php +++ b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php @@ -8,7 +8,7 @@ namespace Magento\MediaContent\Plugin; use Magento\Framework\Exception\CouldNotDeleteException; -use Magento\MediaContent\Model\RemoveRelationsForAssetIds; +use Magento\MediaContentApi\Api\DeleteContentAssetLinksByAssetIdsInterface; use Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface; use Magento\MediaGalleryApi\Model\Asset\Command\GetByPathInterface; use Psr\Log\LoggerInterface; @@ -29,21 +29,21 @@ class MediaGalleryAssetDeleteByPath private $logger; /** - * @var RemoveRelationsForAssetIds + * @var DeleteContentAssetLinksByAssetIdsInterface */ - private $removeRelationsForAssetIds; + private $deleteContentAssetLinksByAssetIds; /** - * @param RemoveRelationsForAssetIds $removeRelationsForAssetIds + * @param DeleteContentAssetLinksByAssetIdsInterface $deleteContentAssetLinksByAssetIds * @param GetByPathInterface $getByPath * @param LoggerInterface $logger */ public function __construct( - RemoveRelationsForAssetIds $removeRelationsForAssetIds, + DeleteContentAssetLinksByAssetIdsInterface $deleteContentAssetLinksByAssetIds, GetByPathInterface $getByPath, LoggerInterface $logger ) { - $this->removeRelationsForAssetIds = $removeRelationsForAssetIds; + $this->deleteContentAssetLinksByAssetIds = $deleteContentAssetLinksByAssetIds; $this->getByPath = $getByPath; $this->logger = $logger; } @@ -66,6 +66,6 @@ public function aroundExecute( $proceed($mediaAssetPath); - $this->removeRelationsForAssetIds->execute([$asset->getId()]); + $this->deleteContentAssetLinksByAssetIds->execute([$asset->getId()]); } } diff --git a/app/code/Magento/MediaContent/etc/db_schema.xml b/app/code/Magento/MediaContent/etc/db_schema.xml index 18700f09fd802..2e4ed19201c9c 100644 --- a/app/code/Magento/MediaContent/etc/db_schema.xml +++ b/app/code/Magento/MediaContent/etc/db_schema.xml @@ -7,15 +7,18 @@ --> <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> <table name="media_content_asset" resource="default" engine="innodb" comment="Relation between media content and media asset"> - <column xsi:type="int" padding="10" name="asset_id" unsigned="true" nullable="false" identity="true" comment="Entity ID"/> + <column xsi:type="int" padding="10" name="asset_id" unsigned="true" nullable="false" comment="Entity ID"/> <column xsi:type="varchar" length="255" name="entity_type" nullable="false" comment="Content type"/> <column xsi:type="varchar" length="255" name="entity_id" nullable="false" comment="Content entity id"/> <column xsi:type="varchar" length="255" name="field" nullable="false" comment="Content field"/> <constraint xsi:type="primary" referenceId="PRIMARY"> - <column name="asset_id"/> <column name="entity_type"/> - <column name="field"/> <column name="entity_id"/> + <column name="field"/> + <column name="asset_id"/> </constraint> + <index referenceId="MEDIA_CONTENT_ASSET_ID" indexType="btree"> + <column name="asset_id"/> + </index> </table> </schema> diff --git a/app/code/Magento/MediaContent/etc/db_schema_whitelist.json b/app/code/Magento/MediaContent/etc/db_schema_whitelist.json index a9e141117c72e..5ff8dc52591cc 100644 --- a/app/code/Magento/MediaContent/etc/db_schema_whitelist.json +++ b/app/code/Magento/MediaContent/etc/db_schema_whitelist.json @@ -1,10 +1,13 @@ { "media_content_asset": { "column": { - "asset_id": true, "entity_type": true, "entity_id": true, - "field": true + "field": true, + "asset_id": true + }, + "index": { + "MEDIA_CONTENT_ASSET_ID": true }, "constraint": { "PRIMARY": true diff --git a/app/code/Magento/MediaContent/etc/di.xml b/app/code/Magento/MediaContent/etc/di.xml index 778cbec07989e..dc151fb7a377d 100644 --- a/app/code/Magento/MediaContent/etc/di.xml +++ b/app/code/Magento/MediaContent/etc/di.xml @@ -6,16 +6,16 @@ */ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> - <preference for="Magento\MediaContentApi\Api\AssignAssetsInterface" type="Magento\MediaContent\Model\AssignAssets"/> - <preference for="Magento\MediaContentApi\Api\UnassignAssetsInterface" type="Magento\MediaContent\Model\UnassignAssets"/> - <preference for="Magento\MediaContentApi\Api\GetAssetIdsUsedInContentInterface" type="Magento\MediaContent\Model\GetAssetIdsUsedInContent"/> - <preference for="Magento\MediaContentApi\Api\GetContentWithAssetsInterface" type="Magento\MediaContent\Model\GetContentWithAssets"/> + <preference for="Magento\MediaContentApi\Api\DeleteContentAssetLinksByAssetIdsInterface" type="Magento\MediaContent\Model\DeleteContentAssetLinksByAssetIds"/> + <preference for="Magento\MediaContentApi\Api\GetAssetIdsByContentIdentityInterface" type="Magento\MediaContent\Model\GetAssetIdsByContentIdentity"/> + <preference for="Magento\MediaContentApi\Api\GetContentByAssetIdsInterface" type="Magento\MediaContent\Model\GetContentByAssetIds"/> <preference for="Magento\MediaContentApi\Api\ExtractAssetsFromContentInterface" type="Magento\MediaContent\Model\ExtractAssetsFromContent"/> - <preference for="Magento\MediaContentApi\Api\UpdateRelationsInterface" type="Magento\MediaContent\Model\UpdateRelations"/> + <preference for="Magento\MediaContentApi\Api\UpdateContentAssetLinksInterface" type="Magento\MediaContent\Model\UpdateContentAssetLinks"/> <preference for="Magento\MediaContentApi\Api\DeleteContentAssetLinksInterface" type="Magento\MediaContent\Model\DeleteContentAssetLinks"/> <preference for="Magento\MediaContentApi\Api\SaveContentAssetLinksInterface" type="Magento\MediaContent\Model\SaveContentAssetLinks"/> <preference for="Magento\MediaContentApi\Api\Data\ContentIdentityInterface" type="Magento\MediaContent\Model\ContentIdentity"/> <preference for="Magento\MediaContentApi\Api\Data\ContentAssetLinkInterface" type="Magento\MediaContent\Model\ContentAssetLink"/> + <preference for="Magento\MediaContentApi\Model\SearchPatternConfigInterface" type="Magento\MediaContent\Model\Content\SearchPatternConfig"/> <preference for="Magento\MediaContent\Model\Content\ConfigInterface" type="Magento\MediaContent\Model\Content\Config"/> <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface"> <plugin name="remove_media_content_after_asset_is_removed_by_path" type="Magento\MediaContent\Model\MediaGalleryAssetDeleteByPath" /> @@ -39,7 +39,7 @@ <argument name="cacheId" xsi:type="string">Media_Content_Patterns_CacheId</argument> </arguments> </virtualType> - <type name="Magento\MediaContent\Model\Content\Config"> + <type name="Magento\MediaContent\Model\Content\SearchPatternConfig"> <arguments> <argument name="data" xsi:type="object">Magento\MediaContent\Model\Content\Config\Data</argument> </arguments> diff --git a/app/code/Magento/MediaContentApi/Api/AssignAssetsInterface.php b/app/code/Magento/MediaContentApi/Api/AssignAssetsInterface.php deleted file mode 100644 index 6a7ba1abbff6e..0000000000000 --- a/app/code/Magento/MediaContentApi/Api/AssignAssetsInterface.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ - -declare(strict_types=1); - -namespace Magento\MediaContentApi\Api; - -use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; - -/** - * Assign a media asset to the piece of content. Should be executed when media assets is added to the content - * @api - */ -interface AssignAssetsInterface -{ - /** - * Assign a media asset to the piece of content. Should be executed when media assets is added to the content - * - * @param ContentIdentityInterface $contentIdentity - * @param int[] $assetIds - * @throws \Magento\Framework\Exception\CouldNotSaveException - */ - public function execute(ContentIdentityInterface $contentIdentity, array $assetIds): void; -} diff --git a/app/code/Magento/MediaContentApi/Api/Data/ContentAssetLinkInterface.php b/app/code/Magento/MediaContentApi/Api/Data/ContentAssetLinkInterface.php index c3869e151f78c..0c94032e8bcfb 100644 --- a/app/code/Magento/MediaContentApi/Api/Data/ContentAssetLinkInterface.php +++ b/app/code/Magento/MediaContentApi/Api/Data/ContentAssetLinkInterface.php @@ -8,45 +8,33 @@ namespace Magento\MediaContentApi\Api\Data; +use Magento\Framework\Api\ExtensibleDataInterface; use Magento\MediaContentApi\Api\Data\ContentAssetLinkExtensionInterface; /** * Data interface representing the identificator of content. I.e. short description field of product entity with id 42 * @api */ -interface ContentAssetLinkInterface +interface ContentAssetLinkInterface extends ExtensibleDataInterface { /** - * Id of the entity containing content with media + * Return the object that represent content identity * - * @return int + * @return ContentIdentityInterface */ public function getContentId(): ContentIdentityInterface; /** * Array of assets related to the content entity * - * @return array + * @return int */ public function getAssetId(): int; - /** - * @return string - */ - public function getField() : string; - /** * Retrieve existing extension attributes object or create a new one. * * @return \Magento\MediaContentApi\Api\Data\ContentAssetLinkExtensionInterface|null */ - public function getExtensionAttributes(): ContentAssetLinkExtensionInterface; - - /** - * Set extension attributes - * - * @param \Magento\MediaContentApi\Api\Data\ContentAssetLinkExtensionInterface $extensionAttributes - * @return void - */ - public function setExtensionAttributes(ContentAssetLinkExtensionInterface $extensionAttributes): void; + public function getExtensionAttributes(): ?ContentAssetLinkExtensionInterface; } diff --git a/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php b/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php index e775b3ebf5dca..f4c18e4ba0704 100644 --- a/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php +++ b/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php @@ -8,13 +8,14 @@ namespace Magento\MediaContentApi\Api\Data; +use Magento\Framework\Api\ExtensibleDataInterface; use Magento\MediaContentApi\Api\Data\ContentIdentityExtensionInterface; /** * Data interface representing the identificator of content. I.e. short description field of product entity with id 42 * @api */ -interface ContentIdentityInterface +interface ContentIdentityInterface extends ExtensibleDataInterface { /** * Type of entity that can have a content with media. I.e. catalog_product or cms_page @@ -43,12 +44,4 @@ public function getField(): string; * @return \Magento\MediaContentApi\Api\Data\ContentIdentityExtensionInterface|null */ public function getExtensionAttributes(): ContentIdentityExtensionInterface; - - /** - * Set extension attributes - * - * @param \Magento\MediaContentApi\Api\Data\ContentIdentityExtensionInterface $extensionAttributes - * @return void - */ - public function setExtensionAttributes(ContentIdentityExtensionInterface $extensionAttributes): void; } diff --git a/app/code/Magento/MediaContentApi/Api/UnassignAssetsInterface.php b/app/code/Magento/MediaContentApi/Api/DeleteContentAssetLinksByAssetIdsInterface.php similarity index 52% rename from app/code/Magento/MediaContentApi/Api/UnassignAssetsInterface.php rename to app/code/Magento/MediaContentApi/Api/DeleteContentAssetLinksByAssetIdsInterface.php index 462d1c188a168..8997e4b6e7e77 100644 --- a/app/code/Magento/MediaContentApi/Api/UnassignAssetsInterface.php +++ b/app/code/Magento/MediaContentApi/Api/DeleteContentAssetLinksByAssetIdsInterface.php @@ -8,20 +8,19 @@ namespace Magento\MediaContentApi\Api; -use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; +use Magento\MediaContentApi\Api\Data\ContentAssetLinkInterface; /** - * Remove the relation between media asset and the piece of content. I.e media asset no longer part of the content + * Delete the relation between media asset and the piece of content. I.e media asset no longer part of the content * @api */ -interface UnassignAssetsInterface +interface DeleteContentAssetLinksByAssetIdsInterface { /** - * Remove relation between the media asset and the content. I.e media asset no longer part of the content + * Delete relation between the media asset and the content. I.e media asset no longer part of the content * * @param int[] $assetIds - * @param ContentIdentityInterface $contentIdentity * @throws \Magento\Framework\Exception\CouldNotDeleteException */ - public function execute(ContentIdentityInterface $contentIdentity, array $assetIds): void; + public function execute(array $assetIds): void; } diff --git a/app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentEntitiesInterface.php b/app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentEntitiesInterface.php new file mode 100644 index 0000000000000..398992603c63b --- /dev/null +++ b/app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentEntitiesInterface.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\MediaContentApi\Api; + +use Magento\MediaGalleryApi\Api\Data\AssetInterface; + +/** + * Parse the content string for references to media assets and return the list of identified media assets + * @api + */ +interface ExtractAssetsFromContentEntitiesInterface +{ + /** + * Parse the content string for references to media assets and return the list of identified media assets + * + * @param string[] $contentEntities + * @return AssetInterface[] + */ + public function execute(array $contentEntities): array; +} diff --git a/app/code/Magento/MediaContentApi/Api/GetAssetIdsUsedInContentInterface.php b/app/code/Magento/MediaContentApi/Api/GetAssetIdsByContentIdentityInterface.php similarity index 93% rename from app/code/Magento/MediaContentApi/Api/GetAssetIdsUsedInContentInterface.php rename to app/code/Magento/MediaContentApi/Api/GetAssetIdsByContentIdentityInterface.php index 91faa6b7646fc..4316a0d6ee33d 100644 --- a/app/code/Magento/MediaContentApi/Api/GetAssetIdsUsedInContentInterface.php +++ b/app/code/Magento/MediaContentApi/Api/GetAssetIdsByContentIdentityInterface.php @@ -14,7 +14,7 @@ * Get media asset ids that are used in the piece of content identified by the specified content identity * @api */ -interface GetAssetIdsUsedInContentInterface +interface GetAssetIdsByContentIdentityInterface { /** * Get media asset ids that are used in the piece of content identified by the specified content identity diff --git a/app/code/Magento/MediaContentApi/Api/GetContentWithAssetsInterface.php b/app/code/Magento/MediaContentApi/Api/GetContentByAssetIdsInterface.php similarity index 94% rename from app/code/Magento/MediaContentApi/Api/GetContentWithAssetsInterface.php rename to app/code/Magento/MediaContentApi/Api/GetContentByAssetIdsInterface.php index ec940829ce6fc..cb117545c257e 100644 --- a/app/code/Magento/MediaContentApi/Api/GetContentWithAssetsInterface.php +++ b/app/code/Magento/MediaContentApi/Api/GetContentByAssetIdsInterface.php @@ -14,7 +14,7 @@ * Get list of content identifiers for pieces of content that include the specified media asset * @api */ -interface GetContentWithAssetsInterface +interface GetContentByAssetIdsInterface { /** * Get list of content identifiers for pieces of content that include the specified media asset diff --git a/app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php b/app/code/Magento/MediaContentApi/Api/UpdateContentAssetLinksInterface.php similarity index 94% rename from app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php rename to app/code/Magento/MediaContentApi/Api/UpdateContentAssetLinksInterface.php index d9ccdb5759e6b..c552e8bb2149b 100644 --- a/app/code/Magento/MediaContentApi/Api/UpdateRelationsInterface.php +++ b/app/code/Magento/MediaContentApi/Api/UpdateContentAssetLinksInterface.php @@ -12,7 +12,7 @@ /** * Update the media assets to content relations. Assign new media assets and unassign media assets no longer used */ -interface UpdateRelationsInterface +interface UpdateContentAssetLinksInterface { /** * Update the media assets to content relations. Assign new media assets and unassign media assets no longer used diff --git a/app/code/Magento/MediaContent/Model/Content/ConfigInterface.php b/app/code/Magento/MediaContentApi/Model/SearchPatternConfigInterface.php similarity index 54% rename from app/code/Magento/MediaContent/Model/Content/ConfigInterface.php rename to app/code/Magento/MediaContentApi/Model/SearchPatternConfigInterface.php index cd3265626784c..c6715615ffe39 100644 --- a/app/code/Magento/MediaContent/Model/Content/ConfigInterface.php +++ b/app/code/Magento/MediaContentApi/Model/SearchPatternConfigInterface.php @@ -4,17 +4,17 @@ * See COPYING.txt for license details. */ -namespace Magento\MediaContent\Model\Content; +namespace Magento\MediaContentApi\Model; /** * Interface for Media content Config. */ -interface ConfigInterface +interface SearchPatternConfigInterface { /** - * Retrieve search regexp patterns for finding media asset paths within content + * Retrieve search RegExp patterns for finding media asset paths within content * * @return array */ - public function getSearchPatterns() : array; + public function get(): array; } diff --git a/app/code/Magento/MediaContentCatalog/Observer/Category.php b/app/code/Magento/MediaContentCatalog/Observer/Category.php index e1a262b5193c6..21767e0199ae6 100644 --- a/app/code/Magento/MediaContentCatalog/Observer/Category.php +++ b/app/code/Magento/MediaContentCatalog/Observer/Category.php @@ -10,7 +10,7 @@ use Magento\Catalog\Model\Category as CatalogCategory; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; -use Magento\MediaContentApi\Api\UpdateRelationsInterface; +use Magento\MediaContentApi\Api\UpdateContentAssetLinksInterface; use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory; /** @@ -19,14 +19,14 @@ class Category implements ObserverInterface { private const CONTENT_TYPE = 'catalog_category'; - private const TYPE = 'entity_type'; - private const ENTITY_ID = 'entity_id'; + private const TYPE = 'entityType'; + private const ENTITY_ID = 'entityId'; private const FIELD = 'field'; /** - * @var UpdateRelationsInterface + * @var UpdateContentAssetLinksInterface */ - private $processor; + private $updateContentAssetLinks; /** * @var array @@ -40,16 +40,16 @@ class Category implements ObserverInterface /** * @param ContentIdentityInterfaceFactory $contentIdentityFactory - * @param UpdateRelationsInterface $processor + * @param UpdateContentAssetLinksInterface $updateContentAssetLinks * @param array $fields */ public function __construct( ContentIdentityInterfaceFactory $contentIdentityFactory, - UpdateRelationsInterface $processor, + UpdateContentAssetLinksInterface $updateContentAssetLinks, array $fields ) { $this->contentIdentityFactory = $contentIdentityFactory; - $this->processor = $processor; + $this->updateContentAssetLinks = $updateContentAssetLinks; $this->fields = $fields; } @@ -67,14 +67,12 @@ public function execute(Observer $observer): void if (!$model->dataHasChangedFor($field)) { continue; } - $this->processor->execute( + $this->updateContentAssetLinks->execute( $this->contentIdentityFactory->create( [ - 'data' => [ - self::TYPE => self::CONTENT_TYPE, - self::FIELD => $field, - self::ENTITY_ID => (string) $model->getId(), - ] + self::TYPE => self::CONTENT_TYPE, + self::FIELD => $field, + self::ENTITY_ID => (string) $model->getId(), ] ), (string) $model->getData($field) diff --git a/app/code/Magento/MediaContentCatalog/Observer/Product.php b/app/code/Magento/MediaContentCatalog/Observer/Product.php index d250a02498da5..e69cc8486f62f 100644 --- a/app/code/Magento/MediaContentCatalog/Observer/Product.php +++ b/app/code/Magento/MediaContentCatalog/Observer/Product.php @@ -10,7 +10,7 @@ use Magento\Catalog\Model\Product as CatalogProduct; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; -use Magento\MediaContentApi\Api\UpdateRelationsInterface; +use Magento\MediaContentApi\Api\UpdateContentAssetLinksInterface; use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory; /** @@ -19,12 +19,12 @@ class Product implements ObserverInterface { private const CONTENT_TYPE = 'catalog_product'; - private const TYPE = 'entity_type'; - private const ENTITY_ID = 'entity_id'; + private const TYPE = 'entityType'; + private const ENTITY_ID = 'entityId'; private const FIELD = 'field'; /** - * @var UpdateRelationsInterface + * @var UpdateContentAssetLinksInterface */ private $processor; @@ -40,12 +40,12 @@ class Product implements ObserverInterface /** * @param ContentIdentityInterfaceFactory $contentIdentityFactory - * @param UpdateRelationsInterface $processor + * @param UpdateContentAssetLinksInterface $processor * @param array $fields */ public function __construct( ContentIdentityInterfaceFactory $contentIdentityFactory, - UpdateRelationsInterface $processor, + UpdateContentAssetLinksInterface $processor, array $fields ) { $this->contentIdentityFactory = $contentIdentityFactory; @@ -67,14 +67,13 @@ public function execute(Observer $observer): void if (!$model->dataHasChangedFor($field)) { continue; } + $this->processor->execute( $this->contentIdentityFactory->create( [ - 'data' => [ - self::TYPE => self::CONTENT_TYPE, - self::FIELD => $field, - self::ENTITY_ID => (string) $model->getId(), - ] + self::TYPE => self::CONTENT_TYPE, + self::FIELD => $field, + self::ENTITY_ID => (string) $model->getId(), ] ), (string) $model->getData($field) diff --git a/app/code/Magento/MediaContentCms/Observer/Block.php b/app/code/Magento/MediaContentCms/Observer/Block.php index 17bf5bd88acac..5ccda6670de44 100644 --- a/app/code/Magento/MediaContentCms/Observer/Block.php +++ b/app/code/Magento/MediaContentCms/Observer/Block.php @@ -10,7 +10,7 @@ use Magento\Cms\Block\Block as CmsBlock; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; -use Magento\MediaContentApi\Api\UpdateRelationsInterface; +use Magento\MediaContentApi\Api\UpdateContentAssetLinksInterface; use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory; /** @@ -19,14 +19,14 @@ class Block implements ObserverInterface { private const CONTENT_TYPE = 'cms_block'; - private const TYPE = 'entity_type'; - private const ENTITY_ID = 'entity_id'; + private const TYPE = 'entityType'; + private const ENTITY_ID = 'entityId'; private const FIELD = 'field'; /** - * @var UpdateRelationsInterface + * @var UpdateContentAssetLinksInterface */ - private $processor; + private $updateContentAssetLinks; /** * @var array @@ -40,16 +40,16 @@ class Block implements ObserverInterface /** * @param ContentIdentityInterfaceFactory $contentIdentityFactory - * @param UpdateRelationsInterface $processor + * @param UpdateContentAssetLinksInterface $updateContentAssetLinks * @param array $fields */ public function __construct( ContentIdentityInterfaceFactory $contentIdentityFactory, - UpdateRelationsInterface $processor, + UpdateContentAssetLinksInterface $updateContentAssetLinks, array $fields ) { $this->contentIdentityFactory = $contentIdentityFactory; - $this->processor = $processor; + $this->updateContentAssetLinks = $updateContentAssetLinks; $this->fields = $fields; } @@ -67,14 +67,12 @@ public function execute(Observer $observer): void if (!$model->dataHasChangedFor($field)) { continue; } - $this->processor->execute( + $this->updateContentAssetLinks->execute( $this->contentIdentityFactory->create( [ - 'data' => [ - self::TYPE => self::CONTENT_TYPE, - self::FIELD => $field, - self::ENTITY_ID => (string) $model->getId(), - ] + self::TYPE => self::CONTENT_TYPE, + self::FIELD => $field, + self::ENTITY_ID => (string) $model->getId(), ] ), (string) $model->getData($field) diff --git a/app/code/Magento/MediaContentCms/Observer/Page.php b/app/code/Magento/MediaContentCms/Observer/Page.php index 727efe3dc2ef0..4c0ed5c628d1c 100644 --- a/app/code/Magento/MediaContentCms/Observer/Page.php +++ b/app/code/Magento/MediaContentCms/Observer/Page.php @@ -10,7 +10,7 @@ use Magento\Cms\Model\Page as CmsPage; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; -use Magento\MediaContentApi\Api\UpdateRelationsInterface; +use Magento\MediaContentApi\Api\UpdateContentAssetLinksInterface; use Magento\MediaContentApi\Api\Data\ContentIdentityInterfaceFactory; /** @@ -19,14 +19,14 @@ class Page implements ObserverInterface { private const CONTENT_TYPE = 'cms_page'; - private const TYPE = 'entity_type'; - private const ENTITY_ID = 'entity_id'; + private const TYPE = 'entityType'; + private const ENTITY_ID = 'entityId'; private const FIELD = 'field'; /** - * @var UpdateRelationsInterface + * @var UpdateContentAssetLinksInterface */ - private $processor; + private $updateContentAssetLinks; /** * @var array @@ -40,16 +40,16 @@ class Page implements ObserverInterface /** * @param ContentIdentityInterfaceFactory $contentIdentityFactory - * @param UpdateRelationsInterface $processor + * @param UpdateContentAssetLinksInterface $updateContentAssetLinks * @param array $fields */ public function __construct( ContentIdentityInterfaceFactory $contentIdentityFactory, - UpdateRelationsInterface $processor, + UpdateContentAssetLinksInterface $updateContentAssetLinks, array $fields ) { $this->contentIdentityFactory = $contentIdentityFactory; - $this->processor = $processor; + $this->updateContentAssetLinks = $updateContentAssetLinks; $this->fields = $fields; } @@ -67,14 +67,12 @@ public function execute(Observer $observer): void if (!$model->dataHasChangedFor($field)) { continue; } - $this->processor->execute( + $this->updateContentAssetLinks->execute( $this->contentIdentityFactory->create( [ - 'data' => [ - self::TYPE => self::CONTENT_TYPE, - self::FIELD => $field, - self::ENTITY_ID => (string) $model->getId(), - ] + self::TYPE => self::CONTENT_TYPE, + self::FIELD => $field, + self::ENTITY_ID => (string) $model->getId(), ] ), (string) $model->getData($field) diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php index a0fd632b843ed..c2daccf167c4d 100644 --- a/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php @@ -8,11 +8,12 @@ namespace Magento\MediaContent\Model; -use Magento\MediaContentApi\Api\AssignAssetsInterface; +use Magento\MediaContentApi\Api\SaveContentAssetLinksInterface; use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; -use Magento\MediaContentApi\Api\GetAssetIdsUsedInContentInterface; -use Magento\MediaContentApi\Api\GetContentWithAssetsInterface; -use Magento\MediaContentApi\Api\UnassignAssetsInterface; +use Magento\MediaContentApi\Api\Data\ContentAssetLinkInterface; +use Magento\MediaContentApi\Api\GetAssetIdsByContentIdentityInterface; +use Magento\MediaContentApi\Api\GetContentByAssetIdsInterface; +use Magento\MediaContentApi\Api\DeleteContentAssetLinksInterface; use Magento\TestFramework\Helper\Bootstrap; use PHPUnit\Framework\TestCase; @@ -22,34 +23,35 @@ class AssignGetUnassignTest extends TestCase { /** - * @var AssignAssetsInterface + * @var SaveContentAssetLinksInterface */ - private $assign; + private $saveContentAssetLinks; /** - * @var GetAssetIdsUsedInContentInterface + * @var GetAssetIdsByContentIdentityInterface */ - private $getAssetIds; + private $getAssetIdsByContentIdentity; /** - * @var GetContentWithAssetsInterface + * @var GetContentByAssetIdsInterface */ - private $getContent; + private $getContentByAssetIds; /** - * @var UnassignAssetsInterface + * @var DeleteContentAssetLinksInterface */ - private $unassign; + private $deleteContentAssetLinks; /** * @inheritdoc */ public function setUp(): void { - $this->assign = Bootstrap::getObjectManager()->get(AssignAssetsInterface::class); - $this->getAssetIds = Bootstrap::getObjectManager()->get(GetAssetIdsUsedInContentInterface::class); - $this->getContent = Bootstrap::getObjectManager()->get(GetContentWithAssetsInterface::class); - $this->unassign = Bootstrap::getObjectManager()->get(UnassignAssetsInterface::class); + $this->saveContentAssetLinks = Bootstrap::getObjectManager()->get(SaveContentAssetLinksInterface::class); + $this->getAssetIdsByContentIdentity = Bootstrap::getObjectManager() + ->get(GetAssetIdsByContentIdentityInterface::class); + $this->getContentByAssetIds = Bootstrap::getObjectManager()->get(GetContentByAssetIdsInterface::class); + $this->deleteContentAssetLinks = Bootstrap::getObjectManager()->get(DeleteContentAssetLinksInterface::class); } /** @@ -65,21 +67,28 @@ public function testAssignRetrieveAndUnassign(): void $contentIdentity = Bootstrap::getObjectManager()->create( ContentIdentityInterface::class, [ - 'data' => [ - 'entity_type' => $entityType, - 'entity_id' => $entityId, - 'field' => $field - ] + 'entityType' => $entityType, + 'entityId' => $entityId, + 'field' => $field ] ); - $this->assign->execute($contentIdentity, $assetIds); - - $retrievedAssetIds = $this->getAssetIds->execute($contentIdentity); - $this->assertEquals($assetIds, $retrievedAssetIds); + $contentAssetLinks = []; - $retrievedContentIdentities = $this->getContent->execute($assetIds); + foreach ($assetIds as $assetId) { + $contentAssetLinks[] = Bootstrap::getObjectManager()->create( + ContentAssetLinkInterface::class, + [ + 'assetId' => $assetId, + 'contentIdentity' => $contentIdentity + ] + ); + } + $this->saveContentAssetLinks->execute($contentAssetLinks); + $retrievedAssetIds = $this->getAssetIdsByContentIdentity->execute($contentIdentity); + $this->assertEquals($assetIds, $retrievedAssetIds); + $retrievedContentIdentities = $this->getContentByAssetIds->execute($assetIds); $this->assertEquals(count($retrievedContentIdentities), 1); foreach ($retrievedContentIdentities as $identity) { @@ -88,9 +97,9 @@ public function testAssignRetrieveAndUnassign(): void $this->assertEquals($field, $identity->getField()); } - $this->unassign->execute($contentIdentity, $assetIds); + $this->deleteContentAssetLinks->execute($contentAssetLinks); - $this->assertEmpty($this->getContent->execute($assetIds)); - $this->assertEmpty($this->getAssetIds->execute($contentIdentity)); + $this->assertEmpty($this->getContentByAssetIds->execute($assetIds)); + $this->assertEmpty($this->getAssetIdsByContentIdentity->execute($contentIdentity)); } } diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php index 1364747036848..c2c6d66737b4b 100644 --- a/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php @@ -9,8 +9,8 @@ namespace Magento\MediaContent\Model; use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; -use Magento\MediaContentApi\Api\GetAssetIdsUsedInContentInterface; -use Magento\MediaContentApi\Api\UpdateRelationsInterface; +use Magento\MediaContentApi\Api\GetAssetIdsByContentIdentityInterface; +use Magento\MediaContentApi\Api\UpdateContentAssetLinksInterface; use Magento\TestFramework\Helper\Bootstrap; use PHPUnit\Framework\TestCase; @@ -20,12 +20,12 @@ class UpdateRelationsTest extends TestCase { /** - * @var UpdateRelationsInterface + * @var UpdateContentAssetLinksInterface */ private $service; /** - * @var GetAssetIdsUsedInContentInterface + * @var GetAssetIdsByContentIdentityInterface */ private $getAssetIds; @@ -34,8 +34,8 @@ class UpdateRelationsTest extends TestCase */ public function setUp(): void { - $this->service = Bootstrap::getObjectManager()->get(UpdateRelationsInterface::class); - $this->getAssetIds = Bootstrap::getObjectManager()->get(GetAssetIdsUsedInContentInterface::class); + $this->service = Bootstrap::getObjectManager()->get(UpdateContentAssetLinksInterface::class); + $this->getAssetIds = Bootstrap::getObjectManager()->get(GetAssetIdsByContentIdentityInterface::class); } /** From 54467d43a6e4254b8ee65cbc28a4548eaedb91d0 Mon Sep 17 00:00:00 2001 From: Slava Mankivski <mankivsk@adobe.com> Date: Thu, 16 Apr 2020 12:30:02 -0500 Subject: [PATCH 162/177] ENGCOM-7452: Revert https://github.com/magento/magento2/pull/23234 --- app/code/Magento/Ui/view/base/web/js/modal/alert.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/modal/alert.js b/app/code/Magento/Ui/view/base/web/js/modal/alert.js index f36fe54a37a9e..0c7042952bc18 100644 --- a/app/code/Magento/Ui/view/base/web/js/modal/alert.js +++ b/app/code/Magento/Ui/view/base/web/js/modal/alert.js @@ -39,18 +39,11 @@ define([ }] }, - /** - * Create widget. - */ - _create: function () { - this.options.actions.always(); - this._super(); - }, - /** * Close modal window. */ closeModal: function () { + this.options.actions.always(); this.element.bind('alertclosed', _.bind(this._remove, this)); return this._super(); From 024300a40743a953f459dcc9eab3b2aedd7c77e5 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Thu, 16 Apr 2020 13:01:16 -0500 Subject: [PATCH 163/177] Updated MediaGallery modules and marked as API --- app/code/Magento/MediaGalleryCatalog/etc/di.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/MediaGalleryCatalog/etc/di.xml b/app/code/Magento/MediaGalleryCatalog/etc/di.xml index 8145134025990..bdfdf2c5ef959 100644 --- a/app/code/Magento/MediaGalleryCatalog/etc/di.xml +++ b/app/code/Magento/MediaGalleryCatalog/etc/di.xml @@ -7,6 +7,6 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Catalog\Model\Product\Gallery\Processor"> - <plugin name="media_gallery_image_remove_metadata" type="Magento\MediaGallery\Plugin\Product\Gallery\RemoveAssetAfterRemoveImage"/> + <plugin name="media_gallery_image_remove_metadata" type="Magento\MediaGalleryCatalog\Plugin\Product\Gallery\RemoveAssetAfterRemoveImage"/> </type> </config> From 01ac38b82ec697e136a80f70e2f5c744c464b1f6 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Thu, 16 Apr 2020 13:43:49 -0500 Subject: [PATCH 164/177] Updated MediaGallery modules and marked as API --- .../MediaGallery/Model/Directory/Command/CreateByPaths.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php index 52459d42086e4..aed624bce5d21 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php @@ -48,9 +48,11 @@ public function execute(array $paths): void foreach ($paths as $path) { try { $name = basename($path); + $folder = str_replace($name, '', $path); + $this->storage->createDirectory( $name, - $this->storage->getCmsWysiwygImages()->getStorageRoot() . $path + $this->storage->getCmsWysiwygImages()->getStorageRoot() . $folder ); } catch (\Exception $exception) { $this->logger->critical($exception); From 1c7fd0ab9bf9aacd074fd8fa56b5993860bee2fe Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Thu, 16 Apr 2020 15:15:52 -0500 Subject: [PATCH 165/177] Eliminate AbstractExtensibleModel usage --- app/code/Magento/MediaGallery/Model/Asset.php | 144 +++++++++++++----- .../Model/Asset/Command/DeleteByPath.php | 3 +- .../Model/Asset/Command/GetById.php | 15 +- .../Model/Asset/Command/GetByPath.php | 20 ++- .../MediaGallery/Model/Asset/Command/Save.php | 6 +- .../MediaGallery/Model/AssetKeywords.php | 46 ++++-- .../Model/Directory/Command/CreateByPaths.php | 2 + .../Model/Directory/IsBlacklisted.php | 2 +- .../Magento/MediaGallery/Model/Keyword.php | 52 +++++-- .../Keyword/Command/GetAssetKeywords.php | 7 +- .../Keyword/Command/SaveAssetKeywords.php | 4 +- .../Model/ResourceModel/GetAssetsByIds.php | 15 +- .../Model/ResourceModel/GetAssetsByPaths.php | 15 +- .../Keyword/GetAssetsKeywords.php | 10 +- .../Unit/Model/Asset/Command/SaveTest.php | 34 +++-- .../Model/Directory/IsBlacklistedTest.php | 4 +- .../MediaGallery/etc/db_schema_whitelist.json | 3 +- .../Api/Data/AssetInterface.php | 14 +- .../Api/Data/AssetKeywordsInterface.php | 7 +- .../Api/Data/KeywordInterface.php | 6 +- .../Magento/MediaGalleryCatalog/composer.json | 2 +- .../MediaGallery/Model/AssetEndToEndTest.php | 23 +-- .../MediaGallery/Model/IsBlacklistedTest.php | 2 +- .../Model/ResourceModel/AssetKeywordsTest.php | 12 +- .../Model/ResourceModel/AssetsTest.php | 9 +- .../MediaGallery/_files/media_asset.php | 8 +- .../_files/media_asset_rollback.php | 1 - 27 files changed, 324 insertions(+), 142 deletions(-) diff --git a/app/code/Magento/MediaGallery/Model/Asset.php b/app/code/Magento/MediaGallery/Model/Asset.php index 8e232ff0336d9..ff6ba8e372024 100644 --- a/app/code/Magento/MediaGallery/Model/Asset.php +++ b/app/code/Magento/MediaGallery/Model/Asset.php @@ -10,36 +10,112 @@ use Magento\MediaGalleryApi\Api\Data\AssetExtensionInterface; use Magento\MediaGalleryApi\Api\Data\AssetInterface; -use Magento\Framework\Model\AbstractExtensibleModel; /** * Media Gallery Asset */ -class Asset extends AbstractExtensibleModel implements AssetInterface +class Asset implements AssetInterface { - private const ID = 'id'; - private const PATH = 'path'; - private const TITLE = 'title'; - private const SOURCE = 'source'; - private const CONTENT_TYPE = 'content_type'; - private const WIDTH = 'width'; - private const HEIGHT = 'height'; - private const SIZE = 'size'; - private const CREATED_AT = 'created_at'; - private const UPDATED_AT = 'updated_at'; + /** + * @var int|null + */ + private $id; + + /** + * @var string + */ + private $path; + + /** + * @var string|null + */ + private $title; + + /** + * @var string|null + */ + private $source; + + /** + * @var string + */ + private $contentType; + + /** + * @var int + */ + private $width; + + /** + * @var int + */ + private $height; + + /** + * @var int + */ + private $size; + + /** + * @var string|null + */ + private $createdAt; + + /** + * @var string|null + */ + private $updatedAt; + + /** + * @var AssetExtensionInterface|null + */ + private $extensionAttributes; + + /** + * @param string $path + * @param string $contentType + * @param int $width + * @param int $height + * @param int $size + * @param int|null $id + * @param string|null $title + * @param string|null $source + * @param string|null $createdAt + * @param string|null $updatedAt + * @param AssetExtensionInterface|null $extensionAttributes + */ + public function __construct( + string $path, + string $contentType, + int $width, + int $height, + int $size, + ?int $id = null, + ?string $title = null, + ?string $source = null, + ?string $createdAt = null, + ?string $updatedAt = null, + ?AssetExtensionInterface $extensionAttributes = null + ) { + $this->path = $path; + $this->contentType = $contentType; + $this->width = $width; + $this->height = $height; + $this->size = $size; + $this->id = $id; + $this->title = $title; + $this->source = $source; + $this->createdAt = $createdAt; + $this->updatedAt = $updatedAt; + $this->extensionAttributes = $extensionAttributes; + } /** * @inheritdoc */ public function getId(): ?int { - $id = $this->getData(self::ID); - - if (!$id) { - return null; - } - - return (int) $id; + return $this->id; } /** @@ -47,7 +123,7 @@ public function getId(): ?int */ public function getPath(): string { - return (string) $this->getData(self::PATH); + return $this->path; } /** @@ -55,7 +131,7 @@ public function getPath(): string */ public function getTitle(): ?string { - return $this->getData(self::TITLE); + return $this->title; } /** @@ -63,7 +139,7 @@ public function getTitle(): ?string */ public function getSource(): ?string { - return $this->getData(self::SOURCE); + return $this->source; } /** @@ -71,7 +147,7 @@ public function getSource(): ?string */ public function getContentType(): string { - return (string) $this->getData(self::CONTENT_TYPE); + return $this->contentType; } /** @@ -79,7 +155,7 @@ public function getContentType(): string */ public function getWidth(): int { - return (int) $this->getData(self::WIDTH); + return $this->width; } /** @@ -87,7 +163,7 @@ public function getWidth(): int */ public function getHeight(): int { - return (int) $this->getData(self::HEIGHT); + return $this->height; } /** @@ -95,38 +171,38 @@ public function getHeight(): int */ public function getSize(): int { - return (int) $this->getData(self::SIZE); + return $this->size; } /** * @inheritdoc */ - public function getCreatedAt(): string + public function getCreatedAt(): ?string { - return (string) $this->getData(self::CREATED_AT); + return $this->createdAt; } /** * @inheritdoc */ - public function getUpdatedAt(): string + public function getUpdatedAt(): ?string { - return (string) $this->getData(self::UPDATED_AT); + return $this->updatedAt; } /** * @inheritdoc */ - public function getExtensionAttributes(): AssetExtensionInterface + public function getExtensionAttributes(): ?AssetExtensionInterface { - return $this->_getExtensionAttributes(); + return $this->extensionAttributes; } /** * @inheritdoc */ - public function setExtensionAttributes(AssetExtensionInterface $extensionAttributes): void + public function setExtensionAttributes(?AssetExtensionInterface $extensionAttributes): void { - $this->_setExtensionAttributes($extensionAttributes); + $this->extensionAttributes = $extensionAttributes; } } diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByPath.php b/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByPath.php index 3abe707fbf863..fc8e5d7c84bfd 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByPath.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/DeleteByPath.php @@ -14,7 +14,8 @@ use Psr\Log\LoggerInterface; /** - * Class DeleteByPath + * Delete media asset by path + * * @deprecated use \Magento\MediaGalleryApi\Api\DeleteAssetsByPathInterface instead * @see \Magento\MediaGalleryApi\Api\DeleteAssetsByPathInterface */ diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php b/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php index 18fd3738580c4..b2f900233e46a 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/GetById.php @@ -89,7 +89,20 @@ public function execute(int $mediaAssetId): AssetInterface } try { - return $this->assetFactory->create(['data' => $mediaAssetData]); + return $this->assetFactory->create( + [ + 'id' => $mediaAssetData['id'], + 'path' => $mediaAssetData['path'], + 'title' => $mediaAssetData['title'], + 'source' => $mediaAssetData['source'], + 'contentType' => $mediaAssetData['content_type'], + 'width' => $mediaAssetData['width'], + 'height' => $mediaAssetData['height'], + 'size' => $mediaAssetData['size'], + 'createdAt' => $mediaAssetData['created_at'], + 'updatedAt' => $mediaAssetData['updated_at'], + ] + ); } catch (\Exception $exception) { $this->logger->critical($exception); $message = __( diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php b/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php index 21a27ce500332..d9faad62b2cd1 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/GetByPath.php @@ -16,7 +16,8 @@ use Psr\Log\LoggerInterface; /** - * Class GetByPath + * Provide media asset by path + * * @deprecated use \Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface instead * @see \Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface */ @@ -59,7 +60,7 @@ public function __construct( } /** - * Return media asset asset list + * Return media asset * * @param string $path * @@ -80,7 +81,20 @@ public function execute(string $path): AssetInterface throw new NoSuchEntityException($message); } - return $this->mediaAssetFactory->create(['data' => $data]); + return $this->mediaAssetFactory->create( + [ + 'id' => $data['id'], + 'path' => $data['path'], + 'title' => $data['title'], + 'source' => $data['source'], + 'contentType' => $data['content_type'], + 'width' => $data['width'], + 'height' => $data['height'], + 'size' => $data['size'], + 'createdAt' => $data['created_at'], + 'updatedAt' => $data['updated_at'], + ] + ); } catch (\Exception $exception) { $this->logger->critical($exception); $message = __('An error occurred during get media asset list: %1', $exception->getMessage()); diff --git a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php index 168fb479d3cdd..1710176c1b3af 100644 --- a/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php +++ b/app/code/Magento/MediaGallery/Model/Asset/Command/Save.php @@ -9,13 +9,13 @@ use Magento\Framework\App\ResourceConnection; use Magento\Framework\Exception\CouldNotSaveException; -use Magento\Framework\Reflection\DataObjectProcessor; use Magento\MediaGalleryApi\Api\Data\AssetInterface; use Magento\MediaGalleryApi\Model\Asset\Command\SaveInterface; use Psr\Log\LoggerInterface; /** - * Class Save + * Save media asset + * * @deprecated use \Magento\MediaGalleryApi\Api\SaveAssetsInterface instead * @see \Magento\MediaGalleryApi\Api\SaveAssetsInterface */ @@ -48,7 +48,7 @@ public function __construct( } /** - * Save media assets + * Save media asset * * @param AssetInterface $mediaAsset * diff --git a/app/code/Magento/MediaGallery/Model/AssetKeywords.php b/app/code/Magento/MediaGallery/Model/AssetKeywords.php index c4cced87f4d4e..4ffea9551263c 100644 --- a/app/code/Magento/MediaGallery/Model/AssetKeywords.php +++ b/app/code/Magento/MediaGallery/Model/AssetKeywords.php @@ -7,24 +7,50 @@ namespace Magento\MediaGallery\Model; -use Magento\Framework\Model\AbstractExtensibleModel; use Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface; use Magento\MediaGalleryApi\Api\Data\AssetKeywordsExtensionInterface; /** * Asset Id and Keywords combination data object for bulk operations with keyword services */ -class AssetKeywords extends AbstractExtensibleModel implements AssetKeywordsInterface +class AssetKeywords implements AssetKeywordsInterface { - private const ASSET_ID = 'asset_id'; - private const KEYWORDS = 'keywords'; + /** + * @var int + */ + private $assetId; + + /** + * @var array + */ + private $keywords; + + /** + * @var AssetKeywordsExtensionInterface|null + */ + private $extensionAttributes; + + /** + * @param int $assetId + * @param array $keywords + * @param AssetKeywordsExtensionInterface|null $extensionAttributes + */ + public function __construct( + int $assetId, + array $keywords, + ?AssetKeywordsExtensionInterface $extensionAttributes = null + ) { + $this->assetId = $assetId; + $this->keywords = $keywords; + $this->extensionAttributes = $extensionAttributes; + } /** * @inheritdoc */ public function getAssetId(): int { - return (int) $this->getData(self::ASSET_ID); + return $this->assetId; } /** @@ -32,22 +58,22 @@ public function getAssetId(): int */ public function getKeywords(): array { - return $this->getData(self::KEYWORDS); + return $this->keywords; } /** * @inheritdoc */ - public function getExtensionAttributes(): AssetKeywordsExtensionInterface + public function getExtensionAttributes(): ?AssetKeywordsExtensionInterface { - return $this->_getExtensionAttributes(); + return $this->extensionAttributes; } /** * @inheritdoc */ - public function setExtensionAttributes(AssetKeywordsExtensionInterface $extensionAttributes): void + public function setExtensionAttributes(?AssetKeywordsExtensionInterface $extensionAttributes): void { - $this->_setExtensionAttributes($extensionAttributes); + $this->extensionAttributes = $extensionAttributes; } } diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php index aed624bce5d21..cba101a18a39a 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php @@ -47,7 +47,9 @@ public function execute(array $paths): void $failedPaths = []; foreach ($paths as $path) { try { + //phpcs:ignore Magento2.Functions.DiscouragedFunction $name = basename($path); + //phpcs:ignore Magento2.Functions.DiscouragedFunction $folder = str_replace($name, '', $path); $this->storage->createDirectory( diff --git a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php index 4ca7527ef724b..0191b357aaefa 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php +++ b/app/code/Magento/MediaGallery/Model/Directory/IsBlacklisted.php @@ -20,7 +20,7 @@ class IsBlacklisted implements IsPathBlacklistedInterface */ private $config; - /* + /** * @param BlacklistPatternsConfigInterface $config */ public function __construct(BlacklistPatternsConfigInterface $config) diff --git a/app/code/Magento/MediaGallery/Model/Keyword.php b/app/code/Magento/MediaGallery/Model/Keyword.php index 18600af0dfc6c..5d3afd2096a62 100644 --- a/app/code/Magento/MediaGallery/Model/Keyword.php +++ b/app/code/Magento/MediaGallery/Model/Keyword.php @@ -10,28 +10,48 @@ use Magento\MediaGalleryApi\Api\Data\KeywordExtensionInterface; use Magento\MediaGalleryApi\Api\Data\KeywordInterface; -use Magento\Framework\Model\AbstractExtensibleModel; /** * Asset's Keyword */ -class Keyword extends AbstractExtensibleModel implements KeywordInterface +class Keyword implements KeywordInterface { - private const ID = 'id'; - private const KEYWORD = 'keyword'; + /** + * @var int + */ + private $id; + + /** + * @var string + */ + private $keyword; + + /** + * @var KeywordExtensionInterface|null + */ + private $extensionAttributes; + + /** + * @param string $keyword + * @param int|null $id + * @param KeywordExtensionInterface|null $extensionAttributes + */ + public function __construct( + string $keyword, + ?int $id = null, + ?KeywordExtensionInterface $extensionAttributes = null + ) { + $this->keyword = $keyword; + $this->id = $id; + $this->extensionAttributes = $extensionAttributes; + } /** * @inheritdoc */ public function getId(): ?int { - $id = $this->getData(self::ID); - - if (!$id) { - return null; - } - - return (int) $id; + return $this->id; } /** @@ -39,22 +59,22 @@ public function getId(): ?int */ public function getKeyword(): string { - return (string) $this->getData(self::KEYWORD); + return $this->keyword; } /** * @inheritdoc */ - public function getExtensionAttributes(): KeywordExtensionInterface + public function getExtensionAttributes(): ?KeywordExtensionInterface { - return $this->_getExtensionAttributes(); + return $this->extensionAttributes; } /** * @inheritdoc */ - public function setExtensionAttributes(KeywordExtensionInterface $extensionAttributes): void + public function setExtensionAttributes(?KeywordExtensionInterface $extensionAttributes): void { - $this->_setExtensionAttributes($extensionAttributes); + $this->extensionAttributes = $extensionAttributes; } } diff --git a/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php b/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php index 4112b717c24a2..27d32e5444f4b 100644 --- a/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php +++ b/app/code/Magento/MediaGallery/Model/Keyword/Command/GetAssetKeywords.php @@ -76,7 +76,12 @@ public function execute(int $assetId): array $keywords = []; foreach ($data as $keywordData) { - $keywords[] = $this->assetKeywordFactory->create(['data' => $keywordData]); + $keywords[] = $this->assetKeywordFactory->create( + [ + 'id' => $keywordData['id'], + 'keyword' => $keywordData['keyword'], + ] + ); } return $keywords; diff --git a/app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetKeywords.php b/app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetKeywords.php index 748b1e0d2463a..d3a5eab36de06 100644 --- a/app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetKeywords.php +++ b/app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetKeywords.php @@ -17,7 +17,7 @@ use Psr\Log\LoggerInterface; /** - * Class SaveAssetKeywords + * Save asset keywords * @deprecated use \Magento\MediaGalleryApi\Api\SaveAssetKeywordsInterface instead */ class SaveAssetKeywords implements SaveAssetKeywordsInterface @@ -42,8 +42,6 @@ class SaveAssetKeywords implements SaveAssetKeywordsInterface private $logger; /** - * SaveAssetKeywords constructor. - * * @param ResourceConnection $resourceConnection * @param SaveAssetLinks $saveAssetLinks * @param LoggerInterface $logger diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByIds.php b/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByIds.php index 89daded071c33..53185939b2283 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByIds.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByIds.php @@ -60,7 +60,20 @@ public function execute(array $ids): array $assets = []; try { foreach ($this->getAssetsData($ids) as $assetData) { - $assets[] = $this->assetFactory->create(['data' => $assetData]); + $assets[] = $this->assetFactory->create( + [ + 'id' => $assetData['id'], + 'path' => $assetData['path'], + 'title' => $assetData['title'], + 'source' => $assetData['source'], + 'contentType' => $assetData['content_type'], + 'width' => $assetData['width'], + 'height' => $assetData['height'], + 'size' => $assetData['size'], + 'createdAt' => $assetData['created_at'], + 'updatedAt' => $assetData['updated_at'], + ] + ); } } catch (\Exception $exception) { $this->logger->critical($exception); diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php b/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php index 3a94ebd287399..5593083d9673a 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/GetAssetsByPaths.php @@ -61,7 +61,20 @@ public function execute(array $paths): array $assets = []; try { foreach ($this->getAssetsData($paths) as $assetData) { - $assets[] = $this->mediaAssetFactory->create(['data' => $assetData]); + $assets[] = $this->mediaAssetFactory->create( + [ + 'id' => $assetData['id'], + 'path' => $assetData['path'], + 'title' => $assetData['title'], + 'source' => $assetData['source'], + 'contentType' => $assetData['content_type'], + 'width' => $assetData['width'], + 'height' => $assetData['height'], + 'size' => $assetData['size'], + 'createdAt' => $assetData['created_at'], + 'updatedAt' => $assetData['updated_at'], + ] + ); } } catch (\Exception $exception) { $this->logger->critical($exception); diff --git a/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php index f9d767d70bed8..11b0a0fa3a359 100644 --- a/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php +++ b/app/code/Magento/MediaGallery/Model/ResourceModel/Keyword/GetAssetsKeywords.php @@ -10,7 +10,6 @@ use Magento\Framework\Exception\IntegrationException; use Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterface; use Magento\MediaGalleryApi\Api\Data\AssetKeywordsInterfaceFactory; -use Magento\MediaGalleryApi\Api\Data\KeywordInterface; use Magento\MediaGalleryApi\Api\Data\KeywordInterfaceFactory; use Magento\MediaGalleryApi\Api\GetAssetsKeywordsInterface; use Magento\Framework\App\ResourceConnection; @@ -105,7 +104,8 @@ private function getAssetKeywords(array $keywordsData): array foreach ($keywordsData as $keywordData) { $keywordsByAsset[$keywordData[self::FIELD_ASSET_ID]][] = $this->keywordFactory->create( [ - 'data' => $keywordData + 'id' => $keywordData['id'], + 'keyword' => $keywordData['keyword'], ] ); } @@ -114,10 +114,8 @@ private function getAssetKeywords(array $keywordsData): array foreach ($keywordsByAsset as $assetId => $keywords) { $assetKeywords[$assetId] = $this->assetKeywordsFactory->create( [ - 'data' => [ - 'asset_id' => $assetId, - 'keywords' => $keywords - ] + 'assetId' => $assetId, + 'keywords' => $keywords ] ); } diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php index 8db0258fe3981..6f82d2f2a5cb3 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php @@ -48,12 +48,14 @@ class SaveTest extends TestCase * Constant for image data */ private const IMAGE_DATA = [ + 'id' => null, 'path' => '/test/path', 'title' => 'Test Title', 'source' => 'Adobe Stock', 'content_type' => 'image/jpeg', 'height' => 4863, - 'width' => 12129 + 'width' => 12129, + 'size' => 300, ]; /** @@ -125,11 +127,16 @@ public function testSuccessfulExecute(): void $this->resourceConnectionMock->expects(self::once())->method('getConnection'); $this->resourceConnectionMock->expects(self::once())->method('getTableName'); - $this->objectProcessor - ->expects(self::once()) - ->method('buildOutputDataArray') - ->with($this->mediaAssetMock, AssetInterface::class) - ->willReturn(self::IMAGE_DATA); + $this->mediaAssetMock->expects(self::once())->method('getId')->willReturn(self::IMAGE_DATA['id']); + $this->mediaAssetMock->expects(self::once())->method('getPath')->willReturn(self::IMAGE_DATA['path']); + $this->mediaAssetMock->expects(self::once())->method('getTitle')->willReturn(self::IMAGE_DATA['title']); + $this->mediaAssetMock->expects(self::once())->method('getSource')->willReturn(self::IMAGE_DATA['source']); + $this->mediaAssetMock->expects(self::once())->method('getWidth')->willReturn(self::IMAGE_DATA['width']); + $this->mediaAssetMock->expects(self::once())->method('getHeight')->willReturn(self::IMAGE_DATA['height']); + $this->mediaAssetMock->expects(self::once())->method('getSize')->willReturn(self::IMAGE_DATA['size']); + $this->mediaAssetMock->expects(self::once()) + ->method('getContentType') + ->willReturn(self::IMAGE_DATA['content_type']); $this->adapterMock ->expects(self::once()) @@ -154,11 +161,16 @@ public function testExceptionExecute(): void $this->resourceConnectionMock->expects(self::once())->method('getConnection'); $this->resourceConnectionMock->expects(self::once())->method('getTableName'); - $this->objectProcessor - ->expects(self::once()) - ->method('buildOutputDataArray') - ->with($this->mediaAssetMock, AssetInterface::class) - ->willReturn(self::IMAGE_DATA); + $this->mediaAssetMock->expects(self::once())->method('getId')->willReturn(self::IMAGE_DATA['id']); + $this->mediaAssetMock->expects(self::once())->method('getPath')->willReturn(self::IMAGE_DATA['path']); + $this->mediaAssetMock->expects(self::once())->method('getTitle')->willReturn(self::IMAGE_DATA['title']); + $this->mediaAssetMock->expects(self::once())->method('getSource')->willReturn(self::IMAGE_DATA['source']); + $this->mediaAssetMock->expects(self::once())->method('getWidth')->willReturn(self::IMAGE_DATA['width']); + $this->mediaAssetMock->expects(self::once())->method('getHeight')->willReturn(self::IMAGE_DATA['height']); + $this->mediaAssetMock->expects(self::once())->method('getSize')->willReturn(self::IMAGE_DATA['size']); + $this->mediaAssetMock->expects(self::once()) + ->method('getContentType') + ->willReturn(self::IMAGE_DATA['content_type']); $this->adapterMock ->expects(self::once()) diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php index a60c4d75aee7d..5b069dcc70030 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Directory/IsBlacklistedTest.php @@ -33,7 +33,9 @@ class IsBlacklistedTest extends TestCase */ protected function setUp(): void { - $this->config = $this->getMockBuilder(BlacklistPatternsConfigInterface::class)->disableOriginalConstructor()->getMock(); + $this->config = $this->getMockBuilder(BlacklistPatternsConfigInterface::class) + ->disableOriginalConstructor() + ->getMock(); $this->config->expects($this->at(0))->method('get')->willReturn([ 'tmp' => '/pub\/media\/tmp/', 'captcha' => '/pub\/media\/captcha/' diff --git a/app/code/Magento/MediaGallery/etc/db_schema_whitelist.json b/app/code/Magento/MediaGallery/etc/db_schema_whitelist.json index 9e187e6dea4a5..8f5098caa9753 100644 --- a/app/code/Magento/MediaGallery/etc/db_schema_whitelist.json +++ b/app/code/Magento/MediaGallery/etc/db_schema_whitelist.json @@ -14,7 +14,8 @@ }, "index": { "MEDIA_GALLERY_ID": true, - "MEDIA_GALLERY_ASSET_ID": true + "MEDIA_GALLERY_ASSET_ID": true, + "MEDIA_GALLERY_ASSET_TITLE": true }, "constraint": { "MEDIA_GALLERY_ID_PATH_TITLE_CONTENT_TYPE_WIDTH_HEIGHT": true, diff --git a/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php b/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php index c3454400b2995..5df420a274933 100644 --- a/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php @@ -76,29 +76,29 @@ public function getSize(): int; /** * Get created at * - * @return string + * @return string|null */ - public function getCreatedAt(): string; + public function getCreatedAt(): ?string; /** * Get updated at * - * @return string + * @return string|null */ - public function getUpdatedAt(): string; + public function getUpdatedAt(): ?string; /** * Retrieve existing extension attributes object or create a new one. * * @return \Magento\MediaGalleryApi\Api\Data\AssetExtensionInterface|null */ - public function getExtensionAttributes(): AssetExtensionInterface; + public function getExtensionAttributes(): ?AssetExtensionInterface; /** * Set extension attributes * - * @param \Magento\MediaGalleryApi\Api\Data\AssetExtensionInterface $extensionAttributes + * @param \Magento\MediaGalleryApi\Api\Data\AssetExtensionInterface|null $extensionAttributes * @return void */ - public function setExtensionAttributes(AssetExtensionInterface $extensionAttributes): void; + public function setExtensionAttributes(?AssetExtensionInterface $extensionAttributes): void; } diff --git a/app/code/Magento/MediaGalleryApi/Api/Data/AssetKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Api/Data/AssetKeywordsInterface.php index e4356f05a1ece..1c18225470493 100644 --- a/app/code/Magento/MediaGalleryApi/Api/Data/AssetKeywordsInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/Data/AssetKeywordsInterface.php @@ -30,19 +30,18 @@ public function getAssetId(): int; */ public function getKeywords(): array; - /** * Get extension attributes * * @return \Magento\MediaGalleryApi\Api\Data\AssetKeywordsExtensionInterface|null */ - public function getExtensionAttributes(): AssetKeywordsExtensionInterface; + public function getExtensionAttributes(): ?AssetKeywordsExtensionInterface; /** * Set extension attributes * - * @param \Magento\MediaGalleryApi\Api\Data\AssetKeywordsExtensionInterface $extensionAttributes + * @param \Magento\MediaGalleryApi\Api\Data\AssetKeywordsExtensionInterface|null $extensionAttributes * @return void */ - public function setExtensionAttributes(AssetKeywordsExtensionInterface $extensionAttributes): void; + public function setExtensionAttributes(?AssetKeywordsExtensionInterface $extensionAttributes): void; } diff --git a/app/code/Magento/MediaGalleryApi/Api/Data/KeywordInterface.php b/app/code/Magento/MediaGalleryApi/Api/Data/KeywordInterface.php index 7f19e53d6e380..3cba118e03a1a 100644 --- a/app/code/Magento/MediaGalleryApi/Api/Data/KeywordInterface.php +++ b/app/code/Magento/MediaGalleryApi/Api/Data/KeywordInterface.php @@ -35,13 +35,13 @@ public function getKeyword(): string; * * @return \Magento\MediaGalleryApi\Api\Data\KeywordExtensionInterface|null */ - public function getExtensionAttributes(): KeywordExtensionInterface; + public function getExtensionAttributes(): ?KeywordExtensionInterface; /** * Set extension attributes * - * @param \Magento\MediaGalleryApi\Api\Data\KeywordExtensionInterface $extensionAttributes + * @param \Magento\MediaGalleryApi\Api\Data\KeywordExtensionInterface|null $extensionAttributes * @return void */ - public function setExtensionAttributes(KeywordExtensionInterface $extensionAttributes): void; + public function setExtensionAttributes(?KeywordExtensionInterface $extensionAttributes): void; } diff --git a/app/code/Magento/MediaGalleryCatalog/composer.json b/app/code/Magento/MediaGalleryCatalog/composer.json index 8152fb5aac8bb..ed3eb63ac970a 100644 --- a/app/code/Magento/MediaGalleryCatalog/composer.json +++ b/app/code/Magento/MediaGalleryCatalog/composer.json @@ -1,5 +1,5 @@ { - "name": "magento/module-media-gallery", + "name": "magento/module-media-gallery-catalog", "description": "Magento module responsible for catalog gallery processor delete operation handling", "require": { "php": "~7.1.3||~7.2.0||~7.3.0", diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php index f24a960a29be9..4d30646d596b6 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php @@ -93,25 +93,20 @@ public function testExecute(): void { $keyword1 = $this->keywordFactory->create( [ - 'data' => [ - 'keyword' => 'pear' - ] + 'keyword' => 'pear' ] ); $keyword2 = $this->keywordFactory->create( [ - 'data' => [ - 'keyword' => 'plum' - ] + 'keyword' => 'plum' ] ); $asset = $this->assetFactory->create( [ - 'data' => [ - 'path' => 'fruit.jpg' - ] + 'path' => 'fruit.jpg', + 'contentType' => 'image' ] ); $this->saveAssets->execute([$asset]); @@ -122,12 +117,10 @@ public function testExecute(): void $assetKeywords = $this->assetsKeywordsFactory->create( [ - 'data' => [ - 'asset_id' => $loadedAsset->getId(), - 'keywords' => [ - $keyword1, - $keyword2 - ] + 'assetId' => $loadedAsset->getId(), + 'keywords' => [ + $keyword1, + $keyword2 ] ] ); diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/IsBlacklistedTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/IsBlacklistedTest.php index 57822d674a842..47ff2b3a94aa3 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/IsBlacklistedTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/IsBlacklistedTest.php @@ -14,7 +14,7 @@ /** * Test for IsPathBlacklistedInterface */ -class CreateByPathsTest extends TestCase +class IsBlacklistedTest extends TestCase { /** diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetKeywordsTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetKeywordsTest.php index 02249021f2a50..f6b9ed5e1ff75 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetKeywordsTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetKeywordsTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\MediaGallery\Model; +namespace Magento\MediaGallery\Model\ResourceModel; use Behat\Gherkin\Keywords\KeywordsInterface; use Magento\MediaGalleryApi\Api\Data\KeywordInterfaceFactory; @@ -79,10 +79,8 @@ public function testSaveAndGetKeywords(array $keywords): void $assetKeywords = $this->assetsKeywordsFactory->create( [ - 'data' => [ - 'asset_id' => $loadedAsset->getId(), - 'keywords' => $this->getKeywords($keywords) - ] + 'assetId' => $loadedAsset->getId(), + 'keywords' => $this->getKeywords($keywords) ] ); @@ -136,9 +134,7 @@ private function getKeywords(array $keywords): array foreach ($keywords as $keyword) { $keywordObjects[] = $this->keywordFactory->create( [ - 'data' => [ - 'keyword' => $keyword - ] + 'keyword' => $keyword ] ); } diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php index c32113dfdda33..8af8a31356dd3 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php @@ -103,17 +103,20 @@ public function assetsDataProvider(): array 'One asset' => [ 'assetsData' => [ 'asset1' => [ - 'path' => 'fruit.jpg' + 'path' => 'fruit.jpg', + 'contentType' => 'image' ] ] ], 'Two assets' => [ 'assetsData' => [ 'asset1' => [ - 'path' => 'image.jpg' + 'path' => 'image.jpg', + 'contentType' => 'image' ], 'asset2' => [ - 'path' => 'image2.png' + 'path' => 'image2.png', + 'contentType' => 'image' ] ] ], diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php index f9ad69220dc4d..f332bfde37422 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php @@ -16,13 +16,11 @@ /** @var AssetInterface $mediaAsset */ $mediaAsset = $mediaAssetFactory->create( [ - 'data' => [ - 'id' => 2020, - 'path' => 'testDirectory/path.jpg' - ] + 'id' => 2020, + 'path' => 'testDirectory/path.jpg', + 'contentType' => 'image' ] ); /** @var SaveInterface $mediaSave */ $mediaSave = $objectManager->get(SaveInterface::class); $mediaId = $mediaSave->execute($mediaAsset); - diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php index 0f51c10814029..76756e912b3b5 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset_rollback.php @@ -18,4 +18,3 @@ } catch (\Exception $exception) { } - From 4d33b027a0e94ef44c58888ede76d1a254396611 Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets <vzaets@magento.com> Date: Thu, 16 Apr 2020 16:55:26 -0500 Subject: [PATCH 166/177] Fix integration and static tests --- .../MediaContent/Model/ContentAssetLink.php | 17 +++++++--- .../MediaContent/Model/ContentIdentity.php | 10 +++++- .../Model/DeleteContentAssetLinks.php | 11 +++++-- ...MediaGalleryAssetDeleteByDirectoryPath.php | 2 ++ .../Plugin/MediaGalleryAssetDeleteByPath.php | 2 ++ .../Api/Data/ContentAssetLinkInterface.php | 8 +++++ .../Api/Data/ContentIdentityInterface.php | 10 +++++- ...ractAssetsFromContentEntitiesInterface.php | 25 -------------- .../Model/ExtractAssetsFromContentTest.php | 7 ++-- ...hp => SaveDeleteContentAssetLinksTest.php} | 4 +-- ...st.php => UpdateContentAssetLinksTest.php} | 33 +++++++++---------- 11 files changed, 72 insertions(+), 57 deletions(-) delete mode 100644 app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentEntitiesInterface.php rename dev/tests/integration/testsuite/Magento/MediaContent/Model/{AssignGetUnassignTest.php => SaveDeleteContentAssetLinksTest.php} (96%) rename dev/tests/integration/testsuite/Magento/MediaContent/Model/{UpdateRelationsTest.php => UpdateContentAssetLinksTest.php} (53%) diff --git a/app/code/Magento/MediaContent/Model/ContentAssetLink.php b/app/code/Magento/MediaContent/Model/ContentAssetLink.php index 5f0f2b0c01c8b..abfafd39c4a23 100644 --- a/app/code/Magento/MediaContent/Model/ContentAssetLink.php +++ b/app/code/Magento/MediaContent/Model/ContentAssetLink.php @@ -16,9 +16,6 @@ */ class ContentAssetLink implements ContentAssetLinkInterface { - private const ASSET_ID = 'asset_id'; - private const CONTENT_IDENTITY = 'content_identity'; - /** * @var ContentAssetLinkExtensionInterface|null */ @@ -35,14 +32,16 @@ class ContentAssetLink implements ContentAssetLinkInterface private $assetId; /** + * ContentAssetLink constructor. + * @param int $assetId + * @param ContentIdentityInterface $contentIdentity * @param ContentAssetLinkExtensionInterface|null $extensionAttributes */ public function __construct( int $assetId, ContentIdentityInterface $contentIdentity, ?ContentAssetLinkExtensionInterface $extensionAttributes = null - ) - { + ) { $this->assetId = $assetId; $this->contentIdentity = $contentIdentity; $this->extensionAttributes = $extensionAttributes; @@ -71,4 +70,12 @@ public function getExtensionAttributes(): ?ContentAssetLinkExtensionInterface { return $this->extensionAttributes; } + + /** + * @inheritdoc + */ + public function setExtensionAttributes(?ContentAssetLinkExtensionInterface $extensionAttributes): void + { + $this->extensionAttributes = $extensionAttributes; + } } diff --git a/app/code/Magento/MediaContent/Model/ContentIdentity.php b/app/code/Magento/MediaContent/Model/ContentIdentity.php index 752db82703ff8..fd60aa8f19430 100644 --- a/app/code/Magento/MediaContent/Model/ContentIdentity.php +++ b/app/code/Magento/MediaContent/Model/ContentIdentity.php @@ -66,8 +66,16 @@ public function getField(): string /** * @inheritdoc */ - public function getExtensionAttributes(): ContentIdentityExtensionInterface + public function getExtensionAttributes(): ?ContentIdentityExtensionInterface { return $this->extensionAttributes; } + + /** + * @inheritdoc + */ + public function setExtensionAttributes(?ContentIdentityExtensionInterface $extensionAttributes): void + { + $this->extensionAttributes = $extensionAttributes; + } } diff --git a/app/code/Magento/MediaContent/Model/DeleteContentAssetLinks.php b/app/code/Magento/MediaContent/Model/DeleteContentAssetLinks.php index 6abe9c6217106..543347c872e73 100644 --- a/app/code/Magento/MediaContent/Model/DeleteContentAssetLinks.php +++ b/app/code/Magento/MediaContent/Model/DeleteContentAssetLinks.php @@ -66,6 +66,8 @@ public function execute(array $contentAssetLinks): void } /** + * Build sql where condition + * * @param ContentAssetLinkInterface[] $contentAssetLinks * @return string */ @@ -76,13 +78,16 @@ private function buildWhereSqlPart(array $contentAssetLinks): string foreach ($contentAssetLinks as $contentAssetLink) { $assetId = $connection->quoteInto(self::ASSET_ID . ' = ?', $contentAssetLink->getAssetId()); $entityId = $connection->quoteInto( - self::ENTITY_ID . ' = ?', $contentAssetLink->getContentId()->getEntityId() + self::ENTITY_ID . ' = ?', + $contentAssetLink->getContentId()->getEntityId() ); $entityType = $connection->quoteInto( - self::ENTITY_TYPE . ' = ?', $contentAssetLink->getContentId()->getEntityType() + self::ENTITY_TYPE . ' = ?', + $contentAssetLink->getContentId()->getEntityType() ); $field = $connection->quoteInto( - self::FIELD . ' = ?', $contentAssetLink->getContentId()->getField() + self::FIELD . ' = ?', + $contentAssetLink->getContentId()->getField() ); $condition[] = '(' . $assetId . ' AND ' . $entityId . ' AND ' . $entityType . ' AND ' . $field . ')'; } diff --git a/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php index 180ededa66ce5..29645c4a9887f 100644 --- a/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php +++ b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php @@ -52,6 +52,8 @@ public function __construct( } /** + * Around plugin on execute method + * * @param DeleteByDirectoryPathInterface $subject * @param \Closure $proceed * @param string $directoryPath diff --git a/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php index e19d24eda783d..efb95c644b48a 100644 --- a/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php +++ b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php @@ -49,6 +49,8 @@ public function __construct( } /** + * Around plugin on execute method + * * @param DeleteByPathInterface $subject * @param \Closure $proceed * @param string $mediaAssetPath diff --git a/app/code/Magento/MediaContentApi/Api/Data/ContentAssetLinkInterface.php b/app/code/Magento/MediaContentApi/Api/Data/ContentAssetLinkInterface.php index 0c94032e8bcfb..5ff490655d464 100644 --- a/app/code/Magento/MediaContentApi/Api/Data/ContentAssetLinkInterface.php +++ b/app/code/Magento/MediaContentApi/Api/Data/ContentAssetLinkInterface.php @@ -37,4 +37,12 @@ public function getAssetId(): int; * @return \Magento\MediaContentApi\Api\Data\ContentAssetLinkExtensionInterface|null */ public function getExtensionAttributes(): ?ContentAssetLinkExtensionInterface; + + /** + * Set extension attributes + * + * @param \Magento\MediaContentApi\Api\Data\ContentAssetLinkExtensionInterface|null $extensionAttributes + * @return void + */ + public function setExtensionAttributes(?ContentAssetLinkExtensionInterface $extensionAttributes): void; } diff --git a/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php b/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php index f4c18e4ba0704..f1b701fe9d964 100644 --- a/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php +++ b/app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php @@ -43,5 +43,13 @@ public function getField(): string; * * @return \Magento\MediaContentApi\Api\Data\ContentIdentityExtensionInterface|null */ - public function getExtensionAttributes(): ContentIdentityExtensionInterface; + public function getExtensionAttributes(): ?ContentIdentityExtensionInterface; + + /** + * Set extension attributes + * + * @param \Magento\MediaContentApi\Api\Data\ContentIdentityExtensionInterface|null $extensionAttributes + * @return void + */ + public function setExtensionAttributes(?ContentIdentityExtensionInterface $extensionAttributes): void; } diff --git a/app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentEntitiesInterface.php b/app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentEntitiesInterface.php deleted file mode 100644 index 398992603c63b..0000000000000 --- a/app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentEntitiesInterface.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ -declare(strict_types=1); - -namespace Magento\MediaContentApi\Api; - -use Magento\MediaGalleryApi\Api\Data\AssetInterface; - -/** - * Parse the content string for references to media assets and return the list of identified media assets - * @api - */ -interface ExtractAssetsFromContentEntitiesInterface -{ - /** - * Parse the content string for references to media assets and return the list of identified media assets - * - * @param string[] $contentEntities - * @return AssetInterface[] - */ - public function execute(array $contentEntities): array; -} diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php index 3e319a1a2afc6..d8870bb4c422d 100644 --- a/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php @@ -20,14 +20,15 @@ class ExtractAssetsFromContentTest extends TestCase /** * @var ExtractAssetsFromContentInterface */ - private $service; + private $extractAssetsFromContent; /** * @inheritdoc */ public function setUp(): void { - $this->service = Bootstrap::getObjectManager()->get(ExtractAssetsFromContentInterface::class); + $this->extractAssetsFromContent = Bootstrap::getObjectManager() + ->get(ExtractAssetsFromContentInterface::class); } /** @@ -41,7 +42,7 @@ public function setUp(): void */ public function testExecute(string $content, array $assetIds): void { - $assets = $this->service->execute($content); + $assets = $this->extractAssetsFromContent->execute($content); $extractedAssetIds = []; foreach ($assets as $asset) { diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/SaveDeleteContentAssetLinksTest.php similarity index 96% rename from dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php rename to dev/tests/integration/testsuite/Magento/MediaContent/Model/SaveDeleteContentAssetLinksTest.php index c2daccf167c4d..36b2768d9b806 100644 --- a/dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/SaveDeleteContentAssetLinksTest.php @@ -20,7 +20,7 @@ /** * Test for AssignAssets service */ -class AssignGetUnassignTest extends TestCase +class SaveDeleteContentAssetLinksTest extends TestCase { /** * @var SaveContentAssetLinksInterface @@ -55,7 +55,7 @@ public function setUp(): void } /** - * Assing assets to content, retrieve the data, then unassign assets from content + * Save asset to content links, retrieve the data, delete assets to content links */ public function testAssignRetrieveAndUnassign(): void { diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateContentAssetLinksTest.php similarity index 53% rename from dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php rename to dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateContentAssetLinksTest.php index c2c6d66737b4b..8e1747a831abc 100644 --- a/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateRelationsTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateContentAssetLinksTest.php @@ -15,27 +15,28 @@ use PHPUnit\Framework\TestCase; /** - * Test for ExtractAssetsFromContent + * Test for UpdateContentAssetLinks */ -class UpdateRelationsTest extends TestCase +class UpdateContentAssetLinksTest extends TestCase { /** * @var UpdateContentAssetLinksInterface */ - private $service; + private $updateContentAssetLinks; /** * @var GetAssetIdsByContentIdentityInterface */ - private $getAssetIds; + private $getAssetIdsByContentIdentity; /** * @inheritdoc */ public function setUp(): void { - $this->service = Bootstrap::getObjectManager()->get(UpdateContentAssetLinksInterface::class); - $this->getAssetIds = Bootstrap::getObjectManager()->get(GetAssetIdsByContentIdentityInterface::class); + $this->updateContentAssetLinks = Bootstrap::getObjectManager()->get(UpdateContentAssetLinksInterface::class); + $this->getAssetIdsByContentIdentity = Bootstrap::getObjectManager() + ->get(GetAssetIdsByContentIdentityInterface::class); } /** @@ -54,21 +55,19 @@ public function testExecute(): void $contentIdentity = Bootstrap::getObjectManager()->create( ContentIdentityInterface::class, [ - 'data' => [ - 'entity_type' => $entityType, - 'entity_id' => $entityId, - 'field' => $field - ] + 'entityType' => $entityType, + 'entityId' => $entityId, + 'field' => $field ] ); - $this->service->execute($contentIdentity, $contentWithoutAsset); - $this->assertEmpty($this->getAssetIds->execute($contentIdentity)); + $this->updateContentAssetLinks->execute($contentIdentity, $contentWithoutAsset); + $this->assertEmpty($this->getAssetIdsByContentIdentity->execute($contentIdentity)); - $this->service->execute($contentIdentity, $contentWithAsset); - $this->assertNotEmpty($this->getAssetIds->execute($contentIdentity)); + $this->updateContentAssetLinks->execute($contentIdentity, $contentWithAsset); + $this->assertNotEmpty($this->getAssetIdsByContentIdentity->execute($contentIdentity)); - $this->service->execute($contentIdentity, $contentWithoutAsset); - $this->assertEmpty($this->getAssetIds->execute($contentIdentity)); + $this->updateContentAssetLinks->execute($contentIdentity, $contentWithoutAsset); + $this->assertEmpty($this->getAssetIdsByContentIdentity->execute($contentIdentity)); } } From 3b082ffacc0edb070d14162a8890e7466a18cd6c Mon Sep 17 00:00:00 2001 From: Dmytro Voskoboinikov <voskoboi@adobe.com> Date: Thu, 16 Apr 2020 17:02:12 -0500 Subject: [PATCH 167/177] MC-30175: UI component rendering config --- .../Magento/Quote/Model/ShippingMethodManagementTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/Quote/Model/ShippingMethodManagementTest.php b/dev/tests/integration/testsuite/Magento/Quote/Model/ShippingMethodManagementTest.php index c080d7a3ab229..6b2806f147dea 100644 --- a/dev/tests/integration/testsuite/Magento/Quote/Model/ShippingMethodManagementTest.php +++ b/dev/tests/integration/testsuite/Magento/Quote/Model/ShippingMethodManagementTest.php @@ -295,6 +295,8 @@ private function executeTestFlow($flatRateAmount, $tableRateAmount) */ public function testEstimateByAddressWithInclExclTaxAndVATGroup() { + $this->markTestSkipped('MC-33463'); + /** @var CustomerRepositoryInterface $customerRepository */ $customerRepository = $this->objectManager->get(CustomerRepositoryInterface::class); $customer = $customerRepository->get('customer@example.com'); From 2db43c261fc7b055b134b06779ee3f35a57dee1f Mon Sep 17 00:00:00 2001 From: Volodymyr Zaets <vzaets@magento.com> Date: Thu, 16 Apr 2020 17:15:47 -0500 Subject: [PATCH 168/177] Fix plugin namespace --- app/code/Magento/MediaContent/etc/di.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/MediaContent/etc/di.xml b/app/code/Magento/MediaContent/etc/di.xml index dc151fb7a377d..bdbff33b80ad3 100644 --- a/app/code/Magento/MediaContent/etc/di.xml +++ b/app/code/Magento/MediaContent/etc/di.xml @@ -18,7 +18,7 @@ <preference for="Magento\MediaContentApi\Model\SearchPatternConfigInterface" type="Magento\MediaContent\Model\Content\SearchPatternConfig"/> <preference for="Magento\MediaContent\Model\Content\ConfigInterface" type="Magento\MediaContent\Model\Content\Config"/> <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface"> - <plugin name="remove_media_content_after_asset_is_removed_by_path" type="Magento\MediaContent\Model\MediaGalleryAssetDeleteByPath" /> + <plugin name="remove_media_content_after_asset_is_removed_by_path" type="Magento\MediaContent\Plugin\MediaGalleryAssetDeleteByPath" /> </type> <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByDirectoryPathInterface"> <plugin name="remove_media_content_after_asset_is_removed_by_directory_path" type="Magento\MediaContent\Plugin\MediaGalleryAssetDeleteByDirectoryPath" /> From 2a55b2436e41e5ec2da2ef1f279b2a42365f534c Mon Sep 17 00:00:00 2001 From: engcom-Echo <engcom-vendorworker-echo@adobe.com> Date: Fri, 17 Apr 2020 13:53:16 +0300 Subject: [PATCH 169/177] Fix mftf --- .../StorefrontGoCheckoutWithMultipleAddressesActionGroup.xml | 3 +++ .../Mftf/Section/MultishippingSection/MultishippingSection.xml | 1 + 2 files changed, 4 insertions(+) diff --git a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/StorefrontGoCheckoutWithMultipleAddressesActionGroup.xml b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/StorefrontGoCheckoutWithMultipleAddressesActionGroup.xml index fd57a3b095a3d..1d8e836041129 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/StorefrontGoCheckoutWithMultipleAddressesActionGroup.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/ActionGroup/StorefrontGoCheckoutWithMultipleAddressesActionGroup.xml @@ -9,6 +9,9 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> <actionGroup name="StorefrontGoCheckoutWithMultipleAddressesActionGroup"> + <waitForAjaxLoad stepKey="waitAjaxLoad"/> <click selector="{{MultishippingSection.shippingMultipleCheckout}}" stepKey="clickToMultipleAddressShippingButton"/> + <waitForPageLoad stepKey="waitForMultipleCheckoutLoad"/> + <seeElement selector="{{MultishippingSection.pageTitle}}" stepKey="seeMultipleCheckoutPageTitle"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Multishipping/Test/Mftf/Section/MultishippingSection/MultishippingSection.xml b/app/code/Magento/Multishipping/Test/Mftf/Section/MultishippingSection/MultishippingSection.xml index fab513cc8d11a..db037d50f7dc6 100644 --- a/app/code/Magento/Multishipping/Test/Mftf/Section/MultishippingSection/MultishippingSection.xml +++ b/app/code/Magento/Multishipping/Test/Mftf/Section/MultishippingSection/MultishippingSection.xml @@ -8,6 +8,7 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="MultishippingSection"> + <element name="pageTitle" type="text" selector="//span[text()='Ship to Multiple Addresses']"/> <element name="checkoutWithMultipleAddresses" type="button" selector="//span[text()='Check Out with Multiple Addresses']"/> <element name="shippingMultipleCheckout" type="button" selector=".action.multicheckout"/> <element name="shippingAddressSelector" type="select" selector="//tr[position()={{addressPosition}}]//td[@data-th='Send To']//select" parameterized="true"/> From 9a7a1c5137a6949bf9dbfbdc3e0f0b30df5506cc Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Sat, 18 Apr 2020 19:37:16 +0100 Subject: [PATCH 170/177] Fixed unit tests --- ...tionDuringMediaAssetInitializationTest.php | 35 +++++++++++-------- .../Command/GetByIdExceptionOnGetDataTest.php | 16 +++++++-- .../Asset/Command/GetByIdSuccessfulTest.php | 16 +++++++-- .../Keyword/Command/GetAssetKeywordsTest.php | 29 +++++++++++++-- 4 files changed, 73 insertions(+), 23 deletions(-) diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionDuringMediaAssetInitializationTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionDuringMediaAssetInitializationTest.php index 49a5421e623a5..834e8027584dc 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionDuringMediaAssetInitializationTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionDuringMediaAssetInitializationTest.php @@ -23,9 +23,19 @@ */ class GetByIdExceptionDuringMediaAssetInitializationTest extends \PHPUnit\Framework\TestCase { - private const MEDIA_ASSET_STUB_ID = 1; - - private const MEDIA_ASSET_DATA = ['id' => 1]; + private const MEDIA_ASSET_STUB_ID = 45; + private const MEDIA_ASSET_DATA = [ + 'id' => 45, + 'path' => 'img.jpg', + 'title' => 'Img', + 'source' => 'Adobe Stock', + 'content_type' => 'image/jpeg', + 'width' => 420, + 'height' => 240, + 'size' => 12877, + 'created_at' => '2020', + 'updated_at' => '2020' + ]; /** * @var GetById|MockObject @@ -47,11 +57,6 @@ class GetByIdExceptionDuringMediaAssetInitializationTest extends \PHPUnit\Framew */ private $selectStub; - /** - * @var Statement|MockObject - */ - private $statementMock; - /** * @var LoggerInterface|MockObject */ @@ -81,8 +86,6 @@ protected function setUp(): void $this->selectStub->method('from')->willReturnSelf(); $this->selectStub->method('where')->willReturnSelf(); $this->adapter->method('select')->willReturn($this->selectStub); - - $this->statementMock = $this->getMockBuilder(\Zend_Db_Statement_Interface::class)->getMock(); } /** @@ -90,10 +93,14 @@ protected function setUp(): void */ public function testErrorDuringMediaAssetInitializationException(): void { - $this->statementMock->method('fetch')->willReturn(self::MEDIA_ASSET_DATA); - $this->adapter->method('query')->willReturn($this->statementMock); - - $this->assetFactory->expects($this->once())->method('create')->willThrowException(new \Exception()); + $statementMock = $this->createMock(\Zend_Db_Statement_Interface::class); + $statementMock->method('fetch') + ->willReturn(self::MEDIA_ASSET_DATA); + $this->adapter->method('query')->willReturn($statementMock); + + $this->assetFactory->expects($this->once()) + ->method('create') + ->willThrowException(new \Exception()); $this->expectException(IntegrationException::class); $this->logger->expects($this->any()) diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionOnGetDataTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionOnGetDataTest.php index f76552487e0f7..19c295424cbf9 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionOnGetDataTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionOnGetDataTest.php @@ -23,9 +23,19 @@ */ class GetByIdExceptionOnGetDataTest extends \PHPUnit\Framework\TestCase { - private const MEDIA_ASSET_STUB_ID = 1; - - private const MEDIA_ASSET_DATA = ['id' => 1]; + private const MEDIA_ASSET_STUB_ID = 45; + private const MEDIA_ASSET_DATA = [ + 'id' => 45, + 'path' => 'img.jpg', + 'title' => 'Img', + 'source' => 'Adobe Stock', + 'content_type' => 'image/jpeg', + 'width' => 420, + 'height' => 240, + 'size' => 12877, + 'created_at' => '2020', + 'updated_at' => '2020' + ]; /** * @var GetById|MockObject diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdSuccessfulTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdSuccessfulTest.php index c9e8416c53156..410dd5bef18c8 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdSuccessfulTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdSuccessfulTest.php @@ -23,9 +23,19 @@ */ class GetByIdSuccessfulTest extends \PHPUnit\Framework\TestCase { - private const MEDIA_ASSET_STUB_ID = 1; - - private const MEDIA_ASSET_DATA = ['id' => 1]; + private const MEDIA_ASSET_STUB_ID = 45; + private const MEDIA_ASSET_DATA = [ + 'id' => 45, + 'path' => 'img.jpg', + 'title' => 'Img', + 'source' => 'Adobe Stock', + 'content_type' => 'image/jpeg', + 'width' => 420, + 'height' => 240, + 'size' => 12877, + 'created_at' => '2020', + 'updated_at' => '2020' + ]; /** * @var GetById|MockObject diff --git a/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/GetAssetKeywordsTest.php b/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/GetAssetKeywordsTest.php index 0d2d5269c766d..930068aebb3fe 100644 --- a/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/GetAssetKeywordsTest.php +++ b/app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/GetAssetKeywordsTest.php @@ -83,9 +83,32 @@ public function testFind(array $databaseQueryResult, int $expectedNumberOfFoundK public function casesProvider(): array { return [ - 'not_found' => [[],0], - 'find_one_keyword' => [['keywordRawData'],1], - 'find_several_keywords' => [['keywordRawData', 'keywordRawData'],2], + 'not_found' => [ + [], + 0 + ], + 'find_one_keyword' => [ + [ + [ + 'id' => 1, + 'keyword' => 'keywordRawData' + ] + ], + 1 + ], + 'find_several_keywords' => [ + [ + [ + 'id' => 1, + 'keyword' => 'keywordRawData' + ], + [ + 'id' => 2, + 'keyword' => 'keywordRawData2' + ] + ], + 2 + ], ]; } From 21955c58a037aebf08e8d7968c75673af6833ce7 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Sat, 18 Apr 2020 19:58:16 +0100 Subject: [PATCH 171/177] Fixed integration tests --- app/code/Magento/MediaGallery/Model/Asset.php | 1 + .../Keyword/Command/SaveAssetKeywords.php | 2 +- .../MediaGallery/Model/AssetEndToEndTest.php | 7 ++++- .../Model/ResourceModel/AssetsTest.php | 29 +++++++++++++------ .../MediaGallery/_files/media_asset.php | 7 ++++- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/MediaGallery/Model/Asset.php b/app/code/Magento/MediaGallery/Model/Asset.php index ff6ba8e372024..0e20d6432beee 100644 --- a/app/code/Magento/MediaGallery/Model/Asset.php +++ b/app/code/Magento/MediaGallery/Model/Asset.php @@ -13,6 +13,7 @@ /** * Media Gallery Asset + * @SuppressWarnings(PHPMD.ExcessiveParameterList */ class Asset implements AssetInterface { diff --git a/app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetKeywords.php b/app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetKeywords.php index d3a5eab36de06..f21db25bac767 100644 --- a/app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetKeywords.php +++ b/app/code/Magento/MediaGallery/Model/Keyword/Command/SaveAssetKeywords.php @@ -17,7 +17,7 @@ use Psr\Log\LoggerInterface; /** - * Save asset keywords + * Save media asset keywords to database * @deprecated use \Magento\MediaGalleryApi\Api\SaveAssetKeywordsInterface instead */ class SaveAssetKeywords implements SaveAssetKeywordsInterface diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php index 4d30646d596b6..61b3c22c3ca54 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/AssetEndToEndTest.php @@ -106,7 +106,12 @@ public function testExecute(): void $asset = $this->assetFactory->create( [ 'path' => 'fruit.jpg', - 'contentType' => 'image' + 'title' => 'Img', + 'source' => 'Local', + 'contentType' => 'image/jpeg', + 'width' => 420, + 'height' => 240, + 'size' => 12877 ] ); $this->saveAssets->execute([$asset]); diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php index 8af8a31356dd3..8aec9454951f9 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/Model/ResourceModel/AssetsTest.php @@ -104,7 +104,12 @@ public function assetsDataProvider(): array 'assetsData' => [ 'asset1' => [ 'path' => 'fruit.jpg', - 'contentType' => 'image' + 'title' => 'Img', + 'source' => 'Local', + 'contentType' => 'image/jpeg', + 'width' => 420, + 'height' => 240, + 'size' => 12877 ] ] ], @@ -112,11 +117,21 @@ public function assetsDataProvider(): array 'assetsData' => [ 'asset1' => [ 'path' => 'image.jpg', - 'contentType' => 'image' + 'title' => 'Img', + 'source' => 'Local', + 'contentType' => 'image/jpeg', + 'width' => 420, + 'height' => 240, + 'size' => 12877 ], 'asset2' => [ - 'path' => 'image2.png', - 'contentType' => 'image' + 'path' => 'image2.jpg', + 'title' => 'Img', + 'source' => 'Local', + 'contentType' => 'image/jpeg', + 'width' => 420, + 'height' => 240, + 'size' => 12877 ] ] ], @@ -133,11 +148,7 @@ private function getAssets(array $assetsData): array { $assets = []; foreach ($assetsData as $assetData) { - $assets[] = $this->assetFactory->create( - [ - 'data' => $assetData - ] - ); + $assets[] = $this->assetFactory->create($assetData); } return $assets; } diff --git a/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php index f332bfde37422..0a2a00c254975 100644 --- a/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php +++ b/dev/tests/integration/testsuite/Magento/MediaGallery/_files/media_asset.php @@ -18,7 +18,12 @@ [ 'id' => 2020, 'path' => 'testDirectory/path.jpg', - 'contentType' => 'image' + 'contentType' => 'image', + 'title' => 'Img', + 'source' => 'Local', + 'width' => 420, + 'height' => 240, + 'size' => 12877 ] ); /** @var SaveInterface $mediaSave */ From c0065901fdb9bdf98a61f62b1aaeed0502089b8d Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Sat, 18 Apr 2020 21:57:25 +0100 Subject: [PATCH 172/177] Added blacklist to directory operations --- app/code/Magento/MediaGallery/Model/Asset.php | 2 +- .../Model/Directory/Command/CreateByPaths.php | 15 ++++++++++++++- .../Model/Directory/Command/DeleteByPaths.php | 15 ++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/MediaGallery/Model/Asset.php b/app/code/Magento/MediaGallery/Model/Asset.php index 0e20d6432beee..78b9477a70b08 100644 --- a/app/code/Magento/MediaGallery/Model/Asset.php +++ b/app/code/Magento/MediaGallery/Model/Asset.php @@ -13,7 +13,7 @@ /** * Media Gallery Asset - * @SuppressWarnings(PHPMD.ExcessiveParameterList + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ class Asset implements AssetInterface { diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php index cba101a18a39a..bfb6b677ce19c 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/CreateByPaths.php @@ -10,6 +10,7 @@ use Magento\Cms\Model\Wysiwyg\Images\Storage; use Magento\Framework\Exception\CouldNotSaveException; use Magento\MediaGalleryApi\Api\CreateDirectoriesByPathsInterface; +use Magento\MediaGalleryApi\Api\IsPathBlacklistedInterface; use Psr\Log\LoggerInterface; /** @@ -27,16 +28,24 @@ class CreateByPaths implements CreateDirectoriesByPathsInterface */ private $storage; + /** + * @var IsPathBlacklistedInterface + */ + private $isPathBlacklisted; + /** * @param LoggerInterface $logger * @param Storage $storage + * @param IsPathBlacklistedInterface $isPathBlacklisted */ public function __construct( LoggerInterface $logger, - Storage $storage + Storage $storage, + IsPathBlacklistedInterface $isPathBlacklisted ) { $this->logger = $logger; $this->storage = $storage; + $this->isPathBlacklisted = $isPathBlacklisted; } /** @@ -46,6 +55,10 @@ public function execute(array $paths): void { $failedPaths = []; foreach ($paths as $path) { + if ($this->isPathBlacklisted->execute($path)) { + $failedPaths[] = $path; + continue; + } try { //phpcs:ignore Magento2.Functions.DiscouragedFunction $name = basename($path); diff --git a/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php b/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php index 10360e3d98926..d46fb854fff22 100644 --- a/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php +++ b/app/code/Magento/MediaGallery/Model/Directory/Command/DeleteByPaths.php @@ -10,6 +10,7 @@ use Magento\Cms\Model\Wysiwyg\Images\Storage; use Magento\Framework\Exception\CouldNotDeleteException; use Magento\MediaGalleryApi\Api\DeleteDirectoriesByPathsInterface; +use Magento\MediaGalleryApi\Api\IsPathBlacklistedInterface; use Psr\Log\LoggerInterface; /** @@ -27,16 +28,24 @@ class DeleteByPaths implements DeleteDirectoriesByPathsInterface */ private $storage; + /** + * @var IsPathBlacklistedInterface + */ + private $isPathBlacklisted; + /** * @param LoggerInterface $logger * @param Storage $storage + * @param IsPathBlacklistedInterface $isPathBlacklisted */ public function __construct( LoggerInterface $logger, - Storage $storage + Storage $storage, + IsPathBlacklistedInterface $isPathBlacklisted ) { $this->logger = $logger; $this->storage = $storage; + $this->isPathBlacklisted = $isPathBlacklisted; } /** @@ -46,6 +55,10 @@ public function execute(array $paths): void { $failedPaths = []; foreach ($paths as $path) { + if ($this->isPathBlacklisted->execute($path)) { + $failedPaths[] = $path; + continue; + } try { $this->storage->deleteDirectory($this->storage->getCmsWysiwygImages()->getStorageRoot() . $path); } catch (\Exception $exception) { From 8b3c9b1df5c8584e757670a8d5b9cfc307a5b6f5 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Sun, 19 Apr 2020 12:36:29 +0100 Subject: [PATCH 173/177] Added MediaGalleryCatalog to composer.json --- composer.json | 1 + composer.lock | 708 +++++++++++++++++++++++++++++--------------------- 2 files changed, 413 insertions(+), 296 deletions(-) diff --git a/composer.json b/composer.json index 5223fa2a0aca4..63876202fbed8 100644 --- a/composer.json +++ b/composer.json @@ -195,6 +195,7 @@ "magento/module-layered-navigation": "*", "magento/module-media-gallery": "*", "magento/module-media-gallery-api": "*", + "magento/module-media-gallery-catalog": "*", "magento/module-media-storage": "*", "magento/module-message-queue": "*", "magento/module-msrp": "*", diff --git a/composer.lock b/composer.lock index 37849c7c21a29..f1095dc95b150 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1f11bed01d000a3d3eeda8b462e29f75", + "content-hash": "b7ee4a27d76ea68e295d5025c986854d", "packages": [ { "name": "braintree/braintree_php", @@ -201,16 +201,16 @@ }, { "name": "composer/ca-bundle", - "version": "1.2.6", + "version": "1.2.7", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "47fe531de31fca4a1b997f87308e7d7804348f7e" + "reference": "95c63ab2117a72f48f5a55da9740a3273d45b7fd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/47fe531de31fca4a1b997f87308e7d7804348f7e", - "reference": "47fe531de31fca4a1b997f87308e7d7804348f7e", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/95c63ab2117a72f48f5a55da9740a3273d45b7fd", + "reference": "95c63ab2117a72f48f5a55da9740a3273d45b7fd", "shasum": "" }, "require": { @@ -253,20 +253,30 @@ "ssl", "tls" ], - "time": "2020-01-13T10:02:55+00:00" + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2020-04-08T08:27:21+00:00" }, { "name": "composer/composer", - "version": "1.10.1", + "version": "1.10.5", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "b912a45da3e2b22f5cb5a23e441b697a295ba011" + "reference": "7a4d5b6aa30d2118af27c04f5e897b57156ccfa9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/b912a45da3e2b22f5cb5a23e441b697a295ba011", - "reference": "b912a45da3e2b22f5cb5a23e441b697a295ba011", + "url": "https://api.github.com/repos/composer/composer/zipball/7a4d5b6aa30d2118af27c04f5e897b57156ccfa9", + "reference": "7a4d5b6aa30d2118af27c04f5e897b57156ccfa9", "shasum": "" }, "require": { @@ -333,7 +343,7 @@ "dependency", "package" ], - "time": "2020-03-13T19:34:27+00:00" + "time": "2020-04-10T09:44:22+00:00" }, { "name": "composer/semver", @@ -698,23 +708,24 @@ }, { "name": "guzzlehttp/guzzle", - "version": "6.5.2", + "version": "6.5.3", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "43ece0e75098b7ecd8d13918293029e555a50f82" + "reference": "aab4ebd862aa7d04f01a4b51849d657db56d882e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/43ece0e75098b7ecd8d13918293029e555a50f82", - "reference": "43ece0e75098b7ecd8d13918293029e555a50f82", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/aab4ebd862aa7d04f01a4b51849d657db56d882e", + "reference": "aab4ebd862aa7d04f01a4b51849d657db56d882e", "shasum": "" }, "require": { "ext-json": "*", "guzzlehttp/promises": "^1.0", "guzzlehttp/psr7": "^1.6.1", - "php": ">=5.5" + "php": ">=5.5", + "symfony/polyfill-intl-idn": "^1.11" }, "require-dev": { "ext-curl": "*", @@ -722,7 +733,6 @@ "psr/log": "^1.1" }, "suggest": { - "ext-intl": "Required for Internationalized Domain Name (IDN) support", "psr/log": "Required for using the Log middleware" }, "type": "library", @@ -761,7 +771,7 @@ "rest", "web service" ], - "time": "2019-12-23T11:57:10+00:00" + "time": "2020-04-18T10:38:46+00:00" }, { "name": "guzzlehttp/promises", @@ -1243,16 +1253,16 @@ }, { "name": "laminas/laminas-db", - "version": "2.11.2", + "version": "2.11.3", "source": { "type": "git", "url": "https://github.com/laminas/laminas-db.git", - "reference": "76f9527da996c2fef32ef1f3a939e18ca5e9d962" + "reference": "6c4238918b9204db1eb8cafae2c1940d40f4c007" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-db/zipball/76f9527da996c2fef32ef1f3a939e18ca5e9d962", - "reference": "76f9527da996c2fef32ef1f3a939e18ca5e9d962", + "url": "https://api.github.com/repos/laminas/laminas-db/zipball/6c4238918b9204db1eb8cafae2c1940d40f4c007", + "reference": "6c4238918b9204db1eb8cafae2c1940d40f4c007", "shasum": "" }, "require": { @@ -1261,7 +1271,7 @@ "php": "^5.6 || ^7.0" }, "replace": { - "zendframework/zend-db": "self.version" + "zendframework/zend-db": "^2.11.0" }, "require-dev": { "laminas/laminas-coding-standard": "~1.0.0", @@ -1301,7 +1311,7 @@ "db", "laminas" ], - "time": "2020-01-14T13:07:26+00:00" + "time": "2020-03-29T12:08:51+00:00" }, { "name": "laminas/laminas-dependency-plugin", @@ -1402,16 +1412,16 @@ }, { "name": "laminas/laminas-diactoros", - "version": "1.8.7p1", + "version": "1.8.7p2", "source": { "type": "git", "url": "https://github.com/laminas/laminas-diactoros.git", - "reference": "56a9aca1f89231763d24d2ae13531b97fa5f4029" + "reference": "6991c1af7c8d2c8efee81b22ba97024781824aaa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/56a9aca1f89231763d24d2ae13531b97fa5f4029", - "reference": "56a9aca1f89231763d24d2ae13531b97fa5f4029", + "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/6991c1af7c8d2c8efee81b22ba97024781824aaa", + "reference": "6991c1af7c8d2c8efee81b22ba97024781824aaa", "shasum": "" }, "require": { @@ -1423,7 +1433,7 @@ "psr/http-message-implementation": "1.0" }, "replace": { - "zendframework/zend-diactoros": "self.version" + "zendframework/zend-diactoros": "~1.8.7.0" }, "require-dev": { "ext-dom": "*", @@ -1473,7 +1483,7 @@ "psr", "psr-7" ], - "time": "2020-01-07T19:25:17+00:00" + "time": "2020-03-23T15:28:28+00:00" }, { "name": "laminas/laminas-escaper", @@ -1584,16 +1594,16 @@ }, { "name": "laminas/laminas-feed", - "version": "2.12.1", + "version": "2.12.2", "source": { "type": "git", "url": "https://github.com/laminas/laminas-feed.git", - "reference": "c9356994eb80d0f6b46d7e12ba048d450bf0cd72" + "reference": "8a193ac96ebcb3e16b6ee754ac2a889eefacb654" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-feed/zipball/c9356994eb80d0f6b46d7e12ba048d450bf0cd72", - "reference": "c9356994eb80d0f6b46d7e12ba048d450bf0cd72", + "url": "https://api.github.com/repos/laminas/laminas-feed/zipball/8a193ac96ebcb3e16b6ee754ac2a889eefacb654", + "reference": "8a193ac96ebcb3e16b6ee754ac2a889eefacb654", "shasum": "" }, "require": { @@ -1605,7 +1615,7 @@ "php": "^5.6 || ^7.0" }, "replace": { - "zendframework/zend-feed": "self.version" + "zendframework/zend-feed": "^2.12.0" }, "require-dev": { "laminas/laminas-cache": "^2.7.2", @@ -1647,20 +1657,20 @@ "feed", "laminas" ], - "time": "2020-03-23T10:40:31+00:00" + "time": "2020-03-29T12:36:29+00:00" }, { "name": "laminas/laminas-filter", - "version": "2.9.3", + "version": "2.9.4", "source": { "type": "git", "url": "https://github.com/laminas/laminas-filter.git", - "reference": "52b5cdbef8902280996e687e7352a648a8e22f31" + "reference": "3c4476e772a062cef7531c6793377ae585d89c82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-filter/zipball/52b5cdbef8902280996e687e7352a648a8e22f31", - "reference": "52b5cdbef8902280996e687e7352a648a8e22f31", + "url": "https://api.github.com/repos/laminas/laminas-filter/zipball/3c4476e772a062cef7531c6793377ae585d89c82", + "reference": "3c4476e772a062cef7531c6793377ae585d89c82", "shasum": "" }, "require": { @@ -1672,7 +1682,7 @@ "laminas/laminas-validator": "<2.10.1" }, "replace": { - "zendframework/zend-filter": "self.version" + "zendframework/zend-filter": "^2.9.2" }, "require-dev": { "laminas/laminas-coding-standard": "~1.0.0", @@ -1716,20 +1726,20 @@ "filter", "laminas" ], - "time": "2020-01-07T20:43:53+00:00" + "time": "2020-03-29T12:41:29+00:00" }, { "name": "laminas/laminas-form", - "version": "2.14.4", + "version": "2.14.5", "source": { "type": "git", "url": "https://github.com/laminas/laminas-form.git", - "reference": "8b985f74bfe32910edb4ba9503877c4310228cd2" + "reference": "3e22e09751cf6ae031be87a44e092e7925ce5b7b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-form/zipball/8b985f74bfe32910edb4ba9503877c4310228cd2", - "reference": "8b985f74bfe32910edb4ba9503877c4310228cd2", + "url": "https://api.github.com/repos/laminas/laminas-form/zipball/3e22e09751cf6ae031be87a44e092e7925ce5b7b", + "reference": "3e22e09751cf6ae031be87a44e092e7925ce5b7b", "shasum": "" }, "require": { @@ -1740,7 +1750,7 @@ "php": "^5.6 || ^7.0" }, "replace": { - "zendframework/zend-form": "self.version" + "zendframework/zend-form": "^2.14.3" }, "require-dev": { "doctrine/annotations": "~1.0", @@ -1798,7 +1808,7 @@ "form", "laminas" ], - "time": "2020-03-18T22:38:54+00:00" + "time": "2020-03-29T12:46:16+00:00" }, { "name": "laminas/laminas-http", @@ -1924,16 +1934,16 @@ }, { "name": "laminas/laminas-i18n", - "version": "2.10.2", + "version": "2.10.3", "source": { "type": "git", "url": "https://github.com/laminas/laminas-i18n.git", - "reference": "9699c98d97d2f519def3da8d4128dfe6e6ad11bf" + "reference": "94ff957a1366f5be94f3d3a9b89b50386649e3ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-i18n/zipball/9699c98d97d2f519def3da8d4128dfe6e6ad11bf", - "reference": "9699c98d97d2f519def3da8d4128dfe6e6ad11bf", + "url": "https://api.github.com/repos/laminas/laminas-i18n/zipball/94ff957a1366f5be94f3d3a9b89b50386649e3ae", + "reference": "94ff957a1366f5be94f3d3a9b89b50386649e3ae", "shasum": "" }, "require": { @@ -1946,7 +1956,7 @@ "phpspec/prophecy": "<1.9.0" }, "replace": { - "zendframework/zend-i18n": "self.version" + "zendframework/zend-i18n": "^2.10.1" }, "require-dev": { "laminas/laminas-cache": "^2.6.1", @@ -1995,7 +2005,7 @@ "i18n", "laminas" ], - "time": "2020-03-20T11:57:14+00:00" + "time": "2020-03-29T12:51:08+00:00" }, { "name": "laminas/laminas-inputfilter", @@ -2362,16 +2372,16 @@ }, { "name": "laminas/laminas-mime", - "version": "2.7.3", + "version": "2.7.4", "source": { "type": "git", "url": "https://github.com/laminas/laminas-mime.git", - "reference": "e844abb02e868fae154207929190292ad25057cc" + "reference": "e45a7d856bf7b4a7b5bd00d6371f9961dc233add" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-mime/zipball/e844abb02e868fae154207929190292ad25057cc", - "reference": "e844abb02e868fae154207929190292ad25057cc", + "url": "https://api.github.com/repos/laminas/laminas-mime/zipball/e45a7d856bf7b4a7b5bd00d6371f9961dc233add", + "reference": "e45a7d856bf7b4a7b5bd00d6371f9961dc233add", "shasum": "" }, "require": { @@ -2380,7 +2390,7 @@ "php": "^5.6 || ^7.0" }, "replace": { - "zendframework/zend-mime": "self.version" + "zendframework/zend-mime": "^2.7.2" }, "require-dev": { "laminas/laminas-coding-standard": "~1.0.0", @@ -2412,7 +2422,7 @@ "laminas", "mime" ], - "time": "2020-03-06T08:38:03+00:00" + "time": "2020-03-29T13:12:07+00:00" }, { "name": "laminas/laminas-modulemanager", @@ -2797,16 +2807,16 @@ }, { "name": "laminas/laminas-session", - "version": "2.9.2", + "version": "2.9.3", "source": { "type": "git", "url": "https://github.com/laminas/laminas-session.git", - "reference": "fdba34c1b257235dba2fff6ed4df1844390f85f6" + "reference": "519e8966146536cd97c1cc3d59a21b095fb814d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-session/zipball/fdba34c1b257235dba2fff6ed4df1844390f85f6", - "reference": "fdba34c1b257235dba2fff6ed4df1844390f85f6", + "url": "https://api.github.com/repos/laminas/laminas-session/zipball/519e8966146536cd97c1cc3d59a21b095fb814d7", + "reference": "519e8966146536cd97c1cc3d59a21b095fb814d7", "shasum": "" }, "require": { @@ -2816,7 +2826,7 @@ "php": "^5.6 || ^7.0" }, "replace": { - "zendframework/zend-session": "self.version" + "zendframework/zend-session": "^2.9.1" }, "require-dev": { "container-interop/container-interop": "^1.1", @@ -2864,7 +2874,7 @@ "laminas", "session" ], - "time": "2020-03-06T09:44:45+00:00" + "time": "2020-03-29T13:26:04+00:00" }, { "name": "laminas/laminas-soap", @@ -3078,16 +3088,16 @@ }, { "name": "laminas/laminas-validator", - "version": "2.13.2", + "version": "2.13.4", "source": { "type": "git", "url": "https://github.com/laminas/laminas-validator.git", - "reference": "e7bf6a2eedc0508ebde0ebc66662efeb0abbcb2c" + "reference": "93593684e70b8ed1e870cacd34ca32b0c0ace185" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/e7bf6a2eedc0508ebde0ebc66662efeb0abbcb2c", - "reference": "e7bf6a2eedc0508ebde0ebc66662efeb0abbcb2c", + "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/93593684e70b8ed1e870cacd34ca32b0c0ace185", + "reference": "93593684e70b8ed1e870cacd34ca32b0c0ace185", "shasum": "" }, "require": { @@ -3097,7 +3107,7 @@ "php": "^7.1" }, "replace": { - "zendframework/zend-validator": "self.version" + "zendframework/zend-validator": "^2.13.0" }, "require-dev": { "laminas/laminas-cache": "^2.6.1", @@ -3153,7 +3163,7 @@ "laminas", "validator" ], - "time": "2020-03-16T11:38:27+00:00" + "time": "2020-03-31T18:57:01+00:00" }, { "name": "laminas/laminas-view", @@ -3248,16 +3258,16 @@ }, { "name": "laminas/laminas-zendframework-bridge", - "version": "1.0.2", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/laminas/laminas-zendframework-bridge.git", - "reference": "faf68f6109ceeff24241226033ab59640c7eb63b" + "reference": "bfbbdb6c998d50dbf69d2187cb78a5f1fa36e1e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/faf68f6109ceeff24241226033ab59640c7eb63b", - "reference": "faf68f6109ceeff24241226033ab59640c7eb63b", + "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/bfbbdb6c998d50dbf69d2187cb78a5f1fa36e1e9", + "reference": "bfbbdb6c998d50dbf69d2187cb78a5f1fa36e1e9", "shasum": "" }, "require": { @@ -3296,7 +3306,7 @@ "laminas", "zf" ], - "time": "2020-03-26T16:07:12+00:00" + "time": "2020-04-03T16:01:00+00:00" }, { "name": "magento/composer", @@ -3863,16 +3873,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "2.0.26", + "version": "2.0.27", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "09655fcc1f8bab65727be036b28f6f20311c126c" + "reference": "34620af4df7d1988d8f0d7e91f6c8a3bf931d8dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/09655fcc1f8bab65727be036b28f6f20311c126c", - "reference": "09655fcc1f8bab65727be036b28f6f20311c126c", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/34620af4df7d1988d8f0d7e91f6c8a3bf931d8dc", + "reference": "34620af4df7d1988d8f0d7e91f6c8a3bf931d8dc", "shasum": "" }, "require": { @@ -3951,7 +3961,7 @@ "x.509", "x509" ], - "time": "2020-03-13T04:15:39+00:00" + "time": "2020-04-04T23:17:33+00:00" }, { "name": "psr/container", @@ -4362,16 +4372,16 @@ }, { "name": "symfony/console", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "4fa15ae7be74e53f6ec8c83ed403b97e23b665e9" + "reference": "10bb3ee3c97308869d53b3e3d03f6ac23ff985f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/4fa15ae7be74e53f6ec8c83ed403b97e23b665e9", - "reference": "4fa15ae7be74e53f6ec8c83ed403b97e23b665e9", + "url": "https://api.github.com/repos/symfony/console/zipball/10bb3ee3c97308869d53b3e3d03f6ac23ff985f7", + "reference": "10bb3ee3c97308869d53b3e3d03f6ac23ff985f7", "shasum": "" }, "require": { @@ -4434,20 +4444,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2020-02-24T13:10:00+00:00" + "time": "2020-03-30T11:41:10+00:00" }, { "name": "symfony/css-selector", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "d0a6dd288fa8848dcc3d1f58b94de6a7cc5d2d22" + "reference": "afc26133a6fbdd4f8842e38893e0ee4685c7c94b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/d0a6dd288fa8848dcc3d1f58b94de6a7cc5d2d22", - "reference": "d0a6dd288fa8848dcc3d1f58b94de6a7cc5d2d22", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/afc26133a6fbdd4f8842e38893e0ee4685c7c94b", + "reference": "afc26133a6fbdd4f8842e38893e0ee4685c7c94b", "shasum": "" }, "require": { @@ -4487,20 +4497,34 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2020-02-04T09:01:01+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "4ad8e149799d3128621a3a1f70e92b9897a8930d" + "reference": "abc8e3618bfdb55e44c8c6a00abd333f831bbfed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4ad8e149799d3128621a3a1f70e92b9897a8930d", - "reference": "4ad8e149799d3128621a3a1f70e92b9897a8930d", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/abc8e3618bfdb55e44c8c6a00abd333f831bbfed", + "reference": "abc8e3618bfdb55e44c8c6a00abd333f831bbfed", "shasum": "" }, "require": { @@ -4557,7 +4581,21 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2020-02-04T09:32:40+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -4619,16 +4657,16 @@ }, { "name": "symfony/filesystem", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "266c9540b475f26122b61ef8b23dd9198f5d1cfd" + "reference": "fe297193bf2e6866ed900ed2d5869362768df6a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/266c9540b475f26122b61ef8b23dd9198f5d1cfd", - "reference": "266c9540b475f26122b61ef8b23dd9198f5d1cfd", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/fe297193bf2e6866ed900ed2d5869362768df6a7", + "reference": "fe297193bf2e6866ed900ed2d5869362768df6a7", "shasum": "" }, "require": { @@ -4665,20 +4703,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2020-01-21T08:20:44+00:00" + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/finder", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "ea69c129aed9fdeca781d4b77eb20b62cf5d5357" + "reference": "5729f943f9854c5781984ed4907bbb817735776b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ea69c129aed9fdeca781d4b77eb20b62cf5d5357", - "reference": "ea69c129aed9fdeca781d4b77eb20b62cf5d5357", + "url": "https://api.github.com/repos/symfony/finder/zipball/5729f943f9854c5781984ed4907bbb817735776b", + "reference": "5729f943f9854c5781984ed4907bbb817735776b", "shasum": "" }, "require": { @@ -4714,7 +4752,21 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2020-02-14T07:42:58+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/polyfill-ctype", @@ -4774,6 +4826,68 @@ ], "time": "2020-02-27T09:26:54+00:00" }, + { + "name": "symfony/polyfill-intl-idn", + "version": "v1.15.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-idn.git", + "reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf", + "reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/polyfill-mbstring": "^1.3", + "symfony/polyfill-php72": "^1.10" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.15-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Intl\\Idn\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Laurent Bassin", + "email": "laurent@bassin.info" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "idn", + "intl", + "polyfill", + "portable", + "shim" + ], + "time": "2020-03-09T19:04:49+00:00" + }, { "name": "symfony/polyfill-mbstring", "version": "v1.15.0", @@ -4833,6 +4947,61 @@ ], "time": "2020-03-09T19:04:49+00:00" }, + { + "name": "symfony/polyfill-php72", + "version": "v1.15.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "37b0976c78b94856543260ce09b460a7bc852747" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/37b0976c78b94856543260ce09b460a7bc852747", + "reference": "37b0976c78b94856543260ce09b460a7bc852747", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.15-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2020-02-27T09:26:54+00:00" + }, { "name": "symfony/polyfill-php73", "version": "v1.15.0", @@ -4893,16 +5062,16 @@ }, { "name": "symfony/process", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "bf9166bac906c9e69fb7a11d94875e7ced97bcd7" + "reference": "3e40e87a20eaf83a1db825e1fa5097ae89042db3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/bf9166bac906c9e69fb7a11d94875e7ced97bcd7", - "reference": "bf9166bac906c9e69fb7a11d94875e7ced97bcd7", + "url": "https://api.github.com/repos/symfony/process/zipball/3e40e87a20eaf83a1db825e1fa5097ae89042db3", + "reference": "3e40e87a20eaf83a1db825e1fa5097ae89042db3", "shasum": "" }, "require": { @@ -4938,7 +5107,7 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2020-02-07T20:06:44+00:00" + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/service-contracts", @@ -5414,16 +5583,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.133.45", + "version": "3.134.8", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "928a23e2ee7e195a66f93d0758895e26958c3b7d" + "reference": "8a9b598a0ede2165be5988899dcebead6fcc4d41" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/928a23e2ee7e195a66f93d0758895e26958c3b7d", - "reference": "928a23e2ee7e195a66f93d0758895e26958c3b7d", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/8a9b598a0ede2165be5988899dcebead6fcc4d41", + "reference": "8a9b598a0ede2165be5988899dcebead6fcc4d41", "shasum": "" }, "require": { @@ -5494,7 +5663,7 @@ "s3", "sdk" ], - "time": "2020-03-26T18:12:15+00:00" + "time": "2020-04-17T18:11:57+00:00" }, { "name": "behat/gherkin", @@ -5969,20 +6138,21 @@ }, { "name": "doctrine/annotations", - "version": "v1.8.0", + "version": "1.10.1", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc" + "reference": "5eb79f3dbdffed6544e1fc287572c0f462bd29bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/904dca4eb10715b92569fbcd79e201d5c349b6bc", - "reference": "904dca4eb10715b92569fbcd79e201d5c349b6bc", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/5eb79f3dbdffed6544e1fc287572c0f462bd29bb", + "reference": "5eb79f3dbdffed6544e1fc287572c0f462bd29bb", "shasum": "" }, "require": { "doctrine/lexer": "1.*", + "ext-tokenizer": "*", "php": "^7.1" }, "require-dev": { @@ -5992,7 +6162,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7.x-dev" + "dev-master": "1.9.x-dev" } }, "autoload": { @@ -6033,7 +6203,7 @@ "docblock", "parser" ], - "time": "2019-10-01T18:55:10+00:00" + "time": "2020-04-02T12:33:25+00:00" }, { "name": "doctrine/cache", @@ -6567,16 +6737,16 @@ }, { "name": "league/flysystem", - "version": "1.0.66", + "version": "1.0.67", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "021569195e15f8209b1c4bebb78bd66aa4f08c21" + "reference": "5b1f36c75c4bdde981294c2a0ebdb437ee6f275e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/021569195e15f8209b1c4bebb78bd66aa4f08c21", - "reference": "021569195e15f8209b1c4bebb78bd66aa4f08c21", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/5b1f36c75c4bdde981294c2a0ebdb437ee6f275e", + "reference": "5b1f36c75c4bdde981294c2a0ebdb437ee6f275e", "shasum": "" }, "require": { @@ -6647,7 +6817,7 @@ "sftp", "storage" ], - "time": "2020-03-17T18:58:12+00:00" + "time": "2020-04-16T13:21:26+00:00" }, { "name": "lusitanian/oauth", @@ -8970,16 +9140,16 @@ }, { "name": "symfony/browser-kit", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "090ce406505149d6852a7c03b0346dec3b8cf612" + "reference": "e4b0dc1b100bf75b5717c5b451397f230a618a42" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/090ce406505149d6852a7c03b0346dec3b8cf612", - "reference": "090ce406505149d6852a7c03b0346dec3b8cf612", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/e4b0dc1b100bf75b5717c5b451397f230a618a42", + "reference": "e4b0dc1b100bf75b5717c5b451397f230a618a42", "shasum": "" }, "require": { @@ -9025,20 +9195,34 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", - "time": "2020-02-23T10:00:59+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-03-28T10:15:50+00:00" }, { "name": "symfony/config", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "cbfef5ae91ccd3b06621c18d58cd355c68c87ae9" + "reference": "3f4a3de1af498ed0ea653d4dc2317794144e6ca4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/cbfef5ae91ccd3b06621c18d58cd355c68c87ae9", - "reference": "cbfef5ae91ccd3b06621c18d58cd355c68c87ae9", + "url": "https://api.github.com/repos/symfony/config/zipball/3f4a3de1af498ed0ea653d4dc2317794144e6ca4", + "reference": "3f4a3de1af498ed0ea653d4dc2317794144e6ca4", "shasum": "" }, "require": { @@ -9089,20 +9273,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2020-02-04T09:32:40+00:00" + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/dependency-injection", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "ebb2e882e8c9e2eb990aa61ddcd389848466e342" + "reference": "755b18859be26b90f4bf63753432d3387458bf31" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/ebb2e882e8c9e2eb990aa61ddcd389848466e342", - "reference": "ebb2e882e8c9e2eb990aa61ddcd389848466e342", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/755b18859be26b90f4bf63753432d3387458bf31", + "reference": "755b18859be26b90f4bf63753432d3387458bf31", "shasum": "" }, "require": { @@ -9162,20 +9346,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2020-02-29T09:50:10+00:00" + "time": "2020-03-30T10:09:30+00:00" }, { "name": "symfony/dom-crawler", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "11dcf08f12f29981bf770f097a5d64d65bce5929" + "reference": "4d0fb3374324071ecdd94898367a3fa4b5563162" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/11dcf08f12f29981bf770f097a5d64d65bce5929", - "reference": "11dcf08f12f29981bf770f097a5d64d65bce5929", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/4d0fb3374324071ecdd94898367a3fa4b5563162", + "reference": "4d0fb3374324071ecdd94898367a3fa4b5563162", "shasum": "" }, "require": { @@ -9223,20 +9407,34 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2020-02-29T10:05:28+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-03-29T19:12:22+00:00" }, { "name": "symfony/http-foundation", - "version": "v5.0.5", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "6f9c2ba72f4295d7ce6cf9f79dbb18036291d335" + "reference": "26fb006a2c7b6cdd23d52157b05f8414ffa417b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/6f9c2ba72f4295d7ce6cf9f79dbb18036291d335", - "reference": "6f9c2ba72f4295d7ce6cf9f79dbb18036291d335", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/26fb006a2c7b6cdd23d52157b05f8414ffa417b6", + "reference": "26fb006a2c7b6cdd23d52157b05f8414ffa417b6", "shasum": "" }, "require": { @@ -9278,20 +9476,20 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", - "time": "2020-02-14T07:43:07+00:00" + "time": "2020-03-30T14:14:32+00:00" }, { "name": "symfony/mime", - "version": "v5.0.5", + "version": "v5.0.7", "source": { "type": "git", "url": "https://github.com/symfony/mime.git", - "reference": "9b3e5b5e58c56bbd76628c952d2b78556d305f3c" + "reference": "481b7d6da88922fb1e0d86a943987722b08f3955" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/9b3e5b5e58c56bbd76628c952d2b78556d305f3c", - "reference": "9b3e5b5e58c56bbd76628c952d2b78556d305f3c", + "url": "https://api.github.com/repos/symfony/mime/zipball/481b7d6da88922fb1e0d86a943987722b08f3955", + "reference": "481b7d6da88922fb1e0d86a943987722b08f3955", "shasum": "" }, "require": { @@ -9340,20 +9538,20 @@ "mime", "mime-type" ], - "time": "2020-02-04T09:41:09+00:00" + "time": "2020-03-27T16:56:45+00:00" }, { "name": "symfony/options-resolver", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "9a02d6662660fe7bfadad63b5f0b0718d4c8b6b0" + "reference": "9072131b5e6e21203db3249c7db26b52897bc73e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/9a02d6662660fe7bfadad63b5f0b0718d4c8b6b0", - "reference": "9a02d6662660fe7bfadad63b5f0b0718d4c8b6b0", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/9072131b5e6e21203db3249c7db26b52897bc73e", + "reference": "9072131b5e6e21203db3249c7db26b52897bc73e", "shasum": "" }, "require": { @@ -9394,69 +9592,21 @@ "configuration", "options" ], - "time": "2020-01-04T13:00:46+00:00" - }, - { - "name": "symfony/polyfill-intl-idn", - "version": "v1.15.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf", - "reference": "47bd6aa45beb1cd7c6a16b7d1810133b728bdfcf", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "symfony/polyfill-mbstring": "^1.3", - "symfony/polyfill-php72": "^1.10" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.15-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Idn\\": "" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ { - "name": "Laurent Bassin", - "email": "laurent@bassin.info" + "url": "https://github.com/fabpot", + "type": "github" }, { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" } ], - "description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "idn", - "intl", - "polyfill", - "portable", - "shim" - ], - "time": "2020-03-09T19:04:49+00:00" + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/polyfill-php70", @@ -9517,73 +9667,18 @@ ], "time": "2020-02-27T09:26:54+00:00" }, - { - "name": "symfony/polyfill-php72", - "version": "v1.15.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "37b0976c78b94856543260ce09b460a7bc852747" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/37b0976c78b94856543260ce09b460a7bc852747", - "reference": "37b0976c78b94856543260ce09b460a7bc852747", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.15-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php72\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "time": "2020-02-27T09:26:54+00:00" - }, { "name": "symfony/stopwatch", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "abc08d7c48987829bac301347faa10f7e8bbf4fb" + "reference": "e0324d3560e4128270e3f08617480d9233d81cfc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/abc08d7c48987829bac301347faa10f7e8bbf4fb", - "reference": "abc08d7c48987829bac301347faa10f7e8bbf4fb", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/e0324d3560e4128270e3f08617480d9233d81cfc", + "reference": "e0324d3560e4128270e3f08617480d9233d81cfc", "shasum": "" }, "require": { @@ -9620,20 +9715,34 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2020-01-04T13:00:46+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-03-27T16:54:36+00:00" }, { "name": "symfony/yaml", - "version": "v4.4.5", + "version": "v4.4.7", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "94d005c176db2080e98825d98e01e8b311a97a88" + "reference": "ef166890d821518106da3560086bfcbeb4fadfec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/94d005c176db2080e98825d98e01e8b311a97a88", - "reference": "94d005c176db2080e98825d98e01e8b311a97a88", + "url": "https://api.github.com/repos/symfony/yaml/zipball/ef166890d821518106da3560086bfcbeb4fadfec", + "reference": "ef166890d821518106da3560086bfcbeb4fadfec", "shasum": "" }, "require": { @@ -9679,7 +9788,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2020-02-03T10:46:43+00:00" + "time": "2020-03-30T11:41:10+00:00" }, { "name": "theseer/fdomdocument", @@ -9763,16 +9872,16 @@ }, { "name": "vlucas/phpdotenv", - "version": "v2.6.1", + "version": "v2.6.3", "source": { "type": "git", "url": "https://github.com/vlucas/phpdotenv.git", - "reference": "2a7dcf7e3e02dc5e701004e51a6f304b713107d5" + "reference": "df4c4d08a639be4ef5d6d1322868f9e477553679" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/2a7dcf7e3e02dc5e701004e51a6f304b713107d5", - "reference": "2a7dcf7e3e02dc5e701004e51a6f304b713107d5", + "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/df4c4d08a639be4ef5d6d1322868f9e477553679", + "reference": "df4c4d08a639be4ef5d6d1322868f9e477553679", "shasum": "" }, "require": { @@ -9780,8 +9889,14 @@ "symfony/polyfill-ctype": "^1.9" }, "require-dev": { + "ext-filter": "*", + "ext-pcre": "*", "phpunit/phpunit": "^4.8.35 || ^5.0" }, + "suggest": { + "ext-filter": "Required to use the boolean validator.", + "ext-pcre": "Required to use most of the library." + }, "type": "library", "extra": { "branch-alias": { @@ -9810,20 +9925,20 @@ "env", "environment" ], - "time": "2019-01-29T11:11:52+00:00" + "time": "2020-04-12T15:11:38+00:00" }, { "name": "webmozart/assert", - "version": "1.7.0", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "aed98a490f9a8f78468232db345ab9cf606cf598" + "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/aed98a490f9a8f78468232db345ab9cf606cf598", - "reference": "aed98a490f9a8f78468232db345ab9cf606cf598", + "url": "https://api.github.com/repos/webmozart/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6", + "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6", "shasum": "" }, "require": { @@ -9831,7 +9946,7 @@ "symfony/polyfill-ctype": "^1.8" }, "conflict": { - "vimeo/psalm": "<3.6.0" + "vimeo/psalm": "<3.9.1" }, "require-dev": { "phpunit/phpunit": "^4.8.36 || ^7.5.13" @@ -9858,7 +9973,7 @@ "check", "validate" ], - "time": "2020-02-14T12:15:55+00:00" + "time": "2020-04-18T12:12:48+00:00" }, { "name": "weew/helpers-array", @@ -9926,5 +10041,6 @@ "ext-zip": "*", "lib-libxml": "*" }, - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } From 4b6e8f62ae97e647b37550133c3ca2aa9626483a Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Sun, 19 Apr 2020 17:47:33 +0100 Subject: [PATCH 174/177] Corrected classes and search patterns --- .../MediaContent/Model/ExtractAssetsFromContent.php | 10 ++++++++-- app/code/Magento/MediaContentCms/Observer/Block.php | 2 +- app/code/Magento/MediaContentCms/etc/media_content.xml | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php b/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php index 97d9b1ad65c22..3a03cd94cf2d7 100644 --- a/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php +++ b/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php @@ -63,7 +63,7 @@ public function execute(string $content): array preg_match_all($pattern, $content, $matches, PREG_PATTERN_ORDER); if (!empty($matches[1])) { - $paths += array_unique($matches[1]); + $paths = array_merge($paths, array_unique($matches[1])); } } @@ -81,6 +81,8 @@ private function getAssetsByPaths(array $paths): array $assets = []; foreach ($paths as $path) { + $path = htmlspecialchars_decode($path); + $path = trim($path, '"\''); try { /** @var AssetInterface $asset */ $asset = $this->getMediaAssetByPath->execute($this->getPathStartingWithSlash($path)); @@ -101,6 +103,10 @@ private function getAssetsByPaths(array $paths): array */ private function getPathStartingWithSlash(string $path): string { - return '/' . ltrim($path, '/'); + $normalizedPath = ltrim($path, '/'); + if (strpos($normalizedPath, '/')) { + return $normalizedPath; + } + return '/' . $normalizedPath; } } diff --git a/app/code/Magento/MediaContentCms/Observer/Block.php b/app/code/Magento/MediaContentCms/Observer/Block.php index 5ccda6670de44..ccd1abb98bc60 100644 --- a/app/code/Magento/MediaContentCms/Observer/Block.php +++ b/app/code/Magento/MediaContentCms/Observer/Block.php @@ -7,7 +7,7 @@ namespace Magento\MediaContentCms\Observer; -use Magento\Cms\Block\Block as CmsBlock; +use Magento\Cms\Model\Block as CmsBlock; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; use Magento\MediaContentApi\Api\UpdateContentAssetLinksInterface; diff --git a/app/code/Magento/MediaContentCms/etc/media_content.xml b/app/code/Magento/MediaContentCms/etc/media_content.xml index 57c954a9d70fe..c0f41d1092134 100644 --- a/app/code/Magento/MediaContentCms/etc/media_content.xml +++ b/app/code/Magento/MediaContentCms/etc/media_content.xml @@ -9,6 +9,7 @@ <search> <patterns> <pattern name="media_gallery">/{{media url="?(.*?)"?}}/</pattern> + <pattern name="wysiwyg">/src=".*\/media\/(.*?)"/</pattern> </patterns> </search> </config> \ No newline at end of file From 76ba852953b94c2af297a337d97852ccb911ada5 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Sun, 19 Apr 2020 20:49:22 +0100 Subject: [PATCH 175/177] Fixed static tests --- .../MediaContent/Model/ExtractAssetsFromContent.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php b/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php index 3a03cd94cf2d7..8c2db3032412a 100644 --- a/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php +++ b/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php @@ -53,7 +53,7 @@ public function __construct( */ public function execute(string $content): array { - $paths = []; + $matchesArrays = []; foreach ($this->searchPatternConfig->get() as $pattern) { if (empty($pattern)) { @@ -63,11 +63,11 @@ public function execute(string $content): array preg_match_all($pattern, $content, $matches, PREG_PATTERN_ORDER); if (!empty($matches[1])) { - $paths = array_merge($paths, array_unique($matches[1])); + $matchesArrays[] = $matches[1]; } } - return $this->getAssetsByPaths(array_unique($paths)); + return $this->getAssetsByPaths(array_unique(array_merge([], ...$matchesArrays))); } /** @@ -104,7 +104,7 @@ private function getAssetsByPaths(array $paths): array private function getPathStartingWithSlash(string $path): string { $normalizedPath = ltrim($path, '/'); - if (strpos($normalizedPath, '/')) { + if (strpos($normalizedPath, '/') === false) { return $normalizedPath; } return '/' . $normalizedPath; From 44cb07a19e0d414374a9a62d20389e9b835599b2 Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Mon, 20 Apr 2020 11:34:06 +0100 Subject: [PATCH 176/177] Fixed integration tests --- .../Model/ExtractAssetsFromContent.php | 2 +- .../Model/SaveContentAssetLinks.php | 1 - ...MediaGalleryAssetDeleteByDirectoryPath.php | 19 ++++++---- .../Plugin/MediaGalleryAssetDeleteByPath.php | 38 ++++++++++++------- app/code/Magento/MediaContent/etc/di.xml | 4 +- .../Model/ExtractAssetsFromContentTest.php | 10 ++++- .../Model/SaveDeleteContentAssetLinksTest.php | 2 +- .../Model/UpdateContentAssetLinksTest.php | 2 +- 8 files changed, 49 insertions(+), 29 deletions(-) diff --git a/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php b/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php index 8c2db3032412a..92248ee1debfe 100644 --- a/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php +++ b/app/code/Magento/MediaContent/Model/ExtractAssetsFromContent.php @@ -104,7 +104,7 @@ private function getAssetsByPaths(array $paths): array private function getPathStartingWithSlash(string $path): string { $normalizedPath = ltrim($path, '/'); - if (strpos($normalizedPath, '/') === false) { + if (strpos($normalizedPath, '/') !== false) { return $normalizedPath; } return '/' . $normalizedPath; diff --git a/app/code/Magento/MediaContent/Model/SaveContentAssetLinks.php b/app/code/Magento/MediaContent/Model/SaveContentAssetLinks.php index 9c5c8879b00c5..3d4ed2c0e4b80 100644 --- a/app/code/Magento/MediaContent/Model/SaveContentAssetLinks.php +++ b/app/code/Magento/MediaContent/Model/SaveContentAssetLinks.php @@ -10,7 +10,6 @@ use Magento\Framework\App\ResourceConnection; use Magento\Framework\Exception\CouldNotSaveException; use Magento\MediaContentApi\Api\SaveContentAssetLinksInterface; -use Magento\MediaContentApi\Api\Data\ContentIdentityInterface; use Magento\MediaContentApi\Api\Data\ContentAssetLinkInterface; use Psr\Log\LoggerInterface; diff --git a/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php index 29645c4a9887f..c260c877cdb4a 100644 --- a/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php +++ b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php @@ -11,7 +11,7 @@ use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\Exception\CouldNotDeleteException; use Magento\MediaContentApi\Api\DeleteContentAssetLinksByAssetIdsInterface; -use Magento\MediaGalleryApi\Model\Asset\Command\DeleteByDirectoryPathInterface; +use Magento\MediaGalleryApi\Api\DeleteDirectoriesByPathsInterface; use Psr\Log\LoggerInterface; /** @@ -54,22 +54,27 @@ public function __construct( /** * Around plugin on execute method * - * @param DeleteByDirectoryPathInterface $subject + * @param DeleteDirectoriesByPathsInterface $subject * @param \Closure $proceed - * @param string $directoryPath + * @param array $paths * @throws CouldNotDeleteException * @return void * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundExecute( - DeleteByDirectoryPathInterface $subject, + DeleteDirectoriesByPathsInterface $subject, \Closure $proceed, - string $directoryPath + array $paths ) : void { - $assetIds = $this->getAssetIdsByDirectoryPath($directoryPath); + $assetIdsArrays =[]; + foreach ($paths as $path) { + $assetIdsArrays[] = $this->getAssetIdsByDirectoryPath($path); + } - $proceed($directoryPath); + $assetIds = array_unique(array_merge([], ...$assetIdsArrays)); + + $proceed($paths); $this->deleteContentAssetLinksByAssetIds->execute($assetIds); } diff --git a/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php index efb95c644b48a..83df5c13f36c8 100644 --- a/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php +++ b/app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php @@ -8,9 +8,11 @@ namespace Magento\MediaContent\Plugin; use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\Framework\Exception\LocalizedException; use Magento\MediaContentApi\Api\DeleteContentAssetLinksByAssetIdsInterface; -use Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface; -use Magento\MediaGalleryApi\Model\Asset\Command\GetByPathInterface; +use Magento\MediaGalleryApi\Api\Data\AssetInterface; +use Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface; +use Magento\MediaGalleryApi\Api\GetAssetsByPathsInterface; use Psr\Log\LoggerInterface; /** @@ -19,9 +21,9 @@ class MediaGalleryAssetDeleteByPath { /** - * @var GetByPathInterface + * @var GetAssetsByPathsInterface */ - private $getByPath; + private $getByPaths; /** * @var LoggerInterface @@ -35,39 +37,47 @@ class MediaGalleryAssetDeleteByPath /** * @param DeleteContentAssetLinksByAssetIdsInterface $deleteContentAssetLinksByAssetIds - * @param GetByPathInterface $getByPath + * @param GetAssetsByPathsInterface $getByPath * @param LoggerInterface $logger */ public function __construct( DeleteContentAssetLinksByAssetIdsInterface $deleteContentAssetLinksByAssetIds, - GetByPathInterface $getByPath, + GetAssetsByPathsInterface $getByPath, LoggerInterface $logger ) { $this->deleteContentAssetLinksByAssetIds = $deleteContentAssetLinksByAssetIds; - $this->getByPath = $getByPath; + $this->getByPaths = $getByPath; $this->logger = $logger; } /** * Around plugin on execute method * - * @param DeleteByPathInterface $subject + * @param DeleteAssetsByPathsInterface $subject * @param \Closure $proceed - * @param string $mediaAssetPath + * @param array $paths * @throws CouldNotDeleteException + * @throws LocalizedException * @return void * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundExecute( - DeleteByPathInterface $subject, + DeleteAssetsByPathsInterface $subject, \Closure $proceed, - string $mediaAssetPath + array $paths ) : void { - $asset = $this->getByPath->execute($mediaAssetPath); + $assets = $this->getByPaths->execute($paths); - $proceed($mediaAssetPath); + $proceed($paths); - $this->deleteContentAssetLinksByAssetIds->execute([$asset->getId()]); + $assetIds = array_map( + function (AssetInterface $asset) { + return $asset->getId(); + }, + $assets + ); + + $this->deleteContentAssetLinksByAssetIds->execute($assetIds); } } diff --git a/app/code/Magento/MediaContent/etc/di.xml b/app/code/Magento/MediaContent/etc/di.xml index bdbff33b80ad3..35dcf2aa836a0 100644 --- a/app/code/Magento/MediaContent/etc/di.xml +++ b/app/code/Magento/MediaContent/etc/di.xml @@ -17,10 +17,10 @@ <preference for="Magento\MediaContentApi\Api\Data\ContentAssetLinkInterface" type="Magento\MediaContent\Model\ContentAssetLink"/> <preference for="Magento\MediaContentApi\Model\SearchPatternConfigInterface" type="Magento\MediaContent\Model\Content\SearchPatternConfig"/> <preference for="Magento\MediaContent\Model\Content\ConfigInterface" type="Magento\MediaContent\Model\Content\Config"/> - <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByPathInterface"> + <type name="Magento\MediaGalleryApi\Api\DeleteAssetsByPathsInterface"> <plugin name="remove_media_content_after_asset_is_removed_by_path" type="Magento\MediaContent\Plugin\MediaGalleryAssetDeleteByPath" /> </type> - <type name="Magento\MediaGalleryApi\Model\Asset\Command\DeleteByDirectoryPathInterface"> + <type name="Magento\MediaGalleryApi\Api\DeleteDirectoriesByPathsInterface"> <plugin name="remove_media_content_after_asset_is_removed_by_directory_path" type="Magento\MediaContent\Plugin\MediaGalleryAssetDeleteByDirectoryPath" /> </type> <virtualType name="Magento\MediaContent\Model\Content\Config\Reader" type="Magento\Framework\Config\Reader\Filesystem"> diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php index d8870bb4c422d..841113d35c1d2 100644 --- a/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php @@ -74,13 +74,19 @@ public function contentProvider() 'Relevant paths in content' => [ 'content {{media url="testDirectory/path.jpg"}} content', [ - 55 + 2020 + ] + ], + 'Relevant wysiwyg paths in content' => [ + 'content <img src="https://domain.com/media/testDirectory/path.jpg"}} content', + [ + 2020 ] ], 'Relevant path content' => [ '/media/testDirectory/path.jpg', [ - 55 + 2020 ] ], 'Irrelevant paths in content' => [ diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/SaveDeleteContentAssetLinksTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/SaveDeleteContentAssetLinksTest.php index 36b2768d9b806..4244cd66475a0 100644 --- a/dev/tests/integration/testsuite/Magento/MediaContent/Model/SaveDeleteContentAssetLinksTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/SaveDeleteContentAssetLinksTest.php @@ -60,7 +60,7 @@ public function setUp(): void public function testAssignRetrieveAndUnassign(): void { $entityType = 'catalog_product'; - $entityId = '42'; + $entityId = 42; $field = 'description'; $assetIds = [56, 78]; diff --git a/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateContentAssetLinksTest.php b/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateContentAssetLinksTest.php index 8e1747a831abc..0a9393c1c3c20 100644 --- a/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateContentAssetLinksTest.php +++ b/dev/tests/integration/testsuite/Magento/MediaContent/Model/UpdateContentAssetLinksTest.php @@ -47,7 +47,7 @@ public function setUp(): void public function testExecute(): void { $entityType = 'catalog_product'; - $entityId = '42'; + $entityId = 2020; $field = 'description'; $contentWithoutAsset = ''; $contentWithAsset = 'content {{media url="testDirectory/path.jpg"}} content'; From 1c521b14af86971e9b54b18fa577d09db977028c Mon Sep 17 00:00:00 2001 From: Sergii Ivashchenko <serg.ivashchenko@gmail.com> Date: Mon, 20 Apr 2020 13:38:54 +0100 Subject: [PATCH 177/177] Updated db_schema_whitelist.json --- app/code/Magento/MediaContent/etc/db_schema.xml | 2 +- app/code/Magento/MediaContent/etc/db_schema_whitelist.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/MediaContent/etc/db_schema.xml b/app/code/Magento/MediaContent/etc/db_schema.xml index 2e4ed19201c9c..7e45e29cbb434 100644 --- a/app/code/Magento/MediaContent/etc/db_schema.xml +++ b/app/code/Magento/MediaContent/etc/db_schema.xml @@ -17,7 +17,7 @@ <column name="field"/> <column name="asset_id"/> </constraint> - <index referenceId="MEDIA_CONTENT_ASSET_ID" indexType="btree"> + <index referenceId="MEDIA_CONTENT_ASSET_ASSET_ID" indexType="btree"> <column name="asset_id"/> </index> </table> diff --git a/app/code/Magento/MediaContent/etc/db_schema_whitelist.json b/app/code/Magento/MediaContent/etc/db_schema_whitelist.json index 5ff8dc52591cc..e33768b5e1ab5 100644 --- a/app/code/Magento/MediaContent/etc/db_schema_whitelist.json +++ b/app/code/Magento/MediaContent/etc/db_schema_whitelist.json @@ -7,7 +7,7 @@ "asset_id": true }, "index": { - "MEDIA_CONTENT_ASSET_ID": true + "MEDIA_CONTENT_ASSET_ASSET_ID": true }, "constraint": { "PRIMARY": true