From 1f743bd7fdf8147a80630fbd8f37a2cd53ee4d49 Mon Sep 17 00:00:00 2001 From: Yurii Borysov Date: Thu, 23 Aug 2018 15:17:16 +0300 Subject: [PATCH 001/121] MAGETWO-91559: Static blocks with same ID appear in place of correct block --- .../Magento/Cms/Model/ResourceModel/Block.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Cms/Model/ResourceModel/Block.php b/app/code/Magento/Cms/Model/ResourceModel/Block.php index 9aab54b02bc14..ff7cc8d3e034d 100644 --- a/app/code/Magento/Cms/Model/ResourceModel/Block.php +++ b/app/code/Magento/Cms/Model/ResourceModel/Block.php @@ -183,10 +183,12 @@ public function getIsUniqueBlockToStores(AbstractModel $object) $entityMetadata = $this->metadataPool->getMetadata(BlockInterface::class); $linkField = $entityMetadata->getLinkField(); - if ($this->_storeManager->isSingleStoreMode()) { - $stores = [Store::DEFAULT_STORE_ID]; - } else { - $stores = (array)$object->getData('store_id'); + $stores = (array)$object->getData('store_id'); + $isDefaultStore = $this->_storeManager->isSingleStoreMode() + || array_search(Store::DEFAULT_STORE_ID, $stores) !== false; + + if(!$isDefaultStore) { + $stores[] = Store::DEFAULT_STORE_ID; } $select = $this->getConnection()->select() @@ -196,8 +198,11 @@ public function getIsUniqueBlockToStores(AbstractModel $object) 'cb.' . $linkField . ' = cbs.' . $linkField, [] ) - ->where('cb.identifier = ?', $object->getData('identifier')) - ->where('cbs.store_id IN (?)', $stores); + ->where('cb.identifier = ? ', $object->getData('identifier')); + + if(!$isDefaultStore) { + $select->where('cbs.store_id IN (?)', $stores); + } if ($object->getId()) { $select->where('cb.' . $entityMetadata->getIdentifierField() . ' <> ?', $object->getId()); From 33a84d6b554dbc82b4fda378bb8da79a1ecc9f1f Mon Sep 17 00:00:00 2001 From: Vital_Pantsialeyeu Date: Thu, 30 Aug 2018 02:23:28 +0300 Subject: [PATCH 002/121] MAGETWO-66872: Customer Address Attribute not being marked as required when the "Values Required" setting is overriden on Website scope - Updated retrieve attribute collection --- .../Model/ResourceModel/Attribute/Collection.php | 13 +++++++++++++ app/code/Magento/Eav/Model/Entity/Type.php | 10 ++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Customer/Model/ResourceModel/Attribute/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Attribute/Collection.php index 4dd2eaa68b686..4cf438a95bed4 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Attribute/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Attribute/Collection.php @@ -42,4 +42,17 @@ protected function _getEavWebsiteTable() { return $this->getTable('customer_eav_attribute_website'); } + + /** + * Set collection item class name. + * + * @return $this + */ + protected function _beforeLoad() + { + $entityType = $this->getEntityType(); + $this->setItemObjectClass($entityType->getAttributeModel()); + + return parent::_beforeLoad(); + } } diff --git a/app/code/Magento/Eav/Model/Entity/Type.php b/app/code/Magento/Eav/Model/Entity/Type.php index 80fcfd4ab585c..e0f890170f1b7 100644 --- a/app/code/Magento/Eav/Model/Entity/Type.php +++ b/app/code/Magento/Eav/Model/Entity/Type.php @@ -163,17 +163,11 @@ public function getAttributeCollection($setId = null) /** * Init and retrieve attribute collection * - * @return \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection + * @return mixed */ protected function _getAttributeCollection() { - $collection = $this->_attributeFactory->create()->getCollection(); - $objectsModel = $this->getAttributeModel(); - if ($objectsModel) { - $collection->setModel($objectsModel); - } - - return $collection; + return $this->_universalFactory->create($this->getEntityAttributeCollection()); } /** From 78a9a737a2c64c7deece3fa4708a57c23cf4d314 Mon Sep 17 00:00:00 2001 From: Lusine Hakobyan Date: Thu, 30 Aug 2018 10:38:55 +0400 Subject: [PATCH 003/121] MAGETWO-91559: Static blocks with same ID appear in place of correct block - Add automated test --- .../Test/Mftf/ActionGroup/CMSActionGroup.xml | 12 +++- .../CmsNewBlockBlockActionsSection.xml | 1 + .../Test/Mftf/Test/CheckStaticBlocksTest.xml | 72 +++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/CMSActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/CMSActionGroup.xml index 06419356d8e84..d83e154bc9d70 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/CMSActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/CMSActionGroup.xml @@ -6,7 +6,7 @@ */ --> + xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd"> @@ -44,4 +44,14 @@ + + + + + + + + + + diff --git a/app/code/Magento/Cms/Test/Mftf/Section/CmsNewBlockBlockActionsSection.xml b/app/code/Magento/Cms/Test/Mftf/Section/CmsNewBlockBlockActionsSection.xml index 65ea1226772cf..3cc204d64adca 100644 --- a/app/code/Magento/Cms/Test/Mftf/Section/CmsNewBlockBlockActionsSection.xml +++ b/app/code/Magento/Cms/Test/Mftf/Section/CmsNewBlockBlockActionsSection.xml @@ -17,6 +17,7 @@ +
diff --git a/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml new file mode 100644 index 0000000000000..df7cd59a45886 --- /dev/null +++ b/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml @@ -0,0 +1,72 @@ + + + + + + + + + + <description value="Check static blocks: ID should be unique per Store View"/> + <severity value="CRITICAL"/> + <testCaseId value="MAGETWO-94229"/> + <group value="Cms"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/> + <actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="AdminCreateWebsite"> + <argument name="newWebsiteName" value="secondWebsite"/> + <argument name="websiteCode" value="second_website"/> + </actionGroup> + <actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="AdminCreateStore"> + <argument name="website" value="secondWebsite"/> + <argument name="storeGroupName" value="{{customStoreGroup.name}}"/> + <argument name="storeGroupCode" value="{{customStoreGroup.code}}"/> + </actionGroup> + <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="AdminCreateStoreView"> + <argument name="StoreGroup" value="customStoreGroup"/> + <argument name="customStore" value="customStore"/> + </actionGroup> + </before> + + <!--Go to Cms blocks page--> + <amOnPage url="{{CmsBlocksPage.url}}" stepKey="navigateToCMSPagesGrid"/> + <waitForPageLoad stepKey="waitForPageLoad1"/> + <seeInCurrentUrl url="cms/block/" stepKey="VerifyPageIsOpened"/> + <!--Click to create new block--> + <click selector="{{BlockPageActionsSection.addNewBlock}}" stepKey="ClickToAddNewBlock"/> + <waitForPageLoad stepKey="waitForPageLoad2"/> + <seeInCurrentUrl url="cms/block/new" stepKey="VerifyNewBlockPageIsOpened"/> + <actionGroup ref="FillOutBlockContent" stepKey="FillOutBlockContent"/> + <click selector="{{BlockNewPagePageActionsSection.saveBlock}}" stepKey="ClickToSaveBlock"/> + <waitForPageLoad stepKey="waitForPageLoad3"/> + <see userInput="You saved the block." stepKey="VerifyBlockIsSaved"/> + <!--Click to go back and add new block--> + <click selector="{{BlockNewPagePageActionsSection.back}}" stepKey="ClickToGoBack"/> + <waitForPageLoad stepKey="waitForPageLoad4"/> + <click selector="{{BlockPageActionsSection.addNewBlock}}" stepKey="ClickToAddNewBlock1"/> + <waitForPageLoad stepKey="waitForPageLoad5"/> + <seeInCurrentUrl url="cms/block/new" stepKey="VerifyNewBlockPageIsOpened1"/> + <!--Add new BLock with the same data--> + <actionGroup ref="FillOutBlockContent" stepKey="FillOutBlockContent1"/> + <selectOption selector="{{BlockNewPageBasicFieldsSection.storeView}}" userInput="Default Store View" stepKey="selectDefaultStoreView" /> + <selectOption selector="{{BlockNewPageBasicFieldsSection.storeView}}" userInput="{{customStore.name}}" stepKey="selectSecondStoreView1" /> + <click selector="{{BlockNewPagePageActionsSection.saveBlock}}" stepKey="ClickToSaveBlock1"/> + <waitForPageLoad stepKey="waitForPageLoad6"/> + <!--Verify that corresponding message is displayed--> + <see userInput="A block identifier with the same properties already exists in the selected store." stepKey="VerifyBlockIsSaved1"/> + + <after> + <actionGroup ref="DeleteCMSBlockActionGroup" stepKey="DeleteCMSBlockActionGroup"/> + <actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="DeleteWebsite"> + <argument name="websiteName" value="secondWebsite"/> + </actionGroup> + </after> + </test> +</tests> From aa5fa74db5eb7b5725c7ca8ad9cb47b77c968b7c Mon Sep 17 00:00:00 2001 From: Vital_Pantsialeyeu <vital_pantsialeyeu@epam.com> Date: Tue, 4 Sep 2018 23:50:07 +0300 Subject: [PATCH 004/121] MAGETWO-66872: Customer Address Attribute not being marked as required when the "Values Required" setting is overriden on Website scope - Updated retrieve attribute collection --- .../Model/ResourceModel/Attribute/Collection.php | 13 ------------- app/code/Magento/Eav/Model/Entity/Type.php | 4 +++- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/app/code/Magento/Customer/Model/ResourceModel/Attribute/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Attribute/Collection.php index 4cf438a95bed4..4dd2eaa68b686 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Attribute/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Attribute/Collection.php @@ -42,17 +42,4 @@ protected function _getEavWebsiteTable() { return $this->getTable('customer_eav_attribute_website'); } - - /** - * Set collection item class name. - * - * @return $this - */ - protected function _beforeLoad() - { - $entityType = $this->getEntityType(); - $this->setItemObjectClass($entityType->getAttributeModel()); - - return parent::_beforeLoad(); - } } diff --git a/app/code/Magento/Eav/Model/Entity/Type.php b/app/code/Magento/Eav/Model/Entity/Type.php index e0f890170f1b7..462c42cbc9654 100644 --- a/app/code/Magento/Eav/Model/Entity/Type.php +++ b/app/code/Magento/Eav/Model/Entity/Type.php @@ -167,7 +167,9 @@ public function getAttributeCollection($setId = null) */ protected function _getAttributeCollection() { - return $this->_universalFactory->create($this->getEntityAttributeCollection()); + $collection = $this->_universalFactory->create($this->getEntityAttributeCollection()); + $collection->setItemObjectClass($this->getAttributeModel()); + return $collection; } /** From e61b23a8e506576974cf37f12929c7b2c8053614 Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <veronika_kurochkina@epam.com> Date: Mon, 17 Sep 2018 10:42:58 +0300 Subject: [PATCH 005/121] MAGETWO-91559: Static blocks with same ID appear in place of correct block - Fix static test --- app/code/Magento/Cms/Model/ResourceModel/Block.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Cms/Model/ResourceModel/Block.php b/app/code/Magento/Cms/Model/ResourceModel/Block.php index ff7cc8d3e034d..30e817713755c 100644 --- a/app/code/Magento/Cms/Model/ResourceModel/Block.php +++ b/app/code/Magento/Cms/Model/ResourceModel/Block.php @@ -95,9 +95,11 @@ protected function _beforeSave(AbstractModel $object) } /** + * Get block id. + * * @param AbstractModel $object * @param mixed $value - * @param null $field + * @param string $field * @return bool|int|string * @throws LocalizedException * @throws \Exception @@ -187,7 +189,7 @@ public function getIsUniqueBlockToStores(AbstractModel $object) $isDefaultStore = $this->_storeManager->isSingleStoreMode() || array_search(Store::DEFAULT_STORE_ID, $stores) !== false; - if(!$isDefaultStore) { + if (!$isDefaultStore) { $stores[] = Store::DEFAULT_STORE_ID; } @@ -200,7 +202,7 @@ public function getIsUniqueBlockToStores(AbstractModel $object) ) ->where('cb.identifier = ? ', $object->getData('identifier')); - if(!$isDefaultStore) { + if (!$isDefaultStore) { $select->where('cbs.store_id IN (?)', $stores); } @@ -241,6 +243,8 @@ public function lookupStoreIds($id) } /** + * Save an object. + * * @param AbstractModel $object * @return $this * @throws \Exception From 921fa69da95fa159a9a57fcc374b3cd19ac270df Mon Sep 17 00:00:00 2001 From: Vital_Pantsialeyeu <vital_pantsialeyeu@epam.com> Date: Wed, 19 Sep 2018 17:43:23 +0300 Subject: [PATCH 006/121] MAGETWO-66872: Customer Address Attribute not being marked as required when the "Values Required" setting is overriden on Website scope - Updated retrieve attribute collection --- app/code/Magento/Eav/Model/Entity/Type.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Eav/Model/Entity/Type.php b/app/code/Magento/Eav/Model/Entity/Type.php index 462c42cbc9654..444d58bf546d4 100644 --- a/app/code/Magento/Eav/Model/Entity/Type.php +++ b/app/code/Magento/Eav/Model/Entity/Type.php @@ -163,7 +163,7 @@ public function getAttributeCollection($setId = null) /** * Init and retrieve attribute collection * - * @return mixed + * @return \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection */ protected function _getAttributeCollection() { From 1e81c95abbccce1c086189ab6f59d81f3d30ab9e Mon Sep 17 00:00:00 2001 From: Sona Sargsyan <sona_sargsyan@epam.com> Date: Tue, 25 Sep 2018 16:10:48 +0400 Subject: [PATCH 007/121] MAGETWO-66872: Customer Address Attribute not being marked as required when the "Values Required" setting is overriden on Website scope - Add automation test --- ...tCustomerAddressesFromAdminActionGroup.xml | 32 +++++++++++++++++++ .../Test/Mftf/Page/AdminEditCustomerPage.xml | 1 + .../AdminEditCustomerAddressesSection.xml | 31 ++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml create mode 100644 app/code/Magento/Customer/Test/Mftf/Section/AdminEditCustomerAddressesSection.xml diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml new file mode 100644 index 0000000000000..402566c771928 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml @@ -0,0 +1,32 @@ +<?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="EditCustomerAddressesFromAdminActionGroup" > + <click selector="{{AdminEditCustomerAddressesSection.addresses}}" stepKey="proceedToAddresses"/> + <click selector="{{AdminEditCustomerAddressesSection.addNewAddresses}}" stepKey="addNewAddresses"/> + <fillField stepKey="fillPrefixName" userInput="{{CustomerAddressSimple.prefix}}" selector="{{AdminEditCustomerAddressesSection.prefixName}}"/> + <fillField stepKey="fillFirstName" userInput="{{CustomerAddressSimple.firstname}}" selector="{{AdminEditCustomerAddressesSection.firstName}}"/> + <fillField stepKey="fillMiddleName" userInput="{{CustomerAddressSimple.middlename}}" selector="{{AdminEditCustomerAddressesSection.middleName}}"/> + <fillField stepKey="fillLastName" userInput="{{CustomerAddressSimple.lastname}}" selector="{{AdminEditCustomerAddressesSection.lastName}}"/> + <fillField stepKey="fillSuffixName" userInput="{{CustomerAddressSimple.suffix}}" selector="{{AdminEditCustomerAddressesSection.suffixName}}"/> + <fillField stepKey="fillCompany" userInput="{{CustomerAddressSimple.company}}" selector="{{AdminEditCustomerAddressesSection.company}}"/> + <fillField stepKey="fillStreetAddress" userInput="{{CustomerAddressSimple.street}}" selector="{{AdminEditCustomerAddressesSection.streetAddress}}"/> + <fillField stepKey="fillCity" userInput="{{CustomerAddressSimple.city}}" selector="{{AdminEditCustomerAddressesSection.city}}"/> + <selectOption stepKey="selectCountry" selector="{{AdminEditCustomerAddressesSection.country}}" userInput="{{US_Address_CA.country_id}}"/> + <selectOption stepKey="selectState" selector="{{AdminEditCustomerAddressesSection.state}}" userInput="{{US_Address_CA.state}}"/> + <fillField stepKey="fillZipCode" userInput="{{CustomerAddressSimple.postcode}}" selector="{{AdminEditCustomerAddressesSection.zipCode}}"/> + <fillField stepKey="fillPhone" userInput="{{CustomerAddressSimple.telephone}}" selector="{{AdminEditCustomerAddressesSection.phone}}"/> + <fillField stepKey="fillVAT" userInput="{{CustomerAddressSimple.vat_id}}" selector="{{AdminEditCustomerAddressesSection.vat}}"/> + <click selector="{{CustomerAccountSection.save}}" stepKey="saveAddress"/> + <waitForPageLoad stepKey="waitForStorefrontPage"/> + <click selector="{{CustomerAccountSection.save}}" stepKey="saveCustomer"/> + <waitForPageLoad stepKey="waitForCustomerSaved"/> + <see stepKey="seeSaveMessage" userInput="You saved the customer."/> + </actionGroup> +</actionGroups> \ No newline at end of file diff --git a/app/code/Magento/Customer/Test/Mftf/Page/AdminEditCustomerPage.xml b/app/code/Magento/Customer/Test/Mftf/Page/AdminEditCustomerPage.xml index 31dad24ba8372..327cfe659aff2 100644 --- a/app/code/Magento/Customer/Test/Mftf/Page/AdminEditCustomerPage.xml +++ b/app/code/Magento/Customer/Test/Mftf/Page/AdminEditCustomerPage.xml @@ -10,5 +10,6 @@ <page name="AdminEditCustomerPage" url="/customer/index/edit/id/{{var1}}" area="admin" module="Magento_Customer" parameterized="true"> <section name="AdminCustomerAccountInformationSection"/> <section name="AdminCustomerMainActionsSection"/> + <section name="AdminEditCustomerAddressesSection" /> </page> </pages> diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminEditCustomerAddressesSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminEditCustomerAddressesSection.xml new file mode 100644 index 0000000000000..0718800c871a7 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminEditCustomerAddressesSection.xml @@ -0,0 +1,31 @@ +<?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="AdminEditCustomerAddressesSection"> + <element name="addresses" type="button" selector="//span[text()='Addresses']" timeout="30"/> + <element name="addNewAddresses" type="button" selector="//span[text()='Add New Addresses']"/> + <element name="defaultBillingAddress" type="text" selector="input[name='address[new_0][default_billing]']"/> + <element name="defaultShippingAddress" type="text" selector="input[name='address[new_0][default_shipping]']"/> + <element name="prefixName" type="text" selector="input[name='address[new_0][prefix]']"/> + <element name="firstName" type="text" selector="input[name='address[new_0][firstname]']" /> + <element name="middleName" type="text" selector="input[name='address[new_0][middlename]']" /> + <element name="lastName" type="text" selector="input[name='address[new_0][lastname]']" /> + <element name="suffixName" type="text" selector="input[name='address[new_0][suffix]']" /> + <element name="company" type="text" selector="input[name='address[new_0][company]']" /> + <element name="streetAddress" type="text" selector="input[name='address[new_0][street][0]']" /> + <element name="city" type="text" selector="input[name='address[new_0][city]']" /> + <element name="country" type="select" selector="select[name='address[new_0][country_id]']" /> + <element name="state" type="select" selector="select[name='address[new_0][region_id]']" /> + <element name="zipCode" type="text" selector="input[name='address[new_0][postcode]']" /> + <element name="phone" type="text" selector="input[name='address[new_0][telephone]']" /> + <element name="vat" type="text" selector="input[name='address[new_0][vat_id]']" /> + </section> + +</sections> From eb2be5fbf8df76be3f5eee7872dc30aeba8d6bbb Mon Sep 17 00:00:00 2001 From: David Grigoryan <david_grigoryan@epam.com> Date: Mon, 1 Oct 2018 12:40:36 +0400 Subject: [PATCH 008/121] MAGETWO-66872: Customer Address Attribute not being marked as required when the "Values Required" setting is overriden on Website scope - Update automation test --- ...tCustomerAddressesFromAdminActionGroup.xml | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml index 402566c771928..9d918990c8172 100644 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml @@ -8,21 +8,24 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> <actionGroup name="EditCustomerAddressesFromAdminActionGroup" > + <arguments> + <argument name="customerAddress"/> + </arguments> <click selector="{{AdminEditCustomerAddressesSection.addresses}}" stepKey="proceedToAddresses"/> <click selector="{{AdminEditCustomerAddressesSection.addNewAddresses}}" stepKey="addNewAddresses"/> - <fillField stepKey="fillPrefixName" userInput="{{CustomerAddressSimple.prefix}}" selector="{{AdminEditCustomerAddressesSection.prefixName}}"/> - <fillField stepKey="fillFirstName" userInput="{{CustomerAddressSimple.firstname}}" selector="{{AdminEditCustomerAddressesSection.firstName}}"/> - <fillField stepKey="fillMiddleName" userInput="{{CustomerAddressSimple.middlename}}" selector="{{AdminEditCustomerAddressesSection.middleName}}"/> - <fillField stepKey="fillLastName" userInput="{{CustomerAddressSimple.lastname}}" selector="{{AdminEditCustomerAddressesSection.lastName}}"/> - <fillField stepKey="fillSuffixName" userInput="{{CustomerAddressSimple.suffix}}" selector="{{AdminEditCustomerAddressesSection.suffixName}}"/> - <fillField stepKey="fillCompany" userInput="{{CustomerAddressSimple.company}}" selector="{{AdminEditCustomerAddressesSection.company}}"/> - <fillField stepKey="fillStreetAddress" userInput="{{CustomerAddressSimple.street}}" selector="{{AdminEditCustomerAddressesSection.streetAddress}}"/> - <fillField stepKey="fillCity" userInput="{{CustomerAddressSimple.city}}" selector="{{AdminEditCustomerAddressesSection.city}}"/> + <fillField stepKey="fillPrefixName" userInput="{{customerAddress.prefix}}" selector="{{AdminEditCustomerAddressesSection.prefixName}}"/> + <fillField stepKey="fillFirstName" userInput="{{customerAddress.firstname}}" selector="{{AdminEditCustomerAddressesSection.firstName}}"/> + <fillField stepKey="fillMiddleName" userInput="{{customerAddress.middlename}}" selector="{{AdminEditCustomerAddressesSection.middleName}}"/> + <fillField stepKey="fillLastName" userInput="{{customerAddress.lastname}}" selector="{{AdminEditCustomerAddressesSection.lastName}}"/> + <fillField stepKey="fillSuffixName" userInput="{{customerAddress.suffix}}" selector="{{AdminEditCustomerAddressesSection.suffixName}}"/> + <fillField stepKey="fillCompany" userInput="{{customerAddress.company}}" selector="{{AdminEditCustomerAddressesSection.company}}"/> + <fillField stepKey="fillStreetAddress" userInput="{{customerAddress.street}}" selector="{{AdminEditCustomerAddressesSection.streetAddress}}"/> + <fillField stepKey="fillCity" userInput="{{customerAddress.city}}" selector="{{AdminEditCustomerAddressesSection.city}}"/> <selectOption stepKey="selectCountry" selector="{{AdminEditCustomerAddressesSection.country}}" userInput="{{US_Address_CA.country_id}}"/> <selectOption stepKey="selectState" selector="{{AdminEditCustomerAddressesSection.state}}" userInput="{{US_Address_CA.state}}"/> - <fillField stepKey="fillZipCode" userInput="{{CustomerAddressSimple.postcode}}" selector="{{AdminEditCustomerAddressesSection.zipCode}}"/> - <fillField stepKey="fillPhone" userInput="{{CustomerAddressSimple.telephone}}" selector="{{AdminEditCustomerAddressesSection.phone}}"/> - <fillField stepKey="fillVAT" userInput="{{CustomerAddressSimple.vat_id}}" selector="{{AdminEditCustomerAddressesSection.vat}}"/> + <fillField stepKey="fillZipCode" userInput="{{customerAddress.postcode}}" selector="{{AdminEditCustomerAddressesSection.zipCode}}"/> + <fillField stepKey="fillPhone" userInput="{{customerAddress.telephone}}" selector="{{AdminEditCustomerAddressesSection.phone}}"/> + <fillField stepKey="fillVAT" userInput="{{customerAddress.vat_id}}" selector="{{AdminEditCustomerAddressesSection.vat}}"/> <click selector="{{CustomerAccountSection.save}}" stepKey="saveAddress"/> <waitForPageLoad stepKey="waitForStorefrontPage"/> <click selector="{{CustomerAccountSection.save}}" stepKey="saveCustomer"/> From 456f431e8a86fcc5d28404c5e6c13b431b043510 Mon Sep 17 00:00:00 2001 From: Alexey Yakimovich <yakimovich@almagy.com> Date: Wed, 24 Oct 2018 12:18:09 +0300 Subject: [PATCH 009/121] MAGETWO-95820: Order placed by new customer before they registered is displayed in the admin under the name Guest - Fixed issue with missing customer data in order when account was created after order placing; --- .../Observer/AssignOrderToCustomerObserver.php | 15 +++++++++++---- .../AssignOrderToCustomerObserverTest.php | 11 +++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Sales/Observer/AssignOrderToCustomerObserver.php b/app/code/Magento/Sales/Observer/AssignOrderToCustomerObserver.php index cade86d18e935..5883bde175101 100644 --- a/app/code/Magento/Sales/Observer/AssignOrderToCustomerObserver.php +++ b/app/code/Magento/Sales/Observer/AssignOrderToCustomerObserver.php @@ -31,7 +31,7 @@ public function __construct(OrderRepositoryInterface $orderRepository) } /** - * {@inheritdoc} + * @inheritdoc */ public function execute(Observer $observer) { @@ -44,9 +44,16 @@ public function execute(Observer $observer) $orderId = $delegateData['__sales_assign_order_id']; $order = $this->orderRepository->get($orderId); if (!$order->getCustomerId()) { - //if customer ID wasn't already assigned then assigning. - $order->setCustomerId($customer->getId()); - $order->setCustomerIsGuest(0); + //assign customer info to order after customer creation. + $order->setCustomerId($customer->getId()) + ->setCustomerIsGuest(0) + ->setCustomerEmail($customer->getEmail()) + ->setCustomerFirstname($customer->getFirstname()) + ->setCustomerLastname($customer->getLastname()) + ->setCustomerMiddlename($customer->getMiddlename()) + ->setCustomerPrefix($customer->getPrefix()) + ->setCustomerSuffix($customer->getSuffix()) + ->setCustomerGroupId($customer->getGroupId()); $this->orderRepository->save($order); } } diff --git a/app/code/Magento/Sales/Test/Unit/Observer/AssignOrderToCustomerObserverTest.php b/app/code/Magento/Sales/Test/Unit/Observer/AssignOrderToCustomerObserverTest.php index c6e02151b9bc1..e919b45667f24 100644 --- a/app/code/Magento/Sales/Test/Unit/Observer/AssignOrderToCustomerObserverTest.php +++ b/app/code/Magento/Sales/Test/Unit/Observer/AssignOrderToCustomerObserverTest.php @@ -69,6 +69,17 @@ public function testAssignOrderToCustomerAfterGuestOrder($customerId) $orderMock->expects($this->once())->method('getCustomerId')->willReturn($customerId); $this->orderRepositoryMock->expects($this->once())->method('get')->with($orderId) ->willReturn($orderMock); + + $orderMock->expects($this->once())->method('setCustomerId')->willReturn($orderMock); + $orderMock->expects($this->once())->method('setCustomerIsGuest')->willReturn($orderMock); + $orderMock->expects($this->once())->method('setCustomerEmail')->willReturn($orderMock); + $orderMock->expects($this->once())->method('setCustomerFirstname')->willReturn($orderMock); + $orderMock->expects($this->once())->method('setCustomerLastname')->willReturn($orderMock); + $orderMock->expects($this->once())->method('setCustomerMiddlename')->willReturn($orderMock); + $orderMock->expects($this->once())->method('setCustomerPrefix')->willReturn($orderMock); + $orderMock->expects($this->once())->method('setCustomerSuffix')->willReturn($orderMock); + $orderMock->expects($this->once())->method('setCustomerGroupId')->willReturn($orderMock); + if (!$customerId) { $this->orderRepositoryMock->expects($this->once())->method('save')->with($orderMock); $this->sut->execute($observerMock); From 5902f1e80c0884b513dbc310845ffe8f6f09aa87 Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Tue, 30 Oct 2018 14:20:01 +0300 Subject: [PATCH 010/121] MAGETWO-95822: Layered Navigation shows options not available - Add observer for filter --- .../Mysql/Aggregation/DataProvider.php | 23 ++++++++++++++++--- .../Model/Layer/Filter/Attribute.php | 8 +++++++ .../Mysql/Aggregation/DataProviderTest.php | 12 +++++++++- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider.php b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider.php index 15856bbee7461..66f5ad7a7192b 100644 --- a/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider.php +++ b/app/code/Magento/CatalogSearch/Model/Adapter/Mysql/Aggregation/DataProvider.php @@ -16,8 +16,11 @@ use Magento\Framework\DB\Select; use Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderInterface; use Magento\Framework\Search\Request\BucketInterface; +use Magento\Framework\Event\Manager; /** + * Data Provider for catalog search. + * * @deprecated * @see \Magento\ElasticSearch */ @@ -43,12 +46,18 @@ class DataProvider implements DataProviderInterface */ private $selectBuilderForAttribute; + /** + * @var Manager + */ + private $eventManager; + /** * @param Config $eavConfig * @param ResourceConnection $resource * @param ScopeResolverInterface $scopeResolver * @param null $customerSession @deprecated * @param SelectBuilderForAttribute|null $selectBuilderForAttribute + * @param Manager|null $eventManager * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ @@ -57,17 +66,19 @@ public function __construct( ResourceConnection $resource, ScopeResolverInterface $scopeResolver, $customerSession, - SelectBuilderForAttribute $selectBuilderForAttribute = null + SelectBuilderForAttribute $selectBuilderForAttribute = null, + Manager $eventManager = null ) { $this->eavConfig = $eavConfig; $this->connection = $resource->getConnection(); $this->scopeResolver = $scopeResolver; $this->selectBuilderForAttribute = $selectBuilderForAttribute ?: ObjectManager::getInstance()->get(SelectBuilderForAttribute::class); + $this->eventManager = $eventManager ?: ObjectManager::getInstance()->get(Manager::class); } /** - * {@inheritdoc} + * @inheritdoc */ public function getDataSet( BucketInterface $bucket, @@ -83,13 +94,17 @@ public function getDataSet( 'main_table.entity_id = entities.entity_id', [] ); + $this->eventManager->dispatch( + 'catalogsearch_query_add_filter_after', + ['bucket' => $bucket, 'select' => $select] + ); $select = $this->selectBuilderForAttribute->build($select, $attribute, $currentScope); return $select; } /** - * {@inheritdoc} + * @inheritdoc */ public function execute(Select $select) { @@ -97,6 +112,8 @@ public function execute(Select $select) } /** + * Get select. + * * @return Select */ private function getSelect() diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php index 7aac6e98fc044..ea0c74a401cbc 100644 --- a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php +++ b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php @@ -156,4 +156,12 @@ private function getOptionCount($value, $optionsFacetedData) ? (int)$optionsFacetedData[$value]['count'] : 0; } + + /** + * @inheritdoc + */ + protected function isOptionReducesResults($optionCount, $totalSize) + { + return $optionCount <= $totalSize; + } } diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProviderTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProviderTest.php index 85b1b136e78d2..e3cc3e1d18377 100644 --- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProviderTest.php +++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Adapter/Mysql/Aggregation/DataProviderTest.php @@ -20,6 +20,7 @@ use Magento\Eav\Model\Entity\Attribute; use Magento\Catalog\Model\Product; use Magento\Framework\DB\Ddl\Table; +use Magento\Framework\Event\Manager; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) @@ -64,6 +65,11 @@ class DataProviderTest extends \PHPUnit\Framework\TestCase */ private $selectBuilderForAttribute; + /** + * @var Manager|\PHPUnit_Framework_MockObject_MockObject + */ + private $eventManager; + protected function setUp() { $this->eavConfigMock = $this->createMock(Config::class); @@ -73,12 +79,14 @@ protected function setUp() $this->adapterMock = $this->createMock(AdapterInterface::class); $this->resourceConnectionMock->expects($this->once())->method('getConnection')->willReturn($this->adapterMock); $this->selectBuilderForAttribute = $this->createMock(SelectBuilderForAttribute::class); + $this->eventManager = $this->createMock(Manager::class); $this->model = new DataProvider( $this->eavConfigMock, $this->resourceConnectionMock, $this->scopeResolverMock, $this->sessionMock, - $this->selectBuilderForAttribute + $this->selectBuilderForAttribute, + $this->eventManager ); } @@ -102,6 +110,7 @@ public function testGetDataSetUsesFrontendPriceIndexerTableIfAttributeIsPrice() $selectMock = $this->createMock(Select::class); $this->adapterMock->expects($this->atLeastOnce())->method('select')->willReturn($selectMock); + $this->eventManager->expects($this->once())->method('dispatch')->willReturn($selectMock); $tableMock = $this->createMock(Table::class); $this->model->getDataSet($bucketMock, ['scope' => $dimensionMock], $tableMock); @@ -129,6 +138,7 @@ public function testGetDataSetUsesFrontendPriceIndexerTableForDecimalAttributes( $selectMock = $this->createMock(Select::class); $this->selectBuilderForAttribute->expects($this->once())->method('build')->willReturn($selectMock); $this->adapterMock->expects($this->atLeastOnce())->method('select')->willReturn($selectMock); + $this->eventManager->expects($this->once())->method('dispatch')->willReturn($selectMock); $tableMock = $this->createMock(Table::class); $this->model->getDataSet($bucketMock, ['scope' => $dimensionMock], $tableMock); } From 853225e2222c62fc44166c212f8f648c66c777e5 Mon Sep 17 00:00:00 2001 From: Karen_Mkhitaryan <Karen_Mkhitaryan@epam.com> Date: Tue, 30 Oct 2018 17:22:08 +0400 Subject: [PATCH 011/121] MAGETWO-95820: Order placed by new customer before they registered is displayed in the admin under the name Guest - Add automated test --- .../CheckoutSuccessRegisterSection.xml | 1 + ...ontCheckCustomerInfoCreatedByGuestTest.xml | 62 +++++++++++++++++++ .../Test/Mftf/Data/AllowGuestCheckoutData.xml | 24 +++++++ .../Metadata/allow_guest_checkout-meta.xml | 21 +++++++ .../Sales/Test/Mftf/Page/AdminOrderPage.xml | 13 ++++ 5 files changed, 121 insertions(+) create mode 100644 app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml create mode 100644 app/code/Magento/Config/Test/Mftf/Data/AllowGuestCheckoutData.xml create mode 100644 app/code/Magento/Config/Test/Mftf/Metadata/allow_guest_checkout-meta.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/Page/AdminOrderPage.xml diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutSuccessRegisterSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutSuccessRegisterSection.xml index d0ef8d347efb5..0d692e4ab143e 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutSuccessRegisterSection.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutSuccessRegisterSection.xml @@ -12,5 +12,6 @@ <element name="registerMessage" type="text" selector="#registration p:nth-child(1)"/> <element name="customerEmail" type="text" selector="#registration p:nth-child(2)"/> <element name="createAccountButton" type="button" selector="#registration form input[type='submit']" timeout="30"/> + <element name="orderNumber" type="text" selector="//p[text()='Your order # is: ']//span"/> </section> </sections> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml new file mode 100644 index 0000000000000..2e2dee82a6eaf --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml @@ -0,0 +1,62 @@ +<?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="StoreFrontCheckCustomerInfoCreatedByGuestTest"> + <annotations> + <features value="Checkout"/> + <stories value="Check customer information created by guest"/> + <title value="Check Customer Information Created By Guest"/> + <description value="Check customer information after placing the order as the guest who created an account"/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-95820"/> + <group value="checkout"/> + </annotations> + + <before> + <createData entity="_defaultCategory" stepKey="category"/> + <createData entity="_defaultProduct" stepKey="product"> + <requiredEntity createDataKey="category"/> + </createData> + <createData entity="EnableAllowGuestCheckout" stepKey="enableGuestCheckout"/> + <magentoCLI command="cache:flush" stepKey="flushCache"/> + </before> + + <after> + <deleteData createDataKey="product" stepKey="deleteProduct" /> + <deleteData createDataKey="category" stepKey="deleteCategory" /> + <actionGroup ref="logout" stepKey="logoutFromAdmin"/> + </after> + + <amOnPage url="$$product.name$$.html" stepKey="navigateToProductPage"/> + <waitForPageLoad stepKey="waitForProductPage"/> + <actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartFromStorefrontProductPage"> + <argument name="productName" value="$$product.name$$"/> + </actionGroup> + <actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/> + <actionGroup ref="GuestCheckoutFillingShippingSectionActionGroup" stepKey="guestCheckoutFillingShippingSection"> + <argument name="customerVar" value="CustomerEntityOne"/> + <argument name="customerAddressVar" value="CustomerAddressSimple"/> + </actionGroup> + <actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="placeOrder"> + <argument name="orderNumberMessage" value="CONST.successGuestCheckoutOrderNumberMessage"/> + <argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" /> + </actionGroup> + <grabTextFrom selector="{{CheckoutSuccessRegisterSection.orderNumber}}" stepKey="grabOrderNumber"/> + <click selector="{{CustomerAccountSection.createAccount}}" stepKey="clickToCreateAccount"/> + <fillField selector="{{StorefrontCustomerCreateFormSection.passwordField}}" userInput="{{CustomerData.password}}" stepKey="TypePassword"/> + <fillField selector="{{StorefrontCustomerCreateFormSection.confirmPasswordField}}" userInput="{{CustomerData.password}}" stepKey="TypeConfirmationPassword"/> + <click selector="{{StorefrontCustomerCreateFormSection.createAccountButton}}" stepKey="clickOnCreateAccount"/> + <see userInput="Thank you for registering" stepKey="verifyAccountCreated"/> + <actionGroup ref="LoginAsAdmin" stepKey="loginToAdmin"/> + <amOnPage url="{{AdminOrderPage.url({$grabOrderNumber})}}" stepKey="navigateToOrderPage"/> + <waitForPageLoad stepKey="waitForCreatedOrderPage"/> + <see stepKey="seeCustomerName" userInput="{{CustomerEntityOne.firstname}}" selector="{{AdminShipmentOrderInformationSection.customerName}}"/> + </test> +</tests> diff --git a/app/code/Magento/Config/Test/Mftf/Data/AllowGuestCheckoutData.xml b/app/code/Magento/Config/Test/Mftf/Data/AllowGuestCheckoutData.xml new file mode 100644 index 0000000000000..f89cdf1a87b31 --- /dev/null +++ b/app/code/Magento/Config/Test/Mftf/Data/AllowGuestCheckoutData.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="EnableAllowGuestCheckout" type="allow_guest_checkout_config"> + <requiredEntity type="guest_checkout">AllowGuestCheckoutYes</requiredEntity> + </entity> + <entity name="AllowGuestCheckoutYes" type="guest_checkout"> + <data key="value">1</data> + </entity> + + <entity name="DisableAllowGuestCheckout" type="allow_guest_checkout_config"> + <requiredEntity type="guest_checkout">AllowGuestCheckoutNo</requiredEntity> + </entity> + <entity name="AllowGuestCheckoutNo" type="guest_checkout"> + <data key="value">0</data> + </entity> +</entities> diff --git a/app/code/Magento/Config/Test/Mftf/Metadata/allow_guest_checkout-meta.xml b/app/code/Magento/Config/Test/Mftf/Metadata/allow_guest_checkout-meta.xml new file mode 100644 index 0000000000000..052d9b6574774 --- /dev/null +++ b/app/code/Magento/Config/Test/Mftf/Metadata/allow_guest_checkout-meta.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<operations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataOperation.xsd"> + <operation name="AllowGuestCheckoutConfig" dataType="allow_guest_checkout_config" type="create" auth="adminFormKey" url="/admin/system_config/save/section/checkout/" method="POST"> + <object key="groups" dataType="allow_guest_checkout_config"> + <object key="options" dataType="allow_guest_checkout_config"> + <object key="fields" dataType="allow_guest_checkout_config"> + <object key="guest_checkout" dataType="guest_checkout"> + <field key="value">string</field> + </object> + </object> + </object> + </object> + </operation> +</operations> diff --git a/app/code/Magento/Sales/Test/Mftf/Page/AdminOrderPage.xml b/app/code/Magento/Sales/Test/Mftf/Page/AdminOrderPage.xml new file mode 100644 index 0000000000000..6abe265a37b79 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Page/AdminOrderPage.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> + <page name="AdminOrderPage" url="sales/order/view/order_id/{{var1}}" area="admin" module="Magento_Sales" parameterized="true"> + </page> +</pages> From 1b14b277e13ac05489b69caf75c0068c9dba6518 Mon Sep 17 00:00:00 2001 From: Yauhen_Lyskavets <yauhen_lyskavets@epam.com> Date: Thu, 25 Oct 2018 15:37:41 +0300 Subject: [PATCH 012/121] MAGETWO-95823: Order Sales Report includes canceled orders - Bug fix. --- .../Block/Adminhtml/Sales/Sales/Grid.php | 67 ++++++++++++++++++- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php index 9f5f784df677f..25a4aa1b88ca4 100644 --- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php +++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php @@ -6,23 +6,58 @@ namespace Magento\Reports\Block\Adminhtml\Sales\Sales; +use Magento\Framework\DataObject; use Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Currency; +use Magento\Framework\App\ObjectManager; +use Magento\Sales\Model\Order\ConfigFactory; +use Magento\Sales\Model\Order; /** * Adminhtml sales report grid block * - * @author Magento Core Team <core@magentocommerce.com> * @SuppressWarnings(PHPMD.DepthOfInheritance) */ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid { /** - * GROUP BY criteria - * * @var string */ protected $_columnGroupBy = 'period'; + /** + * @var ConfigFactory + */ + private $configFactory; + + /** + * @param \Magento\Backend\Block\Template\Context $context + * @param \Magento\Backend\Helper\Data $backendHelper + * @param \Magento\Reports\Model\ResourceModel\Report\Collection\Factory $resourceFactory + * @param \Magento\Reports\Model\Grouped\CollectionFactory $collectionFactory + * @param \Magento\Reports\Helper\Data $reportsData + * @param array $data + * @param ConfigFactory|null $configFactory + */ + public function __construct( + \Magento\Backend\Block\Template\Context $context, + \Magento\Backend\Helper\Data $backendHelper, + \Magento\Reports\Model\ResourceModel\Report\Collection\Factory $resourceFactory, + \Magento\Reports\Model\Grouped\CollectionFactory $collectionFactory, + \Magento\Reports\Helper\Data $reportsData, + array $data = [], + ConfigFactory $configFactory = null + ) { + parent::__construct( + $context, + $backendHelper, + $resourceFactory, + $collectionFactory, + $reportsData, + $data + ); + $this->configFactory = $configFactory ?: ObjectManager::getInstance()->get(ConfigFactory::class); + } + /** * Reports grid constructor * @@ -331,4 +366,30 @@ protected function _prepareColumns() return parent::_prepareColumns(); } + + /** + * @inheritdoc + * + * Filter canceled statuses for orders. + * + * @return Grid + */ + protected function _prepareCollection() + { + /** @var DataObject $filterData */ + $filterData = $this->getData('filter_data'); + if (!$filterData->hasData('order_statuses')) { + $orderConfig = $this->configFactory->create(); + $statusValues = []; + $canceledStatuses = $orderConfig->getStateStatuses(Order::STATE_CANCELED); + $statusCodes = array_keys($orderConfig->getStatuses()); + foreach ($statusCodes as $code) { + if (!isset($canceledStatuses[$code])) { + $statusValues[] = $code; + } + } + $filterData->setData('order_statuses', $statusValues); + } + return parent::_prepareCollection(); + } } From f886f15f327f4e62ab65ba235a5cff4b67d30306 Mon Sep 17 00:00:00 2001 From: Lusine <lusine_papyan@epam.com> Date: Thu, 1 Nov 2018 15:42:16 +0400 Subject: [PATCH 013/121] MAGETWO-95823: Order Sales Report includes canceled orders - Add automated test. --- .../GenerateOrderReportActionGroup.xml | 22 +++++ .../Test/Mftf/Page/OrdersReportPage.xml | 14 ++++ .../Mftf/Section/OrderReportMainSection.xml | 28 +++++++ .../CancelOrdersInOrderSalesReportTest.xml | 80 +++++++++++++++++++ .../ActionGroup/AdminOrderActionGroup.xml | 24 +++++- 5 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Reports/Test/Mftf/ActionGroup/GenerateOrderReportActionGroup.xml create mode 100644 app/code/Magento/Reports/Test/Mftf/Page/OrdersReportPage.xml create mode 100644 app/code/Magento/Reports/Test/Mftf/Section/OrderReportMainSection.xml create mode 100644 app/code/Magento/Reports/Test/Mftf/Test/CancelOrdersInOrderSalesReportTest.xml diff --git a/app/code/Magento/Reports/Test/Mftf/ActionGroup/GenerateOrderReportActionGroup.xml b/app/code/Magento/Reports/Test/Mftf/ActionGroup/GenerateOrderReportActionGroup.xml new file mode 100644 index 0000000000000..b96a367903ac8 --- /dev/null +++ b/app/code/Magento/Reports/Test/Mftf/ActionGroup/GenerateOrderReportActionGroup.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="GenerateOrderReportActionGroup"> + <arguments> + <argument name="orderFromDate" type="string"/> + <argument name="orderToDate" type="string"/> + </arguments> + <click selector="{{OrderReportMainSection.here}}" stepKey="clickOnHere" /> + <fillField selector="{{OrderReportFilterSection.dateFrom}}" userInput="{{orderFromDate}}" stepKey="fillFromDate"/> + <fillField selector="{{OrderReportFilterSection.dateTo}}" userInput="{{orderToDate}}" stepKey="fillToDate"/> + <selectOption selector="{{OrderReportFilterSection.orderStatus}}" userInput="Any" stepKey="selectAnyOption" /> + <click selector="{{OrderReportMainSection.showReport}}" stepKey="showReport" /> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Reports/Test/Mftf/Page/OrdersReportPage.xml b/app/code/Magento/Reports/Test/Mftf/Page/OrdersReportPage.xml new file mode 100644 index 0000000000000..46509089b97ba --- /dev/null +++ b/app/code/Magento/Reports/Test/Mftf/Page/OrdersReportPage.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> + <page name="OrdersReportPage" url="reports/report_sales/sales/" area="admin" module="Reports"> + <section name="OrderReportFilterSection"/> + <section name="OrderReportMainSection"/> + <section name="GeneratedReportSection" /> + </page> +</pages> diff --git a/app/code/Magento/Reports/Test/Mftf/Section/OrderReportMainSection.xml b/app/code/Magento/Reports/Test/Mftf/Section/OrderReportMainSection.xml new file mode 100644 index 0000000000000..fb71a67da87dc --- /dev/null +++ b/app/code/Magento/Reports/Test/Mftf/Section/OrderReportMainSection.xml @@ -0,0 +1,28 @@ +<?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="OrderReportMainSection"> + <element name="showReport" type="button" selector="#filter_form_submit"/> + <element name="here" type="text" selector="//a[contains(text(), 'here')]"/> + </section> + + <section name="OrderReportFilterSection"> + <element name="dateFrom" type="input" selector="#sales_report_from"/> + <element name="dateTo" type="input" selector="#sales_report_to"/> + <element name="orderStatus" type="select" selector="#sales_report_show_order_statuses"/> + <element name="optionAny" type="option" selector="//select[@id='sales_report_show_order_statuses']/option[contains(text(), 'Any')]"/> + <element name="optionSpecified" type="option" selector="//select[@id='sales_report_show_order_statuses']/option[contains(text(), 'Specified')]"/> + </section> + + <section name="GeneratedReportSection"> + <element name="ordersCount" type="text" selector="//tr[@class='totals']/th[@class=' col-orders col-orders_count col-number']"/> + <element name="canceledOrders" type="text" selector="//tr[@class='totals']/th[@class=' col-canceled col-total_canceled_amount a-right']"/> + </section> +</sections> diff --git a/app/code/Magento/Reports/Test/Mftf/Test/CancelOrdersInOrderSalesReportTest.xml b/app/code/Magento/Reports/Test/Mftf/Test/CancelOrdersInOrderSalesReportTest.xml new file mode 100644 index 0000000000000..967b0f3caf515 --- /dev/null +++ b/app/code/Magento/Reports/Test/Mftf/Test/CancelOrdersInOrderSalesReportTest.xml @@ -0,0 +1,80 @@ +<?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="CancelOrdersInOrderSalesReportTest"> + <annotations> + <features value="Reports"/> + <stories value="MAGETWO-95823: Order Sales Report includes canceled orders"/> + <group value="reports"/> + <title value="Canceled orders in order sales report"/> + <description value="Verify canceling of orders in order sales report"/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-95960"/> + </annotations> + + <before> + <!-- log in as admin --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + + <!-- create new product --> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="SimpleProduct" stepKey="createSimpleProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + + <!-- create new customer--> + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> + </before> + + <!-- Create completed order --> + <actionGroup ref="CreateOrderActionGroup" stepKey="createOrderd"> + <argument name="product" value="$$createSimpleProduct$$"/> + <argument name="customer" value="$$createCustomer$$"/> + </actionGroup> + + <click selector="{{AdminOrderDetailsMainActionsSection.invoice}}" stepKey="clickInvoiceAction"/> + <see selector="{{AdminHeaderSection.pageTitle}}" userInput="New Invoice" stepKey="seePageNameNewInvoicePage"/> + <click selector="{{AdminInvoiceMainActionsSection.submitInvoice}}" stepKey="clickSubmitInvoice"/> + + <click selector="{{AdminOrderDetailsMainActionsSection.ship}}" stepKey="clickShipAction"/> + <seeInCurrentUrl url="{{AdminShipmentNewPage.url}}" stepKey="seeOrderShipmentUrl"/> + <click selector="{{AdminShipmentMainActionsSection.submitShipment}}" stepKey="clickSubmitShipment"/> + + <!-- Create Order --> + <actionGroup ref="CreateOrderActionGroup" stepKey="createOrder"> + <argument name="product" value="$$createSimpleProduct$$"/> + <argument name="customer" value="$$createCustomer$$"/> + </actionGroup> + + <!-- Cancel order --> + <actionGroup ref="cancelPendingOrder" stepKey="cancelOrder"/> + + <!-- Generate Order report --> + <amOnPage url="{{OrdersReportPage.url}}" stepKey="goToOrdersReportPage1"/> + <!-- Get date --> + <generateDate stepKey="generateEndDate" date="+0 day" format="m/d/Y"/> + <generateDate stepKey="generateStartDate" date="-1 day" format="m/d/Y"/> + <actionGroup ref="GenerateOrderReportActionGroup" stepKey="generateReportAfterCancelOrder"> + <argument name="orderFromDate" value="$generateStartDate"/> + <argument name="orderToDate" value="$generateEndDate"/> + </actionGroup> + <waitForElement selector="{{GeneratedReportSection.ordersCount}}" stepKey="waitForOrdersCount"/> + <grabTextFrom selector="{{GeneratedReportSection.canceledOrders}}" stepKey="grabCanceledOrdersPrice"/> + + <!-- Compare canceled orders price --> + <assertEquals expected="$0.00" expectedType="string" actual="{$grabCanceledOrdersPrice}" actualType="string" stepKey="assertEquals"/> + + <after> + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + </test> +</tests> diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderActionGroup.xml index 53dc52ca58fa7..7df9fb6552f19 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderActionGroup.xml @@ -296,4 +296,26 @@ <see selector="{{AdminMessagesSection.success}}" userInput="You canceled the order." stepKey="seeCancelSuccessMessage"/> <see selector="{{AdminOrderDetailsInformationSection.orderStatus}}" userInput="Canceled" stepKey="seeOrderStatusCanceled"/> </actionGroup> -</actionGroups> \ No newline at end of file + + <!-- Create Order --> + <actionGroup name="CreateOrderActionGroup"> + <arguments> + <argument name="product"/> + <argument name="customer"/> + </arguments> + <amOnPage stepKey="navigateToNewOrderPage" url="{{AdminOrderCreatePage.url}}"/> + <click stepKey="chooseCustomer" selector="{{AdminOrdersGridSection.customerInOrdersSection(customer.firstname)}}"/> + <waitForPageLoad stepKey="waitForStoresPageOpened"/> + <click selector="{{OrdersGridSection.addProducts}}" stepKey="clickOnAddProducts"/> + <waitForPageLoad stepKey="waitForProductsListForOrder"/> + <click selector="{{AdminOrdersGridSection.productForOrder(product.sku)}}" stepKey="chooseTheProduct"/> + <click selector="{{AdminOrderFormItemsSection.addSelected}}" stepKey="addSelectedProductToOrder"/> + <waitForPageLoad stepKey="waitForProductAddedInOrder"/> + <click selector="{{AdminInvoicePaymentShippingSection.getShippingMethodAndRates}}" stepKey="openShippingMethod"/> + <waitForPageLoad stepKey="waitForShippingMethods"/> + <click selector="{{AdminInvoicePaymentShippingSection.shippingMethod}}" stepKey="chooseShippingMethod"/> + <waitForPageLoad stepKey="waitForShippingMethodsThickened"/> + <click selector="{{OrdersGridSection.submitOrder}}" stepKey="submitOrder"/> + <see stepKey="seeSuccessMessageForOrder" userInput="You created the order."/> + </actionGroup> +</actionGroups> From 9edabc7755a90fdfaa3a774415e076b495b4f0ca Mon Sep 17 00:00:00 2001 From: David Grigoryan <david_grigoryan@epam.com> Date: Fri, 2 Nov 2018 16:28:02 +0400 Subject: [PATCH 014/121] MAGETWO-95822: Layered Navigation shows options not available - Add automated test --- .../AdminAddOptionsToAttributeActionGroup.xml | 44 +++++++++++++++++++ ...reateProductConfigurationsPanelSection.xml | 1 + .../Section/AdminNewAttributePanelSection.xml | 1 + .../Mftf/Section/LayeredNavigationSection.xml | 4 ++ .../Section/AdminDataGridHeaderSection.xml | 2 + 5 files changed, 52 insertions(+) create mode 100644 app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminAddOptionsToAttributeActionGroup.xml diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminAddOptionsToAttributeActionGroup.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminAddOptionsToAttributeActionGroup.xml new file mode 100644 index 0000000000000..4328159d6e930 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminAddOptionsToAttributeActionGroup.xml @@ -0,0 +1,44 @@ +<?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="addOptionsToAttributeActionGroup"> + <arguments> + <argument name="option1" defaultValue="colorProductAttribute2"/> + <argument name="option2" defaultValue="colorDefaultProductAttribute1"/> + <argument name="option3" defaultValue="colorProductAttribute3"/> + <argument name="option4" defaultValue="colorProductAttribute1"/> + <argument name="option5" defaultValue="colorDefaultProductAttribute2"/> + </arguments> + <!--Add option 1 to attribute--> + <click selector="{{AdminNewAttributePanel.addOption}}" stepKey="clickAddOption1"/> + <waitForElementVisible selector="{{AdminNewAttributePanel.isDefault('1')}}" time="30" stepKey="waitForOptionRow1" after="clickAddOption1"/> + <fillField selector="{{AdminNewAttributePanel.optionAdminValue('0')}}" userInput="{{option1.name}}" stepKey="fillAdminLabel1" after="waitForOptionRow1"/> + <!--Add option 2 to attribute--> + <click selector="{{AdminNewAttributePanel.addOption}}" stepKey="clickAddOption2" after="fillAdminLabel1"/> + <waitForElementVisible selector="{{AdminNewAttributePanel.isDefault('2')}}" time="30" stepKey="waitForOptionRow2" after="clickAddOption2"/> + <fillField selector="{{AdminNewAttributePanel.optionAdminValue('1')}}" userInput="{{option2.name}}" stepKey="fillAdminLabel2" after="waitForOptionRow2"/> + <!--Add option 3 to attribute--> + <click selector="{{AdminNewAttributePanel.addOption}}" stepKey="clickAddOption3" after="fillAdminLabel2"/> + <waitForElementVisible selector="{{AdminNewAttributePanel.isDefault('3')}}" time="30" stepKey="waitForOptionRow3" after="clickAddOption3"/> + <fillField selector="{{AdminNewAttributePanel.optionAdminValue('2')}}" userInput="{{option3.name}}" stepKey="fillAdminLabel3" after="waitForOptionRow3"/> + <!--Add option 4 to attribute--> + <click selector="{{AdminNewAttributePanel.addOption}}" stepKey="clickAddOption4" after="fillAdminLabel3"/> + <waitForElementVisible selector="{{AdminNewAttributePanel.isDefault('4')}}" time="30" stepKey="waitForOptionRow4" after="clickAddOption4"/> + <fillField selector="{{AdminNewAttributePanel.optionAdminValue('3')}}" userInput="{{option4.name}}" stepKey="fillAdminLabel4" after="waitForOptionRow4"/> + <!--Add option 5 to attribute--> + <click selector="{{AdminNewAttributePanel.addOption}}" stepKey="clickAddOption5" after="fillAdminLabel4"/> + <waitForElementVisible selector="{{AdminNewAttributePanel.isDefault('5')}}" time="30" stepKey="waitForOptionRow5" after="clickAddOption5"/> + <fillField selector="{{AdminNewAttributePanel.optionAdminValue('4')}}" userInput="{{option5.name}}" stepKey="fillAdminLabel5" after="waitForOptionRow5"/> + <!--Save attribute--> + <click selector="{{AdminNewAttributePanel.saveAttribute}}" stepKey="clickSaveAttribute" after="fillAdminLabel5"/> + <waitForPageLoad stepKey="waitForSavingAttribute"/> + <see userInput="You saved the product attribute." stepKey="seeSuccessMessage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminCreateProductConfigurationsPanelSection.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminCreateProductConfigurationsPanelSection.xml index 99e47baac37d5..fa018c07bcea8 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminCreateProductConfigurationsPanelSection.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminCreateProductConfigurationsPanelSection.xml @@ -35,5 +35,6 @@ <element name="applySingleQuantityToEachSkus" type="radio" selector=".admin__field-label[for='apply-single-inventory-radio']" timeout="30"/> <element name="quantity" type="input" selector="#apply-single-inventory-input"/> <element name="gridLoadingMask" type="text" selector="[data-role='spinner'][data-component*='product_attributes_listing']"/> + <element name="attributeCheckboxByName" type="input" selector="//*[contains(@data-attribute-option-title,'{{arg}}')]//input[@type='checkbox']" parameterized="true"/> </section> </sections> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminNewAttributePanelSection.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminNewAttributePanelSection.xml index 44077888f8bc0..1df777f44f2f4 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminNewAttributePanelSection.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminNewAttributePanelSection.xml @@ -20,5 +20,6 @@ <element name="optionAdminValue" type="input" selector="[data-role='options-container'] input[name='option[value][option_{{row}}][0]']" parameterized="true"/> <element name="optionDefaultStoreValue" type="input" selector="[data-role='options-container'] input[name='option[value][option_{{row}}][1]']" parameterized="true"/> <element name="deleteOption" type="button" selector="#delete_button_option_{{row}}" parameterized="true"/> + <element name="deleteOptionByName" type="button" selector="//*[contains(@value, '{{arg}}')]/../following-sibling::td[contains(@id, 'delete_button_container')]/button" parameterized="true"/> </section> </sections> diff --git a/app/code/Magento/LayeredNavigation/Test/Mftf/Section/LayeredNavigationSection.xml b/app/code/Magento/LayeredNavigation/Test/Mftf/Section/LayeredNavigationSection.xml index ad94d44d636e9..b44ee9ddbd734 100644 --- a/app/code/Magento/LayeredNavigation/Test/Mftf/Section/LayeredNavigationSection.xml +++ b/app/code/Magento/LayeredNavigation/Test/Mftf/Section/LayeredNavigationSection.xml @@ -16,4 +16,8 @@ <element name="PriceNavigationStep" type="button" selector="#catalog_layered_navigation_price_range_step"/> <element name="PriceNavigationStepSystemValue" type="button" selector="#catalog_layered_navigation_price_range_step_inherit"/> </section> + + <section name="StorefrontLayeredNavigationSection"> + <element name="shoppingOptionsByName" type="button" selector="//*[text()='Shopping Options']/..//*[contains(text(),'{{arg}}')]" parameterized="true"/> + </section> </sections> diff --git a/app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridHeaderSection.xml b/app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridHeaderSection.xml index 3e917a5944f95..4ee38e30f98e6 100644 --- a/app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridHeaderSection.xml +++ b/app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridHeaderSection.xml @@ -25,5 +25,7 @@ <!--Visible columns management--> <element name="columnsToggle" type="button" selector="div.admin__data-grid-action-columns button[data-bind='toggleCollapsible']" timeout="30"/> <element name="columnCheckbox" type="checkbox" selector="//div[contains(@class,'admin__data-grid-action-columns')]//div[contains(@class, 'admin__field-option')]//label[text() = '{{column}}']/preceding-sibling::input" parameterized="true"/> + <element name="perPage" type="select" selector="#product_attributes_listing.product_attributes_listing.listing_top.listing_paging_sizes"/> + <element name="attributeName" type="input" selector="//div[text()='{{arg}}']/../preceding-sibling::td//input" parameterized="true"/> </section> </sections> From bbf124759cf3d27dd4bfee4a9c4e3a3969bc59ff Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky <p.bystritsky@yandex.ru> Date: Tue, 13 Nov 2018 11:56:42 +0200 Subject: [PATCH 015/121] magento/magento2#14849: [Forwardport] In Sales Emails no translation using order.getStatusLabel(). --- app/code/Magento/Sales/Model/Order.php | 24 ++++++++--- app/code/Magento/Sales/Model/Order/Config.php | 42 +++++++++++++++---- .../frontend/email/creditmemo_update.html | 4 +- .../email/creditmemo_update_guest.html | 4 +- .../view/frontend/email/invoice_update.html | 4 +- .../frontend/email/invoice_update_guest.html | 4 +- .../view/frontend/email/order_update.html | 4 +- .../frontend/email/order_update_guest.html | 4 +- .../view/frontend/email/shipment_update.html | 4 +- .../frontend/email/shipment_update_guest.html | 4 +- .../email/creditmemo_update.html | 4 +- .../email/creditmemo_update_guest.html | 4 +- .../Magento_Sales/email/invoice_update.html | 4 +- .../email/invoice_update_guest.html | 4 +- .../Magento_Sales/email/order_update.html | 4 +- .../email/order_update_guest.html | 4 +- .../Magento_Sales/email/shipment_update.html | 4 +- .../email/shipment_update_guest.html | 4 +- 18 files changed, 84 insertions(+), 46 deletions(-) diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index 345ff036a2be6..e223f213b86f7 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -8,6 +8,7 @@ use Magento\Directory\Model\Currency; use Magento\Framework\Api\AttributeValueFactory; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Locale\ResolverInterface; use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Sales\Api\Data\OrderInterface; @@ -1024,10 +1025,21 @@ public function setState($state) return $this->setData(self::STATE, $state); } + /** + * Retrieve frontend label of order status + * + * @return string + */ + public function getFrontendStatusLabel() + { + return $this->getConfig()->getStatusFrontendLabel($this->getStatus()); + } + /** * Retrieve label of order status * * @return string + * @throws LocalizedException */ public function getStatusLabel() { @@ -1135,12 +1147,12 @@ public function place() * Hold order * * @return $this - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function hold() { if (!$this->canHold()) { - throw new \Magento\Framework\Exception\LocalizedException(__('A hold action is not available.')); + throw new LocalizedException(__('A hold action is not available.')); } $this->setHoldBeforeState($this->getState()); $this->setHoldBeforeStatus($this->getStatus()); @@ -1153,12 +1165,12 @@ public function hold() * Attempt to unhold the order * * @return $this - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException */ public function unhold() { if (!$this->canUnhold()) { - throw new \Magento\Framework\Exception\LocalizedException(__('You cannot remove the hold.')); + throw new LocalizedException(__('You cannot remove the hold.')); } $this->setState($this->getHoldBeforeState()) @@ -1202,7 +1214,7 @@ public function isFraudDetected() * @param string $comment * @param bool $graceful * @return $this - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function registerCancellation($comment = '', $graceful = true) @@ -1241,7 +1253,7 @@ public function registerCancellation($comment = '', $graceful = true) $this->addStatusHistoryComment($comment, false); } } elseif (!$graceful) { - throw new \Magento\Framework\Exception\LocalizedException(__('We cannot cancel this order.')); + throw new LocalizedException(__('We cannot cancel this order.')); } return $this; } diff --git a/app/code/Magento/Sales/Model/Order/Config.php b/app/code/Magento/Sales/Model/Order/Config.php index e00eda647dc8d..8999fca174de9 100644 --- a/app/code/Magento/Sales/Model/Order/Config.php +++ b/app/code/Magento/Sales/Model/Order/Config.php @@ -5,6 +5,8 @@ */ namespace Magento\Sales\Model\Order; +use Magento\Framework\Exception\LocalizedException; + /** * Order configuration model * @@ -85,7 +87,7 @@ protected function _getCollection() /** * @param string $state - * @return Status|null + * @return Status */ protected function _getState($state) { @@ -101,7 +103,7 @@ protected function _getState($state) * Retrieve default status for state * * @param string $state - * @return string + * @return string|null */ public function getStateDefaultStatus($state) { @@ -115,24 +117,48 @@ public function getStateDefaultStatus($state) } /** - * Retrieve status label + * Get status label for a specified area * - * @param string $code - * @return string + * @param string $code + * @param string $area + * @return string */ - public function getStatusLabel($code) + private function getStatusLabelForArea(string $code, string $area): string { - $area = $this->state->getAreaCode(); $code = $this->maskStatusForArea($area, $code); $status = $this->orderStatusFactory->create()->load($code); - if ($area == 'adminhtml') { + if ($area === 'adminhtml') { return $status->getLabel(); } return $status->getStoreLabel(); } + /** + * Retrieve status label for detected area + * + * @param string $code + * @return string + * @throws LocalizedException + */ + public function getStatusLabel($code) + { + $area = $this->state->getAreaCode() ?: \Magento\Framework\App\Area::AREA_FRONTEND; + return $this->getStatusLabelForArea($code, $area); + } + + /** + * Retrieve status label for area + * + * @param string $code + * @return string + */ + public function getStatusFrontendLabel(string $code): string + { + return $this->getStatusLabelForArea($code, \Magento\Framework\App\Area::AREA_FRONTEND); + } + /** * Mask status for order for specified area * diff --git a/app/code/Magento/Sales/view/frontend/email/creditmemo_update.html b/app/code/Magento/Sales/view/frontend/email/creditmemo_update.html index 3a4aab19e9e7c..a6a10fb49e3f5 100644 --- a/app/code/Magento/Sales/view/frontend/email/creditmemo_update.html +++ b/app/code/Magento/Sales/view/frontend/email/creditmemo_update.html @@ -11,7 +11,7 @@ "var this.getUrl($store, 'customer/account/')":"Customer Account URL", "var order.getCustomerName()":"Customer Name", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status" +"var order.getFrontendStatusLabel()":"Order Status" } @--> {{template config_path="design/email/header_template"}} @@ -24,7 +24,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} </p> <p>{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p> diff --git a/app/code/Magento/Sales/view/frontend/email/creditmemo_update_guest.html b/app/code/Magento/Sales/view/frontend/email/creditmemo_update_guest.html index bc7c079d7f21b..b7411d80d2ba6 100644 --- a/app/code/Magento/Sales/view/frontend/email/creditmemo_update_guest.html +++ b/app/code/Magento/Sales/view/frontend/email/creditmemo_update_guest.html @@ -10,7 +10,7 @@ "var creditmemo.increment_id":"Credit Memo Id", "var billing.getName()":"Guest Customer Name", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status" +"var order.getFrontendStatusLabel()":"Order Status" } @--> {{template config_path="design/email/header_template"}} @@ -23,7 +23,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} </p> <p> diff --git a/app/code/Magento/Sales/view/frontend/email/invoice_update.html b/app/code/Magento/Sales/view/frontend/email/invoice_update.html index cafdd65ff5208..4043e59f9d7d6 100644 --- a/app/code/Magento/Sales/view/frontend/email/invoice_update.html +++ b/app/code/Magento/Sales/view/frontend/email/invoice_update.html @@ -11,7 +11,7 @@ "var comment":"Invoice Comment", "var invoice.increment_id":"Invoice Id", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status" +"var order.getFrontendStatusLabel()":"Order Status" } @--> {{template config_path="design/email/header_template"}} @@ -24,7 +24,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} </p> <p>{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p> diff --git a/app/code/Magento/Sales/view/frontend/email/invoice_update_guest.html b/app/code/Magento/Sales/view/frontend/email/invoice_update_guest.html index fafb533301efb..40cdec7fb4cab 100644 --- a/app/code/Magento/Sales/view/frontend/email/invoice_update_guest.html +++ b/app/code/Magento/Sales/view/frontend/email/invoice_update_guest.html @@ -10,7 +10,7 @@ "var comment":"Invoice Comment", "var invoice.increment_id":"Invoice Id", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status" +"var order.getFrontendStatusLabel()":"Order Status" } @--> {{template config_path="design/email/header_template"}} @@ -23,7 +23,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} </p> <p> diff --git a/app/code/Magento/Sales/view/frontend/email/order_update.html b/app/code/Magento/Sales/view/frontend/email/order_update.html index a709a9ed8a7f1..a8f0068b70e87 100644 --- a/app/code/Magento/Sales/view/frontend/email/order_update.html +++ b/app/code/Magento/Sales/view/frontend/email/order_update.html @@ -10,7 +10,7 @@ "var order.getCustomerName()":"Customer Name", "var comment":"Order Comment", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status" +"var order.getFrontendStatusLabel()":"Order Status" } @--> {{template config_path="design/email/header_template"}} @@ -23,7 +23,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} </p> <p>{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p> diff --git a/app/code/Magento/Sales/view/frontend/email/order_update_guest.html b/app/code/Magento/Sales/view/frontend/email/order_update_guest.html index 5a39b01810c18..749fa3b60ad59 100644 --- a/app/code/Magento/Sales/view/frontend/email/order_update_guest.html +++ b/app/code/Magento/Sales/view/frontend/email/order_update_guest.html @@ -9,7 +9,7 @@ "var billing.getName()":"Guest Customer Name", "var comment":"Order Comment", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status" +"var order.getFrontendStatusLabel()":"Order Status" } @--> {{template config_path="design/email/header_template"}} @@ -22,7 +22,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} </p> <p> diff --git a/app/code/Magento/Sales/view/frontend/email/shipment_update.html b/app/code/Magento/Sales/view/frontend/email/shipment_update.html index 6d9efc37004bc..9d1c93287549a 100644 --- a/app/code/Magento/Sales/view/frontend/email/shipment_update.html +++ b/app/code/Magento/Sales/view/frontend/email/shipment_update.html @@ -10,7 +10,7 @@ "var order.getCustomerName()":"Customer Name", "var comment":"Order Comment", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status", +"var order.getFrontendStatusLabel()":"Order Status", "var shipment.increment_id":"Shipment Id" } @--> {{template config_path="design/email/header_template"}} @@ -24,7 +24,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} </p> <p>{{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p> diff --git a/app/code/Magento/Sales/view/frontend/email/shipment_update_guest.html b/app/code/Magento/Sales/view/frontend/email/shipment_update_guest.html index 4896a00b7bc5a..0d2dccd3377d2 100644 --- a/app/code/Magento/Sales/view/frontend/email/shipment_update_guest.html +++ b/app/code/Magento/Sales/view/frontend/email/shipment_update_guest.html @@ -9,7 +9,7 @@ "var billing.getName()":"Guest Customer Name", "var comment":"Order Comment", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status", +"var order.getFrontendStatusLabel()":"Order Status", "var shipment.increment_id":"Shipment Id" } @--> {{template config_path="design/email/header_template"}} @@ -23,7 +23,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} </p> <p> diff --git a/app/design/frontend/Magento/luma/Magento_Sales/email/creditmemo_update.html b/app/design/frontend/Magento/luma/Magento_Sales/email/creditmemo_update.html index a7b9b330ab9ce..269e46d752084 100644 --- a/app/design/frontend/Magento/luma/Magento_Sales/email/creditmemo_update.html +++ b/app/design/frontend/Magento/luma/Magento_Sales/email/creditmemo_update.html @@ -11,7 +11,7 @@ "var this.getUrl($store, 'customer/account/')":"Customer Account URL", "var order.getCustomerName()":"Customer Name", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status" +"var order.getFrontendStatusLabel()":"Order Status" } @--> {{template config_path="design/email/header_template"}} @@ -24,7 +24,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} {{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}} </p> diff --git a/app/design/frontend/Magento/luma/Magento_Sales/email/creditmemo_update_guest.html b/app/design/frontend/Magento/luma/Magento_Sales/email/creditmemo_update_guest.html index 36279eb26005e..c8bdae7b08fa5 100644 --- a/app/design/frontend/Magento/luma/Magento_Sales/email/creditmemo_update_guest.html +++ b/app/design/frontend/Magento/luma/Magento_Sales/email/creditmemo_update_guest.html @@ -10,7 +10,7 @@ "var creditmemo.increment_id":"Credit Memo Id", "var billing.getName()":"Guest Customer Name", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status" +"var order.getFrontendStatusLabel()":"Order Status" } @--> {{template config_path="design/email/header_template"}} @@ -23,7 +23,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} </p> <p> diff --git a/app/design/frontend/Magento/luma/Magento_Sales/email/invoice_update.html b/app/design/frontend/Magento/luma/Magento_Sales/email/invoice_update.html index a739c9f54b08f..8ec54f1e64d9c 100644 --- a/app/design/frontend/Magento/luma/Magento_Sales/email/invoice_update.html +++ b/app/design/frontend/Magento/luma/Magento_Sales/email/invoice_update.html @@ -11,7 +11,7 @@ "var comment":"Invoice Comment", "var invoice.increment_id":"Invoice Id", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status" +"var order.getFrontendStatusLabel()":"Order Status" } @--> {{template config_path="design/email/header_template"}} @@ -24,7 +24,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} {{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}} </p> diff --git a/app/design/frontend/Magento/luma/Magento_Sales/email/invoice_update_guest.html b/app/design/frontend/Magento/luma/Magento_Sales/email/invoice_update_guest.html index a56ee6da9fa25..6028db7b97730 100644 --- a/app/design/frontend/Magento/luma/Magento_Sales/email/invoice_update_guest.html +++ b/app/design/frontend/Magento/luma/Magento_Sales/email/invoice_update_guest.html @@ -10,7 +10,7 @@ "var comment":"Invoice Comment", "var invoice.increment_id":"Invoice Id", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status" +"var order.getFrontendStatusLabel()":"Order Status" } @--> {{template config_path="design/email/header_template"}} @@ -23,7 +23,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} </p> <p> diff --git a/app/design/frontend/Magento/luma/Magento_Sales/email/order_update.html b/app/design/frontend/Magento/luma/Magento_Sales/email/order_update.html index 3e4bf8df2f107..fa16ac2196bf4 100644 --- a/app/design/frontend/Magento/luma/Magento_Sales/email/order_update.html +++ b/app/design/frontend/Magento/luma/Magento_Sales/email/order_update.html @@ -10,7 +10,7 @@ "var order.getCustomerName()":"Customer Name", "var comment":"Order Comment", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status" +"var order.getFrontendStatusLabel()":"Order Status" } @--> {{template config_path="design/email/header_template"}} @@ -23,7 +23,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} {{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}} </p> diff --git a/app/design/frontend/Magento/luma/Magento_Sales/email/order_update_guest.html b/app/design/frontend/Magento/luma/Magento_Sales/email/order_update_guest.html index 1075608db4341..8ead615fe01ca 100644 --- a/app/design/frontend/Magento/luma/Magento_Sales/email/order_update_guest.html +++ b/app/design/frontend/Magento/luma/Magento_Sales/email/order_update_guest.html @@ -9,7 +9,7 @@ "var billing.getName()":"Guest Customer Name", "var comment":"Order Comment", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status" +"var order.getFrontendStatusLabel()":"Order Status" } @--> {{template config_path="design/email/header_template"}} @@ -22,7 +22,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} </p> <p> diff --git a/app/design/frontend/Magento/luma/Magento_Sales/email/shipment_update.html b/app/design/frontend/Magento/luma/Magento_Sales/email/shipment_update.html index 37bf92b866c74..4f9b7286f3ae4 100644 --- a/app/design/frontend/Magento/luma/Magento_Sales/email/shipment_update.html +++ b/app/design/frontend/Magento/luma/Magento_Sales/email/shipment_update.html @@ -10,7 +10,7 @@ "var order.getCustomerName()":"Customer Name", "var comment":"Order Comment", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status", +"var order.getFrontendStatusLabel()":"Order Status", "var shipment.increment_id":"Shipment Id" } @--> {{template config_path="design/email/header_template"}} @@ -24,7 +24,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} {{trans 'You can check the status of your order by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}} </p> diff --git a/app/design/frontend/Magento/luma/Magento_Sales/email/shipment_update_guest.html b/app/design/frontend/Magento/luma/Magento_Sales/email/shipment_update_guest.html index 954819949860b..3ef26463ea755 100644 --- a/app/design/frontend/Magento/luma/Magento_Sales/email/shipment_update_guest.html +++ b/app/design/frontend/Magento/luma/Magento_Sales/email/shipment_update_guest.html @@ -9,7 +9,7 @@ "var billing.getName()":"Guest Customer Name", "var comment":"Order Comment", "var order.increment_id":"Order Id", -"var order.getStatusLabel()":"Order Status", +"var order.getFrontendStatusLabel()":"Order Status", "var shipment.increment_id":"Shipment Id" } @--> {{template config_path="design/email/header_template"}} @@ -23,7 +23,7 @@ "Your order #%increment_id has been updated with a status of <strong>%order_status</strong>." increment_id=$order.increment_id - order_status=$order.getStatusLabel() + order_status=$order.getFrontendStatusLabel() |raw}} </p> <p> From ea3a8c7a42ad4132f5641de6d47e9b8d7020cdef Mon Sep 17 00:00:00 2001 From: Alexey Yakimovich <yakimovich@almagy.com> Date: Wed, 14 Nov 2018 15:39:15 +0300 Subject: [PATCH 016/121] MAGETWO-94556: Undefined variables during product save - Fixed an issue with missing product data after sku validation; --- .../adminhtml/web/js/variations/variations.js | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js index a46943bd5d145..c6eee5486d117 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js @@ -389,10 +389,23 @@ define([ this.formSaveParams = arguments; this.attributeSetHandlerModal().openModal(); } else { + if (this.validateForm(this.formElement())) { + this.clearOutdatedData(); + } this.formElement().save(arguments[0], arguments[1]); } }, + /** + * @param {Object} formElement + * + * Validates each form element and returns true, if all elements are valid. + */ + validateForm: function (formElement) { + formElement.validate(); + return !formElement.additionalInvalid && !formElement.source.get('params.invalid'); + }, + /** * Serialize data for specific form fields * @@ -410,12 +423,27 @@ define([ if (this.source.data['configurable-matrix']) { this.source.data['configurable-matrix-serialized'] = JSON.stringify(this.source.data['configurable-matrix']); - delete this.source.data['configurable-matrix']; } if (this.source.data['associated_product_ids']) { this.source.data['associated_product_ids_serialized'] = JSON.stringify(this.source.data['associated_product_ids']); + } + }, + + /** + * Clear outdated data for specific form fields + * + * Outdated fields: + * - configurable-matrix; + * - associated_product_ids. + */ + clearOutdatedData: function () { + if (this.source.data['configurable-matrix']) { + delete this.source.data['configurable-matrix']; + } + + if (this.source.data['associated_product_ids']) { delete this.source.data['associated_product_ids']; } }, From 8b4c1fa781ef14b2f1b9d3ae46be5b932cf108a6 Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <Veronika_Kurochkina@epam.com> Date: Thu, 15 Nov 2018 18:02:08 +0300 Subject: [PATCH 017/121] MAGETWO-91559: Static blocks with same ID appear in place of correct block - Update automated test --- app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml index df7cd59a45886..c3c92dc59c288 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/CheckStaticBlocksTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="CheckStaticBlocksTest"> <annotations> <features value="Cms"/> @@ -63,10 +63,10 @@ <see userInput="A block identifier with the same properties already exists in the selected store." stepKey="VerifyBlockIsSaved1"/> <after> - <actionGroup ref="DeleteCMSBlockActionGroup" stepKey="DeleteCMSBlockActionGroup"/> <actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="DeleteWebsite"> <argument name="websiteName" value="secondWebsite"/> </actionGroup> + <actionGroup ref="DeleteCMSBlockActionGroup" stepKey="DeleteCMSBlockActionGroup"/> </after> </test> </tests> From 1b71e53cd67d7e1ab46f98a867e94225d05cd528 Mon Sep 17 00:00:00 2001 From: Yauhen_Lyskavets <yauhen_lyskavets@epam.com> Date: Thu, 15 Nov 2018 15:11:06 +0300 Subject: [PATCH 018/121] MAGETWO-95310: [2.3] Wrong color image when filtering by color filter - Bug fix. --- .../Product/Renderer/Listing/Configurable.php | 29 ++++++++++++++++--- app/code/Magento/Swatches/Helper/Data.php | 14 ++++----- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/app/code/Magento/Swatches/Block/Product/Renderer/Listing/Configurable.php b/app/code/Magento/Swatches/Block/Product/Renderer/Listing/Configurable.php index e13373fb72558..287134d6bb70a 100644 --- a/app/code/Magento/Swatches/Block/Product/Renderer/Listing/Configurable.php +++ b/app/code/Magento/Swatches/Block/Product/Renderer/Listing/Configurable.php @@ -8,7 +8,8 @@ use Magento\Catalog\Block\Product\Context; use Magento\Catalog\Helper\Product as CatalogProduct; use Magento\Catalog\Model\Product; -use Magento\Catalog\Model\Product\Image\UrlBuilder; +use Magento\Catalog\Model\Layer\Resolver; +use Magento\Catalog\Model\Layer\Category as CategoryLayer; use Magento\ConfigurableProduct\Helper\Data; use Magento\ConfigurableProduct\Model\ConfigurableAttributeData; use Magento\Customer\Helper\Session\CurrentCustomer; @@ -39,6 +40,11 @@ class Configurable extends \Magento\Swatches\Block\Product\Renderer\Configurable */ private $variationPrices; + /** + * @var \Magento\Catalog\Model\Layer\Resolver + */ + private $layerResolver; + /** * @SuppressWarnings(PHPMD.ExcessiveParameterList) * @param Context $context @@ -55,6 +61,7 @@ class Configurable extends \Magento\Swatches\Block\Product\Renderer\Configurable * @param SwatchAttributesProvider|null $swatchAttributesProvider * @param \Magento\Framework\Locale\Format|null $localeFormat * @param \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices|null $variationPrices + * @param Resolver $layerResolver */ public function __construct( Context $context, @@ -70,7 +77,8 @@ public function __construct( array $data = [], SwatchAttributesProvider $swatchAttributesProvider = null, \Magento\Framework\Locale\Format $localeFormat = null, - \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices $variationPrices = null + \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices $variationPrices = null, + Resolver $layerResolver = null ) { parent::__construct( $context, @@ -92,10 +100,11 @@ public function __construct( $this->variationPrices = $variationPrices ?: ObjectManager::getInstance()->get( \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices::class ); + $this->layerResolver = $layerResolver ?: ObjectManager::getInstance()->get(Resolver::class); } /** - * @return string + * @inheritdoc */ protected function getRendererTemplate() { @@ -121,7 +130,7 @@ protected function _toHtml() } /** - * @return array + * @inheritdoc */ protected function getSwatchAttributesData() { @@ -247,4 +256,16 @@ private function getLayeredAttributesIfExists(Product $configurableProduct, arra return $layeredAttributes; } + + /** + * @inheritdoc + */ + public function getCacheKeyInfo() + { + $cacheKeyInfo = parent::getCacheKeyInfo(); + /** @var CategoryLayer $catalogLayer */ + $catalogLayer = $this->layerResolver->get(); + $cacheKeyInfo[] = $catalogLayer->getStateKey(); + return $cacheKeyInfo; + } } diff --git a/app/code/Magento/Swatches/Helper/Data.php b/app/code/Magento/Swatches/Helper/Data.php index d82109ac12603..a40d65b6bb90b 100644 --- a/app/code/Magento/Swatches/Helper/Data.php +++ b/app/code/Magento/Swatches/Helper/Data.php @@ -7,7 +7,6 @@ use Magento\Catalog\Api\Data\ProductInterface as Product; use Magento\Catalog\Api\ProductRepositoryInterface; -use Magento\Catalog\Helper\Image; use Magento\Catalog\Model\Product as ModelProduct; use Magento\Catalog\Model\Product\Image\UrlBuilder; use Magento\Catalog\Model\ResourceModel\Eav\Attribute; @@ -254,18 +253,15 @@ public function loadVariationByFallback(Product $parentProduct, array $attribute $this->addFilterByParent($productCollection, $parentId); $configurableAttributes = $this->getAttributesFromConfigurable($parentProduct); - $allAttributesArray = []; + + $resultAttributesToFilter = []; foreach ($configurableAttributes as $attribute) { - if (!empty($attribute['default_value'])) { - $allAttributesArray[$attribute['attribute_code']] = $attribute['default_value']; + $attributeCode = $attribute->getData('attribute_code'); + if (array_key_exists($attributeCode, $attributes)) { + $resultAttributesToFilter[$attributeCode] = $attributes[$attributeCode]; } } - $resultAttributesToFilter = array_merge( - $attributes, - array_diff_key($allAttributesArray, $attributes) - ); - $this->addFilterByAttributes($productCollection, $resultAttributesToFilter); $variationProduct = $productCollection->getFirstItem(); From 6d5a80c09aa94b38b8e2a5a5504d38257438364f Mon Sep 17 00:00:00 2001 From: Stepan Furman <furman.stepan@gmail.com> Date: Sun, 18 Nov 2018 20:13:58 +0200 Subject: [PATCH 019/121] 248: Create customer account --- .../Model/Resolver/CreateCustomer.php | 117 ++++++++++++++++++ .../CustomerGraphQl/etc/schema.graphqls | 7 +- 2 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php diff --git a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php new file mode 100644 index 0000000000000..4dbf6ea4d7946 --- /dev/null +++ b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php @@ -0,0 +1,117 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CustomerGraphQl\Model\Resolver; + +use Magento\Customer\Api\AccountManagementInterface; +use Magento\Customer\Api\Data\CustomerInterfaceFactory; +use Magento\Framework\Api\DataObjectHelper; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\GraphQl\Exception\GraphQlInputException; +use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; +use Magento\CustomerGraphQl\Model\Customer\CustomerDataProvider; +use Magento\Framework\GraphQl\Config\Element\Field; +use Magento\Framework\GraphQl\Query\ResolverInterface; +use Magento\Newsletter\Model\SubscriberFactory; +use Magento\Store\Model\StoreManagerInterface; +use Psr\Log\LoggerInterface; +use Psr\Log\Test\LoggerInterfaceTest; + +/** + * Create customer data resolver + */ +class CreateCustomer implements ResolverInterface +{ + /** + * @var CustomerDataProvider + */ + private $customerDataProvider; + + /** + * @var AccountManagementInterface + */ + private $accountManagement; + + /** + * @var CustomerInterfaceFactory + */ + private $customerFactory; + + /** + * @var DataObjectHelper + */ + private $dataObjectHelper; + /** + * @var StoreManagerInterface + */ + private $storeManager; + /** + * @var Magento\Newsletter\Model\SubscriberFactory + */ + private $subscriberFactory; + + /** + * @param DataObjectHelper $dataObjectHelper + * @param CustomerInterfaceFactory $customerFactory + * @param AccountManagementInterface $accountManagement + * @param StoreManagerInterface $storeManager + * @param SubscriberFactory $subscriberFactory + * @param CustomerDataProvider $customerDataProvider + */ + public function __construct( + DataObjectHelper $dataObjectHelper, + CustomerInterfaceFactory $customerFactory, + AccountManagementInterface $accountManagement, + StoreManagerInterface $storeManager, + SubscriberFactory $subscriberFactory, + CustomerDataProvider $customerDataProvider + ) { + $this->customerDataProvider = $customerDataProvider; + $this->accountManagement = $accountManagement; + $this->customerFactory = $customerFactory; + $this->dataObjectHelper = $dataObjectHelper; + $this->storeManager = $storeManager; + $this->subscriberFactory = $subscriberFactory; + } + + /** + * @inheritdoc + */ + public function resolve( + Field $field, + $context, + ResolveInfo $info, + array $value = null, + array $args = null + ) { + if (!isset($args['input']) || !is_array($args['input']) || empty($args['input'])) { + throw new GraphQlInputException(__('"input" value should be specified')); + } + try { + $customerDataObject = $this->customerFactory->create(); + $this->dataObjectHelper->populateWithArray( + $customerDataObject, + $args['input'], + \Magento\Customer\Api\Data\CustomerInterface::class + ); + $store = $this->storeManager->getStore(); + $customerDataObject->setWebsiteId($store->getWebsiteId()); + $customerDataObject->setStoreId($store->getId()); + $customer = $this->accountManagement->createAccount($customerDataObject, $args['input']['password']); + if (array_key_exists('is_subscribed', $args['input'])) { + if ($args['input']['is_subscribed']) { + $this->subscriberFactory->create()->subscribeCustomerById($customer->getId()); + } + } + $data = $this->customerDataProvider->getCustomerById((int)$customer->getId()); + } catch (LocalizedException $e) { + throw new GraphQlInputException(__($e->getMessage())); + } + return ['customer' => $data]; + } +} diff --git a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls index b8411f00c5cb1..951d767eb1e67 100644 --- a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls +++ b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls @@ -8,7 +8,8 @@ type Query { type Mutation { generateCustomerToken(email: String!, password: String!): CustomerToken @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\GenerateCustomerToken") @doc(description:"Retrieve Customer token") changeCustomerPassword(currentPassword: String!, newPassword: String!): Customer @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\ChangePassword") @doc(description:"Changes password for logged in customer") - updateCustomer (input: UpdateCustomerInput): UpdateCustomerOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\UpdateCustomer") @doc(description:"Update customer personal information") + createCustomer (input: CustomerInput): CustomerOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\CreateCustomer") @doc(description:"Create customer account") + updateCustomer (input: CustomerInput): CustomerOutput @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\UpdateCustomer") @doc(description:"Update customer personal information") revokeCustomerToken: Boolean @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\RevokeCustomerToken") @doc(description:"Revoke Customer token") } @@ -16,7 +17,7 @@ type CustomerToken { token: String @doc(description: "The customer token") } -input UpdateCustomerInput { +input CustomerInput { firstname: String lastname: String email: String @@ -24,7 +25,7 @@ input UpdateCustomerInput { is_subscribed: Boolean } -type UpdateCustomerOutput { +type CustomerOutput { customer: Customer! } From 91edcc574478fc57d798938261c5be4c6732707e Mon Sep 17 00:00:00 2001 From: Stepan Furman <furman.stepan@gmail.com> Date: Mon, 19 Nov 2018 09:55:51 +0200 Subject: [PATCH 020/121] 248:Bugfix - Solved 'user is not authorised' error after creating customer and trying to retrieve data --- .../Model/Resolver/CreateCustomer.php | 53 ++++++++++++------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php index 4dbf6ea4d7946..2bf85eefe7617 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php +++ b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php @@ -7,20 +7,18 @@ namespace Magento\CustomerGraphQl\Model\Resolver; -use Magento\Customer\Api\AccountManagementInterface; -use Magento\Customer\Api\Data\CustomerInterfaceFactory; -use Magento\Framework\Api\DataObjectHelper; -use Magento\Framework\App\ObjectManager; -use Magento\Framework\Exception\LocalizedException; +use Magento\CustomerGraphQl\Model\Customer\CustomerDataProvider; use Magento\Framework\GraphQl\Exception\GraphQlInputException; +use Magento\Customer\Api\Data\CustomerInterfaceFactory; use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; -use Magento\CustomerGraphQl\Model\Customer\CustomerDataProvider; -use Magento\Framework\GraphQl\Config\Element\Field; use Magento\Framework\GraphQl\Query\ResolverInterface; +use Magento\Authorization\Model\UserContextInterface; +use Magento\Customer\Api\AccountManagementInterface; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\GraphQl\Config\Element\Field; use Magento\Newsletter\Model\SubscriberFactory; use Magento\Store\Model\StoreManagerInterface; -use Psr\Log\LoggerInterface; -use Psr\Log\Test\LoggerInterfaceTest; +use Magento\Framework\Api\DataObjectHelper; /** * Create customer data resolver @@ -51,7 +49,7 @@ class CreateCustomer implements ResolverInterface */ private $storeManager; /** - * @var Magento\Newsletter\Model\SubscriberFactory + * @var SubscriberFactory */ private $subscriberFactory; @@ -93,16 +91,8 @@ public function resolve( throw new GraphQlInputException(__('"input" value should be specified')); } try { - $customerDataObject = $this->customerFactory->create(); - $this->dataObjectHelper->populateWithArray( - $customerDataObject, - $args['input'], - \Magento\Customer\Api\Data\CustomerInterface::class - ); - $store = $this->storeManager->getStore(); - $customerDataObject->setWebsiteId($store->getWebsiteId()); - $customerDataObject->setStoreId($store->getId()); - $customer = $this->accountManagement->createAccount($customerDataObject, $args['input']['password']); + $customer = $this->createUserAccount($args); + $this->setUpUserContext($context, $customer); if (array_key_exists('is_subscribed', $args['input'])) { if ($args['input']['is_subscribed']) { $this->subscriberFactory->create()->subscribeCustomerById($customer->getId()); @@ -114,4 +104,27 @@ public function resolve( } return ['customer' => $data]; } + + private function createUserAccount($args) + { + $customerDataObject = $this->customerFactory->create(); + $this->dataObjectHelper->populateWithArray( + $customerDataObject, + $args['input'], + \Magento\Customer\Api\Data\CustomerInterface::class + ); + $store = $this->storeManager->getStore(); + $customerDataObject->setWebsiteId($store->getWebsiteId()); + $customerDataObject->setStoreId($store->getId()); + + $password = array_key_exists('password', $args['input']) ? $args['input']['password'] : null; + + return $this->accountManagement->createAccount($customerDataObject, $password); + } + + private function setUpUserContext($context, $customer) + { + $context->setUserId((int)$customer->getId()); + $context->setUserType(UserContextInterface::USER_TYPE_CUSTOMER); + } } From 5ef59e9373174a1c4dc062b823371f40f4143aff Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Mon, 19 Nov 2018 11:53:04 +0300 Subject: [PATCH 021/121] MAGETWO-57337: Store View (language) switch leads to 404 - Add redirect to the home page in case with switch CMS page from other store --- .../UrlRewrite/Model/StoreSwitcher/RewriteUrl.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/code/Magento/UrlRewrite/Model/StoreSwitcher/RewriteUrl.php b/app/code/Magento/UrlRewrite/Model/StoreSwitcher/RewriteUrl.php index 2ce00d53588b3..34e82f561ee80 100644 --- a/app/code/Magento/UrlRewrite/Model/StoreSwitcher/RewriteUrl.php +++ b/app/code/Magento/UrlRewrite/Model/StoreSwitcher/RewriteUrl.php @@ -40,6 +40,8 @@ public function __construct( } /** + * Switch to another store. + * * @param StoreInterface $fromStore * @param StoreInterface $targetStore * @param string $redirectUrl @@ -75,6 +77,14 @@ public function switch(StoreInterface $fromStore, StoreInterface $targetStore, s /** @var \Magento\Framework\App\Response\Http $response */ $targetUrl = $targetStore->getBaseUrl(); } + } else { + $existingRewrite = $this->urlFinder->findOneByData([ + UrlRewrite::REQUEST_PATH => $urlPath + ]); + if ($existingRewrite) { + /** @var \Magento\Framework\App\Response\Http $response */ + $targetUrl = $targetStore->getBaseUrl(); + } } return $targetUrl; From bb4f44fa53176c8ebce6ef2719dcd710d66c35ca Mon Sep 17 00:00:00 2001 From: Lusine <lusine_papyan@epam.com> Date: Tue, 20 Nov 2018 14:01:33 +0400 Subject: [PATCH 022/121] MAGETWO-96124: [2.3.x] Custom Customer Attributes get cleared in case of invalid Customer Account creation on Storefront - Add automated test script --- .../Mftf/Page/StorefrontCustomerCreatePage.xml | 3 ++- .../StorefrontCustomerCreateFormSection.xml | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerCreatePage.xml b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerCreatePage.xml index e2ebf638934c6..101ff1451ccbf 100644 --- a/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerCreatePage.xml +++ b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerCreatePage.xml @@ -9,6 +9,7 @@ <pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> <page name="StorefrontCustomerCreatePage" url="/customer/account/create/" area="storefront" module="Magento_Customer"> - <section name="StorefrontCustomerCreateFormSection" /> + <section name="StorefrontCustomerCreateFormSection"/> + <section name="StoreFrontCustomerCustomAttributesSection"/> </page> </pages> diff --git a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection.xml index 2b5662cdd623e..a8c7cefb773d1 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection.xml @@ -11,9 +11,23 @@ <section name="StorefrontCustomerCreateFormSection"> <element name="firstnameField" type="input" selector="#firstname"/> <element name="lastnameField" type="input" selector="#lastname"/> + <element name="lastnameLabel" type="text" selector="//label[@for='lastname']"/> <element name="emailField" type="input" selector="#email_address"/> <element name="passwordField" type="input" selector="#password"/> <element name="confirmPasswordField" type="input" selector="#password-confirmation"/> <element name="createAccountButton" type="button" selector="button.action.submit.primary" timeout="30"/> </section> + <section name="StoreFrontCustomerCustomAttributesSection"> + <element name="textFieldAttribute" type="input" selector="//input[@id='{{var}}']" parameterized="true" /> + <element name="textAreaAttribute" type="input" selector="//textarea[@id='{{var}}']" parameterized="true" /> + <element name="multiLineFirstAttribute" type="input" selector="//input[@id='{{var}}_0']" parameterized="true" /> + <element name="multiLineSecondAttribute" type="input" selector="//input[@id='{{var}}_1']" parameterized="true" /> + <element name="datedAttribute" type="input" selector="//input[@id='{{var}}']" parameterized="true" /> + <element name="dropDownAttribute" type="select" selector="//select[@id='{{var}}']" parameterized="true" /> + <element name="dropDownOptionAttribute" type="text" selector="//*[@id='{{var}}']/option[2]" parameterized="true" /> + <element name="multiSelectFirstOptionAttribute" type="text" selector="//select[@id='{{var}}']/option[3]" parameterized="true" /> + <element name="yesNoAttribute" type="select" selector="//select[@id='{{var}}']" parameterized="true" /> + <element name="yesNoOptionAttribute" type="select" selector="//select[@id='{{var}}']/option[2]" parameterized="true" /> + <element name="selectedOption" type="text" selector="//select[@id='{{var}}']/option[@selected='selected']" parameterized="true"/> + </section> </sections> From 4864793070dabf2de761c938a8c85404bf802920 Mon Sep 17 00:00:00 2001 From: David Grigoryan <david_grigoryan@epam.com> Date: Wed, 21 Nov 2018 12:40:42 +0400 Subject: [PATCH 023/121] MAGETWO-95823: Order Sales Report includes canceled orders - Updated automated test --- .../Test/CancelOrdersInOrderSalesReportTest.xml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Reports/Test/Mftf/Test/CancelOrdersInOrderSalesReportTest.xml b/app/code/Magento/Reports/Test/Mftf/Test/CancelOrdersInOrderSalesReportTest.xml index 967b0f3caf515..38ad418865eac 100644 --- a/app/code/Magento/Reports/Test/Mftf/Test/CancelOrdersInOrderSalesReportTest.xml +++ b/app/code/Magento/Reports/Test/Mftf/Test/CancelOrdersInOrderSalesReportTest.xml @@ -10,12 +10,13 @@ <test name="CancelOrdersInOrderSalesReportTest"> <annotations> <features value="Reports"/> - <stories value="MAGETWO-95823: Order Sales Report includes canceled orders"/> + <stories value="Order Sales Report includes canceled orders"/> <group value="reports"/> <title value="Canceled orders in order sales report"/> <description value="Verify canceling of orders in order sales report"/> <severity value="MAJOR"/> <testCaseId value="MAGETWO-95960"/> + <useCaseId value="MAGETWO-95823"/> </annotations> <before> @@ -32,6 +33,13 @@ <createData entity="Simple_US_Customer" stepKey="createCustomer"/> </before> + <after> + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + <!-- Create completed order --> <actionGroup ref="CreateOrderActionGroup" stepKey="createOrderd"> <argument name="product" value="$$createSimpleProduct$$"/> @@ -69,12 +77,5 @@ <!-- Compare canceled orders price --> <assertEquals expected="$0.00" expectedType="string" actual="{$grabCanceledOrdersPrice}" actualType="string" stepKey="assertEquals"/> - - <after> - <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> - <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/> - <actionGroup ref="logout" stepKey="logout"/> - </after> </test> </tests> From fbec41e5b8720c9e76203dc729213574a7754d97 Mon Sep 17 00:00:00 2001 From: Lusine <lusine_papyan@epam.com> Date: Thu, 22 Nov 2018 17:33:10 +0400 Subject: [PATCH 024/121] MAGETWO-57337: Store View (language) switch leads to 404 - Add automated test script --- .../Test/Mftf/ActionGroup/CMSActionGroup.xml | 16 +++++ .../StoreViewLanguageCorrectSwitchTest.xml | 60 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 app/code/Magento/Cms/Test/Mftf/Test/StoreViewLanguageCorrectSwitchTest.xml diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/CMSActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/CMSActionGroup.xml index 75e059f620c2d..e2f22d29d3456 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/CMSActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/CMSActionGroup.xml @@ -44,4 +44,20 @@ <waitForPageLoad stepKey="waitForPageLoad3"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskOfStagingSection" /> </actionGroup> + + <actionGroup name="AddStoreViewToCmsPage" extends="navigateToCreatedCMSPage"> + <arguments> + <argument name="storeViewName" type="string"/> + </arguments> + <remove keyForRemoval="clickExpandContentTabForPage"/> + <remove keyForRemoval="waitForLoadingMaskOfStagingSection"/> + <click selector="{{CmsNewPagePiwSection.header}}" stepKey="clickPageInWebsites" after="waitForPageLoad3"/> + <waitForElementVisible selector="{{CmsNewPagePiwSection.selectStoreView(storeViewName)}}" stepKey="waitForStoreGridReload"/> + <clickWithLeftButton selector="{{CmsNewPagePiwSection.selectStoreView(storeViewName)}}" stepKey="clickStoreView"/> + <click selector="{{CmsNewPagePageActionsSection.expandSplitButton}}" stepKey="expandButtonMenu"/> + <waitForElementVisible selector="{{CmsNewPagePageActionsSection.splitButtonMenu}}" stepKey="waitForSplitButtonMenuVisible"/> + <click selector="{{CmsNewPagePageActionsSection.savePage}}" stepKey="clickSavePage"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + <see userInput="You saved the page." stepKey="seeMessage"/> + </actionGroup> </actionGroups> diff --git a/app/code/Magento/Cms/Test/Mftf/Test/StoreViewLanguageCorrectSwitchTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/StoreViewLanguageCorrectSwitchTest.xml new file mode 100644 index 0000000000000..65fabfe25e817 --- /dev/null +++ b/app/code/Magento/Cms/Test/Mftf/Test/StoreViewLanguageCorrectSwitchTest.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="StoreViewLanguageCorrectSwitchTest"> + <annotations> + <features value="Cms"/> + <stories value="Store View (language) switch leads to 404"/> + <group value="Cms"/> + <title value="Check that Store View(language) switches correct"/> + <description value="Check that Store View(language) switches correct"/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-96388"/> + <useCaseId value="MAGETWO-57337"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + + <!-- Create Cms Pages --> + <createData entity="_newDefaultCmsPage" stepKey="createFirstCmsPage"/> + <createData entity="_newDefaultCmsPage" stepKey="createSecondCmsPage"/> + </before> + <after> + <deleteData createDataKey="createFirstCmsPage" stepKey="deleteFirstCmsPage"/> + <deleteData createDataKey="createSecondCmsPage" stepKey="deleteSecondCmsPage"/> + <actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="deleteStoreView"> + <argument name="customStore" value="NewStoreViewData"/> + </actionGroup> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <!-- Create StoreView --> + <actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreView"> + <argument name="customStore" value="NewStoreViewData"/> + </actionGroup> + + <!-- Add StoreView To Cms Page--> + <actionGroup ref="AddStoreViewToCmsPage" stepKey="gotToCmsPage"> + <argument name="CMSPage" value="$$createSecondCmsPage$$"/> + <argument name="storeViewName" value="{{NewStoreViewData.name}}"/> + </actionGroup> + + <!-- Check that Cms Page is open --> + <amOnPage url="{{StorefrontHomePage.url}}/$$createFirstCmsPage.identifier$$" stepKey="gotToFirstCmsPage"/> + <see userInput="$$createFirstCmsPage.title$$" stepKey="seePageTitle"/> + + <!-- Switch StoreView and check that Cms Page is open --> + <click selector="{{StorefrontHeaderSection.storeViewSwitcher}}" stepKey="clickStoreViewSwitcher"/> + <waitForElementVisible selector="{{StorefrontHeaderSection.storeViewDropdown}}" stepKey="waitForStoreViewDropDown"/> + <click selector="{{StorefrontHeaderSection.storeViewOption(NewStoreViewData.code)}}" stepKey="selectStoreView"/> + <amOnPage url="{{StorefrontHomePage.url}}/$$createSecondCmsPage.identifier$$" stepKey="gotToSecondCmsPage"/> + <see userInput="$$createSecondCmsPage.title$$" stepKey="seePageTitle1"/> + </test> +</tests> From c6c9ff4a4a82025ad316f0712a045f1f804b2aab Mon Sep 17 00:00:00 2001 From: Karen_Mkhitaryan <Karen_Mkhitaryan@epam.com> Date: Thu, 22 Nov 2018 19:03:20 +0400 Subject: [PATCH 025/121] MAGETWO-94556: Undefined variables during product save - Add automated test --- .../AdminProductAttributeOptionsSection.xml | 1 + .../Section/AdminProductGridFilterSection.xml | 2 +- .../AdminProductFormConfigurationsSection.xml | 1 + .../AdminConfigurableProductCreateTest.xml | 65 +++++++++++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeOptionsSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeOptionsSection.xml index 0f438540603d0..5f1112eef3625 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeOptionsSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductAttributeOptionsSection.xml @@ -10,5 +10,6 @@ <section name="DropdownAttributeOptionsSection"> <element name="nthOptionAdminLabel" type="input" selector="(//*[@id='manage-options-panel']//tr[{{var}}]//input[contains(@name, 'option[value]')])[1]" parameterized="true"/> + <element name="deleteButton" type="button" selector="(//td[@class='col-delete'])[1]" timeout="30"/> </section> </sections> \ No newline at end of file diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridFilterSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridFilterSection.xml index 611f12a39b510..2e4b9c6cb0430 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridFilterSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridFilterSection.xml @@ -9,7 +9,7 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminProductGridFilterSection"> - <element name="filters" type="button" selector="button[data-action='grid-filter-expand']"/> + <element name="filters" type="button" selector="//button[text()='Filters']"/> <element name="clearAll" type="button" selector=".admin__data-grid-header .admin__data-grid-filters-current._show .action-clear" timeout="30"/> <element name="enabledFilters" type="textarea" selector=".admin__data-grid-header .admin__data-grid-filters-current._show"/> <element name="basicSearchFilter" type="textarea" selector=".admin__control-text.data-grid-search-control"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminProductFormConfigurationsSection.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminProductFormConfigurationsSection.xml index 0de7bc00044c8..1541b5ae81a28 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminProductFormConfigurationsSection.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminProductFormConfigurationsSection.xml @@ -22,6 +22,7 @@ <element name="removeProductBtn" type="button" selector="//a[text()='Remove Product']"/> <element name="disableProductBtn" type="button" selector="//a[text()='Disable Product']"/> <element name="enableProductBtn" type="button" selector="//a[text()='Enable Product']"/> + <element name="firstSKUInConfigurableProductsGrid" type="input" selector="//input[@name='configurable-matrix[0][sku]']"/> </section> <section name="AdminConfigurableProductFormSection"> <element name="productWeight" type="input" selector=".admin__control-text[name='product[weight]']"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml index 48f46a1205ec3..f400a4d4708a8 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml @@ -68,4 +68,69 @@ <see selector="{{StorefrontProductInfoMainSection.productAttributeOptions1}}" userInput="{{colorProductAttribute2.name}}" stepKey="seeInDropDown2"/> <see selector="{{StorefrontProductInfoMainSection.productAttributeOptions1}}" userInput="{{colorProductAttribute3.name}}" stepKey="seeInDropDown3"/> </test> + + <test name="AdminCreateConfigurableProductAfterGettingIncorrectSKUMessageTest"> + <annotations> + <features value="ConfigurableProduct"/> + <stories value="Create, Read, Update, Delete"/> + <title value="admin should be able to create a configurable product after incorrect sku"/> + <description value="admin should be able to create a configurable product after incorrect sku"/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-96365"/> + <useCaseId value="MAGETWO-94556"/> + <group value="ConfigurableProduct"/> + </annotations> + + <before> + <createData entity="ApiCategory" stepKey="createCategory"/> + <createData entity="ApiConfigurableProduct" stepKey="createConfigProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <deleteData createDataKey="createConfigProduct" stepKey="deleteConfigProduct"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <amOnPage url="{{AdminProductEditPage.url($$createConfigProduct.id$$)}}" stepKey="goToEditPage"/> + <waitForPageLoad stepKey="waitForProductPage"/> + <conditionalClick selector="{{AdminProductFormConfigurationsSection.sectionHeader}}" dependentSelector="{{AdminProductFormConfigurationsSection.createConfigurations}}" visible="false" stepKey="openConfigurationSection"/> + <click selector="{{AdminProductFormConfigurationsSection.createConfigurations}}" stepKey="openConfigurationPane"/> + <click selector="{{AdminCreateProductConfigurationsPanel.filters}}" stepKey="clickFilters"/> + <fillField selector="{{AdminCreateProductConfigurationsPanel.attributeCode}}" userInput="color" stepKey="fillFilterAttributeCodeField"/> + <click selector="{{AdminCreateProductConfigurationsPanel.applyFilters}}" stepKey="clickApplyFiltersButton"/> + <click selector="{{AdminCreateProductConfigurationsPanel.firstCheckbox}}" stepKey="clickOnFirstCheckbox"/> + <click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton1"/> + <click selector="{{AdminCreateProductConfigurationsPanel.createNewValue}}" stepKey="clickOnCreateNewValue1"/> + <fillField userInput="{{colorProductAttribute2.name}}" selector="{{AdminCreateProductConfigurationsPanel.attributeName}}" stepKey="fillFieldForNewAttribute1"/> + <click selector="{{AdminCreateProductConfigurationsPanel.saveAttribute}}" stepKey="clickOnSaveNewAttribute1"/> + <click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton2"/> + <click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnNextButton3"/> + <click selector="{{ConfigurableProductSection.generateConfigure}}" stepKey="generateConfigure"/> + <waitForPageLoad stepKey="waitForGenerateConfigure"/> + <grabValueFrom selector="{{AdminProductFormConfigurationsSection.firstSKUInConfigurableProductsGrid}}" stepKey="grabTextFromContent"/> + <fillField stepKey="fillMoreThan64Symbols" selector="{{AdminProductFormConfigurationsSection.firstSKUInConfigurableProductsGrid}}" userInput="01234567890123456789012345678901234567890123456789012345678901234"/> + <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct1"/> + <see stepKey="seeErrorMessage" userInput="Please enter less or equal than 64 symbols."/> + <fillField stepKey="fillCorrectSKU" selector="{{AdminProductFormConfigurationsSection.firstSKUInConfigurableProductsGrid}}" userInput="$grabTextFromContent"/> + <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct2"/> + <see userInput="You saved the product." stepKey="seeSaveConfirmation"/> + <amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="goToProductAttributes"/> + <waitForPageLoad stepKey="waitForProductAttributes"/> + <click selector="{{AdminProductAttributeGridSection.ResetFilter}}" stepKey="resetFiltersOnGrid1"/> + <fillField selector="{{AdminProductAttributeGridSection.FilterByAttributeCode}}" userInput="color" stepKey="fillFilter"/> + <click selector="{{AdminProductAttributeGridSection.Search}}" stepKey="clickSearch"/> + <click selector="{{AdminProductAttributeGridSection.AttributeCode('color')}}" stepKey="clickRowToEdit"/> + <click selector="{{DropdownAttributeOptionsSection.deleteButton(1)}}" stepKey="deleteOption"/> + <click selector="{{AttributePropertiesSection.Save}}" stepKey="saveAttribute"/> + <click selector="{{AdminProductAttributeGridSection.ResetFilter}}" stepKey="resetFiltersOnGrid2"/> + <actionGroup stepKey="deleteProduct1" ref="deleteProductBySku"> + <argument name="sku" value="$grabTextFromContent"/> + </actionGroup> + <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPage"/> + <waitForPageLoad time="60" stepKey="waitForPageLoadInitial"/> + <conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial"/> + </test> </tests> From de2807d853dd8a1f817904950bbb16b4e691b31b Mon Sep 17 00:00:00 2001 From: Karen_Mkhitaryan <Karen_Mkhitaryan@epam.com> Date: Thu, 22 Nov 2018 19:11:49 +0400 Subject: [PATCH 026/121] MAGETWO-94556: Undefined variables during product save - Add minor change --- .../Test/Mftf/Section/AdminProductFormConfigurationsSection.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminProductFormConfigurationsSection.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminProductFormConfigurationsSection.xml index 1541b5ae81a28..d4ac6bec9cfd5 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminProductFormConfigurationsSection.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminProductFormConfigurationsSection.xml @@ -18,11 +18,11 @@ <element name="currentVariationsQuantityCells" type="textarea" selector=".admin__control-fields[data-index='quantity_container']"/> <element name="currentVariationsAttributesCells" type="textarea" selector=".admin__control-fields[data-index='attributes']"/> <element name="currentVariationsStatusCells" type="textarea" selector="._no-header[data-index='status']"/> + <element name="firstSKUInConfigurableProductsGrid" type="input" selector="//input[@name='configurable-matrix[0][sku]']"/> <element name="actionsBtn" type="button" selector="(//button[@class='action-select']/span[contains(text(), 'Select')])[{{var1}}]" parameterized="true"/> <element name="removeProductBtn" type="button" selector="//a[text()='Remove Product']"/> <element name="disableProductBtn" type="button" selector="//a[text()='Disable Product']"/> <element name="enableProductBtn" type="button" selector="//a[text()='Enable Product']"/> - <element name="firstSKUInConfigurableProductsGrid" type="input" selector="//input[@name='configurable-matrix[0][sku]']"/> </section> <section name="AdminConfigurableProductFormSection"> <element name="productWeight" type="input" selector=".admin__control-text[name='product[weight]']"/> From 6c2e4c774d8ec0dbca14c0c02c985b93728d1f5f Mon Sep 17 00:00:00 2001 From: Karen_Mkhitaryan <Karen_Mkhitaryan@epam.com> Date: Mon, 26 Nov 2018 11:23:43 +0400 Subject: [PATCH 027/121] MAGETWO-95820: Order placed by new customer before they registered is displayed in the admin under the name Guest - Add fix after review --- .../Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml index 2e2dee82a6eaf..38a23e43d426a 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml @@ -15,7 +15,8 @@ <title value="Check Customer Information Created By Guest"/> <description value="Check customer information after placing the order as the guest who created an account"/> <severity value="MAJOR"/> - <testCaseId value="MAGETWO-95820"/> + <testCaseId value="MAGETWO-95932"/> + <useCaseId value="MAGETWO-95820"/> <group value="checkout"/> </annotations> @@ -29,6 +30,7 @@ </before> <after> + <createData entity="DisableAllowGuestCheckout" stepKey="enableGuestCheckout"/> <deleteData createDataKey="product" stepKey="deleteProduct" /> <deleteData createDataKey="category" stepKey="deleteCategory" /> <actionGroup ref="logout" stepKey="logoutFromAdmin"/> From 1ea5632e9a44e1b341273e1322c4a4bf161026d5 Mon Sep 17 00:00:00 2001 From: Karen_Mkhitaryan <Karen_Mkhitaryan@epam.com> Date: Mon, 26 Nov 2018 12:28:59 +0400 Subject: [PATCH 028/121] MAGETWO-95820: Order placed by new customer before they registered is displayed in the admin under the name Guest - Add minor change after internal review --- .../Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml index 38a23e43d426a..a781315f7cb0a 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml @@ -30,7 +30,7 @@ </before> <after> - <createData entity="DisableAllowGuestCheckout" stepKey="enableGuestCheckout"/> + <createData entity="DisableAllowGuestCheckout" stepKey="disableGuestCheckout"/> <deleteData createDataKey="product" stepKey="deleteProduct" /> <deleteData createDataKey="category" stepKey="deleteCategory" /> <actionGroup ref="logout" stepKey="logoutFromAdmin"/> @@ -50,7 +50,9 @@ <argument name="orderNumberMessage" value="CONST.successGuestCheckoutOrderNumberMessage"/> <argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" /> </actionGroup> + <wait stepKey="asd" time="15"/> <grabTextFrom selector="{{CheckoutSuccessRegisterSection.orderNumber}}" stepKey="grabOrderNumber"/> + <wait stepKey="asdasd" time="15"/> <click selector="{{CustomerAccountSection.createAccount}}" stepKey="clickToCreateAccount"/> <fillField selector="{{StorefrontCustomerCreateFormSection.passwordField}}" userInput="{{CustomerData.password}}" stepKey="TypePassword"/> <fillField selector="{{StorefrontCustomerCreateFormSection.confirmPasswordField}}" userInput="{{CustomerData.password}}" stepKey="TypeConfirmationPassword"/> From 46fd447c15e196735ee88af0441fd96678afdfa8 Mon Sep 17 00:00:00 2001 From: Karen_Mkhitaryan <Karen_Mkhitaryan@epam.com> Date: Mon, 26 Nov 2018 12:30:19 +0400 Subject: [PATCH 029/121] MAGETWO-95820: Order placed by new customer before they registered is displayed in the admin under the name Guest - Add minor change after internal review --- .../Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml index a781315f7cb0a..740d75cb0ffe3 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml @@ -50,9 +50,7 @@ <argument name="orderNumberMessage" value="CONST.successGuestCheckoutOrderNumberMessage"/> <argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" /> </actionGroup> - <wait stepKey="asd" time="15"/> <grabTextFrom selector="{{CheckoutSuccessRegisterSection.orderNumber}}" stepKey="grabOrderNumber"/> - <wait stepKey="asdasd" time="15"/> <click selector="{{CustomerAccountSection.createAccount}}" stepKey="clickToCreateAccount"/> <fillField selector="{{StorefrontCustomerCreateFormSection.passwordField}}" userInput="{{CustomerData.password}}" stepKey="TypePassword"/> <fillField selector="{{StorefrontCustomerCreateFormSection.confirmPasswordField}}" userInput="{{CustomerData.password}}" stepKey="TypeConfirmationPassword"/> From 27d3e660c4cbb9bc62399e027469f2279e8115b6 Mon Sep 17 00:00:00 2001 From: Yauhen_Lyskavets <yauhen_lyskavets@epam.com> Date: Tue, 27 Nov 2018 18:49:18 +0300 Subject: [PATCH 030/121] MAGETWO-96406: [2.3.x] Swatch Attribute is not displayed in the Widget CMS - Bug fix. --- .../Block/Product/ProductsList.php | 64 +++++++++++++- .../layout/catalog_widget_product_list.xml | 17 ++++ .../product/widget/content/grid.phtml | 87 ++++++++++--------- .../layout/catalog_widget_product_list.xml | 12 +++ 4 files changed, 136 insertions(+), 44 deletions(-) create mode 100644 app/code/Magento/CatalogWidget/view/frontend/layout/catalog_widget_product_list.xml create mode 100644 app/code/Magento/Swatches/view/frontend/layout/catalog_widget_product_list.xml diff --git a/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php b/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php index 55f4d67273379..a2067bae7807d 100644 --- a/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php +++ b/app/code/Magento/CatalogWidget/Block/Product/ProductsList.php @@ -6,10 +6,14 @@ namespace Magento\CatalogWidget\Block\Product; +use Magento\Catalog\Model\Product; use Magento\Framework\App\ObjectManager; +use Magento\Framework\App\ActionInterface; use Magento\Framework\DataObject\IdentityInterface; use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Framework\Serialize\Serializer\Json; +use Magento\Framework\Url\Helper\Data as UrlHelper; +use Magento\Framework\View\LayoutFactory; use Magento\Widget\Block\BlockInterface; /** @@ -94,6 +98,21 @@ class ProductsList extends \Magento\Catalog\Block\Product\AbstractProduct implem */ private $json; + /** + * @var LayoutFactory + */ + private $layoutFactory; + + /** + * @var UrlHelper + */ + private $urlHelper; + + /** + * @var \Magento\Framework\View\Element\RendererList + */ + private $rendererListBlock; + /** * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory @@ -104,6 +123,10 @@ class ProductsList extends \Magento\Catalog\Block\Product\AbstractProduct implem * @param \Magento\Widget\Helper\Conditions $conditionsHelper * @param array $data * @param Json|null $json + * @param LayoutFactory|null $layoutFactory + * @param UrlHelper|null $urlHelper + * + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( \Magento\Catalog\Block\Product\Context $context, @@ -114,7 +137,9 @@ public function __construct( \Magento\CatalogWidget\Model\Rule $rule, \Magento\Widget\Helper\Conditions $conditionsHelper, array $data = [], - Json $json = null + Json $json = null, + LayoutFactory $layoutFactory = null, + UrlHelper $urlHelper = null ) { $this->productCollectionFactory = $productCollectionFactory; $this->catalogProductVisibility = $catalogProductVisibility; @@ -123,6 +148,8 @@ public function __construct( $this->rule = $rule; $this->conditionsHelper = $conditionsHelper; $this->json = $json ?: ObjectManager::getInstance()->get(Json::class); + $this->layoutFactory = $layoutFactory ?: ObjectManager::getInstance()->get(LayoutFactory::class); + $this->urlHelper = $urlHelper ?: ObjectManager::getInstance()->get(UrlHelper::class); parent::__construct( $context, $data @@ -217,6 +244,41 @@ public function getProductPriceHtml( return $price; } + /** + * @inheritdoc + */ + protected function getDetailsRendererList() + { + if (empty($this->rendererListBlock)) { + /** @var $layout \Magento\Framework\View\LayoutInterface */ + $layout = $this->layoutFactory->create(['cacheable' => false]); + $layout->getUpdate()->addHandle('catalog_widget_product_list')->load(); + $layout->generateXml(); + $layout->generateElements(); + + $this->rendererListBlock = $layout->getBlock('category.product.type.widget.details.renderers'); + } + return $this->rendererListBlock; + } + + /** + * Get post parameters. + * + * @param Product $product + * @return array + */ + public function getAddToCartPostParams(Product $product) + { + $url = $this->getAddToCartUrl($product); + return [ + 'action' => $url, + 'data' => [ + 'product' => $product->getEntityId(), + ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlHelper->getEncodedUrl($url), + ] + ]; + } + /** * @inheritdoc */ diff --git a/app/code/Magento/CatalogWidget/view/frontend/layout/catalog_widget_product_list.xml b/app/code/Magento/CatalogWidget/view/frontend/layout/catalog_widget_product_list.xml new file mode 100644 index 0000000000000..9a6d704ecce9b --- /dev/null +++ b/app/code/Magento/CatalogWidget/view/frontend/layout/catalog_widget_product_list.xml @@ -0,0 +1,17 @@ +<!-- + ~ Copyright © Magento, Inc. All rights reserved. + ~ See COPYING.txt for license details. + --> + +<!-- + ~ Copyright © Magento, Inc. All rights reserved. + ~ See COPYING.txt for license details. + --> + +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> + <body> + <block class="Magento\Framework\View\Element\RendererList" name="category.product.type.widget.details.renderers" alias="details.renderers"> + <block class="Magento\Framework\View\Element\Template" name="category.product.type.details.renderers.default" as="default"/> + </block> + </body> +</page> \ No newline at end of file diff --git a/app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml b/app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml index f2273f7d44ff3..159d4010c0115 100644 --- a/app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml +++ b/app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml @@ -3,6 +3,7 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +use Magento\Framework\App\Action\Action; // @codingStandardsIgnoreFile @@ -48,57 +49,57 @@ <?= $block->escapeHtml($_item->getName()) ?> </a> </strong> - <?php - echo $block->getProductPriceHtml($_item, $type); - ?> - <?php if ($templateType): ?> <?= $block->getReviewsSummaryHtml($_item, $templateType) ?> <?php endif; ?> + <?= $block->getProductPriceHtml($_item, $type) ?> + + <?= $block->getProductDetailsHtml($_item) ?> + <?php if ($showWishlist || $showCompare || $showCart): ?> - <div class="product-item-actions"> - <?php if ($showCart): ?> - <div class="actions-primary"> - <?php if ($_item->isSaleable()): ?> - <?php if ($_item->getTypeInstance()->hasRequiredOptions($_item)): ?> - <button class="action tocart primary" data-mage-init='{"redirectUrl":{"url":"<?= $block->escapeUrl($block->getAddToCartUrl($_item)) ?>"}}' type="button" title="<?= $block->escapeHtmlAttr(__('Add to Cart')) ?>"> - <span><?= $block->escapeHtml(__('Add to Cart')) ?></span> - </button> + <div class="product-item-inner"> + <div class="product-item-actions"> + <?php if ($showCart): ?> + <div class="actions-primary"> + <?php if ($_item->isSaleable()): ?> + <?php $postParams = $block->getAddToCartPostParams($_item); ?> + <form data-role="tocart-form" data-product-sku="<?= $block->escapeHtml($_item->getSku()) ?>" action="<?= /* @NoEscape */ $postParams['action'] ?>" method="post"> + <input type="hidden" name="product" value="<?= /* @escapeNotVerified */ $postParams['data']['product'] ?>"> + <input type="hidden" name="<?= /* @escapeNotVerified */ Action::PARAM_NAME_URL_ENCODED ?>" value="<?= /* @escapeNotVerified */ $postParams['data'][Action::PARAM_NAME_URL_ENCODED] ?>"> + <?= $block->getBlockHtml('formkey') ?> + <button type="submit" + title="<?= $block->escapeHtml(__('Add to Cart')) ?>" + class="action tocart primary"> + <span><?= /* @escapeNotVerified */ __('Add to Cart') ?></span> + </button> + </form> <?php else: ?> - <?php - $postDataHelper = $this->helper('Magento\Framework\Data\Helper\PostHelper'); - $postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()]) - ?> - <button class="action tocart primary" data-post='<?= /* @noEscape */ $postData ?>' type="button" title="<?= $block->escapeHtmlAttr(__('Add to Cart')) ?>"> - <span><?= $block->escapeHtml(__('Add to Cart')) ?></span> - </button> + <?php if ($_item->getIsSalable()): ?> + <div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div> + <?php else: ?> + <div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div> + <?php endif; ?> <?php endif; ?> - <?php else: ?> - <?php if ($_item->getIsSalable()): ?> - <div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div> - <?php else: ?> - <div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div> + </div> + <?php endif; ?> + <?php if ($showWishlist || $showCompare): ?> + <div class="actions-secondary" data-role="add-to-links"> + <?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow() && $showWishlist): ?> + <a href="#" + data-post='<?= /* @noEscape */ $block->getAddToWishlistParams($_item) ?>' class="action towishlist" data-action="add-to-wishlist" title="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>"> + <span><?= $block->escapeHtml(__('Add to Wish List')) ?></span> + </a> + <?php endif; ?> + <?php if ($block->getAddToCompareUrl() && $showCompare): ?> + <?php $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare');?> + <a href="#" class="action tocompare" data-post='<?= /* @noEscape */ $compareHelper->getPostDataParams($_item) ?>' title="<?= $block->escapeHtmlAttr(__('Add to Compare')) ?>"> + <span><?= $block->escapeHtml(__('Add to Compare')) ?></span> + </a> <?php endif; ?> - <?php endif; ?> - </div> - <?php endif; ?> - <?php if ($showWishlist || $showCompare): ?> - <div class="actions-secondary" data-role="add-to-links"> - <?php if ($this->helper('Magento\Wishlist\Helper\Data')->isAllow() && $showWishlist): ?> - <a href="#" - data-post='<?= /* @noEscape */ $block->getAddToWishlistParams($_item) ?>' class="action towishlist" data-action="add-to-wishlist" title="<?= $block->escapeHtmlAttr(__('Add to Wish List')) ?>"> - <span><?= $block->escapeHtml(__('Add to Wish List')) ?></span> - </a> - <?php endif; ?> - <?php if ($block->getAddToCompareUrl() && $showCompare): ?> - <?php $compareHelper = $this->helper('Magento\Catalog\Helper\Product\Compare');?> - <a href="#" class="action tocompare" data-post='<?= /* @noEscape */ $compareHelper->getPostDataParams($_item) ?>' title="<?= $block->escapeHtmlAttr(__('Add to Compare')) ?>"> - <span><?= $block->escapeHtml(__('Add to Compare')) ?></span> - </a> - <?php endif; ?> - </div> - <?php endif; ?> + </div> + <?php endif; ?> + </div> </div> <?php endif; ?> </div> diff --git a/app/code/Magento/Swatches/view/frontend/layout/catalog_widget_product_list.xml b/app/code/Magento/Swatches/view/frontend/layout/catalog_widget_product_list.xml new file mode 100644 index 0000000000000..91798cbd9947f --- /dev/null +++ b/app/code/Magento/Swatches/view/frontend/layout/catalog_widget_product_list.xml @@ -0,0 +1,12 @@ +<!-- + ~ Copyright © Magento, Inc. All rights reserved. + ~ See COPYING.txt for license details. + --> + +<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> + <body> + <referenceBlock name="category.product.type.widget.details.renderers"> + <block class="Magento\Swatches\Block\Product\Renderer\Listing\Configurable" name="category.product.type.details.renderers.configurable" as="configurable" template="Magento_Swatches::product/listing/renderer.phtml" ifconfig="catalog/frontend/show_swatches_in_product_list"/> + </referenceBlock> + </body> +</page> \ No newline at end of file From dabc8865967719c5e387c5c7576a978f5198ee22 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza <enarc@atwix.com> Date: Wed, 28 Nov 2018 16:51:00 +0100 Subject: [PATCH 031/121] Added possibility to retrieve cart information --- .../Model/Cart/ExtractDataFromCart.php | 3 + .../QuoteGraphQl/Model/Resolver/Cart.php | 67 +++++++++++++++++++ .../Magento/QuoteGraphQl/etc/schema.graphqls | 6 +- 3 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 app/code/Magento/QuoteGraphQl/Model/Resolver/Cart.php diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractDataFromCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractDataFromCart.php index faefa686606e2..438f28980918d 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractDataFromCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractDataFromCart.php @@ -40,8 +40,11 @@ public function execute(Quote $cart): array ]; } + $appliedCoupon = $cart->getCouponCode(); + return [ 'items' => $items, + 'applied_coupon' => $appliedCoupon ? ['code' => $appliedCoupon] : null ]; } } diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart.php new file mode 100644 index 0000000000000..5023c186f1e6c --- /dev/null +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart.php @@ -0,0 +1,67 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\QuoteGraphQl\Model\Resolver; + +use Magento\Framework\GraphQl\Config\Element\Field; +use Magento\Framework\GraphQl\Exception\GraphQlInputException; +use Magento\Framework\GraphQl\Query\ResolverInterface; +use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; +use Magento\QuoteGraphQl\Model\Cart\GetCartForUser; +use Magento\QuoteGraphQl\Model\Cart\ExtractDataFromCart; + +/** + * @inheritdoc + */ +class Cart implements ResolverInterface +{ + /** + * @var ExtractDataFromCart + */ + private $extractDataFromCart; + + /** + * @var GetCartForUser + */ + private $getCartForUser; + + /** + * @param GetCartForUser $getCartForUser + * @param ExtractDataFromCart $extractDataFromCart + */ + public function __construct( + GetCartForUser $getCartForUser, + ExtractDataFromCart $extractDataFromCart + ) { + $this->getCartForUser = $getCartForUser; + $this->extractDataFromCart = $extractDataFromCart; + } + + /** + * @inheritdoc + */ + public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) + { + if (!isset($args['cart_id'])) { + throw new GraphQlInputException(__('Required parameter "cart_id" is missing')); + } + $maskedCartId = $args['cart_id']; + + $currentUserId = $context->getUserId(); + $cart = $this->getCartForUser->execute($maskedCartId, $currentUserId); + + $data = array_merge( + [ + 'cart_id' => $maskedCartId, + 'model' => $cart + ], + $this->extractDataFromCart->execute($cart) + ); + + return $data; + } +} diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls index edc643973ce77..4c1101a5f90a8 100644 --- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls +++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls @@ -2,7 +2,7 @@ # See COPYING.txt for license details. type Query { - getAvailableShippingMethodsOnCart(input: AvailableShippingMethodsOnCartInput): AvailableShippingMethodsOnCartOutput @doc(description:"Returns available shipping methods for cart by address/address_id") + Cart(cart_id: String!): Cart @resolver (class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\Cart") @doc(description:"Returns information about shopping cart") } type Mutation { @@ -84,10 +84,6 @@ input AvailableShippingMethodsOnCartInput { address: CartAddressInput } -type AvailableShippingMethodsOnCartOutput { - available_shipping_methods: [CheckoutShippingMethod] -} - input ApplyCouponToCartInput { cart_id: String! coupon_code: String! From af0b38bdcbb393d94db3422e34c072572165a3b9 Mon Sep 17 00:00:00 2001 From: Stepan Furman <furman.stepan@gmail.com> Date: Wed, 28 Nov 2018 22:17:05 +0200 Subject: [PATCH 032/121] refactoring + first test --- .../Model/Resolver/CreateCustomer.php | 27 +++++-- .../GraphQl/Customer/CreateCustomerTest.php | 73 +++++++++++++++++++ 2 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerTest.php diff --git a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php index 2bf85eefe7617..a265dc300b923 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php +++ b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php @@ -7,18 +7,20 @@ namespace Magento\CustomerGraphQl\Model\Resolver; -use Magento\CustomerGraphQl\Model\Customer\CustomerDataProvider; -use Magento\Framework\GraphQl\Exception\GraphQlInputException; -use Magento\Customer\Api\Data\CustomerInterfaceFactory; -use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; -use Magento\Framework\GraphQl\Query\ResolverInterface; use Magento\Authorization\Model\UserContextInterface; use Magento\Customer\Api\AccountManagementInterface; +use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Customer\Api\Data\CustomerInterfaceFactory; +use Magento\CustomerGraphQl\Model\Customer\CustomerDataProvider; +use Magento\Framework\Api\DataObjectHelper; use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\GraphQl\Config\Element\Field; +use Magento\Framework\GraphQl\Exception\GraphQlInputException; +use Magento\Framework\GraphQl\Query\ResolverInterface; +use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; use Magento\Newsletter\Model\SubscriberFactory; use Magento\Store\Model\StoreManagerInterface; -use Magento\Framework\Api\DataObjectHelper; /** * Create customer data resolver @@ -102,16 +104,23 @@ public function resolve( } catch (LocalizedException $e) { throw new GraphQlInputException(__($e->getMessage())); } + return ['customer' => $data]; } + /** + * @param $args + * @return CustomerInterface + * @throws LocalizedException + * @throws NoSuchEntityException + */ private function createUserAccount($args) { $customerDataObject = $this->customerFactory->create(); $this->dataObjectHelper->populateWithArray( $customerDataObject, $args['input'], - \Magento\Customer\Api\Data\CustomerInterface::class + CustomerInterface::class ); $store = $this->storeManager->getStore(); $customerDataObject->setWebsiteId($store->getWebsiteId()); @@ -122,6 +131,10 @@ private function createUserAccount($args) return $this->accountManagement->createAccount($customerDataObject, $password); } + /** + * @param $context + * @param CustomerInterface $customer + */ private function setUpUserContext($context, $customer) { $context->setUserId((int)$customer->getId()); diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerTest.php new file mode 100644 index 0000000000000..80a24eacb5f2c --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerTest.php @@ -0,0 +1,73 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\GraphQl\Customer; + +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Customer\Model\CustomerRegistry; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\TestCase\GraphQlAbstract; + +class CreateCustomerTest extends GraphQlAbstract +{ + /** + * @var CustomerRegistry + */ + private $customerRegistry; + + /** + * @var CustomerRepositoryInterface + */ + private $customerRepository; + + protected function setUp() + { + parent::setUp(); + + $this->customerRegistry = Bootstrap::getObjectManager()->get(CustomerRegistry::class); + $this->customerRepository = Bootstrap::getObjectManager()->get(CustomerRepositoryInterface::class); + } + + /** + * @throws \Exception + */ + public function testCreateCustomerAccount() + { + $newFirstname = 'Richard'; + $newLastname = 'Rowe'; + $currentPassword = 'test123#'; + $newEmail = 'customer_created' . rand(1, 2000000) . '@example.com'; + + $query = <<<QUERY +mutation { + createCustomer( + input: { + firstname: "{$newFirstname}" + lastname: "{$newLastname}" + email: "{$newEmail}" + password: "{$currentPassword}" + is_subscribed: true + } + ) { + customer { + id + firstname + lastname + email + is_subscribed + } + } +} +QUERY; + $response = $this->graphQlQuery($query); + + $this->assertEquals($newFirstname, $response['createCustomer']['customer']['firstname']); + $this->assertEquals($newLastname, $response['createCustomer']['customer']['lastname']); + $this->assertEquals($newEmail, $response['createCustomer']['customer']['email']); + $this->assertEquals(true, $response['createCustomer']['customer']['is_subscribed']); + } +} From acf541e7ba9967be7932bdac5c329fb3841829e1 Mon Sep 17 00:00:00 2001 From: David Grigoryan <david_grigoryan@epam.com> Date: Thu, 29 Nov 2018 11:54:39 +0400 Subject: [PATCH 033/121] MAGETWO-96106: CMS Block status is not staged - Updated automated test --- .../Magento/Cms/Test/Mftf/Data/BlockData.xml | 18 ++++++++ .../Test/Mftf/Page/AdminCmsEditBlockPage.xml | 14 ++++++ .../Mftf/Section/AdminBlockGridSection.xml | 18 ++++++++ .../ActionGroup/AdminWidgetActionGroup.xml | 44 +++++++++++++++++++ .../Widget/Test/Mftf/Data/WidgetData.xml | 19 ++++++++ .../Test/Mftf/Page/AdminNewWidgetPage.xml | 4 +- .../Mftf/Section/AdminNewWidgetSection.xml | 8 +++- 7 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 app/code/Magento/Cms/Test/Mftf/Data/BlockData.xml create mode 100644 app/code/Magento/Cms/Test/Mftf/Page/AdminCmsEditBlockPage.xml create mode 100644 app/code/Magento/Cms/Test/Mftf/Section/AdminBlockGridSection.xml create mode 100644 app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminWidgetActionGroup.xml create mode 100644 app/code/Magento/Widget/Test/Mftf/Data/WidgetData.xml diff --git a/app/code/Magento/Cms/Test/Mftf/Data/BlockData.xml b/app/code/Magento/Cms/Test/Mftf/Data/BlockData.xml new file mode 100644 index 0000000000000..dea047ec43568 --- /dev/null +++ b/app/code/Magento/Cms/Test/Mftf/Data/BlockData.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="Sales25offBlock" type="block"> + <data key="title" unique="suffix">Sales25off</data> + <data key="identifier" unique="suffix">Sales25off</data> + <data key="store_id">All Store Views</data> + <data key="content">sales25off everything!</data> + <data key="is_active">0</data> + </entity> +</entities> diff --git a/app/code/Magento/Cms/Test/Mftf/Page/AdminCmsEditBlockPage.xml b/app/code/Magento/Cms/Test/Mftf/Page/AdminCmsEditBlockPage.xml new file mode 100644 index 0000000000000..3fd100ee02aa2 --- /dev/null +++ b/app/code/Magento/Cms/Test/Mftf/Page/AdminCmsEditBlockPage.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> + <page name="AdminEditBlockPage" url="cms/block/edit/block_id" area="admin" module="Magento_Cms"> + <section name="AdminUpdateBlockSection"/> + </page> +</pages> diff --git a/app/code/Magento/Cms/Test/Mftf/Section/AdminBlockGridSection.xml b/app/code/Magento/Cms/Test/Mftf/Section/AdminBlockGridSection.xml new file mode 100644 index 0000000000000..ab15570a01f40 --- /dev/null +++ b/app/code/Magento/Cms/Test/Mftf/Section/AdminBlockGridSection.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="AdminBlockGridSection"> + <element name="search" type="input" selector="//input[@placeholder='Search by keyword']"/> + <element name="searchButton" type="button" selector="//div[@class='data-grid-search-control-wrap']//label[@class='data-grid-search-label']/following-sibling::button[@class='action-submit']"/> + <element name="checkbox" type="checkbox" selector="//label[@class='data-grid-checkbox-cell-inner']//input[@class='admin__control-checkbox']"/> + <element name="select" type="select" selector="//tr[@class='data-row']//button[@class='action-select']"/> + <element name="editInSelect" type="text" selector="//a[contains(text(), 'Edit')]"/> + </section> +</sections> diff --git a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminWidgetActionGroup.xml b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminWidgetActionGroup.xml new file mode 100644 index 0000000000000..05c56f588c5d0 --- /dev/null +++ b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminWidgetActionGroup.xml @@ -0,0 +1,44 @@ +<?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="AdminCreateWidgetActionGroup"> + <arguments> + <argument name="widget"/> + <argument name="block" type="string"/> + </arguments> + <amOnPage url="{{AdminNewWidgetPage.url}}" stepKey="createWidgetPage"/> + <selectOption selector="{{AdminNewWidgetSection.widgetType}}" userInput="{{widget.type}}" stepKey="selectWidgetType"/> + <selectOption selector="{{AdminNewWidgetSection.widgetDesignTheme}}" userInput="{{widget.designTheme}}" stepKey="selectWidgetDesignTheme"/> + <click selector="{{AdminNewWidgetSection.continue}}" stepKey="continue"/> + <waitForElement selector="{{AdminNewWidgetSection.widgetTitle}}" time="30" stepKey="waitForElement"/> + <fillField selector="{{AdminNewWidgetSection.widgetTitle}}" userInput="{{widget.name}}" stepKey="fillWidgetTitle"/> + <selectOption selector="{{AdminNewWidgetSection.widgetStoreIds}}" userInput="{{widget.store_id}}" stepKey="selectWidgetStoreView"/> + <click selector="{{AdminNewWidgetSection.addLayoutUpdate}}" stepKey="clickAddLayoutUpdate"/> + <waitForPageLoad stepKey="waitForLoad1"/> + <scrollTo selector="{{AdminNewWidgetSection.selectDisplayOn}}" stepKey="scrollToElement" /> + <selectOption selector="{{AdminNewWidgetSection.selectDisplayOn}}" userInput="{{widget.display}}" stepKey="selectWidgetDisplayOn"/> + <waitForElement selector="{{AdminNewWidgetSection.selectContainer}}" time="30" stepKey="waitForContainer"/> + <selectOption selector="{{AdminNewWidgetSection.selectContainer}}" userInput="{{widget.container}}" stepKey="selectWidgetContainer"/> + <scrollToTopOfPage stepKey="scrollToAddresses"/> + <waitForAjaxLoad stepKey="waitForAjaxLoad1"/> + <click selector="{{AdminNewWidgetSection.widgetOptions}}" stepKey="goToWidgetOptions"/> + <waitForElement selector="{{AdminNewWidgetSection.widgetSelectBlock}}" time="60" stepKey="waitForSelectBlock"/> + <click selector="{{AdminNewWidgetSection.widgetSelectBlock}}" stepKey="openSelectBlock"/> + <waitForPageLoad stepKey="waitForLoadBlocks"/> + <selectOption selector="{{AdminNewWidgetSection.blockStatus}}" userInput="Disable" stepKey="chooseStatus"/> + <fillField selector="{{AdminNewWidgetSection.selectBlockTitle}}" userInput="{{block}}" stepKey="fillBlockTitle"/> + <click selector="{{AdminNewWidgetSection.searchBlock}}" stepKey="searchBlock"/> + <waitForAjaxLoad stepKey="waitForAjaxLoad"/> + <click selector="{{AdminNewWidgetSection.searchedBlock}}" stepKey="clickSearchedBlock"/> + <waitForPageLoad stepKey="wait"/> + <click selector="{{AdminNewWidgetSection.saveWidget}}" stepKey="saveWidget"/> + <waitForPageLoad stepKey="waitForSaving"/> + <see userInput="The widget instance has been saved." stepKey="seeSuccessMessage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Widget/Test/Mftf/Data/WidgetData.xml b/app/code/Magento/Widget/Test/Mftf/Data/WidgetData.xml new file mode 100644 index 0000000000000..4c6e98aafd765 --- /dev/null +++ b/app/code/Magento/Widget/Test/Mftf/Data/WidgetData.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="WidgetWithBlock" type="widget"> + <data key="type">CMS Static Block</data> + <data key="designTheme">Magento Luma</data> + <data key="name" unique="suffix">testName</data> + <data key="store_id">All Store Views</data> + <data key="display">All Pages</data> + <data key="container">Page Top</data> + </entity> +</entities> diff --git a/app/code/Magento/Widget/Test/Mftf/Page/AdminNewWidgetPage.xml b/app/code/Magento/Widget/Test/Mftf/Page/AdminNewWidgetPage.xml index 8eb0a5f65318e..d495a36f68d0a 100644 --- a/app/code/Magento/Widget/Test/Mftf/Page/AdminNewWidgetPage.xml +++ b/app/code/Magento/Widget/Test/Mftf/Page/AdminNewWidgetPage.xml @@ -7,8 +7,8 @@ --> <pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd"> - <page name="AdminNewWidgetPage" url="admin/admin/widget_instance/new/" area="admin" module="Magento_Widget"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> + <page name="AdminNewWidgetPage" url="admin/widget_instance/new/" area="admin" module="Magento_Widget"> <section name="AdminNewWidgetSection"/> </page> </pages> diff --git a/app/code/Magento/Widget/Test/Mftf/Section/AdminNewWidgetSection.xml b/app/code/Magento/Widget/Test/Mftf/Section/AdminNewWidgetSection.xml index 38b4df335ea83..bc90c45ae5d5f 100644 --- a/app/code/Magento/Widget/Test/Mftf/Section/AdminNewWidgetSection.xml +++ b/app/code/Magento/Widget/Test/Mftf/Section/AdminNewWidgetSection.xml @@ -7,7 +7,7 @@ --> <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminNewWidgetSection"> <element name="widgetType" type="select" selector="#code"/> <element name="widgetDesignTheme" type="select" selector="#theme_id"/> @@ -25,5 +25,11 @@ <element name="applyParameter" type="button" selector=".rule-param-apply"/> <element name="openChooser" type="button" selector=".rule-chooser-trigger"/> <element name="selectAll" type="checkbox" selector=".admin__control-checkbox"/> + <element name="widgetSelectBlock" type="button" selector="//button[@class='action-default scalable btn-chooser']"/> + <element name="selectBlockTitle" type="input" selector="//input[@name='chooser_title']"/> + <element name="searchBlock" type="button" selector="//div[@class='admin__filter-actions']/button[@title='Search']"/> + <element name="blockStatus" type="select" selector="//select[@name='chooser_is_active']"/> + <element name="searchedBlock" type="button" selector="//*[@class='magento-message']//tbody/tr/td[1]"/> + <element name="saveWidget" type="select" selector="#save"/> </section> </sections> From bcfae0ce0eeeb1203ba114d274d53b816c117c3e Mon Sep 17 00:00:00 2001 From: Stepan Furman <furman.stepan@gmail.com> Date: Mon, 3 Dec 2018 23:27:04 +0200 Subject: [PATCH 034/121] extend CustomerInput schema --- .../Magento/CustomerGraphQl/etc/schema.graphqls | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls index a6b48b62568d1..9e33b8a0d3fa7 100644 --- a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls +++ b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls @@ -18,10 +18,16 @@ type CustomerToken { } input CustomerInput { - firstname: String - lastname: String - email: String - password: String + prefix: String + firstname: String! + middlename: String! + lastname: String! + suffix: String + dob: String + taxvat: String + gender: String + email: String! + password: String! is_subscribed: Boolean } From 9bf12ccb6439e611c762e973ccc5f3d68568669f Mon Sep 17 00:00:00 2001 From: Stepan Furman <furman.stepan@gmail.com> Date: Tue, 4 Dec 2018 00:52:16 +0200 Subject: [PATCH 035/121] subscription implementetion way changed, schema required fields removed, gender input type changed --- .../Model/Resolver/CreateCustomer.php | 21 +++++++++++-------- .../CustomerGraphQl/etc/schema.graphqls | 12 +++++------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php index a265dc300b923..51353cd5b27aa 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php +++ b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php @@ -11,6 +11,7 @@ use Magento\Customer\Api\AccountManagementInterface; use Magento\Customer\Api\Data\CustomerInterface; use Magento\Customer\Api\Data\CustomerInterfaceFactory; +use Magento\CustomerGraphQl\Model\Customer\ChangeSubscriptionStatus; use Magento\CustomerGraphQl\Model\Customer\CustomerDataProvider; use Magento\Framework\Api\DataObjectHelper; use Magento\Framework\Exception\LocalizedException; @@ -22,26 +23,20 @@ use Magento\Newsletter\Model\SubscriberFactory; use Magento\Store\Model\StoreManagerInterface; -/** - * Create customer data resolver - */ class CreateCustomer implements ResolverInterface { /** * @var CustomerDataProvider */ private $customerDataProvider; - /** * @var AccountManagementInterface */ private $accountManagement; - /** * @var CustomerInterfaceFactory */ private $customerFactory; - /** * @var DataObjectHelper */ @@ -54,6 +49,10 @@ class CreateCustomer implements ResolverInterface * @var SubscriberFactory */ private $subscriberFactory; + /** + * @var ChangeSubscriptionStatus + */ + private $changeSubscriptionStatus; /** * @param DataObjectHelper $dataObjectHelper @@ -62,6 +61,7 @@ class CreateCustomer implements ResolverInterface * @param StoreManagerInterface $storeManager * @param SubscriberFactory $subscriberFactory * @param CustomerDataProvider $customerDataProvider + * @param ChangeSubscriptionStatus $changeSubscriptionStatus */ public function __construct( DataObjectHelper $dataObjectHelper, @@ -69,7 +69,8 @@ public function __construct( AccountManagementInterface $accountManagement, StoreManagerInterface $storeManager, SubscriberFactory $subscriberFactory, - CustomerDataProvider $customerDataProvider + CustomerDataProvider $customerDataProvider, + ChangeSubscriptionStatus $changeSubscriptionStatus ) { $this->customerDataProvider = $customerDataProvider; $this->accountManagement = $accountManagement; @@ -77,6 +78,7 @@ public function __construct( $this->dataObjectHelper = $dataObjectHelper; $this->storeManager = $storeManager; $this->subscriberFactory = $subscriberFactory; + $this->changeSubscriptionStatus = $changeSubscriptionStatus; } /** @@ -94,13 +96,14 @@ public function resolve( } try { $customer = $this->createUserAccount($args); + $customerId = (int)$customer->getId(); $this->setUpUserContext($context, $customer); if (array_key_exists('is_subscribed', $args['input'])) { if ($args['input']['is_subscribed']) { - $this->subscriberFactory->create()->subscribeCustomerById($customer->getId()); + $this->changeSubscriptionStatus->execute($customerId, true); } } - $data = $this->customerDataProvider->getCustomerById((int)$customer->getId()); + $data = $this->customerDataProvider->getCustomerById($customerId); } catch (LocalizedException $e) { throw new GraphQlInputException(__($e->getMessage())); } diff --git a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls index 9e33b8a0d3fa7..9ff16eddbe5f3 100644 --- a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls +++ b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls @@ -19,15 +19,15 @@ type CustomerToken { input CustomerInput { prefix: String - firstname: String! - middlename: String! - lastname: String! + firstname: String + middlename: String + lastname: String suffix: String dob: String taxvat: String - gender: String - email: String! - password: String! + gender: Int + email: String + password: String is_subscribed: Boolean } From 906aeb25f9c1dd4cf45e343f6405fef0766ab5fd Mon Sep 17 00:00:00 2001 From: Stepan Furman <furman.stepan@gmail.com> Date: Tue, 4 Dec 2018 09:47:25 +0200 Subject: [PATCH 036/121] added customer input fields doc block, changed try catch block for handling only validation exceptions --- .../Model/Resolver/CreateCustomer.php | 15 +++++++++++-- .../CustomerGraphQl/etc/schema.graphqls | 22 +++++++++---------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php index 51353cd5b27aa..503c7203233f8 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php +++ b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php @@ -18,8 +18,11 @@ use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\GraphQl\Config\Element\Field; use Magento\Framework\GraphQl\Exception\GraphQlInputException; +use Magento\Framework\GraphQl\Query\Resolver\ContextInterface; +use Magento\Framework\GraphQl\Query\Resolver\Value; use Magento\Framework\GraphQl\Query\ResolverInterface; use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; +use Magento\Framework\Validator\Exception as ValidatorException; use Magento\Newsletter\Model\SubscriberFactory; use Magento\Store\Model\StoreManagerInterface; @@ -82,7 +85,15 @@ public function __construct( } /** - * @inheritdoc + * @param Field $field + * @param ContextInterface $context + * @param ResolveInfo $info + * @param array|null $value + * @param array|null $args + * @return array|Value|mixed + * @throws GraphQlInputException + * @throws LocalizedException + * @throws NoSuchEntityException */ public function resolve( Field $field, @@ -104,7 +115,7 @@ public function resolve( } } $data = $this->customerDataProvider->getCustomerById($customerId); - } catch (LocalizedException $e) { + } catch (ValidatorException $e) { throw new GraphQlInputException(__($e->getMessage())); } diff --git a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls index 9ff16eddbe5f3..d7a00b70303e4 100644 --- a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls +++ b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls @@ -18,17 +18,17 @@ type CustomerToken { } input CustomerInput { - prefix: String - firstname: String - middlename: String - lastname: String - suffix: String - dob: String - taxvat: String - gender: Int - email: String - password: String - is_subscribed: Boolean + prefix: String @doc(description: "An honorific, such as Dr., Mr., or Mrs.") + firstname: String @doc(description: "The customer's first name") + middlename: String @doc(description: "The customer's middle name") + lastname: String @doc(description: "The customer's family name") + suffix: String @doc(description: "A value such as Sr., Jr., or III") + email: String @doc(description: "The customer's email address. Required") + dob: String @doc(description: "The customer's date of birth") + taxvat: String @doc(description: "The customer's Tax/VAT number (for corporate customers)") + gender: Int @doc(description: "The customer's gender(Male - 1, Female - 2)") + password: String @doc(description: "The customer's password") + is_subscribed: Boolean @doc(description: "Indicates whether the customer is subscribed to the company's newsletter") } type CustomerOutput { From 0136faf798d7c67907981ab25f4db0850aeeaa03 Mon Sep 17 00:00:00 2001 From: Stepan Furman <furman.stepan@gmail.com> Date: Tue, 4 Dec 2018 11:25:48 +0200 Subject: [PATCH 037/121] turn InputMismatchException into GraphQlInputException --- .../Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php index 503c7203233f8..ad09fd71efde3 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php +++ b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php @@ -16,6 +16,7 @@ use Magento\Framework\Api\DataObjectHelper; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Exception\State\InputMismatchException; use Magento\Framework\GraphQl\Config\Element\Field; use Magento\Framework\GraphQl\Exception\GraphQlInputException; use Magento\Framework\GraphQl\Query\Resolver\ContextInterface; @@ -117,6 +118,8 @@ public function resolve( $data = $this->customerDataProvider->getCustomerById($customerId); } catch (ValidatorException $e) { throw new GraphQlInputException(__($e->getMessage())); + } catch (InputMismatchException $e) { + throw new GraphQlInputException(__($e->getMessage())); } return ['customer' => $data]; From 72b3c93f37c4c559ec2eab76b16b943d94961527 Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <Veronika_Kurochkina@epam.com> Date: Tue, 4 Dec 2018 14:59:07 +0300 Subject: [PATCH 038/121] MAGETWO-95820: Order placed by new customer before they registered is displayed in the admin under the name Guest - Update automated test --- .../Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml index 740d75cb0ffe3..52eb0c3eb69e4 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml @@ -51,7 +51,7 @@ <argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" /> </actionGroup> <grabTextFrom selector="{{CheckoutSuccessRegisterSection.orderNumber}}" stepKey="grabOrderNumber"/> - <click selector="{{CustomerAccountSection.createAccount}}" stepKey="clickToCreateAccount"/> + <click selector="{{StorefrontPanelHeaderSection.createAnAccountLink}}" stepKey="clickToCreateAccount"/> <fillField selector="{{StorefrontCustomerCreateFormSection.passwordField}}" userInput="{{CustomerData.password}}" stepKey="TypePassword"/> <fillField selector="{{StorefrontCustomerCreateFormSection.confirmPasswordField}}" userInput="{{CustomerData.password}}" stepKey="TypeConfirmationPassword"/> <click selector="{{StorefrontCustomerCreateFormSection.createAccountButton}}" stepKey="clickOnCreateAccount"/> From 064b76e914ef2f95f8f1476e107194e4a0deae9a Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <Veronika_Kurochkina@epam.com> Date: Tue, 4 Dec 2018 15:57:38 +0300 Subject: [PATCH 039/121] MAGETWO-95820: Order placed by new customer before they registered is displayed in the admin under the name Guest - Update automated test --- .../Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml index 52eb0c3eb69e4..e489f80ab6281 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml @@ -52,8 +52,8 @@ </actionGroup> <grabTextFrom selector="{{CheckoutSuccessRegisterSection.orderNumber}}" stepKey="grabOrderNumber"/> <click selector="{{StorefrontPanelHeaderSection.createAnAccountLink}}" stepKey="clickToCreateAccount"/> - <fillField selector="{{StorefrontCustomerCreateFormSection.passwordField}}" userInput="{{CustomerData.password}}" stepKey="TypePassword"/> - <fillField selector="{{StorefrontCustomerCreateFormSection.confirmPasswordField}}" userInput="{{CustomerData.password}}" stepKey="TypeConfirmationPassword"/> + <fillField selector="{{StorefrontCustomerCreateFormSection.passwordField}}" userInput="{{customerData.password}}" stepKey="TypePassword"/> + <fillField selector="{{StorefrontCustomerCreateFormSection.confirmPasswordField}}" userInput="{{customerData.password}}" stepKey="TypeConfirmationPassword"/> <click selector="{{StorefrontCustomerCreateFormSection.createAccountButton}}" stepKey="clickOnCreateAccount"/> <see userInput="Thank you for registering" stepKey="verifyAccountCreated"/> <actionGroup ref="LoginAsAdmin" stepKey="loginToAdmin"/> From 579772cd4a0813cb8c0c12891707835d37806dd6 Mon Sep 17 00:00:00 2001 From: Yauhen_Lyskavets <yauhen_lyskavets@epam.com> Date: Tue, 4 Dec 2018 16:48:43 +0300 Subject: [PATCH 040/121] MAGETWO-95310: [2.3] Wrong color image when filtering by color filter - CM test fix. --- .../Swatches/Block/Product/Renderer/Listing/Configurable.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Swatches/Block/Product/Renderer/Listing/Configurable.php b/app/code/Magento/Swatches/Block/Product/Renderer/Listing/Configurable.php index 287134d6bb70a..2e4980c2fbfd0 100644 --- a/app/code/Magento/Swatches/Block/Product/Renderer/Listing/Configurable.php +++ b/app/code/Magento/Swatches/Block/Product/Renderer/Listing/Configurable.php @@ -192,6 +192,7 @@ protected function getOptionImages() * Add images to result json config in case of Layered Navigation is used * * @return array + * @SuppressWarnings(PHPMD.RequestAwareBlockMethod) * @since 100.2.0 */ protected function _getAdditionalConfig() From 9f80c0106f59bb1d2e5d4409c17045901fee1534 Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <Veronika_Kurochkina@epam.com> Date: Tue, 4 Dec 2018 16:59:39 +0300 Subject: [PATCH 041/121] MAGETWO-95820: Order placed by new customer before they registered is displayed in the admin under the name Guest - Update automated test --- .../Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml index e489f80ab6281..79936776ab0ac 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml @@ -51,9 +51,9 @@ <argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage" /> </actionGroup> <grabTextFrom selector="{{CheckoutSuccessRegisterSection.orderNumber}}" stepKey="grabOrderNumber"/> - <click selector="{{StorefrontPanelHeaderSection.createAnAccountLink}}" stepKey="clickToCreateAccount"/> - <fillField selector="{{StorefrontCustomerCreateFormSection.passwordField}}" userInput="{{customerData.password}}" stepKey="TypePassword"/> - <fillField selector="{{StorefrontCustomerCreateFormSection.confirmPasswordField}}" userInput="{{customerData.password}}" stepKey="TypeConfirmationPassword"/> + <click selector="{{CheckoutSuccessRegisterSection.createAccountButton}}" stepKey="clickCreateAccountButton"/> + <fillField selector="{{StorefrontCustomerCreateFormSection.passwordField}}" userInput="{{CustomerEntityOne.password}}" stepKey="TypePassword"/> + <fillField selector="{{StorefrontCustomerCreateFormSection.confirmPasswordField}}" userInput="{{CustomerEntityOne.password}}" stepKey="TypeConfirmationPassword"/> <click selector="{{StorefrontCustomerCreateFormSection.createAccountButton}}" stepKey="clickOnCreateAccount"/> <see userInput="Thank you for registering" stepKey="verifyAccountCreated"/> <actionGroup ref="LoginAsAdmin" stepKey="loginToAdmin"/> From 255b8f226400a1a5f2e2d93b877bfffe1a8f60ea Mon Sep 17 00:00:00 2001 From: Stepan Furman <furman.stepan@gmail.com> Date: Tue, 4 Dec 2018 20:30:20 +0200 Subject: [PATCH 042/121] split class, format changes --- .../Model/Customer/CreateAccount.php | 78 ++++++++++++ .../Model/Customer/SetUpUserContext.php | 23 ++++ .../Model/Resolver/CreateCustomer.php | 113 ++++-------------- 3 files changed, 125 insertions(+), 89 deletions(-) create mode 100644 app/code/Magento/CustomerGraphQl/Model/Customer/CreateAccount.php create mode 100644 app/code/Magento/CustomerGraphQl/Model/Customer/SetUpUserContext.php diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/CreateAccount.php b/app/code/Magento/CustomerGraphQl/Model/Customer/CreateAccount.php new file mode 100644 index 0000000000000..355bd1c6ec853 --- /dev/null +++ b/app/code/Magento/CustomerGraphQl/Model/Customer/CreateAccount.php @@ -0,0 +1,78 @@ +<?php + +namespace Magento\CustomerGraphQl\Model\Customer; + +use Magento\Customer\Api\AccountManagementInterface; +use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Customer\Api\Data\CustomerInterfaceFactory; +use Magento\Framework\Api\DataObjectHelper; +use Magento\Framework\Exception\LocalizedException; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Store\Model\StoreManagerInterface; + +/** + * Class CreateAccount creates new customer account + */ +class CreateAccount +{ + /** + * @var DataObjectHelper + */ + private $dataObjectHelper; + + /** + * @var CustomerInterfaceFactory + */ + private $customerFactory; + + /** + * @var AccountManagementInterface + */ + private $accountManagement; + + /** + * @var StoreManagerInterface + */ + private $storeManager; + + /** + * @param DataObjectHelper $dataObjectHelper + * @param CustomerInterfaceFactory $customerFactory + * @param StoreManagerInterface $storeManager + * @param AccountManagementInterface $accountManagement + */ + public function __construct( + DataObjectHelper $dataObjectHelper, + CustomerInterfaceFactory $customerFactory, + StoreManagerInterface $storeManager, + AccountManagementInterface $accountManagement + ) { + $this->dataObjectHelper = $dataObjectHelper; + $this->customerFactory = $customerFactory; + $this->accountManagement = $accountManagement; + $this->storeManager = $storeManager; + } + + /** + * @param array $args + * @return CustomerInterface + * @throws LocalizedException + * @throws NoSuchEntityException + */ + public function execute($args) + { + $customerDataObject = $this->customerFactory->create(); + $this->dataObjectHelper->populateWithArray( + $customerDataObject, + $args['input'], + CustomerInterface::class + ); + $store = $this->storeManager->getStore(); + $customerDataObject->setWebsiteId($store->getWebsiteId()); + $customerDataObject->setStoreId($store->getId()); + + $password = array_key_exists('password', $args['input']) ? $args['input']['password'] : null; + + return $this->accountManagement->createAccount($customerDataObject, $password); + } +} diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/SetUpUserContext.php b/app/code/Magento/CustomerGraphQl/Model/Customer/SetUpUserContext.php new file mode 100644 index 0000000000000..94131722e5a9f --- /dev/null +++ b/app/code/Magento/CustomerGraphQl/Model/Customer/SetUpUserContext.php @@ -0,0 +1,23 @@ +<?php + +namespace Magento\CustomerGraphQl\Model\Customer; + +use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Framework\GraphQl\Query\Resolver\ContextInterface; +use Magento\Authorization\Model\UserContextInterface; + +/** + * Set up user context after creating new customer account + */ +class SetUpUserContext +{ + /** + * @param ContextInterface $context + * @param CustomerInterface $customer + */ + public function execute(ContextInterface $context, CustomerInterface $customer) + { + $context->setUserId((int)$customer->getId()); + $context->setUserType(UserContextInterface::USER_TYPE_CUSTOMER); + } +} diff --git a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php index ad09fd71efde3..299045c6b62b0 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php +++ b/app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php @@ -7,94 +7,62 @@ namespace Magento\CustomerGraphQl\Model\Resolver; -use Magento\Authorization\Model\UserContextInterface; -use Magento\Customer\Api\AccountManagementInterface; -use Magento\Customer\Api\Data\CustomerInterface; -use Magento\Customer\Api\Data\CustomerInterfaceFactory; use Magento\CustomerGraphQl\Model\Customer\ChangeSubscriptionStatus; +use Magento\CustomerGraphQl\Model\Customer\CreateAccount; use Magento\CustomerGraphQl\Model\Customer\CustomerDataProvider; -use Magento\Framework\Api\DataObjectHelper; -use Magento\Framework\Exception\LocalizedException; -use Magento\Framework\Exception\NoSuchEntityException; +use Magento\CustomerGraphQl\Model\Customer\SetUpUserContext; use Magento\Framework\Exception\State\InputMismatchException; use Magento\Framework\GraphQl\Config\Element\Field; use Magento\Framework\GraphQl\Exception\GraphQlInputException; -use Magento\Framework\GraphQl\Query\Resolver\ContextInterface; -use Magento\Framework\GraphQl\Query\Resolver\Value; use Magento\Framework\GraphQl\Query\ResolverInterface; use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; use Magento\Framework\Validator\Exception as ValidatorException; -use Magento\Newsletter\Model\SubscriberFactory; -use Magento\Store\Model\StoreManagerInterface; +/** + * Create customer account resolver + */ class CreateCustomer implements ResolverInterface { /** * @var CustomerDataProvider */ private $customerDataProvider; + /** - * @var AccountManagementInterface - */ - private $accountManagement; - /** - * @var CustomerInterfaceFactory - */ - private $customerFactory; - /** - * @var DataObjectHelper + * @var ChangeSubscriptionStatus */ - private $dataObjectHelper; + private $changeSubscriptionStatus; + /** - * @var StoreManagerInterface + * @var CreateAccount */ - private $storeManager; + private $createAccount; + /** - * @var SubscriberFactory + * @var SetUpUserContext */ - private $subscriberFactory; - /** - * @var ChangeSubscriptionStatus - */ - private $changeSubscriptionStatus; + private $setUpUserContext; /** - * @param DataObjectHelper $dataObjectHelper - * @param CustomerInterfaceFactory $customerFactory - * @param AccountManagementInterface $accountManagement - * @param StoreManagerInterface $storeManager - * @param SubscriberFactory $subscriberFactory * @param CustomerDataProvider $customerDataProvider * @param ChangeSubscriptionStatus $changeSubscriptionStatus + * @param SetUpUserContext $setUpUserContext + * @param CreateAccount $createAccount */ public function __construct( - DataObjectHelper $dataObjectHelper, - CustomerInterfaceFactory $customerFactory, - AccountManagementInterface $accountManagement, - StoreManagerInterface $storeManager, - SubscriberFactory $subscriberFactory, CustomerDataProvider $customerDataProvider, - ChangeSubscriptionStatus $changeSubscriptionStatus + ChangeSubscriptionStatus $changeSubscriptionStatus, + SetUpUserContext $setUpUserContext, + CreateAccount $createAccount ) { $this->customerDataProvider = $customerDataProvider; - $this->accountManagement = $accountManagement; - $this->customerFactory = $customerFactory; - $this->dataObjectHelper = $dataObjectHelper; - $this->storeManager = $storeManager; - $this->subscriberFactory = $subscriberFactory; $this->changeSubscriptionStatus = $changeSubscriptionStatus; + $this->createAccount = $createAccount; + $this->setUpUserContext = $setUpUserContext; } /** - * @param Field $field - * @param ContextInterface $context - * @param ResolveInfo $info - * @param array|null $value - * @param array|null $args - * @return array|Value|mixed - * @throws GraphQlInputException - * @throws LocalizedException - * @throws NoSuchEntityException + * @inheritdoc */ public function resolve( Field $field, @@ -107,9 +75,9 @@ public function resolve( throw new GraphQlInputException(__('"input" value should be specified')); } try { - $customer = $this->createUserAccount($args); + $customer = $this->createAccount->execute($args); $customerId = (int)$customer->getId(); - $this->setUpUserContext($context, $customer); + $this->setUpUserContext->execute($context, $customer); if (array_key_exists('is_subscribed', $args['input'])) { if ($args['input']['is_subscribed']) { $this->changeSubscriptionStatus->execute($customerId, true); @@ -124,37 +92,4 @@ public function resolve( return ['customer' => $data]; } - - /** - * @param $args - * @return CustomerInterface - * @throws LocalizedException - * @throws NoSuchEntityException - */ - private function createUserAccount($args) - { - $customerDataObject = $this->customerFactory->create(); - $this->dataObjectHelper->populateWithArray( - $customerDataObject, - $args['input'], - CustomerInterface::class - ); - $store = $this->storeManager->getStore(); - $customerDataObject->setWebsiteId($store->getWebsiteId()); - $customerDataObject->setStoreId($store->getId()); - - $password = array_key_exists('password', $args['input']) ? $args['input']['password'] : null; - - return $this->accountManagement->createAccount($customerDataObject, $password); - } - - /** - * @param $context - * @param CustomerInterface $customer - */ - private function setUpUserContext($context, $customer) - { - $context->setUserId((int)$customer->getId()); - $context->setUserType(UserContextInterface::USER_TYPE_CUSTOMER); - } } From 89584157cac040738fab386e51e54ebd81286954 Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <Veronika_Kurochkina@epam.com> Date: Tue, 11 Dec 2018 11:07:17 +0300 Subject: [PATCH 043/121] MAGETWO-95820: Order placed by new customer before they registered is displayed in the admin under the name Guest - Update automated test --- .../Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml index 79936776ab0ac..693c05684f292 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StoreFrontCheckCustomerInfoCreatedByGuestTest.xml @@ -25,12 +25,10 @@ <createData entity="_defaultProduct" stepKey="product"> <requiredEntity createDataKey="category"/> </createData> - <createData entity="EnableAllowGuestCheckout" stepKey="enableGuestCheckout"/> <magentoCLI command="cache:flush" stepKey="flushCache"/> </before> <after> - <createData entity="DisableAllowGuestCheckout" stepKey="disableGuestCheckout"/> <deleteData createDataKey="product" stepKey="deleteProduct" /> <deleteData createDataKey="category" stepKey="deleteCategory" /> <actionGroup ref="logout" stepKey="logoutFromAdmin"/> From f50d5ceae5f98e09d1f7a161fda54bd171b95f77 Mon Sep 17 00:00:00 2001 From: Sona Sargsyan <sona_sargsyan@epam.com> Date: Tue, 11 Dec 2018 15:50:12 +0400 Subject: [PATCH 044/121] MAGETWO-96406: [2.3.x] Swatch Attribute is not displayed in the Widget CMS - Added automation test --- .../AdminProductAttributeActionGroup.xml | 16 ++++ .../CreateNewPageWithWidgetActionGroup.xml | 40 +++++++++ .../Cms/Test/Mftf/Data/NewCMSPageData.xml | 14 +++ .../Section/CmsNewPagePageActionsSection.xml | 1 + .../Section/AdminNewAttributePanelSection.xml | 7 ++ .../AddSwatchToProductActionGroup.xml | 18 ++++ .../StorefrontProductInfoMainSection.xml | 1 + ...SwatchAttributesDisplayInWidgetCMSTest.xml | 85 +++++++++++++++++++ 8 files changed, 182 insertions(+) create mode 100644 app/code/Magento/Cms/Test/Mftf/ActionGroup/CreateNewPageWithWidgetActionGroup.xml create mode 100644 app/code/Magento/Cms/Test/Mftf/Data/NewCMSPageData.xml create mode 100644 app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml index 80cadbb6571f2..8f8a86ac5adf1 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml @@ -47,4 +47,20 @@ <seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="waitForSuccessMessage"/> </actionGroup> + <actionGroup name="deleteProductAttributeByLabel"> + <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/Cms/Test/Mftf/ActionGroup/CreateNewPageWithWidgetActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/CreateNewPageWithWidgetActionGroup.xml new file mode 100644 index 0000000000000..a4b88c544de88 --- /dev/null +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/CreateNewPageWithWidgetActionGroup.xml @@ -0,0 +1,40 @@ +<?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="CreateNewPageWithWidget"> + <arguments> + <argument name="pageTitle" type="string" defaultValue="{{defaultCmsPage.title}}"/> + <argument name="category" type="string"/> + <argument name="condition" type="string"/> + <argument name="widgetType" type="string"/> + </arguments> + <amOnPage url="{{CmsNewPagePage.url}}" stepKey="amOnCMSNewPage"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + <fillField selector="{{CmsNewPagePageBasicFieldsSection.pageTitle}}" userInput="{{pageTitle}}" stepKey="fillFieldTitle"/> + <click selector="{{CmsNewPagePageContentSection.header}}" stepKey="clickExpandContent"/> + <click selector="{{CmsNewPagePageActionsSection.insertWidget}}" stepKey="clickToInsertWidget"/> + <waitForPageLoad stepKey="waitForPageLoad1"/> + <waitForElementVisible stepKey="waitForInsertWidgetTitle" selector="{{WidgetSection.InsertWidgetTitle}}"/> + <selectOption selector="{{WidgetSection.WidgetType}}" userInput="{{widgetType}}" stepKey="selectCatalogProductsList"/> + <waitForElementVisible selector="{{WidgetSection.AddParam}}" stepKey="waitForAddParam"/> + <scrollTo selector="{{WidgetSection.AddParam}}" stepKey="scrollToAddParamElement"/> + <click selector="{{WidgetSection.AddParam}}" stepKey="addParam"/> + <selectOption selector="{{WidgetSection.ConditionsDropdown}}" userInput="{{condition}}" stepKey="selectCategory"/> + <waitForElementVisible selector="{{WidgetSection.RuleParam}}" stepKey="waitForRuleParam"/> + <click selector="{{WidgetSection.RuleParam}}" stepKey="clickToAddRuleParam"/> + <click selector="{{WidgetSection.Chooser}}" stepKey="clickToSelectFromList"/> + <waitForPageLoad stepKey="waitForPageLoad2"/> + <click selector="{{WidgetSection.PreCreateCategory(category)}}" stepKey="selectPreCategory" /> + <click selector="{{WidgetSection.InsertWidget}}" stepKey="clickToSaveInsertedWidget"/> + <waitForPageLoad stepKey="waitForPageLoad3"/> + <click selector="{{CmsNewBlockBlockActionsSection.savePage}}" stepKey="saveCMSPage"/> + <waitForElementVisible selector="{{CmsPagesPageActionsSection.savePageSuccessMessage}}" stepKey="waitForSuccessMessageLoggedOut" time="5"/> + <see userInput="You saved the page." stepKey="seeSuccessMessage"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Cms/Test/Mftf/Data/NewCMSPageData.xml b/app/code/Magento/Cms/Test/Mftf/Data/NewCMSPageData.xml new file mode 100644 index 0000000000000..61dfb051d101e --- /dev/null +++ b/app/code/Magento/Cms/Test/Mftf/Data/NewCMSPageData.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="defaultCmsPage" type="block"> + <data key="title" unique="suffix">CMSpage</data> + </entity> +</entities> diff --git a/app/code/Magento/Cms/Test/Mftf/Section/CmsNewPagePageActionsSection.xml b/app/code/Magento/Cms/Test/Mftf/Section/CmsNewPagePageActionsSection.xml index 42f8f4d00ee9f..a340d0af1e7a1 100644 --- a/app/code/Magento/Cms/Test/Mftf/Section/CmsNewPagePageActionsSection.xml +++ b/app/code/Magento/Cms/Test/Mftf/Section/CmsNewPagePageActionsSection.xml @@ -22,5 +22,6 @@ <element name="content" type="input" selector="//textarea[@name='content']"/> <element name="spinner" type="input" selector='//div[@data-component="cms_page_form.cms_page_form"]' /> <element name="saveAndClose" type="button" selector="#save_and_close" timeout="10"/> + <element name="insertWidget" type="button" selector="//span[contains(text(),'Insert Widget...')]"/> </section> </sections> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminNewAttributePanelSection.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminNewAttributePanelSection.xml index 44077888f8bc0..9310091ee13f2 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminNewAttributePanelSection.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminNewAttributePanelSection.xml @@ -9,6 +9,13 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminNewAttributePanel"> + <element name="useInSearch" type="select" selector="#is_searchable"/> + <element name="visibleInAdvancedSearch" type="select" selector="#is_visible_in_advanced_search"/> + <element name="comparableOnStorefront" type="select" selector="#is_comparable"/> + <element name="useInLayeredNavigation" type="select" selector="#is_filterable"/> + <element name="visibleOnCatalogPagesOnStorefront" type="select" selector="#is_visible_on_front"/> + <element name="useInProductListing" type="select" selector="#used_in_product_listing"/> + <element name="usedForStoringInProductListing" type="select" selector="#used_for_sort_by"/> <element name="container" type="text" selector="#create_new_attribute"/> <element name="saveAttribute" type="button" selector="#save"/> <element name="newAttributeIFrame" type="iframe" selector="create_new_attribute_container"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddSwatchToProductActionGroup.xml b/app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddSwatchToProductActionGroup.xml index 60a8035dedeca..a4fbc028e54a6 100644 --- a/app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddSwatchToProductActionGroup.xml +++ b/app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddSwatchToProductActionGroup.xml @@ -62,4 +62,22 @@ <seeElement selector="{{AdminMessagesSection.success}}" stepKey="seeSaveProductMessage"/> </actionGroup> + <actionGroup name="AddVisualSwatchToProductWithStorefrontConfigActionGroup" extends="AddVisualSwatchToProductActionGroup"> + <arguments> + <argument name="attribute" defaultValue="visualSwatchAttribute"/> + <argument name="option1" defaultValue="visualSwatchOption1"/> + <argument name="option2" defaultValue="visualSwatchOption2"/> + </arguments> + + <!-- Go to Storefront Properties tab --> + <scrollToTopOfPage stepKey="scrollToTop" after="fillDefaultStoreLabel2"/> + <click selector="#front_fieldset-wrapper" stepKey="goToStorefrontPropertiesTab" after="scrollToTop"/> + <waitForElementVisible selector="//span[text()='Storefront Properties']" stepKey="waitTabLoad" after="goToStorefrontPropertiesTab"/> + <selectOption selector="{{AdminNewAttributePanel.useInSearch}}" stepKey="switchOnUsInSearch" userInput="Yes" after="waitTabLoad"/> + <selectOption selector="{{AdminNewAttributePanel.visibleInAdvancedSearch}}" stepKey="switchOnVisibleInAdvancedSearch" userInput="Yes" after="switchOnUsInSearch"/> + <selectOption selector="{{AdminNewAttributePanel.comparableOnStorefront}}" stepKey="switchOnComparableOnStorefront" userInput="Yes" after="switchOnVisibleInAdvancedSearch"/> + <selectOption selector="{{AdminNewAttributePanel.useInLayeredNavigation}}" stepKey="selectUseInLayer" userInput="Filterable (with results)" after="switchOnComparableOnStorefront"/> + <selectOption selector="{{AdminNewAttributePanel.visibleOnCatalogPagesOnStorefront}}" stepKey="switchOnVisibleOnCatalogPagesOnStorefront" userInput="Yes" after="selectUseInLayer"/> + <selectOption selector="{{AdminNewAttributePanel.useInProductListing}}" stepKey="switchOnUsedInProductListing" userInput="Yes" after="switchOnVisibleOnCatalogPagesOnStorefront"/> + </actionGroup> </actionGroups> diff --git a/app/code/Magento/Swatches/Test/Mftf/Section/StorefrontProductInfoMainSection.xml b/app/code/Magento/Swatches/Test/Mftf/Section/StorefrontProductInfoMainSection.xml index 415ae88fceb52..e40a04080285a 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Section/StorefrontProductInfoMainSection.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Section/StorefrontProductInfoMainSection.xml @@ -14,5 +14,6 @@ <element name="selectedSwatchValue" type="text" selector="//div[contains(@class, 'swatch-attribute') and contains(., '{{attr}}')]//span[contains(@class, 'swatch-attribute-selected-option')]" parameterized="true"/> <element name="swatchAttributeOptions" type="text" selector="div.swatch-attribute-options"/> <element name="nthSwatchOptionText" type="button" selector="div.swatch-option.text:nth-of-type({{n}})" parameterized="true"/> + <element name="productSwatch" type="button" selector="//div[@class='swatch-option'][@aria-label='{{var1}}']" parameterized="true"/> </section> </sections> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml new file mode 100644 index 0000000000000..bcd4cac70118b --- /dev/null +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml @@ -0,0 +1,85 @@ +<?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="StorefrontSwatchAttributesDisplayInWidgetCMSTest"> + <annotations> + <features value="ConfigurableProduct"/> + <title value="Swatch Attribute is not displayed in the Widget CMS"/> + <description value="Swatch Attribute is not displayed in the Widget CMS"/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-96469"/> + <useCaseId value="MAGETWO-96406"/> + <group value="ConfigurableProduct"/> + </annotations> + + <before> + <createData entity="NewRootCategory" stepKey="createRootCategory"/> + </before> + + <after> + <!--delete created configurable product--> + <actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteProduct"> + <argument name="product" value="BaseConfigurableProduct"/> + </actionGroup> + <actionGroup ref="deleteProductAttributeByLabel" stepKey="deleteAttribute"> + <argument name="ProductAttribute" value="visualSwatchAttribute"/> + </actionGroup> + <!--delete root category--> + <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPageAfterCLIReindexCommand"/> + <waitForPageLoad time="30" stepKey="waitForPageCategoryLoadAfterCLIReindexCommand"/> + <click selector="{{AdminCategorySidebarTreeSection.categoryInTree('$$createRootCategory.name$$')}}" stepKey="clickOnDefaultRootCategory"/> + <waitForPageLoad stepKey="waitForPageDefaultCategoryEditLoad" /> + <seeElement selector="{{AdminCategoryMainActionsSection.DeleteButton}}" stepKey="assertDeleteButtonIsPresent1"/> + <click selector="{{AdminCategoryMainActionsSection.DeleteButton}}" stepKey="DeleteDefaultRootCategory"/> + <waitForElementVisible selector="{{AdminCategoryModalSection.ok}}" stepKey="waitForModalDeleteDefaultRootCategory" /> + <click selector="{{AdminCategoryModalSection.ok}}" stepKey="acceptModal1"/> + <waitForElementVisible selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="waitForPageReloadAfterDeleteDefaultCategory"/> + <!--logout--> + <actionGroup ref="logout" stepKey="logoutFromAdmin"/> + </after> + <!--Login--> + <actionGroup ref="LoginAsAdmin" stepKey="loginToAdmin"/> + <!--Create a configurable swatch product via the UI --> + <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="goToProductIndex"/> + <waitForPageLoad stepKey="waitForProductPage"/> + <actionGroup ref="goToCreateProductPage" stepKey="goToCreateProductPage"> + <argument name="product" value="BaseConfigurableProduct"/> + </actionGroup> + <actionGroup ref="fillMainProductForm" stepKey="fillProductForm"> + <argument name="product" value="BaseConfigurableProduct"/> + </actionGroup> + <searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="[$$createRootCategory.name$$]" stepKey="searchAndSelectCategory"/> + <!--Add swatch attribute to configurable product--> + <actionGroup ref="AddVisualSwatchToProductWithStorefrontConfigActionGroup" stepKey="addSwatchToProduct"/> + + <!--Create CMS page--> + <actionGroup ref="CreateNewPageWithWidget" stepKey="createCMSPageWithWidget"> + <argument name="category" value="$$createRootCategory.name$$"/> + <argument name="condition" value="Category"/> + <argument name="widgetType" value="Catalog Products List"/> + </actionGroup> + <click selector="{{CmsNewPagePageSeoSection.header}}" stepKey="clickToExpandSEOSection"/> + <scrollTo selector="{{CmsNewPagePageSeoSection.urlKey}}" stepKey="scrollToUrlKey"/> + <grabValueFrom selector="{{CmsNewPagePageSeoSection.urlKey}}" stepKey="grabTextFromUrlKey"/> + <actionGroup ref="logout" stepKey="logout"/> + + <!--Open Storefront page for the new created page--> + <amOnPage url="{{StorefrontHomePage.url}}$grabTextFromUrlKey" stepKey="gotToCreatedCmsPage"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + <seeElement selector="{{StorefrontProductInfoMainSection.productSwatch(visualSwatchOption1.default_label)}}" stepKey="assertAddedWidgetS"/> + <seeElement selector="{{StorefrontProductInfoMainSection.productSwatch(visualSwatchOption2.default_label)}}" stepKey="assertAddedWidgetM"/> + + <!--Login to delete CMS page--> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + <actionGroup ref="DeletePageByUrlKeyActionGroup" stepKey="deletePage"> + <argument name="UrlKey" value="$grabTextFromUrlKey"/> + </actionGroup> + </test> +</tests> From 27ad6c4e25d38bdf80be07406d2755da94e4a681 Mon Sep 17 00:00:00 2001 From: Andrew Molina <amolina@adobe.com> Date: Tue, 11 Dec 2018 13:13:43 -0600 Subject: [PATCH 045/121] MC-5717: Sub-category doesnt display after moving categories --- .../Catalog/Controller/Adminhtml/Category/RefreshPath.php | 1 + .../Unit/Controller/Adminhtml/Category/RefreshPathTest.php | 4 ++-- .../Catalog/view/adminhtml/ui_component/category_form.xml | 7 +++++++ .../Catalog/view/adminhtml/web/catalog/category/form.js | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php index 046ebbb119e5b..e58a0c5b0996e 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php @@ -44,6 +44,7 @@ public function execute() 'id' => $categoryId, 'path' => $category->getPath(), 'parentId' => $category->getParentId(), + 'level' => $category->getLevel() ]); } } diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/RefreshPathTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/RefreshPathTest.php index 45de62e218cfc..adf00333721ba 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/RefreshPathTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/RefreshPathTest.php @@ -66,8 +66,8 @@ private function setObjectProperty($object, string $propertyName, $value) : void */ public function testExecute() : void { - $value = ['id' => 3, 'path' => '1/2/3', 'parentId' => 2]; - $result = '{"id":3,"path":"1/2/3","parentId":"2"}'; + $value = ['id' => 3, 'path' => '1/2/3', 'parentId' => 2, 'level' => 2]; + $result = '{"id":3,"path":"1/2/3","parentId":"2","level":"2"}'; $requestMock = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class); diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml index 1a54db0d59f0f..90d6e0b48400e 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml @@ -77,6 +77,13 @@ <dataType>text</dataType> </settings> </field> + <field name="level" formElement="hidden"> + <argument name="data" xsi:type="array"> + <item name="config" xsi:type="array"> + <item name="source" xsi:type="string">category</item> + </item> + </argument> + </field> <field name="store_id" formElement="hidden"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> diff --git a/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/form.js b/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/form.js index 0a04358e41123..76aaddf55ac99 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/form.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/form.js @@ -15,6 +15,7 @@ define([ categoryIdSelector: 'input[name="id"]', categoryPathSelector: 'input[name="path"]', categoryParentSelector: 'input[name="parent"]', + categoryLevelSelector: 'input[name="level"]', refreshUrl: config.refreshUrl }, @@ -47,6 +48,7 @@ define([ $(this.options.categoryIdSelector).val(data.id).change(); $(this.options.categoryPathSelector).val(data.path).change(); $(this.options.categoryParentSelector).val(data.parentId).change(); + $(this.options.categoryLevelSelector).val(data.level).change(); } } }; From b44371f7167d42a03ff3797f58929aa53da7b00b Mon Sep 17 00:00:00 2001 From: Alexey Yakimovich <yakimovich@almagy.com> Date: Wed, 12 Dec 2018 16:08:27 +0300 Subject: [PATCH 046/121] MAGETWO-94556: Undefined variables during product save - Fixed js static and unit tests; --- .../view/adminhtml/web/js/variations/variations.js | 1 + .../view/adminhtml/web/js/variations/variations.test.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js index c6eee5486d117..4cb580ce9740c 100644 --- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js +++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.js @@ -403,6 +403,7 @@ define([ */ validateForm: function (formElement) { formElement.validate(); + return !formElement.additionalInvalid && !formElement.source.get('params.invalid'); }, diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.test.js index ed2e29f4baf16..01998a69d3519 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.test.js @@ -46,8 +46,8 @@ define([ variation.serializeData(); - expect(variation.source.data['configurable-matrix']).toBeUndefined(); - expect(variation.source.data['associated_product_ids']).toBeUndefined(); + expect(variation.source.data['configurable-matrix']).toEqual(matrix); + expect(variation.source.data['associated_product_ids']).toEqual(ids); expect(variation.source.data['configurable-matrix-serialized']).toEqual(resultMatrix); expect(variation.source.data['associated_product_ids_serialized']).toEqual(resultIds); }); @@ -112,8 +112,8 @@ define([ variation.source.data['associated_product_ids_serialized'] = JSON.stringify(['some old data']); variation.serializeData(); - expect(variation.source.data['configurable-matrix']).toBeUndefined(); - expect(variation.source.data['associated_product_ids']).toBeUndefined(); + expect(variation.source.data['configurable-matrix']).toEqual(matrix); + expect(variation.source.data['associated_product_ids']).toEqual(ids); expect(variation.source.data['configurable-matrix-serialized']).toEqual(resultMatrix); expect(variation.source.data['associated_product_ids_serialized']).toEqual(resultIds); }); From 859bb7055e0c79b3f7ea2d82fec266a981adb016 Mon Sep 17 00:00:00 2001 From: Sona Sargsyan <sona_sargsyan@epam.com> Date: Wed, 12 Dec 2018 17:39:56 +0400 Subject: [PATCH 047/121] MAGETWO-96406: [2.3.x] Swatch Attribute is not displayed in the Widget CMS - Added fixes based on comments --- .../Mftf/ActionGroup/CreateNewPageWithWidgetActionGroup.xml | 1 + app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml | 1 + .../Test/Mftf/Section/AdminNewAttributePanelSection.xml | 2 ++ .../Test/Mftf/ActionGroup/AddSwatchToProductActionGroup.xml | 5 ++--- .../StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml | 4 ++-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/CreateNewPageWithWidgetActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/CreateNewPageWithWidgetActionGroup.xml index a4b88c544de88..7c8694a247dee 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/CreateNewPageWithWidgetActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/CreateNewPageWithWidgetActionGroup.xml @@ -30,6 +30,7 @@ <click selector="{{WidgetSection.RuleParam}}" stepKey="clickToAddRuleParam"/> <click selector="{{WidgetSection.Chooser}}" stepKey="clickToSelectFromList"/> <waitForPageLoad stepKey="waitForPageLoad2"/> + <click selector="{{WidgetSection.RuleParamListExpander('1')}}" stepKey="expandRootCategory"/> <click selector="{{WidgetSection.PreCreateCategory(category)}}" stepKey="selectPreCategory" /> <click selector="{{WidgetSection.InsertWidget}}" stepKey="clickToSaveInsertedWidget"/> <waitForPageLoad stepKey="waitForPageLoad3"/> diff --git a/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml b/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml index c7ea85e441bb9..101e694d75f55 100644 --- a/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml +++ b/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml @@ -101,6 +101,7 @@ <element name="RuleParamSelect" type="select" selector="//ul[contains(@class,'rule-param-children')]/li[{{arg1}}]//*[contains(@class,'rule-param')][{{arg2}}]//select" parameterized="true"/> <element name="RuleParamInput" type="input" selector="//ul[contains(@class,'rule-param-children')]/li[{{arg1}}]//*[contains(@class,'rule-param')][{{arg2}}]//input" parameterized="true"/> <element name="RuleParamLabel" type="input" selector="//ul[contains(@class,'rule-param-children')]/li[{{arg1}}]//*[contains(@class,'rule-param')][{{arg2}}]//a" parameterized="true"/> + <element name="RuleParamListExpander" selector="//div[@class='rule-chooser']//ul[contains(@class,'x-tree-root')]//li[{{arg3}}]//img[contains(@class,'x-tree-elbow-end-plus')]" parameterized="true"/> <element name="Chooser" type="button" selector="//img[@title='Open Chooser']"/> <element name="PageSize" type="input" selector="input[name='parameters[page_size]']"/> <element name="ProductAttribute" type="multiselect" selector="select[name='parameters[show_attributes][]']" /> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminNewAttributePanelSection.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminNewAttributePanelSection.xml index 9310091ee13f2..48d526b72bc2c 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminNewAttributePanelSection.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminNewAttributePanelSection.xml @@ -16,6 +16,8 @@ <element name="visibleOnCatalogPagesOnStorefront" type="select" selector="#is_visible_on_front"/> <element name="useInProductListing" type="select" selector="#used_in_product_listing"/> <element name="usedForStoringInProductListing" type="select" selector="#used_for_sort_by"/> + <element name="storefrontPropertiesTab" selector="#front_fieldset-wrapper"/> + <element name="storefrontPropertiesTitle" selector="//span[text()='Storefront Properties']"/> <element name="container" type="text" selector="#create_new_attribute"/> <element name="saveAttribute" type="button" selector="#save"/> <element name="newAttributeIFrame" type="iframe" selector="create_new_attribute_container"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddSwatchToProductActionGroup.xml b/app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddSwatchToProductActionGroup.xml index a4fbc028e54a6..2c91bba75fec9 100644 --- a/app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddSwatchToProductActionGroup.xml +++ b/app/code/Magento/Swatches/Test/Mftf/ActionGroup/AddSwatchToProductActionGroup.xml @@ -70,9 +70,8 @@ </arguments> <!-- Go to Storefront Properties tab --> - <scrollToTopOfPage stepKey="scrollToTop" after="fillDefaultStoreLabel2"/> - <click selector="#front_fieldset-wrapper" stepKey="goToStorefrontPropertiesTab" after="scrollToTop"/> - <waitForElementVisible selector="//span[text()='Storefront Properties']" stepKey="waitTabLoad" after="goToStorefrontPropertiesTab"/> + <click selector="{{AdminNewAttributePanel.storefrontPropertiesTab}}" stepKey="goToStorefrontPropertiesTab" after="fillDefaultStoreLabel2"/> + <waitForElementVisible selector="{{AdminNewAttributePanel.storefrontPropertiesTitle}}" stepKey="waitTabLoad" after="goToStorefrontPropertiesTab"/> <selectOption selector="{{AdminNewAttributePanel.useInSearch}}" stepKey="switchOnUsInSearch" userInput="Yes" after="waitTabLoad"/> <selectOption selector="{{AdminNewAttributePanel.visibleInAdvancedSearch}}" stepKey="switchOnVisibleInAdvancedSearch" userInput="Yes" after="switchOnUsInSearch"/> <selectOption selector="{{AdminNewAttributePanel.comparableOnStorefront}}" stepKey="switchOnComparableOnStorefront" userInput="Yes" after="switchOnVisibleInAdvancedSearch"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml index bcd4cac70118b..b45339edecd86 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml @@ -32,8 +32,8 @@ <argument name="ProductAttribute" value="visualSwatchAttribute"/> </actionGroup> <!--delete root category--> - <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPageAfterCLIReindexCommand"/> - <waitForPageLoad time="30" stepKey="waitForPageCategoryLoadAfterCLIReindexCommand"/> + <amOnPage url="{{AdminCategoryPage.url}}" stepKey="navigateToCategoryPage"/> + <waitForPageLoad time="30" stepKey="waitForPageCategoryLoad"/> <click selector="{{AdminCategorySidebarTreeSection.categoryInTree('$$createRootCategory.name$$')}}" stepKey="clickOnDefaultRootCategory"/> <waitForPageLoad stepKey="waitForPageDefaultCategoryEditLoad" /> <seeElement selector="{{AdminCategoryMainActionsSection.DeleteButton}}" stepKey="assertDeleteButtonIsPresent1"/> From 4bcd4787239bc155e91473c1ee0ba8bc22fbb35e Mon Sep 17 00:00:00 2001 From: Karen_Mkhitaryan <Karen_Mkhitaryan@epam.com> Date: Thu, 13 Dec 2018 11:16:18 +0400 Subject: [PATCH 048/121] MAGETWO-94556: Undefined variables during product save - Fix test --- .../Test/Mftf/Test/AdminConfigurableProductCreateTest.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml index f400a4d4708a8..bba352b16cc8a 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml @@ -113,9 +113,11 @@ <grabValueFrom selector="{{AdminProductFormConfigurationsSection.firstSKUInConfigurableProductsGrid}}" stepKey="grabTextFromContent"/> <fillField stepKey="fillMoreThan64Symbols" selector="{{AdminProductFormConfigurationsSection.firstSKUInConfigurableProductsGrid}}" userInput="01234567890123456789012345678901234567890123456789012345678901234"/> <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct1"/> + <conditionalClick selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" dependentSelector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" visible="true" stepKey="clickOnConfirmInPopup1"/> <see stepKey="seeErrorMessage" userInput="Please enter less or equal than 64 symbols."/> <fillField stepKey="fillCorrectSKU" selector="{{AdminProductFormConfigurationsSection.firstSKUInConfigurableProductsGrid}}" userInput="$grabTextFromContent"/> <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct2"/> + <conditionalClick selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" dependentSelector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" visible="true" stepKey="clickOnConfirmInPopup2"/> <see userInput="You saved the product." stepKey="seeSaveConfirmation"/> <amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="goToProductAttributes"/> <waitForPageLoad stepKey="waitForProductAttributes"/> From 1749d09856d08ee571b13f07ed4efe972f8c4cdb Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <Veronika_Kurochkina@epam.com> Date: Thu, 13 Dec 2018 13:49:24 +0300 Subject: [PATCH 049/121] MAGETWO-96124: [2.3.x] Custom Customer Attributes get cleared in case of invalid Customer Account creation on Storefront - Update automated test script --- .../Customer/Test/Mftf/Page/StorefrontCustomerCreatePage.xml | 2 +- .../Test/Mftf/Section/StorefrontCustomerCreateFormSection.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerCreatePage.xml b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerCreatePage.xml index 101ff1451ccbf..0d273da353005 100644 --- a/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerCreatePage.xml +++ b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerCreatePage.xml @@ -10,6 +10,6 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> <page name="StorefrontCustomerCreatePage" url="/customer/account/create/" area="storefront" module="Magento_Customer"> <section name="StorefrontCustomerCreateFormSection"/> - <section name="StoreFrontCustomerCustomAttributesSection"/> + <section name="StoreFrontCustomerAdvancedAttributesSection"/> </page> </pages> diff --git a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection.xml index a8c7cefb773d1..ee14ee5c165c5 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection.xml @@ -17,7 +17,7 @@ <element name="confirmPasswordField" type="input" selector="#password-confirmation"/> <element name="createAccountButton" type="button" selector="button.action.submit.primary" timeout="30"/> </section> - <section name="StoreFrontCustomerCustomAttributesSection"> + <section name="StoreFrontCustomerAdvancedAttributesSection"> <element name="textFieldAttribute" type="input" selector="//input[@id='{{var}}']" parameterized="true" /> <element name="textAreaAttribute" type="input" selector="//textarea[@id='{{var}}']" parameterized="true" /> <element name="multiLineFirstAttribute" type="input" selector="//input[@id='{{var}}_0']" parameterized="true" /> From d3d06f17e679f96a094061fd807edbe407515d51 Mon Sep 17 00:00:00 2001 From: David Grigoryan <david_grigoryan@epam.com> Date: Thu, 13 Dec 2018 15:34:53 +0400 Subject: [PATCH 050/121] MAGETWO-96411: [2.3.x] Default addresses not selected when checking out from cart - Add automated test --- .../AdminCustomerShopingCartActionGroup.xml | 27 ++++ .../AdminCustomerMainActionsSection.xml | 1 + .../AdminCustomerShoppingCartSection.xml | 23 ++++ .../AdminOrderFormShippingAddressSection.xml | 1 + ...DifferentBillingAndShippingAddressTest.xml | 124 ++++++++++++++++++ 5 files changed, 176 insertions(+) create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminCustomerShopingCartActionGroup.xml create mode 100644 app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerShoppingCartSection.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/Test/AdminDifferentBillingAndShippingAddressTest.xml diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminCustomerShopingCartActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminCustomerShopingCartActionGroup.xml new file mode 100644 index 0000000000000..f5d5682e374f2 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminCustomerShopingCartActionGroup.xml @@ -0,0 +1,27 @@ +<?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="AdminAddProductToShoppingCartActionGroup"> + <arguments> + <argument name="productName" type="string"/> + </arguments> + <waitForElementVisible selector="{{AdminCustomerShoppingCartProductItemSection.productItem}}" stepKey="waitForElementVisible"/> + <click selector="{{AdminCustomerShoppingCartProductItemSection.productItem}}" stepKey="expandProductItem"/> + <waitForElementVisible selector="{{AdminCustomerShoppingCartProductItemSection.productNameFilter}}" stepKey="waitForProductFilterFieldVisible"/> + <fillField selector="{{AdminCustomerShoppingCartProductItemSection.productNameFilter}}" stepKey="setProductName" userInput="{{productName}}"/> + <click selector="{{AdminCustomerShoppingCartProductItemSection.searchButton}}" stepKey="clickSearchButton"/> + <waitForAjaxLoad stepKey="waitForAjax"/> + <waitForElementVisible selector="{{AdminCustomerShoppingCartProductItemSection.firstProductCheckbox}}" stepKey="waitForElementCheckboxVisible"/> + <click selector="{{AdminCustomerShoppingCartProductItemSection.firstProductCheckbox}}" stepKey="selectFirstCheckbox"/> + <click selector="{{AdminCustomerShoppingCartProductItemSection.addSelectionsToMyCartButton}}" stepKey="clickAddSelectionsToMyCartButton" after="selectFirstCheckbox"/> + <waitForAjaxLoad stepKey="waitForAjax2"/> + <seeElement stepKey="seeAddedProduct" selector="{{AdminCustomerShoppingCartProductItemSection.addedProductName('productName')}}"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerMainActionsSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerMainActionsSection.xml index 3ff880c64e6d6..0a56763b66704 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerMainActionsSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerMainActionsSection.xml @@ -11,5 +11,6 @@ <section name="AdminCustomerMainActionsSection"> <element name="saveButton" type="button" selector="#save" timeout="30"/> <element name="resetPassword" type="button" selector="#resetPassword" timeout="30"/> + <element name="manageShoppingCart" type="button" selector="#manage_quote" timeout="30"/> </section> </sections> diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerShoppingCartSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerShoppingCartSection.xml new file mode 100644 index 0000000000000..c4a4d650c1e59 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerShoppingCartSection.xml @@ -0,0 +1,23 @@ +<?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="AdminCustomerShoppingCartSection"> + <element name="createOrderButton" type="button" selector="button[title='Create Order']"/> + </section> + + <section name="AdminCustomerShoppingCartProductItemSection"> + <element name="productItem" type="button" selector="#dt-products"/> + <element name="productNameFilter" type="input" selector="#source_products_filter_name"/> + <element name="searchButton" type="button" selector="//*[@id='anchor-content']//button[@title='Search']"/> + <element name="firstProductCheckbox" type="checkbox" selector="//*[@id='source_products_table']/tbody/tr[1]//*[@name='source_products']"/> + <element name="addSelectionsToMyCartButton" type="button" selector="//*[@id='products_search']/div[1]//*[text()='Add selections to my cart']"/> + <element name="addedProductName" type="text" selector="//*[@id='order-items_grid']//*[text()='{{var}}']" parameterized="true"/> + </section> +</sections> diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormShippingAddressSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormShippingAddressSection.xml index b79d933268769..0f1461b121e15 100644 --- a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormShippingAddressSection.xml +++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormShippingAddressSection.xml @@ -10,6 +10,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminOrderFormShippingAddressSection"> <element name="SameAsBilling" type="checkbox" selector="#order-shipping_same_as_billing"/> + <element name="SelectFromExistingCustomerAddress" type="select" selector="#order-shipping_address_customer_address_id"/> <element name="NamePrefix" type="input" selector="#order-shipping_address_prefix"/> <element name="FirstName" type="input" selector="#order-shipping_address_firstname"/> <element name="MiddleName" type="input" selector="#order-shipping_address_middlename"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminDifferentBillingAndShippingAddressTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminDifferentBillingAndShippingAddressTest.xml new file mode 100644 index 0000000000000..37ab0302e6fd2 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminDifferentBillingAndShippingAddressTest.xml @@ -0,0 +1,124 @@ +<?xml version="1.0"?> +<!-- +/** + * 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="AdminDifferentBillingAndShippingAddressTest"> + <annotations> + <features value="Sales"/> + <title value="Check that Billing and Shipping addresses pre-selected for customer with existing order in the cart"/> + <description value="Check Billing Address and Shipping Address"/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-96725"/> + <useCaseId value="MAGETWO-96411"/> + <group value="sales"/> + </annotations> + <before> + <createData entity="SimpleSubCategory" stepKey="createCategory"/> + <createData entity="SimpleProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <!--Clear customer page filter--> + <amOnPage url="{{AdminCustomerPage.url}}" stepKey="navigateToCustomers"/> + <waitForPageLoad stepKey="waitForCustomerPageLoad"/> + <actionGroup ref="clearFiltersAdminDataGrid" stepKey="clearGridFilter"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <actionGroup ref="OpenEditCustomerFromAdminActionGroup" stepKey="openCustomerEditPage"> + <argument name="customer" value="$$createCustomer$$" /> + </actionGroup> + <click stepKey="goToAddresses" selector="{{NewCustomerPageSection.addresses}}"/> + <waitForAjaxLoad stepKey="waitForAddresses" time="5"/> + <!--Uncheck Default Shipping Address checkbox--> + <click stepKey="thickShippingAddress" selector="{{NewCustomerPageSection.defaultShippingAddress}}"/> + <waitForElementVisible selector="{{AdminCustomerMainActionsSection.saveButton}}" stepKey="waitForElement"/> + <click selector="{{AdminCustomerMainActionsSection.saveButton}}" stepKey="clickSave"/> + <conditionalClick selector="{{AdminCustomerMainActionsSection.saveButton}}" + dependentSelector="{{AdminCustomerMainActionsSection.saveButton}}" visible="true" stepKey="clickSave2"/> + <waitForElement selector="{{AdminCustomerMessagesSection.successMessage}}" stepKey="waitSuccessMessage"/> + + <!--Create new order with existing customer--> + <actionGroup ref="navigateToNewOrderPageExistingCustomer" stepKey="goToCreateOrderPage"> + <argument name="customer" value="$$createCustomer$$"/> + </actionGroup> + <!--Add product to order--> + <actionGroup ref="addSimpleProductToOrder" stepKey="addProductToOrder"> + <argument name="product" value="$$createProduct$$"/> + </actionGroup> + + <!--Uncheck Same As Billing Address Checkbox--> + <click selector="{{AdminOrderFormShippingAddressSection.SameAsBilling}}" stepKey="uncheckSameAsBillingAddressCheckbox"/> + <waitForAjaxLoad stepKey="waitForAjax" after="uncheckSameAsBillingAddressCheckbox"/> + <selectOption selector="{{AdminOrderFormShippingAddressSection.SelectFromExistingCustomerAddress}}" + stepKey="selectAddNewCustomer" userInput="Add New Address" after="waitForAjax"/> + <waitForAjaxLoad stepKey="waitForAjaxLoad" after="selectAddNewCustomer"/> + + <!--Fill customer Shipping address information--> + <fillField selector="{{AdminOrderFormShippingAddressSection.FirstName}}" userInput="{{UK_Not_Default_Address.firstname}}" stepKey="fillFirstName"/> + <fillField selector="{{AdminOrderFormShippingAddressSection.LastName}}" userInput="{{UK_Not_Default_Address.lastname}}" stepKey="fillLastName" after="fillFirstName"/> + <fillField selector="{{AdminOrderFormShippingAddressSection.StreetLine1}}" userInput="{{UK_Not_Default_Address.street[0]}}" stepKey="fillStreetLine1" after="fillLastName"/> + <fillField selector="{{AdminOrderFormShippingAddressSection.City}}" userInput="{{UK_Not_Default_Address.city}}" stepKey="fillCity" after="fillStreetLine1"/> + <selectOption selector="{{AdminOrderFormShippingAddressSection.Country}}" userInput="United Kingdom" stepKey="fillCountry" after="fillCity"/> + <fillField selector="{{AdminOrderFormShippingAddressSection.Province}}" userInput="London" stepKey="fillProvince" after="fillCountry"/> + <fillField selector="{{AdminOrderFormShippingAddressSection.PostalCode}}" userInput="{{UK_Not_Default_Address.postcode}}" stepKey="fillPostalCode" after="fillProvince"/> + <fillField selector="{{AdminOrderFormShippingAddressSection.Phone}}" userInput="{{UK_Not_Default_Address.telephone}}" stepKey="fillPhoneNumber" after="fillPostalCode"/> + + <click stepKey="checkSaveBillingAddressCheckbox" selector="{{AdminOrderFormBillingAddressSection.SaveAddress}}" after="fillPhoneNumber"/> + <click stepKey="checkSaveShippingAddressCheckbox" selector="{{AdminOrderFormShippingAddressSection.SaveAddress}}" after="checkSaveBillingAddressCheckbox"/> + + <!-- Select shipping --> + <actionGroup ref="orderSelectFlatRateShipping" stepKey="selectFlatRateShipping" after="checkSaveShippingAddressCheckbox"/> + + <!--Submit Order and verify that Order created successfully--> + <click selector="{{AdminOrderFormActionSection.SubmitOrder}}" stepKey="clickSubmitOrder"/> + <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear"/> + <waitForPageLoad stepKey="waitForOrderToProcess"/> + <seeElement selector="{{AdminMessagesSection.successMessage}}" stepKey="seeSuccessMessage"/> + + <!--Open customer for edit--> + <actionGroup ref="OpenEditCustomerFromAdminActionGroup" stepKey="openCustomerEdit"> + <argument name="customer" value="$$createCustomer$$" /> + </actionGroup> + + <!--Click on *Manage Shopping Cart*--> + <click selector="{{AdminCustomerMainActionsSection.manageShoppingCart}}" stepKey="clickManageShoppingCartButton"/> + <waitForPageLoad stepKey="waitForPageLoaded"/> + + <!--Add Product To Shopping Cart--> + <actionGroup ref="AdminAddProductToShoppingCartActionGroup" stepKey="addProductToShoppingCart"> + <argument name="productName" value="$$createProduct.name$$" /> + </actionGroup> + + <!--Click on *Create Order*--> + <waitForElementVisible selector="{{AdminCustomerShoppingCartSection.createOrderButton}}" stepKey="waitToShoppingCartPageOpened"/> + <click selector="{{AdminCustomerShoppingCartSection.createOrderButton}}" stepKey="clickCreateOrderButton"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + + <!--Check Billing Address and Shipping Address should be pre-selected/fill out--> + <waitForElementVisible stepKey="waitElementsBecomeVisible" selector="{{AdminOrderFormShippingAddressSection.FirstName}}"/> + <scrollTo selector="{{AdminOrderFormShippingAddressSection.FirstName}}" stepKey="scrollToMiddleOfPage"/> + <grabValueFrom selector="{{AdminOrderFormShippingAddressSection.FirstName}}" stepKey="grabTextShippingFirstNameValue"/> + <grabValueFrom selector="{{AdminOrderFormShippingAddressSection.LastName}}" stepKey="grabTextShippingLastNameValue"/> + <grabValueFrom selector="{{AdminOrderFormShippingAddressSection.StreetLine1}}" stepKey="grabShippingStreetLineValue"/> + <grabValueFrom selector="{{AdminOrderFormShippingAddressSection.City}}" stepKey="grabShippingCityValue"/> + <grabValueFrom selector="{{AdminOrderFormBillingAddressSection.Country}}" stepKey="grabBillingCountryValue"/> + + <assertNotEmpty actual="$grabTextShippingFirstNameValue" stepKey="assertTextShippingFirstNameIsNotEmpty" after="grabTextShippingFirstNameValue"/> + <assertNotEmpty actual="$grabTextShippingLastNameValue" stepKey="assertTextShippingLastNameIsNotEmpty" after="grabTextShippingLastNameValue"/> + <assertNotEmpty actual="$grabShippingStreetLineValue" stepKey="assertShippingStreetLineIsNotEmpty" after="grabShippingStreetLineValue"/> + <assertNotEmpty actual="$grabShippingCityValue" stepKey="assertShippingCityIsNotEmpty" after="grabShippingCityValue"/> + <assertNotEmpty actual="$grabBillingCountryValue" stepKey="assertBillingCountryIsNotEmpty" after="grabBillingCountryValue"/> + </test> +</tests> From 8131d75032e66004c123b02e23786f2729748b22 Mon Sep 17 00:00:00 2001 From: Sona Sargsyan <sona_sargsyan@epam.com> Date: Thu, 13 Dec 2018 17:28:15 +0400 Subject: [PATCH 051/121] MAGETWO-66872: Customer Address Attribute not being marked as required when the "Values Required" setting is overriden on Website scope - Added fix for b2b --- .../ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml index 9d918990c8172..8eaf5a1f1d284 100644 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml @@ -28,8 +28,8 @@ <fillField stepKey="fillVAT" userInput="{{customerAddress.vat_id}}" selector="{{AdminEditCustomerAddressesSection.vat}}"/> <click selector="{{CustomerAccountSection.save}}" stepKey="saveAddress"/> <waitForPageLoad stepKey="waitForStorefrontPage"/> - <click selector="{{CustomerAccountSection.save}}" stepKey="saveCustomer"/> + <conditionalClick selector="{{CustomerAccountSection.save}}" dependentSelector="{{CustomerAccountSection.save}}" visible="true" stepKey="clickSaveAgain"/> <waitForPageLoad stepKey="waitForCustomerSaved"/> <see stepKey="seeSaveMessage" userInput="You saved the customer."/> </actionGroup> -</actionGroups> \ No newline at end of file +</actionGroups> From b029e34e661b0740d52caf7afa65e2af911f7b1a Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <veronika_kurochkina@epam.com> Date: Tue, 18 Dec 2018 16:24:48 +0300 Subject: [PATCH 052/121] MAGETWO-94556: Undefined variables during product save - Update automated test --- .../Mftf/Section/AdminChooseAffectedAttributeSetSection.xml | 1 + .../Test/Mftf/Test/AdminConfigurableProductCreateTest.xml | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminChooseAffectedAttributeSetSection.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminChooseAffectedAttributeSetSection.xml index 4289638352990..fb83251ab287d 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminChooseAffectedAttributeSetSection.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminChooseAffectedAttributeSetSection.xml @@ -10,5 +10,6 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminChooseAffectedAttributeSetPopup"> <element name="confirm" type="button" selector="button[data-index='confirm_button']" timeout="30"/> + <element name="close" type="button" selector="//button[@data-index='confirm_button']/ancestor::div[@class='modal-inner-wrap']//button[@data-role='closeBtn']" timeout="30" /> </section> </sections> \ No newline at end of file diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml index bba352b16cc8a..a3da630fa2dfb 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductCreateTest.xml @@ -113,11 +113,11 @@ <grabValueFrom selector="{{AdminProductFormConfigurationsSection.firstSKUInConfigurableProductsGrid}}" stepKey="grabTextFromContent"/> <fillField stepKey="fillMoreThan64Symbols" selector="{{AdminProductFormConfigurationsSection.firstSKUInConfigurableProductsGrid}}" userInput="01234567890123456789012345678901234567890123456789012345678901234"/> <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct1"/> - <conditionalClick selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" dependentSelector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" visible="true" stepKey="clickOnConfirmInPopup1"/> + <conditionalClick selector="{{AdminChooseAffectedAttributeSetPopup.close}}" dependentSelector="{{AdminChooseAffectedAttributeSetPopup.close}}" visible="true" stepKey="clickOnCloseInPopup"/> <see stepKey="seeErrorMessage" userInput="Please enter less or equal than 64 symbols."/> <fillField stepKey="fillCorrectSKU" selector="{{AdminProductFormConfigurationsSection.firstSKUInConfigurableProductsGrid}}" userInput="$grabTextFromContent"/> <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct2"/> - <conditionalClick selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" dependentSelector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" visible="true" stepKey="clickOnConfirmInPopup2"/> + <conditionalClick selector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" dependentSelector="{{AdminChooseAffectedAttributeSetPopup.confirm}}" visible="true" stepKey="clickOnConfirmInPopup"/> <see userInput="You saved the product." stepKey="seeSaveConfirmation"/> <amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="goToProductAttributes"/> <waitForPageLoad stepKey="waitForProductAttributes"/> From c4f9b60e5c255a540a391d8e00bd07fc54e53e78 Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <veronika_kurochkina@epam.com> Date: Wed, 19 Dec 2018 12:40:26 +0300 Subject: [PATCH 053/121] MAGETWO-94556: Undefined variables during product save - Update automated test --- .../Catalog/Test/Mftf/Section/AdminProductGridFilterSection.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridFilterSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridFilterSection.xml index 2e4b9c6cb0430..611f12a39b510 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridFilterSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridFilterSection.xml @@ -9,7 +9,7 @@ <sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminProductGridFilterSection"> - <element name="filters" type="button" selector="//button[text()='Filters']"/> + <element name="filters" type="button" selector="button[data-action='grid-filter-expand']"/> <element name="clearAll" type="button" selector=".admin__data-grid-header .admin__data-grid-filters-current._show .action-clear" timeout="30"/> <element name="enabledFilters" type="textarea" selector=".admin__data-grid-header .admin__data-grid-filters-current._show"/> <element name="basicSearchFilter" type="textarea" selector=".admin__control-text.data-grid-search-control"/> From 5000d937ecd2e9399f268c481e7b7412d3e7db0b Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <veronika_kurochkina@epam.com> Date: Thu, 20 Dec 2018 17:03:00 +0300 Subject: [PATCH 054/121] MAGETWO-66872: Customer Address Attribute not being marked as required when the "Values Required" setting is overriden on Website scope - Update automation test --- ...tCustomerAddressesFromAdminActionGroup.xml | 12 +++---- .../AdminEditCustomerAddressesSection.xml | 33 ++++++++++--------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml index 8eaf5a1f1d284..617c895bc1201 100644 --- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/EditCustomerAddressesFromAdminActionGroup.xml @@ -12,11 +12,10 @@ <argument name="customerAddress"/> </arguments> <click selector="{{AdminEditCustomerAddressesSection.addresses}}" stepKey="proceedToAddresses"/> - <click selector="{{AdminEditCustomerAddressesSection.addNewAddresses}}" stepKey="addNewAddresses"/> + <click selector="{{AdminEditCustomerAddressesSection.addNewAddress}}" stepKey="addNewAddresses"/> + <waitForPageLoad time="60" stepKey="wait5678" /> <fillField stepKey="fillPrefixName" userInput="{{customerAddress.prefix}}" selector="{{AdminEditCustomerAddressesSection.prefixName}}"/> - <fillField stepKey="fillFirstName" userInput="{{customerAddress.firstname}}" selector="{{AdminEditCustomerAddressesSection.firstName}}"/> <fillField stepKey="fillMiddleName" userInput="{{customerAddress.middlename}}" selector="{{AdminEditCustomerAddressesSection.middleName}}"/> - <fillField stepKey="fillLastName" userInput="{{customerAddress.lastname}}" selector="{{AdminEditCustomerAddressesSection.lastName}}"/> <fillField stepKey="fillSuffixName" userInput="{{customerAddress.suffix}}" selector="{{AdminEditCustomerAddressesSection.suffixName}}"/> <fillField stepKey="fillCompany" userInput="{{customerAddress.company}}" selector="{{AdminEditCustomerAddressesSection.company}}"/> <fillField stepKey="fillStreetAddress" userInput="{{customerAddress.street}}" selector="{{AdminEditCustomerAddressesSection.streetAddress}}"/> @@ -26,10 +25,7 @@ <fillField stepKey="fillZipCode" userInput="{{customerAddress.postcode}}" selector="{{AdminEditCustomerAddressesSection.zipCode}}"/> <fillField stepKey="fillPhone" userInput="{{customerAddress.telephone}}" selector="{{AdminEditCustomerAddressesSection.phone}}"/> <fillField stepKey="fillVAT" userInput="{{customerAddress.vat_id}}" selector="{{AdminEditCustomerAddressesSection.vat}}"/> - <click selector="{{CustomerAccountSection.save}}" stepKey="saveAddress"/> - <waitForPageLoad stepKey="waitForStorefrontPage"/> - <conditionalClick selector="{{CustomerAccountSection.save}}" dependentSelector="{{CustomerAccountSection.save}}" visible="true" stepKey="clickSaveAgain"/> - <waitForPageLoad stepKey="waitForCustomerSaved"/> - <see stepKey="seeSaveMessage" userInput="You saved the customer."/> + <click selector="{{AdminEditCustomerAddressesSection.save}}" stepKey="saveAddress"/> + <waitForPageLoad stepKey="waitForAddressSaved"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminEditCustomerAddressesSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminEditCustomerAddressesSection.xml index 0718800c871a7..04d6c4dc2a09d 100644 --- a/app/code/Magento/Customer/Test/Mftf/Section/AdminEditCustomerAddressesSection.xml +++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminEditCustomerAddressesSection.xml @@ -10,22 +10,23 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> <section name="AdminEditCustomerAddressesSection"> <element name="addresses" type="button" selector="//span[text()='Addresses']" timeout="30"/> - <element name="addNewAddresses" type="button" selector="//span[text()='Add New Addresses']"/> - <element name="defaultBillingAddress" type="text" selector="input[name='address[new_0][default_billing]']"/> - <element name="defaultShippingAddress" type="text" selector="input[name='address[new_0][default_shipping]']"/> - <element name="prefixName" type="text" selector="input[name='address[new_0][prefix]']"/> - <element name="firstName" type="text" selector="input[name='address[new_0][firstname]']" /> - <element name="middleName" type="text" selector="input[name='address[new_0][middlename]']" /> - <element name="lastName" type="text" selector="input[name='address[new_0][lastname]']" /> - <element name="suffixName" type="text" selector="input[name='address[new_0][suffix]']" /> - <element name="company" type="text" selector="input[name='address[new_0][company]']" /> - <element name="streetAddress" type="text" selector="input[name='address[new_0][street][0]']" /> - <element name="city" type="text" selector="input[name='address[new_0][city]']" /> - <element name="country" type="select" selector="select[name='address[new_0][country_id]']" /> - <element name="state" type="select" selector="select[name='address[new_0][region_id]']" /> - <element name="zipCode" type="text" selector="input[name='address[new_0][postcode]']" /> - <element name="phone" type="text" selector="input[name='address[new_0][telephone]']" /> - <element name="vat" type="text" selector="input[name='address[new_0][vat_id]']" /> + <element name="addNewAddress" type="button" selector="//span[text()='Add New Address']"/> + <element name="defaultBillingAddress" type="text" selector="input[name='default_billing']"/> + <element name="defaultShippingAddress" type="text" selector="input[name='default_shipping']"/> + <element name="prefixName" type="text" selector="input[name='prefix']"/> + <element name="firstName" type="text" selector="input[name='firstname']" /> + <element name="middleName" type="text" selector="input[name='middlename']" /> + <element name="lastName" type="text" selector="input[name='lastname']" /> + <element name="suffixName" type="text" selector="input[name='suffix']" /> + <element name="company" type="text" selector="input[name='company']" /> + <element name="streetAddress" type="text" selector="input[name='street[0]']" /> + <element name="city" type="text" selector="//*[@class='modal-component']//input[@name='city']" /> + <element name="country" type="select" selector="//*[@class='modal-component']//select[@name='country_id']" /> + <element name="state" type="select" selector="//*[@class='modal-component']//select[@name='region_id']" /> + <element name="zipCode" type="text" selector="//*[@class='modal-component']//input[@name='postcode']" /> + <element name="phone" type="text" selector="//*[@class='modal-component']//input[@name='telephone']" /> + <element name="vat" type="text" selector="input[name='vat_id']" /> + <element name="save" type="button" selector="//button[@title='Save']" /> </section> </sections> From 3998176c0995dbb912977719039fdac956c8a43c Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky <p.bystritsky@yandex.ru> Date: Thu, 20 Dec 2018 16:09:29 +0200 Subject: [PATCH 055/121] ENGCOM-3491: Static test fix. --- app/code/Magento/Sales/Model/Order/Config.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Model/Order/Config.php b/app/code/Magento/Sales/Model/Order/Config.php index 8999fca174de9..70cf8c181cf95 100644 --- a/app/code/Magento/Sales/Model/Order/Config.php +++ b/app/code/Magento/Sales/Model/Order/Config.php @@ -75,6 +75,8 @@ public function __construct( } /** + * Get collection. + * * @return \Magento\Sales\Model\ResourceModel\Order\Status\Collection */ protected function _getCollection() @@ -86,6 +88,8 @@ protected function _getCollection() } /** + * Get state. + * * @param string $state * @return Status */ @@ -275,8 +279,9 @@ public function getInvisibleOnFrontStatuses() } /** - * Get existing order statuses - * Visible or invisible on frontend according to passed param + * Get existing order statuses. + * + * Visible or invisible on frontend according to passed param. * * @param bool $visibility * @return array From 54561ba1a13d0a0ed60e4d2fb3974b558d901f2b Mon Sep 17 00:00:00 2001 From: Lusine Papyan <Lusine_Papyan@epam.com> Date: Fri, 21 Dec 2018 10:55:23 +0400 Subject: [PATCH 056/121] MAGETWO-96849: [2.3.x] Money are refunded to gift card during partial refund when it's not required - Add automated test script --- .../Sales/Test/Mftf/Section/AdminCreditMemoTotalSection.xml | 1 + .../Test/Mftf/Section/AdminOrderDetailsMainActionsSection.xml | 1 + 2 files changed, 2 insertions(+) diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminCreditMemoTotalSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminCreditMemoTotalSection.xml index 84fcc8fc47dfb..df1a0064d25a8 100644 --- a/app/code/Magento/Sales/Test/Mftf/Section/AdminCreditMemoTotalSection.xml +++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminCreditMemoTotalSection.xml @@ -21,5 +21,6 @@ <element name="submitRefundOffline" type="button" selector=".order-totals-actions button[data-ui-id='order-items-submit-button']" timeout="30"/> <element name="creditMemoItem" type="text" selector="#sales_order_view_tabs_order_creditmemos"/> <element name="viewMemo" type="text" selector="div#sales_order_view_tabs_order_creditmemos_content a.action-menu-item"/> + <element name="refundOffline" type="button" selector=".order-totals-actions button[data-ui-id='order-items-submit-offline']"/> </section> </sections> \ No newline at end of file diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderDetailsMainActionsSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderDetailsMainActionsSection.xml index 578022217f358..6fa5d9a9a3787 100644 --- a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderDetailsMainActionsSection.xml +++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderDetailsMainActionsSection.xml @@ -18,5 +18,6 @@ <element name="ship" type="button" selector="#order_ship" timeout="30"/> <element name="reorder" type="button" selector="#order_reorder" timeout="30"/> <element name="edit" type="button" selector="#order_edit" timeout="30"/> + <element name="modalOk" type="button" selector=".action-accept"/> </section> </sections> From 2bc10a2484462d6554dbc07655b68e56ca4f72f2 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky <p.bystritsky@yandex.ru> Date: Fri, 21 Dec 2018 15:58:15 +0200 Subject: [PATCH 057/121] ENGCOM-3491: WebAPI test fix. --- .../Service/V1/OrderStatusHistoryAddTest.php | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php index c5ecead00ce29..9e3bd4ca48478 100644 --- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/OrderStatusHistoryAddTest.php @@ -11,6 +11,7 @@ /** * Class OrderCommentAddTest + * * @package Magento\Sales\Service\V1 */ class OrderStatusHistoryAddTest extends WebapiAbstract @@ -48,7 +49,7 @@ public function testOrderCommentAdd() OrderStatusHistoryInterface::CREATED_AT => null, OrderStatusHistoryInterface::PARENT_ID => $order->getId(), OrderStatusHistoryInterface::ENTITY_NAME => null, - OrderStatusHistoryInterface::STATUS => null, + OrderStatusHistoryInterface::STATUS => $order->getStatus(), OrderStatusHistoryInterface::IS_VISIBLE_ON_FRONT => 1, ]; @@ -69,25 +70,27 @@ public function testOrderCommentAdd() //Verification $comments = $order->load($order->getId())->getAllStatusHistory(); + $comment = reset($comments); - $commentData = reset($comments); - foreach ($commentData as $key => $value) { - $this->assertEquals( - $commentData[OrderStatusHistoryInterface::COMMENT], - $statusHistoryComment->getComment() - ); - $this->assertEquals( - $commentData[OrderStatusHistoryInterface::PARENT_ID], - $statusHistoryComment->getParentId() - ); - $this->assertEquals( - $commentData[OrderStatusHistoryInterface::IS_CUSTOMER_NOTIFIED], - $statusHistoryComment->getIsCustomerNotified() - ); - $this->assertEquals( - $commentData[OrderStatusHistoryInterface::IS_VISIBLE_ON_FRONT], - $statusHistoryComment->getIsVisibleOnFront() - ); - } + $this->assertEquals( + $commentData[OrderStatusHistoryInterface::COMMENT], + $comment->getComment() + ); + $this->assertEquals( + $commentData[OrderStatusHistoryInterface::PARENT_ID], + $comment->getParentId() + ); + $this->assertEquals( + $commentData[OrderStatusHistoryInterface::IS_CUSTOMER_NOTIFIED], + $comment->getIsCustomerNotified() + ); + $this->assertEquals( + $commentData[OrderStatusHistoryInterface::IS_VISIBLE_ON_FRONT], + $comment->getIsVisibleOnFront() + ); + $this->assertEquals( + $commentData[OrderStatusHistoryInterface::STATUS], + $comment->getStatus() + ); } } From 7c5bea3783ea15d81dc5e3e4e64ab23dd5c3dff9 Mon Sep 17 00:00:00 2001 From: Stepan Furman <furman.stepan@gmail.com> Date: Mon, 24 Dec 2018 15:25:18 +0200 Subject: [PATCH 058/121] GraphQL-248: Test coverage --- .../GraphQl/Customer/CreateCustomerTest.php | 169 +++++++++++++++++- 1 file changed, 168 insertions(+), 1 deletion(-) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerTest.php index 80a24eacb5f2c..7342800379d13 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerTest.php @@ -35,7 +35,7 @@ protected function setUp() /** * @throws \Exception */ - public function testCreateCustomerAccount() + public function testCreateCustomerAccountWithPassword() { $newFirstname = 'Richard'; $newLastname = 'Rowe'; @@ -70,4 +70,171 @@ public function testCreateCustomerAccount() $this->assertEquals($newEmail, $response['createCustomer']['customer']['email']); $this->assertEquals(true, $response['createCustomer']['customer']['is_subscribed']); } + + /** + * @throws \Exception + */ + public function testCreateCustomerAccountWithoutPassword() + { + $newFirstname = 'Richard'; + $newLastname = 'Rowe'; + $newEmail = 'customer_created' . rand(1, 2000000) . '@example.com'; + + $query = <<<QUERY +mutation { + createCustomer( + input: { + firstname: "{$newFirstname}" + lastname: "{$newLastname}" + email: "{$newEmail}" + is_subscribed: true + } + ) { + customer { + id + firstname + lastname + email + is_subscribed + } + } +} +QUERY; + $response = $this->graphQlQuery($query); + + $this->assertEquals($newFirstname, $response['createCustomer']['customer']['firstname']); + $this->assertEquals($newLastname, $response['createCustomer']['customer']['lastname']); + $this->assertEquals($newEmail, $response['createCustomer']['customer']['email']); + $this->assertEquals(true, $response['createCustomer']['customer']['is_subscribed']); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage "input" value should be specified + */ + public function testCreateCustomerIfInputDataIsEmpty() + { + $query = <<<QUERY +mutation { + createCustomer( + input: { + + } + ) { + customer { + id + firstname + lastname + email + is_subscribed + } + } +} +QUERY; + $this->graphQlQuery($query); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage The customer email is missing. Enter and try again. + */ + public function testCreateCustomerIfEmailMissed() + { + $newFirstname = 'Richard'; + $newLastname = 'Rowe'; + $currentPassword = 'test123#'; + + $query = <<<QUERY +mutation { + createCustomer( + input: { + firstname: "{$newFirstname}" + lastname: "{$newLastname}" + password: "{$currentPassword}" + is_subscribed: true + } + ) { + customer { + id + firstname + lastname + email + is_subscribed + } + } +} +QUERY; + $this->graphQlQuery($query); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage "Email" is not a valid email address. + */ + public function testCreateCustomerIfEmailIsNotValid() + { + $newFirstname = 'Richard'; + $newLastname = 'Rowe'; + $currentPassword = 'test123#'; + $newEmail = 'email'; + + $query = <<<QUERY +mutation { + createCustomer( + input: { + firstname: "{$newFirstname}" + lastname: "{$newLastname}" + email: "{$newEmail}" + password: "{$currentPassword}" + is_subscribed: true + } + ) { + customer { + id + firstname + lastname + email + is_subscribed + } + } +} +QUERY; + $this->graphQlQuery($query); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessage Field "test123" is not defined by type CustomerInput. + */ + public function testCreateCustomerIfPassedAttributeDosNotExistsInCustomerInput() + { + $newFirstname = 'Richard'; + $newLastname = 'Rowe'; + $currentPassword = 'test123#'; + $newEmail = 'customer_created' . rand(1, 2000000) . '@example.com'; + + $query = <<<QUERY +mutation { + createCustomer( + input: { + firstname: "{$newFirstname}" + lastname: "{$newLastname}" + test123: "123test123" + email: "{$newEmail}" + password: "{$currentPassword}" + is_subscribed: true + } + ) { + customer { + id + firstname + lastname + email + is_subscribed + } + } +} +QUERY; + $this->graphQlQuery($query); + } } From 7329633242e8ffc523f36a5721a01c4486d42069 Mon Sep 17 00:00:00 2001 From: David Grigoryan <david_grigoryan@epam.com> Date: Thu, 27 Dec 2018 17:45:01 +0400 Subject: [PATCH 059/121] MAGETWO-96411: [2.3.x] Default addresses not selected when checking out from cart - Add automated test --- ...DifferentBillingAndShippingAddressTest.xml | 124 ------------------ 1 file changed, 124 deletions(-) delete mode 100644 app/code/Magento/Sales/Test/Mftf/Test/AdminDifferentBillingAndShippingAddressTest.xml diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminDifferentBillingAndShippingAddressTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminDifferentBillingAndShippingAddressTest.xml deleted file mode 100644 index 37ab0302e6fd2..0000000000000 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminDifferentBillingAndShippingAddressTest.xml +++ /dev/null @@ -1,124 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * 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="AdminDifferentBillingAndShippingAddressTest"> - <annotations> - <features value="Sales"/> - <title value="Check that Billing and Shipping addresses pre-selected for customer with existing order in the cart"/> - <description value="Check Billing Address and Shipping Address"/> - <severity value="MAJOR"/> - <testCaseId value="MAGETWO-96725"/> - <useCaseId value="MAGETWO-96411"/> - <group value="sales"/> - </annotations> - <before> - <createData entity="SimpleSubCategory" stepKey="createCategory"/> - <createData entity="SimpleProduct" stepKey="createProduct"> - <requiredEntity createDataKey="createCategory"/> - </createData> - <createData entity="Simple_US_Customer" stepKey="createCustomer"/> - <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> - </before> - <after> - <!--Clear customer page filter--> - <amOnPage url="{{AdminCustomerPage.url}}" stepKey="navigateToCustomers"/> - <waitForPageLoad stepKey="waitForCustomerPageLoad"/> - <actionGroup ref="clearFiltersAdminDataGrid" stepKey="clearGridFilter"/> - <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> - <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> - <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> - <actionGroup ref="logout" stepKey="logout"/> - </after> - - <actionGroup ref="OpenEditCustomerFromAdminActionGroup" stepKey="openCustomerEditPage"> - <argument name="customer" value="$$createCustomer$$" /> - </actionGroup> - <click stepKey="goToAddresses" selector="{{NewCustomerPageSection.addresses}}"/> - <waitForAjaxLoad stepKey="waitForAddresses" time="5"/> - <!--Uncheck Default Shipping Address checkbox--> - <click stepKey="thickShippingAddress" selector="{{NewCustomerPageSection.defaultShippingAddress}}"/> - <waitForElementVisible selector="{{AdminCustomerMainActionsSection.saveButton}}" stepKey="waitForElement"/> - <click selector="{{AdminCustomerMainActionsSection.saveButton}}" stepKey="clickSave"/> - <conditionalClick selector="{{AdminCustomerMainActionsSection.saveButton}}" - dependentSelector="{{AdminCustomerMainActionsSection.saveButton}}" visible="true" stepKey="clickSave2"/> - <waitForElement selector="{{AdminCustomerMessagesSection.successMessage}}" stepKey="waitSuccessMessage"/> - - <!--Create new order with existing customer--> - <actionGroup ref="navigateToNewOrderPageExistingCustomer" stepKey="goToCreateOrderPage"> - <argument name="customer" value="$$createCustomer$$"/> - </actionGroup> - <!--Add product to order--> - <actionGroup ref="addSimpleProductToOrder" stepKey="addProductToOrder"> - <argument name="product" value="$$createProduct$$"/> - </actionGroup> - - <!--Uncheck Same As Billing Address Checkbox--> - <click selector="{{AdminOrderFormShippingAddressSection.SameAsBilling}}" stepKey="uncheckSameAsBillingAddressCheckbox"/> - <waitForAjaxLoad stepKey="waitForAjax" after="uncheckSameAsBillingAddressCheckbox"/> - <selectOption selector="{{AdminOrderFormShippingAddressSection.SelectFromExistingCustomerAddress}}" - stepKey="selectAddNewCustomer" userInput="Add New Address" after="waitForAjax"/> - <waitForAjaxLoad stepKey="waitForAjaxLoad" after="selectAddNewCustomer"/> - - <!--Fill customer Shipping address information--> - <fillField selector="{{AdminOrderFormShippingAddressSection.FirstName}}" userInput="{{UK_Not_Default_Address.firstname}}" stepKey="fillFirstName"/> - <fillField selector="{{AdminOrderFormShippingAddressSection.LastName}}" userInput="{{UK_Not_Default_Address.lastname}}" stepKey="fillLastName" after="fillFirstName"/> - <fillField selector="{{AdminOrderFormShippingAddressSection.StreetLine1}}" userInput="{{UK_Not_Default_Address.street[0]}}" stepKey="fillStreetLine1" after="fillLastName"/> - <fillField selector="{{AdminOrderFormShippingAddressSection.City}}" userInput="{{UK_Not_Default_Address.city}}" stepKey="fillCity" after="fillStreetLine1"/> - <selectOption selector="{{AdminOrderFormShippingAddressSection.Country}}" userInput="United Kingdom" stepKey="fillCountry" after="fillCity"/> - <fillField selector="{{AdminOrderFormShippingAddressSection.Province}}" userInput="London" stepKey="fillProvince" after="fillCountry"/> - <fillField selector="{{AdminOrderFormShippingAddressSection.PostalCode}}" userInput="{{UK_Not_Default_Address.postcode}}" stepKey="fillPostalCode" after="fillProvince"/> - <fillField selector="{{AdminOrderFormShippingAddressSection.Phone}}" userInput="{{UK_Not_Default_Address.telephone}}" stepKey="fillPhoneNumber" after="fillPostalCode"/> - - <click stepKey="checkSaveBillingAddressCheckbox" selector="{{AdminOrderFormBillingAddressSection.SaveAddress}}" after="fillPhoneNumber"/> - <click stepKey="checkSaveShippingAddressCheckbox" selector="{{AdminOrderFormShippingAddressSection.SaveAddress}}" after="checkSaveBillingAddressCheckbox"/> - - <!-- Select shipping --> - <actionGroup ref="orderSelectFlatRateShipping" stepKey="selectFlatRateShipping" after="checkSaveShippingAddressCheckbox"/> - - <!--Submit Order and verify that Order created successfully--> - <click selector="{{AdminOrderFormActionSection.SubmitOrder}}" stepKey="clickSubmitOrder"/> - <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear"/> - <waitForPageLoad stepKey="waitForOrderToProcess"/> - <seeElement selector="{{AdminMessagesSection.successMessage}}" stepKey="seeSuccessMessage"/> - - <!--Open customer for edit--> - <actionGroup ref="OpenEditCustomerFromAdminActionGroup" stepKey="openCustomerEdit"> - <argument name="customer" value="$$createCustomer$$" /> - </actionGroup> - - <!--Click on *Manage Shopping Cart*--> - <click selector="{{AdminCustomerMainActionsSection.manageShoppingCart}}" stepKey="clickManageShoppingCartButton"/> - <waitForPageLoad stepKey="waitForPageLoaded"/> - - <!--Add Product To Shopping Cart--> - <actionGroup ref="AdminAddProductToShoppingCartActionGroup" stepKey="addProductToShoppingCart"> - <argument name="productName" value="$$createProduct.name$$" /> - </actionGroup> - - <!--Click on *Create Order*--> - <waitForElementVisible selector="{{AdminCustomerShoppingCartSection.createOrderButton}}" stepKey="waitToShoppingCartPageOpened"/> - <click selector="{{AdminCustomerShoppingCartSection.createOrderButton}}" stepKey="clickCreateOrderButton"/> - <waitForPageLoad stepKey="waitForPageLoad"/> - - <!--Check Billing Address and Shipping Address should be pre-selected/fill out--> - <waitForElementVisible stepKey="waitElementsBecomeVisible" selector="{{AdminOrderFormShippingAddressSection.FirstName}}"/> - <scrollTo selector="{{AdminOrderFormShippingAddressSection.FirstName}}" stepKey="scrollToMiddleOfPage"/> - <grabValueFrom selector="{{AdminOrderFormShippingAddressSection.FirstName}}" stepKey="grabTextShippingFirstNameValue"/> - <grabValueFrom selector="{{AdminOrderFormShippingAddressSection.LastName}}" stepKey="grabTextShippingLastNameValue"/> - <grabValueFrom selector="{{AdminOrderFormShippingAddressSection.StreetLine1}}" stepKey="grabShippingStreetLineValue"/> - <grabValueFrom selector="{{AdminOrderFormShippingAddressSection.City}}" stepKey="grabShippingCityValue"/> - <grabValueFrom selector="{{AdminOrderFormBillingAddressSection.Country}}" stepKey="grabBillingCountryValue"/> - - <assertNotEmpty actual="$grabTextShippingFirstNameValue" stepKey="assertTextShippingFirstNameIsNotEmpty" after="grabTextShippingFirstNameValue"/> - <assertNotEmpty actual="$grabTextShippingLastNameValue" stepKey="assertTextShippingLastNameIsNotEmpty" after="grabTextShippingLastNameValue"/> - <assertNotEmpty actual="$grabShippingStreetLineValue" stepKey="assertShippingStreetLineIsNotEmpty" after="grabShippingStreetLineValue"/> - <assertNotEmpty actual="$grabShippingCityValue" stepKey="assertShippingCityIsNotEmpty" after="grabShippingCityValue"/> - <assertNotEmpty actual="$grabBillingCountryValue" stepKey="assertBillingCountryIsNotEmpty" after="grabBillingCountryValue"/> - </test> -</tests> From f7f56fc819f1b7fc33370e66cf613c35c2044c48 Mon Sep 17 00:00:00 2001 From: Andrii Meysar <andrii.meysar@transoftgroup.com> Date: Thu, 3 Jan 2019 17:47:33 +0200 Subject: [PATCH 060/121] MAGETWO-67129: Function test Magento\GroupedProduct\Test\TestCase\CreateGroupedProductEntityTest fails randomly --- .../AssociatedProducts/Search/Grid.php | 62 +++++++++++++++++++ .../CreateGroupedProductEntityTest.xml | 2 +- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts/Search/Grid.php b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts/Search/Grid.php index 45481d6ee0758..6c19291222a97 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts/Search/Grid.php +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Block/Adminhtml/Product/Grouped/AssociatedProducts/Search/Grid.php @@ -20,6 +20,13 @@ class Grid extends DataGrid */ protected $addProducts = '.action-primary[data-role="action"]'; + /** + * Grid selector. + * + * @var string + */ + private $gridSelector = '[data-role="grid-wrapper"]'; + /** * Filters array mapping * @@ -40,4 +47,59 @@ public function addProducts() { $this->_rootElement->find($this->addProducts)->click(); } + + /** + * @inheritdoc + */ + public function searchAndSelect(array $filter) + { + $this->waitGridVisible(); + $this->waitLoader(); + parent::searchAndSelect($filter); + } + + /** + * @inheritdoc + */ + protected function waitLoader() + { + parent::waitLoader(); + $this->waitGridLoaderInvisible(); + } + + /** + * Wait for grid to appear. + * + * @return void + */ + private function waitGridVisible() + { + $browser = $this->_rootElement; + $selector = $this->gridSelector; + + return $browser->waitUntil( + function () use ($browser, $selector) { + $element = $browser->find($selector); + return $element->isVisible() ? true : null; + } + ); + } + + /** + * Wait for grid spinner disappear. + * + * @return void + */ + private function waitGridLoaderInvisible() + { + $browser = $this->_rootElement; + $selector = $this->loader; + + return $browser->waitUntil( + function () use ($browser, $selector) { + $element = $browser->find($selector); + return $element->isVisible() === false ? true : null; + } + ); + } } diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.xml index 38ef02ff49441..39f4fd08bb922 100644 --- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/TestCase/CreateGroupedProductEntityTest.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\GroupedProduct\Test\TestCase\CreateGroupedProductEntityTest" summary="Create Grouped Product" ticketId="MAGETWO-24877"> <variation name="CreateGroupedProductEntityTestVariation1" summary="Create Grouped Product and Assign It to the Category" ticketId="MAGETWO-13610"> - <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, stable:no</data> + <data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test</data> <data name="product/data/url_key" xsi:type="string">test-grouped-product-%isolation%</data> <data name="product/data/name" xsi:type="string">GroupedProduct %isolation%</data> <data name="product/data/sku" xsi:type="string">GroupedProduct_sku%isolation%</data> From 69eaa77c837ac8a19fb7f2f3dccd9d60dd286b41 Mon Sep 17 00:00:00 2001 From: Alexey Yakimovich <yakimovich@almagy.com> Date: Fri, 4 Jan 2019 12:00:55 +0300 Subject: [PATCH 061/121] MAGETWO-94556: Undefined variables during product save - Fixed js unit test; --- .../view/adminhtml/web/js/variations/variations.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.test.js index c3bb90f79a495..6b68978380ea4 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/variations.test.js @@ -164,8 +164,8 @@ define([ variation.serializeData(); - expect(variation.source.data['configurable-matrix']).toBeUndefined(); - expect(variation.source.data['associated_product_ids']).toBeUndefined(); + expect(variation.source.data['configurable-matrix']).toEqual(matrix); + expect(variation.source.data['associated_product_ids']).toEqual(ids); expect(variation.source.data['configurable-matrix-serialized']).toEqual(resultMatrix); expect(variation.source.data['associated_product_ids_serialized']).toEqual(resultIds); From 0b8d5314b9c103cee5d763b91517504c3d122d51 Mon Sep 17 00:00:00 2001 From: Andrew Molina <amolina@adobe.com> Date: Thu, 10 Jan 2019 09:29:16 -0600 Subject: [PATCH 062/121] MC-6296: Update DCTRequest --- app/code/Magento/Dhl/Model/Carrier.php | 27 +++-- .../Dhl/Test/Unit/Model/CarrierTest.php | 82 +++++++++----- ...ata_dhl.php => dhl_quote_request_data.php} | 7 +- ...ponse_rates.xml => dhl_quote_response.xml} | 104 +++++++++++++----- .../Model/_files/dhl_quote_response_rates.php | 31 ++++++ 5 files changed, 184 insertions(+), 67 deletions(-) rename app/code/Magento/Dhl/Test/Unit/Model/_files/{rates_request_data_dhl.php => dhl_quote_request_data.php} (92%) rename app/code/Magento/Dhl/Test/Unit/Model/_files/{success_dhl_response_rates.xml => dhl_quote_response.xml} (84%) create mode 100644 app/code/Magento/Dhl/Test/Unit/Model/_files/dhl_quote_response_rates.php diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index d997db6ac1a3e..9f1d9ef75659f 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -199,6 +199,8 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin 'SiteID', 'Password' ]; + protected $productMetadata; + /** * Xml response validator * @@ -261,7 +263,8 @@ public function __construct( \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory, array $data = [], - \Magento\Dhl\Model\Validator\XmlValidator $xmlValidator = null + \Magento\Dhl\Model\Validator\XmlValidator $xmlValidator = null, + \Magento\Framework\App\ProductMetadataInterface $productMetadata ) { $this->readFactory = $readFactory; $this->_carrierHelper = $carrierHelper; @@ -272,6 +275,7 @@ public function __construct( $this->mathDivision = $mathDivision; $this->_dateTime = $dateTime; $this->_httpClientFactory = $httpClientFactory; + $this->productMetadata = $productMetadata; parent::__construct( $scopeConfig, $rateErrorFactory, @@ -929,6 +933,7 @@ protected function _getQuotes() $date = date(self::REQUEST_DATE_FORMAT, strtotime($this->_getShipDate() . " +{$offset} days")); $this->_setQuotesRequestXmlDate($requestXml, $date); + $request = $requestXml->asXML(); $debugPoint['request'] = $this->filterDebugData($request); $responseBody = $this->_getCachedQuotes($request); @@ -983,18 +988,26 @@ protected function _getQuotesFromServer($request) protected function _buildQuotesRequestXml() { $rawRequest = $this->_rawRequest; - $xmlStr = '<?xml version = "1.0" encoding = "UTF-8"?>' . - '<p:DCTRequest xmlns:p="http://www.dhl.com" xmlns:p1="http://www.dhl.com/datatypes" ' . - 'xmlns:p2="http://www.dhl.com/DCTRequestdatatypes" ' . + + $xmlStr = '<?xml version="1.0" encoding = "UTF-8"?>' . + '<req:DCTRequest schemaVersion="2.0" ' . + 'xmlns:req="http://www.dhl.com" ' . 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' . - 'xsi:schemaLocation="http://www.dhl.com DCT-req.xsd "/>'; + 'xsi:schemaLocation="http://www.dhl.com DCT-req_global-2.0.xsd"/>'; + $xml = $this->_xmlElFactory->create(['data' => $xmlStr]); $nodeGetQuote = $xml->addChild('GetQuote', '', ''); $nodeRequest = $nodeGetQuote->addChild('Request'); $nodeServiceHeader = $nodeRequest->addChild('ServiceHeader'); - $nodeServiceHeader->addChild('SiteID', (string)$this->getConfigData('id')); - $nodeServiceHeader->addChild('Password', (string)$this->getConfigData('password')); + $nodeServiceHeader->addChild('MessageTime', date('Y-m-d\TH:i:sP')); + $nodeServiceHeader->addChild('MessageReference', uniqid('magento_quotereq_')); + $nodeServiceHeader->addChild('SiteID', (string) $this->getConfigData('id')); + $nodeServiceHeader->addChild('Password', (string) $this->getConfigData('password')); + + $nodeMetaData = $nodeRequest->addChild('MetaData'); + $nodeMetaData->addChild('SoftwareName', $this->productMetadata->getName()); + $nodeMetaData->addChild('SoftwareVersion', $this->productMetadata->getVersion()); $nodeFrom = $nodeGetQuote->addChild('From'); $nodeFrom->addChild('CountryCode', $rawRequest->getOrigCountryId()); diff --git a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php index 96c76a17bc317..06a2c84285702 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php @@ -55,6 +55,7 @@ class CarrierTest extends \PHPUnit\Framework\TestCase private $model; /** + * @var Error|MockObject * @var Error|MockObject */ private $error; @@ -124,6 +125,7 @@ protected function setUp() $configReader = $this->getConfigReader(); $readFactory = $this->getReadFactory(); $storeManager = $this->getStoreManager(); + $productMetadata = $this->getProductMetadata(); $this->error = $this->getMockBuilder(Error::class) ->setMethods(['setCarrier', 'setCarrierTitle', 'setErrorMessage']) @@ -160,6 +162,7 @@ protected function setUp() 'carrierHelper' => $carrierHelper, 'data' => ['id' => 'dhl', 'store' => '1'], 'xmlValidator' => $this->xmlValidator, + 'productMetadata' => $productMetadata ] ); } @@ -183,7 +186,7 @@ public function scopeConfigGetValue($path) 'carriers/dhl/content_type' => 'N', 'carriers/dhl/nondoc_methods' => '1,3,4,8,P,Q,E,F,H,J,M,V,Y', 'carriers/dhl/showmethod' => 1, - 'carriers/dhl/title' => 'dhl Title', + 'carriers/dhl/title' => 'DHL Title', 'carriers/dhl/specificerrmsg' => 'dhl error message', 'carriers/dhl/unit_of_measure' => 'K', 'carriers/dhl/size' => '1', @@ -191,7 +194,7 @@ public function scopeConfigGetValue($path) 'carriers/dhl/width' => '1.6', 'carriers/dhl/depth' => '1.6', 'carriers/dhl/debug' => 1, - 'shipping/origin/country_id' => 'GB', + 'shipping/origin/country_id' => 'GB' ]; return isset($pathMap[$path]) ? $pathMap[$path] : null; } @@ -247,8 +250,14 @@ protected function _invokePrepareShippingLabelContent(\SimpleXMLElement $xml) return $method->invoke($model, $xml); } + /** + * Tests that valid rates are returned when sending a quotes request. + */ public function testCollectRates() { + $requestData = require __DIR__ . '/_files/dhl_quote_request_data.php'; + $responseXml = file_get_contents(__DIR__ . '/_files/dhl_quote_response.xml'); + $this->scope->method('getValue') ->willReturnCallback([$this, 'scopeConfigGetValue']); @@ -256,13 +265,9 @@ public function testCollectRates() ->willReturn(true); $this->httpResponse->method('getBody') - ->willReturn(file_get_contents(__DIR__ . '/_files/success_dhl_response_rates.xml')); + ->willReturn($responseXml); - /** @var RateRequest $request */ - $request = $this->objectManager->getObject( - RateRequest::class, - require __DIR__ . '/_files/rates_request_data_dhl.php' - ); + $request = $this->objectManager->getObject(RateRequest::class, $requestData); $reflectionClass = new \ReflectionObject($this->httpClient); $rawPostData = $reflectionClass->getProperty('raw_post_data'); @@ -272,13 +277,27 @@ public function testCollectRates() ->method('debug') ->with($this->stringContains('<SiteID>****</SiteID><Password>****</Password>')); - self::assertNotEmpty($this->model->collectRates($request)->getAllRates()); - self::assertContains('<Weight>18.223</Weight>', $rawPostData->getValue($this->httpClient)); - self::assertContains('<Height>0.630</Height>', $rawPostData->getValue($this->httpClient)); - self::assertContains('<Width>0.630</Width>', $rawPostData->getValue($this->httpClient)); - self::assertContains('<Depth>0.630</Depth>', $rawPostData->getValue($this->httpClient)); + $expectedRates = require __DIR__ . '/_files/dhl_quote_response_rates.php'; + $actualRates = $this->model->collectRates($request)->getAllRates(); + + self::assertEquals(count($expectedRates), count($actualRates)); + + foreach ($actualRates as $i => $actualRate) { + $actualRate = $actualRate->getData(); + unset($actualRate['method_title']); + self::assertEquals($expectedRates[$i], $actualRate); + } + + $requestXml = $rawPostData->getValue($this->httpClient); + self::assertContains('<Weight>18.223</Weight>', $requestXml); + self::assertContains('<Height>0.630</Height>', $requestXml); + self::assertContains('<Width>0.630</Width>', $requestXml); + self::assertContains('<Depth>0.630</Depth>', $requestXml); } + /** + * Tests that an error is returned when attempting to collect rates for an inactive shipping method. + */ public function testCollectRatesErrorMessage() { $this->scope->method('getValue') @@ -296,16 +315,6 @@ public function testCollectRatesErrorMessage() $this->assertSame($this->error, $this->model->collectRates($request)); } - public function testCollectRatesFail() - { - $this->scope->expects($this->once())->method('isSetFlag')->willReturn(true); - - $request = new RateRequest(); - $request->setPackageWeight(1); - - $this->assertFalse(false, $this->model->collectRates($request)); - } - /** * Test request to shipment sends valid xml values. */ @@ -595,14 +604,18 @@ private function getRateMethodFactory(): MockObject ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $rateMethod = $this->getMockBuilder(Method::class) - ->disableOriginalConstructor() - ->setMethods(['setPrice']) - ->getMock(); - $rateMethod->method('setPrice') - ->willReturnSelf(); + $rateMethodFactory->method('create') - ->willReturn($rateMethod); + ->willReturnCallback(function () { + $rateMethod = $this->getMockBuilder(Method::class) + ->disableOriginalConstructor() + ->setMethods(['setPrice']) + ->getMock(); + $rateMethod->method('setPrice') + ->willReturnSelf(); + + return $rateMethod; + }); return $rateMethodFactory; } @@ -700,4 +713,13 @@ private function getHttpClientFactory(): MockObject return $httpClientFactory; } + + private function getProductMetadata(): MockObject + { + $productMetadata = $this->createMock(\Magento\Framework\App\ProductMetadata::class); + $productMetadata->method('getName')->willReturn('Magento'); + $productMetadata->method('getVersion')->willReturn('2.3.1'); + + return $productMetadata; + } } diff --git a/app/code/Magento/Dhl/Test/Unit/Model/_files/rates_request_data_dhl.php b/app/code/Magento/Dhl/Test/Unit/Model/_files/dhl_quote_request_data.php similarity index 92% rename from app/code/Magento/Dhl/Test/Unit/Model/_files/rates_request_data_dhl.php rename to app/code/Magento/Dhl/Test/Unit/Model/_files/dhl_quote_request_data.php index 32e9c78886cef..f762b99735233 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/_files/rates_request_data_dhl.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/_files/dhl_quote_request_data.php @@ -24,10 +24,9 @@ 'limit_carrier' => null, 'base_subtotal_incl_tax' => '5', 'orig_country_id' => 'US', - 'country_id' => 'US', - 'region_id' => '12', - 'city' => 'Fremont', - 'postcode' => '94538', + 'orig_region_id' => '12', + 'orig_city' => 'Fremont', + 'orig_postcode' => '94538', 'dhl_id' => 'MAGEN_8501', 'dhl_password' => 'QR2GO1U74X', 'dhl_account' => '799909537', diff --git a/app/code/Magento/Dhl/Test/Unit/Model/_files/success_dhl_response_rates.xml b/app/code/Magento/Dhl/Test/Unit/Model/_files/dhl_quote_response.xml similarity index 84% rename from app/code/Magento/Dhl/Test/Unit/Model/_files/success_dhl_response_rates.xml rename to app/code/Magento/Dhl/Test/Unit/Model/_files/dhl_quote_response.xml index b529e86ef154c..7421707966411 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/_files/success_dhl_response_rates.xml +++ b/app/code/Magento/Dhl/Test/Unit/Model/_files/dhl_quote_response.xml @@ -5,9 +5,9 @@ * See COPYING.txt for license details. */ --> - -<res:DCTResponse xmlns:res="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.dhl.com DCT-Response.xsd"> +<res:DCTResponse xmlns:res="http://www.dhl.com" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.dhl.com DCT-Response_global-2.0.xsd"> <GetQuoteResponse> <Response> <ServiceHeader> @@ -16,15 +16,15 @@ </ServiceHeader> </Response> <BkgDetails> - <OriginServiceArea> - <FacilityCode>NUQ</FacilityCode> - <ServiceAreaCode>NUQ</ServiceAreaCode> - </OriginServiceArea> - <DestinationServiceArea> - <FacilityCode>BER</FacilityCode> - <ServiceAreaCode>BER</ServiceAreaCode> - </DestinationServiceArea> <QtdShp> + <OriginServiceArea> + <FacilityCode>NUQ</FacilityCode> + <ServiceAreaCode>NUQ</ServiceAreaCode> + </OriginServiceArea> + <DestinationServiceArea> + <FacilityCode>BER</FacilityCode> + <ServiceAreaCode>BER</ServiceAreaCode> + </DestinationServiceArea> <GlobalProductCode>E</GlobalProductCode> <LocalProductCode>E</LocalProductCode> <ProductShortName>EXPRESS 9:00</ProductShortName> @@ -42,9 +42,10 @@ <TotalTransitDays>2</TotalTransitDays> <PickupPostalLocAddDays>0</PickupPostalLocAddDays> <DeliveryPostalLocAddDays>0</DeliveryPostalLocAddDays> - <PickupNonDHLCourierCode /> - <DeliveryNonDHLCourierCode /> - <DeliveryDate>2014-01-13</DeliveryDate> + <DeliveryDate> + <DlvyDateTime>2014-01-13 11:59:00</DlvyDateTime> + <DeliveryDateTimeOffset>+00:00</DeliveryDateTimeOffset> + </DeliveryDate> <DeliveryTime>PT9H</DeliveryTime> <DimensionalWeight>2.205</DimensionalWeight> <WeightUnit>LB</WeightUnit> @@ -101,8 +102,19 @@ <TotalTaxAmount>0.000</TotalTaxAmount> <WeightChargeTax>0.000</WeightChargeTax> </QtdSInAdCur> + <PickupWindowEarliestTime>09:00:00</PickupWindowEarliestTime> + <PickupWindowLatestTime>17:00:00</PickupWindowLatestTime> + <BookingCutoffOffset>PT1H</BookingCutoffOffset> </QtdShp> <QtdShp> + <OriginServiceArea> + <FacilityCode>NUQ</FacilityCode> + <ServiceAreaCode>NUQ</ServiceAreaCode> + </OriginServiceArea> + <DestinationServiceArea> + <FacilityCode>BER</FacilityCode> + <ServiceAreaCode>BER</ServiceAreaCode> + </DestinationServiceArea> <GlobalProductCode>Q</GlobalProductCode> <LocalProductCode>Q</LocalProductCode> <ProductShortName>MEDICAL EXPRESS</ProductShortName> @@ -120,9 +132,10 @@ <TotalTransitDays>2</TotalTransitDays> <PickupPostalLocAddDays>0</PickupPostalLocAddDays> <DeliveryPostalLocAddDays>0</DeliveryPostalLocAddDays> - <PickupNonDHLCourierCode /> - <DeliveryNonDHLCourierCode /> - <DeliveryDate>2014-01-13</DeliveryDate> + <DeliveryDate> + <DlvyDateTime>2014-01-13 11:59:00</DlvyDateTime> + <DeliveryDateTimeOffset>+00:00</DeliveryDateTimeOffset> + </DeliveryDate> <DeliveryTime>PT9H</DeliveryTime> <DimensionalWeight>2.205</DimensionalWeight> <WeightUnit>LB</WeightUnit> @@ -179,8 +192,19 @@ <TotalTaxAmount>0.000</TotalTaxAmount> <WeightChargeTax>0.000</WeightChargeTax> </QtdSInAdCur> + <PickupWindowEarliestTime>09:00:00</PickupWindowEarliestTime> + <PickupWindowLatestTime>17:00:00</PickupWindowLatestTime> + <BookingCutoffOffset>PT1H</BookingCutoffOffset> </QtdShp> <QtdShp> + <OriginServiceArea> + <FacilityCode>NUQ</FacilityCode> + <ServiceAreaCode>NUQ</ServiceAreaCode> + </OriginServiceArea> + <DestinationServiceArea> + <FacilityCode>BER</FacilityCode> + <ServiceAreaCode>BER</ServiceAreaCode> + </DestinationServiceArea> <GlobalProductCode>Y</GlobalProductCode> <LocalProductCode>Y</LocalProductCode> <ProductShortName>EXPRESS 12:00</ProductShortName> @@ -198,9 +222,10 @@ <TotalTransitDays>2</TotalTransitDays> <PickupPostalLocAddDays>0</PickupPostalLocAddDays> <DeliveryPostalLocAddDays>0</DeliveryPostalLocAddDays> - <PickupNonDHLCourierCode /> - <DeliveryNonDHLCourierCode /> - <DeliveryDate>2014-01-13</DeliveryDate> + <DeliveryDate> + <DlvyDateTime>2014-01-13 11:59:00</DlvyDateTime> + <DeliveryDateTimeOffset>+00:00</DeliveryDateTimeOffset> + </DeliveryDate> <DeliveryTime>PT12H</DeliveryTime> <DimensionalWeight>2.205</DimensionalWeight> <WeightUnit>LB</WeightUnit> @@ -257,8 +282,19 @@ <TotalTaxAmount>0.000</TotalTaxAmount> <WeightChargeTax>0.000</WeightChargeTax> </QtdSInAdCur> + <PickupWindowEarliestTime>09:00:00</PickupWindowEarliestTime> + <PickupWindowLatestTime>17:00:00</PickupWindowLatestTime> + <BookingCutoffOffset>PT1H</BookingCutoffOffset> </QtdShp> <QtdShp> + <OriginServiceArea> + <FacilityCode>NUQ</FacilityCode> + <ServiceAreaCode>NUQ</ServiceAreaCode> + </OriginServiceArea> + <DestinationServiceArea> + <FacilityCode>BER</FacilityCode> + <ServiceAreaCode>BER</ServiceAreaCode> + </DestinationServiceArea> <GlobalProductCode>3</GlobalProductCode> <LocalProductCode>3</LocalProductCode> <ProductShortName>B2C</ProductShortName> @@ -275,9 +311,10 @@ <TotalTransitDays>2</TotalTransitDays> <PickupPostalLocAddDays>0</PickupPostalLocAddDays> <DeliveryPostalLocAddDays>0</DeliveryPostalLocAddDays> - <PickupNonDHLCourierCode /> - <DeliveryNonDHLCourierCode /> - <DeliveryDate>2014-01-13</DeliveryDate> + <DeliveryDate> + <DlvyDateTime>2014-01-13 11:59:00</DlvyDateTime> + <DeliveryDateTimeOffset>+00:00</DeliveryDateTimeOffset> + </DeliveryDate> <DeliveryTime>PT23H59M</DeliveryTime> <DimensionalWeight>2.205</DimensionalWeight> <WeightUnit>LB</WeightUnit> @@ -309,8 +346,19 @@ <TotalTaxAmount>0.000</TotalTaxAmount> <WeightChargeTax>0.000</WeightChargeTax> </QtdSInAdCur> + <PickupWindowEarliestTime>09:00:00</PickupWindowEarliestTime> + <PickupWindowLatestTime>17:00:00</PickupWindowLatestTime> + <BookingCutoffOffset>PT1H</BookingCutoffOffset> </QtdShp> <QtdShp> + <OriginServiceArea> + <FacilityCode>NUQ</FacilityCode> + <ServiceAreaCode>NUQ</ServiceAreaCode> + </OriginServiceArea> + <DestinationServiceArea> + <FacilityCode>BER</FacilityCode> + <ServiceAreaCode>BER</ServiceAreaCode> + </DestinationServiceArea> <GlobalProductCode>P</GlobalProductCode> <LocalProductCode>P</LocalProductCode> <ProductShortName>EXPRESS WORLDWIDE</ProductShortName> @@ -328,9 +376,10 @@ <TotalTransitDays>2</TotalTransitDays> <PickupPostalLocAddDays>0</PickupPostalLocAddDays> <DeliveryPostalLocAddDays>0</DeliveryPostalLocAddDays> - <PickupNonDHLCourierCode /> - <DeliveryNonDHLCourierCode /> - <DeliveryDate>2014-01-13</DeliveryDate> + <DeliveryDate> + <DlvyDateTime>2014-01-13 11:59:00</DlvyDateTime> + <DeliveryDateTimeOffset>+00:00</DeliveryDateTimeOffset> + </DeliveryDate> <DeliveryTime>PT23H59M</DeliveryTime> <DimensionalWeight>2.205</DimensionalWeight> <WeightUnit>LB</WeightUnit> @@ -387,6 +436,9 @@ <TotalTaxAmount>0.000</TotalTaxAmount> <WeightChargeTax>0.000</WeightChargeTax> </QtdSInAdCur> + <PickupWindowEarliestTime>09:00:00</PickupWindowEarliestTime> + <PickupWindowLatestTime>17:00:00</PickupWindowLatestTime> + <BookingCutoffOffset>PT1H</BookingCutoffOffset> </QtdShp> </BkgDetails> <Srvs> diff --git a/app/code/Magento/Dhl/Test/Unit/Model/_files/dhl_quote_response_rates.php b/app/code/Magento/Dhl/Test/Unit/Model/_files/dhl_quote_response_rates.php new file mode 100644 index 0000000000000..e623b5944ce7c --- /dev/null +++ b/app/code/Magento/Dhl/Test/Unit/Model/_files/dhl_quote_response_rates.php @@ -0,0 +1,31 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +return [ + [ + 'carrier' => 'dhl', + 'carrier_title' => 'DHL Title', + 'cost' => 45.85, + 'method' => 'E' + ], + [ + 'carrier' => 'dhl', + 'carrier_title' => 'DHL Title', + 'cost' => 35.26, + 'method' => 'Q' + ], + [ + 'carrier' => 'dhl', + 'carrier_title' => 'DHL Title', + 'cost' => 37.38, + 'method' => 'Y' + ], + [ + 'carrier' => 'dhl', + 'carrier_title' => 'DHL Title', + 'cost' => 35.26, + 'method' => 'P' + ] +]; \ No newline at end of file From 1decc0c6ff4e7720581709d3c29d9e2d00bf86c0 Mon Sep 17 00:00:00 2001 From: Andrew Molina <amolina@adobe.com> Date: Thu, 10 Jan 2019 10:13:50 -0600 Subject: [PATCH 063/121] MC-6296: Update DCTRequest Fixed Typo --- app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php index 06a2c84285702..6676be9cc8b7e 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php @@ -55,7 +55,6 @@ class CarrierTest extends \PHPUnit\Framework\TestCase private $model; /** - * @var Error|MockObject * @var Error|MockObject */ private $error; From f6a2f2a7c1fbff444b996a7df97f6856414df98d Mon Sep 17 00:00:00 2001 From: Andrew Molina <amolina@adobe.com> Date: Fri, 11 Jan 2019 15:47:12 -0600 Subject: [PATCH 064/121] MC-11005: Create functions for DHL message timestamp and reference --- app/code/Magento/Dhl/Model/Carrier.php | 42 +++++++++++++++++++ .../Dhl/Test/Unit/Model/CarrierTest.php | 27 ++++++++++++ 2 files changed, 69 insertions(+) diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index d997db6ac1a3e..7840820d91253 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -56,6 +56,13 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin */ const CODE = 'dhl'; + /** + * DHL service prefixes used for message reference + */ + const SERVICE_PREFIX_QUOTE = 'QUOT'; + const SERVICE_PREFIX_SHIPVAL = 'SHIP'; + const SERVICE_PREFIX_TRACKING = 'TRCK'; + /** * Rate request data * @@ -1972,4 +1979,39 @@ protected function isDutiable($origCountryId, $destCountryId) self::DHL_CONTENT_TYPE_NON_DOC == $this->getConfigData('content_type') || !$this->_isDomestic; } + + /** + * Builds a datetime string to be used as the MessageTime in accordance to the expected format. + * + * @param string|null $datetime + * @return string + */ + protected function buildMessageTimestamp(string $datetime = null): string + { + return $this->_coreDate->date(\DATE_RFC3339, $datetime); + } + + /** + * Builds a string to be used as the MessageReference. + * + * @param string $servicePrefix + * @return string + * @throws \Magento\Framework\Exception\LocalizedException + */ + protected function buildMessageReference(string $servicePrefix): string + { + $validPrefixes = [ + self::SERVICE_PREFIX_QUOTE, + self::SERVICE_PREFIX_SHIPVAL, + self::SERVICE_PREFIX_TRACKING + ]; + + if (!in_array($servicePrefix, $validPrefixes)) { + throw new \Magento\Framework\Exception\LocalizedException( + __("Invalid service prefix \"$servicePrefix\" provided while attempting to build MessageReference") + ); + } + + return str_replace('.', '', uniqid("MAGE_{$servicePrefix}_", true)); + } } diff --git a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php index 96c76a17bc317..e90f22e2a150d 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php @@ -537,6 +537,33 @@ public function dhlProductsDataProvider() : array ]; } + /** + * Tests that the built message reference string is of the appropriate format. + * + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage Invalid service prefix + * @throws \ReflectionException + */ + public function testBuildMessageReference() + { + $method = new \ReflectionMethod($this->model, 'buildMessageReference'); + $method->setAccessible(true); + + $msgRefQuote = $method->invoke($this->model, Carrier::SERVICE_PREFIX_QUOTE); + self::assertGreaterThanOrEqual(28, strlen($msgRefQuote)); + self::assertLessThanOrEqual(32, strlen($msgRefQuote)); + + $msgRefShip = $method->invoke($this->model, Carrier::SERVICE_PREFIX_SHIPVAL); + self::assertGreaterThanOrEqual(28, strlen($msgRefShip)); + self::assertLessThanOrEqual(32, strlen($msgRefShip)); + + $msgRefTrack = $method->invoke($this->model, Carrier::SERVICE_PREFIX_TRACKING); + self::assertGreaterThanOrEqual(28, strlen($msgRefTrack)); + self::assertLessThanOrEqual(32, strlen($msgRefTrack)); + + $method->invoke($this->model, 'TEST'); + } + /** * Creates mock for XML factory. * From 3a4d363081ddccc521b6a71cc8cc366580b6d658 Mon Sep 17 00:00:00 2001 From: Andrew Molina <amolina@adobe.com> Date: Fri, 11 Jan 2019 16:06:20 -0600 Subject: [PATCH 065/121] MC-11005: Create functions for DHL message timestamp and reference --- app/code/Magento/Dhl/Model/Carrier.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index 7840820d91253..9bbe0f2beed9a 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -1986,7 +1986,7 @@ protected function isDutiable($origCountryId, $destCountryId) * @param string|null $datetime * @return string */ - protected function buildMessageTimestamp(string $datetime = null): string + private function buildMessageTimestamp(string $datetime = null): string { return $this->_coreDate->date(\DATE_RFC3339, $datetime); } @@ -1998,7 +1998,7 @@ protected function buildMessageTimestamp(string $datetime = null): string * @return string * @throws \Magento\Framework\Exception\LocalizedException */ - protected function buildMessageReference(string $servicePrefix): string + private function buildMessageReference(string $servicePrefix): string { $validPrefixes = [ self::SERVICE_PREFIX_QUOTE, From 1c139107ee6f6f55a403f5f826aeea5ec4665b03 Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <veronika_kurochkina@epam.com> Date: Mon, 14 Jan 2019 13:13:10 +0300 Subject: [PATCH 066/121] MAGETWO-96106: CMS Block status is not staged - Updated automated --- .../Widget/Test/Mftf/ActionGroup/AdminWidgetActionGroup.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminWidgetActionGroup.xml b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminWidgetActionGroup.xml index 05c56f588c5d0..c303b7cc8e900 100644 --- a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminWidgetActionGroup.xml +++ b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminWidgetActionGroup.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="AdminCreateWidgetActionGroup"> + <actionGroup name="AdminCreateWidgetWithBlockActionGroup"> <arguments> <argument name="widget"/> <argument name="block" type="string"/> From 4090741cc8d2cc8837dce204f3d5272f22813513 Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Mon, 14 Jan 2019 18:18:29 +0300 Subject: [PATCH 067/121] MC-5573: Refactoring tests. Improve specified test cases. - Add new line in the end of file and change noNamespaceSchemaLocation. --- .../AdminAddDefaultVideoBundleProductTest.xml | 2 +- ...minRemoveDefaultVideoBundleProductTest.xml | 2 +- .../AdvanceCatalogSearchBundleProductTest.xml | 2 +- .../Mftf/Test/CaptchaFormsDisplayingTest.xml | 2 +- .../AdminAddDefaultVideoSimpleProductTest.xml | 2 +- ...AdminAddDefaultVideoVirtualProductTest.xml | 2 +- ...minRemoveDefaultVideoSimpleProductTest.xml | 2 +- ...inRemoveDefaultVideoVirtualProductTest.xml | 2 +- ...AdvanceCatalogSearchVirtualProductTest.xml | 2 +- .../Test/CheckTierPricingOfProductsTest.xml | 2 +- ...IncrementsWorkWithDecimalinventoryTest.xml | 2 +- .../Test/CheckoutSpecificDestinationsTest.xml | 172 +++++++++--------- ...OfDefaultBillingAndShippingAddressTest.xml | 2 +- .../AdvanceCatalogSearchConfigurableTest.xml | 2 +- ...AddDefaultVideoDownloadableProductTest.xml | 2 +- ...ceCatalogSearchDownloadableProductTest.xml | 2 +- ...AdminAddDefaultVideoGroupedProductTest.xml | 2 +- ...inRemoveDefaultVideoGroupedProductTest.xml | 2 +- ...AdvanceCatalogSearchGroupedProductTest.xml | 2 +- ...erifySubscribedNewsletterDisplayedTest.xml | 2 +- .../AdminAddDefaultVideoSimpleProductTest.xml | 2 +- ...minRemoveDefaultVideoSimpleProductTest.xml | 2 +- .../AdminCreateOrderWithBundleProductTest.xml | 2 +- ...dminSubmitConfigurableProductOrderTest.xml | 2 +- .../Test/StorefrontRedirectToOrderHistory.xml | 2 +- ...inRemoveProductWeeeAttributeOptionTest.xml | 3 +- .../Test/StorefrontUpdateWishlistTest.xml | 118 ++++++------ .../Test/EndToEndB2CGuestUserTest.xml | 2 +- .../Test/EndToEndB2CLoggedInUserTest.xml | 2 +- .../Test/EndToEndB2CLoggedInUserTest.xml | 2 +- 30 files changed, 174 insertions(+), 173 deletions(-) diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdminAddDefaultVideoBundleProductTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdminAddDefaultVideoBundleProductTest.xml index 3c00344697699..c49202f31aefb 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/AdminAddDefaultVideoBundleProductTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdminAddDefaultVideoBundleProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminAddDefaultVideoBundleProductTest" extends="AdminAddDefaultVideoSimpleProductTest"> <annotations> <features value="Bundle"/> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdminRemoveDefaultVideoBundleProductTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdminRemoveDefaultVideoBundleProductTest.xml index e3cb68b6664e2..d050c5443d1fe 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/AdminRemoveDefaultVideoBundleProductTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdminRemoveDefaultVideoBundleProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminRemoveDefaultVideoBundleProductTest" extends="AdminRemoveDefaultVideoSimpleProductTest"> <annotations> <features value="Bundle"/> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleProductTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleProductTest.xml index 0b220efaad49f..52bce67600888 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleProductTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdvanceCatalogSearchBundleByNameTest" extends="AdvanceCatalogSearchSimpleProductByNameTest"> <annotations> <features value="Bundle"/> diff --git a/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest.xml b/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest.xml index a088266f760a5..035e58de06ccf 100644 --- a/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest.xml +++ b/app/code/Magento/Captcha/Test/Mftf/Test/CaptchaFormsDisplayingTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="CaptchaFormsDisplayingTest"> <annotations> <features value="Captcha"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddDefaultVideoSimpleProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddDefaultVideoSimpleProductTest.xml index 5456cb02e74ca..f657fbbdae607 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddDefaultVideoSimpleProductTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddDefaultVideoSimpleProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminAddDefaultVideoSimpleProductTest"> <annotations> <features value="Catalog"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddDefaultVideoVirtualProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddDefaultVideoVirtualProductTest.xml index f48c352c5290a..eab36bc90dc18 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddDefaultVideoVirtualProductTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddDefaultVideoVirtualProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminAddDefaultVideoVirtualProductTest" extends="AdminAddDefaultVideoSimpleProductTest"> <annotations> <features value="Catalog"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminRemoveDefaultVideoSimpleProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminRemoveDefaultVideoSimpleProductTest.xml index 1bd218d18c27d..876eedb9347c7 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminRemoveDefaultVideoSimpleProductTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminRemoveDefaultVideoSimpleProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminRemoveDefaultVideoSimpleProductTest"> <annotations> <features value="Catalog"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminRemoveDefaultVideoVirtualProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminRemoveDefaultVideoVirtualProductTest.xml index e6d3978cad7bb..8b3b38d0ece31 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminRemoveDefaultVideoVirtualProductTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminRemoveDefaultVideoVirtualProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminRemoveDefaultVideoVirtualProductTest" extends="AdminRemoveDefaultVideoSimpleProductTest"> <annotations> <features value="Catalog"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchVirtualProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchVirtualProductTest.xml index 0eb8f5668751a..84c3f81ef6dbf 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchVirtualProductTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchVirtualProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdvanceCatalogSearchVirtualProductByNameTest" extends="AdvanceCatalogSearchSimpleProductByNameTest"> <annotations> <features value="Catalog"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/CheckTierPricingOfProductsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/CheckTierPricingOfProductsTest.xml index 7da668df59022..cee40241185b4 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/CheckTierPricingOfProductsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/CheckTierPricingOfProductsTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="CheckTierPricingOfProductsTest"> <annotations> <features value="Shopping Cart"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/TieredPricingAndQuantityIncrementsWorkWithDecimalinventoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/TieredPricingAndQuantityIncrementsWorkWithDecimalinventoryTest.xml index f283a040ced41..e6c37c8dc15e3 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/TieredPricingAndQuantityIncrementsWorkWithDecimalinventoryTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/TieredPricingAndQuantityIncrementsWorkWithDecimalinventoryTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="TieredPricingAndQuantityIncrementsWorkWithDecimalinventoryTest"> <annotations> <features value="Catalog"/> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/CheckoutSpecificDestinationsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/CheckoutSpecificDestinationsTest.xml index 269ca94b3f772..f3807388399b8 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/CheckoutSpecificDestinationsTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/CheckoutSpecificDestinationsTest.xml @@ -1,86 +1,86 @@ -<?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="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> - <test name="CheckoutSpecificDestinationsTest"> - <annotations> - <title value="Check that top destinations can be removed after a selection was previously saved"/> - <stories value="MAGETWO-91511: Top destinations cannot be removed after a selection was previously saved"/> - <description value="Check that top destinations can be removed after a selection was previously saved"/> - <features value="Checkout"/> - <severity value="AVERAGE"/> - <testCaseId value="MAGETWO-94195"/> - <group value="Checkout"/> - </annotations> - - <before> - <createData entity="_defaultCategory" stepKey="defaultCategory"/> - <createData entity="_defaultProduct" stepKey="simpleProduct"> - <requiredEntity createDataKey="defaultCategory"/> - </createData> - - <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> - </before> - - <!--Go to configuration general page--> - <actionGroup ref="NavigateToConfigurationGeneralPage" stepKey="navigateToConfigurationGeneralPage"/> - - <!--Open country options section--> - <conditionalClick selector="{{CountryOptionsSection.countryOptions}}" dependentSelector="{{CountryOptionsSection.countryOptionsOpen}}" visible="false" stepKey="clickOnStoreInformation"/> - - <!--Select top destinations country--> - <actionGroup ref="SelectTopDestinationsCountry" stepKey="selectTopDestinationsCountry"> - <argument name="countries" value="Countries"/> - </actionGroup> - - <!--Go to product page--> - <amOnPage url="{{StorefrontProductPage.url($$simpleProduct.name$$)}}" stepKey="amOnStorefrontProductPage"/> - <waitForPageLoad stepKey="waitForProductPageLoad"/> - - <!--Add product to cart--> - <actionGroup ref="StorefrontAddToCartCustomOptionsProductPageActionGroup" stepKey="addToCart"> - <argument name="productName" value="$$simpleProduct.name$$"/> - </actionGroup> - - <!--Go to shopping cart--> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/> - - <!--Verify country options in checkout top destination section--> - <actionGroup ref="VerifyTopDestinationsCountry" stepKey="verifyTopDestinationsCountry"> - <argument name="country" value="Bahamas"/> - <argument name="placeNumber" value="2"/> - </actionGroup> - - <!--Go to configuration general page--> - <actionGroup ref="NavigateToConfigurationGeneralPage" stepKey="navigateToConfigurationGeneralPage2"/> - - <!--Open country options section--> - <conditionalClick selector="{{CountryOptionsSection.countryOptions}}" dependentSelector="{{CountryOptionsSection.countryOptionsOpen}}" visible="false" stepKey="clickOnStoreInformation2"/> - - <!--Deselect top destinations country--> - <actionGroup ref="UnSelectTopDestinationsCountry" stepKey="unSelectTopDestinationsCountry"> - <argument name="countries" value="Countries"/> - </actionGroup> - - <!--Go to shopping cart--> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart2"/> - - <!--Verify country options is shown by default--> - <actionGroup ref="VerifyTopDestinationsCountry" stepKey="verifyTopDestinationsCountry2"> - <argument name="country" value="Afghanistan"/> - <argument name="placeNumber" value="2"/> - </actionGroup> - - <after> - <actionGroup ref="logout" stepKey="logout"/> - - <deleteData createDataKey="simpleProduct" stepKey="deleteProduct"/> - <deleteData createDataKey="defaultCategory" stepKey="deleteCategory"/> - </after> - </test> -</tests> \ No newline at end of file +<?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="CheckoutSpecificDestinationsTest"> + <annotations> + <title value="Check that top destinations can be removed after a selection was previously saved"/> + <stories value="MAGETWO-91511: Top destinations cannot be removed after a selection was previously saved"/> + <description value="Check that top destinations can be removed after a selection was previously saved"/> + <features value="Checkout"/> + <severity value="AVERAGE"/> + <testCaseId value="MAGETWO-94195"/> + <group value="Checkout"/> + </annotations> + + <before> + <createData entity="_defaultCategory" stepKey="defaultCategory"/> + <createData entity="_defaultProduct" stepKey="simpleProduct"> + <requiredEntity createDataKey="defaultCategory"/> + </createData> + + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + + <!--Go to configuration general page--> + <actionGroup ref="NavigateToConfigurationGeneralPage" stepKey="navigateToConfigurationGeneralPage"/> + + <!--Open country options section--> + <conditionalClick selector="{{CountryOptionsSection.countryOptions}}" dependentSelector="{{CountryOptionsSection.countryOptionsOpen}}" visible="false" stepKey="clickOnStoreInformation"/> + + <!--Select top destinations country--> + <actionGroup ref="SelectTopDestinationsCountry" stepKey="selectTopDestinationsCountry"> + <argument name="countries" value="Countries"/> + </actionGroup> + + <!--Go to product page--> + <amOnPage url="{{StorefrontProductPage.url($$simpleProduct.name$$)}}" stepKey="amOnStorefrontProductPage"/> + <waitForPageLoad stepKey="waitForProductPageLoad"/> + + <!--Add product to cart--> + <actionGroup ref="StorefrontAddToCartCustomOptionsProductPageActionGroup" stepKey="addToCart"> + <argument name="productName" value="$$simpleProduct.name$$"/> + </actionGroup> + + <!--Go to shopping cart--> + <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart"/> + + <!--Verify country options in checkout top destination section--> + <actionGroup ref="VerifyTopDestinationsCountry" stepKey="verifyTopDestinationsCountry"> + <argument name="country" value="Bahamas"/> + <argument name="placeNumber" value="2"/> + </actionGroup> + + <!--Go to configuration general page--> + <actionGroup ref="NavigateToConfigurationGeneralPage" stepKey="navigateToConfigurationGeneralPage2"/> + + <!--Open country options section--> + <conditionalClick selector="{{CountryOptionsSection.countryOptions}}" dependentSelector="{{CountryOptionsSection.countryOptionsOpen}}" visible="false" stepKey="clickOnStoreInformation2"/> + + <!--Deselect top destinations country--> + <actionGroup ref="UnSelectTopDestinationsCountry" stepKey="unSelectTopDestinationsCountry"> + <argument name="countries" value="Countries"/> + </actionGroup> + + <!--Go to shopping cart--> + <amOnPage url="{{CheckoutCartPage.url}}" stepKey="amOnPageShoppingCart2"/> + + <!--Verify country options is shown by default--> + <actionGroup ref="VerifyTopDestinationsCountry" stepKey="verifyTopDestinationsCountry2"> + <argument name="country" value="Afghanistan"/> + <argument name="placeNumber" value="2"/> + </actionGroup> + + <after> + <actionGroup ref="logout" stepKey="logout"/> + + <deleteData createDataKey="simpleProduct" stepKey="deleteProduct"/> + <deleteData createDataKey="defaultCategory" stepKey="deleteCategory"/> + </after> + </test> +</tests> diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml index 9664ec47420cc..89028e146c358 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/IdentityOfDefaultBillingAndShippingAddressTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="IdentityOfDefaultBillingAndShippingAddressTest"> <annotations> <features value="Customer"/> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdvanceCatalogSearchConfigurableTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdvanceCatalogSearchConfigurableTest.xml index 454f9f5f29a7a..c303e4d19db81 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdvanceCatalogSearchConfigurableTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdvanceCatalogSearchConfigurableTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdvanceCatalogSearchConfigurableByNameTest" extends="AdvanceCatalogSearchSimpleProductByNameTest"> <annotations> <features value="ConfigurableProduct"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultVideoDownloadableProductTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultVideoDownloadableProductTest.xml index 88dcca0958719..a7acdfded29b6 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultVideoDownloadableProductTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminAddDefaultVideoDownloadableProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminAddDefaultVideoDownloadableProductTest" extends="AdminAddDefaultVideoSimpleProductTest"> <annotations> <features value="Downloadable"/> diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdvanceCatalogSearchDownloadableProductTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdvanceCatalogSearchDownloadableProductTest.xml index af5d20b075d12..66177b6875dd9 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdvanceCatalogSearchDownloadableProductTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdvanceCatalogSearchDownloadableProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdvanceCatalogSearchDownloadableByNameTest" extends="AdvanceCatalogSearchSimpleProductByNameTest"> <annotations> <features value="Downloadable"/> diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAddDefaultVideoGroupedProductTest.xml b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAddDefaultVideoGroupedProductTest.xml index 8634fc3f6f9dc..c3a95bbef3aa3 100644 --- a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAddDefaultVideoGroupedProductTest.xml +++ b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAddDefaultVideoGroupedProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminAddDefaultVideoGroupedProductTest" extends="AdminAddDefaultVideoSimpleProductTest"> <annotations> <features value="GroupedProduct"/> diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminRemoveDefaultVideoGroupedProductTest.xml b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminRemoveDefaultVideoGroupedProductTest.xml index 25c45abdfe047..e322d4a1eb038 100644 --- a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminRemoveDefaultVideoGroupedProductTest.xml +++ b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminRemoveDefaultVideoGroupedProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminRemoveDefaultVideoGroupedProductTest" extends="AdminRemoveDefaultVideoSimpleProductTest"> <annotations> <features value="GroupedProduct"/> diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest.xml b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest.xml index 0fd52ac4a65a4..2a600d38250f8 100644 --- a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest.xml +++ b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdvanceCatalogSearchGroupedProductByNameTest" extends="AdvanceCatalogSearchSimpleProductByNameTest"> <annotations> <features value="GroupedProduct"/> diff --git a/app/code/Magento/Newsletter/Test/Mftf/Test/VerifySubscribedNewsletterDisplayedTest.xml b/app/code/Magento/Newsletter/Test/Mftf/Test/VerifySubscribedNewsletterDisplayedTest.xml index faed8b1af952e..0ef4f69f565a8 100644 --- a/app/code/Magento/Newsletter/Test/Mftf/Test/VerifySubscribedNewsletterDisplayedTest.xml +++ b/app/code/Magento/Newsletter/Test/Mftf/Test/VerifySubscribedNewsletterDisplayedTest.xml @@ -6,7 +6,7 @@ */ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="VerifySubscribedNewsletterDisplayedTest"> <annotations> <features value="Newsletter"/> diff --git a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddDefaultVideoSimpleProductTest.xml b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddDefaultVideoSimpleProductTest.xml index bd7cc0cdf5b4a..2b5f87f78d5e5 100644 --- a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddDefaultVideoSimpleProductTest.xml +++ b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminAddDefaultVideoSimpleProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminAddDefaultVideoSimpleProductTest"> <annotations> <group value="ProductVideo"/> diff --git a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminRemoveDefaultVideoSimpleProductTest.xml b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminRemoveDefaultVideoSimpleProductTest.xml index f5a7886fed45c..d4da0ffa54451 100644 --- a/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminRemoveDefaultVideoSimpleProductTest.xml +++ b/app/code/Magento/ProductVideo/Test/Mftf/Test/AdminRemoveDefaultVideoSimpleProductTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminRemoveDefaultVideoSimpleProductTest"> <annotations> <group value="ProductVideo"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithBundleProductTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithBundleProductTest.xml index f15f5de5df696..93124ac0ffd89 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithBundleProductTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithBundleProductTest.xml @@ -6,7 +6,7 @@ */ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminCreateOrderWithBundleProductTest"> <annotations> <title value="Create Order in Admin and update bundle product configuration"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitConfigurableProductOrderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitConfigurableProductOrderTest.xml index 041252af0ac5b..74784ed495f8a 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitConfigurableProductOrderTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminSubmitConfigurableProductOrderTest.xml @@ -6,7 +6,7 @@ */ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminSubmitConfigurableProductOrderTest"> <annotations> <title value="Create Order in Admin and update product configuration"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/StorefrontRedirectToOrderHistory.xml b/app/code/Magento/Sales/Test/Mftf/Test/StorefrontRedirectToOrderHistory.xml index 9790b5dfc47f3..ad3a411d92414 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/StorefrontRedirectToOrderHistory.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/StorefrontRedirectToOrderHistory.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="StorefrontRedirectToOrderHistory"> <annotations> <features value="Redirection Rules"/> diff --git a/app/code/Magento/Weee/Test/Mftf/Test/AdminRemoveProductWeeeAttributeOptionTest.xml b/app/code/Magento/Weee/Test/Mftf/Test/AdminRemoveProductWeeeAttributeOptionTest.xml index 2e3467fe2c7c5..4f00f72720ef4 100644 --- a/app/code/Magento/Weee/Test/Mftf/Test/AdminRemoveProductWeeeAttributeOptionTest.xml +++ b/app/code/Magento/Weee/Test/Mftf/Test/AdminRemoveProductWeeeAttributeOptionTest.xml @@ -6,7 +6,7 @@ */ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminRemoveProductWeeeAttributeOptionTest"> <annotations> <features value="Weee attribute options can be removed in product page"/> @@ -44,6 +44,7 @@ <deleteData createDataKey="createProductFPTAttribute" stepKey="deleteProductFPTAttribute"/> <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> </after> + <!-- Test Steps --> <!-- Step 1: Open created product edit page --> <actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct"> diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontUpdateWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontUpdateWishlistTest.xml index 9f11de49adcd4..84b605747d08b 100644 --- a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontUpdateWishlistTest.xml +++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontUpdateWishlistTest.xml @@ -1,59 +1,59 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> - <test name="StorefrontUpdateWishlistTest"> - <annotations> - <title value="Displaying of message after Wish List update"/> - <stories value="MAGETWO-91666: Wishlist update does not return a success message"/> - <description value="Displaying of message after Wish List update"/> - <features value="Wishlist"/> - <severity value="MAJOR"/> - <testCaseId value="MAGETWO-94296"/> - <group value="Wishlist"/> - </annotations> - - <before> - <createData entity="SimpleSubCategory" stepKey="category"/> - <createData entity="SimpleProduct" stepKey="product"> - <requiredEntity createDataKey="category"/> - </createData> - <createData entity="Simple_US_Customer" stepKey="customer"/> - </before> - - <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefrontAccount"> - <argument name="Customer" value="$$customer$$"/> - </actionGroup> - - <actionGroup ref="OpenProductFromCategoryPageActionGroup" stepKey="openProductFromCategory"> - <argument name="category" value="$$category$$"/> - <argument name="product" value="$$product$$"/> - </actionGroup> - - <actionGroup ref="StorefrontCustomerAddProductToWishlistActionGroup" stepKey="addProductToWishlist"> - <argument name="productVar" value="$$product$$"/> - </actionGroup> - - <actionGroup ref="StorefrontCustomerCheckProductInWishlist" stepKey="checkProductInWishlist"> - <argument name="productVar" value="$$product$$"/> - </actionGroup> - - <actionGroup ref="StorefrontCustomerEditProductInWishlist" stepKey="updateProductInWishlist"> - <argument name="product" value="$$product$$"/> - <argument name="description" value="some text"/> - <argument name="quantity" value="2"/> - </actionGroup> - - <after> - <deleteData createDataKey="category" stepKey="deleteCategory"/> - <deleteData createDataKey="product" stepKey="deleteProduct"/> - <deleteData createDataKey="customer" stepKey="deleteCustomer"/> - </after> - - </test> -</tests> \ No newline at end of file +<?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="StorefrontUpdateWishlistTest"> + <annotations> + <title value="Displaying of message after Wish List update"/> + <stories value="MAGETWO-91666: Wishlist update does not return a success message"/> + <description value="Displaying of message after Wish List update"/> + <features value="Wishlist"/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-94296"/> + <group value="Wishlist"/> + </annotations> + + <before> + <createData entity="SimpleSubCategory" stepKey="category"/> + <createData entity="SimpleProduct" stepKey="product"> + <requiredEntity createDataKey="category"/> + </createData> + <createData entity="Simple_US_Customer" stepKey="customer"/> + </before> + + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginToStorefrontAccount"> + <argument name="Customer" value="$$customer$$"/> + </actionGroup> + + <actionGroup ref="OpenProductFromCategoryPageActionGroup" stepKey="openProductFromCategory"> + <argument name="category" value="$$category$$"/> + <argument name="product" value="$$product$$"/> + </actionGroup> + + <actionGroup ref="StorefrontCustomerAddProductToWishlistActionGroup" stepKey="addProductToWishlist"> + <argument name="productVar" value="$$product$$"/> + </actionGroup> + + <actionGroup ref="StorefrontCustomerCheckProductInWishlist" stepKey="checkProductInWishlist"> + <argument name="productVar" value="$$product$$"/> + </actionGroup> + + <actionGroup ref="StorefrontCustomerEditProductInWishlist" stepKey="updateProductInWishlist"> + <argument name="product" value="$$product$$"/> + <argument name="description" value="some text"/> + <argument name="quantity" value="2"/> + </actionGroup> + + <after> + <deleteData createDataKey="category" stepKey="deleteCategory"/> + <deleteData createDataKey="product" stepKey="deleteProduct"/> + <deleteData createDataKey="customer" stepKey="deleteCustomer"/> + </after> + + </test> +</tests> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductCatalogSearch/Test/EndToEndB2CGuestUserTest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductCatalogSearch/Test/EndToEndB2CGuestUserTest.xml index f5cd41bda74d7..404bebfb719dc 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductCatalogSearch/Test/EndToEndB2CGuestUserTest.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductCatalogSearch/Test/EndToEndB2CGuestUserTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="EndToEndB2CGuestUserTest"> <!-- Search configurable product --> <comment userInput="Search configurable product" stepKey="commentSearchConfigurableProduct" after="searchAssertSimpleProduct2ImageNotDefault" /> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductCatalogSearch/Test/EndToEndB2CLoggedInUserTest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductCatalogSearch/Test/EndToEndB2CLoggedInUserTest.xml index 3e386a034eecc..9fe70c8b4dd3b 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductCatalogSearch/Test/EndToEndB2CLoggedInUserTest.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductCatalogSearch/Test/EndToEndB2CLoggedInUserTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="EndToEndB2CLoggedInUserTest"> <!-- Search configurable product --> <comment userInput="Search configurable product" stepKey="commentSearchConfigurableProduct" after="searchAssertSimpleProduct2ImageNotDefault" /> diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductWishlist/Test/EndToEndB2CLoggedInUserTest.xml b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductWishlist/Test/EndToEndB2CLoggedInUserTest.xml index d3b009eecf877..cb3d9edbc1cbb 100644 --- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductWishlist/Test/EndToEndB2CLoggedInUserTest.xml +++ b/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/ConfigurableProductWishlist/Test/EndToEndB2CLoggedInUserTest.xml @@ -7,7 +7,7 @@ --> <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd"> + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="EndToEndB2CLoggedInUserTest"> <!-- Step 5: Add products to wishlist --> <!-- Add Configurable Product to wishlist --> From c6c3a25ec2e5a1ab99117f65bb9a977f924a2bcf Mon Sep 17 00:00:00 2001 From: Andrew Molina <amolina@adobe.com> Date: Mon, 14 Jan 2019 10:46:52 -0600 Subject: [PATCH 068/121] MC-11005 - Create functions for DHL message timestamp and reference Changed visibility on constants to private --- app/code/Magento/Dhl/Model/Carrier.php | 6 +++--- app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php | 10 +++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index 9bbe0f2beed9a..e765b33bfdba1 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -59,9 +59,9 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin /** * DHL service prefixes used for message reference */ - const SERVICE_PREFIX_QUOTE = 'QUOT'; - const SERVICE_PREFIX_SHIPVAL = 'SHIP'; - const SERVICE_PREFIX_TRACKING = 'TRCK'; + private const SERVICE_PREFIX_QUOTE = 'QUOT'; + private const SERVICE_PREFIX_SHIPVAL = 'SHIP'; + private const SERVICE_PREFIX_TRACKING = 'TRCK'; /** * Rate request data diff --git a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php index e90f22e2a150d..311dfe2eac736 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php @@ -549,15 +549,19 @@ public function testBuildMessageReference() $method = new \ReflectionMethod($this->model, 'buildMessageReference'); $method->setAccessible(true); - $msgRefQuote = $method->invoke($this->model, Carrier::SERVICE_PREFIX_QUOTE); + $constPrefixQuote = new \ReflectionClassConstant($this->model, 'SERVICE_PREFIX_QUOTE'); + $constPrefixShipval = new \ReflectionClassConstant($this->model, 'SERVICE_PREFIX_SHIPVAL'); + $constPrefixTracking = new \ReflectionClassConstant($this->model, 'SERVICE_PREFIX_TRACKING'); + + $msgRefQuote = $method->invoke($this->model, $constPrefixQuote->getValue()); self::assertGreaterThanOrEqual(28, strlen($msgRefQuote)); self::assertLessThanOrEqual(32, strlen($msgRefQuote)); - $msgRefShip = $method->invoke($this->model, Carrier::SERVICE_PREFIX_SHIPVAL); + $msgRefShip = $method->invoke($this->model, $constPrefixShipval->getValue()); self::assertGreaterThanOrEqual(28, strlen($msgRefShip)); self::assertLessThanOrEqual(32, strlen($msgRefShip)); - $msgRefTrack = $method->invoke($this->model, Carrier::SERVICE_PREFIX_TRACKING); + $msgRefTrack = $method->invoke($this->model, $constPrefixTracking->getValue()); self::assertGreaterThanOrEqual(28, strlen($msgRefTrack)); self::assertLessThanOrEqual(32, strlen($msgRefTrack)); From 80061a668e3107aa8d5713d4819e824d92bff93d Mon Sep 17 00:00:00 2001 From: Andrew Molina <amolina@adobe.com> Date: Mon, 14 Jan 2019 14:19:24 -0600 Subject: [PATCH 069/121] MC-6296 - Update DCTRequest Updated productMetadata variable visibility to private Updated building of quote request to use new messageTimestamp and messageReference function --- app/code/Magento/Dhl/Model/Carrier.php | 23 +++++--- .../Dhl/Test/Unit/Model/CarrierTest.php | 52 +++++++++++-------- 2 files changed, 46 insertions(+), 29 deletions(-) diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index 7a493460e0352..bd129eb6111a5 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -16,6 +16,7 @@ use Magento\Shipping\Model\Rate\Result; use Magento\Framework\Xml\Security; use Magento\Dhl\Model\Validator\XmlValidator; +use Magento\Framework\App\ProductMetadataInterface; /** * DHL International (API v1.4) @@ -206,7 +207,10 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin 'SiteID', 'Password' ]; - protected $productMetadata; + /** + * @var \Magento\Framework\App\ProductMetadataInterface + */ + private $productMetadata; /** * Xml response validator @@ -242,6 +246,7 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin * @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory * @param array $data * @param \Magento\Dhl\Model\Validator\XmlValidator $xmlValidator + * @param \Magento\Framework\App\ProductMetadataInterface $productMetadata * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -271,7 +276,7 @@ public function __construct( \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory, array $data = [], \Magento\Dhl\Model\Validator\XmlValidator $xmlValidator = null, - \Magento\Framework\App\ProductMetadataInterface $productMetadata + \Magento\Framework\App\ProductMetadataInterface $productMetadata = null ) { $this->readFactory = $readFactory; $this->_carrierHelper = $carrierHelper; @@ -282,7 +287,6 @@ public function __construct( $this->mathDivision = $mathDivision; $this->_dateTime = $dateTime; $this->_httpClientFactory = $httpClientFactory; - $this->productMetadata = $productMetadata; parent::__construct( $scopeConfig, $rateErrorFactory, @@ -304,8 +308,10 @@ public function __construct( if ($this->getConfigData('content_type') == self::DHL_CONTENT_TYPE_DOC) { $this->_freeMethod = 'free_method_doc'; } - $this->xmlValidator = $xmlValidator - ?: \Magento\Framework\App\ObjectManager::getInstance()->get(XmlValidator::class); + + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $this->xmlValidator = $xmlValidator ?: $objectManager->get(XmlValidator::class); + $this->productMetadata = $productMetadata ?: $objectManager->get(ProductMetadataInterface::class); } /** @@ -1007,8 +1013,11 @@ protected function _buildQuotesRequestXml() $nodeRequest = $nodeGetQuote->addChild('Request'); $nodeServiceHeader = $nodeRequest->addChild('ServiceHeader'); - $nodeServiceHeader->addChild('MessageTime', date('Y-m-d\TH:i:sP')); - $nodeServiceHeader->addChild('MessageReference', uniqid('magento_quotereq_')); + $nodeServiceHeader->addChild('MessageTime', $this->buildMessageTimestamp()); + $nodeServiceHeader->addChild( + 'MessageReference', + $this->buildMessageReference(self::SERVICE_PREFIX_QUOTE) + ); $nodeServiceHeader->addChild('SiteID', (string) $this->getConfigData('id')); $nodeServiceHeader->addChild('Password', (string) $this->getConfigData('password')); diff --git a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php index 35d998b1108df..785ddb854fe7a 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php @@ -117,15 +117,6 @@ protected function setUp() $this->scope = $this->getMockForAbstractClass(ScopeConfigInterface::class); - $xmlElFactory = $this->getXmlFactory(); - $rateFactory = $this->getRateFactory(); - $rateMethodFactory = $this->getRateMethodFactory(); - $httpClientFactory = $this->getHttpClientFactory(); - $configReader = $this->getConfigReader(); - $readFactory = $this->getReadFactory(); - $storeManager = $this->getStoreManager(); - $productMetadata = $this->getProductMetadata(); - $this->error = $this->getMockBuilder(Error::class) ->setMethods(['setCarrier', 'setCarrierTitle', 'setErrorMessage']) ->getMock(); @@ -136,8 +127,6 @@ protected function setUp() $this->errorFactory->method('create') ->willReturn($this->error); - $carrierHelper = $this->getCarrierHelper(); - $this->xmlValidator = $this->getMockBuilder(XmlValidator::class) ->disableOriginalConstructor() ->getMock(); @@ -148,20 +137,21 @@ protected function setUp() Carrier::class, [ 'scopeConfig' => $this->scope, - 'xmlSecurity' => new Security(), - 'logger' => $this->logger, - 'xmlElFactory' => $xmlElFactory, - 'rateFactory' => $rateFactory, 'rateErrorFactory' => $this->errorFactory, - 'rateMethodFactory' => $rateMethodFactory, - 'httpClientFactory' => $httpClientFactory, - 'readFactory' => $readFactory, - 'storeManager' => $storeManager, - 'configReader' => $configReader, - 'carrierHelper' => $carrierHelper, + 'logger' => $this->logger, + 'xmlSecurity' => new Security(), + 'xmlElFactory' => $this->getXmlFactory(), + 'rateFactory' => $this->getRateFactory(), + 'rateMethodFactory' => $this->getRateMethodFactory(), + 'carrierHelper' => $this->getCarrierHelper(), + 'coreDate' => $this->getCoreDate(), + 'configReader' => $this->getConfigReader(), + 'storeManager' => $this->getStoreManager(), + 'readFactory' => $this->getReadFactory(), + 'httpClientFactory' => $this->getHttpClientFactory(), 'data' => ['id' => 'dhl', 'store' => '1'], 'xmlValidator' => $this->xmlValidator, - 'productMetadata' => $productMetadata + 'productMetadata' => $this->getProductMetadata() ] ); } @@ -721,6 +711,21 @@ private function getCarrierHelper(): CarrierHelper return $carrierHelper; } + /** + * @return MockObject + */ + private function getCoreDate(): MockObject + { + $coreDate = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTime::class) + ->disableOriginalConstructor() + ->getMock(); + $coreDate->method('date')->willReturnCallback(function () { + return date(\DATE_RFC3339); + }); + + return $coreDate; + } + /** * @return MockObject */ @@ -744,6 +749,9 @@ private function getHttpClientFactory(): MockObject return $httpClientFactory; } + /** + * @return MockObject + */ private function getProductMetadata(): MockObject { $productMetadata = $this->createMock(\Magento\Framework\App\ProductMetadata::class); From 2794d6ae7b33666e87c33e643f3996c13ac50706 Mon Sep 17 00:00:00 2001 From: Andrii Meysar <andrii.meysar@transoftgroup.com> Date: Tue, 15 Jan 2019 17:25:29 +0200 Subject: [PATCH 070/121] MC-10939: Integration tests failure on Jenkins --- .../BundleImportExport/Model/BundleTest.php | 19 +- .../AbstractProductExportImportTestCase.php | 227 ++++++++++-------- .../CatalogImportExport/Model/ProductTest.php | 21 +- .../Model/ConfigurableTest.php | 32 ++- .../Model/DownloadableTest.php | 72 ++---- .../GroupedImportExport/Model/GroupedTest.php | 19 +- 6 files changed, 186 insertions(+), 204 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/BundleImportExport/Model/BundleTest.php b/dev/tests/integration/testsuite/Magento/BundleImportExport/Model/BundleTest.php index e15f8d47a7bfc..864bdaa2a1331 100644 --- a/dev/tests/integration/testsuite/Magento/BundleImportExport/Model/BundleTest.php +++ b/dev/tests/integration/testsuite/Magento/BundleImportExport/Model/BundleTest.php @@ -9,7 +9,10 @@ class BundleTest extends AbstractProductExportImportTestCase { - public function exportImportDataProvider() + /** + * @return array + */ + public function exportImportDataProvider(): array { return [ // @todo uncomment after MAGETWO-49677 resolved @@ -45,17 +48,13 @@ public function exportImportDataProvider() ]; } - public function importReplaceDataProvider() - { - return $this->exportImportDataProvider(); - } - /** - * @param \Magento\Catalog\Model\Product $expectedProduct - * @param \Magento\Catalog\Model\Product $actualProduct + * @inheritdoc */ - protected function assertEqualsSpecificAttributes($expectedProduct, $actualProduct) - { + protected function assertEqualsSpecificAttributes( + \Magento\Catalog\Model\Product $expectedProduct, + \Magento\Catalog\Model\Product $actualProduct + ): void { $expectedBundleProductOptions = $expectedProduct->getExtensionAttributes()->getBundleProductOptions(); $actualBundleProductOptions = $actualProduct->getExtensionAttributes()->getBundleProductOptions(); diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/AbstractProductExportImportTestCase.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/AbstractProductExportImportTestCase.php index b562879b319d6..d3a2e4c53f246 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/AbstractProductExportImportTestCase.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/AbstractProductExportImportTestCase.php @@ -55,6 +55,16 @@ abstract class AbstractProductExportImportTestCase extends \PHPUnit\Framework\Te 'is_salable', // stock indexation is not performed during import ]; + /** + * @var array + */ + private static $attributesToRefresh = [ + 'tax_class_id', + ]; + + /** + * @inheritdoc + */ protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); @@ -65,12 +75,17 @@ protected function setUp() \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType::$commonAttributesCache = []; } + /** + * @inheritdoc + */ protected function tearDown() { - $this->executeRollbackFixtures($this->fixtures); + $this->executeFixtures($this->fixtures, true); } /** + * Run import/export tests. + * * @magentoAppArea adminhtml * @magentoDbIsolation disabled * @magentoAppIsolation enabled @@ -78,36 +93,60 @@ protected function tearDown() * @param array $fixtures * @param string[] $skus * @param string[] $skippedAttributes + * @return void * @dataProvider exportImportDataProvider */ - public function testExport($fixtures, $skus, $skippedAttributes = []) + public function testImportExport(array $fixtures, array $skus, array $skippedAttributes = []): void { $this->fixtures = $fixtures; - $this->executeFixtures($fixtures, $skus); + $this->executeFixtures($fixtures); $this->modifyData($skus); $skippedAttributes = array_merge(self::$skippedAttributes, $skippedAttributes); - $this->executeExportTest($skus, $skippedAttributes); + $csvFile = $this->executeExportTest($skus, $skippedAttributes); + + $this->executeImportReplaceTest($skus, $skippedAttributes, false, $csvFile); + $this->executeImportReplaceTest($skus, $skippedAttributes, true, $csvFile); + $this->executeImportDeleteTest($skus, $csvFile); } - abstract public function exportImportDataProvider(); + /** + * Provide data for import/export. + * + * @return array + */ + abstract public function exportImportDataProvider(): array; /** + * Modify data. + * * @param array $skus + * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - protected function modifyData($skus) + protected function modifyData(array $skus): void { } /** + * Prepare product. + * * @param \Magento\Catalog\Model\Product $product + * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function prepareProduct($product) + public function prepareProduct(\Magento\Catalog\Model\Product $product): void { } - protected function executeExportTest($skus, $skippedAttributes) + /** + * Execute export test. + * + * @param array $skus + * @param array $skippedAttributes + * @return string + * @throws \Magento\Framework\Exception\NoSuchEntityException + */ + protected function executeExportTest(array $skus, array $skippedAttributes): string { $index = 0; $ids = []; @@ -140,10 +179,23 @@ protected function executeExportTest($skus, $skippedAttributes) $this->assertEqualsSpecificAttributes($origProducts[$index], $newProduct); } + + return $csvfile; } - private function assertEqualsOtherThanSkippedAttributes($expected, $actual, $skippedAttributes) - { + /** + * Assert data equals (ignore skipped attributes). + * + * @param array $expected + * @param array $actual + * @param array $skippedAttributes + * @return void + */ + private function assertEqualsOtherThanSkippedAttributes( + array $expected, + array $actual, + array $skippedAttributes + ): void { foreach ($expected as $key => $value) { if (is_object($value) || in_array($key, $skippedAttributes)) { continue; @@ -158,134 +210,93 @@ private function assertEqualsOtherThanSkippedAttributes($expected, $actual, $ski } /** - * @magentoAppArea adminhtml - * @magentoDbIsolation disabled - * @magentoAppIsolation enabled + * Execute import test with delete behavior. * - * @param array $fixtures - * @param string[] $skus - * @dataProvider exportImportDataProvider - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @param array $skus + * @param string|null $csvFile + * @return void */ - public function testImportDelete($fixtures, $skus, $skippedAttributes = []) - { - $this->fixtures = $fixtures; - $this->executeFixtures($fixtures, $skus); - $this->modifyData($skus); - $this->executeImportDeleteTest($skus); - } - - protected function executeImportDeleteTest($skus) + protected function executeImportDeleteTest(array $skus, string $csvFile = null): void { - $csvfile = $this->exportProducts(); - $this->importProducts($csvfile, \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE); - /** @var \Magento\Catalog\Model\Product $product */ - $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); + $csvFile = $csvFile ?? $this->exportProducts(); + $this->importProducts($csvFile, \Magento\ImportExport\Model\Import::BEHAVIOR_DELETE); foreach ($skus as $sku) { $productId = $this->productResource->getIdBySku($sku); - $product->load($productId); - $this->assertNull($product->getId()); + $this->assertFalse($productId); } } /** - * Execute fixtures + * Execute fixtures. * - * @param array $skus * @param array $fixtures + * @param bool $rollback * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - protected function executeFixtures($fixtures, $skus = []) + protected function executeFixtures(array $fixtures, bool $rollback = false) { foreach ($fixtures as $fixture) { - $fixturePath = $this->fileSystem->getDirectoryRead(DirectoryList::ROOT) - ->getAbsolutePath('/dev/tests/integration/testsuite/' . $fixture); + $fixturePath = $this->resolveFixturePath($fixture, $rollback); include $fixturePath; } } /** - * Execute rollback fixtures + * Resolve fixture path. * - * @param array $fixtures - * @return void + * @param string $fixture + * @param bool $rollback + * @return string */ - private function executeRollbackFixtures($fixtures) + private function resolveFixturePath(string $fixture, bool $rollback = false) { - foreach ($fixtures as $fixture) { - $fixturePath = $this->fileSystem->getDirectoryRead(DirectoryList::ROOT) - ->getAbsolutePath('/dev/tests/integration/testsuite/' . $fixture); + $fixturePath = $this->fileSystem->getDirectoryRead(DirectoryList::ROOT) + ->getAbsolutePath('/dev/tests/integration/testsuite/' . $fixture); + if ($rollback) { $fileInfo = pathinfo($fixturePath); $extension = ''; if (isset($fileInfo['extension'])) { $extension = '.' . $fileInfo['extension']; } - $rollbackfixturePath = $fileInfo['dirname'] . '/' . $fileInfo['filename'] . '_rollback' . $extension; - if (file_exists($rollbackfixturePath)) { - include $rollbackfixturePath; - } + $fixturePath = $fileInfo['dirname'] . '/' . $fileInfo['filename'] . '_rollback' . $extension; } + + return $fixturePath; } /** + * Assert that specific attributes equal. + * * @param \Magento\Catalog\Model\Product $expectedProduct * @param \Magento\Catalog\Model\Product $actualProduct * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - protected function assertEqualsSpecificAttributes($expectedProduct, $actualProduct) - { + protected function assertEqualsSpecificAttributes( + \Magento\Catalog\Model\Product $expectedProduct, + \Magento\Catalog\Model\Product $actualProduct + ): void { // check custom options } /** - * @magentoAppArea adminhtml - * @magentoDbIsolation disabled - * @magentoAppIsolation enabled + * Execute import test with replace behavior. * - * @param array $fixtures - * @param string[] $skus - * @param string[] $skippedAttributes - * @dataProvider importReplaceDataProvider - */ - public function testImportReplace($fixtures, $skus, $skippedAttributes = []) - { - $this->fixtures = $fixtures; - $this->executeFixtures($fixtures, $skus); - $this->modifyData($skus); - $skippedAttributes = array_merge(self::$skippedAttributes, $skippedAttributes); - $this->executeImportReplaceTest($skus, $skippedAttributes); - } - - /** - * @magentoAppArea adminhtml - * @magentoDbIsolation disabled - * @magentoAppIsolation enabled - * - * @param array $fixtures - * @param string[] $skus - * @param string[] $skippedAttributes - * @dataProvider importReplaceDataProvider - */ - public function testImportReplaceWithPagination($fixtures, $skus, $skippedAttributes = []) - { - $this->fixtures = $fixtures; - $this->executeFixtures($fixtures, $skus); - $this->modifyData($skus); - $skippedAttributes = array_merge(self::$skippedAttributes, $skippedAttributes); - $this->executeImportReplaceTest($skus, $skippedAttributes, true); - } - - /** * @param string[] $skus * @param string[] $skippedAttributes * @param bool $usePagination - * + * @param string|null $csvfile + * @return void + * @throws \Magento\Framework\Exception\NoSuchEntityException * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - protected function executeImportReplaceTest($skus, $skippedAttributes, $usePagination = false) - { + protected function executeImportReplaceTest( + $skus, + $skippedAttributes, + $usePagination = false, + string $csvfile = null + ) { $replacedAttributes = [ 'row_id', 'entity_id', @@ -293,6 +304,7 @@ protected function executeImportReplaceTest($skus, $skippedAttributes, $usePagin 'media_gallery' ]; $skippedAttributes = array_merge($replacedAttributes, $skippedAttributes); + $this->cleanAttributesCache(); $index = 0; $ids = []; @@ -316,15 +328,15 @@ protected function executeImportReplaceTest($skus, $skippedAttributes, $usePagin $itemsPerPageProperty->setValue($exportProduct, 1); } - $csvfile = $this->exportProducts($exportProduct); + $csvfile = $csvfile ?? $this->exportProducts($exportProduct); $this->importProducts($csvfile, \Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE); while ($index > 0) { $index--; $newProduct = $productRepository->get($skus[$index], false, Store::DEFAULT_STORE_ID, true); // check original product is deleted - $origProduct = $this->objectManager->create(\Magento\Catalog\Model\Product::class)->load($ids[$index]); - $this->assertNull($origProduct->getId()); + $productId = $this->productResource->getIdBySku($ids[$index]); + $this->assertFalse($productId); // check new product data // @todo uncomment or remove after MAGETWO-49806 resolved @@ -342,7 +354,7 @@ protected function executeImportReplaceTest($skus, $skippedAttributes, $usePagin array_filter($origProductData[$attribute]) : $origProductData[$attribute]; if (!empty($expected)) { - $actual = isset($newProductData[$attribute]) ? $newProductData[$attribute] : null; + $actual = $newProductData[$attribute] ?? null; $actual = is_array($actual) ? array_filter($actual) : $actual; $this->assertNotEquals($expected, $actual, $attribute . ' is expected to be changed'); } @@ -352,7 +364,7 @@ protected function executeImportReplaceTest($skus, $skippedAttributes, $usePagin } /** - * Export products in the system + * Export products in the system. * * @param \Magento\CatalogImportExport\Model\Export\Product|null $exportProduct * @return string Return exported file name @@ -371,17 +383,18 @@ private function exportProducts(\Magento\CatalogImportExport\Model\Export\Produc ) ); $this->assertNotEmpty($exportProduct->export()); + return $csvfile; } /** - * Import products from the given file + * Import products from the given file. * * @param string $csvfile * @param string $behavior * @return void */ - private function importProducts($csvfile, $behavior) + private function importProducts(string $csvfile, string $behavior): void { /** @var \Magento\CatalogImportExport\Model\Import\Product $importModel */ $importModel = $this->objectManager->create( @@ -437,15 +450,33 @@ private function importProducts($csvfile, $behavior) } /** + * Extract error message. + * * @param \Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingError[] $errors * @return string */ - private function extractErrorMessage($errors) + private function extractErrorMessage(array $errors): string { $errorMessage = ''; foreach ($errors as $error) { $errorMessage = "\n" . $error->getErrorMessage(); } + return $errorMessage; } + + /** + * Clean import attribute cache. + * + * @return void + */ + private function cleanAttributesCache(): void + { + foreach (self::$attributesToRefresh as $attributeCode) { + $attributeId = Import\Product\Type\AbstractType::$attributeCodeToId[$attributeCode] ?? null; + if ($attributeId !== null) { + unset(Import\Product\Type\AbstractType::$commonAttributesCache[$attributeId]); + } + } + } } diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/ProductTest.php index 11cc73e2cf944..c39acbc338727 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/ProductTest.php @@ -10,18 +10,10 @@ */ class ProductTest extends AbstractProductExportImportTestCase { - /** - * Set up - */ - protected function setUp() - { - $this->markTestSkipped('MAGETWO-97378'); - } - /** * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ - public function exportImportDataProvider() + public function exportImportDataProvider(): array { return [ 'product_export_data' => [ @@ -144,11 +136,6 @@ public function exportImportDataProvider() ]; } - public function importReplaceDataProvider() - { - return $this->exportImportDataProvider(); - } - /** * Fixing https://github.com/magento-engcom/import-export-improvements/issues/50 means that during import images * can now get renamed for this we need to skip the attribute checking and instead check that the images contain @@ -158,8 +145,10 @@ public function importReplaceDataProvider() * @param \Magento\Catalog\Model\Product $expectedProduct * @param \Magento\Catalog\Model\Product $actualProduct */ - protected function assertEqualsSpecificAttributes($expectedProduct, $actualProduct) - { + protected function assertEqualsSpecificAttributes( + \Magento\Catalog\Model\Product $expectedProduct, + \Magento\Catalog\Model\Product $actualProduct + ): void { if (!empty($actualProduct->getImage()) && !empty($expectedProduct->getImage()) ) { diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableImportExport/Model/ConfigurableTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableImportExport/Model/ConfigurableTest.php index 5184a37563317..338daa56450d4 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableImportExport/Model/ConfigurableTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableImportExport/Model/ConfigurableTest.php @@ -9,7 +9,10 @@ class ConfigurableTest extends AbstractProductExportImportTestCase { - public function exportImportDataProvider() + /** + * @return array + */ + public function exportImportDataProvider(): array { return [ 'configurable-product' => [ @@ -34,11 +37,12 @@ public function exportImportDataProvider() } /** - * @param \Magento\Catalog\Model\Product $expectedProduct - * @param \Magento\Catalog\Model\Product $actualProduct + * @inheritdoc */ - protected function assertEqualsSpecificAttributes($expectedProduct, $actualProduct) - { + protected function assertEqualsSpecificAttributes( + \Magento\Catalog\Model\Product $expectedProduct, + \Magento\Catalog\Model\Product $actualProduct + ): void { /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable $productType */ $productType = $expectedProduct->getTypeInstance(); $expectedAssociatedProducts = $productType->getUsedProductCollection($expectedProduct); @@ -95,12 +99,16 @@ protected function assertEqualsSpecificAttributes($expectedProduct, $actualProdu } } - public function importReplaceDataProvider() - { - $data = $this->exportImportDataProvider(); - foreach ($data as $key => $value) { - $data[$key][2] = array_merge($value[2], ['_cache_instance_product_set_attributes']); - } - return $data; + /** + * @inheritdoc + */ + protected function executeImportReplaceTest( + $skus, + $skippedAttributes, + $usePagination = false, + string $csvfile = null + ) { + $skippedAttributes = array_merge($skippedAttributes, ['_cache_instance_product_set_attributes']); + parent::executeImportReplaceTest($skus, $skippedAttributes, $usePagination, $csvfile); } } diff --git a/dev/tests/integration/testsuite/Magento/DownloadableImportExport/Model/DownloadableTest.php b/dev/tests/integration/testsuite/Magento/DownloadableImportExport/Model/DownloadableTest.php index c80cd13a1683b..d0e4471e2ea68 100644 --- a/dev/tests/integration/testsuite/Magento/DownloadableImportExport/Model/DownloadableTest.php +++ b/dev/tests/integration/testsuite/Magento/DownloadableImportExport/Model/DownloadableTest.php @@ -9,7 +9,10 @@ class DownloadableTest extends AbstractProductExportImportTestCase { - public function exportImportDataProvider() + /** + * @return array + */ + public function exportImportDataProvider(): array { return [ 'downloadable-product' => [ @@ -31,79 +34,32 @@ public function exportImportDataProvider() ]; } - public function importReplaceDataProvider() - { - return $this->exportImportDataProvider(); - } - - /** - * @param array $fixtures - * @param string[] $skus - * @param string[] $skippedAttributes - * @dataProvider exportImportDataProvider - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * - * @todo remove after MAGETWO-38240 resolved - */ - public function testExport($fixtures, $skus, $skippedAttributes = [], $rollbackFixtures = []) - { - $this->markTestSkipped('Uncomment after MAGETWO-38240 resolved'); - } - - /** - * @param array $fixtures - * @param string[] $skus - * @dataProvider exportImportDataProvider - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * - * @todo remove after MAGETWO-38240 resolved - */ - public function testImportDelete($fixtures, $skus, $skippedAttributes = [], $rollbackFixtures = []) - { - $this->markTestSkipped('Uncomment after MAGETWO-38240 resolved'); - } - /** - * @magentoAppArea adminhtml - * @magentoDbIsolation enabled - * @magentoAppIsolation enabled - * - * @param array $fixtures - * @param string[] $skus - * @param string[] $skippedAttributes - * @dataProvider importReplaceDataProvider - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * Run import/export tests. * - * @todo remove after MAGETWO-38240 resolved - */ - public function testImportReplace($fixtures, $skus, $skippedAttributes = [], $rollbackFixtures = []) - { - $this->markTestSkipped('Uncomment after MAGETWO-38240 resolved'); - } - - /** * @magentoAppArea adminhtml - * @magentoDbIsolation enabled + * @magentoDbIsolation disabled * @magentoAppIsolation enabled * * @param array $fixtures * @param string[] $skus * @param string[] $skippedAttributes - * @dataProvider importReplaceDataProvider - * + * @return void + * @dataProvider exportImportDataProvider * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function testImportReplaceWithPagination($fixtures, $skus, $skippedAttributes = []) + public function testImportExport(array $fixtures, array $skus, array $skippedAttributes = []): void { $this->markTestSkipped('Uncomment after MAGETWO-38240 resolved'); } /** - * @param \Magento\Catalog\Model\Product $expectedProduct - * @param \Magento\Catalog\Model\Product $actualProduct + * @inheritdoc */ - protected function assertEqualsSpecificAttributes($expectedProduct, $actualProduct) - { + protected function assertEqualsSpecificAttributes( + \Magento\Catalog\Model\Product $expectedProduct, + \Magento\Catalog\Model\Product $actualProduct + ): void { $expectedProductLinks = $expectedProduct->getExtensionAttributes()->getDownloadableProductLinks(); $expectedProductSamples = $expectedProduct->getExtensionAttributes()->getDownloadableProductSamples(); diff --git a/dev/tests/integration/testsuite/Magento/GroupedImportExport/Model/GroupedTest.php b/dev/tests/integration/testsuite/Magento/GroupedImportExport/Model/GroupedTest.php index 67817b068ff09..afd515757ae4b 100644 --- a/dev/tests/integration/testsuite/Magento/GroupedImportExport/Model/GroupedTest.php +++ b/dev/tests/integration/testsuite/Magento/GroupedImportExport/Model/GroupedTest.php @@ -9,7 +9,10 @@ class GroupedTest extends AbstractProductExportImportTestCase { - public function exportImportDataProvider() + /** + * @return array + */ + public function exportImportDataProvider(): array { return [ 'grouped-product' => [ @@ -23,17 +26,13 @@ public function exportImportDataProvider() ]; } - public function importReplaceDataProvider() - { - return $this->exportImportDataProvider(); - } - /** - * @param \Magento\Catalog\Model\Product $expectedProduct - * @param \Magento\Catalog\Model\Product $actualProduct + * @inheritdoc */ - protected function assertEqualsSpecificAttributes($expectedProduct, $actualProduct) - { + protected function assertEqualsSpecificAttributes( + \Magento\Catalog\Model\Product $expectedProduct, + \Magento\Catalog\Model\Product $actualProduct + ): void { $expectedAssociatedProducts = $expectedProduct->getTypeInstance()->getAssociatedProducts($expectedProduct); $actualAssociatedProducts = $actualProduct->getTypeInstance()->getAssociatedProducts($actualProduct); From 065e62863c547217b048537fb8b4e5fcb0d39b4a Mon Sep 17 00:00:00 2001 From: Andrew Molina <amolina@adobe.com> Date: Thu, 17 Jan 2019 12:19:41 -0600 Subject: [PATCH 071/121] MC-6296: Update DCTRequest Added private functions to build SoftwareName and SoftwareVersion for request --- app/code/Magento/Dhl/Model/Carrier.php | 24 +++++++++- .../Dhl/Test/Unit/Model/CarrierTest.php | 46 ++++++++++++++++++- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index bd129eb6111a5..769b440396fbe 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -1022,8 +1022,8 @@ protected function _buildQuotesRequestXml() $nodeServiceHeader->addChild('Password', (string) $this->getConfigData('password')); $nodeMetaData = $nodeRequest->addChild('MetaData'); - $nodeMetaData->addChild('SoftwareName', $this->productMetadata->getName()); - $nodeMetaData->addChild('SoftwareVersion', $this->productMetadata->getVersion()); + $nodeMetaData->addChild('SoftwareName', $this->buildSoftwareName()); + $nodeMetaData->addChild('SoftwareVersion', $this->buildSoftwareVersion()); $nodeFrom = $nodeGetQuote->addChild('From'); $nodeFrom->addChild('CountryCode', $rawRequest->getOrigCountryId()); @@ -2036,4 +2036,24 @@ private function buildMessageReference(string $servicePrefix): string return str_replace('.', '', uniqid("MAGE_{$servicePrefix}_", true)); } + + /** + * Builds a string to be used as the request SoftwareName. + * + * @return string + */ + private function buildSoftwareName(): string + { + return substr($this->productMetadata->getName(), 0, 30); + } + + /** + * Builds a string to be used as the request SoftwareVersion. + * + * @return string + */ + private function buildSoftwareVersion(): string + { + return substr($this->productMetadata->getVersion(), 0, 10); + } } diff --git a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php index 785ddb854fe7a..2fc0f1c43f949 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php @@ -566,6 +566,40 @@ public function testBuildMessageReference() $method->invoke($this->model, 'TEST'); } + /** + * Tests that the built software name string is of the appropriate format. + * + * @throws \ReflectionException + */ + public function testBuildSoftwareName() + { + $method = new \ReflectionMethod($this->model, 'buildSoftwareName'); + $method->setAccessible(true); + + $name = $method->invoke($this->model); + self::assertLessThanOrEqual(30, $name); + + $nameExceedsLength = $method->invoke($this->model); + self::assertLessThanOrEqual(30, $nameExceedsLength); + } + + /** + * Tests that the built software version string is of the appropriate format. + * + * @throws \ReflectionException + */ + public function testBuildSoftwareVersion() + { + $method = new \ReflectionMethod($this->model, 'buildSoftwareVersion'); + $method->setAccessible(true); + + $version = $method->invoke($this->model); + self::assertLessThanOrEqual(10, strlen($version)); + + $versionExceedsLength = $method->invoke($this->model); + self::assertLessThanOrEqual(10, strlen($versionExceedsLength)); + } + /** * Creates mock for XML factory. * @@ -755,8 +789,16 @@ private function getHttpClientFactory(): MockObject private function getProductMetadata(): MockObject { $productMetadata = $this->createMock(\Magento\Framework\App\ProductMetadata::class); - $productMetadata->method('getName')->willReturn('Magento'); - $productMetadata->method('getVersion')->willReturn('2.3.1'); + + $productMetadata->method('getName')->willReturnOnConsecutiveCalls( + 'Magento', + str_pad('Magento', 24, '_') + ); + + $productMetadata->method('getVersion')->willReturnOnConsecutiveCalls( + '2.3.1', + 'dev-MC-1000' + ); return $productMetadata; } From ba9b12e0502baafa8dc8f67ef33935e896284472 Mon Sep 17 00:00:00 2001 From: Joan He <johe@magento.com> Date: Thu, 17 Jan 2019 15:41:39 -0600 Subject: [PATCH 072/121] MC-6295: Update ShipmentValidationRequest --- app/code/Magento/Dhl/Model/Carrier.php | 172 ++++++++---------- .../Dhl/Test/Unit/Model/CarrierTest.php | 138 ++++++-------- .../Dhl/Test/Unit/Model/_files/countries.xml | 58 +++--- .../Unit/Model/_files/shipment_request.xml | 91 +++++++++ app/code/Magento/Dhl/etc/countries.xml | 56 +++--- 5 files changed, 282 insertions(+), 233 deletions(-) create mode 100644 app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index e765b33bfdba1..7e43c2dbd5d18 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -7,6 +7,7 @@ namespace Magento\Dhl\Model; use Magento\Catalog\Model\Product\Type; +use Magento\Framework\App\ProductMetadataInterface; use Magento\Framework\Module\Dir; use Magento\Sales\Exception\DocumentValidationException; use Magento\Sales\Model\Order\Shipment; @@ -213,6 +214,11 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin */ private $xmlValidator; + /** + * @var ProductMetadataInterface + */ + private $productMetadata; + /** * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory @@ -239,7 +245,8 @@ class Carrier extends \Magento\Dhl\Model\AbstractDhl implements \Magento\Shippin * @param \Magento\Framework\Stdlib\DateTime $dateTime * @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory * @param array $data - * @param \Magento\Dhl\Model\Validator\XmlValidator $xmlValidator + * @param \Magento\Dhl\Model\Validator\XmlValidator|null $xmlValidator + * @param ProductMetadataInterface|null $productMetadata * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -268,7 +275,8 @@ public function __construct( \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory, array $data = [], - \Magento\Dhl\Model\Validator\XmlValidator $xmlValidator = null + \Magento\Dhl\Model\Validator\XmlValidator $xmlValidator = null, + ProductMetadataInterface $productMetadata = null ) { $this->readFactory = $readFactory; $this->_carrierHelper = $carrierHelper; @@ -302,6 +310,8 @@ public function __construct( } $this->xmlValidator = $xmlValidator ?: \Magento\Framework\App\ObjectManager::getInstance()->get(XmlValidator::class); + $this->productMetadata = $productMetadata + ?: \Magento\Framework\App\ObjectManager::getInstance()->get(ProductMetadataInterface::class); } /** @@ -1393,44 +1403,41 @@ protected function _doRequest() { $rawRequest = $this->_request; - $originRegion = $this->getCountryParams( - $this->_scopeConfig->getValue( - Shipment::XML_PATH_STORE_COUNTRY_ID, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE, - $this->getStore() - ) - )->getRegion(); - - if (!$originRegion) { - throw new \Magento\Framework\Exception\LocalizedException(__('Wrong Region')); - } - - if ($originRegion == 'AM') { - $originRegion = ''; - } - $xmlStr = '<?xml version="1.0" encoding="UTF-8"?>' . - '<req:ShipmentValidateRequest' . - $originRegion . + '<req:ShipmentRequest' . ' xmlns:req="http://www.dhl.com"' . ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . - ' xsi:schemaLocation="http://www.dhl.com ship-val-req' . - ($originRegion ? '_' . - $originRegion : '') . - '.xsd" />'; + ' xsi:schemaLocation="http://www.dhl.com ship-val-global-req-6.2.xsd"' . + ' schemaVersion="6.2" />'; $xml = $this->_xmlElFactory->create(['data' => $xmlStr]); $nodeRequest = $xml->addChild('Request', '', ''); $nodeServiceHeader = $nodeRequest->addChild('ServiceHeader'); + $nodeServiceHeader->addChild('MessageTime', $this->buildMessageTimestamp()); + // MessageReference must be 28 to 32 chars. + $nodeServiceHeader->addChild( + 'MessageReference', + $this->buildMessageReference(self::SERVICE_PREFIX_SHIPVAL) + ); $nodeServiceHeader->addChild('SiteID', (string)$this->getConfigData('id')); $nodeServiceHeader->addChild('Password', (string)$this->getConfigData('password')); - if (!$originRegion) { - $xml->addChild('RequestedPickupTime', 'N', ''); - } - if ($originRegion !== 'AP') { - $xml->addChild('NewShipper', 'N', ''); + $nodeMetaData = $nodeRequest->addChild('MetaData'); + $nodeMetaData->addChild('SoftwareName', $this->productMetadata->getName()); + $nodeMetaData->addChild('SoftwareVersion', $this->productMetadata->getVersion()); + + $originRegion = $this->getCountryParams( + $this->_scopeConfig->getValue( + Shipment::XML_PATH_STORE_COUNTRY_ID, + \Magento\Store\Model\ScopeInterface::SCOPE_STORE, + $this->getStore() + ) + )->getRegion(); + if ($originRegion) { + $xml->addChild('RegionCode', $originRegion, ''); } + $xml->addChild('RequestedPickupTime', 'N', ''); + $xml->addChild('NewShipper', 'N', ''); $xml->addChild('LanguageCode', 'EN', ''); $xml->addChild('PiecesEnabled', 'Y', ''); @@ -1472,8 +1479,9 @@ protected function _doRequest() } $nodeConsignee->addChild('City', $rawRequest->getRecipientAddressCity()); - if ($originRegion !== 'AP') { - $nodeConsignee->addChild('Division', $rawRequest->getRecipientAddressStateOrProvinceCode()); + $recipientAddressStateOrProvinceCode = $rawRequest->getRecipientAddressStateOrProvinceCode(); + if ($recipientAddressStateOrProvinceCode) { + $nodeConsignee->addChild('Division', $recipientAddressStateOrProvinceCode); } $nodeConsignee->addChild('PostalCode', $rawRequest->getRecipientAddressPostalCode()); $nodeConsignee->addChild('CountryCode', $rawRequest->getRecipientAddressCountryCode()); @@ -1517,15 +1525,13 @@ protected function _doRequest() $nodeReference->addChild('ReferenceType', 'St'); /** Shipment Details */ - $this->_shipmentDetails($xml, $rawRequest, $originRegion); + $this->_shipmentDetails($xml, $rawRequest); /** Shipper */ $nodeShipper = $xml->addChild('Shipper', '', ''); $nodeShipper->addChild('ShipperID', (string)$this->getConfigData('account')); $nodeShipper->addChild('CompanyName', $rawRequest->getShipperContactCompanyName()); - if ($originRegion !== 'AP') { - $nodeShipper->addChild('RegisteredAccount', (string)$this->getConfigData('account')); - } + $nodeShipper->addChild('RegisteredAccount', (string)$this->getConfigData('account')); $address = $rawRequest->getShipperAddressStreet1() . ' ' . $rawRequest->getShipperAddressStreet2(); $address = $this->string->split($address, 35, false, true); @@ -1538,8 +1544,9 @@ protected function _doRequest() } $nodeShipper->addChild('City', $rawRequest->getShipperAddressCity()); - if ($originRegion !== 'AP') { - $nodeShipper->addChild('Division', $rawRequest->getShipperAddressStateOrProvinceCode()); + $shipperAddressStateOrProvinceCode = $rawRequest->getShipperAddressStateOrProvinceCode(); + if ($shipperAddressStateOrProvinceCode) { + $nodeShipper->addChild('Division', $shipperAddressStateOrProvinceCode); } $nodeShipper->addChild('PostalCode', $rawRequest->getShipperAddressPostalCode()); $nodeShipper->addChild('CountryCode', $rawRequest->getShipperAddressCountryCode()); @@ -1597,13 +1604,6 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '') $nodeShipmentDetails = $xml->addChild('ShipmentDetails', '', ''); $nodeShipmentDetails->addChild('NumberOfPieces', count($rawRequest->getPackages())); - if ($originRegion) { - $nodeShipmentDetails->addChild( - 'CurrencyCode', - $this->_storeManager->getWebsite($this->_request->getWebsiteId())->getBaseCurrencyCode() - ); - } - $nodePieces = $nodeShipmentDetails->addChild('Pieces', '', ''); /* @@ -1622,18 +1622,12 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '') } $nodePiece->addChild('PieceID', ++$i); $nodePiece->addChild('PackageType', $packageType); - $nodePiece->addChild('Weight', sprintf('%.1f', $package['params']['weight'])); + $nodePiece->addChild('Weight', sprintf('%.3f', $package['params']['weight'])); $params = $package['params']; if ($params['width'] && $params['length'] && $params['height']) { - if (!$originRegion) { - $nodePiece->addChild('Width', round($params['width'])); - $nodePiece->addChild('Height', round($params['height'])); - $nodePiece->addChild('Depth', round($params['length'])); - } else { - $nodePiece->addChild('Depth', round($params['length'])); - $nodePiece->addChild('Width', round($params['width'])); - $nodePiece->addChild('Height', round($params['height'])); - } + $nodePiece->addChild('Width', round($params['width'])); + $nodePiece->addChild('Height', round($params['height'])); + $nodePiece->addChild('Depth', round($params['length'])); } $content = []; foreach ($package['items'] as $item) { @@ -1642,51 +1636,33 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '') $nodePiece->addChild('PieceContents', substr(implode(',', $content), 0, 34)); } - if (!$originRegion) { - $nodeShipmentDetails->addChild('Weight', sprintf('%.1f', $rawRequest->getPackageWeight())); - $nodeShipmentDetails->addChild('WeightUnit', substr($this->_getWeightUnit(), 0, 1)); - $nodeShipmentDetails->addChild('GlobalProductCode', $rawRequest->getShippingMethod()); - $nodeShipmentDetails->addChild('LocalProductCode', $rawRequest->getShippingMethod()); - $nodeShipmentDetails->addChild('Date', $this->_coreDate->date('Y-m-d')); - $nodeShipmentDetails->addChild('Contents', 'DHL Parcel'); - /** - * The DoorTo Element defines the type of delivery service that applies to the shipment. - * The valid values are DD (Door to Door), DA (Door to Airport) , AA and DC (Door to - * Door non-compliant) - */ - $nodeShipmentDetails->addChild('DoorTo', 'DD'); - $nodeShipmentDetails->addChild('DimensionUnit', substr($this->_getDimensionUnit(), 0, 1)); - if ($package['params']['container'] == self::DHL_CONTENT_TYPE_NON_DOC) { - $packageType = 'CP'; - } - $nodeShipmentDetails->addChild('PackageType', $packageType); - if ($this->isDutiable($rawRequest->getOrigCountryId(), $rawRequest->getDestCountryId())) { - $nodeShipmentDetails->addChild('IsDutiable', 'Y'); - } - $nodeShipmentDetails->addChild( - 'CurrencyCode', - $this->_storeManager->getWebsite($this->_request->getWebsiteId())->getBaseCurrencyCode() - ); - } else { - if ($package['params']['container'] == self::DHL_CONTENT_TYPE_NON_DOC) { - $packageType = 'CP'; - } - $nodeShipmentDetails->addChild('PackageType', $packageType); - $nodeShipmentDetails->addChild('Weight', sprintf('%.3f', $rawRequest->getPackageWeight())); - $nodeShipmentDetails->addChild('DimensionUnit', substr($this->_getDimensionUnit(), 0, 1)); - $nodeShipmentDetails->addChild('WeightUnit', substr($this->_getWeightUnit(), 0, 1)); - $nodeShipmentDetails->addChild('GlobalProductCode', $rawRequest->getShippingMethod()); - $nodeShipmentDetails->addChild('LocalProductCode', $rawRequest->getShippingMethod()); - - /** - * The DoorTo Element defines the type of delivery service that applies to the shipment. - * The valid values are DD (Door to Door), DA (Door to Airport) , AA and DC (Door to - * Door non-compliant) - */ - $nodeShipmentDetails->addChild('DoorTo', 'DD'); - $nodeShipmentDetails->addChild('Date', $this->_coreDate->date('Y-m-d')); - $nodeShipmentDetails->addChild('Contents', 'DHL Parcel TEST'); + $nodeShipmentDetails->addChild('Weight', sprintf('%.3f', $rawRequest->getPackageWeight())); + $nodeShipmentDetails->addChild('WeightUnit', substr($this->_getWeightUnit(), 0, 1)); + $nodeShipmentDetails->addChild('GlobalProductCode', $rawRequest->getShippingMethod()); + $nodeShipmentDetails->addChild('LocalProductCode', $rawRequest->getShippingMethod()); + $nodeShipmentDetails->addChild( + 'Date', + $this->_coreDate->date('Y-m-d', strtotime('now + 1day')) + ); + $nodeShipmentDetails->addChild('Contents', 'DHL Parcel'); + /** + * The DoorTo Element defines the type of delivery service that applies to the shipment. + * The valid values are DD (Door to Door), DA (Door to Airport) , AA and DC (Door to + * Door non-compliant) + */ + $nodeShipmentDetails->addChild('DoorTo', 'DD'); + $nodeShipmentDetails->addChild('DimensionUnit', substr($this->_getDimensionUnit(), 0, 1)); + if ($package['params']['container'] == self::DHL_CONTENT_TYPE_NON_DOC) { + $packageType = 'CP'; } + $nodeShipmentDetails->addChild('PackageType', $packageType); + if ($this->isDutiable($rawRequest->getOrigCountryId(), $rawRequest->getDestCountryId())) { + $nodeShipmentDetails->addChild('IsDutiable', 'Y'); + } + $nodeShipmentDetails->addChild( + 'CurrencyCode', + $this->_storeManager->getWebsite($this->_request->getWebsiteId())->getBaseCurrencyCode() + ); } /** diff --git a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php index 311dfe2eac736..82eb379d75be0 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php @@ -8,12 +8,14 @@ use Magento\Dhl\Model\Carrier; use Magento\Dhl\Model\Validator\XmlValidator; use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\ProductMetadataInterface; use Magento\Framework\Filesystem\Directory\Read; use Magento\Framework\Filesystem\Directory\ReadFactory; use Magento\Framework\HTTP\ZendClient; use Magento\Framework\HTTP\ZendClientFactory; use Magento\Framework\Locale\ResolverInterface; use Magento\Framework\Module\Dir\Reader; +use Magento\Framework\Stdlib\DateTime\DateTime; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\Xml\Security; use Magento\Quote\Model\Quote\Address\RateRequest; @@ -89,6 +91,17 @@ class CarrierTest extends \PHPUnit\Framework\TestCase */ private $logger; + /** + * @var DateTime|MockObject + */ + private $coreDateMock; + + /** + * @var ProductMetadataInterface + */ + private $productMetadataMock; + + /** * @inheritdoc */ @@ -143,6 +156,20 @@ protected function setUp() $this->logger = $this->getMockForAbstractClass(LoggerInterface::class); + $this->coreDateMock = $this->getMockBuilder(DateTime::class) + ->disableOriginalConstructor() + ->getMock(); + $this->coreDateMock->method('date') + ->willReturn('currentTime'); + + $this->productMetadataMock = $this->getMockBuilder(ProductMetadataInterface::class) + ->disableOriginalConstructor() + ->getMock(); + $this->productMetadataMock->method('getName') + ->willReturn('Software_Product_Name_30_Char_123456789'); + $this->productMetadataMock->method('getVersion') + ->willReturn('10Char_Ver123456789'); + $this->model = $this->objectManager->getObject( Carrier::class, [ @@ -160,6 +187,8 @@ protected function setUp() 'carrierHelper' => $carrierHelper, 'data' => ['id' => 'dhl', 'store' => '1'], 'xmlValidator' => $this->xmlValidator, + 'coreDate' => $this->coreDateMock, + 'productMetadata' => $this->productMetadataMock ] ); } @@ -308,11 +337,26 @@ public function testCollectRatesFail() /** * Test request to shipment sends valid xml values. + * + * @param string $origCountryId + * @param string $expectedRegionCode + * @dataProvider requestToShipmentDataProvider */ - public function testRequestToShipment() + public function testRequestToShipment(string $origCountryId, string $expectedRegionCode) { + $expectedRequestXml = file_get_contents(__DIR__ . '/_files/shipment_request.xml'); + $scopeConfigValueMap = [ + ['carriers/dhl/account', 'store', null, '1234567890'], + ['carriers/dhl/gateway_url', 'store', null, 'https://xmlpi-ea.dhl.com/XMLShippingServlet'], + ['carriers/dhl/id', 'store', null, 'some ID'], + ['carriers/dhl/password', 'store', null, 'some password'], + ['carriers/dhl/content_type', 'store', null, 'N'], + ['carriers/dhl/nondoc_methods', 'store', null, '1,3,4,8,P,Q,E,F,H,J,M,V,Y'], + ['shipping/origin/country_id', 'store', null, $origCountryId], + ]; + $this->scope->method('getValue') - ->willReturnCallback([$this, 'scopeConfigGetValue']); + ->willReturnMap($scopeConfigValueMap); $this->httpResponse->method('getBody') ->willReturn(utf8_encode(file_get_contents(__DIR__ . '/_files/response_shipping_label.xml'))); @@ -352,7 +396,7 @@ public function testRequestToShipment() $this->request->method('getPackages') ->willReturn($packages); $this->request->method('getOrigCountryId') - ->willReturn('GB'); + ->willReturn($origCountryId); $this->request->method('setPackages') ->willReturnSelf(); $this->request->method('setPackageWeight') @@ -382,7 +426,17 @@ public function testRequestToShipment() $rawPostData->setAccessible(true); $this->assertNotNull($result); - $this->assertContains('<Weight>0.454</Weight>', $rawPostData->getValue($this->httpClient)); + $requestXml = $rawPostData->getValue($this->httpClient); + $requestElement = new Element($requestXml); + $this->assertEquals($expectedRegionCode, $requestElement->RegionCode->__toString()); + $requestElement->RegionCode = 'Checked'; + $messageReference = $requestElement->Request->ServiceHeader->MessageReference->__toString(); + $this->assertStringStartsWith('MAGE_SHIP_', $messageReference); + $this->assertGreaterThanOrEqual(28, strlen($messageReference)); + $this->assertLessThanOrEqual(32, strlen($messageReference)); + $requestElement->Request->ServiceHeader->MessageReference = 'MAGE_SHIP_CHECKED'; + $expectedRequestElement = new Element($expectedRequestXml); + $this->assertXmlStringEqualsXmlString($expectedRequestElement->asXML(), $requestElement->asXML()); } /** @@ -394,86 +448,14 @@ public function requestToShipmentDataProvider() { return [ [ - 'GB' + 'GB', 'EU' ], [ - null + 'SG', 'AP' ] ]; } - /** - * Test that shipping label request for origin country from AP region doesn't contain restricted fields. - * - * @return void - */ - public function testShippingLabelRequestForAsiaPacificRegion() - { - $this->scope->method('getValue') - ->willReturnMap( - [ - ['shipping/origin/country_id', ScopeInterface::SCOPE_STORE, null, 'SG'], - ['carriers/dhl/gateway_url', ScopeInterface::SCOPE_STORE, null, 'https://xmlpi-ea.dhl.com'], - ] - ); - - $this->httpResponse->method('getBody') - ->willReturn(utf8_encode(file_get_contents(__DIR__ . '/_files/response_shipping_label.xml'))); - - $packages = [ - 'package' => [ - 'params' => [ - 'width' => '1', - 'length' => '1', - 'height' => '1', - 'dimension_units' => 'INCH', - 'weight_units' => 'POUND', - 'weight' => '0.45', - 'customs_value' => '10.00', - 'container' => Carrier::DHL_CONTENT_TYPE_NON_DOC, - ], - 'items' => [ - 'item1' => [ - 'name' => 'item_name', - ], - ], - ], - ]; - - $this->request->method('getPackages')->willReturn($packages); - $this->request->method('getOrigCountryId')->willReturn('SG'); - $this->request->method('setPackages')->willReturnSelf(); - $this->request->method('setPackageWeight')->willReturnSelf(); - $this->request->method('setPackageValue')->willReturnSelf(); - $this->request->method('setValueWithDiscount')->willReturnSelf(); - $this->request->method('setPackageCustomsValue')->willReturnSelf(); - - $result = $this->model->requestToShipment($this->request); - - $reflectionClass = new \ReflectionObject($this->httpClient); - $rawPostData = $reflectionClass->getProperty('raw_post_data'); - $rawPostData->setAccessible(true); - - $this->assertNotNull($result); - $requestXml = $rawPostData->getValue($this->httpClient); - - $this->assertNotContains( - 'NewShipper', - $requestXml, - 'NewShipper is restricted field for AP region' - ); - $this->assertNotContains( - 'Division', - $requestXml, - 'Division is restricted field for AP region' - ); - $this->assertNotContains( - 'RegisteredAccount', - $requestXml, - 'RegisteredAccount is restricted field for AP region' - ); - } - /** * @dataProvider dhlProductsDataProvider * diff --git a/app/code/Magento/Dhl/Test/Unit/Model/_files/countries.xml b/app/code/Magento/Dhl/Test/Unit/Model/_files/countries.xml index 3f28111f229d1..792465ce45942 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/_files/countries.xml +++ b/app/code/Magento/Dhl/Test/Unit/Model/_files/countries.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0"?> <!-- /** * Copyright © Magento, Inc. All rights reserved. @@ -83,7 +83,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Austria</name> <domestic>1</domestic> </AT> @@ -132,7 +132,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Belgium</name> <domestic>1</domestic> </BE> @@ -146,7 +146,7 @@ <currency>BGN</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Bulgaria</name> <domestic>1</domestic> </BG> @@ -257,7 +257,7 @@ <currency>CHF</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Switzerland</name> </CH> <CI> @@ -331,7 +331,7 @@ <currency>CZK</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Czech Republic, The</name> <domestic>1</domestic> </CZ> @@ -339,7 +339,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Germany</name> <domestic>1</domestic> </DE> @@ -353,7 +353,7 @@ <currency>DKK</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Denmark</name> <domestic>1</domestic> </DK> @@ -389,7 +389,7 @@ <currency>EEK</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Estonia</name> <domestic>1</domestic> </EE> @@ -410,7 +410,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Spain</name> <domestic>1</domestic> </ES> @@ -424,7 +424,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Finland</name> <domestic>1</domestic> </FI> @@ -457,7 +457,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>France</name> <domestic>1</domestic> </FR> @@ -471,7 +471,7 @@ <currency>GBP</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>United Kingdom</name> <domestic>1</domestic> </GB> @@ -549,7 +549,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Greece</name> <domestic>1</domestic> </GR> @@ -612,7 +612,7 @@ <currency>HUF</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Hungary</name> <domestic>1</domestic> </HU> @@ -633,7 +633,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Ireland, Republic Of</name> <domestic>1</domestic> </IE> @@ -668,14 +668,14 @@ <currency>ISK</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Iceland</name> </IS> <IT> <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Italy</name> <domestic>1</domestic> </IT> @@ -834,7 +834,7 @@ <currency>LTL</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Lithuania</name> <domestic>1</domestic> </LT> @@ -842,7 +842,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Luxembourg</name> <domestic>1</domestic> </LU> @@ -850,7 +850,7 @@ <currency>LVL</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Latvia</name> <domestic>1</domestic> </LV> @@ -1039,7 +1039,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Netherlands, The</name> <domestic>1</domestic> </NL> @@ -1047,7 +1047,7 @@ <currency>NOK</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Norway</name> </NO> <NP> @@ -1127,7 +1127,7 @@ <currency>PLN</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Poland</name> <domestic>1</domestic> </PL> @@ -1142,7 +1142,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Portugal</name> <domestic>1</domestic> </PT> @@ -1177,7 +1177,7 @@ <currency>RON</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Romania</name> <domestic>1</domestic> </RO> @@ -1231,7 +1231,7 @@ <currency>SEK</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Sweden</name> <domestic>1</domestic> </SE> @@ -1246,7 +1246,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Slovenia</name> <domestic>1</domestic> </SI> @@ -1254,7 +1254,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Slovakia</name> <domestic>1</domestic> </SK> diff --git a/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml b/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml new file mode 100644 index 0000000000000..7a87046b87b76 --- /dev/null +++ b/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="UTF-8"?> +<req:ShipmentRequest xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.dhl.com ship-val-global-req-6.2.xsd" schemaVersion="6.2"> + <Request xmlns=""> + <ServiceHeader> + <MessageTime>currentTime</MessageTime> + <MessageReference>MAGE_SHIP_CHECKED</MessageReference> + <SiteID>some ID</SiteID> + <Password>some password</Password> + </ServiceHeader> + <MetaData> + <SoftwareName>Software_Product_Name_30_Char_</SoftwareName> + <SoftwareVersion>10Char_Ver</SoftwareVersion> + </MetaData> + </Request> + <RegionCode xmlns="">CHECKED</RegionCode> + <RequestedPickupTime xmlns="">N</RequestedPickupTime> + <NewShipper xmlns="">N</NewShipper> + <LanguageCode xmlns="">EN</LanguageCode> + <PiecesEnabled xmlns="">Y</PiecesEnabled> + <Billing xmlns=""> + <ShipperAccountNumber>1234567890</ShipperAccountNumber> + <ShippingPaymentType>S</ShippingPaymentType> + <BillingAccountNumber>1234567890</BillingAccountNumber> + <DutyPaymentType>S</DutyPaymentType> + <DutyAccountNumber>1234567890</DutyAccountNumber> + </Billing> + <Consignee xmlns=""> + <CompanyName/> + <AddressLine/> + <City/> + <PostalCode/> + <CountryCode/> + <CountryName/> + <Contact> + <PersonName/> + <PhoneNumber/> + </Contact> + </Consignee> + <Commodity xmlns=""> + <CommodityCode>1</CommodityCode> + </Commodity> + <Dutiable xmlns=""> + <DeclaredValue>10.00</DeclaredValue> + <DeclaredCurrency>USD</DeclaredCurrency> + </Dutiable> + <Reference xmlns=""> + <ReferenceID>shipment reference</ReferenceID> + <ReferenceType>St</ReferenceType> + </Reference> + <ShipmentDetails xmlns=""> + <NumberOfPieces>1</NumberOfPieces> + <Pieces xmlns=""> + <Piece xmlns=""> + <PieceID>1</PieceID> + <PackageType>CP</PackageType> + <Weight>0.454</Weight> + <Width>3</Width> + <Height>3</Height> + <Depth>3</Depth> + <PieceContents>item_name</PieceContents> + </Piece> + </Pieces> + <Weight>0.454</Weight> + <WeightUnit>K</WeightUnit> + <GlobalProductCode/> + <LocalProductCode/> + <Date>currentTime</Date> + <Contents>DHL Parcel</Contents> + <DoorTo>DD</DoorTo> + <DimensionUnit>C</DimensionUnit> + <PackageType>CP</PackageType> + <IsDutiable>Y</IsDutiable> + <CurrencyCode>USD</CurrencyCode> + </ShipmentDetails> + <Shipper xmlns=""> + <ShipperID>1234567890</ShipperID> + <CompanyName/> + <RegisteredAccount>1234567890</RegisteredAccount> + <AddressLine/> + <City/> + <PostalCode/> + <CountryCode/> + <CountryName/> + <Contact xmlns=""> + <PersonName/> + <PhoneNumber/> + </Contact> + </Shipper> + <LabelImageFormat xmlns="">PDF</LabelImageFormat> +</req:ShipmentRequest> diff --git a/app/code/Magento/Dhl/etc/countries.xml b/app/code/Magento/Dhl/etc/countries.xml index 48837dbefb576..792465ce45942 100644 --- a/app/code/Magento/Dhl/etc/countries.xml +++ b/app/code/Magento/Dhl/etc/countries.xml @@ -83,7 +83,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Austria</name> <domestic>1</domestic> </AT> @@ -132,7 +132,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Belgium</name> <domestic>1</domestic> </BE> @@ -146,7 +146,7 @@ <currency>BGN</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Bulgaria</name> <domestic>1</domestic> </BG> @@ -257,7 +257,7 @@ <currency>CHF</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Switzerland</name> </CH> <CI> @@ -331,7 +331,7 @@ <currency>CZK</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Czech Republic, The</name> <domestic>1</domestic> </CZ> @@ -339,7 +339,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Germany</name> <domestic>1</domestic> </DE> @@ -353,7 +353,7 @@ <currency>DKK</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Denmark</name> <domestic>1</domestic> </DK> @@ -389,7 +389,7 @@ <currency>EEK</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Estonia</name> <domestic>1</domestic> </EE> @@ -410,7 +410,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Spain</name> <domestic>1</domestic> </ES> @@ -424,7 +424,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Finland</name> <domestic>1</domestic> </FI> @@ -457,7 +457,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>France</name> <domestic>1</domestic> </FR> @@ -471,7 +471,7 @@ <currency>GBP</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>United Kingdom</name> <domestic>1</domestic> </GB> @@ -549,7 +549,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Greece</name> <domestic>1</domestic> </GR> @@ -612,7 +612,7 @@ <currency>HUF</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Hungary</name> <domestic>1</domestic> </HU> @@ -633,7 +633,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Ireland, Republic Of</name> <domestic>1</domestic> </IE> @@ -668,14 +668,14 @@ <currency>ISK</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Iceland</name> </IS> <IT> <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Italy</name> <domestic>1</domestic> </IT> @@ -834,7 +834,7 @@ <currency>LTL</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Lithuania</name> <domestic>1</domestic> </LT> @@ -842,7 +842,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Luxembourg</name> <domestic>1</domestic> </LU> @@ -850,7 +850,7 @@ <currency>LVL</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Latvia</name> <domestic>1</domestic> </LV> @@ -1039,7 +1039,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Netherlands, The</name> <domestic>1</domestic> </NL> @@ -1047,7 +1047,7 @@ <currency>NOK</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Norway</name> </NO> <NP> @@ -1127,7 +1127,7 @@ <currency>PLN</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Poland</name> <domestic>1</domestic> </PL> @@ -1142,7 +1142,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Portugal</name> <domestic>1</domestic> </PT> @@ -1177,7 +1177,7 @@ <currency>RON</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Romania</name> <domestic>1</domestic> </RO> @@ -1231,7 +1231,7 @@ <currency>SEK</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Sweden</name> <domestic>1</domestic> </SE> @@ -1246,7 +1246,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Slovenia</name> <domestic>1</domestic> </SI> @@ -1254,7 +1254,7 @@ <currency>EUR</currency> <weight_unit>KG</weight_unit> <measure_unit>CM</measure_unit> - <region>EA</region> + <region>EU</region> <name>Slovakia</name> <domestic>1</domestic> </SK> From ea668e190ab857ac4c0a3708044e2a621727fddc Mon Sep 17 00:00:00 2001 From: Joan He <johe@magento.com> Date: Thu, 17 Jan 2019 16:55:16 -0600 Subject: [PATCH 073/121] MC-6297: Update KnownTrackingRequest - updated schema - added integration test --- app/code/Magento/Dhl/Model/Carrier.php | 11 +- .../Magento/Dhl/Model/CarrierTest.php | 241 ++++++++++++++++++ ...SingleknownTrackResponse-no-data-found.xml | 28 ++ .../Dhl/_files/Track-res-XML-Parse-Err.xml | 26 ++ .../_files/TrackingRequest_MultipleAWB.xml | 24 ++ .../Dhl/_files/TrackingRequest_SingleAWB.xml | 20 ++ .../_files/TrackingResponse_MultipleAWB.xml | 174 +++++++++++++ .../Dhl/_files/TrackingResponse_SingleAWB.xml | 69 +++++ 8 files changed, 590 insertions(+), 3 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Dhl/Model/CarrierTest.php create mode 100755 dev/tests/integration/testsuite/Magento/Dhl/_files/SingleknownTrackResponse-no-data-found.xml create mode 100755 dev/tests/integration/testsuite/Magento/Dhl/_files/Track-res-XML-Parse-Err.xml create mode 100755 dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_MultipleAWB.xml create mode 100755 dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_SingleAWB.xml create mode 100755 dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_MultipleAWB.xml create mode 100755 dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_SingleAWB.xml diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index e765b33bfdba1..92460cfc4cb61 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -1693,7 +1693,7 @@ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '') * Get tracking * * @param string|string[] $trackings - * @return Result|null + * @return \Magento\Shipping\Model\Tracking\Result|null */ public function getTracking($trackings) { @@ -1717,12 +1717,15 @@ protected function _getXMLTracking($trackings) '<req:KnownTrackingRequest' . ' xmlns:req="http://www.dhl.com"' . ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . - ' xsi:schemaLocation="http://www.dhl.com TrackingRequestKnown.xsd" />'; + ' xsi:schemaLocation="http://www.dhl.com TrackingRequestKnown-1.0.xsd"' . + ' schemaVersion="1.0" />'; $xml = $this->_xmlElFactory->create(['data' => $xmlStr]); $requestNode = $xml->addChild('Request', '', ''); $serviceHeaderNode = $requestNode->addChild('ServiceHeader', '', ''); + $serviceHeaderNode->addChild('MessageTime', $this->buildMessageTimestamp()); + $serviceHeaderNode->addChild('MessageReference', $this->buildMessageReference(self::SERVICE_PREFIX_TRACKING)); $serviceHeaderNode->addChild('SiteID', (string)$this->getConfigData('id')); $serviceHeaderNode->addChild('Password', (string)$this->getConfigData('password')); @@ -1966,12 +1969,14 @@ protected function _prepareShippingLabelContent(\SimpleXMLElement $xml) } /** + * Verify if the shipment is dutiable + * * @param string $origCountryId * @param string $destCountryId * * @return bool */ - protected function isDutiable($origCountryId, $destCountryId) + protected function isDutiable($origCountryId, $destCountryId) : bool { $this->_checkDomesticStatus($origCountryId, $destCountryId); diff --git a/dev/tests/integration/testsuite/Magento/Dhl/Model/CarrierTest.php b/dev/tests/integration/testsuite/Magento/Dhl/Model/CarrierTest.php new file mode 100644 index 0000000000000..d5f3c30c17397 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Dhl/Model/CarrierTest.php @@ -0,0 +1,241 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Dhl\Model; + +use Magento\Framework\HTTP\ZendClient; +use Magento\Framework\HTTP\ZendClientFactory; +use Magento\Framework\Simplexml\Element; +use Magento\Shipping\Model\Tracking\Result\Error; +use Magento\Shipping\Model\Tracking\Result\Status; +use PHPUnit_Framework_MockObject_MockObject as MockObject; + +class CarrierTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var \Magento\Dhl\Model\Carrier + */ + private $dhlCarrier; + + /** + * @var ZendClient|MockObject + */ + private $httpClientMock; + + /** + * @var \Zend_Http_Response|MockObject + */ + private $httpResponseMock; + + protected function setUp() + { + $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->dhlCarrier = $objectManager->create( + \Magento\Dhl\Model\Carrier::class, + ['httpClientFactory' => $this->getHttpClientFactory()] + ); + } + + /** + * @magentoConfigFixture default_store carriers/dhl/id CustomerSiteID + * @magentoConfigFixture default_store carriers/dhl/password CustomerPassword + * @param string[] $trackingNumbers + * @param string $responseXml + * @param $expectedTrackingData + * @param string $expectedRequestXml + * @dataProvider getTrackingDataProvider + */ + public function testGetTracking( + $trackingNumbers, + string $responseXml, + $expectedTrackingData, + string $expectedRequestXml = '' + ) { + $this->httpResponseMock->method('getBody') + ->willReturn($responseXml); + $trackingResult = $this->dhlCarrier->getTracking($trackingNumbers); + $this->assertTrackingResult($expectedTrackingData, $trackingResult->getAllTrackings()); + if ($expectedRequestXml !== '') { + $method = new \ReflectionMethod($this->httpClientMock, '_prepareBody'); + $method->setAccessible(true); + $requestXml = $method->invoke($this->httpClientMock); + $this->assertRequest($expectedRequestXml, $requestXml); + } + } + + /** + * Get tracking data provider + * @return array + */ + public function getTrackingDataProvider() : array + { + $expectedMultiAWBRequestXml = file_get_contents(__DIR__ . '/../_files/TrackingRequest_MultipleAWB.xml'); + $multiAWBResponseXml = file_get_contents(__DIR__ . '/../_files/TrackingResponse_MultipleAWB.xml'); + $expectedSingleAWBRequestXml = file_get_contents(__DIR__ . '/../_files/TrackingRequest_SingleAWB.xml'); + $singleAWBResponseXml = file_get_contents(__DIR__ . '/../_files/TrackingResponse_SingleAWB.xml'); + $singleNoDataResponseXml = file_get_contents(__DIR__ . '/../_files/SingleknownTrackResponse-no-data-found.xml'); + $failedResponseXml = file_get_contents(__DIR__ . '/../_files/Track-res-XML-Parse-Err.xml'); + $expectedTrackingDataA = [ + 'carrier' => 'dhl', + 'carrier_title' => 'DHL', + 'tracking' => 4781584780, + 'service' => 'DOCUMENT', + 'progressdetail' => [ + [ + 'activity' => 'SD Shipment information received', + 'deliverydate' => '2017-12-25', + 'deliverytime' => '14:38:00', + 'deliverylocation' => 'BEIJING-CHN [PEK]' + ] + ], + 'weight' => '0.5 K', + ]; + $expectedTrackingDataB = [ + 'carrier' => 'dhl', + 'carrier_title' => 'DHL', + 'tracking' => 4781585060, + 'service' => 'NOT RESTRICTED FOR TRANSPORT,', + 'progressdetail' => [ + [ + 'activity' => 'SD Shipment information received', + 'deliverydate' => '2017-12-24', + 'deliverytime' => '13:35:00', + 'deliverylocation' => 'HONG KONG-HKG [HKG]' + ] + ], + 'weight' => '2.0 K', + ]; + $expectedTrackingDataC = [ + 'carrier' => 'dhl', + 'carrier_title' => 'DHL', + 'tracking' => 5702254250, + 'service' => 'CD', + 'progressdetail' => [ + [ + 'activity' => 'SD Shipment information received', + 'deliverydate' => '2017-12-24', + 'deliverytime' => '04:12:00', + 'deliverylocation' => 'BIRMINGHAM-GBR [BHX]' + ] + ], + 'weight' => '0.12 K', + ]; + $expectedTrackingDataD = [ + 'carrier' => 'dhl', + 'carrier_title' => 'DHL', + 'tracking' => 4781585060, + 'error_message' => __('Unable to retrieve tracking') + ]; + $expectedTrackingDataE = [ + 'carrier' => 'dhl', + 'carrier_title' => 'DHL', + 'tracking' => 111, + 'error_message' => __( + 'Error #%1 : %2', + '111', + ' Error Parsing incoming request XML + Error: The content of element type + "ShipperReference" must match + "(ReferenceID,ReferenceType?)". at line + 16, column 22' + ) + ]; + return [ + 'multi-AWB' => [ + ['4781584780', '4781585060', '5702254250'], + $multiAWBResponseXml, + [$expectedTrackingDataA, $expectedTrackingDataB, $expectedTrackingDataC], + $expectedMultiAWBRequestXml + ], + 'single-AWB' => [ + ['4781585060'], + $singleAWBResponseXml, + [$expectedTrackingDataB], + $expectedSingleAWBRequestXml + ], + 'single-AWB-no-data' => [ + ['4781585061'], + $singleNoDataResponseXml, + [$expectedTrackingDataD] + ], + 'failed-response' => [ + ['4781585060-failed'], + $failedResponseXml, + [$expectedTrackingDataE] + ] + ]; + } + + /** + * Get mocked Http Client Factory + * + * @return MockObject + */ + private function getHttpClientFactory(): MockObject + { + $this->httpResponseMock = $this->getMockBuilder(\Zend_Http_Response::class) + ->disableOriginalConstructor() + ->getMock(); + $this->httpClientMock = $this->getMockBuilder(ZendClient::class) + ->disableOriginalConstructor() + ->setMethods(['request']) + ->getMock(); + $this->httpClientMock->method('request') + ->willReturn($this->httpResponseMock); + /** @var ZendClientFactory|MockObject $httpClientFactoryMock */ + $httpClientFactoryMock = $this->getMockBuilder(ZendClientFactory::class) + ->disableOriginalConstructor() + ->getMock(); + $httpClientFactoryMock->method('create') + ->willReturn($this->httpClientMock); + + return $httpClientFactoryMock; + } + + /** + * Assert request + * + * @param string $expectedRequestXml + * @param string $requestXml + */ + private function assertRequest(string $expectedRequestXml, string $requestXml): void + { + $expectedRequestElement = new Element($expectedRequestXml); + $requestElement = new Element($requestXml); + $requestMessageTime = $requestElement->Request->ServiceHeader->MessageTime->__toString(); + $this->assertEquals( + 1, + preg_match("/\d{4}\-\d{2}\-\d{2}T\d{2}\:\d{2}\:\d{2}\+\d{2}\:\d{2}/", $requestMessageTime) + ); + $expectedRequestElement->Request->ServiceHeader->MessageTime = $requestMessageTime; + $messageReference = $requestElement->Request->ServiceHeader->MessageReference->__toString(); + $this->assertStringStartsWith('MAGE_TRCK_', $messageReference); + $this->assertGreaterThanOrEqual(28, strlen($messageReference)); + $this->assertLessThanOrEqual(32, strlen($messageReference)); + $requestElement->Request->ServiceHeader->MessageReference = 'MAGE_TRCK_CHECKED'; + $this->assertXmlStringEqualsXmlString($expectedRequestElement->asXML(), $requestElement->asXML()); + } + + /** + * Assert tracking + * + * @param array|null $expectedTrackingData + * @param Status[]|null $trackingResults + * @return void + */ + private function assertTrackingResult($expectedTrackingData, $trackingResults): void + { + if (null === $expectedTrackingData) { + $this->assertNull($trackingResults); + } else { + $ctr = 0; + foreach ($trackingResults as $trackingResult) { + $this->assertEquals($expectedTrackingData[$ctr++], $trackingResult->getData()); + } + } + } +} diff --git a/dev/tests/integration/testsuite/Magento/Dhl/_files/SingleknownTrackResponse-no-data-found.xml b/dev/tests/integration/testsuite/Magento/Dhl/_files/SingleknownTrackResponse-no-data-found.xml new file mode 100755 index 0000000000000..e3e7b93fc652b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Dhl/_files/SingleknownTrackResponse-no-data-found.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<req:TrackingResponse xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com TrackingResponse.xsd"> + <Response> + <ServiceHeader> + <MessageTime>2018-02-27T12:59:34+01:00</MessageTime> + <MessageReference>tracking_4781585060</MessageReference> + <SiteID>CustomerSiteID</SiteID> + </ServiceHeader> + </Response> + <AWBInfo> + <AWBNumber>4781585060</AWBNumber> + <Status> + <ActionStatus>No Shipments Found</ActionStatus> + <Condition> + <ConditionCode>209</ConditionCode> + <ConditionData>No Shipments Found for AWBNumber 6017300993</ConditionData> + </Condition> + </Status> + </AWBInfo> + <LanguageCode>String</LanguageCode> +</req:TrackingResponse> +<!-- ServiceInvocationId:20180227125934_5793_74fbd9e1-a8b0-4f6a-a326-26aae979e5f0 --> diff --git a/dev/tests/integration/testsuite/Magento/Dhl/_files/Track-res-XML-Parse-Err.xml b/dev/tests/integration/testsuite/Magento/Dhl/_files/Track-res-XML-Parse-Err.xml new file mode 100755 index 0000000000000..c2abd68d3c4ae --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Dhl/_files/Track-res-XML-Parse-Err.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<req:ShipmentTrackingErrorResponse xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com track-err-res.xsd"> + <Response> + <ServiceHeader> + <MessageTime>2018-02-27T12:55:05+01:00</MessageTime> + </ServiceHeader> + <Status> + <ActionStatus>Failure</ActionStatus> + <Condition> + <ConditionCode>111</ConditionCode> + <ConditionData> Error Parsing incoming request XML + Error: The content of element type + "ShipperReference" must match + "(ReferenceID,ReferenceType?)". at line + 16, column 22</ConditionData> + </Condition> + </Status> + </Response> +</req:ShipmentTrackingErrorResponse> +<!-- ServiceInvocationId:20180227125505_5793_2008671c-9292-4790-87b6-b02ccdf913db --> diff --git a/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_MultipleAWB.xml b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_MultipleAWB.xml new file mode 100755 index 0000000000000..f3aa662cd68fd --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_MultipleAWB.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<req:KnownTrackingRequest xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com TrackingRequestKnown-1.0.xsd" schemaVersion="1.0"> + <Request> + <ServiceHeader> + <MessageTime>2002-06-25T11:28:56-08:00</MessageTime> + <MessageReference>MAGE_TRCK_CHECKED</MessageReference> + <SiteID>CustomerSiteID</SiteID> + <Password>CustomerPassword</Password> + </ServiceHeader> + </Request> + <LanguageCode>en</LanguageCode> + <AWBNumber>4781584780</AWBNumber> + <AWBNumber>4781585060</AWBNumber> + <AWBNumber>5702254250</AWBNumber> + <LevelOfDetails>ALL_CHECK_POINTS</LevelOfDetails> +</req:KnownTrackingRequest> + + diff --git a/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_SingleAWB.xml b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_SingleAWB.xml new file mode 100755 index 0000000000000..b45988249f665 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_SingleAWB.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<req:KnownTrackingRequest xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com TrackingRequestKnown-1.0.xsd" schemaVersion="1.0"> + <Request> + <ServiceHeader> + <MessageTime>2002-06-25T11:28:56-08:00</MessageTime> + <MessageReference>MAGE_TRCK_CHECKED</MessageReference> + <SiteID>CustomerSiteID</SiteID> + <Password>CustomerPassword</Password> + </ServiceHeader> + </Request> + <LanguageCode>en</LanguageCode> + <AWBNumber>4781585060</AWBNumber> + <LevelOfDetails>ALL_CHECK_POINTS</LevelOfDetails> +</req:KnownTrackingRequest> \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_MultipleAWB.xml b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_MultipleAWB.xml new file mode 100755 index 0000000000000..8375eaea1770d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_MultipleAWB.xml @@ -0,0 +1,174 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<req:TrackingResponse xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com TrackingResponse.xsd"> + <Response> + <ServiceHeader> + <MessageTime>2018-02-27T12:43:44+01:00</MessageTime> + <MessageReference>TrackingRequest_Multiple_AWB</MessageReference> + <SiteID>CustomerSiteID</SiteID> + </ServiceHeader> + </Response> + <AWBInfo> + <AWBNumber>4781584780</AWBNumber> + <Status> + <ActionStatus>success</ActionStatus> + </Status> + <ShipmentInfo> + <OriginServiceArea> + <ServiceAreaCode>PEK</ServiceAreaCode> + <Description>BEIJING-CHN</Description> + </OriginServiceArea> + <DestinationServiceArea> + <ServiceAreaCode>PHL</ServiceAreaCode> + <Description>WEST PHILADELPHIA,PA-USA</Description> + </DestinationServiceArea> + <ShipperName>THE EXP HIGH SCH ATT TO BNU</ShipperName> + <ShipperAccountNumber>123456789</ShipperAccountNumber> + <ConsigneeName>HAVEFORD COLLEGE</ConsigneeName> + <ShipmentDate>2017-12-25T14:38:00</ShipmentDate> + <Pieces>1</Pieces> + <Weight>0.5</Weight> + <WeightUnit>K</WeightUnit> + <GlobalProductCode>D</GlobalProductCode> + <ShipmentDesc>DOCUMENT</ShipmentDesc> + <DlvyNotificationFlag>Y</DlvyNotificationFlag> + <Shipper> + <City>BEIJING</City> + <PostalCode>100032</PostalCode> + <CountryCode>CN</CountryCode> + </Shipper> + <Consignee> + <City>HAVERFORD</City> + <DivisionCode>PA</DivisionCode> + <PostalCode>19041</PostalCode> + <CountryCode>US</CountryCode> + </Consignee> + <ShipperReference> + <ReferenceID>2469</ReferenceID> + </ShipperReference> + <ShipmentEvent> + <Date>2017-12-25</Date> + <Time>14:38:00</Time> + <ServiceEvent> + <EventCode>SD</EventCode> + <Description>Shipment information received</Description> + </ServiceEvent> + <Signatory/> + <ServiceArea> + <ServiceAreaCode>PEK</ServiceAreaCode> + <Description>BEIJING-CHN</Description> + </ServiceArea> + </ShipmentEvent> + </ShipmentInfo> + </AWBInfo> + <AWBInfo> + <AWBNumber>4781585060</AWBNumber> + <Status> + <ActionStatus>success</ActionStatus> + </Status> + <ShipmentInfo> + <OriginServiceArea> + <ServiceAreaCode>HKG</ServiceAreaCode> + <Description>HONG KONG-HKG</Description> + </OriginServiceArea> + <DestinationServiceArea> + <ServiceAreaCode>HKG</ServiceAreaCode> + <Description>HONG KONG-HKG</Description> + </DestinationServiceArea> + <ShipperName>NET-A-PORTER</ShipperName> + <ShipperAccountNumber>123456789</ShipperAccountNumber> + <ConsigneeName>NICOLE LI</ConsigneeName> + <ShipmentDate>2017-12-24T13:35:00</ShipmentDate> + <Pieces>1</Pieces> + <Weight>2.0</Weight> + <WeightUnit>K</WeightUnit> + <GlobalProductCode>N</GlobalProductCode> + <ShipmentDesc>NOT RESTRICTED FOR TRANSPORT,</ShipmentDesc> + <DlvyNotificationFlag>Y</DlvyNotificationFlag> + <Shipper> + <City>HONG KONG</City> + <CountryCode>HK</CountryCode> + </Shipper> + <Consignee> + <City>HONG KONG</City> + <DivisionCode>CH</DivisionCode> + <CountryCode>HK</CountryCode> + </Consignee> + <ShipperReference> + <ReferenceID>1060571</ReferenceID> + </ShipperReference> + <ShipmentEvent> + <Date>2017-12-24</Date> + <Time>13:35:00</Time> + <ServiceEvent> + <EventCode>SD</EventCode> + <Description>Shipment information received</Description> + </ServiceEvent> + <Signatory/> + <ServiceArea> + <ServiceAreaCode>HKG</ServiceAreaCode> + <Description>HONG KONG-HKG</Description> + </ServiceArea> + </ShipmentEvent> + </ShipmentInfo> + </AWBInfo> + <AWBInfo> + <AWBNumber>5702254250</AWBNumber> + <Status> + <ActionStatus>success</ActionStatus> + </Status> + <ShipmentInfo> + <OriginServiceArea> + <ServiceAreaCode>BHX</ServiceAreaCode> + <Description>BIRMINGHAM-GBR</Description> + </OriginServiceArea> + <DestinationServiceArea> + <ServiceAreaCode>AOI</ServiceAreaCode> + <Description>ANCONA-ITA</Description> + </DestinationServiceArea> + <ShipperName>AMAZON EU SARL</ShipperName> + <ShipperAccountNumber>123456789</ShipperAccountNumber> + <ConsigneeName>MATTEO LOMBO</ConsigneeName> + <ShipmentDate>2017-12-24T04:12:00</ShipmentDate> + <Pieces>1</Pieces> + <Weight>0.12</Weight> + <WeightUnit>K</WeightUnit> + <GlobalProductCode>U</GlobalProductCode> + <ShipmentDesc>CD</ShipmentDesc> + <DlvyNotificationFlag>Y</DlvyNotificationFlag> + <Shipper> + <City>PETERBOROUGH</City> + <PostalCode>PE2 9EN</PostalCode> + <CountryCode>GB</CountryCode> + </Shipper> + <Consignee> + <City>ORTONA</City> + <PostalCode>66026</PostalCode> + <CountryCode>IT</CountryCode> + </Consignee> + <ShipperReference> + <ReferenceID>DGWYDy4xN_1</ReferenceID> + </ShipperReference> + <ShipmentEvent> + <Date>2017-12-24</Date> + <Time>04:12:00</Time> + <ServiceEvent> + <EventCode>SD</EventCode> + <Description>Shipment information received</Description> + </ServiceEvent> + <Signatory/> + <ServiceArea> + <ServiceAreaCode>BHX</ServiceAreaCode> + <Description>BIRMINGHAM-GBR</Description> + </ServiceArea> + </ShipmentEvent> + </ShipmentInfo> + </AWBInfo> + <LanguageCode>en</LanguageCode> +</req:TrackingResponse> +<!-- ServiceInvocationId:20180227124344_5793_23bed3d9-e792-4955-8055-9472b1b41929 --> diff --git a/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_SingleAWB.xml b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_SingleAWB.xml new file mode 100755 index 0000000000000..ffa4982183851 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_SingleAWB.xml @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<req:TrackingResponse xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com TrackingResponse.xsd"> + <Response> + <ServiceHeader> + <MessageTime>2018-02-27T12:27:42+01:00</MessageTime> + <MessageReference>tracking_4781585060</MessageReference> + <SiteID>CustomerSiteID</SiteID> + </ServiceHeader> + </Response> + <AWBInfo> + <AWBNumber>4781585060</AWBNumber> + <Status> + <ActionStatus>success</ActionStatus> + </Status> + <ShipmentInfo> + <OriginServiceArea> + <ServiceAreaCode>HKG</ServiceAreaCode> + <Description>HONG KONG-HKG</Description> + </OriginServiceArea> + <DestinationServiceArea> + <ServiceAreaCode>HKG</ServiceAreaCode> + <Description>HONG KONG-HKG</Description> + </DestinationServiceArea> + <ShipperName>NET-A-PORTER</ShipperName> + <ShipperAccountNumber>123456789</ShipperAccountNumber> + <ConsigneeName>NICOLE LI</ConsigneeName> + <ShipmentDate>2017-12-24T13:35:00</ShipmentDate> + <Pieces>1</Pieces> + <Weight>2.0</Weight> + <WeightUnit>K</WeightUnit> + <GlobalProductCode>N</GlobalProductCode> + <ShipmentDesc>NOT RESTRICTED FOR TRANSPORT,</ShipmentDesc> + <DlvyNotificationFlag>Y</DlvyNotificationFlag> + <Shipper> + <City>HONG KONG</City> + <CountryCode>HK</CountryCode> + </Shipper> + <Consignee> + <City>HONG KONG</City> + <DivisionCode>CH</DivisionCode> + <CountryCode>HK</CountryCode> + </Consignee> + <ShipperReference> + <ReferenceID>1060571</ReferenceID> + </ShipperReference> + <ShipmentEvent> + <Date>2017-12-24</Date> + <Time>13:35:00</Time> + <ServiceEvent> + <EventCode>SD</EventCode> + <Description>Shipment information received</Description> + </ServiceEvent> + <Signatory/> + <ServiceArea> + <ServiceAreaCode>HKG</ServiceAreaCode> + <Description>HONG KONG-HKG</Description> + </ServiceArea> + </ShipmentEvent> + </ShipmentInfo> + </AWBInfo> + <LanguageCode>en</LanguageCode> +</req:TrackingResponse> +<!-- ServiceInvocationId:20180227122741_5793_e0f8c40e-5245-4737-ab31-323030366721 --> From 84036d5e1738d15f436818e23119057c862abcee Mon Sep 17 00:00:00 2001 From: Joan He <johe@magento.com> Date: Fri, 18 Jan 2019 13:39:14 -0600 Subject: [PATCH 074/121] MC-6297: Update KnownTrackingRequest - address review comments --- .../integration/testsuite/Magento/Dhl/Model/CarrierTest.php | 2 +- .../Dhl/_files/SingleknownTrackResponse-no-data-found.xml | 2 +- .../Magento/Dhl/_files/TrackingRequest_MultipleAWB.xml | 2 +- .../testsuite/Magento/Dhl/_files/TrackingRequest_SingleAWB.xml | 2 +- .../Magento/Dhl/_files/TrackingResponse_MultipleAWB.xml | 2 +- .../testsuite/Magento/Dhl/_files/TrackingResponse_SingleAWB.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Dhl/Model/CarrierTest.php b/dev/tests/integration/testsuite/Magento/Dhl/Model/CarrierTest.php index d5f3c30c17397..8874d880a4dd1 100644 --- a/dev/tests/integration/testsuite/Magento/Dhl/Model/CarrierTest.php +++ b/dev/tests/integration/testsuite/Magento/Dhl/Model/CarrierTest.php @@ -216,7 +216,7 @@ private function assertRequest(string $expectedRequestXml, string $requestXml): $this->assertStringStartsWith('MAGE_TRCK_', $messageReference); $this->assertGreaterThanOrEqual(28, strlen($messageReference)); $this->assertLessThanOrEqual(32, strlen($messageReference)); - $requestElement->Request->ServiceHeader->MessageReference = 'MAGE_TRCK_CHECKED'; + $requestElement->Request->ServiceHeader->MessageReference = 'MAGE_TRCK_28TO32_Char_CHECKED'; $this->assertXmlStringEqualsXmlString($expectedRequestElement->asXML(), $requestElement->asXML()); } diff --git a/dev/tests/integration/testsuite/Magento/Dhl/_files/SingleknownTrackResponse-no-data-found.xml b/dev/tests/integration/testsuite/Magento/Dhl/_files/SingleknownTrackResponse-no-data-found.xml index e3e7b93fc652b..9887cecbd2d4e 100755 --- a/dev/tests/integration/testsuite/Magento/Dhl/_files/SingleknownTrackResponse-no-data-found.xml +++ b/dev/tests/integration/testsuite/Magento/Dhl/_files/SingleknownTrackResponse-no-data-found.xml @@ -9,7 +9,7 @@ <Response> <ServiceHeader> <MessageTime>2018-02-27T12:59:34+01:00</MessageTime> - <MessageReference>tracking_4781585060</MessageReference> + <MessageReference>1234567890123456789012345678</MessageReference> <SiteID>CustomerSiteID</SiteID> </ServiceHeader> </Response> diff --git a/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_MultipleAWB.xml b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_MultipleAWB.xml index f3aa662cd68fd..c0a18fcc4e2f6 100755 --- a/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_MultipleAWB.xml +++ b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_MultipleAWB.xml @@ -9,7 +9,7 @@ <Request> <ServiceHeader> <MessageTime>2002-06-25T11:28:56-08:00</MessageTime> - <MessageReference>MAGE_TRCK_CHECKED</MessageReference> + <MessageReference>MAGE_TRCK_28TO32_Char_CHECKED</MessageReference> <SiteID>CustomerSiteID</SiteID> <Password>CustomerPassword</Password> </ServiceHeader> diff --git a/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_SingleAWB.xml b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_SingleAWB.xml index b45988249f665..dac69a0d68c57 100755 --- a/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_SingleAWB.xml +++ b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingRequest_SingleAWB.xml @@ -9,7 +9,7 @@ <Request> <ServiceHeader> <MessageTime>2002-06-25T11:28:56-08:00</MessageTime> - <MessageReference>MAGE_TRCK_CHECKED</MessageReference> + <MessageReference>MAGE_TRCK_28TO32_Char_CHECKED</MessageReference> <SiteID>CustomerSiteID</SiteID> <Password>CustomerPassword</Password> </ServiceHeader> diff --git a/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_MultipleAWB.xml b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_MultipleAWB.xml index 8375eaea1770d..369236d80c614 100755 --- a/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_MultipleAWB.xml +++ b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_MultipleAWB.xml @@ -9,7 +9,7 @@ <Response> <ServiceHeader> <MessageTime>2018-02-27T12:43:44+01:00</MessageTime> - <MessageReference>TrackingRequest_Multiple_AWB</MessageReference> + <MessageReference>1234567890123456789012345678</MessageReference> <SiteID>CustomerSiteID</SiteID> </ServiceHeader> </Response> diff --git a/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_SingleAWB.xml b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_SingleAWB.xml index ffa4982183851..ef303eaab64f7 100755 --- a/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_SingleAWB.xml +++ b/dev/tests/integration/testsuite/Magento/Dhl/_files/TrackingResponse_SingleAWB.xml @@ -9,7 +9,7 @@ <Response> <ServiceHeader> <MessageTime>2018-02-27T12:27:42+01:00</MessageTime> - <MessageReference>tracking_4781585060</MessageReference> + <MessageReference>1234567890123456789012345678</MessageReference> <SiteID>CustomerSiteID</SiteID> </ServiceHeader> </Response> From 5a63e6f2049d9056d89173cb2d457095f78c67f5 Mon Sep 17 00:00:00 2001 From: Joan He <johe@magento.com> Date: Fri, 18 Jan 2019 13:57:33 -0600 Subject: [PATCH 075/121] MC-6295: Update ShipmentValidationRequest - address review comments --- app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php | 2 +- .../Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php index 82eb379d75be0..835ef4bf1fe28 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php @@ -434,7 +434,7 @@ public function testRequestToShipment(string $origCountryId, string $expectedReg $this->assertStringStartsWith('MAGE_SHIP_', $messageReference); $this->assertGreaterThanOrEqual(28, strlen($messageReference)); $this->assertLessThanOrEqual(32, strlen($messageReference)); - $requestElement->Request->ServiceHeader->MessageReference = 'MAGE_SHIP_CHECKED'; + $requestElement->Request->ServiceHeader->MessageReference = 'MAGE_SHIP_28TO32_Char_CHECKED'; $expectedRequestElement = new Element($expectedRequestXml); $this->assertXmlStringEqualsXmlString($expectedRequestElement->asXML(), $requestElement->asXML()); } diff --git a/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml b/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml index 7a87046b87b76..896d631f01d50 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml +++ b/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml @@ -4,7 +4,7 @@ <Request xmlns=""> <ServiceHeader> <MessageTime>currentTime</MessageTime> - <MessageReference>MAGE_SHIP_CHECKED</MessageReference> + <MessageReference>MAGE_SHIP_28TO32_Char_CHECKED</MessageReference> <SiteID>some ID</SiteID> <Password>some password</Password> </ServiceHeader> From a0ad012e145876395a3277dde9702d247e070078 Mon Sep 17 00:00:00 2001 From: Andrew Molina <amolina@adobe.com> Date: Fri, 18 Jan 2019 15:56:01 -0600 Subject: [PATCH 076/121] MC-6296: Update DCTRequest Updated unit tests to use data providers --- .../Dhl/Test/Unit/Model/CarrierTest.php | 132 +++++++++--------- 1 file changed, 69 insertions(+), 63 deletions(-) diff --git a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php index d9eb6e04bb4da..bb402d3ebbc84 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php @@ -283,6 +283,11 @@ public function testCollectRates() $this->httpResponse->method('getBody') ->willReturn($responseXml); + $this->coreDateMock->method('date') + ->willReturnCallback(function () { + return date(\DATE_RFC3339); + }); + $request = $this->objectManager->getObject(RateRequest::class, $requestData); $reflectionClass = new \ReflectionObject($this->httpClient); @@ -516,68 +521,104 @@ public function dhlProductsDataProvider() : array } /** - * Tests that the built message reference string is of the appropriate format. + * Tests that the built MessageReference string is of the appropriate format. * - * @expectedException \Magento\Framework\Exception\LocalizedException - * @expectedExceptionMessage Invalid service prefix + * @dataProvider buildMessageReferenceDataProvider + * @param $servicePrefix * @throws \ReflectionException */ - public function testBuildMessageReference() + public function testBuildMessageReference($servicePrefix) { $method = new \ReflectionMethod($this->model, 'buildMessageReference'); $method->setAccessible(true); - $constPrefixQuote = new \ReflectionClassConstant($this->model, 'SERVICE_PREFIX_QUOTE'); - $constPrefixShipval = new \ReflectionClassConstant($this->model, 'SERVICE_PREFIX_SHIPVAL'); - $constPrefixTracking = new \ReflectionClassConstant($this->model, 'SERVICE_PREFIX_TRACKING'); - - $msgRefQuote = $method->invoke($this->model, $constPrefixQuote->getValue()); - self::assertGreaterThanOrEqual(28, strlen($msgRefQuote)); - self::assertLessThanOrEqual(32, strlen($msgRefQuote)); + $messageReference = $method->invoke($this->model, $servicePrefix); + $this->assertGreaterThanOrEqual(28, strlen($messageReference)); + $this->assertLessThanOrEqual(32, strlen($messageReference)); + } - $msgRefShip = $method->invoke($this->model, $constPrefixShipval->getValue()); - self::assertGreaterThanOrEqual(28, strlen($msgRefShip)); - self::assertLessThanOrEqual(32, strlen($msgRefShip)); + /** + * @return array + */ + public function buildMessageReferenceDataProvider() + { + return [ + 'quote_prefix' => ['QUOT'], + 'shipval_prefix' => ['SHIP'], + 'tracking_prefix' => ['TRCK'] + ]; + } - $msgRefTrack = $method->invoke($this->model, $constPrefixTracking->getValue()); - self::assertGreaterThanOrEqual(28, strlen($msgRefTrack)); - self::assertLessThanOrEqual(32, strlen($msgRefTrack)); + /** + * Tests that an exception is thrown when an invalid service prefix is provided. + * + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage Invalid service prefix + */ + public function testBuildMessageReferenceInvalidPrefix() + { + $method = new \ReflectionMethod($this->model, 'buildMessageReference'); + $method->setAccessible(true); - $method->invoke($this->model, 'TEST'); + $method->invoke($this->model, 'INVALID'); } /** * Tests that the built software name string is of the appropriate format. * + * @dataProvider buildSoftwareNameDataProvider + * @param $productName * @throws \ReflectionException */ - public function testBuildSoftwareName() + public function testBuildSoftwareName($productName) { $method = new \ReflectionMethod($this->model, 'buildSoftwareName'); $method->setAccessible(true); - $name = $method->invoke($this->model); - self::assertLessThanOrEqual(30, $name); + $this->productMetadataMock->method('getName')->willReturn($productName); - $nameExceedsLength = $method->invoke($this->model); - self::assertLessThanOrEqual(30, $nameExceedsLength); + $softwareName = $method->invoke($this->model); + $this->assertLessThanOrEqual(30, strlen($softwareName)); + } + + /** + * @return array + */ + public function buildSoftwareNameDataProvider() + { + return [ + 'valid_length' => ['Magento'], + 'exceeds_length' => ['Product_Name_Longer_Than_30_Char'] + ]; } /** * Tests that the built software version string is of the appropriate format. * + * @dataProvider buildSoftwareVersionProvider + * @param $productVersion * @throws \ReflectionException */ - public function testBuildSoftwareVersion() + public function testBuildSoftwareVersion($productVersion) { $method = new \ReflectionMethod($this->model, 'buildSoftwareVersion'); $method->setAccessible(true); - $version = $method->invoke($this->model); - self::assertLessThanOrEqual(10, strlen($version)); + $this->productMetadataMock->method('getVersion')->willReturn($productVersion); - $versionExceedsLength = $method->invoke($this->model); - self::assertLessThanOrEqual(10, strlen($versionExceedsLength)); + $softwareVersion = $method->invoke($this->model); + $this->assertLessThanOrEqual(10, strlen($softwareVersion)); + } + + /** + * @return array + */ + public function buildSoftwareVersionProvider() + { + return [ + 'valid_length' => ['2.3.1'], + 'exceeds_length' => ['dev-MC-1000'] + ]; } /** @@ -725,21 +766,6 @@ private function getCarrierHelper(): CarrierHelper return $carrierHelper; } - /** - * @return MockObject - */ - private function getCoreDate(): MockObject - { - $coreDate = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTime::class) - ->disableOriginalConstructor() - ->getMock(); - $coreDate->method('date')->willReturnCallback(function () { - return date(\DATE_RFC3339); - }); - - return $coreDate; - } - /** * @return MockObject */ @@ -762,24 +788,4 @@ private function getHttpClientFactory(): MockObject return $httpClientFactory; } - - /** - * @return MockObject - */ - private function getProductMetadata(): MockObject - { - $productMetadata = $this->createMock(\Magento\Framework\App\ProductMetadata::class); - - $productMetadata->method('getName')->willReturnOnConsecutiveCalls( - 'Magento', - str_pad('Magento', 24, '_') - ); - - $productMetadata->method('getVersion')->willReturnOnConsecutiveCalls( - '2.3.1', - 'dev-MC-1000' - ); - - return $productMetadata; - } } From a1db46b66b3fd1ecae85fa9a97288d244782ce45 Mon Sep 17 00:00:00 2001 From: Yashwant 2jcommerce <yashwant@2jcommerce.in> Date: Mon, 21 Jan 2019 13:21:34 +0530 Subject: [PATCH 077/121] checkout-page-shipping-title::Shipping method title overlapping on edit icon in mobile view on Checkout page --- .../module/checkout/_sidebar-shipping-information.less | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_sidebar-shipping-information.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_sidebar-shipping-information.less index b54c0a264a03a..0f2a7abcbaa18 100644 --- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_sidebar-shipping-information.less +++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_sidebar-shipping-information.less @@ -67,3 +67,11 @@ } } } + +.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__s) { + .opc-block-shipping-information { + .shipping-information-title { + font-size: 2.3rem; + } + } +} From 927b1b42922f5523ab146808768bafd7ce7b02a4 Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Mon, 21 Jan 2019 15:00:49 +0300 Subject: [PATCH 078/121] MC-10934: Tests failures CreationScheduledUpdateForStagingDashboardTest and StorefrontPurchaseProductWithCustomOptions - Fix MFTF tests. --- .../Test/StorefrontPurchaseProductWithCustomOptionsTest.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsTest.xml index d96399738c80a..951afa2ddb68b 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsTest.xml @@ -17,8 +17,6 @@ <severity value="CRITICAL"/> <testCaseId value="MAGETWO-61717"/> <group value="Catalog"/> - <!-- skip due to MAGETWO-97424 --> - <group value="skip"/> </annotations> <before> <createData entity="Simple_US_Customer" stepKey="createCustomer"/> From d1cb6934d72123c40a83e9fce99d6ce246ca826c Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Mon, 21 Jan 2019 16:14:53 +0300 Subject: [PATCH 079/121] MC-10934: Test failure StorefrontPurchaseProductWithCustomOptions - Fix mftf test. --- .../Test/StorefrontPurchaseProductWithCustomOptionsTest.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsTest.xml index d96399738c80a..951afa2ddb68b 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsTest.xml @@ -17,8 +17,6 @@ <severity value="CRITICAL"/> <testCaseId value="MAGETWO-61717"/> <group value="Catalog"/> - <!-- skip due to MAGETWO-97424 --> - <group value="skip"/> </annotations> <before> <createData entity="Simple_US_Customer" stepKey="createCustomer"/> From a53a63e4631cf87570dd6fcef8045a67d5bc7c36 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza <enarc@atwix.com> Date: Mon, 21 Jan 2019 16:04:06 +0100 Subject: [PATCH 080/121] API-functional tests added --- .../Magento/GraphQl/Quote/GetCartTest.php | 171 ++++++++++++++++++ .../Magento/Checkout/_files/active_quote.php | 8 + 2 files changed, 179 insertions(+) create mode 100644 dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCartTest.php diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCartTest.php new file mode 100644 index 0000000000000..2cd100fc0f758 --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCartTest.php @@ -0,0 +1,171 @@ +<?php /** @noinspection SpellCheckingInspection */ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\GraphQl\Quote; + +use Magento\Integration\Api\CustomerTokenServiceInterface; +use Magento\Quote\Model\Quote; +use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface; +use Magento\Quote\Model\ResourceModel\Quote as QuoteResource; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\TestCase\GraphQlAbstract; + +/** + * Test for getting cart information + */ +class GetCartTest extends GraphQlAbstract +{ + /** + * @var CustomerTokenServiceInterface + */ + private $customerTokenService; + + /** + * @var QuoteResource + */ + private $quoteResource; + + /** + * @var Quote + */ + private $quote; + + /** + * @var QuoteIdToMaskedQuoteIdInterface + */ + private $quoteIdToMaskedId; + + /** + * @inheritdoc + */ + protected function setUp() + { + $objectManager = Bootstrap::getObjectManager(); + $this->quoteResource = $objectManager->create(QuoteResource::class); + $this->quote = $objectManager->create(Quote::class); + $this->quoteIdToMaskedId = $objectManager->create(QuoteIdToMaskedQuoteIdInterface::class); + $this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class); + } + + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php + */ + public function testGetOwnCartForRegisteredCustomer() + { + $reservedOrderId = 'test_order_item_with_items'; + $this->quoteResource->load( + $this->quote, + $reservedOrderId, + 'reserved_order_id' + ); + + $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId()); + $query = $this->prepareGetCartQuery($maskedQuoteId); + + $response = $this->sendRequestWithToken($query); + + self::assertArrayHasKey('Cart', $response); + self::assertNotEmpty($response['Cart']['items']); + self::assertNotEmpty($response['Cart']['addresses']); + } + + /** + * @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php + */ + public function testGetCartFromAnotherCustomer() + { + $reservedOrderId = 'test_order_item_with_items'; + $this->quoteResource->load( + $this->quote, + $reservedOrderId, + 'reserved_order_id' + ); + + + $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId()); + $query = $this->prepareGetCartQuery($maskedQuoteId); + + self::expectExceptionMessage("The current user cannot perform operations on cart \"$maskedQuoteId\""); + + $this->graphQlQuery($query); + } + + /** + * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php + */ + public function testGetCartForGuest() + { + $reservedOrderId = 'test_order_1'; + $this->quoteResource->load( + $this->quote, + $reservedOrderId, + 'reserved_order_id' + ); + + $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId()); + $query = $this->prepareGetCartQuery($maskedQuoteId); + + $response = $this->graphQlQuery($query); + + self::assertArrayHasKey('Cart', $response); + } + + public function testGetNonExistentCart() + { + $maskedQuoteId = 'non_existent_masked_id'; + $query = $this->prepareGetCartQuery($maskedQuoteId); + + self::expectExceptionMessage("Could not find a cart with ID \"$maskedQuoteId\""); + + $this->graphQlQuery($query); + } + + /** + * Generates query for setting the specified shipping method on cart + * + * @param string $maskedQuoteId + * @return string + */ + private function prepareGetCartQuery( + string $maskedQuoteId + ) : string { + return <<<QUERY +{ + Cart(cart_id: "$maskedQuoteId") { + applied_coupon { + code + } + items { + id + } + addresses { + firstname, + lastname, + address_type + } + } +} + +QUERY; + } + + /** + * Sends a GraphQL request with using a bearer token + * + * @param string $query + * @return array + * @throws \Magento\Framework\Exception\AuthenticationException + */ + private function sendRequestWithToken(string $query): array + { + + $customerToken = $this->customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); + $headerMap = ['Authorization' => 'Bearer ' . $customerToken]; + + return $this->graphQlQuery($query, [], '', $headerMap); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/active_quote.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/active_quote.php index 2d948ebeb0128..6b569f37a1a9f 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/_files/active_quote.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/active_quote.php @@ -9,3 +9,11 @@ ->setIsMultiShipping(false) ->setReservedOrderId('test_order_1') ->save(); + +/** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ +$quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() + ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class) + ->create(); +$quoteIdMask->setQuoteId($quote->getId()); +$quoteIdMask->setDataChanges(true); +$quoteIdMask->save(); \ No newline at end of file From c33a84d6d10e04aaa94d0c8e83d07a92fc484cbb Mon Sep 17 00:00:00 2001 From: Parag Chavare <parag@2jcommerce.in> Date: Tue, 22 Jan 2019 17:49:41 +0530 Subject: [PATCH 081/121] Fixed-Product-page-tabbing-content-misalignment-in-mobile-view :: Product Page tabbing Content Misaligned in mobile view --- .../Magento/blank/web/css/source/_sections.less | 8 ++++++++ .../Magento/luma/web/css/source/_sections.less | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/app/design/frontend/Magento/blank/web/css/source/_sections.less b/app/design/frontend/Magento/blank/web/css/source/_sections.less index f0a3518c92a8b..25f8c71f22dd5 100644 --- a/app/design/frontend/Magento/blank/web/css/source/_sections.less +++ b/app/design/frontend/Magento/blank/web/css/source/_sections.less @@ -34,5 +34,13 @@ .data.item { display: block; } + .item.title { + >.switch{ + padding: 1px 15px 1px; + } + } + >.item.content{ + padding: 10px 15px 30px; + } } } diff --git a/app/design/frontend/Magento/luma/web/css/source/_sections.less b/app/design/frontend/Magento/luma/web/css/source/_sections.less index 73665fd22da23..38b936c83cb95 100644 --- a/app/design/frontend/Magento/luma/web/css/source/_sections.less +++ b/app/design/frontend/Magento/luma/web/css/source/_sections.less @@ -75,3 +75,16 @@ } } } + +.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) { + .product.data.items{ + .item.title { + >.switch{ + padding: 1px 15px 1px; + } + } + >.item.content{ + padding: 10px 15px 30px; + } + } +} From 512591378c7201c173b5750d95a5971c038c86f1 Mon Sep 17 00:00:00 2001 From: Joan He <johe@magento.com> Date: Tue, 22 Jan 2019 09:32:13 -0600 Subject: [PATCH 082/121] MC-6295: Update ShipmentValidationRequest - address review comments --- app/code/Magento/Dhl/Model/Carrier.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index accdd3902529f..eda7aee826487 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -1434,8 +1434,8 @@ protected function _doRequest() $nodeServiceHeader->addChild('Password', (string)$this->getConfigData('password')); $nodeMetaData = $nodeRequest->addChild('MetaData'); - $nodeMetaData->addChild('SoftwareName', $this->productMetadata->getName()); - $nodeMetaData->addChild('SoftwareVersion', $this->productMetadata->getVersion()); + $nodeMetaData->addChild('SoftwareName', $this->buildSoftwareName()); + $nodeMetaData->addChild('SoftwareVersion', $this->buildSoftwareVersion()); $originRegion = $this->getCountryParams( $this->_scopeConfig->getValue( From ad74fba18416c519c42898c8195d876b7ca05073 Mon Sep 17 00:00:00 2001 From: Joan He <johe@magento.com> Date: Tue, 22 Jan 2019 11:25:04 -0600 Subject: [PATCH 083/121] MC-4245: Upgrade DHL schema to the latest - fixed static test failures --- app/code/Magento/Dhl/Model/Carrier.php | 1 + app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php | 1 - .../Dhl/Test/Unit/Model/_files/dhl_quote_response_rates.php | 2 +- .../Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml | 6 ++++++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index eda7aee826487..685831138831c 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -1609,6 +1609,7 @@ protected function _doRequest() * @return void * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ protected function _shipmentDetails($xml, $rawRequest, $originRegion = '') { diff --git a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php index 0eb95b14d9727..ac458024fb65c 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php @@ -101,7 +101,6 @@ class CarrierTest extends \PHPUnit\Framework\TestCase */ private $productMetadataMock; - /** * @inheritdoc */ diff --git a/app/code/Magento/Dhl/Test/Unit/Model/_files/dhl_quote_response_rates.php b/app/code/Magento/Dhl/Test/Unit/Model/_files/dhl_quote_response_rates.php index e623b5944ce7c..ddd7b2e4f97c5 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/_files/dhl_quote_response_rates.php +++ b/app/code/Magento/Dhl/Test/Unit/Model/_files/dhl_quote_response_rates.php @@ -28,4 +28,4 @@ 'cost' => 35.26, 'method' => 'P' ] -]; \ No newline at end of file +]; diff --git a/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml b/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml index 896d631f01d50..e93753368f834 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml +++ b/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml @@ -1,4 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> <req:ShipmentRequest xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dhl.com ship-val-global-req-6.2.xsd" schemaVersion="6.2"> <Request xmlns=""> From 547b80b9ba59a127744a6b2e58f7b2efbdff2720 Mon Sep 17 00:00:00 2001 From: Ranee 2Jcommerce <ranee@2jcommerce.in> Date: Wed, 23 Jan 2019 11:23:42 +0530 Subject: [PATCH 084/121] tooltip-dropdown-pointer :: Tooltip dropdown pointer not proper on tablet --- .../css/source/module/checkout/_tooltip.less | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_tooltip.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_tooltip.less index bf264a98f33b8..e42d8eb7a8dd7 100644 --- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_tooltip.less +++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_tooltip.less @@ -147,3 +147,30 @@ } } } + +// +// Tablet +// _____________________________________________ +@media only screen and (max-width: @screen__m) { + .field-tooltip .field-tooltip-content { + right: -10px; + top: 40px; + left: auto; + } + .field-tooltip .field-tooltip-content::before, .field-tooltip .field-tooltip-content::after { + border: 10px solid transparent; + height: 0; + width: 0; + margin-top: -21px; + right: 10px; + left: auto; + top: 0; + } + .field-tooltip .field-tooltip-content::before { + border-bottom-color: #666; + } + .field-tooltip .field-tooltip-content::after { + border-bottom-color: #f4f4f4; + top: 1px; + } +} \ No newline at end of file From 6bac940657d1a8b428f85f7ae2e09f40bd97379a Mon Sep 17 00:00:00 2001 From: Oksana_Kremen <Oksana_Kremen@epam.com> Date: Wed, 23 Jan 2019 18:41:26 +0200 Subject: [PATCH 085/121] MAGETWO-96406: [2.3.x] Swatch Attribute is not displayed in the Widget CMS - Fixes for static tests and automation test --- .../view/frontend/layout/catalog_widget_product_list.xml | 2 +- .../Mftf/ActionGroup/CreateNewPageWithWidgetActionGroup.xml | 1 - app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/code/Magento/CatalogWidget/view/frontend/layout/catalog_widget_product_list.xml b/app/code/Magento/CatalogWidget/view/frontend/layout/catalog_widget_product_list.xml index 9a6d704ecce9b..db44d8b62dc1a 100644 --- a/app/code/Magento/CatalogWidget/view/frontend/layout/catalog_widget_product_list.xml +++ b/app/code/Magento/CatalogWidget/view/frontend/layout/catalog_widget_product_list.xml @@ -10,7 +10,7 @@ <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> - <block class="Magento\Framework\View\Element\RendererList" name="category.product.type.widget.details.renderers" alias="details.renderers"> + <block class="Magento\Framework\View\Element\RendererList" name="category.product.type.widget.details.renderers"> <block class="Magento\Framework\View\Element\Template" name="category.product.type.details.renderers.default" as="default"/> </block> </body> diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/CreateNewPageWithWidgetActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/CreateNewPageWithWidgetActionGroup.xml index 7c8694a247dee..a4b88c544de88 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/CreateNewPageWithWidgetActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/CreateNewPageWithWidgetActionGroup.xml @@ -30,7 +30,6 @@ <click selector="{{WidgetSection.RuleParam}}" stepKey="clickToAddRuleParam"/> <click selector="{{WidgetSection.Chooser}}" stepKey="clickToSelectFromList"/> <waitForPageLoad stepKey="waitForPageLoad2"/> - <click selector="{{WidgetSection.RuleParamListExpander('1')}}" stepKey="expandRootCategory"/> <click selector="{{WidgetSection.PreCreateCategory(category)}}" stepKey="selectPreCategory" /> <click selector="{{WidgetSection.InsertWidget}}" stepKey="clickToSaveInsertedWidget"/> <waitForPageLoad stepKey="waitForPageLoad3"/> diff --git a/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml b/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml index 101e694d75f55..c7ea85e441bb9 100644 --- a/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml +++ b/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml @@ -101,7 +101,6 @@ <element name="RuleParamSelect" type="select" selector="//ul[contains(@class,'rule-param-children')]/li[{{arg1}}]//*[contains(@class,'rule-param')][{{arg2}}]//select" parameterized="true"/> <element name="RuleParamInput" type="input" selector="//ul[contains(@class,'rule-param-children')]/li[{{arg1}}]//*[contains(@class,'rule-param')][{{arg2}}]//input" parameterized="true"/> <element name="RuleParamLabel" type="input" selector="//ul[contains(@class,'rule-param-children')]/li[{{arg1}}]//*[contains(@class,'rule-param')][{{arg2}}]//a" parameterized="true"/> - <element name="RuleParamListExpander" selector="//div[@class='rule-chooser']//ul[contains(@class,'x-tree-root')]//li[{{arg3}}]//img[contains(@class,'x-tree-elbow-end-plus')]" parameterized="true"/> <element name="Chooser" type="button" selector="//img[@title='Open Chooser']"/> <element name="PageSize" type="input" selector="input[name='parameters[page_size]']"/> <element name="ProductAttribute" type="multiselect" selector="select[name='parameters[show_attributes][]']" /> From fce9a9d5d8cd0db8a9aa8410ffdc607b75c59188 Mon Sep 17 00:00:00 2001 From: ajay-2jcommerce <ajay@2jcommerce.in> Date: Thu, 24 Jan 2019 19:04:31 +0530 Subject: [PATCH 086/121] Time-fields-misaligned-in-iPad-landscape-view ::Time fields misaligned in iPad landscape view (1024 x 768) --- .../web/css/source/module/main/_collapsible-blocks.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_collapsible-blocks.less b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_collapsible-blocks.less index 6420738c6fb9b..b12b4a71d5ce6 100644 --- a/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_collapsible-blocks.less +++ b/app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/main/_collapsible-blocks.less @@ -322,7 +322,7 @@ } .value { - padding-right: 4rem; + padding-right: 2rem; } } From 149d9e12a12e8da0bc3066e6e97e72f66adf497c Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky <p.bystritsky@yandex.ru> Date: Thu, 24 Jan 2019 13:13:38 +0200 Subject: [PATCH 087/121] magento/magento2#14849: Nullable status code fix. --- app/code/Magento/Sales/Model/Order/Config.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Sales/Model/Order/Config.php b/app/code/Magento/Sales/Model/Order/Config.php index 70cf8c181cf95..1b31caa573f99 100644 --- a/app/code/Magento/Sales/Model/Order/Config.php +++ b/app/code/Magento/Sales/Model/Order/Config.php @@ -109,7 +109,7 @@ protected function _getState($state) * @param string $state * @return string|null */ - public function getStateDefaultStatus($state) + public function getStateDefaultStatus($state): ?string { $status = false; $stateNode = $this->_getState($state); @@ -123,11 +123,11 @@ public function getStateDefaultStatus($state) /** * Get status label for a specified area * - * @param string $code + * @param string|null $code * @param string $area - * @return string + * @return string|null */ - private function getStatusLabelForArea(string $code, string $area): string + private function getStatusLabelForArea(?string $code, string $area): ?string { $code = $this->maskStatusForArea($area, $code); $status = $this->orderStatusFactory->create()->load($code); @@ -142,8 +142,8 @@ private function getStatusLabelForArea(string $code, string $area): string /** * Retrieve status label for detected area * - * @param string $code - * @return string + * @param string|null $code + * @return string|null * @throws LocalizedException */ public function getStatusLabel($code) @@ -155,10 +155,10 @@ public function getStatusLabel($code) /** * Retrieve status label for area * - * @param string $code - * @return string + * @param string|null $code + * @return string|null */ - public function getStatusFrontendLabel(string $code): string + public function getStatusFrontendLabel(?string $code): ?string { return $this->getStatusLabelForArea($code, \Magento\Framework\App\Area::AREA_FRONTEND); } From 12deeebc95e467bcc628bb39d2d8ec753ec20b85 Mon Sep 17 00:00:00 2001 From: Govind Sharma <govindpokhrelsharma@cedcoss.com> Date: Sat, 26 Jan 2019 21:09:19 +0530 Subject: [PATCH 088/121] Fixed Issue #20631 --- .../Magento/Ui/view/base/web/js/form/element/post-code.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js b/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js index 911574a0fb438..5bfba724dfbe8 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js @@ -26,14 +26,17 @@ define([ update: function (value) { var country = registry.get(this.parentName + '.' + 'country_id'), options = country.indexedOptions, - option; + option = null; if (!value) { return; } option = options[value]; - + if (!option) { + return; + } + if (option['is_zipcode_optional']) { this.error(false); this.validation = _.omit(this.validation, 'required-entry'); From d6dad52746402ad2fbe9713865a0709cafcaec3b Mon Sep 17 00:00:00 2001 From: Dominic <d.fernando@ism-apac.com> Date: Sun, 27 Jan 2019 22:36:06 +0530 Subject: [PATCH 089/121] reove hardcoded value --- .../Model/ConfigurableProductTypeResolver.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProductGraphQl/Model/ConfigurableProductTypeResolver.php b/app/code/Magento/ConfigurableProductGraphQl/Model/ConfigurableProductTypeResolver.php index aae39800cdd30..e4e1c6aab6922 100644 --- a/app/code/Magento/ConfigurableProductGraphQl/Model/ConfigurableProductTypeResolver.php +++ b/app/code/Magento/ConfigurableProductGraphQl/Model/ConfigurableProductTypeResolver.php @@ -8,6 +8,7 @@ namespace Magento\ConfigurableProductGraphQl\Model; use Magento\Framework\GraphQl\Query\Resolver\TypeResolverInterface; +use Magento\ConfigurableProduct\Model\Product\Type\Configurable as Type; /** * {@inheritdoc} @@ -19,7 +20,7 @@ class ConfigurableProductTypeResolver implements TypeResolverInterface */ public function resolveType(array $data) : string { - if (isset($data['type_id']) && $data['type_id'] == 'configurable') { + if (isset($data['type_id']) && $data['type_id'] == Type::TYPE_CODE) { return 'ConfigurableProduct'; } return ''; From 48a63ed446ea8e2761947ed46305cdeac6406929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20Hochd=C3=B6rfer?= <S.Hochdoerfer@bitExpert.de> Date: Sun, 27 Jan 2019 22:57:57 +0100 Subject: [PATCH 090/121] Fix typehint --- app/code/Magento/Quote/Model/Quote.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Quote/Model/Quote.php b/app/code/Magento/Quote/Model/Quote.php index ecda0dd2c0d74..17d3b9205625f 100644 --- a/app/code/Magento/Quote/Model/Quote.php +++ b/app/code/Magento/Quote/Model/Quote.php @@ -1399,7 +1399,7 @@ public function getAllItems() { $items = []; foreach ($this->getItemsCollection() as $item) { - /** @var \Magento\Quote\Model\ResourceModel\Quote\Item $item */ + /** @var \Magento\Quote\Model\Quote\Item $item */ if (!$item->isDeleted()) { $items[] = $item; } From e78576e382e6429296ae11835ef96472e284feaf Mon Sep 17 00:00:00 2001 From: "Leandro F. L" <lfluvisotto@gmail.com> Date: Sun, 27 Jan 2019 21:46:01 -0200 Subject: [PATCH 091/121] It is recommended to use the &&, || operators, instead of and, or to prevent confusion. --- .../Adminhtml/Product/Attribute/Validate.php | 2 +- .../Controller/Transparent/RequestSecureToken.php | 2 +- .../Security/Model/SecurityChecker/Quantity.php | 2 +- app/code/Magento/SendFriend/Model/SendFriend.php | 12 ++++++------ app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php | 2 +- .../testsuite/Magento/Test/Integrity/ClassesTest.php | 2 +- lib/internal/Magento/Framework/Filter/Template.php | 2 +- lib/internal/Magento/Framework/Message/Manager.php | 2 +- .../Setup/Model/ConfigOptionsList/Session.php | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php index 381ca5d08d82a..50f58efae7127 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php @@ -163,7 +163,7 @@ private function isUniqueAdminValues(array $optionsValues, array $deletedOptions { $adminValues = []; foreach ($optionsValues as $optionKey => $values) { - if (!(isset($deletedOptions[$optionKey]) and $deletedOptions[$optionKey] === '1')) { + if (!(isset($deletedOptions[$optionKey]) && $deletedOptions[$optionKey] === '1')) { $adminValues[] = reset($values); } } diff --git a/app/code/Magento/Paypal/Controller/Transparent/RequestSecureToken.php b/app/code/Magento/Paypal/Controller/Transparent/RequestSecureToken.php index 85907c9d371ab..b63799612a24d 100644 --- a/app/code/Magento/Paypal/Controller/Transparent/RequestSecureToken.php +++ b/app/code/Magento/Paypal/Controller/Transparent/RequestSecureToken.php @@ -83,7 +83,7 @@ public function execute() /** @var Quote $quote */ $quote = $this->sessionManager->getQuote(); - if (!$quote or !$quote instanceof Quote) { + if (!$quote || !$quote instanceof Quote) { return $this->getErrorResponse(); } diff --git a/app/code/Magento/Security/Model/SecurityChecker/Quantity.php b/app/code/Magento/Security/Model/SecurityChecker/Quantity.php index 9d86b55158be5..44538a7d8e21e 100644 --- a/app/code/Magento/Security/Model/SecurityChecker/Quantity.php +++ b/app/code/Magento/Security/Model/SecurityChecker/Quantity.php @@ -54,7 +54,7 @@ public function check($securityEventType, $accountReference = null, $longIp = nu { $isEnabled = $this->securityConfig->getPasswordResetProtectionType() != ResetMethod::OPTION_NONE; $allowedAttemptsNumber = $this->securityConfig->getMaxNumberPasswordResetRequests(); - if ($isEnabled and $allowedAttemptsNumber) { + if ($isEnabled && $allowedAttemptsNumber) { $collection = $this->prepareCollection($securityEventType, $accountReference, $longIp); if ($collection->count() >= $allowedAttemptsNumber) { throw new SecurityViolationException( diff --git a/app/code/Magento/SendFriend/Model/SendFriend.php b/app/code/Magento/SendFriend/Model/SendFriend.php index c69d6342b4892..79bac0e680952 100644 --- a/app/code/Magento/SendFriend/Model/SendFriend.php +++ b/app/code/Magento/SendFriend/Model/SendFriend.php @@ -236,7 +236,7 @@ public function validate() } $email = $this->getSender()->getEmail(); - if (empty($email) or !\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) { + if (empty($email) || !\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) { $errors[] = __('Invalid Sender Email'); } @@ -281,13 +281,13 @@ public function setRecipients($recipients) // validate array if (!is_array( $recipients - ) or !isset( + ) || !isset( $recipients['email'] - ) or !isset( + ) || !isset( $recipients['name'] - ) or !is_array( + ) || !is_array( $recipients['email'] - ) or !is_array( + ) || !is_array( $recipients['name'] ) ) { @@ -487,7 +487,7 @@ protected function _sentCountByCookies($increment = false) $oldTimes = explode(',', $oldTimes); foreach ($oldTimes as $oldTime) { $periodTime = $time - $this->_sendfriendData->getPeriod(); - if (is_numeric($oldTime) and $oldTime >= $periodTime) { + if (is_numeric($oldTime) && $oldTime >= $periodTime) { $newTimes[] = $oldTime; } } diff --git a/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php b/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php index 4aea7ab4c5a7c..cee4522903689 100755 --- a/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php +++ b/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php @@ -265,7 +265,7 @@ protected function processExtraTaxables(Address\Total $total, array $itemsByType { $extraTaxableDetails = []; foreach ($itemsByType as $itemType => $itemTaxDetails) { - if ($itemType != self::ITEM_TYPE_PRODUCT and $itemType != self::ITEM_TYPE_SHIPPING) { + if ($itemType != self::ITEM_TYPE_PRODUCT && $itemType != self::ITEM_TYPE_SHIPPING) { foreach ($itemTaxDetails as $itemCode => $itemTaxDetail) { /** @var \Magento\Tax\Api\Data\TaxDetailsInterface $taxDetails */ $taxDetails = $itemTaxDetail[self::KEY_ITEM]; diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php index 6d627574a3a18..b5a4e41b63279 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/ClassesTest.php @@ -194,7 +194,7 @@ private function assertClassesExist(array $classes, string $path): void foreach ($classes as $class) { $class = trim($class, '\\'); try { - if (strrchr($class, '\\') === false and !Classes::isVirtual($class)) { + if (strrchr($class, '\\') === false && !Classes::isVirtual($class)) { $badUsages[] = $class; continue; } else { diff --git a/lib/internal/Magento/Framework/Filter/Template.php b/lib/internal/Magento/Framework/Filter/Template.php index 3e5f9bcf0bd27..a56a4a3edf1fe 100644 --- a/lib/internal/Magento/Framework/Filter/Template.php +++ b/lib/internal/Magento/Framework/Filter/Template.php @@ -293,7 +293,7 @@ public function templateDirective($construction) { // Processing of {template config_path=... [...]} statement $templateParameters = $this->getParameters($construction[2]); - if (!isset($templateParameters['config_path']) or !$this->getTemplateProcessor()) { + if (!isset($templateParameters['config_path']) || !$this->getTemplateProcessor()) { // Not specified template or not set include processor $replacedValue = '{Error in template processing}'; } else { diff --git a/lib/internal/Magento/Framework/Message/Manager.php b/lib/internal/Magento/Framework/Message/Manager.php index c3b5701057d73..484d410181f48 100644 --- a/lib/internal/Magento/Framework/Message/Manager.php +++ b/lib/internal/Magento/Framework/Message/Manager.php @@ -226,7 +226,7 @@ public function addUniqueMessages(array $messages, $group = null) $items = $this->getMessages(false, $group)->getItems(); foreach ($messages as $message) { - if ($message instanceof MessageInterface and !in_array($message, $items, false)) { + if ($message instanceof MessageInterface && !in_array($message, $items, false)) { $this->addMessage($message, $group); } } diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList/Session.php b/setup/src/Magento/Setup/Model/ConfigOptionsList/Session.php index c0ec78f046e23..96edca6130cdc 100644 --- a/setup/src/Magento/Setup/Model/ConfigOptionsList/Session.php +++ b/setup/src/Magento/Setup/Model/ConfigOptionsList/Session.php @@ -340,7 +340,7 @@ public function validate(array $options, DeploymentConfig $deploymentConfig) if (isset($options[self::INPUT_KEY_SESSION_REDIS_LOG_LEVEL])) { $level = $options[self::INPUT_KEY_SESSION_REDIS_LOG_LEVEL]; - if (($level < 0) or ($level > 7)) { + if (($level < 0) || ($level > 7)) { $errors[] = "Invalid Redis log level '{$level}'. Valid range is 0-7, inclusive."; } } From 0e32d5a33ab4707bb3932b71e7b08d3de0f4dd7b Mon Sep 17 00:00:00 2001 From: Yuliya Labudova <Yuliya_Labudova@epam.com> Date: Mon, 28 Jan 2019 11:38:59 +0300 Subject: [PATCH 092/121] MAGETWO-95817: Issue in Redeeming Gift Card - Stabilize mftf test. --- .../Shipping/Test/Mftf/Data/FreeShippingMethodData.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/code/Magento/Shipping/Test/Mftf/Data/FreeShippingMethodData.xml b/app/code/Magento/Shipping/Test/Mftf/Data/FreeShippingMethodData.xml index 512ef8389bb7b..d700aa622c177 100644 --- a/app/code/Magento/Shipping/Test/Mftf/Data/FreeShippingMethodData.xml +++ b/app/code/Magento/Shipping/Test/Mftf/Data/FreeShippingMethodData.xml @@ -13,6 +13,13 @@ <entity name="freeActiveEnable" type="active"> <data key="value">1</data> </entity> + <!-- Disable Free Shipping method --> + <entity name="FreeShippingMethodDisableConfig" type="free_shipping_method"> + <requiredEntity type="active">freeActiveDisable</requiredEntity> + </entity> + <entity name="freeActiveDisable" type="active"> + <data key="value">0</data> + </entity> <!-- Free Shipping method default setup --> <entity name="FreeShippinMethodDefault" type="free_shipping_method"> <requiredEntity type="active">freeActiveDefault</requiredEntity> From 3b635263c112019bf631b866b916d383f61fa98c Mon Sep 17 00:00:00 2001 From: nmalevanec <mikola.malevanec@transoftgroup.com> Date: Mon, 28 Jan 2019 11:34:13 +0200 Subject: [PATCH 093/121] Fix static tests. --- .../web/css/source/module/checkout/_tooltip.less | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_tooltip.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_tooltip.less index e42d8eb7a8dd7..39b9a051e6592 100644 --- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_tooltip.less +++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_tooltip.less @@ -151,26 +151,28 @@ // // Tablet // _____________________________________________ + @media only screen and (max-width: @screen__m) { .field-tooltip .field-tooltip-content { + left: auto; right: -10px; top: 40px; - left: auto; } - .field-tooltip .field-tooltip-content::before, .field-tooltip .field-tooltip-content::after { + .field-tooltip .field-tooltip-content::before, + .field-tooltip .field-tooltip-content::after { border: 10px solid transparent; height: 0; - width: 0; + left: auto; margin-top: -21px; right: 10px; - left: auto; top: 0; + width: 0; } .field-tooltip .field-tooltip-content::before { - border-bottom-color: #666; + border-bottom-color: @color-gray40; } .field-tooltip .field-tooltip-content::after { - border-bottom-color: #f4f4f4; + border-bottom-color: @color-gray-light01; top: 1px; } -} \ No newline at end of file +} From ac39ca2e54fad653d1aef3f7f2a96affcbde5c78 Mon Sep 17 00:00:00 2001 From: amol 2jcommerce <amol@2jcommerce.in> Date: Mon, 28 Jan 2019 17:09:16 +0530 Subject: [PATCH 094/121] My-account-page-title-extra-space-on-mobile --- .../Magento/blank/Magento_Customer/web/css/source/_module.less | 2 +- .../Magento/luma/Magento_Customer/web/css/source/_module.less | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/_module.less b/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/_module.less index 3ffaeb82cdc2a..a22e5baeb57fc 100644 --- a/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/_module.less +++ b/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/_module.less @@ -368,7 +368,7 @@ .account { .page.messages { - margin-bottom: @indent__xl; + margin-bottom: 0; } .toolbar { diff --git a/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less index d7ae6c3b28f4a..fe423a236c80e 100755 --- a/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less @@ -551,7 +551,7 @@ .account { .page.messages { - margin-bottom: @indent__xl; + margin-bottom: 0; } .column.main { From fe35a75689b5950540f2731b6b0f19ce33e21fe9 Mon Sep 17 00:00:00 2001 From: amol 2jcommerce <amol@2jcommerce.in> Date: Mon, 28 Jan 2019 19:05:37 +0530 Subject: [PATCH 095/121] My-account-page-title-extra-space-on-mobile --- .../Magento/blank/Magento_Customer/web/css/source/_module.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/_module.less b/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/_module.less index a22e5baeb57fc..d914f691604cd 100644 --- a/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/_module.less +++ b/app/design/frontend/Magento/blank/Magento_Customer/web/css/source/_module.less @@ -367,7 +367,7 @@ } .account { - .page.messages { + .messages { margin-bottom: 0; } From b208e444bf108f8d5dfd800d952376ad2e4d4c13 Mon Sep 17 00:00:00 2001 From: amol 2jcommerce <amol@2jcommerce.in> Date: Mon, 28 Jan 2019 19:20:51 +0530 Subject: [PATCH 096/121] My-account-page-title-extra-space-on-mobile --- .../Magento/luma/Magento_Customer/web/css/source/_module.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less index c22fd6509248d..92ff50064f3ab 100755 --- a/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less @@ -554,7 +554,7 @@ } .account { - .page.messages { + .messages { margin-bottom: 0; } From 6c2d7d973468322af2094eb5aeec7072c7f16cd9 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky <p.bystritsky@yandex.ru> Date: Mon, 28 Jan 2019 16:50:22 +0200 Subject: [PATCH 097/121] ENGCOM-3980: Static test fix. --- .../Paypal/Controller/Transparent/RequestSecureToken.php | 2 ++ .../Magento/Security/Model/SecurityChecker/Quantity.php | 2 +- app/code/Magento/SendFriend/Model/SendFriend.php | 3 +++ app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php | 1 + lib/internal/Magento/Framework/Message/Manager.php | 2 ++ setup/src/Magento/Setup/Model/ConfigOptionsList/Session.php | 6 +++--- 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Paypal/Controller/Transparent/RequestSecureToken.php b/app/code/Magento/Paypal/Controller/Transparent/RequestSecureToken.php index b63799612a24d..847388eb755a1 100644 --- a/app/code/Magento/Paypal/Controller/Transparent/RequestSecureToken.php +++ b/app/code/Magento/Paypal/Controller/Transparent/RequestSecureToken.php @@ -107,6 +107,8 @@ public function execute() } /** + * Get error response. + * * @return Json */ private function getErrorResponse() diff --git a/app/code/Magento/Security/Model/SecurityChecker/Quantity.php b/app/code/Magento/Security/Model/SecurityChecker/Quantity.php index 44538a7d8e21e..5d72ba261f316 100644 --- a/app/code/Magento/Security/Model/SecurityChecker/Quantity.php +++ b/app/code/Magento/Security/Model/SecurityChecker/Quantity.php @@ -48,7 +48,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function check($securityEventType, $accountReference = null, $longIp = null) { diff --git a/app/code/Magento/SendFriend/Model/SendFriend.php b/app/code/Magento/SendFriend/Model/SendFriend.php index 79bac0e680952..38525a9f83a12 100644 --- a/app/code/Magento/SendFriend/Model/SendFriend.php +++ b/app/code/Magento/SendFriend/Model/SendFriend.php @@ -16,6 +16,7 @@ * @method \Magento\SendFriend\Model\SendFriend setTime(int $value) * * @author Magento Core Team <core@magentocommerce.com> + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * * @api @@ -162,6 +163,8 @@ protected function _construct() } /** + * Send email. + * * @return $this * @throws CoreException */ diff --git a/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php b/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php index cee4522903689..52061fd5d3882 100755 --- a/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php +++ b/app/code/Magento/Tax/Model/Sales/Total/Quote/Tax.php @@ -408,6 +408,7 @@ protected function enhanceTotalData( /** * Process model configuration array. + * * This method can be used for changing totals collect sort order * * @param array $config diff --git a/lib/internal/Magento/Framework/Message/Manager.php b/lib/internal/Magento/Framework/Message/Manager.php index 484d410181f48..4ef1754b7e586 100644 --- a/lib/internal/Magento/Framework/Message/Manager.php +++ b/lib/internal/Magento/Framework/Message/Manager.php @@ -11,6 +11,8 @@ /** * Message manager model + * + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Manager implements ManagerInterface diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList/Session.php b/setup/src/Magento/Setup/Model/ConfigOptionsList/Session.php index 96edca6130cdc..e864a81ffcc0e 100644 --- a/setup/src/Magento/Setup/Model/ConfigOptionsList/Session.php +++ b/setup/src/Magento/Setup/Model/ConfigOptionsList/Session.php @@ -139,7 +139,7 @@ class Session implements ConfigOptionsListInterface ]; /** - * {@inheritdoc} + * @inheritdoc * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function getOptions() @@ -289,7 +289,7 @@ public function getOptions() } /** - * {@inheritdoc} + * @inheritdoc */ public function createConfig(array $options, DeploymentConfig $deploymentConfig) { @@ -320,7 +320,7 @@ public function createConfig(array $options, DeploymentConfig $deploymentConfig) } /** - * {@inheritdoc} + * @inheritdoc */ public function validate(array $options, DeploymentConfig $deploymentConfig) { From 823e68473822fdd3125922a5a2d0a5e1bf0cd019 Mon Sep 17 00:00:00 2001 From: Andrew Molina <amolina@adobe.com> Date: Mon, 28 Jan 2019 13:12:04 -0600 Subject: [PATCH 098/121] MC-5717 - Sub-category doesnt display after moving categories --- app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php index 11c0a73a73708..77518fd9bf5cc 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php @@ -147,6 +147,7 @@ public function execute() $parentCategory = $this->getParentCategory($parentId, $storeId); $category->setPath($parentCategory->getPath()); $category->setParentId($parentCategory->getId()); + $category->setLevel(null); } /** From db9a3c89e0874d0ed76fec5d96195c5a7170efd3 Mon Sep 17 00:00:00 2001 From: Andrew Molina <amolina@adobe.com> Date: Mon, 28 Jan 2019 16:29:06 -0600 Subject: [PATCH 099/121] MC-5717: Sub-category doesnt display after moving categories Fixed static test failures --- .../Catalog/Controller/Adminhtml/Category/RefreshPath.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php index e58a0c5b0996e..e3d40bee214d1 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php @@ -1,6 +1,5 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ @@ -8,6 +7,9 @@ use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface; +/** + * Class RefreshPath + */ class RefreshPath extends \Magento\Catalog\Controller\Adminhtml\Category implements HttpGetActionInterface { /** From d1340328cb649cec143cd31484536e15393d00bf Mon Sep 17 00:00:00 2001 From: Oleksii Korshenko <korshenk@adobe.com> Date: Mon, 28 Jan 2019 16:44:17 -0600 Subject: [PATCH 100/121] Update post-code.js --- .../Magento/Ui/view/base/web/js/form/element/post-code.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js b/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js index 5bfba724dfbe8..72177a1804df0 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js @@ -33,11 +33,8 @@ define([ } option = options[value]; - if (!option) { - return; - } - if (option['is_zipcode_optional']) { + if (option && option['is_zipcode_optional']) { this.error(false); this.validation = _.omit(this.validation, 'required-entry'); } else { From 0902931633e350761e509a62ad66b22ff40cd093 Mon Sep 17 00:00:00 2001 From: Oleksii Korshenko <korshenk@adobe.com> Date: Mon, 28 Jan 2019 16:51:01 -0600 Subject: [PATCH 101/121] Update post-code.js --- .../Magento/Ui/view/base/web/js/form/element/post-code.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js b/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js index 72177a1804df0..b8bab2f72f38a 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js @@ -34,7 +34,11 @@ define([ option = options[value]; - if (option && option['is_zipcode_optional']) { + if (!option) { + return; + } + + if (option['is_zipcode_optional']) { this.error(false); this.validation = _.omit(this.validation, 'required-entry'); } else { From fb29ecf164c517cf415ef988b560b471594d5df0 Mon Sep 17 00:00:00 2001 From: Dominic <d.fernando@ism-apac.com> Date: Tue, 29 Jan 2019 10:57:41 +0530 Subject: [PATCH 102/121] add type resolve sting to const --- .../Model/ConfigurableProductTypeResolver.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProductGraphQl/Model/ConfigurableProductTypeResolver.php b/app/code/Magento/ConfigurableProductGraphQl/Model/ConfigurableProductTypeResolver.php index e4e1c6aab6922..f65a331ab803c 100644 --- a/app/code/Magento/ConfigurableProductGraphQl/Model/ConfigurableProductTypeResolver.php +++ b/app/code/Magento/ConfigurableProductGraphQl/Model/ConfigurableProductTypeResolver.php @@ -15,13 +15,19 @@ */ class ConfigurableProductTypeResolver implements TypeResolverInterface { + /** + * Configurable product type resolver code + */ + const TYPE_RESOLVER = 'ConfigurableProduct'; + /** * {@inheritdoc} */ public function resolveType(array $data) : string { if (isset($data['type_id']) && $data['type_id'] == Type::TYPE_CODE) { - return 'ConfigurableProduct'; + return self::TYPE_RESOLVER; + } return ''; } From 6401f7a1372007b1b3064044f64a462b75b517db Mon Sep 17 00:00:00 2001 From: satyaprakash <satyaprakash@cedcoss.com> Date: Tue, 29 Jan 2019 14:46:39 +0530 Subject: [PATCH 103/121] Code Cleanup : Typo Fixed enabed -> enabled --- .../Test/AdminAddWidgetToWYSIWYGWithCMSPageLinkTypeTest.xml | 2 +- .../AdminAddWidgetToWYSIWYGWithCatalogProductListTypeTest.xml | 2 +- ...inAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeTest.xml | 2 +- ...dminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeTest.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithCMSPageLinkTypeTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithCMSPageLinkTypeTest.xml index ded94eab92042..1adb781a67536 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithCMSPageLinkTypeTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithCMSPageLinkTypeTest.xml @@ -36,7 +36,7 @@ <see userInput="Inserting a widget does not create a widget instance." stepKey="seeMessage" /> <!--see Insert Widget button disabled--> <see selector="{{WidgetSection.InsertWidgetBtnDisabled}}" userInput="Insert Widget" stepKey="seeInsertWidgetDisabled" /> - <!--see Cancel button enabed--> + <!--see Cancel button enabled--> <see selector="{{WidgetSection.CancelBtnEnabled}}" userInput="Cancel" stepKey="seeCancelBtnEnabled" /> <!--Select "Widget Type"--> <selectOption selector="{{WidgetSection.WidgetType}}" userInput="CMS Page Link" stepKey="selectCMSPageLink" /> diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeTest.xml index 2586ffc11d086..394d79bda1ab3 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithCatalogProductListTypeTest.xml @@ -42,7 +42,7 @@ <see userInput="Inserting a widget does not create a widget instance." stepKey="seeMessage" /> <!--see Insert Widget button disabled--> <see selector="{{WidgetSection.InsertWidgetBtnDisabled}}" userInput="Insert Widget" stepKey="seeInsertWidgetDisabled" /> - <!--see Cancel button enabed--> + <!--see Cancel button enabled--> <see selector="{{WidgetSection.CancelBtnEnabled}}" userInput="Cancel" stepKey="seeCancelBtnEnabled" /> <!--Select "Widget Type"--> <selectOption selector="{{WidgetSection.WidgetType}}" userInput="Catalog Products List" stepKey="selectCatalogProductsList" /> diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeTest.xml index 691a99a73b90b..862f51ea72fad 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithRecentlyComparedProductsTypeTest.xml @@ -41,7 +41,7 @@ <waitForPageLoad stepKey="wait2"/> <!--see Insert Widget button disabled--> <see selector="{{WidgetSection.InsertWidgetBtnDisabled}}" userInput="Insert Widget" stepKey="seeInsertWidgetDisabled" /> - <!--see Cancel button enabed--> + <!--see Cancel button enabled--> <see selector="{{WidgetSection.CancelBtnEnabled}}" userInput="Cancel" stepKey="seeCancelBtnEnabled" /> <!--Select "Widget Type"--> <selectOption selector="{{WidgetSection.WidgetType}}" userInput="Recently Compared Products" stepKey="selectRecentlyComparedProducts" /> diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeTest.xml index 9cdbccd1f8c32..298aed917fc18 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminAddWidgetToWYSIWYGWithRecentlyViewedProductsTypeTest.xml @@ -40,7 +40,7 @@ <see userInput="Inserting a widget does not create a widget instance." stepKey="seeMessage" /> <!--see Insert Widget button disabled--> <see selector="{{WidgetSection.InsertWidgetBtnDisabled}}" userInput="Insert Widget" stepKey="seeInsertWidgetDisabled" /> - <!--see Cancel button enabed--> + <!--see Cancel button enabled--> <see selector="{{WidgetSection.CancelBtnEnabled}}" userInput="Cancel" stepKey="seeCancelBtnEnabled" /> <!--Select "Widget Type"--> <selectOption selector="{{WidgetSection.WidgetType}}" userInput="Recently Viewed Products" stepKey="selectRecentlyViewedProducts" /> From ed7586ff3a83e5e87f076f678317ea1435344d55 Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <veronika_kurochkina@epam.com> Date: Tue, 29 Jan 2019 12:40:49 +0300 Subject: [PATCH 104/121] MAGETWO-95823: Order Sales Report includes canceled orders - Update automated test --- .../ActionGroup/AdminOrderActionGroup.xml | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderActionGroup.xml index 8732e7cd84ed6..aea04c8abfa60 100644 --- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderActionGroup.xml +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminOrderActionGroup.xml @@ -361,28 +361,6 @@ <see selector="{{AdminOrderDetailsInformationSection.orderStatus}}" userInput="{{orderStatus}}" stepKey="seeOrderStatusCanceled"/> </actionGroup> - <!-- Create Order --> - <actionGroup name="CreateOrderActionGroup"> - <arguments> - <argument name="product"/> - <argument name="customer"/> - </arguments> - <amOnPage stepKey="navigateToNewOrderPage" url="{{AdminOrderCreatePage.url}}"/> - <click stepKey="chooseCustomer" selector="{{AdminOrdersGridSection.customerInOrdersSection(customer.firstname)}}"/> - <waitForPageLoad stepKey="waitForStoresPageOpened"/> - <click selector="{{OrdersGridSection.addProducts}}" stepKey="clickOnAddProducts"/> - <waitForPageLoad stepKey="waitForProductsListForOrder"/> - <click selector="{{AdminOrdersGridSection.productForOrder(product.sku)}}" stepKey="chooseTheProduct"/> - <click selector="{{AdminOrderFormItemsSection.addSelected}}" stepKey="addSelectedProductToOrder"/> - <waitForPageLoad stepKey="waitForProductAddedInOrder"/> - <click selector="{{AdminInvoicePaymentShippingSection.getShippingMethodAndRates}}" stepKey="openShippingMethod"/> - <waitForPageLoad stepKey="waitForShippingMethods"/> - <click selector="{{AdminInvoicePaymentShippingSection.shippingMethod}}" stepKey="chooseShippingMethod"/> - <waitForPageLoad stepKey="waitForShippingMethodsThickened"/> - <click selector="{{OrdersGridSection.submitOrder}}" stepKey="submitOrder"/> - <see stepKey="seeSuccessMessageForOrder" userInput="You created the order."/> - </actionGroup> - <!--Select Check Money payment method--> <actionGroup name="SelectCheckMoneyPaymentMethod"> <waitForElementVisible selector="{{AdminOrderFormPaymentSection.paymentBlock}}" stepKey="waitForPaymentOptions"/> From 040e5b5a72db21897ac599cf70b8845dcec8596d Mon Sep 17 00:00:00 2001 From: Dominic <d.fernando@ism-apac.com> Date: Tue, 29 Jan 2019 18:14:18 +0530 Subject: [PATCH 105/121] add missing php doc comment --- .../Magento/BundleGraphQl/Model/Resolver/Options/Collection.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/BundleGraphQl/Model/Resolver/Options/Collection.php b/app/code/Magento/BundleGraphQl/Model/Resolver/Options/Collection.php index 149155c86275a..7608d6e9e4d97 100644 --- a/app/code/Magento/BundleGraphQl/Model/Resolver/Options/Collection.php +++ b/app/code/Magento/BundleGraphQl/Model/Resolver/Options/Collection.php @@ -61,6 +61,7 @@ public function __construct( * Add parent id/sku pair to use for option filter at fetch time. * * @param int $parentId + * @param int $parentEntityId * @param string $sku */ public function addParentFilterData(int $parentId, int $parentEntityId, string $sku) : void From 2bb00c285664d0e42f68217d2ccff6f8e3397e46 Mon Sep 17 00:00:00 2001 From: DianaRusin <rusind95@gmail.com> Date: Tue, 29 Jan 2019 15:02:50 +0200 Subject: [PATCH 106/121] MAGETWO-97952: Automate with Integration test Confirmation email should be delivered to the customer when address contains '+' symbol --- .../Customer/Controller/AccountTest.php | 164 ++++++++++++------ .../customer_confirmation_config_disable.php | 21 +++ ...r_confirmation_config_disable_rollback.php | 23 +++ .../customer_confirmation_config_enable.php | 21 +++ ...er_confirmation_config_enable_rollback.php | 23 +++ ...ation_email_address_with_special_chars.php | 37 ++++ ...il_address_with_special_chars_rollback.php | 31 ++++ 7 files changed, 266 insertions(+), 54 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_disable.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_disable_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_enable.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_enable_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_address_with_special_chars.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_address_with_special_chars_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php index c94948e23ab4d..ea7a7710acbc3 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php @@ -17,18 +17,35 @@ use Magento\Framework\App\Http; use Magento\Framework\Data\Form\FormKey; use Magento\Framework\Message\MessageInterface; -use Magento\Store\Model\ScopeInterface; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\Request; use Magento\TestFramework\Response; use Zend\Stdlib\Parameters; use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\TestFramework\Mail\Template\TransportBuilderMock; +use Magento\Framework\Serialize\Serializer\Json; +use Magento\Framework\Stdlib\CookieManagerInterface; +use Magento\Theme\Controller\Result\MessagePlugin; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AccountTest extends \Magento\TestFramework\TestCase\AbstractController { + /** + * @var TransportBuilderMock + */ + private $transportBuilderMock; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + $this->transportBuilderMock = $this->_objectManager->get(TransportBuilderMock::class); + } + /** * Login the user * @@ -133,11 +150,7 @@ public function testForgotPasswordEmailMessageWithSpecialCharacters() $this->dispatch('customer/account/forgotPasswordPost'); $this->assertRedirect($this->stringContains('customer/account/')); - /** @var \Magento\TestFramework\Mail\Template\TransportBuilderMock $transportBuilder */ - $transportBuilder = $this->_objectManager->get( - \Magento\TestFramework\Mail\Template\TransportBuilderMock::class - ); - $subject = $transportBuilder->getSentMessage()->getSubject(); + $subject = $this->transportBuilderMock->getSentMessage()->getSubject(); $this->assertContains( 'Test special\' characters', $subject @@ -260,26 +273,10 @@ public function testNoFormKeyCreatePostAction() /** * @magentoDbIsolation enabled * @magentoAppIsolation enabled + * @magentoDataFixture Magento/Customer/_files/customer_confirmation_config_disable.php */ public function testNoConfirmCreatePostAction() { - /** @var \Magento\Framework\App\Config\MutableScopeConfigInterface $mutableScopeConfig */ - $mutableScopeConfig = Bootstrap::getObjectManager() - ->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class); - - $scopeValue = $mutableScopeConfig->getValue( - 'customer/create_account/confirm', - ScopeInterface::SCOPE_WEBSITES, - null - ); - - $mutableScopeConfig->setValue( - 'customer/create_account/confirm', - 0, - ScopeInterface::SCOPE_WEBSITES, - null - ); - $this->fillRequestWithAccountDataAndFormKey('test1@email.com'); $this->dispatch('customer/account/createPost'); $this->assertRedirect($this->stringEndsWith('customer/account/')); @@ -287,38 +284,15 @@ public function testNoConfirmCreatePostAction() $this->equalTo(['Thank you for registering with Main Website Store.']), MessageInterface::TYPE_SUCCESS ); - - $mutableScopeConfig->setValue( - 'customer/create_account/confirm', - $scopeValue, - ScopeInterface::SCOPE_WEBSITES, - null - ); } /** * @magentoDbIsolation enabled * @magentoAppIsolation enabled + * @magentoDataFixture Magento/Customer/_files/customer_confirmation_config_enable.php */ public function testWithConfirmCreatePostAction() { - /** @var \Magento\Framework\App\Config\MutableScopeConfigInterface $mutableScopeConfig */ - $mutableScopeConfig = Bootstrap::getObjectManager() - ->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class); - - $scopeValue = $mutableScopeConfig->getValue( - 'customer/create_account/confirm', - ScopeInterface::SCOPE_WEBSITES, - null - ); - - $mutableScopeConfig->setValue( - 'customer/create_account/confirm', - 1, - ScopeInterface::SCOPE_WEBSITES, - null - ); - $this->fillRequestWithAccountDataAndFormKey('test2@email.com'); $this->dispatch('customer/account/createPost'); $this->assertRedirect($this->stringContains('customer/account/index/')); @@ -330,13 +304,6 @@ public function testWithConfirmCreatePostAction() ]), MessageInterface::TYPE_SUCCESS ); - - $mutableScopeConfig->setValue( - 'customer/create_account/confirm', - $scopeValue, - ScopeInterface::SCOPE_WEBSITES, - null - ); } /** @@ -730,6 +697,46 @@ public function testLoginPostRedirect($redirectDashboard, string $redirectUrl) $this->assertTrue($this->_objectManager->get(Session::class)->isLoggedIn()); } + /** + * Test that confirmation email address displays special characters correctly. + * + * @magentoDbIsolation enabled + * @magentoDataFixture Magento/Customer/_files/customer_confirmation_email_address_with_special_chars.php + * + * @return void + */ + public function testConfirmationEmailWithSpecialCharacters(): void + { + $email = 'customer+confirmation@example.com'; + $this->dispatch('customer/account/confirmation/email/customer%2Bconfirmation%40email.com'); + $this->getRequest()->setPostValue('email', $email); + $this->dispatch('customer/account/confirmation/email/customer%2Bconfirmation%40email.com'); + + $this->assertRedirect($this->stringContains('customer/account/index')); + $this->assertSessionMessages( + $this->equalTo(['Please check your email for confirmation key.']), + MessageInterface::TYPE_SUCCESS + ); + + /** @var $message \Magento\Framework\Mail\Message */ + $message = $this->transportBuilderMock->getSentMessage(); + $rawMessage = $message->getRawMessage(); + + $this->assertContains('To: ' . $email, $rawMessage); + + $content = $message->getBody()->getPartContent(0); + $confirmationUrl = $this->getConfirmationUrlFromMessageContent($content); + $this->setRequestInfo($confirmationUrl, 'confirm'); + $this->clearCookieMessagesList(); + $this->dispatch($confirmationUrl); + + $this->assertRedirect($this->stringContains('customer/account/index')); + $this->assertSessionMessages( + $this->equalTo(['Thank you for registering with Main Website Store.']), + MessageInterface::TYPE_SUCCESS + ); + } + /** * Data provider for testLoginPostRedirect. * @@ -847,4 +854,53 @@ private function assertResponseRedirect(Response $response, string $redirectUrl) $this->assertTrue($response->isRedirect()); $this->assertSame($redirectUrl, $response->getHeader('Location')->getUri()); } + + /** + * Add new request info (request uri, path info, action name). + * + * @param string $uri + * @param string $actionName + * @return void + */ + private function setRequestInfo(string $uri, string $actionName): void + { + $this->getRequest() + ->setRequestUri($uri) + ->setPathInfo() + ->setActionName($actionName); + } + + /** + * Clear cookie messages list. + * + * @return void + */ + private function clearCookieMessagesList(): void + { + $cookieManager = $this->_objectManager->get(CookieManagerInterface::class); + $jsonSerializer = $this->_objectManager->get(Json::class); + $cookieManager->setPublicCookie( + MessagePlugin::MESSAGES_COOKIES_NAME, + $jsonSerializer->serialize([]) + ); + } + + /** + * Get confirmation URL from message content. + * + * @param string $content + * @return string + */ + private function getConfirmationUrlFromMessageContent(string $content): string + { + $confirmationUrl = ''; + + if (preg_match('<a\s*href="(?<url>.*?)".*>', $content, $matches)) { + $confirmationUrl = $matches['url']; + $confirmationUrl = str_replace('http://localhost/index.php/', '', $confirmationUrl); + $confirmationUrl = html_entity_decode($confirmationUrl); + } + + return $confirmationUrl; + } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_disable.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_disable.php new file mode 100644 index 0000000000000..7d4e451db514b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_disable.php @@ -0,0 +1,21 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +use Magento\Store\Model\ScopeInterface; +use Magento\Framework\App\Config\MutableScopeConfigInterface; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +$mutableScopeConfig = $objectManager->create(MutableScopeConfigInterface::class); + +$mutableScopeConfig->setValue( + 'customer/create_account/confirm', + 0, + ScopeInterface::SCOPE_WEBSITES, + null +); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_disable_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_disable_rollback.php new file mode 100644 index 0000000000000..36743b4a20e9a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_disable_rollback.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +use Magento\Config\Model\ResourceModel\Config; +use Magento\Framework\Registry; +use Magento\TestFramework\Helper\Bootstrap; + +/** @var Registry $registry */ +$registry = Bootstrap::getObjectManager()->get(Registry::class); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var Config $config */ +$config = Bootstrap::getObjectManager()->create(Config::class); +$config->deleteConfig('customer/create_account/confirm'); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_enable.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_enable.php new file mode 100644 index 0000000000000..c8deb7ec2a536 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_enable.php @@ -0,0 +1,21 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +use Magento\Store\Model\ScopeInterface; +use Magento\Framework\App\Config\MutableScopeConfigInterface; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +$mutableScopeConfig = $objectManager->create(MutableScopeConfigInterface::class); + +$mutableScopeConfig->setValue( + 'customer/create_account/confirm', + 1, + ScopeInterface::SCOPE_WEBSITES, + null +); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_enable_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_enable_rollback.php new file mode 100644 index 0000000000000..36743b4a20e9a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_config_enable_rollback.php @@ -0,0 +1,23 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +use Magento\Config\Model\ResourceModel\Config; +use Magento\Framework\Registry; +use Magento\TestFramework\Helper\Bootstrap; + +/** @var Registry $registry */ +$registry = Bootstrap::getObjectManager()->get(Registry::class); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var Config $config */ +$config = Bootstrap::getObjectManager()->create(Config::class); +$config->deleteConfig('customer/create_account/confirm'); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_address_with_special_chars.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_address_with_special_chars.php new file mode 100644 index 0000000000000..c4f046bac57a6 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_address_with_special_chars.php @@ -0,0 +1,37 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Customer\Model\Customer; +use Magento\TestFramework\Helper\Bootstrap; + +include __DIR__ . '/customer_confirmation_config_enable.php'; + +$objectManager = Bootstrap::getObjectManager(); + +/** @var Customer $customer */ +$customer = $objectManager->create(Customer::class); +/** @var CustomerRepositoryInterface $customerRepository */ +$customerRepository = $objectManager->create(CustomerRepositoryInterface::class); +/** @var CustomerInterface $customerInterface */ +$customerInterface = $objectManager->create(CustomerInterface::class); + +$customerInterface->setWebsiteId(1) + ->setEmail('customer+confirmation@example.com') + ->setConfirmation($customer->getRandomConfirmationKey()) + ->setGroupId(1) + ->setStoreId(1) + ->setFirstname('John') + ->setLastname('Smith') + ->setDefaultBilling(1) + ->setDefaultShipping(1) + ->setTaxvat('12') + ->setGender(0); + +$customerRepository->save($customerInterface, 'password'); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_address_with_special_chars_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_address_with_special_chars_rollback.php new file mode 100644 index 0000000000000..7a0ebf74ed8a0 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_address_with_special_chars_rollback.php @@ -0,0 +1,31 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +declare(strict_types=1); + +include __DIR__ . '/customer_confirmation_config_enable_rollback.php'; + +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Framework\Registry; +use Magento\TestFramework\Helper\Bootstrap; + +/** @var Registry $registry */ +$registry = Bootstrap::getObjectManager()->get(Registry::class); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var CustomerRepositoryInterface $customerRepository */ +$customerRepository = Bootstrap::getObjectManager()->create(CustomerRepositoryInterface::class); + +try { + $customer = $customerRepository->get('customer+confirmation@example.com'); + $customerRepository->delete($customer); +} catch (\Magento\Framework\Exception\NoSuchEntityException $e) { + // Customer with the specified email does not exist +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); From 3167a47c17643582832637a976cb624bdd90cdf7 Mon Sep 17 00:00:00 2001 From: Andrii Meysar <andrii.meysar@transoftgroup.com> Date: Tue, 29 Jan 2019 16:59:53 +0200 Subject: [PATCH 107/121] MAGETWO-97953: Automate with Integration test Verify Email functionality for order --- .../TestCase/AbstractBackendController.php | 4 +- .../Adminhtml/Order/Create/SaveTest.php | 160 +++++++++++++++++- .../AbstractCreditmemoControllerTest.php | 92 ++++++++++ .../Order/Creditmemo/AddCommentTest.php | 102 +++++++++++ .../Adminhtml/Order/Creditmemo/SaveTest.php | 99 +++++++++++ .../Controller/Adminhtml/Order/EmailTest.php | 136 +++++++++++++++ .../Invoice/AbstractInvoiceControllerTest.php | 92 ++++++++++ .../Order/Invoice/AddCommentTest.php | 103 +++++++++++ .../Adminhtml/Order/Invoice/EmailTest.php | 88 ++++++++++ .../Adminhtml/Order/Invoice/SaveTest.php | 97 +++++++++++ .../Magento/Sales/Model/Order/CreateTest.php | 100 +++++++++++ .../_files/guest_quote_with_addresses.php | 68 ++++++++ .../guest_quote_with_addresses_rollback.php | 32 ++++ .../AbstractShipmentControllerTest.php | 92 ++++++++++ .../Order/Shipment/AddCommentTest.php | 102 +++++++++++ .../Adminhtml/Order/Shipment/SaveTest.php | 97 +++++++++++ 16 files changed, 1458 insertions(+), 6 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AbstractCreditmemoControllerTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/SaveTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/AbstractInvoiceControllerTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddCommentTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/EmailTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/SaveTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Model/Order/CreateTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/guest_quote_with_addresses.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/guest_quote_with_addresses_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AbstractShipmentControllerTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddCommentTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/SaveTest.php diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php index b2e0b57bae729..7a387bd41eec2 100644 --- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php +++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php @@ -5,8 +5,6 @@ */ namespace Magento\TestFramework\TestCase; -use Magento\Framework\App\Request\Http as HttpRequest; - /** * A parent class for backend controllers - contains directives for admin user creation and authentication. * @@ -122,7 +120,7 @@ public function testAclHasAccess() */ public function testAclNoAccess() { - if ($this->resource === null) { + if ($this->resource === null || $this->uri === null) { $this->markTestIncomplete('Acl test is not complete'); } if ($this->httpMethod) { diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/SaveTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/SaveTest.php index e2638b5df1f88..f863edd049258 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/SaveTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/SaveTest.php @@ -9,21 +9,61 @@ use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\App\Request\Http; +use Magento\Framework\Data\Form\FormKey; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Message\MessageInterface; use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Model\OrderRepository; use Magento\Sales\Model\Service\OrderService; +use Magento\TestFramework\Mail\Template\TransportBuilderMock; use Magento\TestFramework\TestCase\AbstractBackendController; +use PHPUnit\Framework\Constraint\StringContains; use PHPUnit_Framework_MockObject_MockObject as MockObject; +/** + * Class test backend order save. + * + * @magentoAppArea adminhtml + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class SaveTest extends AbstractBackendController { + /** + * @var TransportBuilderMock + */ + private $transportBuilder; + + /** + * @var FormKey + */ + private $formKey; + + /** + * @var string + */ + protected $resource = 'Magento_Sales::create'; + + /** + * @var string + */ + protected $uri = 'backend/sales/order_create/save'; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + $this->transportBuilder = $this->_objectManager->get(TransportBuilderMock::class); + $this->formKey = $this->_objectManager->get(FormKey::class); + } + /** * Checks a case when order creation is failed on payment method processing but new customer already created * in the database and after new controller dispatching the customer should be already loaded in session * to prevent invalid validation. * - * @magentoAppArea adminhtml * @magentoDataFixture Magento/Sales/_files/quote_with_new_customer.php */ public function testExecuteWithPaymentOperation() @@ -36,7 +76,7 @@ public function testExecuteWithPaymentOperation() $email = 'john.doe001@test.com'; $data = [ 'account' => [ - 'email' => $email + 'email' => $email, ] ]; $this->getRequest()->setMethod(Http::METHOD_POST); @@ -66,13 +106,52 @@ public function testExecuteWithPaymentOperation() $this->_objectManager->removeSharedInstance(OrderService::class); } + /** + * @magentoDbIsolation enabled + * @magentoDataFixture Magento/Sales/_files/guest_quote_with_addresses.php + * + * @return void + */ + public function testSendEmailOnOrderSave(): void + { + $this->prepareRequest(['send_confirmation' => true]); + $this->dispatch('backend/sales/order_create/save'); + $this->assertSessionMessages( + $this->equalTo([(string)__('You created the order.')]), + MessageInterface::TYPE_SUCCESS + ); + + $this->assertRedirect($this->stringContains('sales/order/view/')); + + $orderId = $this->getOrderId(); + if ($orderId === false) { + $this->fail('Order is not created.'); + } + $order = $this->getOrder($orderId); + + $message = $this->transportBuilder->getSentMessage(); + $subject = __('Your %1 order confirmation', $order->getStore()->getFrontendName())->render(); + $assert = $this->logicalAnd( + new StringContains($order->getBillingAddress()->getName()), + new StringContains( + 'Thank you for your order from ' . $order->getStore()->getFrontendName() + ), + new StringContains( + "Your Order <span class=\"no-link\">#{$order->getIncrementId()}</span>" + ) + ); + + $this->assertEquals($message->getSubject(), $subject); + $this->assertThat($message->getRawMessage(), $assert); + } + /** * Gets quote by reserved order id. * * @param string $reservedOrderId * @return \Magento\Quote\Api\Data\CartInterface */ - private function getQuote($reservedOrderId) + private function getQuote(string $reservedOrderId): \Magento\Quote\Api\Data\CartInterface { /** @var SearchCriteriaBuilder $searchCriteriaBuilder */ $searchCriteriaBuilder = $this->_objectManager->get(SearchCriteriaBuilder::class); @@ -82,6 +161,81 @@ private function getQuote($reservedOrderId) /** @var CartRepositoryInterface $quoteRepository */ $quoteRepository = $this->_objectManager->get(CartRepositoryInterface::class); $items = $quoteRepository->getList($searchCriteria)->getItems(); + return array_pop($items); } + + /** + * @inheritdoc + * @magentoDbIsolation enabled + * @magentoDataFixture Magento/Sales/_files/guest_quote_with_addresses.php + */ + public function testAclHasAccess() + { + $this->prepareRequest(); + + parent::testAclHasAccess(); + } + + /** + * @inheritdoc + * @magentoDbIsolation enabled + * @magentoDataFixture Magento/Sales/_files/guest_quote_with_addresses.php + */ + public function testAclNoAccess() + { + $this->prepareRequest(); + + parent::testAclNoAccess(); + } + + /** + * @param int $orderId + * @return OrderInterface + */ + private function getOrder(int $orderId): OrderInterface + { + return $this->_objectManager->get(OrderRepository::class)->get($orderId); + } + + /** + * @param array $params + * @return void + */ + private function prepareRequest(array $params = []): void + { + $quote = $this->getQuote('guest_quote'); + $session = $this->_objectManager->get(Quote::class); + $session->setQuoteId($quote->getId()); + $session->setCustomerId(0); + + $email = 'john.doe001@test.com'; + $data = [ + 'account' => [ + 'email' => $email, + ], + ]; + + $data = array_replace_recursive($data, $params); + + $this->getRequest() + ->setMethod('POST') + ->setParams(['form_key' => $this->formKey->getFormKey()]) + ->setPostValue(['order' => $data]); + } + + /** + * @return string|bool + */ + protected function getOrderId() + { + $currentUrl = $this->getResponse()->getHeader('Location'); + $orderId = false; + + if (preg_match('/order_id\/(?<order_id>\d+)/', $currentUrl, $matches)) { + $orderId = $matches['order_id'] ?? ''; + } + + return $orderId; + } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AbstractCreditmemoControllerTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AbstractCreditmemoControllerTest.php new file mode 100644 index 0000000000000..2a7731715021b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AbstractCreditmemoControllerTest.php @@ -0,0 +1,92 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo; + +use Magento\Framework\Api\SearchCriteria; +use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Data\Form\FormKey; +use Magento\Sales\Api\Data\CreditmemoInterface; +use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Model\OrderRepository; +use Magento\TestFramework\Mail\Template\TransportBuilderMock; +use Magento\TestFramework\TestCase\AbstractBackendController; + +/** + * Abstract backend creditmemo test. + */ +class AbstractCreditmemoControllerTest extends AbstractBackendController +{ + /** + * @var TransportBuilderMock + */ + protected $transportBuilder; + + /** + * @var OrderRepository + */ + protected $orderRepository; + + /** + * @var FormKey + */ + protected $formKey; + + /** + * @var string + */ + protected $resource = 'Magento_Sales::sales_creditmemo'; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + $this->transportBuilder = $this->_objectManager->get(TransportBuilderMock::class); + $this->orderRepository = $this->_objectManager->get(OrderRepository::class); + $this->formKey = $this->_objectManager->get(FormKey::class); + } + + /** + * @param string $incrementalId + * @return OrderInterface|null + */ + protected function getOrder(string $incrementalId) + { + /** @var SearchCriteria $searchCriteria */ + $searchCriteria = $this->_objectManager->create(SearchCriteriaBuilder::class) + ->addFilter(OrderInterface::INCREMENT_ID, $incrementalId) + ->create(); + + $orders = $this->orderRepository->getList($searchCriteria)->getItems(); + /** @var OrderInterface|null $order */ + $order = reset($orders); + + return $order; + } + + /** + * @param OrderInterface $order + * @return CreditmemoInterface + */ + protected function getCreditMemo(OrderInterface $order): CreditmemoInterface + { + /** @var \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection $creditMemoCollection */ + $creditMemoCollection = $this->_objectManager->create( + \Magento\Sales\Model\ResourceModel\Order\Creditmemo\CollectionFactory::class + )->create(); + + /** @var CreditmemoInterface $creditMemo */ + $creditMemo = $creditMemoCollection + ->setOrderFilter($order) + ->setPageSize(1) + ->getFirstItem(); + + return $creditMemo; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php new file mode 100644 index 0000000000000..2f23da8b3db87 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php @@ -0,0 +1,102 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo; + +use PHPUnit\Framework\Constraint\RegularExpression; +use PHPUnit\Framework\Constraint\StringContains; + +/** + * Class verifies creditmemo add comment functionality. + * + * @magentoDbIsolation enabled + * @magentoAppArea adminhtml + * @magentoDataFixture Magento/Sales/_files/creditmemo_for_get.php + */ +class AddCommentTest extends AbstractCreditmemoControllerTest +{ + /** + * @var string + */ + protected $uri = 'backend/sales/order_creditmemo/addComment'; + + /** + * @return void + */ + public function testSendEmailOnAddCreditmemoComment(): void + { + $comment = 'Test Credit Memo Comment'; + $order = $this->prepareRequest( + [ + 'comment' => ['comment' => $comment, 'is_customer_notified' => true], + ] + ); + $this->dispatch('backend/sales/order_creditmemo/addComment'); + $html = $this->getResponse()->getBody(); + $this->assertContains($comment, $html); + + $message = $this->transportBuilder->getSentMessage(); + $subject =__('Update to your %1 credit memo', $order->getStore()->getFrontendName())->render(); + $messageConstraint = $this->logicalAnd( + new StringContains($order->getBillingAddress()->getName()), + new RegularExpression( + sprintf( + "/Your order #%s has been updated with a status of.*%s/", + $order->getIncrementId(), + $order->getFrontendStatusLabel() + ) + ), + new StringContains($comment) + ); + + $this->assertEquals($message->getSubject(), $subject); + $this->assertThat($message->getRawMessage(), $messageConstraint); + } + + /** + * @inheritdoc + */ + public function testAclHasAccess() + { + $this->prepareRequest(['comment' => ['comment' => 'Comment']]); + + parent::testAclHasAccess(); + } + + /** + * @inheritdoc + */ + public function testAclNoAccess() + { + $this->prepareRequest(['comment' => ['comment' => 'Comment']]); + + parent::testAclNoAccess(); + } + + /** + * @param array $params + * @return \Magento\Sales\Api\Data\OrderInterface|null + */ + private function prepareRequest(array $params = []) + { + $order = $this->getOrder('100000001'); + $creditmemo = $this->getCreditMemo($order); + + $this->getRequest()->setMethod('POST'); + $this->getRequest()->setParams( + [ + 'id' => $creditmemo->getEntityId(), + 'form_key' => $this->formKey->getFormKey(), + ] + ); + + $data = $params ?? []; + $this->getRequest()->setPostValue($data); + + return $order; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/SaveTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/SaveTest.php new file mode 100644 index 0000000000000..fa5da2e0e50d1 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/SaveTest.php @@ -0,0 +1,99 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo; + +use PHPUnit\Framework\Constraint\StringContains; + +/** + * Class tests creditmemo creation in backend. + * + * @magentoDbIsolation enabled + * @magentoAppArea adminhtml + * @magentoDataFixture Magento/Sales/_files/invoice.php + */ +class SaveTest extends AbstractCreditmemoControllerTest +{ + /** + * @var string + */ + protected $uri = 'backend/sales/order_creditmemo/save'; + + /** + * @return void + */ + public function testSendEmailOnCreditmemoSave(): void + { + $order = $this->prepareRequest(['creditmemo' => ['send_email' => true]]); + $this->dispatch('backend/sales/order_creditmemo/save'); + + $this->assertSessionMessages( + $this->equalTo([(string)__('You created the credit memo.')]), + \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS + ); + $this->assertRedirect($this->stringContains('sales/order/view/order_id/' . $order->getEntityId())); + + $creditMemo = $this->getCreditMemo($order); + $message = $this->transportBuilder->getSentMessage(); + $subject = __('Credit memo for your %1 order', $order->getStore()->getFrontendName())->render(); + $messageConstraint = $this->logicalAnd( + new StringContains($order->getBillingAddress()->getName()), + new StringContains( + 'Thank you for your order from ' . $creditMemo->getStore()->getFrontendName() + ), + new StringContains( + "Your Credit Memo #{$creditMemo->getIncrementId()} for Order #{$order->getIncrementId()}" + ) + ); + + $this->assertEquals($message->getSubject(), $subject); + $this->assertThat($message->getRawMessage(), $messageConstraint); + } + + /** + * @inheritdoc + */ + public function testAclHasAccess() + { + $this->prepareRequest(); + + parent::testAclHasAccess(); + } + + /** + * @inheritdoc + */ + public function testAclNoAccess() + { + $this->prepareRequest(); + + parent::testAclNoAccess(); + } + + /** + * @param array $params + * @return \Magento\Sales\Api\Data\OrderInterface|null + */ + private function prepareRequest(array $params = []) + { + $order = $this->getOrder('100000001'); + $this->getRequest()->setMethod('POST'); + $this->getRequest()->setParams( + [ + 'order_id' => $order->getEntityId(), + 'form_key' => $this->formKey->getFormKey(), + ] + ); + + $data = ['creditmemo' => ['do_offline' => true]]; + $data = array_replace_recursive($data, $params); + + $this->getRequest()->setPostValue($data); + + return $order; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php new file mode 100644 index 0000000000000..4d19106ad8e51 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php @@ -0,0 +1,136 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Controller\Adminhtml\Order; + +use Magento\Framework\Api\SearchCriteria; +use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Model\OrderRepository; +use Magento\TestFramework\Mail\Template\TransportBuilderMock; +use PHPUnit\Framework\Constraint\StringContains; + +/** + * Class verifies order send email functionality. + * + * @magentoDbIsolation enabled + * @magentoAppArea adminhtml + * @magentoDataFixture Magento/Sales/_files/order.php + */ +class EmailTest extends \Magento\TestFramework\TestCase\AbstractBackendController +{ + /** + * @var OrderRepository + */ + private $orderRepository; + + /** + * @var TransportBuilderMock + */ + private $transportBuilder; + + /** + * @var string + */ + protected $resource = 'Magento_Sales::email'; + + /** + * @var string + */ + protected $uri = 'backend/sales/order/email'; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + $this->orderRepository = $this->_objectManager->get(OrderRepository::class); + $this->transportBuilder = $this->_objectManager->get(TransportBuilderMock::class); + } + + /** + * @return void + */ + public function testSendOrderEmail(): void + { + $order = $this->prepareRequest(); + $this->dispatch('backend/sales/order/email'); + + $this->assertSessionMessages( + $this->equalTo([(string)__('You sent the order email.')]), + \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS + ); + + $redirectUrl = 'sales/order/view/order_id/' . $order->getEntityId(); + $this->assertRedirect($this->stringContains($redirectUrl)); + + $message = $this->transportBuilder->getSentMessage(); + $subject = __('Your %1 order confirmation', $order->getStore()->getFrontendName())->render(); + $assert = $this->logicalAnd( + new StringContains($order->getBillingAddress()->getName()), + new StringContains( + 'Thank you for your order from ' . $order->getStore()->getFrontendName() + ), + new StringContains( + "Your Order <span class=\"no-link\">#{$order->getIncrementId()}</span>" + ) + ); + + $this->assertEquals($message->getSubject(), $subject); + $this->assertThat($message->getRawMessage(), $assert); + } + + /** + * @inheritdoc + */ + public function testAclHasAccess() + { + $this->prepareRequest(); + + parent::testAclHasAccess(); + } + + /** + * @inheritdoc + */ + public function testAclNoAccess() + { + $this->prepareRequest(); + + parent::testAclNoAccess(); + } + + /** + * @param string $incrementalId + * @return OrderInterface|null + */ + private function getOrder(string $incrementalId) + { + /** @var SearchCriteria $searchCriteria */ + $searchCriteria = $this->_objectManager->create(SearchCriteriaBuilder::class) + ->addFilter(OrderInterface::INCREMENT_ID, $incrementalId) + ->create(); + + $orders = $this->orderRepository->getList($searchCriteria)->getItems(); + /** @var OrderInterface|null $order */ + $order = reset($orders); + + return $order; + } + + /** + * @return OrderInterface|null + */ + private function prepareRequest() + { + $order = $this->getOrder('100000001'); + $this->getRequest()->setParams(['order_id' => $order->getEntityId()]); + + return $order; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/AbstractInvoiceControllerTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/AbstractInvoiceControllerTest.php new file mode 100644 index 0000000000000..3ba54418b6c26 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/AbstractInvoiceControllerTest.php @@ -0,0 +1,92 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; + +use Magento\Framework\Api\SearchCriteria; +use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Data\Form\FormKey; +use Magento\Sales\Api\Data\InvoiceInterface; +use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Model\OrderRepository; +use Magento\TestFramework\Mail\Template\TransportBuilderMock; +use Magento\TestFramework\TestCase\AbstractBackendController; + +/** + * Abstract backend invoice test. + */ +class AbstractInvoiceControllerTest extends AbstractBackendController +{ + /** + * @var TransportBuilderMock + */ + protected $transportBuilder; + + /** + * @var OrderRepository + */ + protected $orderRepository; + + /** + * @var FormKey + */ + protected $formKey; + + /** + * @var string + */ + protected $resource = 'Magento_Sales::sales_invoice'; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + $this->transportBuilder = $this->_objectManager->get(TransportBuilderMock::class); + $this->orderRepository = $this->_objectManager->get(OrderRepository::class); + $this->formKey = $this->_objectManager->get(FormKey::class); + } + + /** + * @param string $incrementalId + * @return OrderInterface|null + */ + protected function getOrder(string $incrementalId) + { + /** @var SearchCriteria $searchCriteria */ + $searchCriteria = $this->_objectManager->create(SearchCriteriaBuilder::class) + ->addFilter(OrderInterface::INCREMENT_ID, $incrementalId) + ->create(); + + $orders = $this->orderRepository->getList($searchCriteria)->getItems(); + /** @var OrderInterface $order */ + $order = reset($orders); + + return $order; + } + + /** + * @param OrderInterface $order + * @return InvoiceInterface + */ + protected function getInvoiceByOrder(OrderInterface $order): InvoiceInterface + { + /** @var \Magento\Sales\Model\ResourceModel\Order\Invoice\Collection $invoiceCollection */ + $invoiceCollection = $this->_objectManager->create( + \Magento\Sales\Model\ResourceModel\Order\Invoice\CollectionFactory::class + )->create(); + + /** @var InvoiceInterface $invoice */ + $invoice = $invoiceCollection + ->setOrderFilter($order) + ->setPageSize(1) + ->getFirstItem(); + + return $invoice; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddCommentTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddCommentTest.php new file mode 100644 index 0000000000000..81e1dd7afc496 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddCommentTest.php @@ -0,0 +1,103 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; + +use PHPUnit\Framework\Constraint\RegularExpression; +use PHPUnit\Framework\Constraint\StringContains; + +/** + * Class verifies invoice add comment functionality. + * + * @magentoDbIsolation enabled + * @magentoAppArea adminhtml + * @magentoDataFixture Magento/Sales/_files/invoice.php + */ +class AddCommentTest extends AbstractInvoiceControllerTest +{ + /** + * @var string + */ + protected $uri = 'backend/sales/order_invoice/addComment'; + + /** + * @return void + */ + public function testSendEmailOnAddInvoiceComment(): void + { + $comment = 'Test Invoice Comment'; + $order = $this->prepareRequest( + [ + 'comment' => ['comment' => $comment, 'is_customer_notified' => true], + ] + ); + $this->dispatch('backend/sales/order_invoice/addComment'); + + $html = $this->getResponse()->getBody(); + $this->assertContains($comment, $html); + + $message = $this->transportBuilder->getSentMessage(); + $subject = __('Update to your %1 invoice', $order->getStore()->getFrontendName())->render(); + $messageConstraint = $this->logicalAnd( + new StringContains($order->getBillingAddress()->getName()), + new RegularExpression( + sprintf( + "/Your order #%s has been updated with a status of.*%s/", + $order->getIncrementId(), + $order->getFrontendStatusLabel() + ) + ), + new StringContains($comment) + ); + + $this->assertEquals($message->getSubject(), $subject); + $this->assertThat($message->getRawMessage(), $messageConstraint); + } + + /** + * @inheritdoc + */ + public function testAclHasAccess() + { + $this->prepareRequest(['comment' => ['comment' => 'Comment']]); + + parent::testAclHasAccess(); + } + + /** + * @inheritdoc + */ + public function testAclNoAccess() + { + $this->prepareRequest(['comment' => ['comment' => 'Comment']]); + + parent::testAclNoAccess(); + } + + /** + * @param array $params + * @return \Magento\Sales\Api\Data\OrderInterface|null + */ + private function prepareRequest(array $params = []) + { + $order = $this->getOrder('100000001'); + $invoice = $this->getInvoiceByOrder($order); + + $this->getRequest()->setMethod('POST'); + $this->getRequest()->setParams( + [ + 'id' => $invoice->getEntityId(), + 'form_key' => $this->formKey->getFormKey(), + ] + ); + + $data = $params ?? []; + $this->getRequest()->setPostValue($data); + + return $order; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/EmailTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/EmailTest.php new file mode 100644 index 0000000000000..85223528ec82a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/EmailTest.php @@ -0,0 +1,88 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; + +use PHPUnit\Framework\Constraint\StringContains; + +/** + * Class verifies invoice send email functionality. + * + * @magentoDbIsolation enabled + * @magentoAppArea adminhtml + * @magentoDataFixture Magento/Sales/_files/invoice.php + */ +class EmailTest extends AbstractInvoiceControllerTest +{ + /** + * @var string + */ + protected $uri = 'backend/sales/order_invoice/email'; + + /** + * @return void + */ + public function testSendInvoiceEmail(): void + { + $order = $this->getOrder('100000001'); + $invoice = $this->getInvoiceByOrder($order); + + $this->getRequest()->setParams(['invoice_id' => $invoice->getEntityId()]); + $this->dispatch('backend/sales/order_invoice/email'); + + $this->assertSessionMessages( + $this->equalTo([(string)__('You sent the message.')]), + \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS + ); + + $redirectUrl = sprintf( + 'sales/invoice/view/order_id/%s/invoice_id/%s', + $order->getEntityId(), + $invoice->getEntityId() + ); + $this->assertRedirect($this->stringContains($redirectUrl)); + + $message = $this->transportBuilder->getSentMessage(); + $subject = __('Invoice for your %1 order', $order->getStore()->getFrontendName())->render(); + $messageConstraint = $this->logicalAnd( + new StringContains($invoice->getBillingAddress()->getName()), + new StringContains( + 'Thank you for your order from ' . $invoice->getStore()->getFrontendName() + ), + new StringContains( + "Your Invoice #{$invoice->getIncrementId()} for Order #{$order->getIncrementId()}" + ) + ); + + $this->assertEquals($message->getSubject(), $subject); + $this->assertThat($message->getRawMessage(), $messageConstraint); + } + + /** + * @inheritdoc + */ + public function testAclHasAccess() + { + $order = $this->getOrder('100000001'); + $invoice = $this->getInvoiceByOrder($order); + $this->uri .= '/invoice_id/' . $invoice->getEntityId(); + + parent::testAclHasAccess(); + } + + /** + * @inheritdoc + */ + public function testAclNoAccess() + { + $order = $this->getOrder('100000001'); + $invoice = $this->getInvoiceByOrder($order); + $this->uri .= '/invoice_id/' . $invoice->getEntityId(); + + parent::testAclNoAccess(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/SaveTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/SaveTest.php new file mode 100644 index 0000000000000..68074e38d9a39 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/SaveTest.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\Controller\Adminhtml\Order\Invoice; + +use PHPUnit\Framework\Constraint\StringContains; + +/** + * Class tests invoice creation in backend. + * + * @magentoDbIsolation enabled + * @magentoAppArea adminhtml + * @magentoDataFixture Magento/Sales/_files/order.php + */ +class SaveTest extends AbstractInvoiceControllerTest +{ + /** + * @var string + */ + protected $uri = 'backend/sales/order_invoice/save'; + + /** + * @return void + */ + public function testSendEmailOnInvoiceSave(): void + { + $order = $this->prepareRequest(['invoice' => ['send_email' => true]]); + $this->dispatch('backend/sales/order_invoice/save'); + + $this->assertSessionMessages( + $this->equalTo([(string)__('The invoice has been created.')]), + \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS + ); + $this->assertRedirect($this->stringContains('sales/order/view/order_id/' . $order->getEntityId())); + + $invoice = $this->getInvoiceByOrder($order); + $message = $this->transportBuilder->getSentMessage(); + $subject = __('Invoice for your %1 order', $order->getStore()->getFrontendName())->render(); + $messageConstraint = $this->logicalAnd( + new StringContains($invoice->getBillingAddress()->getName()), + new StringContains( + 'Thank you for your order from ' . $invoice->getStore()->getFrontendName() + ), + new StringContains( + "Your Invoice #{$invoice->getIncrementId()} for Order #{$order->getIncrementId()}" + ) + ); + + $this->assertEquals($message->getSubject(), $subject); + $this->assertThat($message->getRawMessage(), $messageConstraint); + } + + /** + * @inheritdoc + */ + public function testAclHasAccess() + { + $this->prepareRequest(); + + parent::testAclHasAccess(); + } + + /** + * @inheritdoc + */ + public function testAclNoAccess() + { + $this->prepareRequest(); + + parent::testAclNoAccess(); + } + + /** + * @param array $params + * @return \Magento\Sales\Api\Data\OrderInterface|null + */ + private function prepareRequest(array $params = []) + { + $order = $this->getOrder('100000001'); + $this->getRequest()->setMethod('POST'); + $this->getRequest()->setParams( + [ + 'order_id' => $order->getEntityId(), + 'form_key' => $this->formKey->getFormKey(), + ] + ); + + $data = $params ?? []; + $this->getRequest()->setPostValue($data); + + return $order; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/CreateTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/CreateTest.php new file mode 100644 index 0000000000000..1035ce1592314 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/CreateTest.php @@ -0,0 +1,100 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Model\Order; + +use Magento\Checkout\Model\Session as CheckoutSession; +use Magento\Framework\Data\Form\FormKey; +use Magento\Framework\ObjectManagerInterface; +use Magento\Quote\Api\GuestCartManagementInterface; +use Magento\Quote\Model\Quote; +use Magento\Quote\Model\QuoteIdMask; +use Magento\Quote\Model\QuoteIdMaskFactory; +use Magento\Sales\Model\OrderRepository; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Mail\Template\TransportBuilderMock; +use PHPUnit\Framework\Constraint\StringContains; + +/** + * Class verifies order creation. + * + * @magentoDbIsolation enabled + * @magentoAppArea frontend + */ +class CreateTest extends \PHPUnit\Framework\TestCase +{ + /** + * @var ObjectManagerInterface + */ + private $objectManager; + + /** + * @var TransportBuilderMock + */ + private $transportBuilder; + + /** + * @var QuoteIdMaskFactory + */ + private $quoteIdMaskFactory; + + /** + * @var FormKey + */ + private $formKey; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + $this->objectManager = Bootstrap::getObjectManager(); + $this->transportBuilder = $this->objectManager->get(TransportBuilderMock::class); + $this->quoteIdMaskFactory = $this->objectManager->get(QuoteIdMaskFactory::class); + $this->formKey = $this->objectManager->get(FormKey::class); + } + + /** + * @magentoDataFixture Magento/Sales/_files/guest_quote_with_addresses.php + * @return void + */ + public function testSendEmailOnOrderPlace(): void + { + /** @var Quote $quote */ + $quote = $this->objectManager->create(Quote::class); + $quote->load('guest_quote', 'reserved_order_id'); + + $checkoutSession = $this->objectManager->get(CheckoutSession::class); + $checkoutSession->setQuoteId($quote->getId()); + + /** @var QuoteIdMask $quoteIdMask */ + $quoteIdMask = $this->quoteIdMaskFactory->create(); + $quoteIdMask->load($quote->getId(), 'quote_id'); + $cartId = $quoteIdMask->getMaskedId(); + + /** @var GuestCartManagementInterface $cartManagement */ + $cartManagement = $this->objectManager->get(GuestCartManagementInterface::class); + $orderId = $cartManagement->placeOrder($cartId); + $order = $this->objectManager->get(OrderRepository::class)->get($orderId); + + $message = $this->transportBuilder->getSentMessage(); + $subject = __('Your %1 order confirmation', $order->getStore()->getFrontendName())->render(); + $assert = $this->logicalAnd( + new StringContains($order->getBillingAddress()->getName()), + new StringContains( + 'Thank you for your order from ' . $order->getStore()->getFrontendName() + ), + new StringContains( + "Your Order <span class=\"no-link\">#{$order->getIncrementId()}</span>" + ) + ); + + $this->assertEquals($message->getSubject(), $subject); + $this->assertThat($message->getRawMessage(), $assert); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/guest_quote_with_addresses.php b/dev/tests/integration/testsuite/Magento/Sales/_files/guest_quote_with_addresses.php new file mode 100644 index 0000000000000..b8f2ca38e2489 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/guest_quote_with_addresses.php @@ -0,0 +1,68 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +require __DIR__ . '/address_list.php'; + +\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND); + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); +/** @var \Magento\Catalog\Model\Product $product */ +$product = $objectManager->create(\Magento\Catalog\Model\Product::class); +$product->setTypeId('simple') + ->setAttributeSetId($product->getDefaultAttributeSetId()) + ->setName('Simple Product') + ->setSku('simple-product-guest-quote') + ->setPrice(10) + ->setTaxClassId(0) + ->setMetaTitle('meta title') + ->setMetaKeyword('meta keyword') + ->setMetaDescription('meta description') + ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH) + ->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED) + ->setStockData( + [ + 'qty' => 100, + 'is_in_stock' => 1, + ] + )->save(); + +$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); +$product = $productRepository->get('simple-product-guest-quote'); + +$addressData = reset($addresses); + +$billingAddress = $objectManager->create( + \Magento\Quote\Model\Quote\Address::class, + ['data' => $addressData] +); +$billingAddress->setAddressType('billing'); + +$shippingAddress = clone $billingAddress; +$shippingAddress->setId(null)->setAddressType('shipping'); + +$store = $objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->getStore(); + +/** @var \Magento\Quote\Model\Quote $quote */ +$quote = $objectManager->create(\Magento\Quote\Model\Quote::class); +$quote->setCustomerIsGuest(true) + ->setStoreId($store->getId()) + ->setReservedOrderId('guest_quote') + ->setBillingAddress($billingAddress) + ->setShippingAddress($shippingAddress) + ->addProduct($product); +$quote->getPayment()->setMethod('checkmo'); +$quote->getShippingAddress()->setShippingMethod('flatrate_flatrate')->setCollectShippingRates(true); +$quote->collectTotals(); + +$quoteRepository = $objectManager->create(\Magento\Quote\Api\CartRepositoryInterface::class); +$quoteRepository->save($quote); + +/** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */ +$quoteIdMask = $objectManager->create(\Magento\Quote\Model\QuoteIdMaskFactory::class)->create(); +$quoteIdMask->setQuoteId($quote->getId()); +$quoteIdMask->setDataChanges(true); +$quoteIdMask->save(); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/guest_quote_with_addresses_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/guest_quote_with_addresses_rollback.php new file mode 100644 index 0000000000000..02c42153b72c3 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/guest_quote_with_addresses_rollback.php @@ -0,0 +1,32 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +/** @var \Magento\Framework\Registry $registry */ +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); +$registry = $objectManager->get(\Magento\Framework\Registry::class); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +/** @var $quote \Magento\Quote\Model\Quote */ +$quote = $objectManager->create(\Magento\Quote\Model\Quote::class); +$quote->load('guest_quote', 'reserved_order_id'); +if ($quote->getId()) { + $quote->delete(); +} + +/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); + +try { + $product = $productRepository->get('simple-product-guest-quote', false, null, true); + $productRepository->delete($product); +} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { + //Product already removed +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); diff --git a/dev/tests/integration/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AbstractShipmentControllerTest.php b/dev/tests/integration/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AbstractShipmentControllerTest.php new file mode 100644 index 0000000000000..0a1926d58624c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AbstractShipmentControllerTest.php @@ -0,0 +1,92 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; + +use Magento\Framework\Api\SearchCriteria; +use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Data\Form\FormKey; +use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Api\Data\ShipmentInterface; +use Magento\Sales\Model\OrderRepository; +use Magento\TestFramework\Mail\Template\TransportBuilderMock; +use Magento\TestFramework\TestCase\AbstractBackendController; + +/** + * Abstract backend shipment test. + */ +class AbstractShipmentControllerTest extends AbstractBackendController +{ + /** + * @var TransportBuilderMock + */ + protected $transportBuilder; + + /** + * @var OrderRepository + */ + protected $orderRepository; + + /** + * @var FormKey + */ + protected $formKey; + + /** + * @var string + */ + protected $resource = 'Magento_Sales::shipment'; + + /** + * @inheritdoc + */ + protected function setUp() + { + parent::setUp(); + $this->transportBuilder = $this->_objectManager->get(TransportBuilderMock::class); + $this->orderRepository = $this->_objectManager->get(OrderRepository::class); + $this->formKey = $this->_objectManager->get(FormKey::class); + } + + /** + * @param string $incrementalId + * @return OrderInterface|null + */ + protected function getOrder(string $incrementalId) + { + /** @var SearchCriteria $searchCriteria */ + $searchCriteria = $this->_objectManager->create(SearchCriteriaBuilder::class) + ->addFilter(OrderInterface::INCREMENT_ID, $incrementalId) + ->create(); + + $orders = $this->orderRepository->getList($searchCriteria)->getItems(); + /** @var OrderInterface|null $order */ + $order = reset($orders); + + return $order; + } + + /** + * @param OrderInterface $order + * @return ShipmentInterface + */ + protected function getShipment(OrderInterface $order): ShipmentInterface + { + /** @var \Magento\Sales\Model\ResourceModel\Order\Shipment\Collection $shipmentCollection */ + $shipmentCollection = $this->_objectManager->create( + \Magento\Sales\Model\ResourceModel\Order\Shipment\CollectionFactory::class + )->create(); + + /** @var ShipmentInterface $shipment */ + $shipment = $shipmentCollection + ->setOrderFilter($order) + ->setPageSize(1) + ->getFirstItem(); + + return $shipment; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddCommentTest.php b/dev/tests/integration/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddCommentTest.php new file mode 100644 index 0000000000000..25a44bab62994 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/AddCommentTest.php @@ -0,0 +1,102 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; + +use PHPUnit\Framework\Constraint\RegularExpression; +use PHPUnit\Framework\Constraint\StringContains; + +/** + * Class verifies shipment add comment functionality. + * + * @magentoDbIsolation enabled + * @magentoAppArea adminhtml + * @magentoDataFixture Magento/Sales/_files/shipment.php + */ +class AddCommentTest extends AbstractShipmentControllerTest +{ + /** + * @var string + */ + protected $uri = 'backend/admin/order_shipment/addComment'; + + /** + * @return void + */ + public function testSendEmailOnShipmentCommentAdd(): void + { + $comment = 'Test Shipment Comment'; + $order = $this->prepareRequest( + [ + 'comment' => ['comment' => $comment, 'is_customer_notified' => true], + ] + ); + $this->dispatch('backend/admin/order_shipment/addComment'); + $html = $this->getResponse()->getBody(); + $this->assertContains($comment, $html); + + $message = $this->transportBuilder->getSentMessage(); + $subject =__('Update to your %1 shipment', $order->getStore()->getFrontendName())->render(); + $messageConstraint = $this->logicalAnd( + new StringContains($order->getBillingAddress()->getName()), + new RegularExpression( + sprintf( + "/Your order #%s has been updated with a status of.*%s/", + $order->getIncrementId(), + $order->getFrontendStatusLabel() + ) + ), + new StringContains($comment) + ); + + $this->assertEquals($message->getSubject(), $subject); + $this->assertThat($message->getRawMessage(), $messageConstraint); + } + + /** + * @inheritdoc + */ + public function testAclHasAccess() + { + $this->prepareRequest(['comment', ['comment' => 'Comment']]); + + parent::testAclHasAccess(); + } + + /** + * @inheritdoc + */ + public function testAclNoAccess() + { + $this->prepareRequest(['comment', ['comment' => 'Comment']]); + + parent::testAclNoAccess(); + } + + /** + * @param array $params + * @return \Magento\Sales\Api\Data\OrderInterface|null + */ + private function prepareRequest(array $params = []) + { + $order = $this->getOrder('100000001'); + $shipment = $this->getShipment($order); + + $this->getRequest()->setMethod('POST'); + $this->getRequest()->setParams( + [ + 'id' => $shipment->getEntityId(), + 'form_key' => $this->formKey->getFormKey(), + ] + ); + + $data = $params ?? []; + $this->getRequest()->setPostValue($data); + + return $order; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/SaveTest.php b/dev/tests/integration/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/SaveTest.php new file mode 100644 index 0000000000000..27b5bb02d4b22 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/SaveTest.php @@ -0,0 +1,97 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; + +use PHPUnit\Framework\Constraint\StringContains; + +/** + * Class verifies shipment creation functionality. + * + * @magentoDbIsolation enabled + * @magentoAppArea adminhtml + * @magentoDataFixture Magento/Sales/_files/order.php + */ +class SaveTest extends AbstractShipmentControllerTest +{ + /** + * @var string + */ + protected $uri = 'backend/admin/order_shipment/save'; + + /** + * @return void + */ + public function testSendEmailOnShipmentSave(): void + { + $order = $this->prepareRequest(['shipment' => ['send_email' => true]]); + $this->dispatch('backend/admin/order_shipment/save'); + + $this->assertSessionMessages( + $this->equalTo([(string)__('The shipment has been created.')]), + \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS + ); + $this->assertRedirect($this->stringContains('sales/order/view/order_id/' . $order->getEntityId())); + + $shipment = $this->getShipment($order); + $message = $this->transportBuilder->getSentMessage(); + $subject = __('Your %1 order has shipped', $order->getStore()->getFrontendName())->render(); + $messageConstraint = $this->logicalAnd( + new StringContains($order->getBillingAddress()->getName()), + new StringContains( + 'Thank you for your order from ' . $shipment->getStore()->getFrontendName() + ), + new StringContains( + "Your Shipment #{$shipment->getIncrementId()} for Order #{$order->getIncrementId()}" + ) + ); + + $this->assertEquals($message->getSubject(), $subject); + $this->assertThat($message->getRawMessage(), $messageConstraint); + } + + /** + * @inheritdoc + */ + public function testAclHasAccess() + { + $this->prepareRequest(); + + parent::testAclHasAccess(); + } + + /** + * @inheritdoc + */ + public function testAclNoAccess() + { + $this->prepareRequest(); + + parent::testAclNoAccess(); + } + + /** + * @param array $params + * @return \Magento\Sales\Api\Data\OrderInterface|null + */ + private function prepareRequest(array $params = []) + { + $order = $this->getOrder('100000001'); + $this->getRequest()->setMethod('POST'); + $this->getRequest()->setParams( + [ + 'order_id' => $order->getEntityId(), + 'form_key' => $this->formKey->getFormKey(), + ] + ); + + $data = $params ?? []; + $this->getRequest()->setPostValue($data); + + return $order; + } +} From 4c56bf0d06f43b5bb9aee51b5b4f3b9ed956c6a2 Mon Sep 17 00:00:00 2001 From: Joan He <johe@magento.com> Date: Tue, 29 Jan 2019 11:53:28 -0600 Subject: [PATCH 108/121] MC-13747: Update ShipmentValidationRequest to DHL 6.0 version --- app/code/Magento/Dhl/Model/Carrier.php | 8 ++------ .../Dhl/Test/Unit/Model/_files/shipment_request.xml | 6 +----- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php index 685831138831c..42716d73373a2 100644 --- a/app/code/Magento/Dhl/Model/Carrier.php +++ b/app/code/Magento/Dhl/Model/Carrier.php @@ -1418,8 +1418,8 @@ protected function _doRequest() '<req:ShipmentRequest' . ' xmlns:req="http://www.dhl.com"' . ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . - ' xsi:schemaLocation="http://www.dhl.com ship-val-global-req-6.2.xsd"' . - ' schemaVersion="6.2" />'; + ' xsi:schemaLocation="http://www.dhl.com ship-val-global-req-6.0.xsd"' . + ' schemaVersion="6.0" />'; $xml = $this->_xmlElFactory->create(['data' => $xmlStr]); $nodeRequest = $xml->addChild('Request', '', ''); @@ -1433,10 +1433,6 @@ protected function _doRequest() $nodeServiceHeader->addChild('SiteID', (string)$this->getConfigData('id')); $nodeServiceHeader->addChild('Password', (string)$this->getConfigData('password')); - $nodeMetaData = $nodeRequest->addChild('MetaData'); - $nodeMetaData->addChild('SoftwareName', $this->buildSoftwareName()); - $nodeMetaData->addChild('SoftwareVersion', $this->buildSoftwareVersion()); - $originRegion = $this->getCountryParams( $this->_scopeConfig->getValue( Shipment::XML_PATH_STORE_COUNTRY_ID, diff --git a/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml b/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml index e93753368f834..d411041c96072 100644 --- a/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml +++ b/app/code/Magento/Dhl/Test/Unit/Model/_files/shipment_request.xml @@ -6,7 +6,7 @@ */ --> <req:ShipmentRequest xmlns:req="http://www.dhl.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.dhl.com ship-val-global-req-6.2.xsd" schemaVersion="6.2"> + xsi:schemaLocation="http://www.dhl.com ship-val-global-req-6.0.xsd" schemaVersion="6.0"> <Request xmlns=""> <ServiceHeader> <MessageTime>currentTime</MessageTime> @@ -14,10 +14,6 @@ <SiteID>some ID</SiteID> <Password>some password</Password> </ServiceHeader> - <MetaData> - <SoftwareName>Software_Product_Name_30_Char_</SoftwareName> - <SoftwareVersion>10Char_Ver</SoftwareVersion> - </MetaData> </Request> <RegionCode xmlns="">CHECKED</RegionCode> <RequestedPickupTime xmlns="">N</RequestedPickupTime> From 6e2f29c2946806478586b8f94ef37d63d392715f Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza <enarc@atwix.com> Date: Wed, 30 Jan 2019 15:38:56 +0100 Subject: [PATCH 109/121] Removed unnecessary annotation --- .../testsuite/Magento/GraphQl/Quote/GetCartTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCartTest.php index 2cd100fc0f758..e837afc65481e 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCartTest.php @@ -1,4 +1,4 @@ -<?php /** @noinspection SpellCheckingInspection */ +<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. From 99ea949d923dd0fc3bdb02058d2375fcf472b595 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov <sidolov@magento.com> Date: Wed, 30 Jan 2019 10:30:26 -0600 Subject: [PATCH 110/121] magento-engcom/magento2ce#2518: Fixed code style issue --- .../base/web/js/form/element/post-code.js | 4 +- .../blank/web/css/source/_sections.less | 17 ++++---- .../luma/web/css/source/_sections.less | 39 ++++++++++--------- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js b/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js index b8bab2f72f38a..1b6dd9f1c57ec 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/post-code.js @@ -33,11 +33,11 @@ define([ } option = options[value]; - + if (!option) { return; } - + if (option['is_zipcode_optional']) { this.error(false); this.validation = _.omit(this.validation, 'required-entry'); diff --git a/app/design/frontend/Magento/blank/web/css/source/_sections.less b/app/design/frontend/Magento/blank/web/css/source/_sections.less index 25f8c71f22dd5..1eee47bda817c 100644 --- a/app/design/frontend/Magento/blank/web/css/source/_sections.less +++ b/app/design/frontend/Magento/blank/web/css/source/_sections.less @@ -31,16 +31,19 @@ .media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) { .product.data.items { .lib-data-accordion(); + .data.item { display: block; } - .item.title { - >.switch{ - padding: 1px 15px 1px; + + .item.title { + > .switch { + padding: 1px 15px 1px; + } + } + + > .item.content { + padding: 10px 15px 30px; } - } - >.item.content{ - padding: 10px 15px 30px; - } } } diff --git a/app/design/frontend/Magento/luma/web/css/source/_sections.less b/app/design/frontend/Magento/luma/web/css/source/_sections.less index 38b936c83cb95..95769c4f4b6ba 100644 --- a/app/design/frontend/Magento/luma/web/css/source/_sections.less +++ b/app/design/frontend/Magento/luma/web/css/source/_sections.less @@ -19,16 +19,16 @@ a { position: relative; .lib-icon-font( - @_icon-font-content: @icon-down, - @_icon-font-size: @font-size__base, - @_icon-font-line-height: @icon-font__line-height, - @_icon-font-color: @icon-font__color, - @_icon-font-color-hover: @icon-font__color-hover, - @_icon-font-color-active: @icon-font__color-active, - @_icon-font-margin: @icon-font__margin, - @_icon-font-vertical-align: @icon-font__vertical-align, - @_icon-font-position: after, - @_icon-font-display: false + @_icon-font-content: @icon-down, + @_icon-font-size: @font-size__base, + @_icon-font-line-height: @icon-font__line-height, + @_icon-font-color: @icon-font__color, + @_icon-font-color-hover: @icon-font__color-hover, + @_icon-font-color-active: @icon-font__color-active, + @_icon-font-margin: @icon-font__margin, + @_icon-font-vertical-align: @icon-font__vertical-align, + @_icon-font-position: after, + @_icon-font-display: false ); &:after { @@ -77,14 +77,15 @@ } .media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) { - .product.data.items{ - .item.title { - >.switch{ - padding: 1px 15px 1px; - } - } - >.item.content{ - padding: 10px 15px 30px; + .product.data.items { + .item.title { + > .switch { + padding: 1px 15px 1px; + } + } + + > .item.content { + padding: 10px 15px 30px; + } } - } } From 69308c00554bba262883763d4ccbe180b10c0719 Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko <omiroshnichenko@magento.com> Date: Wed, 30 Jan 2019 16:40:30 -0600 Subject: [PATCH 111/121] MC-11043: Flaky MFTF Test - MAGETWO-93767: Use saved for Braintree credit card on checkout with selecting billing address --- .../Mftf/ActionGroup/StorefrontFillCartDataActionGroup.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Braintree/Test/Mftf/ActionGroup/StorefrontFillCartDataActionGroup.xml b/app/code/Magento/Braintree/Test/Mftf/ActionGroup/StorefrontFillCartDataActionGroup.xml index bc6d6c2b46dc9..bf06bc7df5201 100644 --- a/app/code/Magento/Braintree/Test/Mftf/ActionGroup/StorefrontFillCartDataActionGroup.xml +++ b/app/code/Magento/Braintree/Test/Mftf/ActionGroup/StorefrontFillCartDataActionGroup.xml @@ -6,24 +6,27 @@ */ --> <actionGroups 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/actionGroupSchema.xsd"> <actionGroup name="StorefrontFillCartDataActionGroup"> <arguments> <argument name="cartData" defaultValue="PaymentAndShippingInfo"/> </arguments> <switchToIFrame selector="{{BraintreeConfigurationPaymentSection.cartFrame}}" stepKey="switchToIframe"/> + <waitForElementVisible selector="{{BraintreeConfigurationPaymentSection.cartCode}}" stepKey="waitCartCodeElement"/> <fillField selector="{{BraintreeConfigurationPaymentSection.cartCode}}" userInput="{{cartData.cardNumber}}" stepKey="setCartCode"/> <switchToIFrame stepKey="switchBack"/> <switchToIFrame selector="{{BraintreeConfigurationPaymentSection.monthFrame}}" stepKey="switchToIframe1"/> + <waitForElementVisible selector="{{BraintreeConfigurationPaymentSection.month}}" stepKey="waitMonthElement"/> <fillField selector="{{BraintreeConfigurationPaymentSection.month}}" userInput="{{cartData.month}}" stepKey="setMonth"/> <switchToIFrame stepKey="switchBack1"/> <switchToIFrame selector="{{BraintreeConfigurationPaymentSection.yearFrame}}" stepKey="switchToIframe2"/> + <waitForElementVisible selector="{{BraintreeConfigurationPaymentSection.year}}" stepKey="waitYearElement"/> <fillField selector="{{BraintreeConfigurationPaymentSection.year}}" userInput="{{cartData.year}}" stepKey="setYear"/> <switchToIFrame stepKey="switchBack2"/> <switchToIFrame selector="{{BraintreeConfigurationPaymentSection.codeFrame}}" stepKey="switchToIframe3"/> + <waitForElementVisible selector="{{BraintreeConfigurationPaymentSection.verificationNumber}}" stepKey="waitVerificationNumber"/> <fillField selector="{{BraintreeConfigurationPaymentSection.verificationNumber}}" userInput="{{cartData.cvv}}" stepKey="setVerificationNumber"/> <switchToIFrame stepKey="SwitchBackToWindow"/> - </actionGroup> </actionGroups> \ No newline at end of file From d6a23379f7594e5189f93671181672c5add3e02d Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <veronika_kurochkina@epam.com> Date: Wed, 30 Jan 2019 17:29:05 +0300 Subject: [PATCH 112/121] MAGETWO-96411: [2.3.x] Default addresses not selected when checking out from cart - Fixed MFTF test; --- .../Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml index 2cc21df85ab67..4b3e18fb31877 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/ZeroSubtotalOrdersWithProcessingStatusTest.xml @@ -36,7 +36,6 @@ <createData entity="DefaultShippingMethodsConfig" stepKey="defaultShippingMethodsConfig"/> <createData entity="DisableFreeShippingConfig" stepKey="disableFreeShippingConfig"/> <createData entity="DisablePaymentMethodsSettingConfig" stepKey="disablePaymentMethodsSettingConfig"/> - <actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearOrderFilters"/> <actionGroup ref="logout" stepKey="logout"/> <deleteData createDataKey="simpleproduct" stepKey="deleteProduct"/> <deleteData createDataKey="simplecategory" stepKey="deleteCategory"/> @@ -99,5 +98,6 @@ <!--Verify that Created order is in Processing status--> <see selector="{{AdminShipmentOrderInformationSection.orderStatus}}" userInput="Processing" stepKey="seeShipmentOrderStatus"/> + <actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearOrderFilters"/> </test> </tests> From 21fb25a6ee34e5842c0d05997c6e2054a87ebb83 Mon Sep 17 00:00:00 2001 From: Yauhen_Lyskavets <yauhen_lyskavets@epam.com> Date: Fri, 28 Sep 2018 14:03:50 +0300 Subject: [PATCH 113/121] MAGETWO-91676: Model related data missing in order rest api - Fix added - Fix unit tests added --- app/code/Magento/Sales/Model/Order.php | 31 ++++- .../Sales/Test/Unit/Model/OrderTest.php | 116 +++++++++++++++++- 2 files changed, 137 insertions(+), 10 deletions(-) diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php index a9c14be8675ab..e71b60427e9f2 100644 --- a/app/code/Magento/Sales/Model/Order.php +++ b/app/code/Magento/Sales/Model/Order.php @@ -23,6 +23,8 @@ use Magento\Sales\Model\ResourceModel\Order\Shipment\Collection as ShipmentCollection; use Magento\Sales\Model\ResourceModel\Order\Shipment\Track\Collection as TrackCollection; use Magento\Sales\Model\ResourceModel\Order\Status\History\Collection as HistoryCollection; +use Magento\Sales\Api\OrderItemRepositoryInterface; +use Magento\Framework\Api\SearchCriteriaBuilder; /** * Order model @@ -286,6 +288,16 @@ class Order extends AbstractModel implements EntityInterface, OrderInterface */ private $productOption; + /** + * @var OrderItemRepositoryInterface + */ + private $itemRepository; + + /** + * @var SearchCriteriaBuilder + */ + private $searchCriteriaBuilder; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry @@ -316,6 +328,8 @@ class Order extends AbstractModel implements EntityInterface, OrderInterface * @param array $data * @param ResolverInterface $localeResolver * @param ProductOption|null $productOption + * @param OrderItemRepositoryInterface $itemRepository + * @param SearchCriteriaBuilder $searchCriteriaBuilder * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -347,7 +361,9 @@ public function __construct( \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [], ResolverInterface $localeResolver = null, - ProductOption $productOption = null + ProductOption $productOption = null, + OrderItemRepositoryInterface $itemRepository = null, + SearchCriteriaBuilder $searchCriteriaBuilder = null ) { $this->_storeManager = $storeManager; $this->_orderConfig = $orderConfig; @@ -371,6 +387,10 @@ public function __construct( $this->priceCurrency = $priceCurrency; $this->localeResolver = $localeResolver ?: ObjectManager::getInstance()->get(ResolverInterface::class); $this->productOption = $productOption ?: ObjectManager::getInstance()->get(ProductOption::class); + $this->itemRepository = $itemRepository ?: ObjectManager::getInstance() + ->get(OrderItemRepositoryInterface::class); + $this->searchCriteriaBuilder = $searchCriteriaBuilder ?: ObjectManager::getInstance() + ->get(SearchCriteriaBuilder::class); parent::__construct( $context, @@ -668,7 +688,7 @@ private function canCreditmemoForZeroTotalRefunded($totalRefunded) return true; } - + /** * Retrieve credit memo for zero total availability. * @@ -2076,9 +2096,12 @@ public function getIncrementId() public function getItems() { if ($this->getData(OrderInterface::ITEMS) == null) { + $this->searchCriteriaBuilder->addFilter(OrderItemInterface::ORDER_ID, $this->getId()); + + $searchCriteria = $this->searchCriteriaBuilder->create(); $this->setData( OrderInterface::ITEMS, - $this->getItemsCollection()->getItems() + $this->itemRepository->getList($searchCriteria)->getItems() ); } return $this->getData(OrderInterface::ITEMS); @@ -2919,7 +2942,7 @@ public function getDiscountTaxCompensationRefunded() } /** - * Return hold_before_state + * Returns hold_before_state * * @return string|null */ diff --git a/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php b/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php index f724136eb5154..faee759273295 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php @@ -12,6 +12,10 @@ use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Model\Order; use Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory as HistoryCollectionFactory; +use Magento\Sales\Api\OrderItemRepositoryInterface; +use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Api\SearchCriteria; +use Magento\Sales\Api\Data\OrderItemSearchResultInterface; /** * Test class for \Magento\Sales\Model\Order @@ -87,6 +91,16 @@ class OrderTest extends \PHPUnit\Framework\TestCase */ private $timezone; + /** + * @var OrderItemRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $itemRepository; + + /** + * @var SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject + */ + private $searchCriteriaBuilder; + protected function setUp() { $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -144,6 +158,15 @@ protected function setUp() $this->eventManager = $this->createMock(\Magento\Framework\Event\Manager::class); $context = $this->createPartialMock(\Magento\Framework\Model\Context::class, ['getEventDispatcher']); $context->expects($this->any())->method('getEventDispatcher')->willReturn($this->eventManager); + + $this->itemRepository = $this->getMockBuilder(OrderItemRepositoryInterface::class) + ->setMethods(['getList']) + ->disableOriginalConstructor()->getMockForAbstractClass(); + + $this->searchCriteriaBuilder = $this->getMockBuilder(SearchCriteriaBuilder::class) + ->setMethods(['addFilter', 'create']) + ->disableOriginalConstructor()->getMockForAbstractClass(); + $this->order = $helper->getObject( \Magento\Sales\Model\Order::class, [ @@ -157,37 +180,80 @@ protected function setUp() 'productListFactory' => $this->productCollectionFactoryMock, 'localeResolver' => $this->localeResolver, 'timezone' => $this->timezone, + 'itemRepository' => $this->itemRepository, + 'searchCriteriaBuilder' => $this->searchCriteriaBuilder ] ); } - public function testGetItemById() + /** + * Test testGetItems method. + */ + public function testGetItems() { - $realOrderItemId = 1; - $fakeOrderItemId = 2; + $orderItems = [$this->item]; + + $this->searchCriteriaBuilder->expects($this->once())->method('addFilter')->willReturnSelf(); + + $searchCriteria = $this->getMockBuilder(SearchCriteria::class) + ->disableOriginalConstructor()->getMockForAbstractClass(); + $this->searchCriteriaBuilder->expects($this->once())->method('create')->willReturn($searchCriteria); - $orderItem = $this->createMock(\Magento\Sales\Model\Order\Item::class); + $itemsCollection = $this->getMockBuilder(OrderItemSearchResultInterface::class) + ->setMethods(['getItems']) + ->disableOriginalConstructor()->getMockForAbstractClass(); + $itemsCollection->expects($this->once())->method('getItems')->willReturn($orderItems); + $this->itemRepository->expects($this->once())->method('getList')->willReturn($itemsCollection); + $this->assertEquals($orderItems, $this->order->getItems()); + } + + /** + * Prepare order item mock. + * + * @param int $orderId + * @return void + */ + private function prepareOrderItem(int $orderId = 0) + { $this->order->setData( \Magento\Sales\Api\Data\OrderInterface::ITEMS, [ - $realOrderItemId => $orderItem + $orderId => $this->item ] ); + } - $this->assertEquals($orderItem, $this->order->getItemById($realOrderItemId)); + /** + * Test GetItemById method. + * + * @return void + */ + public function testGetItemById() + { + $realOrderItemId = 1; + $fakeOrderItemId = 2; + + $this->prepareOrderItem($realOrderItemId); + + $this->assertEquals($this->item, $this->order->getItemById($realOrderItemId)); $this->assertEquals(null, $this->order->getItemById($fakeOrderItemId)); } /** + * Test GetItemByQuoteItemId method. + * * @param int|null $gettingQuoteItemId * @param int|null $quoteItemId * @param string|null $result * * @dataProvider dataProviderGetItemByQuoteItemId + * @return void */ public function testGetItemByQuoteItemId($gettingQuoteItemId, $quoteItemId, $result) { + $this->prepareOrderItem(); + $this->item->expects($this->any()) ->method('getQuoteItemId') ->willReturn($gettingQuoteItemId); @@ -212,14 +278,19 @@ public function dataProviderGetItemByQuoteItemId() } /** + * Test getAllVisibleItems method. + * * @param bool $isDeleted * @param int|null $parentItemId * @param array $result * * @dataProvider dataProviderGetAllVisibleItems + * @return void */ public function testGetAllVisibleItems($isDeleted, $parentItemId, array $result) { + $this->prepareOrderItem(); + $this->item->expects($this->once()) ->method('isDeleted') ->willReturn($isDeleted); @@ -263,8 +334,15 @@ public function testCanCancelIsPaymentReview() $this->assertFalse($this->order->canCancel()); } + /** + * Test CanInvoice method. + * + * @return void + */ public function testCanInvoice() { + $this->prepareOrderItem(); + $this->item->expects($this->any()) ->method('getQtyToInvoice') ->willReturn(42); @@ -304,8 +382,15 @@ public function testCanNotInvoiceWhenActionInvoiceFlagIsFalse() $this->assertFalse($this->order->canInvoice()); } + /** + * Test CanNotInvoice method when invoice is locked. + * + * @return void + */ public function testCanNotInvoiceWhenLockedInvoice() { + $this->prepareOrderItem(); + $this->item->expects($this->any()) ->method('getQtyToInvoice') ->willReturn(42); @@ -315,8 +400,15 @@ public function testCanNotInvoiceWhenLockedInvoice() $this->assertFalse($this->order->canInvoice()); } + /** + * Test CanNotInvoice method when didn't have qty to invoice. + * + * @return void + */ public function testCanNotInvoiceWhenDidNotHaveQtyToInvoice() { + $this->prepareOrderItem(); + $this->item->expects($this->any()) ->method('getQtyToInvoice') ->willReturn(0); @@ -601,8 +693,15 @@ public function testCanCancelCanReviewPayment() $this->assertFalse($this->order->canCancel()); } + /** + * Test CanCancelAllInvoiced method. + * + * @return void + */ public function testCanCancelAllInvoiced() { + $this->prepareOrderItem(); + $paymentMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Payment::class) ->disableOriginalConstructor() ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo', '__wakeUp']) @@ -662,11 +761,16 @@ public function testCanCancelState() } /** + * Test CanCancelActionFlag method. + * * @param bool $cancelActionFlag * @dataProvider dataProviderActionFlag + * @return void */ public function testCanCancelActionFlag($cancelActionFlag) { + $this->prepareOrderItem(); + $paymentMock = $this->getMockBuilder(\Magento\Sales\Model\ResourceModel\Order\Payment::class) ->disableOriginalConstructor() ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo', '__wakeUp']) From d17a99f22f274af0136530227b77b1ec8829d3ef Mon Sep 17 00:00:00 2001 From: Oksana_Kremen <Oksana_Kremen@epam.com> Date: Thu, 24 Jan 2019 19:04:08 +0200 Subject: [PATCH 114/121] MAGETWO-91676: Model related data missing in order rest api - Fix for unit tests --- app/code/Magento/Sales/Test/Unit/Model/OrderTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php b/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php index faee759273295..61ae9ae45e12f 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/OrderTest.php @@ -11,6 +11,7 @@ use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Model\Order; +use Magento\Sales\Model\ResourceModel\Order\Item\Collection; use Magento\Sales\Model\ResourceModel\Order\Status\History\CollectionFactory as HistoryCollectionFactory; use Magento\Sales\Api\OrderItemRepositoryInterface; use Magento\Framework\Api\SearchCriteriaBuilder; @@ -421,6 +422,7 @@ public function testCanNotInvoiceWhenDidNotHaveQtyToInvoice() public function testCanCreditMemo() { $totalPaid = 10; + $this->prepareOrderItem(); $this->order->setTotalPaid($totalPaid); $this->priceCurrency->expects($this->once())->method('round')->with($totalPaid)->willReturnArgument(0); $this->assertTrue($this->order->canCreditmemo()); @@ -436,6 +438,7 @@ public function testCanCreditMemoForZeroTotal() $grandTotal = 0; $totalPaid = 0; $totalRefunded = 0; + $this->prepareOrderItem(); $this->order->setGrandTotal($grandTotal); $this->order->setTotalPaid($totalPaid); $this->assertFalse($this->order->canCreditmemoForZeroTotal($totalRefunded)); @@ -444,6 +447,7 @@ public function testCanCreditMemoForZeroTotal() public function testCanNotCreditMemoWithTotalNull() { $totalPaid = 0; + $this->prepareOrderItem(); $this->order->setTotalPaid($totalPaid); $this->priceCurrency->expects($this->once())->method('round')->with($totalPaid)->willReturnArgument(0); $this->assertFalse($this->order->canCreditmemo()); @@ -455,6 +459,7 @@ public function testCanNotCreditMemoWithAdjustmentNegative() $adjustmentNegative = 10; $totalRefunded = 90; + $this->prepareOrderItem(); $this->order->setTotalPaid($totalPaid); $this->order->setTotalRefunded($totalRefunded); $this->order->setAdjustmentNegative($adjustmentNegative); @@ -469,6 +474,7 @@ public function testCanCreditMemoWithAdjustmentNegativeLowerThanTotalPaid() $adjustmentNegative = 9; $totalRefunded = 90; + $this->prepareOrderItem(); $this->order->setTotalPaid($totalPaid); $this->order->setTotalRefunded($totalRefunded); $this->order->setAdjustmentNegative($adjustmentNegative); From 230e0840eae8832d65f6ef5c9a39cdc8f3c91c6d Mon Sep 17 00:00:00 2001 From: RomanKis <roman.kis.y@gmail.com> Date: Thu, 31 Jan 2019 17:19:30 +0200 Subject: [PATCH 115/121] graphQl-336: Magento/CatalogGraphQl/Model/Category/LevelCalculator class has fields declared dynamically --- .../CatalogGraphQl/Model/Category/LevelCalculator.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/code/Magento/CatalogGraphQl/Model/Category/LevelCalculator.php b/app/code/Magento/CatalogGraphQl/Model/Category/LevelCalculator.php index 0401e1c42331e..f587be245c99d 100644 --- a/app/code/Magento/CatalogGraphQl/Model/Category/LevelCalculator.php +++ b/app/code/Magento/CatalogGraphQl/Model/Category/LevelCalculator.php @@ -15,6 +15,16 @@ */ class LevelCalculator { + /** + * @var ResourceConnection + */ + private $resourceConnection; + + /** + * @var Category + */ + private $resourceCategory; + /** * @param ResourceConnection $resourceConnection * @param Category $resourceCategory @@ -39,6 +49,7 @@ public function calculate(int $rootCategoryId) : int $select = $connection->select() ->from($this->resourceConnection->getTableName('catalog_category_entity'), 'level') ->where($this->resourceCategory->getLinkField() . " = ?", $rootCategoryId); + return (int) $connection->fetchOne($select); } } From cc1cadf00e16c34fb4e313bc7bacfcdbb143aaf0 Mon Sep 17 00:00:00 2001 From: Joan He <johe@magento.com> Date: Thu, 31 Jan 2019 15:56:06 -0600 Subject: [PATCH 116/121] MC-13644: Default billing and default shipping address lose their status after edit --- .../Customer/Controller/Address/FormPost.php | 14 ++++++++-- .../StorefrontUpdateCustomerAddressTest.xml | 3 --- .../Unit/Controller/Address/FormPostTest.php | 26 ++++++++++++------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/app/code/Magento/Customer/Controller/Address/FormPost.php b/app/code/Magento/Customer/Controller/Address/FormPost.php index 217af0abd7592..0fc0c4611ab9c 100644 --- a/app/code/Magento/Customer/Controller/Address/FormPost.php +++ b/app/code/Magento/Customer/Controller/Address/FormPost.php @@ -120,8 +120,18 @@ protected function _extractAddress() \Magento\Customer\Api\Data\AddressInterface::class ); $addressDataObject->setCustomerId($this->_getSession()->getCustomerId()) - ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false)) - ->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false)); + ->setIsDefaultBilling( + $this->getRequest()->getParam( + 'default_billing', + isset($existingAddressData['default_billing']) ? $existingAddressData['default_billing'] : false + ) + ) + ->setIsDefaultShipping( + $this->getRequest()->getParam( + 'default_shipping', + isset($existingAddressData['default_shipping']) ? $existingAddressData['default_shipping'] : false + ) + ); return $addressDataObject; } diff --git a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressTest.xml index d1b5fb2aa7d11..d9d1c9f2e05a0 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontUpdateCustomerAddressTest.xml @@ -18,9 +18,6 @@ <testCaseId value="MAGETWO-97501"/> <group value="customer"/> <group value="update"/> - <skip> - <issueId value="MAGETWO-97504"/> - </skip> </annotations> <before> <createData entity="Simple_US_Customer_With_Different_Billing_Shipping_Addresses" stepKey="createCustomer"/> diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php index c2a795fc95016..7ae55f44421c7 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php @@ -455,14 +455,20 @@ public function testExecute( $regionCode, $newRegionId, $newRegion, - $newRegionCode + $newRegionCode, + $existingDefaultBilling = false, + $existingDefaultShipping = false, + $setDefaultBilling = false, + $setDefaultShipping = false ): void { $existingAddressData = [ 'country_id' => $countryId, 'region_id' => $regionId, 'region' => $region, 'region_code' => $regionCode, - 'customer_id' => $customerId + 'customer_id' => $customerId, + 'default_billing' => $existingDefaultBilling, + 'default_shipping' => $existingDefaultShipping, ]; $newAddressData = [ 'country_id' => $countryId, @@ -486,8 +492,8 @@ public function testExecute( ->method('getParam') ->willReturnMap([ ['id', null, $addressId], - ['default_billing', false, $addressId], - ['default_shipping', false, $addressId], + ['default_billing', $existingDefaultBilling, $setDefaultBilling], + ['default_shipping', $existingDefaultShipping, $setDefaultShipping], ]); $this->addressRepository->expects($this->once()) @@ -565,11 +571,11 @@ public function testExecute( ->willReturnSelf(); $this->addressData->expects($this->once()) ->method('setIsDefaultBilling') - ->with() + ->with($setDefaultBilling) ->willReturnSelf(); $this->addressData->expects($this->once()) ->method('setIsDefaultShipping') - ->with() + ->with($setDefaultShipping) ->willReturnSelf(); $this->messageManager->expects($this->once()) @@ -628,11 +634,11 @@ public function dataProviderTestExecute(): array [1, 1, 1, 2, null, null, 12, null, null], [1, 1, 1, 2, 'Alaska', null, 12, null, 'CA'], - [1, 1, 1, 2, 'Alaska', 'AK', 12, 'California', null], + [1, 1, 1, 2, 'Alaska', 'AK', 12, 'California', null, true, true, true, false], - [1, 1, 1, 2, null, null, 12, null, null], - [1, 1, 1, 2, 'Alaska', null, 12, null, 'CA'], - [1, 1, 1, 2, 'Alaska', 'AK', 12, 'California', null], + [1, 1, 1, 2, null, null, 12, null, null, false, false, true, false], + [1, 1, 1, 2, 'Alaska', null, 12, null, 'CA', true, false, true, false], + [1, 1, 1, 2, 'Alaska', 'AK', 12, 'California', null, true, true, true, true], ]; } From 9551799d2237337ec15c92238c27d85800d4ae0f Mon Sep 17 00:00:00 2001 From: Valerii Naida <vnayda@adobe.com> Date: Thu, 31 Jan 2019 17:59:21 -0600 Subject: [PATCH 117/121] GraphQL-248: [My Account] Create customer account --- .../Magento/CustomerGraphQl/Model/Customer/CreateAccount.php | 5 +++++ .../CustomerGraphQl/Model/Customer/SetUpUserContext.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/CreateAccount.php b/app/code/Magento/CustomerGraphQl/Model/Customer/CreateAccount.php index 355bd1c6ec853..e21e0330bc5a2 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Customer/CreateAccount.php +++ b/app/code/Magento/CustomerGraphQl/Model/Customer/CreateAccount.php @@ -1,4 +1,9 @@ <?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); namespace Magento\CustomerGraphQl\Model\Customer; diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/SetUpUserContext.php b/app/code/Magento/CustomerGraphQl/Model/Customer/SetUpUserContext.php index 94131722e5a9f..720034e06c331 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Customer/SetUpUserContext.php +++ b/app/code/Magento/CustomerGraphQl/Model/Customer/SetUpUserContext.php @@ -1,4 +1,9 @@ <?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); namespace Magento\CustomerGraphQl\Model\Customer; From 0533dc290d9e0390ca3086f461a9f0dd35cc7e23 Mon Sep 17 00:00:00 2001 From: Valerii Naida <vnayda@adobe.com> Date: Thu, 31 Jan 2019 19:27:03 -0600 Subject: [PATCH 118/121] GraphQL-248: [My Account] Create customer account -- fix static tests --- .../Model/ConfigurableProductTypeResolver.php | 7 +++---- .../CustomerGraphQl/Model/Customer/CreateAccount.php | 4 +++- .../CustomerGraphQl/Model/Customer/SetUpUserContext.php | 2 ++ .../testsuite/Magento/GraphQl/Quote/GetCartTest.php | 1 - .../testsuite/Magento/Checkout/_files/active_quote.php | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/ConfigurableProductGraphQl/Model/ConfigurableProductTypeResolver.php b/app/code/Magento/ConfigurableProductGraphQl/Model/ConfigurableProductTypeResolver.php index f65a331ab803c..eda2ce11daaf6 100644 --- a/app/code/Magento/ConfigurableProductGraphQl/Model/ConfigurableProductTypeResolver.php +++ b/app/code/Magento/ConfigurableProductGraphQl/Model/ConfigurableProductTypeResolver.php @@ -11,7 +11,7 @@ use Magento\ConfigurableProduct\Model\Product\Type\Configurable as Type; /** - * {@inheritdoc} + * @inheritdoc */ class ConfigurableProductTypeResolver implements TypeResolverInterface { @@ -21,13 +21,12 @@ class ConfigurableProductTypeResolver implements TypeResolverInterface const TYPE_RESOLVER = 'ConfigurableProduct'; /** - * {@inheritdoc} + * @inheritdoc */ - public function resolveType(array $data) : string + public function resolveType(array $data): string { if (isset($data['type_id']) && $data['type_id'] == Type::TYPE_CODE) { return self::TYPE_RESOLVER; - } return ''; } diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/CreateAccount.php b/app/code/Magento/CustomerGraphQl/Model/Customer/CreateAccount.php index e21e0330bc5a2..4a4b5c863528b 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Customer/CreateAccount.php +++ b/app/code/Magento/CustomerGraphQl/Model/Customer/CreateAccount.php @@ -59,12 +59,14 @@ public function __construct( } /** + * Creates new customer account + * * @param array $args * @return CustomerInterface * @throws LocalizedException * @throws NoSuchEntityException */ - public function execute($args) + public function execute(array $args): CustomerInterface { $customerDataObject = $this->customerFactory->create(); $this->dataObjectHelper->populateWithArray( diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/SetUpUserContext.php b/app/code/Magento/CustomerGraphQl/Model/Customer/SetUpUserContext.php index 720034e06c331..1fcf1c0d7c1c3 100644 --- a/app/code/Magento/CustomerGraphQl/Model/Customer/SetUpUserContext.php +++ b/app/code/Magento/CustomerGraphQl/Model/Customer/SetUpUserContext.php @@ -17,6 +17,8 @@ class SetUpUserContext { /** + * Set up user context after creating new customer account + * * @param ContextInterface $context * @param CustomerInterface $customer */ diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCartTest.php index e837afc65481e..78204aaa567b0 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/GetCartTest.php @@ -85,7 +85,6 @@ public function testGetCartFromAnotherCustomer() 'reserved_order_id' ); - $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId()); $query = $this->prepareGetCartQuery($maskedQuoteId); diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/active_quote.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/active_quote.php index 6b569f37a1a9f..52437ef828afd 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/_files/active_quote.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/active_quote.php @@ -16,4 +16,4 @@ ->create(); $quoteIdMask->setQuoteId($quote->getId()); $quoteIdMask->setDataChanges(true); -$quoteIdMask->save(); \ No newline at end of file +$quoteIdMask->save(); From ed37f5ba3c669f14ed7613cbd9ac00770e481658 Mon Sep 17 00:00:00 2001 From: Joan He <johe@magento.com> Date: Thu, 31 Jan 2019 20:47:10 -0600 Subject: [PATCH 119/121] MC-13644: Default billing and default shipping address lose their status after edit - Fix static test failure --- app/code/Magento/Customer/Controller/Address/FormPost.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/Customer/Controller/Address/FormPost.php b/app/code/Magento/Customer/Controller/Address/FormPost.php index 0fc0c4611ab9c..25618e3129160 100644 --- a/app/code/Magento/Customer/Controller/Address/FormPost.php +++ b/app/code/Magento/Customer/Controller/Address/FormPost.php @@ -26,6 +26,8 @@ use Magento\Framework\View\Result\PageFactory; /** + * Customer Address Form Post Controller + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class FormPost extends \Magento\Customer\Controller\Address implements HttpPostActionInterface From 45df4a71d2a96a3cb00822509b1b11fa48c12fd3 Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <veronika_kurochkina@epam.com> Date: Fri, 1 Feb 2019 15:49:56 +0300 Subject: [PATCH 120/121] MAGETWO-96406: [2.3.x] Swatch Attribute is not displayed in the Widget CMS - Update fixes based on comments --- .../Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml index b45339edecd86..674b2b66cd0c0 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontSwatchAttributesDisplayInWidgetCMSTest.xml @@ -28,6 +28,9 @@ <actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteProduct"> <argument name="product" value="BaseConfigurableProduct"/> </actionGroup> + <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="visitAdminProductPage"/> + <waitForPageLoad stepKey="waitForAdminProductGridLoad"/> + <conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial"/> <actionGroup ref="deleteProductAttributeByLabel" stepKey="deleteAttribute"> <argument name="ProductAttribute" value="visualSwatchAttribute"/> </actionGroup> From 30e84d398230d8b2cc2aaada731636a97f9dd974 Mon Sep 17 00:00:00 2001 From: Veronika Kurochkina <veronika_kurochkina@epam.com> Date: Fri, 1 Feb 2019 21:40:03 +0300 Subject: [PATCH 121/121] MC-13779: [MFTF] CreateAnAdminOrderUsingBraintreePaymentTest1 randomly fails on jenkins --- .../Mftf/Test/CreateAnAdminOrderUsingBraintreePaymentTest1.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/Magento/Braintree/Test/Mftf/Test/CreateAnAdminOrderUsingBraintreePaymentTest1.xml b/app/code/Magento/Braintree/Test/Mftf/Test/CreateAnAdminOrderUsingBraintreePaymentTest1.xml index 2376fe9f8006f..88bcf22a4b79f 100644 --- a/app/code/Magento/Braintree/Test/Mftf/Test/CreateAnAdminOrderUsingBraintreePaymentTest1.xml +++ b/app/code/Magento/Braintree/Test/Mftf/Test/CreateAnAdminOrderUsingBraintreePaymentTest1.xml @@ -17,6 +17,9 @@ <severity value="CRITICAL"/> <testCaseId value="MAGETWO-93677"/> <group value="braintree"/> + <skip> + <issueId value="MC-13779"/> + </skip> </annotations>