From 7a04c04bec1fa3525d8b43ca684e13da3cb37974 Mon Sep 17 00:00:00 2001 From: Pascal Brouwers Date: Fri, 24 Jan 2020 15:42:02 +0100 Subject: [PATCH 01/99] issue/26526 Fix orderRepository does not check if there are no extensionAttributes --- app/code/Magento/Sales/Model/OrderRepository.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/code/Magento/Sales/Model/OrderRepository.php b/app/code/Magento/Sales/Model/OrderRepository.php index f93de4c32d888..baac39b333712 100644 --- a/app/code/Magento/Sales/Model/OrderRepository.php +++ b/app/code/Magento/Sales/Model/OrderRepository.php @@ -157,6 +157,9 @@ public function get($id) private function setOrderTaxDetails(OrderInterface $order) { $extensionAttributes = $order->getExtensionAttributes(); + if ($extensionAttributes === null) { + $extensionAttributes = $this->orderExtensionFactory->create(); + } $orderTaxDetails = $this->orderTaxManagement->getOrderTaxDetails($order->getEntityId()); $appliedTaxes = $orderTaxDetails->getAppliedTaxes(); @@ -180,6 +183,9 @@ private function setOrderTaxDetails(OrderInterface $order) private function setPaymentAdditionalInfo(OrderInterface $order): void { $extensionAttributes = $order->getExtensionAttributes(); + if ($extensionAttributes === null) { + $extensionAttributes = $this->orderExtensionFactory->create(); + } $paymentAdditionalInformation = $order->getPayment()->getAdditionalInformation(); $objects = []; From 3f616adb872b020c2ec132f2998d806ef7da2b8a Mon Sep 17 00:00:00 2001 From: Ashoka de Wit Date: Thu, 26 Mar 2020 12:19:06 +0800 Subject: [PATCH 02/99] Convert MSRP currency of configurable product options The MSRP of configurable products is updated in Javascript when an option is chosen. Javascript uses an object with prices of the options. The prices in this object are converted to the chosen currency. MSRP prices however were not converted, leading to the price being displayed in a wrong currency. --- .../Block/Product/View/Type/Configurable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php index 55c0c8f6ca4ce..7fe0aca43c5b8 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php @@ -321,7 +321,7 @@ protected function getOptionPrices() 'tierPrices' => $tierPrices, 'msrpPrice' => [ 'amount' => $this->localeFormat->getNumber( - $product->getMsrp() + $this->priceCurrency->convertAndRound($product->getMsrp()) ), ], ]; From a84629ff29f6011fceea1b4a40498a9ba78382d3 Mon Sep 17 00:00:00 2001 From: "v.prokopov" Date: Tue, 14 Apr 2020 21:38:57 +0300 Subject: [PATCH 03/99] fixed wrong customer group that assign to order --- .../Frontend/Quote/Address/CollectTotalsObserver.php | 4 +--- .../Frontend/Quote/Address/CollectTotalsObserverTest.php | 9 +-------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php b/app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php index a1228903e2323..b2004c60261fd 100644 --- a/app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php +++ b/app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php @@ -119,9 +119,7 @@ public function execute(\Magento\Framework\Event\Observer $observer) $groupId = null; if (empty($customerVatNumber) || false == $this->customerVat->isCountryInEU($customerCountryCode)) { - $groupId = $customer->getId() ? $this->groupManagement->getDefaultGroup( - $storeId - )->getId() : $this->groupManagement->getNotLoggedInGroup()->getId(); + $groupId = $customer->getId() ? $quote->getCustomerGroupId() : $this->groupManagement->getNotLoggedInGroup()->getId(); } else { // Magento always has to emulate group even if customer uses default billing/shipping address $groupId = $this->customerVat->getCustomerGroupIdBasedOnVatNumber( diff --git a/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php b/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php index a590c8aa891a5..03ae2c12df07c 100644 --- a/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php +++ b/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php @@ -243,26 +243,19 @@ public function testDispatchWithDefaultCustomerGroupId() ->will($this->returnValue('customerCountryCode')); $this->quoteAddressMock->expects($this->once())->method('getVatId')->will($this->returnValue(null)); - $this->quoteMock->expects($this->once()) + $this->quoteMock->expects($this->exactly(2)) ->method('getCustomerGroupId') ->will($this->returnValue('customerGroupId')); $this->customerMock->expects($this->once())->method('getId')->will($this->returnValue('1')); - $this->groupManagementMock->expects($this->once()) - ->method('getDefaultGroup') - ->will($this->returnValue($this->groupInterfaceMock)); - $this->groupInterfaceMock->expects($this->once()) - ->method('getId')->will($this->returnValue('defaultCustomerGroupId')); /** Assertions */ $this->quoteAddressMock->expects($this->once()) ->method('setPrevQuoteCustomerGroupId') ->with('customerGroupId'); - $this->quoteMock->expects($this->once())->method('setCustomerGroupId')->with('defaultCustomerGroupId'); $this->customerDataFactoryMock->expects($this->any()) ->method('create') ->willReturn($this->customerMock); $this->quoteMock->expects($this->once())->method('setCustomer')->with($this->customerMock); - /** SUT execution */ $this->model->execute($this->observerMock); } From 24793f9d90913df2489daffe7cce773c138a684e Mon Sep 17 00:00:00 2001 From: "v.prokopov" Date: Tue, 14 Apr 2020 21:44:07 +0300 Subject: [PATCH 04/99] refactored unit test class --- .../Address/CollectTotalsObserverTest.php | 85 ++++++++++++------- 1 file changed, 52 insertions(+), 33 deletions(-) diff --git a/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php b/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php index 03ae2c12df07c..4718119adc714 100644 --- a/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php +++ b/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php @@ -6,85 +6,104 @@ namespace Magento\Quote\Test\Unit\Observer\Frontend\Quote\Address; +use Magento\Customer\Api\AddressRepositoryInterface; +use Magento\Customer\Api\Data\AddressInterface; +use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Customer\Api\Data\CustomerInterfaceFactory; +use Magento\Customer\Api\Data\GroupInterface; +use Magento\Customer\Api\GroupManagementInterface; +use Magento\Customer\Model\Session; +use Magento\Customer\Model\Vat; +use Magento\Framework\Event\Observer; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Quote\Api\Data\ShippingAssignmentInterface; +use Magento\Quote\Api\Data\ShippingInterface; +use Magento\Quote\Model\Quote; +use Magento\Quote\Model\Quote\Address; +use Magento\Quote\Observer\Frontend\Quote\Address\CollectTotalsObserver; +use Magento\Quote\Observer\Frontend\Quote\Address\VatValidator; +use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\MockObject\MockObject; + /** * Class CollectTotalsTest * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class CollectTotalsObserverTest extends \PHPUnit\Framework\TestCase +class CollectTotalsObserverTest extends TestCase { /** - * @var \Magento\Quote\Observer\Frontend\Quote\Address\CollectTotalsObserver + * @var CollectTotalsObserver */ protected $model; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $customerAddressMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $customerSession; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $customerVatMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $addressRepository; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $quoteAddressMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $quoteMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $storeId; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $customerMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $vatValidatorMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $observerMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $customerDataFactoryMock; /** - * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager + * @var ObjectManager */ protected $objectManager; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $groupManagementMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ protected $groupInterfaceMock; @@ -93,10 +112,10 @@ class CollectTotalsObserverTest extends \PHPUnit\Framework\TestCase */ protected function setUp() { - $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->objectManager = new ObjectManager($this); $this->storeId = 1; $this->customerMock = $this->getMockForAbstractClass( - \Magento\Customer\Api\Data\CustomerInterface::class, + CustomerInterface::class, [], '', false, @@ -105,29 +124,29 @@ protected function setUp() ['getStoreId', 'getCustomAttribute', 'getId', '__wakeup'] ); $this->customerAddressMock = $this->createMock(\Magento\Customer\Helper\Address::class); - $this->customerVatMock = $this->createMock(\Magento\Customer\Model\Vat::class); + $this->customerVatMock = $this->createMock(Vat::class); $this->customerDataFactoryMock = $this->createPartialMock( - \Magento\Customer\Api\Data\CustomerInterfaceFactory::class, + CustomerInterfaceFactory::class, ['mergeDataObjectWithArray', 'create'] ); - $this->vatValidatorMock = $this->createMock(\Magento\Quote\Observer\Frontend\Quote\Address\VatValidator::class); + $this->vatValidatorMock = $this->createMock(VatValidator::class); $this->observerMock = $this->createPartialMock( - \Magento\Framework\Event\Observer::class, + Observer::class, ['getShippingAssignment', 'getQuote'] ); $this->quoteAddressMock = $this->createPartialMock( - \Magento\Quote\Model\Quote\Address::class, + Address::class, ['getCountryId', 'getVatId', 'getQuote', 'setPrevQuoteCustomerGroupId', '__wakeup'] ); $this->quoteMock = $this->createPartialMock( - \Magento\Quote\Model\Quote::class, + Quote::class, ['setCustomerGroupId', 'getCustomerGroupId', 'getCustomer', '__wakeup', 'setCustomer'] ); $this->groupManagementMock = $this->getMockForAbstractClass( - \Magento\Customer\Api\GroupManagementInterface::class, + GroupManagementInterface::class, [], '', false, @@ -140,7 +159,7 @@ protected function setUp() ); $this->groupInterfaceMock = $this->getMockForAbstractClass( - \Magento\Customer\Api\Data\GroupInterface::class, + GroupInterface::class, [], '', false, @@ -149,8 +168,8 @@ protected function setUp() ['getId'] ); - $shippingAssignmentMock = $this->createMock(\Magento\Quote\Api\Data\ShippingAssignmentInterface::class); - $shippingMock = $this->createMock(\Magento\Quote\Api\Data\ShippingInterface::class); + $shippingAssignmentMock = $this->createMock(ShippingAssignmentInterface::class); + $shippingMock = $this->createMock(ShippingInterface::class); $shippingAssignmentMock->expects($this->once())->method('getShipping')->willReturn($shippingMock); $shippingMock->expects($this->once())->method('getAddress')->willReturn($this->quoteAddressMock); @@ -163,14 +182,14 @@ protected function setUp() ->method('getCustomer') ->will($this->returnValue($this->customerMock)); - $this->addressRepository = $this->createMock(\Magento\Customer\Api\AddressRepositoryInterface::class); - $this->customerSession = $this->getMockBuilder(\Magento\Customer\Model\Session::class) + $this->addressRepository = $this->createMock(AddressRepositoryInterface::class); + $this->customerSession = $this->getMockBuilder(Session::class) ->disableOriginalConstructor() ->getMock(); $this->customerMock->expects($this->any())->method('getStoreId')->will($this->returnValue($this->storeId)); - $this->model = new \Magento\Quote\Observer\Frontend\Quote\Address\CollectTotalsObserver( + $this->model = new CollectTotalsObserver( $this->customerAddressMock, $this->customerVatMock, $this->vatValidatorMock, @@ -313,7 +332,7 @@ public function testDispatchWithAddressCustomerVatIdAndCountryId() $customerVat = "123123123"; $defaultShipping = 1; - $customerAddress = $this->createMock(\Magento\Quote\Model\Quote\Address::class); + $customerAddress = $this->createMock(Address::class); $customerAddress->expects($this->any()) ->method("getVatId") ->willReturn($customerVat); @@ -350,7 +369,7 @@ public function testDispatchWithEmptyShippingAddress() $customerVat = "123123123"; $defaultShipping = 1; - $customerAddress = $this->createMock(\Magento\Customer\Api\Data\AddressInterface::class); + $customerAddress = $this->createMock(AddressInterface::class); $customerAddress->expects($this->once()) ->method("getCountryId") ->willReturn($customerCountryCode); From a6cf5cb8901671db758391d7a099c6ed630f5944 Mon Sep 17 00:00:00 2001 From: "v.prokopov" Date: Mon, 20 Apr 2020 19:24:25 +0300 Subject: [PATCH 05/99] fixed too long string --- .../Observer/Frontend/Quote/Address/CollectTotalsObserver.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php b/app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php index b2004c60261fd..c19dbc2c429ae 100644 --- a/app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php +++ b/app/code/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserver.php @@ -119,7 +119,8 @@ public function execute(\Magento\Framework\Event\Observer $observer) $groupId = null; if (empty($customerVatNumber) || false == $this->customerVat->isCountryInEU($customerCountryCode)) { - $groupId = $customer->getId() ? $quote->getCustomerGroupId() : $this->groupManagement->getNotLoggedInGroup()->getId(); + $groupId = $customer->getId() ? $quote->getCustomerGroupId() : + $this->groupManagement->getNotLoggedInGroup()->getId(); } else { // Magento always has to emulate group even if customer uses default billing/shipping address $groupId = $this->customerVat->getCustomerGroupIdBasedOnVatNumber( From c38d1eff47da68c410eacd92e32df67a0ab80ecf Mon Sep 17 00:00:00 2001 From: "v.prokopov" Date: Sat, 23 May 2020 23:01:18 +0300 Subject: [PATCH 06/99] fixed integration test --- .../Frontend/Quote/Address/CollectTotalsObserverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php b/dev/tests/integration/testsuite/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php index 828dac514427d..27e4d2c9b876d 100644 --- a/dev/tests/integration/testsuite/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Quote/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php @@ -133,6 +133,6 @@ public function testChangeQuoteCustomerGroupIdForCustomerWithEnabledAutomaticGro ); $this->model->execute($eventObserver); - $this->assertEquals(1, $quote->getCustomer()->getGroupId()); + $this->assertEquals(2, $quote->getCustomer()->getGroupId()); } } From cae2258c432e3c136e36480891ca0d21558d1b11 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Wed, 17 Jun 2020 17:18:58 +0300 Subject: [PATCH 07/99] MFTF test --- ...tCustomerCheckoutWithCustomerGroupTest.xml | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest/StorefrontCustomerCheckoutWithCustomerGroupTest.xml diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest/StorefrontCustomerCheckoutWithCustomerGroupTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest/StorefrontCustomerCheckoutWithCustomerGroupTest.xml new file mode 100644 index 0000000000000..53d50b8ea8bf9 --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest/StorefrontCustomerCheckoutWithCustomerGroupTest.xml @@ -0,0 +1,89 @@ + + + + + + + + + <description value="Should be assign Customer Group to Order, when enabled setting fir Customer - Auto Group Assign"/> + <severity value="MAJOR"/> + <group value="checkout"/> + <group value="customer"/> + </annotations> + <before> + + <magentoCLI command="config:set customer/create_account/auto_group_assign 1" stepKey="enableAutoGroupAssign"/> + + <createData entity="SimpleSubCategory" stepKey="createCategory"/> + <createData entity="SimpleProduct" stepKey="createSimpleProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> + + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + + <actionGroup ref="AdminUpdateCustomerGroupByEmailActionGroup" stepKey="updateCustomerGroup"> + <argument name="emailAddress" value="$$createCustomer.email$$"/> + <argument name="customerGroup" value="Retail"/> + </actionGroup> + + </before> + <after> + <magentoCLI command="config:set customer/create_account/auto_group_assign 0" stepKey="disableAutoGroupAssign"/> + + <actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer"/> + <deleteData createDataKey="createCustomer" stepKey="deleteUsCustomer"/> + <actionGroup ref="AdminClearCustomersFiltersActionGroup" stepKey="resetCustomerFilters"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/> + <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> + <deleteData createDataKey="createCategory" stepKey="deleteSimpleCategory"/> + </after> + + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="storefrontCustomerLogin"> + <argument name="Customer" value="$$createCustomer$$"/> + </actionGroup> + + <actionGroup ref="StorefrontNavigateCategoryPageActionGroup" stepKey="navigateToCategoryPage"> + <argument name="category" value="$$createCategory$$"/> + </actionGroup> + + <waitForPageLoad stepKey="waitForCatalogPageLoad"/> + + <actionGroup ref="StorefrontAddCategoryProductToCartActionGroup" stepKey="addProductToCart"> + <argument name="product" value="$$createSimpleProduct$$"/> + <argument name="productCount" value="CONST.one"/> + </actionGroup> + + <actionGroup ref="GoToCheckoutFromMinicartActionGroup" stepKey="goToCheckoutFromMinicart"/> + <actionGroup ref="CheckoutSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRate"/> + <actionGroup ref="StorefrontCheckoutForwardFromShippingStepActionGroup" stepKey="goToReview"/> + <actionGroup ref="CheckoutSelectCheckMoneyOrderPaymentActionGroup" stepKey="selectCheckMoneyOrder"/> + <actionGroup ref="CheckoutPlaceOrderActionGroup" stepKey="clickOnPlaceOrder"> + <argument name="orderNumberMessage" value="CONST.successCheckoutOrderNumberMessage"/> + <argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage"/> + </actionGroup> + + <grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="orderNumber"/> + + <actionGroup ref="OpenOrderByIdActionGroup" stepKey="addFilterToGridAndOpenOrder"> + <argument name="orderId" value="{$orderNumber}"/> + </actionGroup> + + <see selector="{{AdminOrderDetailsInformationSection.orderStatus}}" userInput="Pending" stepKey="verifyOrderStatus"/> + <see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="Customer" stepKey="verifyAccountInformation"/> + <see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="$$createCustomer.email$$" stepKey="verifyCustomerEmail"/> + <see selector="{{AdminOrderDetailsInformationSection.accountInformation}}" userInput="Retail" stepKey="verifyCustomerGroup"/> + <see selector="{{AdminOrderDetailsInformationSection.billingAddress}}" userInput="{{US_Address_TX.street[0]}}" stepKey="verifyBillingAddress"/> + <see selector="{{AdminOrderDetailsInformationSection.shippingAddress}}" userInput="{{US_Address_TX.street[0]}}" stepKey="verifyShippingAddress"/> + <see selector="{{AdminOrderDetailsInformationSection.itemsOrdered}}" userInput="$$createSimpleProduct.name$$" stepKey="verifyProductName"/> + + </test> +</tests> From a57dbd6d203251a4dd93f5d3fb258d53d7464821 Mon Sep 17 00:00:00 2001 From: poraphit <porraphit@gmail.com> Date: Fri, 26 Jun 2020 10:37:42 +0700 Subject: [PATCH 08/99] Remove related products that not exist in map list. --- .../Model/Resolver/Batch/AbstractLikedProducts.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/Magento/RelatedProductGraphQl/Model/Resolver/Batch/AbstractLikedProducts.php b/app/code/Magento/RelatedProductGraphQl/Model/Resolver/Batch/AbstractLikedProducts.php index 7ad2e5dde2985..e14d8bde6be74 100644 --- a/app/code/Magento/RelatedProductGraphQl/Model/Resolver/Batch/AbstractLikedProducts.php +++ b/app/code/Magento/RelatedProductGraphQl/Model/Resolver/Batch/AbstractLikedProducts.php @@ -110,6 +110,10 @@ private function findRelations(array $products, array $loadAttributes, int $link //Matching products with related products. $relationsData = []; foreach ($relations as $productId => $relatedIds) { + //Remove related products that not exist in map list. + $relatedIds = array_filter($relatedIds, function ($relatedId) use ($relatedProducts) { + return isset($relatedProducts[$relatedId]); + }); $relationsData[$productId] = array_map( function ($id) use ($relatedProducts) { return $relatedProducts[$id]; From a9e6752a024fd6998b5a838cdf84cc2004d6dbf7 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk <grp-engcom-vendorworker-Kilo@adobe.com> Date: Mon, 27 Jul 2020 15:50:30 +0300 Subject: [PATCH 09/99] Correct Static and Unit test --- .../Frontend/Quote/Address/CollectTotalsObserverTest.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php b/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php index 4eced46a2ee2e..ae2a4734215ad 100644 --- a/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php +++ b/app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php @@ -150,7 +150,6 @@ protected function setUp(): void ->disableOriginalConstructor() ->getMock(); - $this->groupManagementMock = $this->getMockForAbstractClass( GroupManagementInterface::class, [], @@ -272,11 +271,6 @@ public function testDispatchWithDefaultCustomerGroupId() ->method('getCustomerGroupId') ->willReturn('customerGroupId'); $this->customerMock->expects($this->once())->method('getId')->willReturn('1'); - $this->groupManagementMock->expects($this->once()) - ->method('getDefaultGroup') - ->willReturn($this->groupInterfaceMock); - $this->groupInterfaceMock->expects($this->once()) - ->method('getId')->willReturn('defaultCustomerGroupId'); /** Assertions */ $this->quoteAddressMock->expects($this->once()) From 4f2d8de0f36132cab835e5af3bc88d461e87967f Mon Sep 17 00:00:00 2001 From: Shankar Konar <konar.shankar2013@gmail.com> Date: Thu, 6 Aug 2020 11:47:05 +0530 Subject: [PATCH 10/99] Added sticky in lac banner --- .../frontend/templates/html/notices.phtml | 4 +- .../view/frontend/web/css/source/_module.less | 64 ++++++++++--------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/app/code/Magento/LoginAsCustomerFrontendUi/view/frontend/templates/html/notices.phtml b/app/code/Magento/LoginAsCustomerFrontendUi/view/frontend/templates/html/notices.phtml index aa64e78aa234f..b2e0aaf20ce34 100644 --- a/app/code/Magento/LoginAsCustomerFrontendUi/view/frontend/templates/html/notices.phtml +++ b/app/code/Magento/LoginAsCustomerFrontendUi/view/frontend/templates/html/notices.phtml @@ -11,7 +11,9 @@ $viewFileUrl = $block->getViewFileUrl('Magento_LoginAsCustomerFrontendUi::images/magento-icon.svg'); ?> <?php if ($block->getConfig()->isEnabled()): ?> - <div data-bind="scope: 'loginAsCustomer'" > + <div class="lac-notification-sticky" + data-mage-init='{"sticky":{"container": "body"}}' + data-bind="scope: 'loginAsCustomer'" > <div class="lac-notification clearfix" data-bind="visible: isVisible" style="display: none"> <div class="top-container"> <div class="lac-notification-icon wrapper"> diff --git a/app/code/Magento/LoginAsCustomerFrontendUi/view/frontend/web/css/source/_module.less b/app/code/Magento/LoginAsCustomerFrontendUi/view/frontend/web/css/source/_module.less index d630ff06c3e34..c42f5143b4fda 100644 --- a/app/code/Magento/LoginAsCustomerFrontendUi/view/frontend/web/css/source/_module.less +++ b/app/code/Magento/LoginAsCustomerFrontendUi/view/frontend/web/css/source/_module.less @@ -16,43 +16,47 @@ // --------------------------------------------- & when (@media-common = true) { - .lac-notification { - background-color: @lac-notification-background-color; - color: @lac-notification-color; - font-size: 16px; + .lac-notification-sticky { + position: relative; + z-index: 999; + .lac-notification { + background-color: @lac-notification-background-color; + color: @lac-notification-color; + font-size: 16px; - .lac-notification-icon { - float: left; - margin: 10px 25px 10px 10px; + .lac-notification-icon { + float: left; + margin: 10px 25px 10px 10px; - .logo-img { - display: block + .logo-img { + display: block + } } - } - .lac-notification-text { - float: left; - padding: 15px 0; - } + .lac-notification-text { + float: left; + padding: 15px 0; + } - .lac-notification-links { - float: right; - padding: 15px 0; + .lac-notification-links { + float: right; + padding: 15px 0; - a { - color: @lac-notification-links-color; - font-size: 14px; - } + a { + color: @lac-notification-links-color; + font-size: 14px; + } - .lac-notification-close-link { - &:after { - background: url('../Magento_LoginAsCustomerFrontendUi/images/close.svg'); - content: ' '; - display: inline-block; - height: 12px; - margin-left: 5px; - vertical-align: middle; - width: 12px; + .lac-notification-close-link { + &:after { + background: url('../Magento_LoginAsCustomerFrontendUi/images/close.svg'); + content: ' '; + display: inline-block; + height: 12px; + margin-left: 5px; + vertical-align: middle; + width: 12px; + } } } } From 43cca51a6d361c73bfebcbeeebf2430e345b5157 Mon Sep 17 00:00:00 2001 From: Shankar Konar <konar.shankar2013@gmail.com> Date: Thu, 6 Aug 2020 16:20:05 +0530 Subject: [PATCH 11/99] MFTF test added --- ...oginAsCustomerBannerVisibleActionGroup.xml | 20 +++++++++++ .../StorefrontLoginToCustomerActionGroup.xml | 22 ++++++++++++ ...orefrontCustomerLoginAsCustomerSection.xml | 15 ++++++++ .../StorefrontLoginAsCustomerBannerTest.xml | 35 +++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerBannerVisibleActionGroup.xml create mode 100644 app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontLoginToCustomerActionGroup.xml create mode 100644 app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Section/StorefrontCustomerLoginAsCustomerSection.xml create mode 100644 app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Test/StorefrontLoginAsCustomerBannerTest.xml diff --git a/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerBannerVisibleActionGroup.xml b/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerBannerVisibleActionGroup.xml new file mode 100644 index 0000000000000..c37cf089398dc --- /dev/null +++ b/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerBannerVisibleActionGroup.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="StorefrontAssertLoginAsCustomerBannerVisibleActionGroup"> + <annotations> + <description>Assert Login As Customer Banner is sticky</description> + </annotations> + + <seeElement selector="{{StorefrontCustomerLoginAsCustomerSection.loginAsCustomerBanner}}" stepKey="verifyBannerIsVisibleBeforeScroll"/> + <scrollTo selector="{{StorefrontCustomerLoginAsCustomerSection.copyright}}" stepKey="scrollToEndOfThePage" /> + <seeElement selector="{{StorefrontCustomerLoginAsCustomerSection.loginAsCustomerBanner}}" stepKey="verifyBannerIsVisibleAfterScroll"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontLoginToCustomerActionGroup.xml b/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontLoginToCustomerActionGroup.xml new file mode 100644 index 0000000000000..2227cd4a3109c --- /dev/null +++ b/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontLoginToCustomerActionGroup.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="StorefrontLoginToCustomerActionGroup"> + <annotations> + <description>Login to customer account using Login As customer.</description> + </annotations> + <arguments> + <argument name="customerId" type="string"/> + </arguments> + + <amOnPage url="admin/loginascustomer/login/login/customer_id/{{customerId}}/" stepKey="loginAsCustomer"/> + <waitForElementVisible selector="{{StorefrontCustomerLoginAsCustomerSection.loginAsCustomerBanner}}" stepKey="waitForLoginAsCustomerPageLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Section/StorefrontCustomerLoginAsCustomerSection.xml b/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Section/StorefrontCustomerLoginAsCustomerSection.xml new file mode 100644 index 0000000000000..a58fcab7145d5 --- /dev/null +++ b/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Section/StorefrontCustomerLoginAsCustomerSection.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> + <section name="StorefrontCustomerLoginAsCustomerSection"> + <element name="loginAsCustomerBanner" type="text" selector=".lac-notification-sticky" timeout="30"/> + <element name="copyright" type="text" selector=".copyright" timeout="30"/> + </section> +</sections> diff --git a/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Test/StorefrontLoginAsCustomerBannerTest.xml b/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Test/StorefrontLoginAsCustomerBannerTest.xml new file mode 100644 index 0000000000000..04b0acca3be63 --- /dev/null +++ b/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Test/StorefrontLoginAsCustomerBannerTest.xml @@ -0,0 +1,35 @@ +<?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="StorefrontLoginAsCustomerBannerTest"> + <annotations> + <features value="StorefrontLoginAsCustomerBanner"/> + <stories value="User login as customer and verify banner is sticky"/> + <useCaseId value="https://github.com/magento/magento2/issues/29354"/> + <title value="User login as customer and verify banner is sticky"/> + <testCaseId value=""/> + <description value="User login as customer and verify banner is sticky"/> + <severity value="CRITICAL"/> + </annotations> + <before> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> + </before> + + <after> + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer" /> + </after> + + <actionGroup ref="StorefrontLoginToCustomerActionGroup" stepKey="LoginAsCustomer"> + <argument name="customerId" value="$$createCustomer.id$$"/> + </actionGroup> + <actionGroup ref="StorefrontAssertLoginAsCustomerBannerVisibleActionGroup" stepKey="assertBannerIsSticky" /> + </test> +</tests> From 804ed717fbe4ece509cb7cac483ff0aa8945770f Mon Sep 17 00:00:00 2001 From: Shankar Konar <konar.shankar2013@gmail.com> Date: Fri, 7 Aug 2020 12:36:07 +0530 Subject: [PATCH 12/99] refactoring MFTF test --- ...sCustomerNotificationBannerActionGroup.xml | 33 ++++++++++++ ...yLoginAsCustomerNotificationBannerTest.xml | 51 +++++++++++++++++++ ...oginAsCustomerBannerVisibleActionGroup.xml | 20 -------- .../StorefrontLoginToCustomerActionGroup.xml | 22 -------- ...orefrontCustomerLoginAsCustomerSection.xml | 15 ------ .../StorefrontLoginAsCustomerBannerTest.xml | 35 ------------- 6 files changed, 84 insertions(+), 92 deletions(-) create mode 100644 app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml create mode 100644 app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml delete mode 100644 app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerBannerVisibleActionGroup.xml delete mode 100644 app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontLoginToCustomerActionGroup.xml delete mode 100644 app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Section/StorefrontCustomerLoginAsCustomerSection.xml delete mode 100644 app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Test/StorefrontLoginAsCustomerBannerTest.xml diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml new file mode 100644 index 0000000000000..46f582ca6d44e --- /dev/null +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml @@ -0,0 +1,33 @@ +<?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="StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup"> + <annotations> + <description>Verify Sticky Login as Customer notification banner present on page.</description> + </annotations> + <arguments> + <argument name="customerFullName" type="string"/> + <argument name="websiteName" type="string" defaultValue="Main Website"/> + </arguments> + + <waitForElementVisible selector="{{StorefrontLoginAsCustomerNotificationSection.notificationText}}" stepKey="waitForNotificationBanner"/> + <see selector="{{StorefrontLoginAsCustomerNotificationSection.notificationText}}" + userInput="You are connected as {{customerFullName}} on {{websiteName}}" + stepKey="assertCorrectNotificationBannerMessage"/> + <seeElement selector="{{StorefrontLoginAsCustomerNotificationSection.closeLink}}" + stepKey="assertCloseNotificationBannerPresent"/> + <executeJS function="window.scrollTo(0,document.body.scrollHeight);" stepKey="scrollToBottomOfPage"/> + <see selector="{{StorefrontLoginAsCustomerNotificationSection.notificationText}}" + userInput="You are connected as {{customerFullName}} on {{websiteName}}" + stepKey="assertCorrectNotificationBannerMessageAfterScroll"/> + <seeElement selector="{{StorefrontLoginAsCustomerNotificationSection.closeLink}}" + stepKey="assertCloseNotificationBannerPresentAfterScroll"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml new file mode 100644 index 0000000000000..3368fa7e5be7a --- /dev/null +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml @@ -0,0 +1,51 @@ +<?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="StorefrontStickyLoginAsCustomerNotificationBannerTest"> + <annotations> + <features value="Login as Customer"/> + <useCaseId value="https://github.com/magento/magento2/issues/29354"/> + <stories value="Availability of sticky UI elements if module enable/disable"/> + <title value="Sticky Notification Banner is present on Storefront page"/> + <description + value="Verify that Sticky Notification Banner is present on page if 'Login as customer' functionality used"/> + <testCaseId value=""/> + <severity value="CRITICAL"/> + </annotations> + <before> + <magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 1" + stepKey="enableLoginAsCustomer"/> + <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushConfigCache"> + <argument name="tags" value="config"/> + </actionGroup> + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="login"/> + </before> + + <after> + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> + <magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 0" + stepKey="disableLoginAsCustomer"/> + <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushConfigCache"> + <argument name="tags" value="config"/> + </actionGroup> + </after> + + <actionGroup ref="AdminLoginAsCustomerLoginFromCustomerPageActionGroup" stepKey="loginAsCustomerFromCustomerPage"> + <argument name="customerId" value="$$createCustomer.id$$"/> + </actionGroup> + + <actionGroup ref="StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup" stepKey="assertStickyNotificationBanner"> + <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> + </actionGroup> + + <actionGroup ref="StorefrontSignOutNotificationBannerAndCloseTabActionGroup" stepKey="signOutAndCloseTab"/> + </test> +</tests> diff --git a/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerBannerVisibleActionGroup.xml b/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerBannerVisibleActionGroup.xml deleted file mode 100644 index c37cf089398dc..0000000000000 --- a/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerBannerVisibleActionGroup.xml +++ /dev/null @@ -1,20 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> - -<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="StorefrontAssertLoginAsCustomerBannerVisibleActionGroup"> - <annotations> - <description>Assert Login As Customer Banner is sticky</description> - </annotations> - - <seeElement selector="{{StorefrontCustomerLoginAsCustomerSection.loginAsCustomerBanner}}" stepKey="verifyBannerIsVisibleBeforeScroll"/> - <scrollTo selector="{{StorefrontCustomerLoginAsCustomerSection.copyright}}" stepKey="scrollToEndOfThePage" /> - <seeElement selector="{{StorefrontCustomerLoginAsCustomerSection.loginAsCustomerBanner}}" stepKey="verifyBannerIsVisibleAfterScroll"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontLoginToCustomerActionGroup.xml b/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontLoginToCustomerActionGroup.xml deleted file mode 100644 index 2227cd4a3109c..0000000000000 --- a/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/ActionGroup/StorefrontLoginToCustomerActionGroup.xml +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> - -<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="StorefrontLoginToCustomerActionGroup"> - <annotations> - <description>Login to customer account using Login As customer.</description> - </annotations> - <arguments> - <argument name="customerId" type="string"/> - </arguments> - - <amOnPage url="admin/loginascustomer/login/login/customer_id/{{customerId}}/" stepKey="loginAsCustomer"/> - <waitForElementVisible selector="{{StorefrontCustomerLoginAsCustomerSection.loginAsCustomerBanner}}" stepKey="waitForLoginAsCustomerPageLoad"/> - </actionGroup> -</actionGroups> diff --git a/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Section/StorefrontCustomerLoginAsCustomerSection.xml b/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Section/StorefrontCustomerLoginAsCustomerSection.xml deleted file mode 100644 index a58fcab7145d5..0000000000000 --- a/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Section/StorefrontCustomerLoginAsCustomerSection.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> - -<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> - <section name="StorefrontCustomerLoginAsCustomerSection"> - <element name="loginAsCustomerBanner" type="text" selector=".lac-notification-sticky" timeout="30"/> - <element name="copyright" type="text" selector=".copyright" timeout="30"/> - </section> -</sections> diff --git a/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Test/StorefrontLoginAsCustomerBannerTest.xml b/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Test/StorefrontLoginAsCustomerBannerTest.xml deleted file mode 100644 index 04b0acca3be63..0000000000000 --- a/app/code/Magento/LoginAsCustomerFrontendUi/Test/Mftf/Test/StorefrontLoginAsCustomerBannerTest.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> - -<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> - <test name="StorefrontLoginAsCustomerBannerTest"> - <annotations> - <features value="StorefrontLoginAsCustomerBanner"/> - <stories value="User login as customer and verify banner is sticky"/> - <useCaseId value="https://github.com/magento/magento2/issues/29354"/> - <title value="User login as customer and verify banner is sticky"/> - <testCaseId value=""/> - <description value="User login as customer and verify banner is sticky"/> - <severity value="CRITICAL"/> - </annotations> - <before> - <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> - <createData entity="Simple_US_Customer" stepKey="createCustomer"/> - </before> - - <after> - <deleteData createDataKey="createCustomer" stepKey="deleteCustomer" /> - </after> - - <actionGroup ref="StorefrontLoginToCustomerActionGroup" stepKey="LoginAsCustomer"> - <argument name="customerId" value="$$createCustomer.id$$"/> - </actionGroup> - <actionGroup ref="StorefrontAssertLoginAsCustomerBannerVisibleActionGroup" stepKey="assertBannerIsSticky" /> - </test> -</tests> From c0ca7cdf42a3f4425827fe61f4b7711ae0996e8b Mon Sep 17 00:00:00 2001 From: Shankar Konar <konar.shankar2013@gmail.com> Date: Mon, 10 Aug 2020 11:05:10 +0530 Subject: [PATCH 13/99] Feedback changes --- ...insMessageOrderCreatedByAdminActionGroup.xml} | 2 +- ...merConfigNotAvailableDirectlyActionGroup.xml} | 2 +- ...ginAsCustomerConfigNotVisibleActionGroup.xml} | 2 +- ...nLoginAsCustomerConfigVisibleActionGroup.xml} | 2 +- ...AdminLoginAsCustomerLogRecordActionGroup.xml} | 2 +- ...stomerSectionLinkNotAvailableActionGroup.xml} | 2 +- ...insMessageOrderCreatedByAdminActionGroup.xml} | 2 +- ...StorefrontCustomerOnStoreViewActionGroup.xml} | 2 +- ...efrontLoginAsCustomerLoggedInActionGroup.xml} | 2 +- ...nAsCustomerNotificationBannerActionGroup.xml} | 2 +- ...nAsCustomerNotificationBannerActionGroup.xml} | 2 +- .../AdminLoginAsCustomerAutoDetectionTest.xml | 2 +- .../Test/AdminLoginAsCustomerLoggingTest.xml | 8 ++++---- .../AdminLoginAsCustomerManualChooseTest.xml | 4 ++-- ...inLoginAsCustomerMultishippingLoggingTest.xml | 8 ++++---- .../Test/AdminLoginAsCustomerPlaceOrderTest.xml | 4 ++-- .../Test/AdminLoginAsCustomerReorderTest.xml | 4 ++-- ...stomerSettingsAvailableForGlobalLevelTest.xml | 6 +++--- .../Test/AdminLoginAsCustomerUserLogoutTest.xml | 2 +- ...AdminLoginAsCustomerUserSingleSessionTest.xml | 4 ++-- ...oAccessToLoginAsCustomerConfigurationTest.xml | 4 ++-- .../AdminUIShownIfLoginAsCustomerEnabledTest.xml | 4 ++-- ...tomerBannerPresentOnAllPagesInSessionTest.xml | 16 ++++++++-------- ...rontLoginAsCustomerNotificationBannerTest.xml | 2 +- ...inAsCustomerSeeSpecialPriceOnCategoryTest.xml | 2 +- ...rShoppingCartIsNotMergedWithGuestCartTest.xml | 2 +- ...ickyLoginAsCustomerNotificationBannerTest.xml | 4 ++-- 27 files changed, 49 insertions(+), 49 deletions(-) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AdminAssertContainsMessageOrderCreatedByAdminActionGroup.xml => AssertAdminContainsMessageOrderCreatedByAdminActionGroup.xml} (93%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AdminAssertLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml => AssertAdminLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml} (93%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AdminAssertLoginAsCustomerConfigNotVisibleActionGroup.xml => AssertAdminLoginAsCustomerConfigNotVisibleActionGroup.xml} (90%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AdminAssertLoginAsCustomerConfigVisibleActionGroup.xml => AssertAdminLoginAsCustomerConfigVisibleActionGroup.xml} (93%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AdminAssertLoginAsCustomerLogRecordActionGroup.xml => AssertAdminLoginAsCustomerLogRecordActionGroup.xml} (94%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AdminAssertLoginAsCustomerSectionLinkNotAvailableActionGroup.xml => AssertAdminLoginAsCustomerSectionLinkNotAvailableActionGroup.xml} (93%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup.xml => AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup.xml} (93%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{StorefrontAssertCustomerOnStoreViewActionGroup.xml => AssertStorefrontCustomerOnStoreViewActionGroup.xml} (92%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{StorefrontAssertLoginAsCustomerLoggedInActionGroup.xml => AssertStorefrontLoginAsCustomerLoggedInActionGroup.xml} (94%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{StorefrontAssertLoginAsCustomerNotificationBannerActionGroup.xml => AssertStorefrontLoginAsCustomerNotificationBannerActionGroup.xml} (95%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml => AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup.xml} (96%) diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertContainsMessageOrderCreatedByAdminActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminContainsMessageOrderCreatedByAdminActionGroup.xml similarity index 93% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertContainsMessageOrderCreatedByAdminActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminContainsMessageOrderCreatedByAdminActionGroup.xml index bcf6fc96aa131..cfab1ffc5bbf4 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertContainsMessageOrderCreatedByAdminActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminContainsMessageOrderCreatedByAdminActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminAssertContainsMessageOrderCreatedByAdminActionGroup"> + <actionGroup name="AssertAdminContainsMessageOrderCreatedByAdminActionGroup"> <annotations> <description>Assert Admin Order page contains message about Order created by a Store Administrator. </description> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml similarity index 93% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml index 7e032b168f062..ec2261be6d20f 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminAssertLoginAsCustomerConfigNotAvailableDirectlyActionGroup"> + <actionGroup name="AssertAdminLoginAsCustomerConfigNotAvailableDirectlyActionGroup"> <annotations> <description>Verify Login as Customer config section is not available by direct url.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigNotVisibleActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigNotVisibleActionGroup.xml similarity index 90% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigNotVisibleActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigNotVisibleActionGroup.xml index 875869d9928a4..18c1fb32a6f93 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigNotVisibleActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigNotVisibleActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminAssertLoginAsCustomerConfigNotVisibleActionGroup"> + <actionGroup name="AssertAdminLoginAsCustomerConfigNotVisibleActionGroup"> <annotations> <description>Verify no Login as Customer config section available.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigVisibleActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigVisibleActionGroup.xml similarity index 93% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigVisibleActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigVisibleActionGroup.xml index cdc513651ad54..9ddb439b2e5a3 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigVisibleActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigVisibleActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminAssertLoginAsCustomerConfigVisibleActionGroup"> + <actionGroup name="AssertAdminLoginAsCustomerConfigVisibleActionGroup"> <annotations> <description>Verify Login as Customer config section available.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerLogRecordActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerLogRecordActionGroup.xml similarity index 94% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerLogRecordActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerLogRecordActionGroup.xml index da47864e28eac..0c35992e025f3 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerLogRecordActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerLogRecordActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminAssertLoginAsCustomerLogRecordActionGroup"> + <actionGroup name="AssertAdminLoginAsCustomerLogRecordActionGroup"> <annotations> <description>Assert Login as Customer Log record is correct.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerSectionLinkNotAvailableActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerSectionLinkNotAvailableActionGroup.xml similarity index 93% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerSectionLinkNotAvailableActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerSectionLinkNotAvailableActionGroup.xml index 779cb1e5c8899..f05be04bc78fe 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerSectionLinkNotAvailableActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerSectionLinkNotAvailableActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminAssertLoginAsCustomerSectionLinkNotAvailableActionGroup"> + <actionGroup name="AssertAdminLoginAsCustomerSectionLinkNotAvailableActionGroup"> <annotations> <description>Verify Login as Customer config section isn't available.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup.xml similarity index 93% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup.xml index f40ea7f93c7a1..da1be5eed010f 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup"> + <actionGroup name="AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup"> <annotations> <description>Verify Storefront Order page contains message about Order created by a Store Administrator. </description> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertCustomerOnStoreViewActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontCustomerOnStoreViewActionGroup.xml similarity index 92% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertCustomerOnStoreViewActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontCustomerOnStoreViewActionGroup.xml index f63cda2303526..f8c240abeb8fd 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertCustomerOnStoreViewActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontCustomerOnStoreViewActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="StorefrontAssertCustomerOnStoreViewActionGroup"> + <actionGroup name="AssertStorefrontCustomerOnStoreViewActionGroup"> <annotations> <description>Assert Customer is on the provided Store View.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerLoggedInActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontLoginAsCustomerLoggedInActionGroup.xml similarity index 94% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerLoggedInActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontLoginAsCustomerLoggedInActionGroup.xml index bb7e938bdfb59..7badab1fc8dfd 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerLoggedInActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontLoginAsCustomerLoggedInActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="StorefrontAssertLoginAsCustomerLoggedInActionGroup"> + <actionGroup name="AssertStorefrontLoginAsCustomerLoggedInActionGroup"> <annotations> <description>Verify Admin successfully logged in as Customer.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerNotificationBannerActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontLoginAsCustomerNotificationBannerActionGroup.xml similarity index 95% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerNotificationBannerActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontLoginAsCustomerNotificationBannerActionGroup.xml index ce2e261f10040..a2464caa54a38 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerNotificationBannerActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontLoginAsCustomerNotificationBannerActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup"> + <actionGroup name="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup"> <annotations> <description>Verify Login as Customer notification banner present on page.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup.xml similarity index 96% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup.xml index 46f582ca6d44e..b1b3ccd05ddfc 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup"> + <actionGroup name="AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup"> <annotations> <description>Verify Sticky Login as Customer notification banner present on page.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerAutoDetectionTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerAutoDetectionTest.xml index 42d53113e20f4..bdfadaf378561 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerAutoDetectionTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerAutoDetectionTest.xml @@ -53,7 +53,7 @@ </actionGroup> <!-- Assert Customer logged on on default store view --> - <actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerGird"> + <actionGroup ref="AssertStorefrontLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerGird"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> <argument name="customerEmail" value="$$createCustomer.email$$"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerLoggingTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerLoggingTest.xml index bf2556b30967b..7156c407ec6fa 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerLoggingTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerLoggingTest.xml @@ -84,22 +84,22 @@ <actionGroup ref="AdminOpenLoginAsCustomerLogActionGroup" stepKey="gotoLoginAsCustomerLog"/> <!-- Perform assertions --> - <actionGroup ref="AdminAssertLoginAsCustomerLogRecordActionGroup" stepKey="verifyDefaultAdminFirstCustomerLogRecord"> + <actionGroup ref="AssertAdminLoginAsCustomerLogRecordActionGroup" stepKey="verifyDefaultAdminFirstCustomerLogRecord"> <argument name="rowNumber" value="4"/> <argument name="adminId" value="1"/> <argument name="customerId" value="$$createFirstCustomer.id$$"/> </actionGroup> - <actionGroup ref="AdminAssertLoginAsCustomerLogRecordActionGroup" stepKey="verifyDefaultAdminSecondCustomerLogRecord"> + <actionGroup ref="AssertAdminLoginAsCustomerLogRecordActionGroup" stepKey="verifyDefaultAdminSecondCustomerLogRecord"> <argument name="rowNumber" value="3"/> <argument name="adminId" value="1"/> <argument name="customerId" value="$$createSecondCustomer.id$$"/> </actionGroup> - <actionGroup ref="AdminAssertLoginAsCustomerLogRecordActionGroup" stepKey="verifyNewAdminFirstCustomerLogRecord"> + <actionGroup ref="AssertAdminLoginAsCustomerLogRecordActionGroup" stepKey="verifyNewAdminFirstCustomerLogRecord"> <argument name="rowNumber" value="2"/> <argument name="adminId" value="$$createNewAdmin.id$$"/> <argument name="customerId" value="$$createFirstCustomer.id$$"/> </actionGroup> - <actionGroup ref="AdminAssertLoginAsCustomerLogRecordActionGroup" stepKey="verifyNewAdminSecondCustomerLogRecord"> + <actionGroup ref="AssertAdminLoginAsCustomerLogRecordActionGroup" stepKey="verifyNewAdminSecondCustomerLogRecord"> <argument name="rowNumber" value="1"/> <argument name="adminId" value="$$createNewAdmin.id$$"/> <argument name="customerId" value="$$createSecondCustomer.id$$"/> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerManualChooseTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerManualChooseTest.xml index acae07d1cda11..5e6c48a10a894 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerManualChooseTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerManualChooseTest.xml @@ -53,11 +53,11 @@ </actionGroup> <!-- Assert Customer logged on on custom store view --> - <actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerGird"> + <actionGroup ref="AssertStorefrontLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerGird"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> <argument name="customerEmail" value="$$createCustomer.email$$"/> </actionGroup> - <actionGroup ref="StorefrontAssertCustomerOnStoreViewActionGroup" stepKey="assertCustomStoreView"> + <actionGroup ref="AssertStorefrontCustomerOnStoreViewActionGroup" stepKey="assertCustomStoreView"> <argument name="storeViewName" value="{{customStore.name}}"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerMultishippingLoggingTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerMultishippingLoggingTest.xml index 8e5c121fed157..9031644e438bd 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerMultishippingLoggingTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerMultishippingLoggingTest.xml @@ -82,19 +82,19 @@ <waitForPageLoad stepKey="waitForOrderPageLoad"/> <!-- Assert Storefront Order page contains message about Order created by a Store Administrator --> - <actionGroup ref="StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageFirstOrder"> + <actionGroup ref="AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageFirstOrder"> <argument name="orderId" value="{$getFirstOrderIdPlaceOrder}"/> </actionGroup> - <actionGroup ref="StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageSecondOrder"> + <actionGroup ref="AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageSecondOrder"> <argument name="orderId" value="{$getSecondOrderIdPlaceOrder}"/> </actionGroup> <!-- Assert Admin Order page contains message about Order created by a Store Administrator --> - <actionGroup ref="AdminAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageFirstOrder"> + <actionGroup ref="AssertAdminContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageFirstOrder"> <argument name="orderId" value="{$getFirstOrderIdPlaceOrder}"/> <argument name="adminUserFullName" value="Magento User"/> </actionGroup> - <actionGroup ref="AdminAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageSecondOrder"> + <actionGroup ref="AssertAdminContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageSecondOrder"> <argument name="orderId" value="{$getSecondOrderIdPlaceOrder}"/> <argument name="adminUserFullName" value="Magento User"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerPlaceOrderTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerPlaceOrderTest.xml index a4994d5c041d2..f14dfe56610dc 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerPlaceOrderTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerPlaceOrderTest.xml @@ -81,12 +81,12 @@ <grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="grabOrderId"/> <!-- Assert Storefront Order page contains message about Order created by a Store Administrator --> - <actionGroup ref="StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageOrderCreatedByAdmin"> + <actionGroup ref="AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageOrderCreatedByAdmin"> <argument name="orderId" value="{$grabOrderId}"/> </actionGroup> <!-- Assert Admin Order page contains message about Order created by a Store Administrator --> - <actionGroup ref="AdminAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageOrderCreatedByAdmin"> + <actionGroup ref="AssertAdminContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageOrderCreatedByAdmin"> <argument name="orderId" value="{$grabOrderId}"/> <argument name="adminUserFullName" value="{{activeAdmin.firstname}} {{activeAdmin.lastname}}"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerReorderTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerReorderTest.xml index 16e0b94112562..98a04cd02d40a 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerReorderTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerReorderTest.xml @@ -95,12 +95,12 @@ <grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="grabReorderId"/> <!-- Assert Storefront Order page contains message about Order created by a Store Administrator --> - <actionGroup ref="StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageOrderCreatedByAdmin"> + <actionGroup ref="AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageOrderCreatedByAdmin"> <argument name="orderId" value="${grabReorderId}"/> </actionGroup> <!-- Assert Admin Order page contains message about Order created by a Store Administrator --> - <actionGroup ref="AdminAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageOrderCreatedByAdmin"> + <actionGroup ref="AssertAdminContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageOrderCreatedByAdmin"> <argument name="orderId" value="${grabReorderId}"/> <argument name="adminUserFullName" value="{{activeAdmin.firstname}} {{activeAdmin.lastname}}"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerSettingsAvailableForGlobalLevelTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerSettingsAvailableForGlobalLevelTest.xml index 807603bdcba0a..4869990ff7c42 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerSettingsAvailableForGlobalLevelTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerSettingsAvailableForGlobalLevelTest.xml @@ -25,16 +25,16 @@ </after> <amOnPage url="{{AdminLoginAsCustomerConfigPage.url}}" stepKey="navigateToLoginAsCustomerConfigSection"/> - <actionGroup ref="AdminAssertLoginAsCustomerConfigVisibleActionGroup" stepKey="seeLoginAsCustomerConfig"/> + <actionGroup ref="AssertAdminLoginAsCustomerConfigVisibleActionGroup" stepKey="seeLoginAsCustomerConfig"/> <actionGroup ref="SwitchToTheNewStoreViewActionGroup" stepKey="switchToDefaultStoreView"> <argument name="storeViewName" value="'Default Store View'"/> </actionGroup> - <actionGroup ref="AdminAssertLoginAsCustomerSectionLinkNotAvailableActionGroup" stepKey="dontSeeLoginAsCustomerSectionLinkOnStoreView"/> + <actionGroup ref="AssertAdminLoginAsCustomerSectionLinkNotAvailableActionGroup" stepKey="dontSeeLoginAsCustomerSectionLinkOnStoreView"/> <actionGroup ref="SwitchToTheNewStoreViewActionGroup" stepKey="switchToDefaultWebsite"> <argument name="storeViewName" value="'Main Website'"/> </actionGroup> - <actionGroup ref="AdminAssertLoginAsCustomerSectionLinkNotAvailableActionGroup" stepKey="dontSeeLoginAsCustomerSectionLink"/> + <actionGroup ref="AssertAdminLoginAsCustomerSectionLinkNotAvailableActionGroup" stepKey="dontSeeLoginAsCustomerSectionLink"/> </test> </tests> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserLogoutTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserLogoutTest.xml index 4f484e73d580b..33cee2c230e31 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserLogoutTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserLogoutTest.xml @@ -43,7 +43,7 @@ </actionGroup> <!-- Assert correctly logged in as Customer --> - <actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerPage"> + <actionGroup ref="AssertStorefrontLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerPage"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> <argument name="customerEmail" value="$$createCustomer.email$$"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserSingleSessionTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserSingleSessionTest.xml index e4cd48d8e868e..0172f9febf02d 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserSingleSessionTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserSingleSessionTest.xml @@ -46,7 +46,7 @@ </actionGroup> <!-- Assert correctly logged in as First Customer --> - <actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromFirstCustomerPage"> + <actionGroup ref="AssertStorefrontLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromFirstCustomerPage"> <argument name="customerFullName" value="$$createFirstCustomer.firstname$$ $$createFirstCustomer.lastname$$"/> <argument name="customerEmail" value="$$createFirstCustomer.email$$"/> </actionGroup> @@ -58,7 +58,7 @@ </actionGroup> <!-- Assert correctly logged in as Second Customer --> - <actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromSecondCustomerPage"> + <actionGroup ref="AssertStorefrontLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromSecondCustomerPage"> <argument name="customerFullName" value="$$createSecondCustomer.firstname$$ $$createSecondCustomer.lastname$$"/> <argument name="customerEmail" value="$$createSecondCustomer.email$$"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminNoAccessToLoginAsCustomerConfigurationTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminNoAccessToLoginAsCustomerConfigurationTest.xml index c7f42de741862..4a9a067ebd208 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminNoAccessToLoginAsCustomerConfigurationTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminNoAccessToLoginAsCustomerConfigurationTest.xml @@ -87,10 +87,10 @@ </actionGroup> <!-- Assert no Login as Customer config section visible --> - <actionGroup ref="AdminAssertLoginAsCustomerConfigNotVisibleActionGroup" stepKey="assertConfigNotVisible"/> + <actionGroup ref="AssertAdminLoginAsCustomerConfigNotVisibleActionGroup" stepKey="assertConfigNotVisible"/> <!-- Assert Login as Customer config section is not available by direct url --> - <actionGroup ref="AdminAssertLoginAsCustomerConfigNotAvailableDirectlyActionGroup" + <actionGroup ref="AssertAdminLoginAsCustomerConfigNotAvailableDirectlyActionGroup" stepKey="assertConfigNotAvailableDirectly"/> </test> </tests> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminUIShownIfLoginAsCustomerEnabledTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminUIShownIfLoginAsCustomerEnabledTest.xml index 2bf364b29ba8d..6d5787fe605db 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminUIShownIfLoginAsCustomerEnabledTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminUIShownIfLoginAsCustomerEnabledTest.xml @@ -48,7 +48,7 @@ <argument name="customerId" value="$$createCustomer.id$$"/> </actionGroup> - <actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerPage"> + <actionGroup ref="AssertStorefrontLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerPage"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> <argument name="customerEmail" value="$$createCustomer.email$$"/> </actionGroup> @@ -70,7 +70,7 @@ <argument name="orderId" value="$grabOrderId"/> </actionGroup> - <actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromOrderPage"> + <actionGroup ref="AssertStorefrontLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromOrderPage"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> <argument name="customerEmail" value="$$createCustomer.email$$"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml index 6874fcb4fd220..276a48923f764 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml @@ -48,20 +48,20 @@ <actionGroup ref="AdminLoginAsCustomerLoginFromCustomerPageActionGroup" stepKey="loginAsCustomerFromCustomerPage"> <argument name="customerId" value="$$createCustomer.id$$"/> </actionGroup> - <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> + <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> <!-- Go to Wishlist and assert notification banner --> <amOnPage url="{{StorefrontCustomerWishlistPage.url}}" stepKey="amOnWishListPage"/> <waitForPageLoad stepKey="waitForWishlistPageLoad"/> - <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnWishList"> + <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnWishList"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> <!-- Go to category page and assert notification banner --> <amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="navigateToCategoryPage"/> - <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnCategoryPage"> + <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnCategoryPage"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> @@ -69,7 +69,7 @@ <actionGroup ref="OpenStoreFrontProductPageActionGroup" stepKey="openProductPage"> <argument name="productUrlKey" value="$$createSimpleProduct.custom_attributes[url_key]$$"/> </actionGroup> - <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnProductPage"> + <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnProductPage"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> @@ -79,14 +79,14 @@ <argument name="productCount" value="1"/> </actionGroup> <actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openCartPage"/> - <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnCartPage"> + <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnCartPage"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> <!-- Proceed to checkout and assert notification banner --> <click selector="{{CheckoutCartSummarySection.proceedToCheckout}}" stepKey="clickProceedToCheckout"/> <waitForPageLoad stepKey="waitForProceedToCheckout"/> - <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnCheckoutPage"> + <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnCheckoutPage"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> @@ -95,7 +95,7 @@ <waitForElementVisible selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/> <click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskAfterClickNext"/> - <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerBeforePlaceOrder"> + <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerBeforePlaceOrder"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> @@ -105,7 +105,7 @@ <argument name="orderNumberMessage" value="CONST.successCheckoutOrderNumberMessage"/> <argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage"/> </actionGroup> - <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerAfterPlaceOrder"> + <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerAfterPlaceOrder"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> </test> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerNotificationBannerTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerNotificationBannerTest.xml index d953c493562c6..5a4d5ac7b3e24 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerNotificationBannerTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerNotificationBannerTest.xml @@ -42,7 +42,7 @@ </actionGroup> <!-- Assert Notification Banner is present on page --> - <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> + <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerSeeSpecialPriceOnCategoryTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerSeeSpecialPriceOnCategoryTest.xml index 775fcb122e181..d22cb681afb30 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerSeeSpecialPriceOnCategoryTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerSeeSpecialPriceOnCategoryTest.xml @@ -77,7 +77,7 @@ <actionGroup ref="AdminLoginAsCustomerLoginFromCustomerPageActionGroup" stepKey="loginAsCustomerFromCustomerPage"> <argument name="customerId" value="$$createCustomer.id$$"/> </actionGroup> - <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> + <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerShoppingCartIsNotMergedWithGuestCartTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerShoppingCartIsNotMergedWithGuestCartTest.xml index 09ec1b427f515..96d0cec0eb20e 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerShoppingCartIsNotMergedWithGuestCartTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerShoppingCartIsNotMergedWithGuestCartTest.xml @@ -57,7 +57,7 @@ <actionGroup ref="AdminLoginAsCustomerLoginFromCustomerPageActionGroup" stepKey="loginAsCustomerFromCustomerPage"> <argument name="customerId" value="$$createCustomer.id$$"/> </actionGroup> - <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> + <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml index 3368fa7e5be7a..c040351b2ef76 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml @@ -33,7 +33,7 @@ <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> <magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 0" stepKey="disableLoginAsCustomer"/> - <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushConfigCache"> + <actionGroup ref="CliCacheCleanActionGroup" stepKey="flushConfigCache"> <argument name="tags" value="config"/> </actionGroup> </after> @@ -42,7 +42,7 @@ <argument name="customerId" value="$$createCustomer.id$$"/> </actionGroup> - <actionGroup ref="StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup" stepKey="assertStickyNotificationBanner"> + <actionGroup ref="AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup" stepKey="assertStickyNotificationBanner"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> From 425113c355ca8cb880cfec8c2c362dbfd802795a Mon Sep 17 00:00:00 2001 From: Shankar Konar <konar.shankar2013@gmail.com> Date: Mon, 17 Aug 2020 10:15:29 +0530 Subject: [PATCH 14/99] Revert "Feedback changes" This reverts commit c0ca7cdf42a3f4425827fe61f4b7711ae0996e8b. --- ...insMessageOrderCreatedByAdminActionGroup.xml} | 2 +- ...merConfigNotAvailableDirectlyActionGroup.xml} | 2 +- ...ginAsCustomerConfigNotVisibleActionGroup.xml} | 2 +- ...tLoginAsCustomerConfigVisibleActionGroup.xml} | 2 +- ...ssertLoginAsCustomerLogRecordActionGroup.xml} | 2 +- ...stomerSectionLinkNotAvailableActionGroup.xml} | 2 +- ...insMessageOrderCreatedByAdminActionGroup.xml} | 2 +- ...rontAssertCustomerOnStoreViewActionGroup.xml} | 2 +- ...AssertLoginAsCustomerLoggedInActionGroup.xml} | 2 +- ...nAsCustomerNotificationBannerActionGroup.xml} | 2 +- ...nAsCustomerNotificationBannerActionGroup.xml} | 2 +- .../AdminLoginAsCustomerAutoDetectionTest.xml | 2 +- .../Test/AdminLoginAsCustomerLoggingTest.xml | 8 ++++---- .../AdminLoginAsCustomerManualChooseTest.xml | 4 ++-- ...inLoginAsCustomerMultishippingLoggingTest.xml | 8 ++++---- .../Test/AdminLoginAsCustomerPlaceOrderTest.xml | 4 ++-- .../Test/AdminLoginAsCustomerReorderTest.xml | 4 ++-- ...stomerSettingsAvailableForGlobalLevelTest.xml | 6 +++--- .../Test/AdminLoginAsCustomerUserLogoutTest.xml | 2 +- ...AdminLoginAsCustomerUserSingleSessionTest.xml | 4 ++-- ...oAccessToLoginAsCustomerConfigurationTest.xml | 4 ++-- .../AdminUIShownIfLoginAsCustomerEnabledTest.xml | 4 ++-- ...tomerBannerPresentOnAllPagesInSessionTest.xml | 16 ++++++++-------- ...rontLoginAsCustomerNotificationBannerTest.xml | 2 +- ...inAsCustomerSeeSpecialPriceOnCategoryTest.xml | 2 +- ...rShoppingCartIsNotMergedWithGuestCartTest.xml | 2 +- ...ickyLoginAsCustomerNotificationBannerTest.xml | 4 ++-- 27 files changed, 49 insertions(+), 49 deletions(-) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AssertAdminContainsMessageOrderCreatedByAdminActionGroup.xml => AdminAssertContainsMessageOrderCreatedByAdminActionGroup.xml} (93%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AssertAdminLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml => AdminAssertLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml} (93%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AssertAdminLoginAsCustomerConfigNotVisibleActionGroup.xml => AdminAssertLoginAsCustomerConfigNotVisibleActionGroup.xml} (90%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AssertAdminLoginAsCustomerConfigVisibleActionGroup.xml => AdminAssertLoginAsCustomerConfigVisibleActionGroup.xml} (93%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AssertAdminLoginAsCustomerLogRecordActionGroup.xml => AdminAssertLoginAsCustomerLogRecordActionGroup.xml} (94%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AssertAdminLoginAsCustomerSectionLinkNotAvailableActionGroup.xml => AdminAssertLoginAsCustomerSectionLinkNotAvailableActionGroup.xml} (93%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup.xml => StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup.xml} (93%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AssertStorefrontCustomerOnStoreViewActionGroup.xml => StorefrontAssertCustomerOnStoreViewActionGroup.xml} (92%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AssertStorefrontLoginAsCustomerLoggedInActionGroup.xml => StorefrontAssertLoginAsCustomerLoggedInActionGroup.xml} (94%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AssertStorefrontLoginAsCustomerNotificationBannerActionGroup.xml => StorefrontAssertLoginAsCustomerNotificationBannerActionGroup.xml} (95%) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup.xml => StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml} (96%) diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminContainsMessageOrderCreatedByAdminActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertContainsMessageOrderCreatedByAdminActionGroup.xml similarity index 93% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminContainsMessageOrderCreatedByAdminActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertContainsMessageOrderCreatedByAdminActionGroup.xml index cfab1ffc5bbf4..bcf6fc96aa131 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminContainsMessageOrderCreatedByAdminActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertContainsMessageOrderCreatedByAdminActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertAdminContainsMessageOrderCreatedByAdminActionGroup"> + <actionGroup name="AdminAssertContainsMessageOrderCreatedByAdminActionGroup"> <annotations> <description>Assert Admin Order page contains message about Order created by a Store Administrator. </description> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml similarity index 93% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml index ec2261be6d20f..7e032b168f062 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigNotAvailableDirectlyActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertAdminLoginAsCustomerConfigNotAvailableDirectlyActionGroup"> + <actionGroup name="AdminAssertLoginAsCustomerConfigNotAvailableDirectlyActionGroup"> <annotations> <description>Verify Login as Customer config section is not available by direct url.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigNotVisibleActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigNotVisibleActionGroup.xml similarity index 90% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigNotVisibleActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigNotVisibleActionGroup.xml index 18c1fb32a6f93..875869d9928a4 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigNotVisibleActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigNotVisibleActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertAdminLoginAsCustomerConfigNotVisibleActionGroup"> + <actionGroup name="AdminAssertLoginAsCustomerConfigNotVisibleActionGroup"> <annotations> <description>Verify no Login as Customer config section available.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigVisibleActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigVisibleActionGroup.xml similarity index 93% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigVisibleActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigVisibleActionGroup.xml index 9ddb439b2e5a3..cdc513651ad54 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerConfigVisibleActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerConfigVisibleActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertAdminLoginAsCustomerConfigVisibleActionGroup"> + <actionGroup name="AdminAssertLoginAsCustomerConfigVisibleActionGroup"> <annotations> <description>Verify Login as Customer config section available.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerLogRecordActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerLogRecordActionGroup.xml similarity index 94% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerLogRecordActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerLogRecordActionGroup.xml index 0c35992e025f3..da47864e28eac 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerLogRecordActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerLogRecordActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertAdminLoginAsCustomerLogRecordActionGroup"> + <actionGroup name="AdminAssertLoginAsCustomerLogRecordActionGroup"> <annotations> <description>Assert Login as Customer Log record is correct.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerSectionLinkNotAvailableActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerSectionLinkNotAvailableActionGroup.xml similarity index 93% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerSectionLinkNotAvailableActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerSectionLinkNotAvailableActionGroup.xml index f05be04bc78fe..779cb1e5c8899 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertAdminLoginAsCustomerSectionLinkNotAvailableActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AdminAssertLoginAsCustomerSectionLinkNotAvailableActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertAdminLoginAsCustomerSectionLinkNotAvailableActionGroup"> + <actionGroup name="AdminAssertLoginAsCustomerSectionLinkNotAvailableActionGroup"> <annotations> <description>Verify Login as Customer config section isn't available.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup.xml similarity index 93% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup.xml index da1be5eed010f..f40ea7f93c7a1 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup"> + <actionGroup name="StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup"> <annotations> <description>Verify Storefront Order page contains message about Order created by a Store Administrator. </description> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontCustomerOnStoreViewActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertCustomerOnStoreViewActionGroup.xml similarity index 92% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontCustomerOnStoreViewActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertCustomerOnStoreViewActionGroup.xml index f8c240abeb8fd..f63cda2303526 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontCustomerOnStoreViewActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertCustomerOnStoreViewActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertStorefrontCustomerOnStoreViewActionGroup"> + <actionGroup name="StorefrontAssertCustomerOnStoreViewActionGroup"> <annotations> <description>Assert Customer is on the provided Store View.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontLoginAsCustomerLoggedInActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerLoggedInActionGroup.xml similarity index 94% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontLoginAsCustomerLoggedInActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerLoggedInActionGroup.xml index 7badab1fc8dfd..bb7e938bdfb59 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontLoginAsCustomerLoggedInActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerLoggedInActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertStorefrontLoginAsCustomerLoggedInActionGroup"> + <actionGroup name="StorefrontAssertLoginAsCustomerLoggedInActionGroup"> <annotations> <description>Verify Admin successfully logged in as Customer.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontLoginAsCustomerNotificationBannerActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerNotificationBannerActionGroup.xml similarity index 95% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontLoginAsCustomerNotificationBannerActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerNotificationBannerActionGroup.xml index a2464caa54a38..ce2e261f10040 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontLoginAsCustomerNotificationBannerActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertLoginAsCustomerNotificationBannerActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup"> + <actionGroup name="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup"> <annotations> <description>Verify Login as Customer notification banner present on page.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml similarity index 96% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml index b1b3ccd05ddfc..46f582ca6d44e 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup"> + <actionGroup name="StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup"> <annotations> <description>Verify Sticky Login as Customer notification banner present on page.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerAutoDetectionTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerAutoDetectionTest.xml index bdfadaf378561..42d53113e20f4 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerAutoDetectionTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerAutoDetectionTest.xml @@ -53,7 +53,7 @@ </actionGroup> <!-- Assert Customer logged on on default store view --> - <actionGroup ref="AssertStorefrontLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerGird"> + <actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerGird"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> <argument name="customerEmail" value="$$createCustomer.email$$"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerLoggingTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerLoggingTest.xml index 7156c407ec6fa..bf2556b30967b 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerLoggingTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerLoggingTest.xml @@ -84,22 +84,22 @@ <actionGroup ref="AdminOpenLoginAsCustomerLogActionGroup" stepKey="gotoLoginAsCustomerLog"/> <!-- Perform assertions --> - <actionGroup ref="AssertAdminLoginAsCustomerLogRecordActionGroup" stepKey="verifyDefaultAdminFirstCustomerLogRecord"> + <actionGroup ref="AdminAssertLoginAsCustomerLogRecordActionGroup" stepKey="verifyDefaultAdminFirstCustomerLogRecord"> <argument name="rowNumber" value="4"/> <argument name="adminId" value="1"/> <argument name="customerId" value="$$createFirstCustomer.id$$"/> </actionGroup> - <actionGroup ref="AssertAdminLoginAsCustomerLogRecordActionGroup" stepKey="verifyDefaultAdminSecondCustomerLogRecord"> + <actionGroup ref="AdminAssertLoginAsCustomerLogRecordActionGroup" stepKey="verifyDefaultAdminSecondCustomerLogRecord"> <argument name="rowNumber" value="3"/> <argument name="adminId" value="1"/> <argument name="customerId" value="$$createSecondCustomer.id$$"/> </actionGroup> - <actionGroup ref="AssertAdminLoginAsCustomerLogRecordActionGroup" stepKey="verifyNewAdminFirstCustomerLogRecord"> + <actionGroup ref="AdminAssertLoginAsCustomerLogRecordActionGroup" stepKey="verifyNewAdminFirstCustomerLogRecord"> <argument name="rowNumber" value="2"/> <argument name="adminId" value="$$createNewAdmin.id$$"/> <argument name="customerId" value="$$createFirstCustomer.id$$"/> </actionGroup> - <actionGroup ref="AssertAdminLoginAsCustomerLogRecordActionGroup" stepKey="verifyNewAdminSecondCustomerLogRecord"> + <actionGroup ref="AdminAssertLoginAsCustomerLogRecordActionGroup" stepKey="verifyNewAdminSecondCustomerLogRecord"> <argument name="rowNumber" value="1"/> <argument name="adminId" value="$$createNewAdmin.id$$"/> <argument name="customerId" value="$$createSecondCustomer.id$$"/> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerManualChooseTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerManualChooseTest.xml index 5e6c48a10a894..acae07d1cda11 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerManualChooseTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerManualChooseTest.xml @@ -53,11 +53,11 @@ </actionGroup> <!-- Assert Customer logged on on custom store view --> - <actionGroup ref="AssertStorefrontLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerGird"> + <actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerGird"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> <argument name="customerEmail" value="$$createCustomer.email$$"/> </actionGroup> - <actionGroup ref="AssertStorefrontCustomerOnStoreViewActionGroup" stepKey="assertCustomStoreView"> + <actionGroup ref="StorefrontAssertCustomerOnStoreViewActionGroup" stepKey="assertCustomStoreView"> <argument name="storeViewName" value="{{customStore.name}}"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerMultishippingLoggingTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerMultishippingLoggingTest.xml index 9031644e438bd..8e5c121fed157 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerMultishippingLoggingTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerMultishippingLoggingTest.xml @@ -82,19 +82,19 @@ <waitForPageLoad stepKey="waitForOrderPageLoad"/> <!-- Assert Storefront Order page contains message about Order created by a Store Administrator --> - <actionGroup ref="AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageFirstOrder"> + <actionGroup ref="StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageFirstOrder"> <argument name="orderId" value="{$getFirstOrderIdPlaceOrder}"/> </actionGroup> - <actionGroup ref="AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageSecondOrder"> + <actionGroup ref="StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageSecondOrder"> <argument name="orderId" value="{$getSecondOrderIdPlaceOrder}"/> </actionGroup> <!-- Assert Admin Order page contains message about Order created by a Store Administrator --> - <actionGroup ref="AssertAdminContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageFirstOrder"> + <actionGroup ref="AdminAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageFirstOrder"> <argument name="orderId" value="{$getFirstOrderIdPlaceOrder}"/> <argument name="adminUserFullName" value="Magento User"/> </actionGroup> - <actionGroup ref="AssertAdminContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageSecondOrder"> + <actionGroup ref="AdminAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageSecondOrder"> <argument name="orderId" value="{$getSecondOrderIdPlaceOrder}"/> <argument name="adminUserFullName" value="Magento User"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerPlaceOrderTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerPlaceOrderTest.xml index f14dfe56610dc..a4994d5c041d2 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerPlaceOrderTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerPlaceOrderTest.xml @@ -81,12 +81,12 @@ <grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="grabOrderId"/> <!-- Assert Storefront Order page contains message about Order created by a Store Administrator --> - <actionGroup ref="AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageOrderCreatedByAdmin"> + <actionGroup ref="StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageOrderCreatedByAdmin"> <argument name="orderId" value="{$grabOrderId}"/> </actionGroup> <!-- Assert Admin Order page contains message about Order created by a Store Administrator --> - <actionGroup ref="AssertAdminContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageOrderCreatedByAdmin"> + <actionGroup ref="AdminAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageOrderCreatedByAdmin"> <argument name="orderId" value="{$grabOrderId}"/> <argument name="adminUserFullName" value="{{activeAdmin.firstname}} {{activeAdmin.lastname}}"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerReorderTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerReorderTest.xml index 98a04cd02d40a..16e0b94112562 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerReorderTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerReorderTest.xml @@ -95,12 +95,12 @@ <grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="grabReorderId"/> <!-- Assert Storefront Order page contains message about Order created by a Store Administrator --> - <actionGroup ref="AssertStorefrontContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageOrderCreatedByAdmin"> + <actionGroup ref="StorefrontAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyStorefrontMessageOrderCreatedByAdmin"> <argument name="orderId" value="${grabReorderId}"/> </actionGroup> <!-- Assert Admin Order page contains message about Order created by a Store Administrator --> - <actionGroup ref="AssertAdminContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageOrderCreatedByAdmin"> + <actionGroup ref="AdminAssertContainsMessageOrderCreatedByAdminActionGroup" stepKey="verifyAdminMessageOrderCreatedByAdmin"> <argument name="orderId" value="${grabReorderId}"/> <argument name="adminUserFullName" value="{{activeAdmin.firstname}} {{activeAdmin.lastname}}"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerSettingsAvailableForGlobalLevelTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerSettingsAvailableForGlobalLevelTest.xml index 4869990ff7c42..807603bdcba0a 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerSettingsAvailableForGlobalLevelTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerSettingsAvailableForGlobalLevelTest.xml @@ -25,16 +25,16 @@ </after> <amOnPage url="{{AdminLoginAsCustomerConfigPage.url}}" stepKey="navigateToLoginAsCustomerConfigSection"/> - <actionGroup ref="AssertAdminLoginAsCustomerConfigVisibleActionGroup" stepKey="seeLoginAsCustomerConfig"/> + <actionGroup ref="AdminAssertLoginAsCustomerConfigVisibleActionGroup" stepKey="seeLoginAsCustomerConfig"/> <actionGroup ref="SwitchToTheNewStoreViewActionGroup" stepKey="switchToDefaultStoreView"> <argument name="storeViewName" value="'Default Store View'"/> </actionGroup> - <actionGroup ref="AssertAdminLoginAsCustomerSectionLinkNotAvailableActionGroup" stepKey="dontSeeLoginAsCustomerSectionLinkOnStoreView"/> + <actionGroup ref="AdminAssertLoginAsCustomerSectionLinkNotAvailableActionGroup" stepKey="dontSeeLoginAsCustomerSectionLinkOnStoreView"/> <actionGroup ref="SwitchToTheNewStoreViewActionGroup" stepKey="switchToDefaultWebsite"> <argument name="storeViewName" value="'Main Website'"/> </actionGroup> - <actionGroup ref="AssertAdminLoginAsCustomerSectionLinkNotAvailableActionGroup" stepKey="dontSeeLoginAsCustomerSectionLink"/> + <actionGroup ref="AdminAssertLoginAsCustomerSectionLinkNotAvailableActionGroup" stepKey="dontSeeLoginAsCustomerSectionLink"/> </test> </tests> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserLogoutTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserLogoutTest.xml index 33cee2c230e31..4f484e73d580b 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserLogoutTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserLogoutTest.xml @@ -43,7 +43,7 @@ </actionGroup> <!-- Assert correctly logged in as Customer --> - <actionGroup ref="AssertStorefrontLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerPage"> + <actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerPage"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> <argument name="customerEmail" value="$$createCustomer.email$$"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserSingleSessionTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserSingleSessionTest.xml index 0172f9febf02d..e4cd48d8e868e 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserSingleSessionTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminLoginAsCustomerUserSingleSessionTest.xml @@ -46,7 +46,7 @@ </actionGroup> <!-- Assert correctly logged in as First Customer --> - <actionGroup ref="AssertStorefrontLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromFirstCustomerPage"> + <actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromFirstCustomerPage"> <argument name="customerFullName" value="$$createFirstCustomer.firstname$$ $$createFirstCustomer.lastname$$"/> <argument name="customerEmail" value="$$createFirstCustomer.email$$"/> </actionGroup> @@ -58,7 +58,7 @@ </actionGroup> <!-- Assert correctly logged in as Second Customer --> - <actionGroup ref="AssertStorefrontLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromSecondCustomerPage"> + <actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromSecondCustomerPage"> <argument name="customerFullName" value="$$createSecondCustomer.firstname$$ $$createSecondCustomer.lastname$$"/> <argument name="customerEmail" value="$$createSecondCustomer.email$$"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminNoAccessToLoginAsCustomerConfigurationTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminNoAccessToLoginAsCustomerConfigurationTest.xml index 4a9a067ebd208..c7f42de741862 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminNoAccessToLoginAsCustomerConfigurationTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminNoAccessToLoginAsCustomerConfigurationTest.xml @@ -87,10 +87,10 @@ </actionGroup> <!-- Assert no Login as Customer config section visible --> - <actionGroup ref="AssertAdminLoginAsCustomerConfigNotVisibleActionGroup" stepKey="assertConfigNotVisible"/> + <actionGroup ref="AdminAssertLoginAsCustomerConfigNotVisibleActionGroup" stepKey="assertConfigNotVisible"/> <!-- Assert Login as Customer config section is not available by direct url --> - <actionGroup ref="AssertAdminLoginAsCustomerConfigNotAvailableDirectlyActionGroup" + <actionGroup ref="AdminAssertLoginAsCustomerConfigNotAvailableDirectlyActionGroup" stepKey="assertConfigNotAvailableDirectly"/> </test> </tests> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminUIShownIfLoginAsCustomerEnabledTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminUIShownIfLoginAsCustomerEnabledTest.xml index 6d5787fe605db..2bf364b29ba8d 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminUIShownIfLoginAsCustomerEnabledTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/AdminUIShownIfLoginAsCustomerEnabledTest.xml @@ -48,7 +48,7 @@ <argument name="customerId" value="$$createCustomer.id$$"/> </actionGroup> - <actionGroup ref="AssertStorefrontLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerPage"> + <actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromCustomerPage"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> <argument name="customerEmail" value="$$createCustomer.email$$"/> </actionGroup> @@ -70,7 +70,7 @@ <argument name="orderId" value="$grabOrderId"/> </actionGroup> - <actionGroup ref="AssertStorefrontLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromOrderPage"> + <actionGroup ref="StorefrontAssertLoginAsCustomerLoggedInActionGroup" stepKey="assertLoggedInFromOrderPage"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> <argument name="customerEmail" value="$$createCustomer.email$$"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml index 276a48923f764..6874fcb4fd220 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerBannerPresentOnAllPagesInSessionTest.xml @@ -48,20 +48,20 @@ <actionGroup ref="AdminLoginAsCustomerLoginFromCustomerPageActionGroup" stepKey="loginAsCustomerFromCustomerPage"> <argument name="customerId" value="$$createCustomer.id$$"/> </actionGroup> - <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> + <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> <!-- Go to Wishlist and assert notification banner --> <amOnPage url="{{StorefrontCustomerWishlistPage.url}}" stepKey="amOnWishListPage"/> <waitForPageLoad stepKey="waitForWishlistPageLoad"/> - <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnWishList"> + <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnWishList"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> <!-- Go to category page and assert notification banner --> <amOnPage url="{{StorefrontCategoryPage.url($$createCategory.name$$)}}" stepKey="navigateToCategoryPage"/> - <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnCategoryPage"> + <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnCategoryPage"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> @@ -69,7 +69,7 @@ <actionGroup ref="OpenStoreFrontProductPageActionGroup" stepKey="openProductPage"> <argument name="productUrlKey" value="$$createSimpleProduct.custom_attributes[url_key]$$"/> </actionGroup> - <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnProductPage"> + <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnProductPage"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> @@ -79,14 +79,14 @@ <argument name="productCount" value="1"/> </actionGroup> <actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openCartPage"/> - <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnCartPage"> + <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnCartPage"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> <!-- Proceed to checkout and assert notification banner --> <click selector="{{CheckoutCartSummarySection.proceedToCheckout}}" stepKey="clickProceedToCheckout"/> <waitForPageLoad stepKey="waitForProceedToCheckout"/> - <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnCheckoutPage"> + <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerOnCheckoutPage"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> @@ -95,7 +95,7 @@ <waitForElementVisible selector="{{CheckoutShippingSection.next}}" time="30" stepKey="waitForNextButton"/> <click selector="{{CheckoutShippingSection.next}}" stepKey="clickNext"/> <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskAfterClickNext"/> - <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerBeforePlaceOrder"> + <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerBeforePlaceOrder"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> @@ -105,7 +105,7 @@ <argument name="orderNumberMessage" value="CONST.successCheckoutOrderNumberMessage"/> <argument name="emailYouMessage" value="CONST.successCheckoutEmailYouMessage"/> </actionGroup> - <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerAfterPlaceOrder"> + <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBannerAfterPlaceOrder"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> </test> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerNotificationBannerTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerNotificationBannerTest.xml index 5a4d5ac7b3e24..d953c493562c6 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerNotificationBannerTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerNotificationBannerTest.xml @@ -42,7 +42,7 @@ </actionGroup> <!-- Assert Notification Banner is present on page --> - <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> + <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerSeeSpecialPriceOnCategoryTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerSeeSpecialPriceOnCategoryTest.xml index d22cb681afb30..775fcb122e181 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerSeeSpecialPriceOnCategoryTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerSeeSpecialPriceOnCategoryTest.xml @@ -77,7 +77,7 @@ <actionGroup ref="AdminLoginAsCustomerLoginFromCustomerPageActionGroup" stepKey="loginAsCustomerFromCustomerPage"> <argument name="customerId" value="$$createCustomer.id$$"/> </actionGroup> - <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> + <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerShoppingCartIsNotMergedWithGuestCartTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerShoppingCartIsNotMergedWithGuestCartTest.xml index 96d0cec0eb20e..09ec1b427f515 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerShoppingCartIsNotMergedWithGuestCartTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontLoginAsCustomerShoppingCartIsNotMergedWithGuestCartTest.xml @@ -57,7 +57,7 @@ <actionGroup ref="AdminLoginAsCustomerLoginFromCustomerPageActionGroup" stepKey="loginAsCustomerFromCustomerPage"> <argument name="customerId" value="$$createCustomer.id$$"/> </actionGroup> - <actionGroup ref="AssertStorefrontLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> + <actionGroup ref="StorefrontAssertLoginAsCustomerNotificationBannerActionGroup" stepKey="assertNotificationBanner"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml index c040351b2ef76..3368fa7e5be7a 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml @@ -33,7 +33,7 @@ <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> <magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 0" stepKey="disableLoginAsCustomer"/> - <actionGroup ref="CliCacheCleanActionGroup" stepKey="flushConfigCache"> + <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushConfigCache"> <argument name="tags" value="config"/> </actionGroup> </after> @@ -42,7 +42,7 @@ <argument name="customerId" value="$$createCustomer.id$$"/> </actionGroup> - <actionGroup ref="AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup" stepKey="assertStickyNotificationBanner"> + <actionGroup ref="StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup" stepKey="assertStickyNotificationBanner"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> From 58b78f6d00d344563632822e9d90292cf7da31b1 Mon Sep 17 00:00:00 2001 From: Shankar Konar <konar.shankar2013@gmail.com> Date: Mon, 17 Aug 2020 10:17:45 +0530 Subject: [PATCH 15/99] Feedback changes --- ...frontStickyLoginAsCustomerNotificationBannerActionGroup.xml} | 2 +- .../StorefrontStickyLoginAsCustomerNotificationBannerTest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/{StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml => AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup.xml} (96%) diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup.xml similarity index 96% rename from app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml rename to app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup.xml index 46f582ca6d44e..b1b3ccd05ddfc 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/ActionGroup/AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup.xml @@ -8,7 +8,7 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup"> + <actionGroup name="AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup"> <annotations> <description>Verify Sticky Login as Customer notification banner present on page.</description> </annotations> diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml index 3368fa7e5be7a..831f8c73a668f 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml @@ -42,7 +42,7 @@ <argument name="customerId" value="$$createCustomer.id$$"/> </actionGroup> - <actionGroup ref="StorefrontAssertStickyLoginAsCustomerNotificationBannerActionGroup" stepKey="assertStickyNotificationBanner"> + <actionGroup ref="AssertStorefrontStickyLoginAsCustomerNotificationBannerActionGroup" stepKey="assertStickyNotificationBanner"> <argument name="customerFullName" value="$$createCustomer.firstname$$ $$createCustomer.lastname$$"/> </actionGroup> From debeec23125bb76b9a65b4fb0613efddfecfc9cd Mon Sep 17 00:00:00 2001 From: Shankar Konar <konar.shankar2013@gmail.com> Date: Mon, 17 Aug 2020 19:22:15 +0530 Subject: [PATCH 16/99] Fixed MFTF test --- .../StorefrontStickyLoginAsCustomerNotificationBannerTest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml index 831f8c73a668f..8d30212e183d7 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml @@ -17,6 +17,7 @@ <description value="Verify that Sticky Notification Banner is present on page if 'Login as customer' functionality used"/> <testCaseId value=""/> + <group value="login_as_customer"/> <severity value="CRITICAL"/> </annotations> <before> From 32adddb365c1170b5daea7c24f8e9966e84496e9 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Wed, 19 Aug 2020 20:18:46 +0200 Subject: [PATCH 17/99] Set of improvements for LoginAsCustomer modules --- .../Magento/LoginAsCustomer/Model/Config.php | 18 ++++------- .../Model/Config/Source/StoreViewLogin.php | 7 ----- .../Plugin/Button/ToolbarPlugin.php | 30 +++++++++---------- .../Block/Adminhtml/NotAllowedPopup.php | 4 --- .../Model/Config.php | 3 -- .../Plugin/CustomerDataValidatePlugin.php | 15 +++------- .../Plugin/CustomerExtractorPlugin.php | 13 ++------ .../Plugin/InvalidateExpiredSessionPlugin.php | 20 +++++++------ .../Config/DisablePageCacheIfNeededPlugin.php | 2 +- .../AdminAddCommentOnOrderPlacementPlugin.php | 5 ++-- 10 files changed, 41 insertions(+), 76 deletions(-) diff --git a/app/code/Magento/LoginAsCustomer/Model/Config.php b/app/code/Magento/LoginAsCustomer/Model/Config.php index 2cfafa6ac09a3..bec9527c65f95 100644 --- a/app/code/Magento/LoginAsCustomer/Model/Config.php +++ b/app/code/Magento/LoginAsCustomer/Model/Config.php @@ -10,16 +10,9 @@ use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\LoginAsCustomerApi\Api\ConfigInterface; -/** - * @inheritdoc - */ class Config implements ConfigInterface { - /** - * Extension config path - */ - private const XML_PATH_ENABLED - = 'login_as_customer/general/enabled'; + private const XML_PATH_ENABLED = 'login_as_customer/general/enabled'; private const XML_PATH_STORE_VIEW_MANUAL_CHOICE_ENABLED = 'login_as_customer/general/store_view_manual_choice_enabled'; private const XML_PATH_AUTHENTICATION_EXPIRATION_TIME @@ -33,9 +26,8 @@ class Config implements ConfigInterface /** * @param ScopeConfigInterface $scopeConfig */ - public function __construct( - ScopeConfigInterface $scopeConfig - ) { + public function __construct(ScopeConfigInterface $scopeConfig) + { $this->scopeConfig = $scopeConfig; } @@ -44,7 +36,7 @@ public function __construct( */ public function isEnabled(): bool { - return (bool)$this->scopeConfig->getValue(self::XML_PATH_ENABLED); + return $this->scopeConfig->isSetFlag(self::XML_PATH_ENABLED); } /** @@ -52,7 +44,7 @@ public function isEnabled(): bool */ public function isStoreManualChoiceEnabled(): bool { - return (bool)$this->scopeConfig->getValue(self::XML_PATH_STORE_VIEW_MANUAL_CHOICE_ENABLED); + return $this->scopeConfig->isSetFlag(self::XML_PATH_STORE_VIEW_MANUAL_CHOICE_ENABLED); } /** diff --git a/app/code/Magento/LoginAsCustomerAdminUi/Model/Config/Source/StoreViewLogin.php b/app/code/Magento/LoginAsCustomerAdminUi/Model/Config/Source/StoreViewLogin.php index 265c4fedb722d..9d14a4b44d10b 100644 --- a/app/code/Magento/LoginAsCustomerAdminUi/Model/Config/Source/StoreViewLogin.php +++ b/app/code/Magento/LoginAsCustomerAdminUi/Model/Config/Source/StoreViewLogin.php @@ -12,14 +12,7 @@ */ class StoreViewLogin implements \Magento\Framework\Data\OptionSourceInterface { - /** - * @const int - */ private const AUTODETECT = 0; - - /** - * @const int - */ private const MANUAL = 1; /** diff --git a/app/code/Magento/LoginAsCustomerAdminUi/Plugin/Button/ToolbarPlugin.php b/app/code/Magento/LoginAsCustomerAdminUi/Plugin/Button/ToolbarPlugin.php index c67b0d9dd5273..2cdcd5723df4b 100644 --- a/app/code/Magento/LoginAsCustomerAdminUi/Plugin/Button/ToolbarPlugin.php +++ b/app/code/Magento/LoginAsCustomerAdminUi/Plugin/Button/ToolbarPlugin.php @@ -8,6 +8,7 @@ namespace Magento\LoginAsCustomerAdminUi\Plugin\Button; use Magento\Backend\Block\Widget\Button\ButtonList; +use Magento\Backend\Block\Widget\Button\ToolbarInterface; use Magento\Framework\AuthorizationInterface; use Magento\Framework\Escaper; use Magento\Framework\View\Element\AbstractBlock; @@ -61,13 +62,13 @@ public function __construct( /** * Add Login as Customer button. * - * @param \Magento\Backend\Block\Widget\Button\ToolbarInterface $subject - * @param \Magento\Framework\View\Element\AbstractBlock $context - * @param \Magento\Backend\Block\Widget\Button\ButtonList $buttonList + * @param ToolbarInterface $subject + * @param AbstractBlock $context + * @param ButtonList $buttonList * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforePushButtons( - \Magento\Backend\Block\Widget\Button\ToolbarInterface $subject, + ToolbarInterface $subject, AbstractBlock $context, ButtonList $buttonList ): void { @@ -97,18 +98,17 @@ public function beforePushButtons( */ private function getOrder(string $nameInLayout, AbstractBlock $context) { - $order = null; - - if ('sales_order_edit' == $nameInLayout) { - $order = $context->getOrder(); - } elseif ('sales_invoice_view' == $nameInLayout) { - $order = $context->getInvoice()->getOrder(); - } elseif ('sales_shipment_view' == $nameInLayout) { - $order = $context->getShipment()->getOrder(); - } elseif ('sales_creditmemo_view' == $nameInLayout) { - $order = $context->getCreditmemo()->getOrder(); + switch ($nameInLayout) { + case 'sales_order_edit': + return $context->getOrder(); + case 'sales_invoice_view': + return $context->getInvoice()->getOrder(); + case 'sales_shipment_view': + return $context->getShipment()->getOrder(); + case 'sales_creditmemo_view': + return $context->getCreditmemo()->getOrder(); } - return $order; + return null; } } diff --git a/app/code/Magento/LoginAsCustomerAssistance/Block/Adminhtml/NotAllowedPopup.php b/app/code/Magento/LoginAsCustomerAssistance/Block/Adminhtml/NotAllowedPopup.php index 547be1de5a008..b98ea203057b1 100644 --- a/app/code/Magento/LoginAsCustomerAssistance/Block/Adminhtml/NotAllowedPopup.php +++ b/app/code/Magento/LoginAsCustomerAssistance/Block/Adminhtml/NotAllowedPopup.php @@ -19,15 +19,11 @@ class NotAllowedPopup extends Template { /** - * Config - * * @var ConfigInterface */ private $config; /** - * Json Serializer - * * @var Json */ private $json; diff --git a/app/code/Magento/LoginAsCustomerAssistance/Model/Config.php b/app/code/Magento/LoginAsCustomerAssistance/Model/Config.php index 2fce39cd4e85e..c2244fa3a799c 100644 --- a/app/code/Magento/LoginAsCustomerAssistance/Model/Config.php +++ b/app/code/Magento/LoginAsCustomerAssistance/Model/Config.php @@ -16,9 +16,6 @@ */ class Config implements ConfigInterface { - /** - * Extension config path - */ private const XML_PATH_SHOPPING_ASSISTANCE_CHECKBOX_TITLE = 'login_as_customer/general/shopping_assistance_checkbox_title'; private const XML_PATH_SHOPPING_ASSISTANCE_CHECKBOX_TOOLTIP diff --git a/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php b/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php index 9da329b4a3991..7512936db6ad9 100644 --- a/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php +++ b/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php @@ -11,6 +11,7 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\AuthorizationInterface; use Magento\Framework\Message\MessageInterface; +use Magento\Framework\Validator\Exception; use Magento\LoginAsCustomerAssistance\Api\IsAssistanceEnabledInterface; use Magento\LoginAsCustomerAssistance\Model\ResourceModel\GetLoginAsCustomerAssistanceAllowed; @@ -46,16 +47,12 @@ public function __construct( * * @param Form $subject * @param RequestInterface $request - * @param null|string $scope - * @param bool $scopeOnly - * @throws \Magento\Framework\Validator\Exception + * @throws Exception * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeExtractData( Form $subject, - RequestInterface $request, - $scope = null, - $scopeOnly = true + RequestInterface $request ): void { if ($this->isSetAssistanceAllowedParam($request) && !$this->authorization->isAllowed('Magento_LoginAsCustomer::allow_shopping_assistance') @@ -74,11 +71,7 @@ public function beforeExtractData( ], ]; - throw new \Magento\Framework\Validator\Exception( - null, - null, - $errorMessages - ); + throw new Exception(null, null, $errorMessages); } } } diff --git a/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerExtractorPlugin.php b/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerExtractorPlugin.php index 619036da8bb22..156d84bcae9bd 100644 --- a/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerExtractorPlugin.php +++ b/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerExtractorPlugin.php @@ -35,27 +35,20 @@ public function __construct( * Add assistance_allowed extension attribute value to Customer instance. * * @param CustomerExtractor $subject - * @param callable $proceed + * @param CustomerInterface $customer * @param string $formCode * @param RequestInterface $request * @param array $attributeValues * @return CustomerInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function aroundExtract( + public function afterExtract( CustomerExtractor $subject, - callable $proceed, + CustomerInterface $customer, string $formCode, RequestInterface $request, array $attributeValues = [] ) { - /** @var CustomerInterface $customer */ - $customer = $proceed( - $formCode, - $request, - $attributeValues - ); - $assistanceAllowedStatus = $request->getParam('assistance_allowed'); if (!empty($assistanceAllowedStatus)) { $extensionAttributes = $customer->getExtensionAttributes(); diff --git a/app/code/Magento/LoginAsCustomerFrontendUi/Plugin/InvalidateExpiredSessionPlugin.php b/app/code/Magento/LoginAsCustomerFrontendUi/Plugin/InvalidateExpiredSessionPlugin.php index c1e035ac9637c..7c0682440b4dc 100644 --- a/app/code/Magento/LoginAsCustomerFrontendUi/Plugin/InvalidateExpiredSessionPlugin.php +++ b/app/code/Magento/LoginAsCustomerFrontendUi/Plugin/InvalidateExpiredSessionPlugin.php @@ -65,15 +65,17 @@ public function __construct( */ public function beforeExecute(ActionInterface $subject) { - if ($this->config->isEnabled()) { - $adminId = $this->getLoggedAsCustomerAdminId->execute(); - $customerId = (int)$this->session->getCustomerId(); - if ($adminId && $customerId) { - if (!$this->isLoginAsCustomerSessionActive->execute($customerId, $adminId)) { - $this->session->clearStorage(); - $this->session->expireSessionCookie(); - $this->session->regenerateId(); - } + if (!$this->config->isEnabled()) { + return; + } + + $adminId = $this->getLoggedAsCustomerAdminId->execute(); + $customerId = (int)$this->session->getCustomerId(); + if ($adminId && $customerId) { + if (!$this->isLoginAsCustomerSessionActive->execute($customerId, $adminId)) { + $this->session->clearStorage(); + $this->session->expireSessionCookie(); + $this->session->regenerateId(); } } } diff --git a/app/code/Magento/LoginAsCustomerPageCache/Plugin/PageCache/Model/Config/DisablePageCacheIfNeededPlugin.php b/app/code/Magento/LoginAsCustomerPageCache/Plugin/PageCache/Model/Config/DisablePageCacheIfNeededPlugin.php index dabf8c62e1dee..2b98c1f6c119e 100644 --- a/app/code/Magento/LoginAsCustomerPageCache/Plugin/PageCache/Model/Config/DisablePageCacheIfNeededPlugin.php +++ b/app/code/Magento/LoginAsCustomerPageCache/Plugin/PageCache/Model/Config/DisablePageCacheIfNeededPlugin.php @@ -54,7 +54,7 @@ public function __construct( public function afterIsEnabled(Config $subject, $isEnabled): bool { if ($isEnabled) { - $disable = $this->scopeConfig->getValue( + $disable = $this->scopeConfig->isSetFlag( 'login_as_customer/general/disable_page_cache', ScopeInterface::SCOPE_STORE ); diff --git a/app/code/Magento/LoginAsCustomerSales/Plugin/AdminAddCommentOnOrderPlacementPlugin.php b/app/code/Magento/LoginAsCustomerSales/Plugin/AdminAddCommentOnOrderPlacementPlugin.php index 2ae982e536f49..3a27a5ef9e561 100644 --- a/app/code/Magento/LoginAsCustomerSales/Plugin/AdminAddCommentOnOrderPlacementPlugin.php +++ b/app/code/Magento/LoginAsCustomerSales/Plugin/AdminAddCommentOnOrderPlacementPlugin.php @@ -25,9 +25,8 @@ class AdminAddCommentOnOrderPlacementPlugin /** * @param Session $session */ - public function __construct( - Session $session - ) { + public function __construct(Session $session) + { $this->userSession = $session; } From 7c6b7f7451f696cb7ce819abd60e6b85c8f3149c Mon Sep 17 00:00:00 2001 From: Lena Orobei <oorobei@adobe.com> Date: Wed, 19 Aug 2020 16:40:55 -0500 Subject: [PATCH 18/99] Update StorefrontCustomerCheckoutWithCustomerGroupTest.xml --- .../StorefrontCustomerCheckoutWithCustomerGroupTest.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest/StorefrontCustomerCheckoutWithCustomerGroupTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest/StorefrontCustomerCheckoutWithCustomerGroupTest.xml index 53d50b8ea8bf9..39869190aa40e 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest/StorefrontCustomerCheckoutWithCustomerGroupTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest/StorefrontCustomerCheckoutWithCustomerGroupTest.xml @@ -10,9 +10,9 @@ <test name="StorefrontCustomerCheckoutWithCustomerGroupTest"> <annotations> <features value="Customer Checkout"/> - <stories value="Checkout via Customer Checkout with Customer Group"/> - <title value="Create order by Customer with Customer Group"/> - <description value="Should be assign Customer Group to Order, when enabled setting fir Customer - Auto Group Assign"/> + <stories value="Customer checkout with Customer Group assigned"/> + <title value="Place order by Customer with Customer Group assigned"/> + <description value="Customer Group should be assigned to Order when setting Auto Group Assign is enabled for Customer"/> <severity value="MAJOR"/> <group value="checkout"/> <group value="customer"/> From 2aca78a139b29368f34f4c8d64c51763178856c8 Mon Sep 17 00:00:00 2001 From: Shankar Konar <konar.shankar2013@gmail.com> Date: Thu, 20 Aug 2020 10:37:52 +0530 Subject: [PATCH 19/99] Added reverted review changes --- .../StorefrontStickyLoginAsCustomerNotificationBannerTest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml index 8d30212e183d7..f9dc3863769df 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml @@ -23,7 +23,7 @@ <before> <magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 1" stepKey="enableLoginAsCustomer"/> - <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushConfigCache"> + <actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanConfigCache"> <argument name="tags" value="config"/> </actionGroup> <createData entity="Simple_US_Customer" stepKey="createCustomer"/> @@ -34,7 +34,7 @@ <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> <magentoCLI command="config:set {{LoginAsCustomerConfigDataEnabled.path}} 0" stepKey="disableLoginAsCustomer"/> - <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushConfigCache"> + <actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanConfigCache"> <argument name="tags" value="config"/> </actionGroup> </after> From eca27c78db1621eac2ec16553f66d4519a00d56b Mon Sep 17 00:00:00 2001 From: Shankar Konar <konar.shankar2013@gmail.com> Date: Thu, 20 Aug 2020 13:37:09 +0530 Subject: [PATCH 20/99] Fixed MFTF test --- .../StorefrontStickyLoginAsCustomerNotificationBannerTest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml index f9dc3863769df..611bc1044fd00 100644 --- a/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml +++ b/app/code/Magento/LoginAsCustomer/Test/Mftf/Test/StorefrontStickyLoginAsCustomerNotificationBannerTest.xml @@ -26,7 +26,7 @@ <actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanConfigCache"> <argument name="tags" value="config"/> </actionGroup> - <createData entity="Simple_US_Customer" stepKey="createCustomer"/> + <createData entity="Simple_US_Customer_Assistance_Allowed" stepKey="createCustomer"/> <actionGroup ref="AdminLoginActionGroup" stepKey="login"/> </before> From b4d78e7435a65e299fd8230030701c3fc082b146 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Thu, 20 Aug 2020 10:31:08 +0200 Subject: [PATCH 21/99] Fix Static tests failure --- .../Plugin/CustomerDataValidatePlugin.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php b/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php index 7512936db6ad9..ed2f599c16c63 100644 --- a/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php +++ b/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php @@ -47,12 +47,16 @@ public function __construct( * * @param Form $subject * @param RequestInterface $request + * @param null|string $scope + * @param bool $scopeOnly * @throws Exception * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeExtractData( Form $subject, - RequestInterface $request + RequestInterface $request, + $scope = null, + $scopeOnly = true ): void { if ($this->isSetAssistanceAllowedParam($request) && !$this->authorization->isAllowed('Magento_LoginAsCustomer::allow_shopping_assistance') From b68e049804bb77e51695aeae2307b7dbf16eb553 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Thu, 20 Aug 2020 12:43:49 +0200 Subject: [PATCH 22/99] Fix Static tests failure --- .../Plugin/CustomerDataValidatePlugin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php b/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php index ed2f599c16c63..c11326c95bf0e 100644 --- a/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php +++ b/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php @@ -75,6 +75,7 @@ public function beforeExtractData( ], ]; + // phpcs:ignore Magento2.Exceptions.DirectThrow throw new Exception(null, null, $errorMessages); } } From 2ba01638f1ad0a347f8d2f359c868fc7eb661e9f Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Thu, 20 Aug 2020 12:45:07 +0200 Subject: [PATCH 23/99] Better way to fix the false positive --- .../Plugin/CustomerDataValidatePlugin.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php b/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php index c11326c95bf0e..4bbf691e2b58e 100644 --- a/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php +++ b/app/code/Magento/LoginAsCustomerAssistance/Plugin/CustomerDataValidatePlugin.php @@ -11,7 +11,7 @@ use Magento\Framework\App\RequestInterface; use Magento\Framework\AuthorizationInterface; use Magento\Framework\Message\MessageInterface; -use Magento\Framework\Validator\Exception; +use Magento\Framework\Validator\Exception as ValidatorException; use Magento\LoginAsCustomerAssistance\Api\IsAssistanceEnabledInterface; use Magento\LoginAsCustomerAssistance\Model\ResourceModel\GetLoginAsCustomerAssistanceAllowed; @@ -49,7 +49,7 @@ public function __construct( * @param RequestInterface $request * @param null|string $scope * @param bool $scopeOnly - * @throws Exception + * @throws ValidatorException * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function beforeExtractData( @@ -75,8 +75,7 @@ public function beforeExtractData( ], ]; - // phpcs:ignore Magento2.Exceptions.DirectThrow - throw new Exception(null, null, $errorMessages); + throw new ValidatorException(null, null, $errorMessages); } } } From d04e4d505aced753aedadf1f3593ef5420825857 Mon Sep 17 00:00:00 2001 From: Buba Suma <soumah@adobe.com> Date: Wed, 19 Aug 2020 10:12:08 -0500 Subject: [PATCH 24/99] MC-36809: Secure flag is not set for frontend cookies on https - Fix secure cookie JS config is missing on frontend --- .../Test/StorefrontVerifySecureCookieTest.xml | 51 +++++++++++++++++++ .../StorefrontVerifyUnsecureCookieTest.xml | 40 +++++++++++++++ .../view/base/templates/html/cookie.phtml | 10 ++-- 3 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 app/code/Magento/Cookie/Test/Mftf/Test/StorefrontVerifySecureCookieTest.xml create mode 100644 app/code/Magento/Cookie/Test/Mftf/Test/StorefrontVerifyUnsecureCookieTest.xml diff --git a/app/code/Magento/Cookie/Test/Mftf/Test/StorefrontVerifySecureCookieTest.xml b/app/code/Magento/Cookie/Test/Mftf/Test/StorefrontVerifySecureCookieTest.xml new file mode 100644 index 0000000000000..56098cfec90cb --- /dev/null +++ b/app/code/Magento/Cookie/Test/Mftf/Test/StorefrontVerifySecureCookieTest.xml @@ -0,0 +1,51 @@ +<?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="StorefrontVerifySecureCookieTest"> + <annotations> + <features value="Cookie"/> + <stories value="Storefront Secure Cookie"/> + <title value="Verify Storefront Cookie Secure Config over https"/> + <description value="Verify that cookie are secure on storefront over https"/> + <severity value="MAJOR"/> + <testCaseId value="MC-36900"/> + <useCaseId value="MC-36809"/> + <group value="cookie"/> + <group value="configuration"/> + <group value="secure_storefront_url"/> + </annotations> + <before> + <amOnPage url="/" stepKey="goToHomePage"/> + <executeJS function="return window.location.host" stepKey="hostname"/> + <magentoCLI command="config:set web/unsecure/base_url https://{$hostname}/" stepKey="setUnsecureBaseURL"/> + <magentoCLI command="config:set web/secure/base_url https://{$hostname}/" stepKey="setSecureBaseURL"/> + <magentoCLI command="config:set web/secure/use_in_frontend 1" stepKey="useSecureURLsOnStorefront"/> + <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> + <argument name="tags" value=""/> + </actionGroup> + </before> + <after> + <amOnPage url="/" stepKey="goToHomePage"/> + <executeJS function="return window.location.host" stepKey="hostname"/> + <magentoCLI command="config:set web/unsecure/base_url http://{$hostname}/" stepKey="setUnsecureBaseURL"/> + <magentoCLI command="config:set web/secure/base_url http://{$hostname}/" stepKey="setSecureBaseURL"/> + <magentoCLI command="config:set web/secure/use_in_frontend 0" stepKey="useSecureURLsOnStorefront"/> + <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> + <argument name="tags" value=""/> + </actionGroup> + </after> + <amOnPage url="/" stepKey="goToHomePage"/> + <executeJS function="return window.cookiesConfig.secure ? 'true' : 'false'" stepKey="isCookieSecure"/> + <assertEquals stepKey="assertCookieIsSecure"> + <actualResult type="variable">isCookieSecure</actualResult> + <expectedResult type="string">true</expectedResult> + </assertEquals> + </test> +</tests> diff --git a/app/code/Magento/Cookie/Test/Mftf/Test/StorefrontVerifyUnsecureCookieTest.xml b/app/code/Magento/Cookie/Test/Mftf/Test/StorefrontVerifyUnsecureCookieTest.xml new file mode 100644 index 0000000000000..e601a6b1920b0 --- /dev/null +++ b/app/code/Magento/Cookie/Test/Mftf/Test/StorefrontVerifyUnsecureCookieTest.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="StorefrontVerifyUnsecureCookieTest"> + <annotations> + <features value="Cookie"/> + <stories value="Storefront Secure Cookie"/> + <title value="Verify Storefront Cookie Secure Config over http"/> + <description value="Verify that cookie are not secure on storefront over http"/> + <severity value="MAJOR"/> + <testCaseId value="MC-36899"/> + <useCaseId value="MC-36809"/> + <group value="cookie"/> + <group value="configuration"/> + </annotations> + <before> + <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> + <argument name="tags" value=""/> + </actionGroup> + </before> + <after> + <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> + <argument name="tags" value=""/> + </actionGroup> + </after> + <amOnPage url="/" stepKey="goToHomePage"/> + <executeJS function="return window.cookiesConfig.secure ? 'true' : 'false'" stepKey="isCookieSecure"/> + <assertEquals stepKey="assertCookieIsUnsecure"> + <actualResult type="variable">isCookieSecure</actualResult> + <expectedResult type="string">false</expectedResult> + </assertEquals> + </test> +</tests> diff --git a/app/code/Magento/Cookie/view/base/templates/html/cookie.phtml b/app/code/Magento/Cookie/view/base/templates/html/cookie.phtml index f9d9c9071d69d..a604290004588 100644 --- a/app/code/Magento/Cookie/view/base/templates/html/cookie.phtml +++ b/app/code/Magento/Cookie/view/base/templates/html/cookie.phtml @@ -10,9 +10,11 @@ * @var $block \Magento\Framework\View\Element\Js\Cookie * @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */ - -$scriptString = ' +$isCookieSecure = $block->getSessionConfig()->getCookieSecure() ? 'true' : 'false'; +$scriptString = " window.cookiesConfig = window.cookiesConfig || {}; - window.cookiesConfig.secure = ' . /* @noEscape */ $block->getSessionConfig()->getCookieSecure() ? 'true' : 'false'; + window.cookiesConfig.secure = $isCookieSecure; +"; +?> -echo /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false); +<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false) ?> From 503c42874911024d704bbd68a24a215ac63ee369 Mon Sep 17 00:00:00 2001 From: Arnob Saha <arnobsh@gmail.com> Date: Thu, 20 Aug 2020 10:40:36 -0500 Subject: [PATCH 25/99] MC-36755: Orders being archived prior to being processed - Checking at UI order has been checked excluding new order before submission --- .../ui_component/sales_order_grid.xml | 2 +- .../adminhtml/web/js/grid/tree-massactions.js | 34 +++++ .../js/grid/tree-massactions.test.js | 117 ++++++++++++++++++ 3 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Sales/view/adminhtml/web/js/grid/tree-massactions.js create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Sales/adminhtml/js/grid/tree-massactions.test.js diff --git a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml index e1f047b372c95..f6b1240402477 100644 --- a/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml +++ b/app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml @@ -58,7 +58,7 @@ </settings> </filterSelect> </filters> - <massaction name="listing_massaction" component="Magento_Ui/js/grid/tree-massactions"> + <massaction name="listing_massaction" component="Magento_Sales/js/grid/tree-massactions"> <action name="cancel"> <settings> <url path="sales/order/massCancel"/> diff --git a/app/code/Magento/Sales/view/adminhtml/web/js/grid/tree-massactions.js b/app/code/Magento/Sales/view/adminhtml/web/js/grid/tree-massactions.js new file mode 100644 index 0000000000000..a2783222afc28 --- /dev/null +++ b/app/code/Magento/Sales/view/adminhtml/web/js/grid/tree-massactions.js @@ -0,0 +1,34 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'underscore', + 'mageUtils', + 'Magento_Ui/js/grid/tree-massactions' +], function (_, utils, Massactions) { + 'use strict'; + + return Massactions.extend({ + /** + * Overwrite Default action callback. + * Sends selections data with ids + * via POST request. + * + * @param {Object} action - Action data. + * @param {Object} data - Selections data. + */ + defaultCallback: function (action, data) { + var itemsType = 'selected', + selections = {}; + + selections[itemsType] = data[itemsType]; + _.extend(selections, data.params || {}); + utils.submit({ + url: action.url, + data: selections + }); + } + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Sales/adminhtml/js/grid/tree-massactions.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Sales/adminhtml/js/grid/tree-massactions.test.js new file mode 100644 index 0000000000000..7e33a7ad3c1fa --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Sales/adminhtml/js/grid/tree-massactions.test.js @@ -0,0 +1,117 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +/*eslint max-nested-callbacks: 0*/ +define([ + 'jquery', + 'squire', + 'underscore', + 'Magento_Sales/js/grid/tree-massactions' +], function ($, Squire, _, TreeMassaction) { + 'use strict'; + + var injector = new Squire(), + mocks = { + 'Magento_Ui/js/grid/massactions': { + defaultCallback: jasmine.createSpy().and.returnValue({}), + applyAction: jasmine.createSpy().and.returnValue({}) + } + }, + obj, + utils; + + describe('Magento_Sales/js/grid/tree-massactions', function () { + var model; + + beforeEach(function (done) { + injector.mock(mocks); + injector.require([ + 'Magento_Ui/js/grid/massactions', + 'mageUtils' + ], function (instance, mageUtils) { + obj = _.extend({}, instance); + utils = mageUtils; + done(); + }); + model = new TreeMassaction({ + actions: [ + { + type: 'availability', + actions: [{ + type: 'enable' + }, { + type: 'disable' + }] + }, + { + type: 'hold_order', + component: 'uiComponent', + label: 'hold', + url: 'http://local.magento/hold_order', + modules: { + selections: ['1','2','3'] + }, + actions: [{ + callback: 'defaultCallback' + }] + }] + }); + }); + + afterEach(function () { + try { + injector.clean(); + injector.remove(); + } catch (e) {} + }); + + describe('check applyAction', function () { + it('change visibility of submenu', function () { + expect(model.actions()[0].visible()).toBeFalsy(); + expect(model.applyAction('availability')).toBe(model); + expect(model.actions()[0].visible()).toBeTruthy(); + }); + }); + describe('check defaultCallback', function () { + it('check model called with action and selected data', function () { + expect(model.applyAction('hold_order')).toBe(model); + expect(model.actions()[1].visible()).toBeTruthy(); + expect(model.actions()[1].modules.selections).toBeTruthy(); + expect(model.actions()[1].modules.selections.total).toBeFalsy(); + }); + + it('check defaultCallback submitted the data', function () { + var action = { + component: 'uiComponent', + label: 'Hold', + type: 'hold_order', + url: 'http://local.magento/hold_order/' + }, + data = { + excludeMode: true, + excluded: [], + params: {}, + selected: ['7', '6', '5', '4', '3', '2', '1'], + total: 7 + }, + result; + + obj.getAction = jasmine.createSpy().and.returnValue('hold_order'); + + obj.applyAction(action); + + result = obj.defaultCallback(action, data); + + expect(typeof result).toBe('object'); + spyOn(utils, 'submit').and.callThrough(); + utils.submit({ + url: action.url, + data: data.selected + }); + expect(utils.submit).toHaveBeenCalled(); + }); + }); + }); +}); From f1e461f80e16745c30970bc48d33864d1e939e80 Mon Sep 17 00:00:00 2001 From: Arnob Saha <arnobsh@gmail.com> Date: Fri, 21 Aug 2020 12:35:08 -0500 Subject: [PATCH 26/99] MC-36721: Unable to export customers with custom gender attribute value - Adding attribute check for gender --- .../Component/DataProvider/DocumentTest.php | 41 ++++++++++++++++--- .../Ui/Component/DataProvider/Document.php | 23 ++++++++--- 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php index e9bd30940a064..08fd76afb76d3 100644 --- a/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php +++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/DataProvider/DocumentTest.php @@ -80,11 +80,16 @@ protected function setUp(): void } /** - * @covers \Magento\Customer\Ui\Component\DataProvider\Document::getCustomAttribute + * @dataProvider getGenderAttributeDataProvider + * @covers \Magento\Customer\Ui\Component\DataProvider\Document::getCustomAttribute + * @param int $genderId + * @param string $attributeValue + * @param string $attributeLabel */ - public function testGetGenderAttribute() + public function testGetGenderAttribute(int $genderId, string $attributeValue, string $attributeLabel): void { - $genderId = 1; + $expectedResult = !empty($attributeValue) ? $attributeLabel : $genderId; + $this->document->setData('gender', $genderId); $this->groupRepository->expects(static::never()) @@ -106,11 +111,37 @@ public function testGetGenderAttribute() ->willReturn([$genderId => $option]); $option->expects(static::once()) + ->method('getValue') + ->willReturn($attributeValue); + + $option->expects(static::any()) ->method('getLabel') - ->willReturn('Male'); + ->willReturn($attributeLabel); $attribute = $this->document->getCustomAttribute('gender'); - static::assertEquals('Male', $attribute->getValue()); + static::assertEquals($expectedResult, $attribute->getValue()); + } + + /** + * Data provider for testGetGenderAttribute + * @return array + */ + public function getGenderAttributeDataProvider() + { + return [ + 'with valid gender label and value' => [ + 1, '1', 'Male' + ], + 'with empty gender label' => [ + 2, '2', '' + ], + 'with empty gender value' => [ + 3, '', 'test' + ], + 'with empty gender label and value' => [ + 4, '', '' + ] + ]; } /** diff --git a/app/code/Magento/Customer/Ui/Component/DataProvider/Document.php b/app/code/Magento/Customer/Ui/Component/DataProvider/Document.php index 468a9e7946f2d..e802505caf9d1 100644 --- a/app/code/Magento/Customer/Ui/Component/DataProvider/Document.php +++ b/app/code/Magento/Customer/Ui/Component/DataProvider/Document.php @@ -5,18 +5,23 @@ */ namespace Magento\Customer\Ui\Component\DataProvider; +use Exception; use Magento\Customer\Api\CustomerMetadataInterface; +use Magento\Customer\Api\Data\OptionInterface; +use Magento\Customer\Api\GroupRepositoryInterface; use Magento\Customer\Model\AccountManagement; use Magento\Framework\Api\AttributeValueFactory; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Customer\Api\GroupRepositoryInterface; use Magento\Framework\App\ObjectManager; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; /** * Class Document + * + * Set the attribute label and value for UI Component + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class Document extends \Magento\Framework\View\Element\UiComponent\DataProvider\Document { @@ -127,7 +132,7 @@ public function getCustomAttribute($attributeCode) private function setGenderValue() { $value = $this->getData(self::$genderAttributeCode); - + if (!$value) { $this->setCustomAttribute(self::$genderAttributeCode, 'N/A'); return; @@ -135,8 +140,15 @@ private function setGenderValue() try { $attributeMetadata = $this->customerMetadata->getAttributeMetadata(self::$genderAttributeCode); - $option = $attributeMetadata->getOptions()[$value]; - $this->setCustomAttribute(self::$genderAttributeCode, $option->getLabel()); + $options = $attributeMetadata->getOptions(); + array_walk( + $options, + function (OptionInterface $option) use ($value) { + if ($option->getValue() == $value) { + $this->setCustomAttribute(self::$genderAttributeCode, $option->getLabel()); + } + } + ); } catch (NoSuchEntityException $e) { $this->setCustomAttribute(self::$genderAttributeCode, 'N/A'); } @@ -199,6 +211,7 @@ private function setConfirmationValue() * Update lock expires value. Method set account lock text value to match what is shown in grid * * @return void + * @throws Exception */ private function setAccountLockValue() { From c67c5f84fed1fa7a33f9ebeb31da58813541526e Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Mon, 24 Aug 2020 21:25:51 +0300 Subject: [PATCH 27/99] Removed redundant action group --- .../AdminOpentCmsBlockActionGroup.xml | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml deleted file mode 100644 index 0f87ee90b7ce0..0000000000000 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminOpenCmsBlockActionGroup"> - <arguments> - <argument name="block_id" type="string"/> - </arguments> - <amOnPage url="{{AdminEditBlockPage.url(block_id)}}" stepKey="openEditCmsBlock"/> - </actionGroup> -</actionGroups> From dd929f86588b8ef39b60b3e0fe1bb592ca587ba7 Mon Sep 17 00:00:00 2001 From: Buba Suma <soumah@adobe.com> Date: Tue, 25 Aug 2020 16:39:17 -0500 Subject: [PATCH 28/99] MC-36903: Records are not deleted when unassigning an item from a website which causes image duplication when executing POST rest/all/V1/products - Remove eav attributes stores values when product is unassigned from website --- .../Model/Product/Gallery/CreateHandler.php | 13 +- .../Model/Product/Gallery/UpdateHandler.php | 94 +++++++++- .../Model/ResourceModel/AttributeValue.php | 173 ++++++++++++++++++ .../Product/Gallery/UpdateHandlerTest.php | 102 ++++++++++- 4 files changed, 375 insertions(+), 7 deletions(-) create mode 100644 app/code/Magento/Eav/Model/ResourceModel/AttributeValue.php diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php b/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php index 225a3a4c44a9b..5fefcf995e0c7 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/CreateHandler.php @@ -596,10 +596,21 @@ private function canRemoveImage(ProductInterface $product, string $imageFile) :b $canRemoveImage = true; $gallery = $this->getImagesForAllStores($product); $storeId = $product->getStoreId(); + $storeIds = []; + $storeIds[] = 0; + $websiteIds = array_map('intval', $product->getWebsiteIds() ?? []); + foreach ($this->storeManager->getStores() as $store) { + if (in_array((int) $store->getWebsiteId(), $websiteIds, true)) { + $storeIds[] = (int) $store->getId(); + } + } if (!empty($gallery)) { foreach ($gallery as $image) { - if ($image['filepath'] === $imageFile && (int) $image['store_id'] !== $storeId) { + if (in_array((int) $image['store_id'], $storeIds) + && $image['filepath'] === $imageFile + && (int) $image['store_id'] !== $storeId + ) { $canRemoveImage = false; } } diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/UpdateHandler.php b/app/code/Magento/Catalog/Model/Product/Gallery/UpdateHandler.php index 049846ef36490..8061422d84288 100644 --- a/app/code/Magento/Catalog/Model/Product/Gallery/UpdateHandler.php +++ b/app/code/Magento/Catalog/Model/Product/Gallery/UpdateHandler.php @@ -5,17 +5,69 @@ */ namespace Magento\Catalog\Model\Product\Gallery; +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Api\ProductAttributeRepositoryInterface; +use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\Product\Media\Config; use Magento\Catalog\Model\ResourceModel\Product\Gallery; -use Magento\Framework\EntityManager\Operation\ExtensionInterface; +use Magento\Eav\Model\ResourceModel\AttributeValue; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\EntityManager\MetadataPool; +use Magento\Framework\Filesystem; +use Magento\Framework\Json\Helper\Data; +use Magento\MediaStorage\Helper\File\Storage\Database; +use Magento\Store\Model\Store; +use Magento\Store\Model\StoreManagerInterface; /** * Update handler for catalog product gallery. * * @api * @since 101.0.0 + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class UpdateHandler extends \Magento\Catalog\Model\Product\Gallery\CreateHandler +class UpdateHandler extends CreateHandler { + /** + * @var AttributeValue + */ + private $attributeValue; + + /** + * @param MetadataPool $metadataPool + * @param ProductAttributeRepositoryInterface $attributeRepository + * @param Gallery $resourceModel + * @param Data $jsonHelper + * @param Config $mediaConfig + * @param Filesystem $filesystem + * @param Database $fileStorageDb + * @param StoreManagerInterface|null $storeManager + * @param AttributeValue|null $attributeValue + */ + public function __construct( + MetadataPool $metadataPool, + ProductAttributeRepositoryInterface $attributeRepository, + Gallery $resourceModel, + Data $jsonHelper, + Config $mediaConfig, + Filesystem $filesystem, + Database $fileStorageDb, + StoreManagerInterface $storeManager = null, + ?AttributeValue $attributeValue = null + ) { + parent::__construct( + $metadataPool, + $attributeRepository, + $resourceModel, + $jsonHelper, + $mediaConfig, + $filesystem, + $fileStorageDb, + $storeManager + ); + $this->attributeValue = $attributeValue ?: ObjectManager::getInstance()->get(AttributeValue::class); + } + /** * @inheritdoc * @@ -26,6 +78,7 @@ protected function processDeletedImages($product, array &$images) $filesToDelete = []; $recordsToDelete = []; $picturesInOtherStores = []; + $imagesToDelete = []; foreach ($this->resourceModel->getProductImages($product, $this->extractStoreIds($product)) as $image) { $picturesInOtherStores[$image['filepath']] = true; @@ -38,6 +91,7 @@ protected function processDeletedImages($product, array &$images) continue; } $recordsToDelete[] = $image['value_id']; + $imagesToDelete[] = $image['file']; $catalogPath = $this->mediaConfig->getBaseMediaPath(); $isFile = $this->mediaDirectory->isFile($catalogPath . $image['file']); // only delete physical files if they are not used by any other products and if this file exist @@ -48,8 +102,8 @@ protected function processDeletedImages($product, array &$images) } } + $this->deleteMediaAttributeValues($product, $imagesToDelete); $this->resourceModel->deleteGallery($recordsToDelete); - $this->removeDeletedImages($filesToDelete); } @@ -94,14 +148,14 @@ protected function processNewImage($product, array &$image) /** * Retrieve store ids from product. * - * @param \Magento\Catalog\Model\Product $product + * @param Product $product * @return array * @since 101.0.0 */ protected function extractStoreIds($product) { $storeIds = $product->getStoreIds(); - $storeIds[] = \Magento\Store\Model\Store::DEFAULT_STORE_ID; + $storeIds[] = Store::DEFAULT_STORE_ID; // Removing current storeId. $storeIds = array_flip($storeIds); @@ -125,5 +179,35 @@ protected function removeDeletedImages(array $files) foreach ($files as $filePath) { $this->mediaDirectory->delete($catalogPath . '/' . $filePath); } + return null; + } + + /** + * Delete media attributes values for given images + * + * @param Product $product + * @param string[] $images + */ + private function deleteMediaAttributeValues(Product $product, array $images): void + { + if ($images) { + $values = $this->attributeValue->getValues( + ProductInterface::class, + $product->getData($this->metadata->getLinkField()), + $this->mediaConfig->getMediaAttributeCodes() + ); + $valuesToDelete = []; + foreach ($values as $value) { + if (in_array($value['value'], $images, true)) { + $valuesToDelete[] = $value; + } + } + if ($valuesToDelete) { + $this->attributeValue->deleteValues( + ProductInterface::class, + $valuesToDelete + ); + } + } } } diff --git a/app/code/Magento/Eav/Model/ResourceModel/AttributeValue.php b/app/code/Magento/Eav/Model/ResourceModel/AttributeValue.php new file mode 100644 index 0000000000000..305ed202ff22b --- /dev/null +++ b/app/code/Magento/Eav/Model/ResourceModel/AttributeValue.php @@ -0,0 +1,173 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Eav\Model\ResourceModel; + +use Magento\Eav\Model\Config; +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Select; +use Magento\Framework\DB\Sql\UnionExpression; +use Magento\Framework\EntityManager\MetadataPool; + +/** + * Entity attribute values resource + */ +class AttributeValue +{ + /** + * @var MetadataPool + */ + private $metadataPool; + /** + * @var ResourceConnection + */ + private $resourceConnection; + /** + * @var Config + */ + private $config; + + /** + * @param ResourceConnection $resourceConnection + * @param MetadataPool $metadataPool + * @param Config $config + */ + public function __construct( + ResourceConnection $resourceConnection, + MetadataPool $metadataPool, + Config $config + ) { + $this->resourceConnection = $resourceConnection; + $this->metadataPool = $metadataPool; + $this->config = $config; + } + + /** + * Get attribute values for given entity type, entity ID, attribute codes and store IDs + * + * @param string $entityType + * @param int $entityId + * @param string[] $attributeCodes + * @param int[] $storeIds + * @return array + */ + public function getValues( + string $entityType, + int $entityId, + array $attributeCodes = [], + array $storeIds = [] + ): array { + $metadata = $this->metadataPool->getMetadata($entityType); + $connection = $metadata->getEntityConnection(); + $selects = []; + $attributeTables = []; + $attributes = []; + $allAttributes = $this->getEntityAttributes($entityType); + $result = []; + if ($attributeCodes) { + foreach ($attributeCodes as $attributeCode) { + $attributes[$attributeCode] = $allAttributes[$attributeCode]; + } + } else { + $attributes = $allAttributes; + } + + foreach ($attributes as $attribute) { + if (!$attribute->isStatic()) { + $attributeTables[$attribute->getBackend()->getTable()][] = $attribute->getAttributeId(); + } + } + + if ($attributeTables) { + foreach ($attributeTables as $attributeTable => $attributeIds) { + $select = $connection->select() + ->from( + ['t' => $attributeTable], + ['*'] + ) + ->where($metadata->getLinkField() . ' = ?', $entityId) + ->where('attribute_id IN (?)', $attributeIds); + if (!empty($storeIds)) { + $select->where( + 'store_id IN (?)', + $storeIds + ); + } + $selects[] = $select; + } + + if (count($selects) > 1) { + $select = $connection->select(); + $select->from(['u' => new UnionExpression($selects, Select::SQL_UNION_ALL, '( %s )')]); + } else { + $select = reset($selects); + } + + $result = $connection->fetchAll($select); + } + + return $result; + } + + /** + * Delete attribute values + * + * @param string $entityType + * @param array[][] $values + * Format: + * array( + * 0 => array( + * value_id => 1, + * attribute_id => 11 + * ), + * 1 => array( + * value_id => 2, + * attribute_id => 22 + * ) + * ) + * @throws \Magento\Framework\Exception\LocalizedException + */ + public function deleteValues(string $entityType, array $values): void + { + $metadata = $this->metadataPool->getMetadata($entityType); + $connection = $metadata->getEntityConnection(); + $attributeTables = []; + $allAttributes = []; + + foreach ($this->getEntityAttributes($entityType) as $attribute) { + $allAttributes[(int) $attribute->getAttributeId()] = $attribute; + } + + foreach ($values as $value) { + $attribute = $allAttributes[(int) $value['attribute_id']] ?? null; + if ($attribute && !$attribute->isStatic()) { + $attributeTables[$attribute->getBackend()->getTable()][] = (int) $value['value_id']; + } + } + + foreach ($attributeTables as $attributeTable => $valueIds) { + $connection->delete( + $attributeTable, + [ + 'value_id IN (?)' => $valueIds + ] + ); + } + } + + /** + * Get attribute of given entity type + * + * @param string $entityType + */ + private function getEntityAttributes(string $entityType) + { + $metadata = $this->metadataPool->getMetadata($entityType); + $eavEntityType = $metadata->getEavEntityType(); + return null === $eavEntityType ? [] : $this->config->getEntityAttributes($eavEntityType); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php index f9d235493297f..2659f14c07c7a 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php @@ -20,6 +20,7 @@ use Magento\Framework\ObjectManagerInterface; use Magento\Store\Api\StoreRepositoryInterface; use Magento\Store\Model\Store; +use Magento\Store\Model\StoreManagerInterface; use Magento\TestFramework\Helper\Bootstrap; /** @@ -79,6 +80,15 @@ class UpdateHandlerTest extends \PHPUnit\Framework\TestCase */ private $mediaAttributeId; + /** + * @var StoreManagerInterface + */ + private $storeManager; + /** + * @var int + */ + private $currentStoreId; + /** * @inheritdoc */ @@ -93,6 +103,8 @@ protected function setUp(): void $this->productResource = $this->objectManager->create(ProductResource::class); $this->mediaAttributeId = (int)$this->productResource->getAttribute('media_gallery')->getAttributeId(); $this->config = $this->objectManager->get(Config::class); + $this->storeManager = $this->objectManager->create(StoreManagerInterface::class); + $this->currentStoreId = $this->storeManager->getStore()->getId(); $this->mediaDirectory = $this->objectManager->get(Filesystem::class) ->getDirectoryWrite(DirectoryList::MEDIA); $this->mediaDirectory->writeFile($this->fileName, 'Test'); @@ -274,7 +286,7 @@ public function testExecuteWithImageToDelete(): void $this->updateHandler->execute($product); $productImages = $this->galleryResource->loadProductGalleryByAttributeId($product, $this->mediaAttributeId); $this->assertCount(0, $productImages); - $this->assertFileNotExists( + $this->assertFileDoesNotExist( $this->mediaDirectory->getAbsolutePath($this->config->getBaseMediaPath() . $image) ); $defaultImages = $this->productResource->getAttributeRawValue( @@ -344,6 +356,7 @@ public function testExecuteWithTwoImagesOnStoreView(): void */ protected function tearDown(): void { + $this->storeManager->setCurrentStore($this->currentStoreId); parent::tearDown(); $this->mediaDirectory->getDriver()->deleteFile($this->mediaDirectory->getAbsolutePath($this->fileName)); $this->galleryResource->getConnection() @@ -377,4 +390,91 @@ private function updateProductGalleryImages(ProductInterface $product, array $im $product->setData('store_id', Store::DEFAULT_STORE_ID); $product->setData('media_gallery', ['images' => ['image' => array_merge($image, $imageData)]]); } + + /** + * @magentoDataFixture Magento/Catalog/_files/product_with_image.php + * @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php + * @magentoDbIsolation disabled + * @return void + */ + public function testDeleteWithMultiWebsites(): void + { + $defaultWebsiteId = (int) $this->storeManager->getWebsite('base')->getId(); + $secondWebsiteId = (int) $this->storeManager->getWebsite('test')->getId(); + $defaultStoreId = (int) $this->storeManager->getStore('default')->getId(); + $secondStoreId = (int) $this->storeManager->getStore('fixture_second_store')->getId(); + $imageRoles = ['image', 'small_image', 'thumbnail']; + $globalScopeId = Store::DEFAULT_STORE_ID; + $this->storeManager->setCurrentStore(Store::DEFAULT_STORE_ID); + $product = $this->getProduct($globalScopeId); + // Assert that product has images + $this->assertNotEmpty($product->getMediaGalleryEntries()); + $image = $product->getImage(); + $path = $this->mediaDirectory->getAbsolutePath($this->config->getBaseMediaPath() . $image); + $this->assertFileExists($path); + // Assign product to default and second website and save changes + $product->setWebsiteIds([$defaultWebsiteId, $secondWebsiteId]); + $this->productRepository->save($product); + // Assert that product image has roles in global scope only + $imageRolesPerStore = $this->getProductStoreImageRoles($product); + $this->assertEquals($image, $imageRolesPerStore[$globalScopeId]['image']); + $this->assertEquals($image, $imageRolesPerStore[$globalScopeId]['small_image']); + $this->assertEquals($image, $imageRolesPerStore[$globalScopeId]['thumbnail']); + $this->assertArrayNotHasKey($defaultStoreId, $imageRolesPerStore); + $this->assertArrayNotHasKey($secondStoreId, $imageRolesPerStore); + // Assign roles to product image on second store and save changes + $this->storeManager->setCurrentStore($secondStoreId); + $product = $this->getProduct($secondStoreId); + $product->addData(array_fill_keys($imageRoles, $image)); + $this->productRepository->save($product); + // Assert that roles are assigned to product image for second store + $imageRolesPerStore = $this->getProductStoreImageRoles($product); + $this->assertEquals($image, $imageRolesPerStore[$globalScopeId]['image']); + $this->assertEquals($image, $imageRolesPerStore[$globalScopeId]['small_image']); + $this->assertEquals($image, $imageRolesPerStore[$globalScopeId]['thumbnail']); + $this->assertArrayNotHasKey($defaultStoreId, $imageRolesPerStore); + $this->assertEquals($image, $imageRolesPerStore[$secondStoreId]['image']); + $this->assertEquals($image, $imageRolesPerStore[$secondStoreId]['small_image']); + $this->assertEquals($image, $imageRolesPerStore[$secondStoreId]['thumbnail']); + // Delete existing images and save changes + $this->storeManager->setCurrentStore($globalScopeId); + $product = $this->getProduct($globalScopeId); + $product->setMediaGalleryEntries([]); + $this->productRepository->save($product); + $product = $this->getProduct($globalScopeId); + // Assert that image was not deleted as it has roles in second store + $this->assertNotEmpty($product->getMediaGalleryEntries()); + $this->assertFileExists($path); + // Unlink second website, delete existing images and save changes + $product->setWebsiteIds([$defaultWebsiteId]); + $product->setMediaGalleryEntries([]); + $this->productRepository->save($product); + $product = $this->getProduct($globalScopeId); + // Assert that image was deleted and product has no images + $this->assertEmpty($product->getMediaGalleryEntries()); + $this->assertFileDoesNotExist($path); + // Load image roles + $imageRolesPerStore = $this->getProductStoreImageRoles($product); + // Assert that image roles are reset on global scope and removed on second store + // as the product is no longer assigned to second website + $this->assertEquals('no_selection', $imageRolesPerStore[$globalScopeId]['image']); + $this->assertEquals('no_selection', $imageRolesPerStore[$globalScopeId]['small_image']); + $this->assertEquals('no_selection', $imageRolesPerStore[$globalScopeId]['thumbnail']); + $this->assertArrayNotHasKey($defaultStoreId, $imageRolesPerStore); + $this->assertArrayNotHasKey($secondStoreId, $imageRolesPerStore); + } + + /** + * @param Product $product + * @return array + */ + private function getProductStoreImageRoles(Product $product): array + { + $imageRolesPerStore = []; + $stores = array_keys($this->storeManager->getStores(true)); + foreach ($this->galleryResource->getProductImages($product, $stores) as $role) { + $imageRolesPerStore[$role['store_id']][$role['attribute_code']] = $role['filepath']; + } + return $imageRolesPerStore; + } } From 30cd67d88ab3c125da2c0e8a1b00a0182d3a4620 Mon Sep 17 00:00:00 2001 From: Yurii Sapiha <yurasapiga93@gmail.com> Date: Fri, 28 Aug 2020 14:19:45 +0300 Subject: [PATCH 29/99] MC-37196: Admin: invoice order for customer --- .../Order/Invoice/Create/ItemsTest.php | 86 ++++++++ .../Sales/Block/Adminhtml/Order/ViewTest.php | 115 ++++++++++ .../Invoice/AbstractInvoiceControllerTest.php | 98 +++++---- .../Order/Invoice/AddCommentTest.php | 40 +--- .../Adminhtml/Order/Invoice/NewActionTest.php | 78 +++++++ .../Adminhtml/Order/Invoice/SaveTest.php | 198 +++++++++++++++--- .../Adminhtml/Order/Invoice/StartTest.php | 66 ++++++ .../Adminhtml/Order/Invoice/UpdateQtyTest.php | 123 +++++++++++ 8 files changed, 707 insertions(+), 97 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Invoice/Create/ItemsTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/ViewTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewActionTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/StartTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Invoice/Create/ItemsTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Invoice/Create/ItemsTest.php new file mode 100644 index 0000000000000..1b5772cec66de --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Invoice/Create/ItemsTest.php @@ -0,0 +1,86 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Block\Adminhtml\Order\Invoice\Create; + +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Registry; +use Magento\Framework\View\LayoutInterface; +use Magento\Sales\Model\OrderFactory; +use Magento\Sales\Model\ResourceModel\Order\Invoice\CollectionFactory; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Checks invoiced items grid appearance + * + * @see \Magento\Sales\Block\Adminhtml\Order\Invoice\Create\Items + * + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ +class ItemsTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Items */ + private $block; + + /** @var OrderFactory */ + private $orderFactory; + + /** @var Registry */ + private $registry; + + /** @var CollectionFactory */ + private $invoiceCollectionFactory; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Items::class); + $this->orderFactory = $this->objectManager->get(OrderFactory::class); + $this->registry = $this->objectManager->get(Registry::class); + $this->invoiceCollectionFactory = $this->objectManager->get(CollectionFactory::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->registry->unregister('current_invoice'); + + parent::tearDown(); + } + + /** + * @magentoDataFixture Magento/Sales/_files/invoice.php + * + * @return void + */ + public function testGetUpdateButtonHtml(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $invoice = $this->invoiceCollectionFactory->create()->setOrderFilter($order)->setPageSize(1)->getFirstItem(); + $this->registry->unregister('current_invoice'); + $this->registry->register('current_invoice', $invoice); + $this->block->toHtml(); + $button = $this->block->getChildBlock('update_button'); + $this->assertEquals((string)__('Update Qty\'s'), (string)$button->getLabel()); + $this->assertStringContainsString( + sprintf('sales/index/updateQty/order_id/%u/', (int)$order->getEntityId()), + $button->getOnClick() + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/ViewTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/ViewTest.php new file mode 100644 index 0000000000000..a78c221cb5f84 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/ViewTest.php @@ -0,0 +1,115 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Block\Adminhtml\Order; + +use Magento\Backend\Model\Search\AuthorizationMock; +use Magento\Framework\Authorization; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Registry; +use Magento\Framework\View\LayoutInterface; +use Magento\Sales\Api\Data\OrderInterface; +use Magento\Sales\Model\OrderFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + +/** + * Checks order create block + * + * @see \Magento\Sales\Block\Adminhtml\Order\View + * + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ +class ViewTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var LayoutInterface */ + private $layout; + + /** @var Registry */ + private $registry; + + /** @var OrderFactory */ + private $orderFactory; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->objectManager->addSharedInstance( + $this->objectManager->get(AuthorizationMock::class), + Authorization::class + ); + $this->registry = $this->objectManager->get(Registry::class); + $this->orderFactory = $this->objectManager->get(OrderFactory::class); + $this->layout = $this->objectManager->get(LayoutInterface::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->registry->unregister('sales_order'); + + parent::tearDown(); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order.php + * + * @return void + */ + public function testInvoiceButton(): void + { + $this->registerOrder('100000001'); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + '//button[@id=\'order_invoice\']', + $this->layout->createBlock(View::class)->getButtonsHtml() + ) + ); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order_with_bundle_and_invoiced.php + * + * @return void + */ + public function testInvoiceButtonIsNotVisible(): void + { + $this->registerOrder('100000001'); + $this->assertEmpty( + Xpath::getElementsCountForXpath( + '//button[@id=\'order_invoice\']', + $this->layout->createBlock(View::class)->getButtonsHtml() + ) + ); + } + + /** + * Register order + * + * @param OrderInterface $order + * @return void + */ + private function registerOrder(string $orderIncrementId): void + { + $order = $this->orderFactory->create()->loadByIncrementId($orderIncrementId); + $this->registry->unregister('sales_order'); + $this->registry->register('sales_order', $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 index 726ba697beb12..3c26a53424d81 100644 --- 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 @@ -7,39 +7,34 @@ 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\Framework\App\Request\Http; use Magento\Sales\Api\Data\InvoiceInterface; use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Model\OrderRepository; +use Magento\Sales\Model\ResourceModel\Order\Invoice\CollectionFactory; use Magento\TestFramework\Mail\Template\TransportBuilderMock; use Magento\TestFramework\TestCase\AbstractBackendController; /** * Abstract backend invoice test. */ -class AbstractInvoiceControllerTest extends AbstractBackendController +abstract class AbstractInvoiceControllerTest extends AbstractBackendController { - /** - * @var TransportBuilderMock - */ + /** @var TransportBuilderMock */ protected $transportBuilder; - /** - * @var OrderRepository - */ - protected $orderRepository; + /** @var string */ + protected $resource = 'Magento_Sales::sales_invoice'; - /** - * @var FormKey - */ - protected $formKey; + /** @var OrderRepository */ + private $orderRepository; - /** - * @var string - */ - protected $resource = 'Magento_Sales::sales_invoice'; + /** @var SearchCriteriaBuilder */ + private $searchCriteriaBuilder; + + /** @var CollectionFactory */ + private $invoiceCollectionFactory; /** * @inheritdoc @@ -47,46 +42,71 @@ class AbstractInvoiceControllerTest extends AbstractBackendController protected function setUp(): void { parent::setUp(); + $this->transportBuilder = $this->_objectManager->get(TransportBuilderMock::class); $this->orderRepository = $this->_objectManager->get(OrderRepository::class); - $this->formKey = $this->_objectManager->get(FormKey::class); + $this->searchCriteriaBuilder = $this->_objectManager->get(SearchCriteriaBuilder::class); + $this->invoiceCollectionFactory = $this->_objectManager->get(CollectionFactory::class); } /** + * Retrieve order + * * @param string $incrementalId * @return OrderInterface|null */ - protected function getOrder(string $incrementalId) + protected function getOrder(string $incrementalId): ?OrderInterface { - /** @var SearchCriteria $searchCriteria */ - $searchCriteria = $this->_objectManager->create(SearchCriteriaBuilder::class) - ->addFilter(OrderInterface::INCREMENT_ID, $incrementalId) + $searchCriteria = $this->searchCriteriaBuilder->addFilter(OrderInterface::INCREMENT_ID, $incrementalId) ->create(); - $orders = $this->orderRepository->getList($searchCriteria)->getItems(); - /** @var OrderInterface $order */ - $order = reset($orders); - return $order; + return reset($orders); } /** - * @param OrderInterface $order + * Get firs order invoice + * + * @param OrderInterface|int $order * @return InvoiceInterface */ - protected function getInvoiceByOrder(OrderInterface $order): InvoiceInterface + protected function getInvoiceByOrder($order): InvoiceInterface { - /** @var \Magento\Sales\Model\ResourceModel\Order\Invoice\Collection $invoiceCollection */ - $invoiceCollection = $this->_objectManager->create( - \Magento\Sales\Model\ResourceModel\Order\Invoice\CollectionFactory::class - )->create(); + $invoiceCollection = $this->invoiceCollectionFactory->create(); - /** @var InvoiceInterface $invoice */ - $invoice = $invoiceCollection - ->setOrderFilter($order) - ->setPageSize(1) - ->getFirstItem(); + return $invoiceCollection->setOrderFilter($order)->setPageSize(1)->getFirstItem(); + } - return $invoice; + /** + * Prepare request + * + * @param array $postParams + * @param array $params + * @return void + */ + protected function prepareRequest(array $postParams = [], array $params = []): void + { + $this->getRequest()->setMethod(Http::METHOD_POST); + $this->getRequest()->setParams($params); + $this->getRequest()->setPostValue($postParams); + } + + /** + * Normalize post parameters + * + * @param array $items + * @param string $commentText + * @param bool $doShipment + * @return array + */ + protected function hydratePost(array $items, string $commentText = '', $doShipment = false): array + { + return [ + 'invoice' => [ + 'items' => $items, + 'comment_text' => $commentText, + 'do_shipment' => $doShipment + ], + ]; } } 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 index ee59a55acd9b1..c7711e8897696 100644 --- 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 @@ -30,10 +30,11 @@ class AddCommentTest extends AbstractInvoiceControllerTest public function testSendEmailOnAddInvoiceComment(): void { $comment = 'Test Invoice Comment'; - $order = $this->prepareRequest( - [ - 'comment' => ['comment' => $comment, 'is_customer_notified' => true], - ] + $order = $this->getOrder('100000001'); + $invoice = $this->getInvoiceByOrder($order); + $this->prepareRequest( + ['comment' => ['comment' => $comment, 'is_customer_notified' => true]], + ['id' => $invoice->getEntityId()] ); $this->dispatch('backend/sales/order_invoice/addComment'); @@ -41,6 +42,7 @@ public function testSendEmailOnAddInvoiceComment(): void $this->assertStringContainsString($comment, $html); $message = $this->transportBuilder->getSentMessage(); + $this->assertNotNull($message); $subject = __('Update to your %1 invoice', $order->getStore()->getFrontendName())->render(); $messageConstraint = $this->logicalAnd( new StringContains($order->getCustomerName()), @@ -55,7 +57,8 @@ public function testSendEmailOnAddInvoiceComment(): void ); $this->assertEquals($message->getSubject(), $subject); - $this->assertThat($message->getBody()->getParts()[0]->getRawContent(), $messageConstraint); + $bodyParts = $message->getBody()->getParts(); + $this->assertThat(reset($bodyParts)->getRawContent(), $messageConstraint); } /** @@ -63,7 +66,7 @@ public function testSendEmailOnAddInvoiceComment(): void */ public function testAclHasAccess() { - $this->prepareRequest(['comment' => ['comment' => 'Comment']]); + $this->prepareRequest(); parent::testAclHasAccess(); } @@ -73,31 +76,8 @@ public function testAclHasAccess() */ public function testAclNoAccess() { - $this->prepareRequest(['comment' => ['comment' => 'Comment']]); + $this->prepareRequest(); 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/NewActionTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewActionTest.php new file mode 100644 index 0000000000000..c8444c827d2e4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewActionTest.php @@ -0,0 +1,78 @@ +<?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\App\Request\Http; +use Magento\Framework\Escaper; +use Magento\Framework\Message\MessageInterface; +use Magento\Sales\Model\OrderFactory; +use Magento\TestFramework\TestCase\AbstractBackendController; + +/** + * Test for new invoice action + * + * @see \Magento\Sales\Controller\Adminhtml\Order\Invoice\NewAction + * + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ +class NewActionTest extends AbstractBackendController +{ + /** @var OrderFactory */ + private $orderFactory; + + /** @var Escaper */ + private $escaper; + + /** + * @inheridoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->orderFactory = $this->_objectManager->get(OrderFactory::class); + $this->escaper = $this->_objectManager->get(Escaper::class); + } + + /** + * @return void + */ + public function testWithNoExistingOrder(): void + { + $this->dispatchWithOrderId(863521); + $expectedMessage = (string)__("The entity that was requested doesn't exist. Verify the entity and try again."); + $this->assertSessionMessages($this->containsEqual($this->escaper->escapeHtml($expectedMessage))); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order_with_bundle_and_invoiced.php + * + * @return void + */ + public function testCanNotInvoice(): void + { + $expectedMessage = __('The order does not allow an invoice to be created.'); + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $this->dispatchWithOrderId((int)$order->getEntityId()); + $this->assertSessionMessages($this->containsEqual((string)$expectedMessage), MessageInterface::TYPE_ERROR); + } + + /** + * Dispatch request with order_id param + * + * @param int $orderId + * @return void + */ + private function dispatchWithOrderId(int $orderId): void + { + $this->getRequest()->setMethod(Http::METHOD_GET) + ->setParams(['order_id' => $orderId]); + $this->dispatch('backend/sales/order_invoice/new'); + } +} 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 index 2dc5f5adc86d2..755d20196aa95 100644 --- 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 @@ -7,38 +7,53 @@ namespace Magento\Sales\Controller\Adminhtml\Order\Invoice; +use Magento\Framework\Escaper; +use Magento\Sales\Api\Data\InvoiceInterface; +use Magento\Sales\Model\Order; use PHPUnit\Framework\Constraint\StringContains; /** - * Class tests invoice creation in backend. + * Class tests invoice creation in admin panel. + * + * @see \Magento\Sales\Controller\Adminhtml\Order\Invoice\Save * * @magentoDbIsolation enabled * @magentoAppArea adminhtml - * @magentoDataFixture Magento/Sales/_files/order.php */ class SaveTest extends AbstractInvoiceControllerTest { + /** @var string */ + protected $uri = 'backend/sales/order_invoice/save'; + + /** @var Escaper */ + private $escaper; + /** - * @var string + * @inheritdoc */ - protected $uri = 'backend/sales/order_invoice/save'; + protected function setUp(): void + { + parent::setUp(); + + $this->escaper = $this->_objectManager->get(Escaper::class); + } /** + * @magentoDataFixture Magento/Sales/_files/order.php + * * @return void */ public function testSendEmailOnInvoiceSave(): void { - $order = $this->prepareRequest(); + $order = $this->getOrder('100000001'); + $itemId = $order->getItemsCollection()->getFirstItem()->getId(); + $post = $this->hydratePost([$itemId => 2]); + $this->prepareRequest($post, ['order_id' => $order->getEntityId()]); $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); + $this->checkSuccess($invoice, 2); $message = $this->transportBuilder->getSentMessage(); + $this->assertNotNull($message); $subject = __('Invoice for your %1 order', $order->getStore()->getFrontendName())->render(); $messageConstraint = $this->logicalAnd( new StringContains($invoice->getBillingAddress()->getName()), @@ -49,9 +64,113 @@ public function testSendEmailOnInvoiceSave(): void "Your Invoice #{$invoice->getIncrementId()} for Order #{$order->getIncrementId()}" ) ); - $this->assertEquals($message->getSubject(), $subject); - $this->assertThat($message->getBody()->getParts()[0]->getRawContent(), $messageConstraint); + $bodyParts = $message->getBody()->getParts(); + $this->assertThat(reset($bodyParts)->getRawContent(), $messageConstraint); + } + + /** + * @magentoConfigFixture current_store sales_email/invoice/enabled 0 + * + * @magentoDataFixture Magento/Sales/_files/order.php + * + * @return void + */ + public function testSendEmailOnInvoiceSaveWithDisabledConfig(): void + { + $order = $this->getOrder('100000001'); + $post = $this->hydratePost([$order->getItemsCollection()->getFirstItem()->getId() => 2]); + $this->prepareRequest($post, ['order_id' => $order->getEntityId()]); + $this->dispatch('backend/sales/order_invoice/save'); + $this->checkSuccess($this->getInvoiceByOrder($order), 2); + $this->assertNull($this->transportBuilder->getSentMessage()); + } + + /** + * @dataProvider invoiceDataProvider + * + * @magentoDataFixture Magento/Sales/_files/order.php + * + * @param int $invoicedItemsQty + * @param string $commentMessage + * @param bool $doShipment + * @return void + */ + public function testSuccessfulInvoice( + int $invoicedItemsQty, + string $commentMessage = '', + bool $doShipment = false + ): void { + $order = $this->getOrder('100000001'); + $post = $this->hydratePost( + [$order->getItemsCollection()->getFirstItem()->getId() => $invoicedItemsQty], + $commentMessage, + $doShipment + ); + $this->prepareRequest($post, ['order_id' => $order->getEntityId()]); + $this->dispatch('backend/sales/order_invoice/save'); + $this->checkSuccess($this->getInvoiceByOrder($order), $invoicedItemsQty, $commentMessage, $doShipment); + } + + /** + * @return array + */ + public function invoiceDataProvider(): array + { + return [ + 'with_comment_message' => [ + 'invoiced_items_qty' => 2, + 'comment_message' => 'test comment message', + ], + 'partial_invoice' => [ + 'invoiced_items_qty' => 1, + ], + 'with_do_shipment' => [ + 'invoiced_items_qty' => 2, + 'comment_message' => '', + 'do_shipment' => true, + ], + ]; + } + + /** + * @return void + */ + public function testWitNoExistingOrder(): void + { + $expectedMessage = (string)__('The order no longer exists.'); + $this->prepareRequest(['order_id' => 899989]); + $this->dispatch('backend/sales/order_invoice/save'); + $this->assertErrorResponse($expectedMessage); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order_with_bundle_and_invoiced.php + * + * @return void + */ + public function testCanNotInvoiceOrder(): void + { + $expectedMessage = (string)__('The order does not allow an invoice to be created.'); + $order = $this->getOrder('100000001'); + $this->prepareRequest([], ['order_id' => $order->getEntityId()]); + $this->dispatch('backend/sales/order_invoice/save'); + $this->assertErrorResponse($expectedMessage); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order.php + * + * @return void + */ + public function testInvoiceWithoutQty(): void + { + $expectedMessage = (string)__('The invoice can\'t be created without products. Add products and try again.'); + $order = $this->getOrder('100000001'); + $post = $this->hydratePost([$order->getItemsCollection()->getFirstItem()->getId() => '0']); + $this->prepareRequest($post, ['order_id' => $order->getEntityId()]); + $this->dispatch('backend/sales/order_invoice/save'); + $this->assertErrorResponse($this->escaper->escapeHtml($expectedMessage)); } /** @@ -75,23 +194,46 @@ public function testAclNoAccess() } /** - * @param array $params - * @return \Magento\Sales\Api\Data\OrderInterface|null + * Check error response + * + * @param string $expectedMessage + * @return void */ - private function prepareRequest(array $params = []) + private function assertErrorResponse(string $expectedMessage): void { - $order = $this->getOrder('100000001'); - $this->getRequest()->setMethod('POST'); - $this->getRequest()->setParams( - [ - 'order_id' => $order->getEntityId(), - 'form_key' => $this->formKey->getFormKey(), - ] - ); + $this->assertRedirect($this->stringContains('sales/order_invoice/new')); + $this->assertSessionMessages($this->containsEqual($expectedMessage)); + } + + /** + * Check that invoice was successfully created + * + * @param InvoiceInterface $invoice + * @param int $invoicedItemsQty + * @param string|null $commentMessage + * @param bool $doShipment + * @return void + */ + private function checkSuccess( + InvoiceInterface $invoice, + int $invoicedItemsQty, + ?string $commentMessage = null, + bool $doShipment = false + ): void { + $message = $doShipment ? 'You created the invoice and shipment.' : 'The invoice has been created.'; + $expectedState = $doShipment ? Order::STATE_COMPLETE : Order::STATE_PROCESSING; + $this->assertNotNull($invoice->getEntityId()); + $this->assertEquals($invoicedItemsQty, (int)$invoice->getTotalQty()); + $order = $invoice->getOrder(); + $this->assertEquals($expectedState, $order->getState()); - $data = $params ?? []; - $this->getRequest()->setPostValue($data); + if ($commentMessage) { + $this->assertEquals($commentMessage, $invoice->getCustomerNote()); + } - return $order; + $this->assertRedirect( + $this->stringContains(sprintf('sales/order/view/order_id/%u', (int)$order->getEntityId())) + ); + $this->assertSessionMessages($this->containsEqual((string)__($message))); } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/StartTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/StartTest.php new file mode 100644 index 0000000000000..5eb554ef937d5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/StartTest.php @@ -0,0 +1,66 @@ +<?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\Backend\Model\Session; +use Magento\Framework\App\Request\Http; +use Magento\Sales\Model\OrderFactory; +use Magento\TestFramework\TestCase\AbstractBackendController; + +/** + * Test for invoice start action + * + * @see \Magento\Sales\Controller\Adminhtml\Order\Invoice\Start + * + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ +class StartTest extends AbstractBackendController +{ + /** @var OrderFactory */ + private $orderFactory; + + /** @var Session */ + private $session; + + /** + * @inheridoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->orderFactory = $this->_objectManager->get(OrderFactory::class); + $this->session = $this->_objectManager->get(Session::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->session->getInvoiceItemQtys(true); + + parent::tearDown(); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order.php + * + * @return void + */ + public function testExecute(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $this->session->setInvoiceItemQtys('test'); + $this->getRequest()->setMethod(Http::METHOD_GET)->setParams(['order_id' => $order->getEntityId()]); + $this->dispatch('backend/sales/order_invoice/start'); + $this->assertRedirect($this->stringContains('sales/order_invoice/new')); + $this->assertNull($this->session->getInvoiceItemQtys()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php new file mode 100644 index 0000000000000..2b91c5d04fd6f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php @@ -0,0 +1,123 @@ +<?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\Serialize\SerializerInterface; +use Magento\TestFramework\Helper\Xpath; + +/** + * Class tests invoice items qty update. + * + * @magentoDbIsolation enabled + * @magentoAppArea adminhtml + */ +class UpdateQtyTest extends AbstractInvoiceControllerTest +{ + /** @var SerializerInterface */ + private $json; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->json = $this->_objectManager->get(SerializerInterface::class); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order.php + * + * @return void + */ + public function testSuccess(): void + { + $order = $this->getOrder('100000001'); + $itemId = $order->getItemsCollection()->getFirstItem()->getId(); + $qtyToInvoice = 1; + $invoicedItemsXpath = sprintf( + "//input[contains(@class, 'qty-input') and @name='invoice[items][%u]' and @value='%u']", + $itemId, + $qtyToInvoice + ); + $post = $this->hydratePost([$itemId => $qtyToInvoice]); + $this->prepareRequest($post, ['order_id' => $order->getEntityId()]); + $this->dispatch('backend/sales/order_invoice/updateQty'); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath($invoicedItemsXpath, $this->getResponse()->getContent()) + ); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order_with_bundle_and_invoiced.php + * + * @return void + */ + public function testCanNotInvoice(): void + { + $order = $this->getOrder('100000001'); + $itemId = $order->getItemsCollection()->getFirstItem()->getId(); + $post = $this->hydratePost([$itemId => '1']); + $this->prepareRequest($post, ['order_id' => $order->getEntityId()]); + $this->dispatch('backend/sales/order_invoice/updateQty'); + $this->assertErrorResponse('The order does not allow an invoice to be created.'); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order.php + * + * @return void + */ + public function testWithoutQty(): void + { + $order = $this->getOrder('100000001'); + $itemId = $order->getItemsCollection()->getFirstItem()->getId(); + $post = $this->hydratePost([$itemId => '0']); + $this->prepareRequest($post, ['order_id' => $order->getEntityId()]); + $this->dispatch('backend/sales/order_invoice/updateQty'); + $this->assertErrorResponse( + 'The invoice can\'t be created without products. Add products and try again.' + ); + } + + /** + * @return void + */ + public function testWithNoExistingOrderId(): void + { + $post = $this->hydratePost([ + 'invoice' => [ + 'items' => [ + '1' => '3', + ], + ], + ]); + $this->prepareRequest($post, ['order_id' => 6543265]); + $this->dispatch('backend/sales/order_invoice/updateQty'); + $this->assertErrorResponse('The order no longer exists.'); + } + + /** + * Check error response + * + * @param string $expectedMessage + * @return void + */ + private function assertErrorResponse(string $expectedMessage): void + { + $expectedResponse = [ + 'error' => true, + 'message' => (string)__($expectedMessage), + ]; + $response = $this->getResponse()->getContent(); + $this->assertNotEmpty($response); + $this->assertEquals($expectedResponse, $this->json->unserialize($response)); + } +} From 33ffe08a4d5efd67b15c6c9e832c8df11692a9af Mon Sep 17 00:00:00 2001 From: Yurii Sapiha <yurasapiga93@gmail.com> Date: Fri, 28 Aug 2020 14:48:34 +0300 Subject: [PATCH 30/99] MC-36914: Storefront: Customer Product reviews tab on customer profile --- .../Magento/Review/Block/Account/LinkTest.php | 80 ++++++++++ .../Block/Customer/ListCustomerTest.php | 135 +++++++++++++++++ .../Review/Block/Customer/ViewTest.php | 138 ++++++++++++++++++ 3 files changed, 353 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Review/Block/Account/LinkTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Review/Block/Customer/ListCustomerTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Review/Block/Customer/ViewTest.php diff --git a/dev/tests/integration/testsuite/Magento/Review/Block/Account/LinkTest.php b/dev/tests/integration/testsuite/Magento/Review/Block/Account/LinkTest.php new file mode 100644 index 0000000000000..df5f5f8336303 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Review/Block/Account/LinkTest.php @@ -0,0 +1,80 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Review\Block\Account; + +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\Result\Page; +use Magento\Framework\View\Result\PageFactory; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Checks "My Product Reviews" link displaying in customer account dashboard + * + * @magentoAppArea frontend + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + */ +class LinkTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Page */ + private $page; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->page = $this->objectManager->get(PageFactory::class)->create(); + } + + /** + * @return void + */ + public function testMyProductReviewsLink(): void + { + $this->preparePage(); + $block = $this->page->getLayout()->getBlock('customer-account-navigation-product-reviews-link'); + $this->assertNotFalse($block); + $html = $block->toHtml(); + $this->assertStringContainsString('/review/customer/', $html); + $this->assertEquals((string)__('My Product Reviews'), strip_tags($html)); + } + + /** + * @magentoConfigFixture current_store catalog/review/active 0 + * + * @return void + */ + public function testMyProductReviewsLinkDisabled(): void + { + $this->preparePage(); + $block = $this->page->getLayout()->getBlock('customer-account-navigation-product-reviews-link'); + $this->assertFalse($block); + } + + /** + * Prepare page before render + * + * @return void + */ + private function preparePage(): void + { + $this->page->addHandle([ + 'default', + 'customer_account', + ]); + $this->page->getLayout()->generateXml(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Review/Block/Customer/ListCustomerTest.php b/dev/tests/integration/testsuite/Magento/Review/Block/Customer/ListCustomerTest.php new file mode 100644 index 0000000000000..24cb2fe76a6d4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Review/Block/Customer/ListCustomerTest.php @@ -0,0 +1,135 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Review\Block\Customer; + +use Magento\Customer\Model\Session; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\LayoutInterface; +use Magento\Review\Model\ResourceModel\Review\Product\CollectionFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + +/** + * Test for customer product reviews grid. + * + * @see \Magento\Review\Block\Customer\ListCustomer + * @magentoAppArea frontend + * @magentoDbIsolation enabled + */ +class ListCustomerTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Session */ + private $customerSession; + + /** @var ListCustomer */ + private $block; + + /** @var CollectionFactory */ + private $collectionFactory; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->customerSession = $this->objectManager->get(Session::class); + $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(ListCustomer::class) + ->setTemplate('Magento_Review::customer/list.phtml'); + $this->collectionFactory = $this->objectManager->get(CollectionFactory::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->customerSession->setCustomerId(null); + + parent::tearDown(); + } + + /** + * @magentoDataFixture Magento/Review/_files/customer_review_with_rating.php + * + * @return void + */ + public function testCustomerProductReviewsGrid(): void + { + $this->customerSession->setCustomerId(1); + $review = $this->collectionFactory->create()->addCustomerFilter(1)->addReviewSummary()->getFirstItem(); + $this->assertNotNull($review->getReviewId()); + $blockHtml = $this->block->toHtml(); + $createdDate = $this->block->dateFormat($review->getReviewCreatedAt()); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf("//td[contains(@class, 'date') and contains(text(), '%s')]", $createdDate), + $blockHtml + ), + sprintf('Created date wasn\'t found or not equals to %s.', $createdDate) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf("//td[contains(@class, 'item')]//a[contains(text(), '%s')]", $review->getName()), + $blockHtml + ), + 'Product name wasn\'t found.' + ); + $rating = $review->getSum() / $review->getCount(); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf("//td[contains(@class, 'summary')]//span[contains(text(), '%s%%')]", $rating), + $blockHtml + ), + sprintf('Rating wasn\'t found or not equals to %s%%.', $rating) + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf("//td[contains(@class, 'description') and contains(text(), '%s')]", $review->getDetail()), + $blockHtml + ), + 'Review description wasn\'t found.' + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//td[contains(@class, 'actions')]//a[contains(@href, '%s')]/span[contains(text(), '%s')]", + $this->block->getReviewUrl($review), + __('See Details') + ), + $blockHtml + ), + sprintf('%s button wasn\'t found.', __('See Details')) + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * + * @return void + */ + public function testCustomerWithoutReviews(): void + { + $this->customerSession->setCustomerId(1); + $this->assertStringContainsString( + (string)__('You have submitted no reviews.'), + strip_tags($this->block->toHtml()) + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Review/Block/Customer/ViewTest.php b/dev/tests/integration/testsuite/Magento/Review/Block/Customer/ViewTest.php new file mode 100644 index 0000000000000..31a342ad8ac54 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Review/Block/Customer/ViewTest.php @@ -0,0 +1,138 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Review\Block\Customer; + +use Magento\Customer\Model\Session; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\LayoutInterface; +use Magento\Review\Model\ResourceModel\Review\Product\CollectionFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + +/** + * Test for displaying customer product review block. + * + * @see \Magento\Review\Block\Customer\View + * @magentoAppArea frontend + * @magentoDbIsolation enabled + */ +class ViewTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Session */ + private $customerSession; + + /** @var CollectionFactory */ + private $collectionFactory; + + /** @var View */ + private $block; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->customerSession = $this->objectManager->get(Session::class); + $this->collectionFactory = $this->objectManager->get(CollectionFactory::class); + $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(View::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->customerSession->setCustomerId(null); + + parent::tearDown(); + } + + /** + * @magentoDataFixture Magento/Review/_files/customer_review_with_rating.php + * + * @return void + */ + public function testCustomerProductReviewBlock(): void + { + $this->customerSession->setCustomerId(1); + $review = $this->collectionFactory->create()->addCustomerFilter(1)->getFirstItem(); + $this->assertNotNull($review->getReviewId()); + $blockHtml = $this->block->setReviewId($review->getReviewId())->toHtml(); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf("//div[contains(@class, 'product-info')]/h2[contains(text(), '%s')]", $review->getName()), + $blockHtml + ), + 'Product name wasn\'t found.' + ); + $ratings = $this->block->getRating(); + $this->assertCount(2, $ratings); + foreach ($ratings as $rating) { + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//div[contains(@class, 'rating-summary')]//span[contains(text(), '%s')]" + . "/../..//span[contains(text(), '%s%%')]", + $rating->getRatingCode(), + $rating->getPercent() + ), + $blockHtml + ), + sprintf('Rating %s was not found or not equals to %s.', $rating->getRatingCode(), $rating->getPercent()) + ); + } + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf("//div[contains(@class, 'review-title') and contains(text(), '%s')]", $review->getTitle()), + $blockHtml + ), + 'Review title wasn\'t found.' + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf("//div[contains(@class, 'review-content') and contains(text(), '%s')]", $review->getDetail()), + $blockHtml + ), + 'Review description wasn\'t found.' + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//div[contains(@class, 'review-date') and contains(text(), '%s')]/time[contains(text(), '%s')]", + __('Submitted on'), + $this->block->dateFormat($review->getCreatedAt()) + ), + $blockHtml + ), + 'Created date wasn\'t found.' + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + "//a[contains(@href, '/review/customer/')]/span[contains(text(), '%s')]", + __('Back to My Reviews') + ), + $blockHtml + ), + sprintf('%s button wasn\'t found.', __('Back to My Reviews')) + ); + } +} From f9006ff4c89831b6c854387fe7838d3c95827178 Mon Sep 17 00:00:00 2001 From: Roman Lytvynenko <lytvynen@adobe.com> Date: Fri, 28 Aug 2020 15:48:01 -0500 Subject: [PATCH 31/99] MC-36978: Invalid Character Customer Account Create DOB --- lib/web/mage/utils/misc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/mage/utils/misc.js b/lib/web/mage/utils/misc.js index b1c0c33324c28..148206d9ad69d 100644 --- a/lib/web/mage/utils/misc.js +++ b/lib/web/mage/utils/misc.js @@ -282,7 +282,7 @@ define([ var newFormat; newFormat = format.replace(/yyyy|yy|y/, 'YYYY'); // replace the year - newFormat = newFormat.replace(/dd|d/g, 'DD'); // replace the date + newFormat = newFormat.replace(/dd|d/g, 'D'); // replace the date return newFormat; }, From 4ea7db83579a89cfd7053c3d9763c8ec57477350 Mon Sep 17 00:00:00 2001 From: Roman Lytvynenko <lytvynen@adobe.com> Date: Mon, 31 Aug 2020 16:10:08 -0500 Subject: [PATCH 32/99] MC-36978: Invalid Character Customer Account Create DOB --- .../view/frontend/web/js/validation.js | 2 +- .../Customer/frontend/js/validation.test.js | 158 ++++++++++++++++++ lib/web/mage/utils/misc.js | 2 +- 3 files changed, 160 insertions(+), 2 deletions(-) create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js diff --git a/app/code/Magento/Customer/view/frontend/web/js/validation.js b/app/code/Magento/Customer/view/frontend/web/js/validation.js index 9ffc8137135da..6b9983c0af873 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/validation.js +++ b/app/code/Magento/Customer/view/frontend/web/js/validation.js @@ -11,7 +11,7 @@ define([ $.validator.addMethod( 'validate-date', function (value, element, params) { - var dateFormat = utils.convertToMomentFormat(params.dateFormat); + var dateFormat = utils.normalizeDate(params.dateFormat); if (value === '') { return true; diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js new file mode 100644 index 0000000000000..57b3557f40c15 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js @@ -0,0 +1,158 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +define([ + 'jquery', + 'Magento_Customer/js/validation' +], function ($) { + 'use strict'; + + describe('Testing Customer/view/frontend/web/js/validation.js', function () { + var params, + dataProvider; + + dataProvider = [ + { + format: 'dd.MM.yy.', + date: '09.02.18.', + expects: true + }, + { + format: 'd/MM/y', + date: '9/02/2018', + expects: true + }, + { + format: 'MM/dd/yy', + date: '02/09/18', + expects: true + }, + { + format: 'M/d/yy', + date: '2/9/18', + expects: true + }, + { + format: 'yy-MM-dd', + date: '18-02-09', + expects: true + }, + { + format: 'dd.MM.y.', + date: '09.02.2018.', + expects: true + }, + { + format: 'y. MM. dd.', + date: '2018. 02. 09.', + expects: true + }, + { + format: 'd/MM/yy', + date: '9/02/18', + expects: true + }, + { + format: 'dd-MM-yy', + date: '09-02-18', + expects: true + }, + { + format: 'dd/MM/yy', + date: '09/02/18', + expects: true + }, + { + format: 'dd.MM.y', + date: '09.02.2018', + expects: true + }, + { + format: 'd. MM. yy', + date: '9. 02. 18', + expects: true + }, + { + format: 'dd/MM/y', + date: '09/02/2018', + expects: true + }, + { + format: 'd.MM.y', + date: '9.02.2018', + expects: true + }, + { + format: 'd.M.yy', + date: '9.2.18', + expects: true + }, + { + format: 'd.MM.yy г.', + date: '9.02.18 г.', + expects: true + }, + { + format: 'dd.M.yy', + date: '09.2.18', + expects: true + }, + { + format: 'y-MM-dd', + date: '2018-02-09', + expects: true + }, + { + format: 'd.M.yy.', + date: '9.2.18.', + expects: true + }, + { + format: 'd.M.y', + date: '9.2.2018', + expects: true + }, + { + format: 'd/M/y', + date: '9/2/2018', + expects: true + }, + { + format: 'yy/M/d', + date: '19/2/9', + expects: true + }, + { + format: 'd/M/yy', + date: '9/2/18', + expects: true + }, + { + format: 'y/M/d', + date: '2018/2/9', + expects: true + }, + { + format: 'y/MM/dd', + date: '2018/02/09', + expects: true + }, + { + format: 'yy. M. d.', + date: '18. 2. 9.', + expects: true + } + ]; + + dataProvider.forEach(function (data) { + it('Test date validation for format ' + data.format, function () { + params = { + 'dateFormat': data.format + }; + expect($.validator.methods['validate-date'] + .call($.validator.prototype, data.date, null, params)).toEqual(data.expects); + }); + }); + }); +}); diff --git a/lib/web/mage/utils/misc.js b/lib/web/mage/utils/misc.js index 148206d9ad69d..b1c0c33324c28 100644 --- a/lib/web/mage/utils/misc.js +++ b/lib/web/mage/utils/misc.js @@ -282,7 +282,7 @@ define([ var newFormat; newFormat = format.replace(/yyyy|yy|y/, 'YYYY'); // replace the year - newFormat = newFormat.replace(/dd|d/g, 'D'); // replace the date + newFormat = newFormat.replace(/dd|d/g, 'DD'); // replace the date return newFormat; }, From a95ee525c1c0c9aa7aee8a813ed94a3e52b7b256 Mon Sep 17 00:00:00 2001 From: Roman Lytvynenko <lytvynen@adobe.com> Date: Mon, 31 Aug 2020 16:53:25 -0500 Subject: [PATCH 33/99] MC-36978: Invalid Character Customer Account Create DOB --- .../app/code/Magento/Customer/frontend/js/validation.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js index 57b3557f40c15..1b82e0ba36e16 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js @@ -2,6 +2,8 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + +/* eslint-disable max-nested-callbacks */ define([ 'jquery', 'Magento_Customer/js/validation' From 269089f9b6be72fa146c86452b618efc37e4fcfc Mon Sep 17 00:00:00 2001 From: Roman Lytvynenko <lytvynen@adobe.com> Date: Mon, 31 Aug 2020 17:43:47 -0500 Subject: [PATCH 34/99] MC-36978: Invalid Character Customer Account Create DOB --- .../Customer/frontend/js/validation.test.js | 130 ++---------------- 1 file changed, 10 insertions(+), 120 deletions(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js index 1b82e0ba36e16..847bb4a040bd7 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js @@ -10,140 +10,30 @@ define([ ], function ($) { 'use strict'; - describe('Testing Customer/view/frontend/web/js/validation.js', function () { + describe('Testing customer DOB validation to tolerate zeroes in the single digit dates', function () { var params, dataProvider; dataProvider = [ { - format: 'dd.MM.yy.', - date: '09.02.18.', - expects: true - }, - { - format: 'd/MM/y', - date: '9/02/2018', - expects: true - }, - { - format: 'MM/dd/yy', - date: '02/09/18', - expects: true - }, - { - format: 'M/d/yy', - date: '2/9/18', - expects: true - }, - { - format: 'yy-MM-dd', - date: '18-02-09', - expects: true - }, - { - format: 'dd.MM.y.', - date: '09.02.2018.', - expects: true - }, - { - format: 'y. MM. dd.', - date: '2018. 02. 09.', - expects: true - }, - { - format: 'd/MM/yy', - date: '9/02/18', - expects: true - }, - { - format: 'dd-MM-yy', - date: '09-02-18', - expects: true - }, - { - format: 'dd/MM/yy', - date: '09/02/18', - expects: true - }, - { - format: 'dd.MM.y', - date: '09.02.2018', - expects: true - }, - { - format: 'd. MM. yy', - date: '9. 02. 18', - expects: true - }, - { - format: 'dd/MM/y', - date: '09/02/2018', - expects: true - }, - { - format: 'd.MM.y', - date: '9.02.2018', - expects: true - }, - { - format: 'd.M.yy', - date: '9.2.18', - expects: true - }, - { - format: 'd.MM.yy г.', - date: '9.02.18 г.', - expects: true - }, - { - format: 'dd.M.yy', - date: '09.2.18', - expects: true - }, - { - format: 'y-MM-dd', - date: '2018-02-09', - expects: true - }, - { - format: 'd.M.yy.', - date: '9.2.18.', - expects: true - }, - { - format: 'd.M.y', - date: '9.2.2018', - expects: true - }, - { - format: 'd/M/y', - date: '9/2/2018', - expects: true - }, - { - format: 'yy/M/d', - date: '19/2/9', - expects: true - }, - { - format: 'd/M/yy', + format: 'M/d/Y', date: '9/2/18', expects: true }, { - format: 'y/M/d', - date: '2018/2/9', - expects: true + format: 'M/DD/Y', + date: '9/2/18', + expects: false }, { - format: 'y/MM/dd', - date: '2018/02/09', + format: 'MM/DD/Y', + date: '09/02/18', expects: true }, { - format: 'yy. M. d.', - date: '18. 2. 9.', - expects: true + format: 'MM/DD/YYYY', + date: '09/2/18', + expects: false } ]; From 194c62ed34ce19615c6ccc5c4822257523761805 Mon Sep 17 00:00:00 2001 From: Roman Lytvynenko <lytvynen@adobe.com> Date: Mon, 31 Aug 2020 17:57:07 -0500 Subject: [PATCH 35/99] MC-36978: Invalid Character Customer Account Create DOB --- .../Customer/frontend/js/validation.test.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js index 847bb4a040bd7..df1fb609f8bda 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js @@ -17,24 +17,14 @@ define([ dataProvider = [ { format: 'M/d/Y', - date: '9/2/18', + date: '09/2/18', expects: true }, { format: 'M/DD/Y', - date: '9/2/18', - expects: false - }, - { - format: 'MM/DD/Y', - date: '09/02/18', - expects: true - }, - { - format: 'MM/DD/YYYY', date: '09/2/18', expects: false - } + }, ]; dataProvider.forEach(function (data) { From 818a7fa969b2c7bf99ca3444048d8d9b42c574cd Mon Sep 17 00:00:00 2001 From: "taras.gamanov" <engcom-vendorworker-hotel@adobe.com> Date: Tue, 1 Sep 2020 11:03:27 +0300 Subject: [PATCH 36/99] Annotations have been updated. --- .../StorefrontCustomerCheckoutWithCustomerGroupTest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest/StorefrontCustomerCheckoutWithCustomerGroupTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest/StorefrontCustomerCheckoutWithCustomerGroupTest.xml index 39869190aa40e..28e779f802cde 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest/StorefrontCustomerCheckoutWithCustomerGroupTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutTest/StorefrontCustomerCheckoutWithCustomerGroupTest.xml @@ -13,6 +13,7 @@ <stories value="Customer checkout with Customer Group assigned"/> <title value="Place order by Customer with Customer Group assigned"/> <description value="Customer Group should be assigned to Order when setting Auto Group Assign is enabled for Customer"/> + <testCaseId value="MC-37259"/> <severity value="MAJOR"/> <group value="checkout"/> <group value="customer"/> From 9bd2b73afe8e8b1835b4fdc6e4c3f725076c8171 Mon Sep 17 00:00:00 2001 From: IvanPletnyov <ivan.pletnyov@transoftgroup.com> Date: Tue, 1 Sep 2020 12:27:57 +0300 Subject: [PATCH 37/99] MC-36907: Storefront: Create reorder from customer profile page. --- .../_files/customer_quote_ready_for_order.php | 55 +++++++ ...ustomer_quote_ready_for_order_rollback.php | 26 ++++ .../Sales/Controller/Guest/ReorderTest.php | 139 ++++++++++++++++++ .../Sales/Controller/Order/ReorderTest.php | 139 ++++++++++++++++++ .../Magento/Sales/Helper/ReorderTest.php | 106 +++++++++++++ .../customer_order_with_simple_product.php | 22 +++ ...mer_order_with_simple_product_rollback.php | 33 +++++ .../customer_order_with_taxable_product.php | 30 ++++ ...er_order_with_taxable_product_rollback.php | 35 +++++ .../order_by_guest_with_simple_product.php | 31 ++++ ..._by_guest_with_simple_product_rollback.php | 33 +++++ 11 files changed, 649 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Checkout/_files/customer_quote_ready_for_order.php create mode 100644 dev/tests/integration/testsuite/Magento/Checkout/_files/customer_quote_ready_for_order_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/ReorderTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Order/ReorderTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Helper/ReorderTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_simple_product.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_simple_product_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_taxable_product.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_taxable_product_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/order_by_guest_with_simple_product.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/_files/order_by_guest_with_simple_product_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/customer_quote_ready_for_order.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/customer_quote_ready_for_order.php new file mode 100644 index 0000000000000..5cca93ce3478c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/customer_quote_ready_for_order.php @@ -0,0 +1,55 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Checkout\Model\Type\Onepage; +use Magento\Customer\Api\AddressRepositoryInterface; +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Api\Data\AddressInterface; +use Magento\Quote\Api\Data\AddressInterfaceFactory; +use Magento\Quote\Api\Data\CartInterface; +use Magento\Quote\Api\Data\CartInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer.php'); +Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_address.php'); +Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_duplicated.php'); + +$objectManager = Bootstrap::getObjectManager(); +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->get(ProductRepositoryInterface::class); +$productRepository->cleanCache(); +/** @var CartRepositoryInterface $quoteRepository */ +$quoteRepository = $objectManager->get(CartRepositoryInterface::class); +/** @var AddressInterface $quoteShippingAddress */ +$quoteShippingAddress = $objectManager->get(AddressInterfaceFactory::class)->create(); +/** @var CustomerRepositoryInterface $customerRepository */ +$customerRepository = $objectManager->get(CustomerRepositoryInterface::class); +/** @var AddressRepositoryInterface $addressRepository */ +$addressRepository = $objectManager->get(AddressRepositoryInterface::class); +$quoteShippingAddress->importCustomerAddressData($addressRepository->getById(1)); +$customer = $customerRepository->getById(1); + +/** @var CartInterface $quote */ +$quote = $objectManager->get(CartInterfaceFactory::class)->create(); +$quote->setStoreId(1) + ->setIsActive(true) + ->setIsMultiShipping(0) + ->assignCustomerWithAddressChange($customer) + ->setShippingAddress($quoteShippingAddress) + ->setBillingAddress($quoteShippingAddress) + ->setCheckoutMethod(Onepage::METHOD_CUSTOMER) + ->setReservedOrderId('55555555') + ->setEmail($customer->getEmail()); +$quote->addProduct($productRepository->get('simple-1'), 55); +$quote->getShippingAddress()->setShippingMethod('flatrate_flatrate'); +$quote->getShippingAddress()->setCollectShippingRates(true); +$quote->getShippingAddress()->collectShippingRates(); +$quote->getPayment()->setMethod('checkmo'); +$quoteRepository->save($quote); diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/customer_quote_ready_for_order_rollback.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/customer_quote_ready_for_order_rollback.php new file mode 100644 index 0000000000000..a599d008cf89c --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/customer_quote_ready_for_order_rollback.php @@ -0,0 +1,26 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +$objectManager = Bootstrap::getObjectManager(); +/** @var CartRepositoryInterface $quoteRepository */ +$quoteRepository = $objectManager->get(CartRepositoryInterface::class); +/** @var GetQuoteByReservedOrderId $getQuoteByReservedOrderId */ +$getQuoteByReservedOrderId = $objectManager->get(GetQuoteByReservedOrderId::class); +$quote = $getQuoteByReservedOrderId->execute('55555555'); +if ($quote) { + $quoteRepository->delete($quote); +} + +Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_duplicated_rollback.php'); +Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_duplicated_rollback.php'); +Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_address_rollback.php'); +Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php'); diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/ReorderTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/ReorderTest.php new file mode 100644 index 0000000000000..cffdda80cc897 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/ReorderTest.php @@ -0,0 +1,139 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Controller\Guest; + +use Magento\Checkout\Model\Session as CheckoutSession; +use Magento\Customer\Model\Session; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Message\MessageInterface; +use Magento\Framework\Stdlib\CookieManagerInterface; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\Sales\Helper\Guest; +use Magento\TestFramework\Request; +use Magento\TestFramework\TestCase\AbstractController; + +/** + * Test for guest reorder controller. + * + * @see \Magento\Sales\Controller\Guest\Reorder + * @magentoAppArea frontend + * @magentoDbIsolation enabled + */ +class ReorderTest extends AbstractController +{ + /** @var CheckoutSession */ + private $checkoutSession; + + /** @var OrderInterfaceFactory */ + private $orderFactory; + + /** @var CookieManagerInterface */ + private $cookieManager; + + /** @var Session */ + private $customerSession; + + /** @var CartRepositoryInterface */ + private $quoteRepository; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->checkoutSession = $this->_objectManager->get(CheckoutSession::class); + $this->orderFactory = $this->_objectManager->get(OrderInterfaceFactory::class); + $this->cookieManager = $this->_objectManager->get(CookieManagerInterface::class); + $this->customerSession = $this->_objectManager->get(Session::class); + $this->quoteRepository = $this->_objectManager->get(CartRepositoryInterface::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $createdQuoteId = $this->checkoutSession->getQuoteId(); + + if ($createdQuoteId !== null) { + try { + $this->quoteRepository->delete($this->quoteRepository->get($createdQuoteId)); + } catch (NoSuchEntityException $e) { + //already deleted + } + } + + $this->customerSession->setCustomerId(null); + + parent::tearDown(); + } + + /** + * @magentoDbIsolation disabled + * + * @magentoDataFixture Magento/Sales/_files/order_by_guest_with_simple_product.php + * + * @return void + */ + public function testReorderSimpleProduct(): void + { + $orderIncrementId = 'test_order_1'; + $order = $this->orderFactory->create()->loadByIncrementId($orderIncrementId); + $cookieValue = base64_encode($order->getProtectCode() . ':' . $orderIncrementId); + $this->cookieManager->setPublicCookie(Guest::COOKIE_NAME, $cookieValue); + $this->dispatchReorderRequest(); + $this->assertRedirect($this->stringContains('checkout/cart')); + $quoteId = $this->checkoutSession->getQuoteId(); + $this->assertNotNull($quoteId); + $quoteItemsCollection = $this->quoteRepository->get((int)$quoteId)->getItemsCollection(); + $this->assertCount(1, $quoteItemsCollection); + $this->assertEquals( + $order->getItemsCollection()->getFirstItem()->getSku(), + $quoteItemsCollection->getFirstItem()->getSku() + ); + } + + /** + * @return void + */ + public function testReorderWithoutParamsAndCookie(): void + { + $this->dispatchReorderRequest(); + $this->assertRedirect($this->stringContains('sales/guest/form')); + $this->assertSessionMessages( + $this->containsEqual((string)__('You entered incorrect data. Please try again.')), + MessageInterface::TYPE_ERROR + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * + * @return void + */ + public function testReorderGuestOrderByCustomer(): void + { + $this->customerSession->setCustomerId(1); + $this->dispatchReorderRequest(); + $this->assertRedirect($this->stringContains('sales/order/history')); + } + + /** + * Dispatch reorder request. + * + * @return void + */ + private function dispatchReorderRequest(): void + { + $this->getRequest()->setMethod(Request::METHOD_POST); + $this->dispatch('sales/guest/reorder/'); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Order/ReorderTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Order/ReorderTest.php new file mode 100644 index 0000000000000..647dc557485d2 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Order/ReorderTest.php @@ -0,0 +1,139 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Controller\Order; + +use Magento\Checkout\Model\Session as CheckoutSession; +use Magento\Customer\Model\Session; +use Magento\Framework\Escaper; +use Magento\Framework\Message\MessageInterface; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Api\Data\CartInterface; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\TestFramework\Request; +use Magento\TestFramework\TestCase\AbstractController; + +/** + * Test for reorder controller. + * + * @see \Magento\Sales\Controller\Order\Reorder + * @magentoAppArea frontend + * @magentoDbIsolation enabled + */ +class ReorderTest extends AbstractController +{ + /** @var CheckoutSession */ + private $checkoutSession; + + /** @var OrderInterfaceFactory */ + private $orderFactory; + + /** @var Session */ + private $customerSession; + + /** @var CartRepositoryInterface */ + private $quoteRepository; + + /** @var CartInterface */ + private $quote; + + /** @var Escaper */ + private $escaper; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->checkoutSession = $this->_objectManager->get(CheckoutSession::class); + $this->orderFactory = $this->_objectManager->get(OrderInterfaceFactory::class); + $this->customerSession = $this->_objectManager->get(Session::class); + $this->quoteRepository = $this->_objectManager->get(CartRepositoryInterface::class); + $this->escaper = $this->_objectManager->get(Escaper::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + if ($this->quote instanceof CartInterface) { + $this->quoteRepository->delete($this->quote); + } + $this->customerSession->setCustomerId(null); + + parent::tearDown(); + } + + /** + * @magentoDataFixture Magento/Sales/_files/customer_order_with_taxable_product.php + * + * @return void + */ + public function testReorder(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('test_order_with_taxable_product'); + $this->customerSession->setCustomerId($order->getCustomerId()); + $this->dispatchReorderRequest((int)$order->getId()); + $this->assertRedirect($this->stringContains('checkout/cart')); + $this->quote = $this->checkoutSession->getQuote(); + $quoteItemsCollection = $this->quote->getItemsCollection(); + $this->assertCount(1, $quoteItemsCollection); + $this->assertEquals( + $order->getItemsCollection()->getFirstItem()->getSku(), + $quoteItemsCollection->getFirstItem()->getSku() + ); + } + + /** + * @magentoDataFixture Magento/Sales/_files/customer_order_with_simple_product.php + * + * @return void + */ + public function testReorderProductLowQty(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('55555555'); + $this->customerSession->setCustomerId($order->getCustomerId()); + $this->dispatchReorderRequest((int)$order->getId()); + $origMessage = (string)__('The requested qty is not available'); + $message = $this->escaper->escapeHtml( + __('Could not add the product with SKU "%1" to the shopping cart: %2', 'simple-1', $origMessage) + ); + $constraint = $this->logicalOr($this->containsEqual($origMessage), $this->containsEqual($message)); + $this->assertThat($this->getMessages(MessageInterface::TYPE_ERROR), $constraint); + $this->quote = $this->checkoutSession->getQuote(); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Sales/_files/customer_order_with_two_items.php + * + * @return void + */ + public function testReorderByAnotherCustomer(): void + { + $this->customerSession->setCustomerId(1); + $order = $this->orderFactory->create()->loadByIncrementId('100000555'); + $this->dispatchReorderRequest((int)$order->getId()); + $this->assertRedirect($this->stringContains('sales/order/history')); + } + + /** + * Dispatch reorder request. + * + * @param null|int $orderId + * @return void + */ + private function dispatchReorderRequest(?int $orderId = null): void + { + $this->getRequest()->setMethod(Request::METHOD_POST); + $this->getRequest()->setParam('order_id', $orderId); + $this->dispatch('sales/order/reorder/'); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Helper/ReorderTest.php b/dev/tests/integration/testsuite/Magento/Sales/Helper/ReorderTest.php new file mode 100644 index 0000000000000..5a21f551ff1a7 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Helper/ReorderTest.php @@ -0,0 +1,106 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Helper; + +use Magento\Customer\Model\Session; +use Magento\Framework\ObjectManagerInterface; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Test for reorder helper. + * + * @see \Magento\Sales\Helper\Reorder + * @magentoDbIsolation enabled + */ +class ReorderTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Reorder */ + private $helper; + + /** @var OrderInterfaceFactory */ + private $orderFactory; + + /** @var Session */ + private $customerSession; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->helper = $this->objectManager->get(Reorder::class); + $this->orderFactory = $this->objectManager->get(OrderInterfaceFactory::class); + $this->customerSession = $this->objectManager->get(Session::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->customerSession->setCustomerId(null); + + parent::tearDown(); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order.php + * + * @return void + */ + public function testCanReorderForGuest(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $this->assertTrue($this->helper->canReorder($order->getId())); + } + + /** + * @magentoDataFixture Magento/Sales/_files/customer_order_with_two_items.php + * + * @return void + */ + public function testCanReorderForLoggedCustomer(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000555'); + $this->customerSession->setCustomerId($order->getCustomerId()); + $this->assertTrue($this->helper->canReorder($order->getId())); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoDataFixture Magento/Sales/_files/order_state_hold.php + * + * @return void + */ + public function testCanReorderHoldOrderForLoggedCustomer(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $this->customerSession->setCustomerId(1); + $this->assertFalse($this->helper->canReorder($order->getId())); + } + + /** + * @magentoConfigFixture current_store sales/reorder/allow 0 + * @magentoDataFixture Magento/Sales/_files/order.php + * + * @return void + */ + public function testCanReorderConfigDisabled(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $this->assertFalse($this->helper->canReorder($order->getId())); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_simple_product.php b/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_simple_product.php new file mode 100644 index 0000000000000..ca102b0fabf89 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_simple_product.php @@ -0,0 +1,22 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Quote\Api\CartManagementInterface; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +Resolver::getInstance()->requireDataFixture('Magento/Checkout/_files/customer_quote_ready_for_order.php'); + +$objectManager = Bootstrap::getObjectManager(); +/** @var CartRepositoryInterface $quoteRepository */ +$quoteRepository = $objectManager->get(CartRepositoryInterface::class); +/** @var CartManagementInterface $quoteManagement */ +$quoteManagement = $objectManager->get(CartManagementInterface::class); + +$quote = $quoteRepository->getActiveForCustomer(1); +$quoteManagement->placeOrder($quote->getId()); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_simple_product_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_simple_product_rollback.php new file mode 100644 index 0000000000000..46cabc2e3fd9b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_simple_product_rollback.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Framework\Registry; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +$objectManager = Bootstrap::getObjectManager(); +/** @var Registry $registry */ +$registry = $objectManager->get(Registry::class); +/** @var OrderRepositoryInterface $orderRepository */ +$orderRepository = $objectManager->get(OrderRepositoryInterface::class); +/** @var OrderInterfaceFactory $orderFactory */ +$orderFactory = $objectManager->get(OrderInterfaceFactory::class); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +$order = $orderFactory->create()->loadByIncrementId('55555555'); +if ($order->getId()) { + $orderRepository->delete($order); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); + +Resolver::getInstance()->requireDataFixture('Magento/Checkout/_files/customer_quote_ready_for_order_rollback.php'); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_taxable_product.php b/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_taxable_product.php new file mode 100644 index 0000000000000..59ec4182ac870 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_taxable_product.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Quote\Api\CartManagementInterface; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Api\Data\PaymentInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +Resolver::getInstance()->requireDataFixture('Magento/Checkout/_files/quote_with_taxable_product_and_customer.php'); + +$objectManager = Bootstrap::getObjectManager(); +/** @var CartRepositoryInterface $quoteRepository */ +$quoteRepository = $objectManager->get(CartRepositoryInterface::class); +/** @var CartManagementInterface $quoteManagement */ +$quoteManagement = $objectManager->get(CartManagementInterface::class); +/** @var PaymentInterface $payment */ +$payment = $objectManager->get(PaymentInterface::class); +$payment->setMethod('checkmo'); + +$quote = $quoteRepository->getActiveForCustomer(1); +$quote->getShippingAddress()->setShippingMethod('flatrate_flatrate'); +$quote->getShippingAddress()->setCollectShippingRates(true); +$quote->getShippingAddress()->collectShippingRates(); +$quoteRepository->save($quote); +$quoteManagement->placeOrder($quote->getId(), $payment); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_taxable_product_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_taxable_product_rollback.php new file mode 100644 index 0000000000000..d42f6a1140286 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/customer_order_with_taxable_product_rollback.php @@ -0,0 +1,35 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Framework\Registry; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +$objectManager = Bootstrap::getObjectManager(); +/** @var Registry $registry */ +$registry = $objectManager->get(Registry::class); +/** @var OrderRepositoryInterface $orderRepository */ +$orderRepository = $objectManager->get(OrderRepositoryInterface::class); +/** @var OrderInterfaceFactory $orderFactory */ +$orderFactory = $objectManager->get(OrderInterfaceFactory::class); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +$order = $orderFactory->create()->loadByIncrementId('test_order_with_taxable_product'); +if ($order->getId()) { + $orderRepository->delete($order); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); + +Resolver::getInstance()->requireDataFixture( + 'Magento/Checkout/_files/quote_with_taxable_product_and_customer_rollback.php' +); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_by_guest_with_simple_product.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_by_guest_with_simple_product.php new file mode 100644 index 0000000000000..c3bab9acca27b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_by_guest_with_simple_product.php @@ -0,0 +1,31 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Quote\Api\CartManagementInterface; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Api\Data\PaymentInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +Resolver::getInstance()->requireDataFixture('Magento/Checkout/_files/quote_with_address_saved.php'); + +$objectManager = Bootstrap::getObjectManager(); +/** @var CartRepositoryInterface $quoteRepository */ +$quoteRepository = $objectManager->get(CartRepositoryInterface::class); +/** @var CartManagementInterface $quoteManagement */ +$quoteManagement = $objectManager->get(CartManagementInterface::class); +/** @var PaymentInterface $payment */ +$payment = $objectManager->get(PaymentInterface::class); + +$quote = $objectManager->get(GetQuoteByReservedOrderId::class)->execute('test_order_1'); +$quote->getShippingAddress()->setShippingMethod('flatrate_flatrate'); +$quote->getShippingAddress()->setCollectShippingRates(true); +$quote->getShippingAddress()->collectShippingRates(); +$quoteRepository->save($quote); +$payment->setMethod('checkmo'); +$quoteManagement->placeOrder($quote->getId(), $payment); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_by_guest_with_simple_product_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_by_guest_with_simple_product_rollback.php new file mode 100644 index 0000000000000..b4ec514d1311e --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_by_guest_with_simple_product_rollback.php @@ -0,0 +1,33 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Framework\Registry; +use Magento\Sales\Api\Data\OrderInterfaceFactory; +use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +$objectManager = Bootstrap::getObjectManager(); +/** @var Registry $registry */ +$registry = $objectManager->get(Registry::class); +/** @var OrderRepositoryInterface $orderRepository */ +$orderRepository = $objectManager->get(OrderRepositoryInterface::class); +/** @var OrderInterfaceFactory $orderFactory */ +$orderFactory = $objectManager->get(OrderInterfaceFactory::class); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +$order = $orderFactory->create()->loadByIncrementId('test_order_1'); +if ($order->getId()) { + $orderRepository->delete($order); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); + +Resolver::getInstance()->requireDataFixture('Magento/Checkout/_files/quote_with_address_saved_rollback.php'); From 6e0864065b760a1aa72d53a6d453c299f9c50e87 Mon Sep 17 00:00:00 2001 From: Yurii Sapiha <yurasapiga93@gmail.com> Date: Tue, 1 Sep 2020 13:44:50 +0300 Subject: [PATCH 38/99] MC-37263: View and edit shopping cart --- .../_files/inactive_quote_with_customer.php | 39 +++ .../inactive_quote_with_customer_rollback.php | 24 ++ .../Adminhtml/Order/Create/Items/GridTest.php | 69 ++++ .../Order/Create/Sidebar/CartTest.php | 80 +++++ .../Adminhtml/Order/Create/LoadBlockTest.php | 301 ++++++++++++++++++ 5 files changed, 513 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Checkout/_files/inactive_quote_with_customer.php create mode 100644 dev/tests/integration/testsuite/Magento/Checkout/_files/inactive_quote_with_customer_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Items/GridTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/CartTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlockTest.php diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/inactive_quote_with_customer.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/inactive_quote_with_customer.php new file mode 100644 index 0000000000000..c74e76f74115f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/inactive_quote_with_customer.php @@ -0,0 +1,39 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Checkout\Model\Type\Onepage; +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Api\Data\CartInterface; +use Magento\Quote\Api\Data\CartInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer.php'); +Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/taxable_simple_product.php'); + +$objectManager = Bootstrap::getObjectManager(); +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->get(ProductRepositoryInterface::class); +$productRepository->cleanCache(); +/** @var CartRepositoryInterface $quoteRepository */ +$quoteRepository = $objectManager->get(CartRepositoryInterface::class); +/** @var CustomerRepositoryInterface $customerRepository */ +$customerRepository = $objectManager->get(CustomerRepositoryInterface::class); +$customer = $customerRepository->get('customer@example.com'); + +/** @var CartInterface $quote */ +$quote = $objectManager->get(CartInterfaceFactory::class)->create(); +$quote->setStoreId(1) + ->setIsActive(false) + ->setIsMultiShipping(0) + ->setCustomer($customer) + ->setCheckoutMethod(Onepage::METHOD_CUSTOMER) + ->setReservedOrderId('test_order_with_customer_inactive_quote') + ->addProduct($productRepository->get('taxable_product'), 1); +$quoteRepository->save($quote); diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/inactive_quote_with_customer_rollback.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/inactive_quote_with_customer_rollback.php new file mode 100644 index 0000000000000..d45cbb547d29d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/inactive_quote_with_customer_rollback.php @@ -0,0 +1,24 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +$objectManager = Bootstrap::getObjectManager(); +/** @var CartRepositoryInterface $quoteRepository */ +$quoteRepository = $objectManager->get(CartRepositoryInterface::class); +/** @var GetQuoteByReservedOrderId $getQuoteByReservedOrderId */ +$getQuoteByReservedOrderId = $objectManager->get(GetQuoteByReservedOrderId::class); +$quote = $getQuoteByReservedOrderId->execute('test_order_with_customer_inactive_quote'); +if ($quote !== null) { + $quoteRepository->delete($quote); +} + +Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/taxable_simple_product_rollback.php'); +Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php'); diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Items/GridTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Items/GridTest.php new file mode 100644 index 0000000000000..b26b71803848f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Items/GridTest.php @@ -0,0 +1,69 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Block\Adminhtml\Order\Create\Items; + +use Magento\Backend\Model\Session\Quote; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\LayoutInterface; +use Magento\Sales\Block\Adminhtml\Order\Create\Items; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId; +use PHPUnit\Framework\TestCase; + +/** + * Checks order items grid + * + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ +class GridTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var LayoutInterface */ + private $layout; + + /** @var Grid */ + private $block; + + /** @var Quote */ + private $session; + + /** @var GetQuoteByReservedOrderId */ + private $getQuoteByReservedOrderId; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->getQuoteByReservedOrderId = $this->objectManager->get(GetQuoteByReservedOrderId::class); + $this->session = $this->objectManager->get(Quote::class); + $this->layout = $this->objectManager->get(LayoutInterface::class); + $this->block = $this->layout->createBlock(Grid::class); + $this->layout->createBlock(Items::class)->setChild('items_grid', $this->block); + } + + /** + * @magentoDataFixture Magento/Checkout/_files/quote_with_customer_without_address.php + * + * @return void + */ + public function testGetItems(): void + { + $quote = $this->getQuoteByReservedOrderId->execute('test_order_with_customer_without_address'); + $this->session->setQuoteId($quote->getId()); + $items = $this->block->getItems(); + $this->assertCount(1, $items); + $this->assertEquals('simple2', reset($items)->getSku()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/CartTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/CartTest.php new file mode 100644 index 0000000000000..291fda6e2494f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/CartTest.php @@ -0,0 +1,80 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Block\Adminhtml\Order\Create\Sidebar; + +use Magento\Backend\Model\Session\Quote; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\LayoutInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Check sidebar shopping cart section block + * + * @see \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\Cart + * + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ +class CartTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Cart */ + private $block; + + /** @var Quote */ + private $session; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Cart::class); + $this->session = $this->objectManager->get(Quote::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->session->clearStorage(); + + parent::tearDown(); + } + + /** + * @magentoDataFixture Magento/Checkout/_files/quote_with_customer_without_address.php + * + * @return void + */ + public function testGetItemCollection(): void + { + $this->session->setCustomerId(1); + $items = $this->block->getItemCollection(); + $this->assertCount(1, $items); + $this->assertEquals('simple2', reset($items)->getSku()); + } + + /** + * @return void + */ + public function testClearShoppingCartButton(): void + { + $confirmation = __('Are you sure you want to delete all items from shopping cart?'); + $button = $this->block->getChildBlock('empty_customer_cart_button'); + $this->assertEquals(sprintf("order.clearShoppingCart('%s')", $confirmation), $button->getOnclick()); + $this->assertEquals(__('Clear Shopping Cart'), $button->getLabel()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlockTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlockTest.php new file mode 100644 index 0000000000000..b6aa44bac1c4d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlockTest.php @@ -0,0 +1,301 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Sales\Controller\Adminhtml\Order\Create; + +use Magento\Backend\Model\Session\Quote; +use Magento\Framework\App\Request\Http; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\View\LayoutInterface; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Api\Data\CartInterface; +use Magento\Store\Model\StoreManagerInterface; +use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId; +use Magento\TestFramework\TestCase\AbstractBackendController; + +/** + * Class checks create order load block controller. + * + * @see \Magento\Sales\Controller\Adminhtml\Order\Create\LoadBlock + * + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ +class LoadBlockTest extends AbstractBackendController +{ + /** @var LayoutInterface */ + private $layout; + + /** @var GetQuoteByReservedOrderId */ + private $getQuoteByReservedOrderId; + + /** @var Quote */ + private $session; + + /** @var CartRepositoryInterface */ + private $quoteRepository; + + /** @var StoreManagerInterface */ + private $storeManager; + + /** @var array */ + private $quoteIdsToRemove; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->layout = $this->_objectManager->get(LayoutInterface::class); + $this->getQuoteByReservedOrderId = $this->_objectManager->get(GetQuoteByReservedOrderId::class); + $this->session = $this->_objectManager->get(Quote::class); + $this->quoteRepository = $this->_objectManager->get(CartRepositoryInterface::class); + $this->storeManager = $this->_objectManager->get(StoreManagerInterface::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->quoteIdsToRemove[] = $this->session->getQuote()->getId(); + foreach ($this->quoteIdsToRemove as $quoteId) { + try { + $this->quoteRepository->delete($this->quoteRepository->get($quoteId)); + } catch (NoSuchEntityException $e) { + //do nothing + } + } + + $this->session->clearStorage(); + + parent::tearDown(); + } + + /** + * @dataProvider responseFlagsProvider + * + * @magentoDataFixture Magento/Checkout/_files/quote_with_customer_without_address.php + * + * @param bool $asJson + * @param bool $asJsVarname + * @return void + */ + public function testAddProductToOrderFromShoppingCart(bool $asJson, bool $asJsVarname): void + { + $oldQuote = $this->getQuoteByReservedOrderId->execute('test_order_with_customer_without_address'); + $params = $this->hydrateParams([ + 'json' => $asJson, + 'as_js_varname' => $asJsVarname, + ]); + $post = $this->hydratePost([ + 'sidebar' => [ + 'add_cart_item' => [ + $oldQuote->getItemsCollection()->getFirstItem()->getId() => 1, + ], + ], + ]); + + $this->dispatchWitParams($params, $post); + + $this->checkHandles(explode(',', $params['block']), $asJson); + $this->checkQuotes($oldQuote, 'simple2'); + + if ($asJsVarname) { + $this->assertRedirect($this->stringContains('sales/order_create/showUpdateResult')); + } + } + + /** + * @return array + */ + public function responseFlagsProvider(): array + { + return [ + 'as_json' => [ + 'as_json' => true, + 'as_js_varname' => false, + ], + 'as_plain' => [ + 'as_json' => false, + 'as_js_varname' => true, + ], + ]; + } + + /** + * @magentoDataFixture Magento/Checkout/_files/quote_with_customer_without_address.php + * + * @return void + */ + public function testRemoveProductFromShoppingCart(): void + { + $oldQuote = $this->getQuoteByReservedOrderId->execute('test_order_with_customer_without_address'); + $post = $this->hydratePost([ + 'sidebar' => [ + 'remove' => [ + $oldQuote->getItemsCollection()->getFirstItem()->getId() => 'cart', + ], + ], + ]); + $params = $this->hydrateParams(); + + $this->dispatchWitParams($params, $post); + + $this->checkHandles(explode(',', $params['block'])); + $this->checkQuotes($oldQuote); + } + + /** + * @magentoDataFixture Magento/Checkout/_files/quote_with_customer_without_address.php + * + * @return void + */ + public function testClearShoppingCart(): void + { + $quote = $this->getQuoteByReservedOrderId->execute('test_order_with_customer_without_address'); + $post = $this->hydratePost([ + 'sidebar' => [ + 'empty_customer_cart' => '1', + ], + ]); + $params = $this->hydrateParams(); + + $this->dispatchWitParams($params, $post); + + $this->checkHandles(explode(',', $params['block'])); + $this->assertEmpty($quote->getItemsCollection(false)->getItems()); + } + + /** + * @magentoDataFixture Magento/Checkout/_files/inactive_quote_with_customer.php + * + * @return void + */ + public function testMoveFromOrderToShoppingCart(): void + { + $quote = $this->getQuoteByReservedOrderId->execute('test_order_with_customer_inactive_quote'); + $this->session->setQuoteId($quote->getId()); + $post = $this->hydratePost([ + 'update_items' => '1', + 'item' => [ + $quote->getItemsCollection()->getFirstItem()->getId() => [ + 'qty' => '1', + 'use_discount' => '1', + 'action' => 'cart', + ], + ], + ]); + $params = $this->hydrateParams(['blocks' => null]); + $this->dispatchWitParams($params, $post); + $customerCart = $this->quoteRepository->getForCustomer(1); + $cartItems = $customerCart->getItemsCollection(); + $this->assertCount(1, $cartItems->getItems()); + $this->assertEquals('taxable_product', $cartItems->getFirstItem()->getSku()); + $this->quoteIdsToRemove[] = $customerCart->getId(); + } + + /** + * Check customer quotes + * + * @param CartInterface $oldQuote + * @param string|null $expectedSku + * @return void + */ + private function checkQuotes(CartInterface $oldQuote, ?string $expectedSku = null): void + { + $newQuote = $this->session->getQuote(); + $oldQuoteItemCollection = $oldQuote->getItemsCollection(false); + $this->assertEmpty($oldQuoteItemCollection->getItems()); + $newQuoteItemsCollection = $newQuote->getItemsCollection(false); + + if ($expectedSku !== null) { + $this->assertNotNull($newQuoteItemsCollection->getItemByColumnValue('sku', $expectedSku)); + } else { + $this->assertEmpty($newQuoteItemsCollection->getItems()); + } + } + + /** + * Check that all required handles were applied + * + * @param array $blocks + * @param bool $asJson + * @return void + */ + private function checkHandles(array $blocks, bool $asJson = true): void + { + $handles = $this->layout->getUpdate()->getHandles(); + + if ($asJson) { + $this->assertContains('sales_order_create_load_block_message', $handles); + $this->assertContains('sales_order_create_load_block_json', $handles); + } else { + $this->assertContains('sales_order_create_load_block_plain', $handles); + } + + foreach ($blocks as $block) { + $this->assertContains( + 'sales_order_create_load_block_' . $block, + $handles + ); + } + } + + /** + * Fill post params array to proper state + * + * @param array $inputArray + * @return array + */ + private function hydratePost(array $inputArray = []): array + { + return array_merge( + [ + 'customer_id' => 1, + 'store_id' => $this->storeManager->getStore('default')->getId(), + 'sidebar' => [], + ], + $inputArray + ); + } + + /** + * Fill params array to proper state + * + * @param array $inputArray + * @return array + */ + private function hydrateParams(array $inputArray = []): array + { + return array_merge( + [ + 'json' => true, + 'block' => 'sidebar,items,shipping_method,billing_method,totals,giftmessage', + 'as_js_varname' => true, + ], + $inputArray + ); + } + + /** + * Dispatch request with params + * + * @param array $params + * @param array $postParams + * @return void + */ + private function dispatchWitParams(array $params, array $postParams): void + { + $this->getRequest()->setMethod(Http::METHOD_POST) + ->setPostValue($postParams) + ->setParams($params); + $this->dispatch('backend/sales/order_create/loadBlock'); + } +} From 51b77f09bb2d5d1279bf7f12f63cdb580fd9689c Mon Sep 17 00:00:00 2001 From: Roman Lytvynenko <lytvynen@adobe.com> Date: Tue, 1 Sep 2020 06:32:01 -0500 Subject: [PATCH 39/99] MC-36978: Invalid Character Customer Account Create DOB --- .../app/code/Magento/Customer/frontend/js/validation.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js index df1fb609f8bda..c830632ed0e87 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/validation.test.js @@ -24,7 +24,7 @@ define([ format: 'M/DD/Y', date: '09/2/18', expects: false - }, + } ]; dataProvider.forEach(function (data) { From 7f311a3a4c72de571f1baca61f28800299f6ede2 Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Wed, 2 Sep 2020 12:53:42 +0300 Subject: [PATCH 40/99] Set action Group as deprecation --- .../AdminOpenCmsPageActionGroup.xml | 3 +++ .../AdminOpentCmsBlockActionGroup.xml | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpenCmsPageActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpenCmsPageActionGroup.xml index 7e907b5b395a4..68eca3b429e2b 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpenCmsPageActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpenCmsPageActionGroup.xml @@ -8,6 +8,9 @@ <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> <actionGroup name="AdminOpenCmsPageActionGroup"> + <annotations> + <description>Open CMS edit page.</description> + </annotations> <arguments> <argument name="page_id" type="string"/> </arguments> diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml new file mode 100644 index 0000000000000..29e100a7e9c37 --- /dev/null +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminOpenCmsBlockActionGroup"> + <annotations> + <description>DEPRECATED. Use AdminOpenCmsPageActionGroup instead.</description> + </annotations> + <arguments> + <argument name="block_id" type="string"/> + </arguments> + <amOnPage url="{{AdminEditBlockPage.url(block_id)}}" stepKey="openEditCmsBlock"/> + </actionGroup> +</actionGroups> From 216c3376c0d90bb5ea0410ae01e68882c1ef1be9 Mon Sep 17 00:00:00 2001 From: IvanPletnyov <ivan.pletnyov@transoftgroup.com> Date: Wed, 2 Sep 2020 15:55:48 +0300 Subject: [PATCH 41/99] MC-37315: Customer configuration: Persistent shopping cart --- .../Persistent/Block/Form/RememberTest.php | 108 ++++++++++++ .../Magento/Persistent/Helper/SessionTest.php | 80 +++++++++ .../Checkout/ConfigProviderPluginTest.php | 160 ++++++++++++++++++ .../Model/CheckoutConfigProviderTest.php | 84 +++++++++ .../Persistent/Model/QuoteManagerTest.php | 116 +++++++++++++ ...nchronizePersistentOnLoginObserverTest.php | 142 +++++++++++----- ...chronizePersistentOnLogoutObserverTest.php | 77 ++++++--- .../Persistent/_files/persistent_rollback.php | 11 ++ ...sistent_with_customer_quote_and_cookie.php | 19 +++ ...ith_customer_quote_and_cookie_rollback.php | 17 ++ 10 files changed, 740 insertions(+), 74 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Persistent/Block/Form/RememberTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Persistent/Helper/SessionTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Persistent/Model/Checkout/ConfigProviderPluginTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Persistent/Model/CheckoutConfigProviderTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Persistent/Model/QuoteManagerTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Persistent/_files/persistent_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Persistent/_files/persistent_with_customer_quote_and_cookie.php create mode 100644 dev/tests/integration/testsuite/Magento/Persistent/_files/persistent_with_customer_quote_and_cookie_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Block/Form/RememberTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Block/Form/RememberTest.php new file mode 100644 index 0000000000000..ca1f309c5cc9b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Persistent/Block/Form/RememberTest.php @@ -0,0 +1,108 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Persistent\Block\Form; + +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\LayoutInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + +/** + * Test for remember me checkbox on create customer account page + * + * @see \Magento\Persistent\Block\Form\Remember + * @magentoAppArea frontend + */ +class RememberTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Remember */ + private $block; + + /** + * @inheritdoc + */ + public function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Remember::class) + ->setTemplate('Magento_Persistent::remember_me.phtml'); + } + + /** + * @magentoConfigFixture current_store persistent/options/enabled 1 + * @magentoConfigFixture current_store persistent/options/remember_enabled 1 + * @magentoConfigFixture current_store persistent/options/remember_default 0 + * + * @return void + */ + public function testRememberMeEnabled(): void + { + $this->assertFalse($this->block->isRememberMeChecked()); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + '//input[@name="persistent_remember_me"]/following-sibling::label/span[contains(text(), "%s")]', + __('Remember Me') + ), + $this->block->toHtml() + ), + 'Remember Me checkbox wasn\'t found.' + ); + } + + /** + * @magentoConfigFixture current_store persistent/options/enabled 1 + * @magentoConfigFixture current_store persistent/options/remember_enabled 1 + * @magentoConfigFixture current_store persistent/options/remember_default 1 + * + * @return void + */ + public function testRememberMeAndRememberDefaultEnabled(): void + { + $this->assertTrue($this->block->isRememberMeChecked()); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath( + sprintf( + '//input[@name="persistent_remember_me"]/following-sibling::label/span[contains(text(), "%s")]', + __('Remember Me') + ), + $this->block->toHtml() + ), + 'Remember Me checkbox wasn\'t found or not checked by default.' + ); + } + + /** + * @magentoConfigFixture current_store persistent/options/enabled 0 + * + * @return void + */ + public function testPersistentDisabled(): void + { + $this->assertEmpty($this->block->toHtml()); + } + + /** + * @magentoConfigFixture current_store persistent/options/enabled 1 + * @magentoConfigFixture current_store persistent/options/remember_enabled 0 + * + * @return void + */ + public function testRememberMeDisabled(): void + { + $this->assertEmpty($this->block->toHtml()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Helper/SessionTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Helper/SessionTest.php new file mode 100644 index 0000000000000..16ce015d89ecd --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Persistent/Helper/SessionTest.php @@ -0,0 +1,80 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Persistent\Helper; + +use Magento\Framework\ObjectManagerInterface; +use Magento\Persistent\Model\SessionFactory; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Test for persistent session helper + * + * @see \Magento\Persistent\Helper\Session + * @magentoDbIsolation enabled + * @magentoAppArea frontend + */ +class SessionTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Session */ + private $helper; + + /** @var SessionFactory */ + private $sessionFactory; + + /** + * @inheritdoc + */ + public function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->helper = $this->objectManager->get(Session::class); + $this->sessionFactory = $this->objectManager->get(SessionFactory::class); + } + + /** + * @magentoDataFixture Magento/Persistent/_files/persistent.php + * @magentoConfigFixture current_store persistent/options/enabled 1 + * + * @return void + */ + public function testPersistentEnabled(): void + { + $this->helper->setSession($this->sessionFactory->create()->loadByCustomerId(1)); + $this->assertTrue($this->helper->isPersistent()); + } + + /** + * @magentoDataFixture Magento/Persistent/_files/persistent.php + * @magentoConfigFixture current_store persistent/options/enabled 0 + * + * @return void + */ + public function testPersistentDisabled(): void + { + $this->helper->setSession($this->sessionFactory->create()->loadByCustomerId(1)); + $this->assertFalse($this->helper->isPersistent()); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoConfigFixture current_store persistent/options/enabled 1 + * + * @return void + */ + public function testCustomerWithoutPersistent(): void + { + $this->helper->setSession($this->sessionFactory->create()->loadByCustomerId(1)); + $this->assertFalse($this->helper->isPersistent()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Model/Checkout/ConfigProviderPluginTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Model/Checkout/ConfigProviderPluginTest.php new file mode 100644 index 0000000000000..803e1502e3ad9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Persistent/Model/Checkout/ConfigProviderPluginTest.php @@ -0,0 +1,160 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Persistent\Model\Checkout; + +use Magento\Customer\Model\Session as CustomerSession; +use Magento\Checkout\Model\DefaultConfigProvider; +use Magento\Checkout\Model\Session as CheckoutSession; +use Magento\Framework\ObjectManagerInterface; +use Magento\Persistent\Helper\Session as PersistentSessionHelper; +use Magento\Persistent\Model\Session as PersistentSession; +use Magento\Persistent\Model\SessionFactory as PersistentSessionFactory; +use Magento\Quote\Model\QuoteIdMask; +use Magento\Quote\Model\QuoteIdMaskFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Interception\PluginList; +use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId; +use PHPUnit\Framework\TestCase; + +/** + * Test for checkout config provider plugin + * + * @see \Magento\Persistent\Model\Checkout\ConfigProviderPlugin + * @magentoAppArea frontend + * @magentoDbIsolation enabled + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class ConfigProviderPluginTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var DefaultConfigProvider */ + private $configProvider; + + /** @var CustomerSession */ + private $customerSession; + + /** @var CheckoutSession */ + private $checkoutSession; + + /** @var QuoteIdMask */ + private $quoteIdMask; + + /** @var PersistentSessionHelper */ + private $persistentSessionHelper; + + /** @var PersistentSession */ + private $persistentSession; + + /** @var GetQuoteByReservedOrderId */ + private $getQuoteByReservedOrderId; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->configProvider = $this->objectManager->get(DefaultConfigProvider::class); + $this->customerSession = $this->objectManager->get(CustomerSession::class); + $this->checkoutSession = $this->objectManager->get(CheckoutSession::class); + $this->quoteIdMask = $this->objectManager->get(QuoteIdMaskFactory::class)->create(); + $this->persistentSessionHelper = $this->objectManager->get(PersistentSessionHelper::class); + $this->persistentSession = $this->objectManager->get(PersistentSessionFactory::class)->create(); + $this->getQuoteByReservedOrderId = $this->objectManager->get(GetQuoteByReservedOrderId::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->customerSession->setCustomerId(null); + $this->checkoutSession->clearQuote(); + $this->checkoutSession->setCustomerData(null); + $this->persistentSessionHelper->setSession(null); + + parent::tearDown(); + } + + /** + * @return void + */ + public function testPluginIsRegistered(): void + { + $pluginInfo = $this->objectManager->get(PluginList::class)->get(DefaultConfigProvider::class); + $this->assertSame(ConfigProviderPlugin::class, $pluginInfo['mask_quote_id_substitutor']['instance']); + } + + /** + * @magentoDataFixture Magento/Persistent/_files/persistent_with_customer_quote_and_cookie.php + * @magentoConfigFixture current_store persistent/options/enabled 1 + * + * @return void + */ + public function testWithNotLoggedCustomer(): void + { + $session = $this->persistentSession->loadByCustomerId(1); + $this->persistentSessionHelper->setSession($session); + $quote = $this->getQuoteByReservedOrderId->execute('test_order_with_customer_without_address'); + $this->checkoutSession->setQuoteId($quote->getId()); + $result = $this->configProvider->getConfig(); + $this->assertEquals( + $this->quoteIdMask->load($quote->getId(), 'quote_id')->getMaskedId(), + $result['quoteData']['entity_id'] + ); + } + + /** + * @magentoDataFixture Magento/Persistent/_files/persistent_with_customer_quote_and_cookie.php + * @magentoConfigFixture current_store persistent/options/enabled 1 + * + * @return void + */ + public function testWithLoggedCustomer(): void + { + $this->customerSession->setCustomerId(1); + $session = $this->persistentSession->loadByCustomerId(1); + $this->persistentSessionHelper->setSession($session); + $quote = $this->getQuoteByReservedOrderId->execute('test_order_with_customer_without_address'); + $this->checkoutSession->setQuoteId($quote->getId()); + $result = $this->configProvider->getConfig(); + $this->assertEquals($quote->getId(), $result['quoteData']['entity_id']); + } + + /** + * @magentoDataFixture Magento/Checkout/_files/quote_with_customer_without_address.php + * @magentoConfigFixture current_store persistent/options/enabled 0 + * + * @return void + */ + public function testPersistentDisabled(): void + { + $quote = $this->getQuoteByReservedOrderId->execute('test_order_with_customer_without_address'); + $this->checkoutSession->setQuoteId($quote->getId()); + $result = $this->configProvider->getConfig(); + $this->assertNull($result['quoteData']['entity_id']); + } + + /** + * @magentoDataFixture Magento/Checkout/_files/quote_with_customer_without_address.php + * @magentoConfigFixture current_store persistent/options/enabled 1 + * + * @return void + */ + public function testWithoutPersistentSession(): void + { + $quote = $this->getQuoteByReservedOrderId->execute('test_order_with_customer_without_address'); + $this->checkoutSession->setQuoteId($quote->getId()); + $result = $this->configProvider->getConfig(); + $this->assertNull($result['quoteData']['entity_id']); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Model/CheckoutConfigProviderTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Model/CheckoutConfigProviderTest.php new file mode 100644 index 0000000000000..176224bad7a1f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Persistent/Model/CheckoutConfigProviderTest.php @@ -0,0 +1,84 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Persistent\Model; + +use Magento\Framework\ObjectManagerInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Test for remember me checkbox on create customer account page. + * + * @see \Magento\Persistent\Model\CheckoutConfigProvider + */ +class CheckoutConfigProviderTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var CheckoutConfigProvider */ + private $model; + + /** + * @inheritdoc + */ + public function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->model = $this->objectManager->get(CheckoutConfigProvider::class); + } + + /** + * @magentoConfigFixture current_store persistent/options/enabled 1 + * @magentoConfigFixture current_store persistent/options/remember_enabled 1 + * @magentoConfigFixture current_store persistent/options/remember_default 1 + * + * @return void + */ + public function testRememberMeEnabled(): void + { + $expectedConfig = [ + 'persistenceConfig' => ['isRememberMeCheckboxVisible' => true, 'isRememberMeCheckboxChecked' => true], + ]; + $config = $this->model->getConfig(); + $this->assertEquals($expectedConfig, $config); + } + + /** + * @magentoConfigFixture current_store persistent/options/enabled 1 + * @magentoConfigFixture current_store persistent/options/remember_enabled 0 + * @magentoConfigFixture current_store persistent/options/remember_default 0 + * + * @return void + */ + public function testRememberMeDisabled(): void + { + $expectedConfig = [ + 'persistenceConfig' => ['isRememberMeCheckboxVisible' => false, 'isRememberMeCheckboxChecked' => false], + ]; + $config = $this->model->getConfig(); + $this->assertEquals($expectedConfig, $config); + } + + /** + * @magentoConfigFixture current_store persistent/options/enabled 0 + * @magentoConfigFixture current_store persistent/options/remember_default 0 + * + * @return void + */ + public function testPersistentDisabled(): void + { + $expectedConfig = [ + 'persistenceConfig' => ['isRememberMeCheckboxVisible' => false, 'isRememberMeCheckboxChecked' => false], + ]; + $config = $this->model->getConfig(); + $this->assertEquals($expectedConfig, $config); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Model/QuoteManagerTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Model/QuoteManagerTest.php new file mode 100644 index 0000000000000..e11d47af3e814 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Persistent/Model/QuoteManagerTest.php @@ -0,0 +1,116 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Persistent\Model; + +use Magento\Customer\Api\Data\GroupInterface; +use Magento\Checkout\Model\Session as CheckoutSession; +use Magento\Framework\ObjectManagerInterface; +use Magento\Persistent\Helper\Session as PersistentSessionHelper; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Api\Data\CartInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId; +use PHPUnit\Framework\TestCase; + +/** + * Test for persistent quote manager model + * + * @see \Magento\Persistent\Model\QuoteManager + * @magentoDbIsolation enabled + */ +class QuoteManagerTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var QuoteManager */ + private $model; + + /** @var CheckoutSession */ + private $checkoutSession; + + /** @var GetQuoteByReservedOrderId */ + private $getQuoteByReservedOrderId; + + /** @var PersistentSessionHelper */ + private $persistentSessionHelper; + + /** @var CartInterface */ + private $quote; + + /** @var CartRepositoryInterface */ + private $quoteRepository; + + /** + * @inheritdoc + */ + public function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->model = $this->objectManager->get(QuoteManager::class); + $this->checkoutSession = $this->objectManager->get(CheckoutSession::class); + $this->getQuoteByReservedOrderId = $this->objectManager->get(GetQuoteByReservedOrderId::class); + $this->persistentSessionHelper = $this->objectManager->get(PersistentSessionHelper::class); + $this->quoteRepository = $this->objectManager->get(CartRepositoryInterface::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->checkoutSession->clearQuote(); + $this->checkoutSession->setCustomerData(null); + if ($this->quote instanceof CartInterface) { + $this->quoteRepository->delete($this->quote); + } + + parent::tearDown(); + } + + /** + * @magentoDataFixture Magento/Persistent/_files/persistent_with_customer_quote_and_cookie.php + * @magentoConfigFixture current_store persistent/options/enabled 1 + * @magentoConfigFixture current_store persistent/options/shopping_cart 1 + * + * @return void + */ + public function testPersistentShoppingCartEnabled(): void + { + $customerQuote = $this->getQuoteByReservedOrderId->execute('test_order_with_customer_without_address'); + $this->checkoutSession->setQuoteId($customerQuote->getId()); + $this->model->setGuest(true); + $this->quote = $this->checkoutSession->getQuote(); + $this->assertNotEquals($customerQuote->getId(), $this->quote->getId()); + $this->assertFalse($this->model->isPersistent()); + $this->assertNull($this->quote->getCustomerId()); + $this->assertNull($this->quote->getCustomerEmail()); + $this->assertNull($this->quote->getCustomerFirstname()); + $this->assertNull($this->quote->getCustomerLastname()); + $this->assertEquals(GroupInterface::NOT_LOGGED_IN_ID, $this->quote->getCustomerGroupId()); + $this->assertEmpty($this->quote->getIsPersistent()); + $this->assertNull($this->persistentSessionHelper->getSession()->getId()); + } + + /** + * @magentoDataFixture Magento/Persistent/_files/persistent_with_customer_quote_and_cookie.php + * @magentoConfigFixture current_store persistent/options/enabled 1 + * @magentoConfigFixture current_store persistent/options/shopping_cart 0 + * + * @return void + */ + public function testPersistentShoppingCartDisabled(): void + { + $quote = $this->getQuoteByReservedOrderId->execute('test_order_with_customer_without_address'); + $this->checkoutSession->setQuoteId($quote->getId()); + $this->model->setGuest(true); + $this->assertNull($this->checkoutSession->getQuote()->getId()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Observer/SynchronizePersistentOnLoginObserverTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Observer/SynchronizePersistentOnLoginObserverTest.php index 35f2283494b1c..f3847b7cb5735 100644 --- a/dev/tests/integration/testsuite/Magento/Persistent/Observer/SynchronizePersistentOnLoginObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Persistent/Observer/SynchronizePersistentOnLoginObserverTest.php @@ -10,16 +10,21 @@ use DateTime; use DateTimeZone; use Magento\Customer\Api\CustomerRepositoryInterface; -use Magento\Customer\Api\Data\CustomerInterface; -use Magento\Framework\Event; -use Magento\Framework\Event\Observer; +use Magento\Customer\Model\Session as CustomerSession; use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Stdlib\CookieManagerInterface; +use Magento\Persistent\Helper\Session as PersistentSessionHelper; use Magento\Persistent\Model\Session; use Magento\Persistent\Model\SessionFactory; use Magento\TestFramework\Helper\Bootstrap; use PHPUnit\Framework\TestCase; /** + * Test for synchronize persistent session on login observer + * + * @see \Magento\Persistent\Observer\SynchronizePersistentOnLoginObserver + * @magentoAppArea frontend + * @magentoDbIsolation enabled * @magentoDataFixture Magento/Customer/_files/customer.php * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ @@ -28,87 +33,130 @@ class SynchronizePersistentOnLoginObserverTest extends TestCase /** * @var SynchronizePersistentOnLoginObserver */ - protected $_model; + private $model; /** * @var ObjectManagerInterface */ - protected $_objectManager; + private $objectManager; /** - * @var \Magento\Persistent\Helper\Session + * @var PersistentSessionHelper */ - protected $_persistentSession; + private $persistentSessionHelper; /** - * @var \Magento\Customer\Model\Session + * @var CustomerRepositoryInterface */ - protected $_customerSession; + private $customerRepository; /** - * @var CustomerInterface + * @var SessionFactory */ - private $customer; + private $persistentSessionFactory; + + + /** + * @var CookieManagerInterface + */ + private $cookieManager; + + /** + * @var CustomerSession + */ + private $customerSession; /** * @inheritDoc */ protected function setUp(): void { - $this->_objectManager = Bootstrap::getObjectManager(); - $this->_persistentSession = $this->_objectManager->get(\Magento\Persistent\Helper\Session::class); - $this->_customerSession = $this->_objectManager->get(\Magento\Customer\Model\Session::class); - $this->_model = $this->_objectManager->create( - SynchronizePersistentOnLoginObserver::class, - [ - 'persistentSession' => $this->_persistentSession, - 'customerSession' => $this->_customerSession - ] - ); - /** @var CustomerRepositoryInterface $customerRepository */ - $customerRepository = $this->_objectManager->create(CustomerRepositoryInterface::class); - $this->customer = $customerRepository->getById(1); + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->persistentSessionHelper = $this->objectManager->get(PersistentSessionHelper::class); + $this->model = $this->objectManager->get(SynchronizePersistentOnLoginObserver::class); + $this->customerRepository = $this->objectManager->get(CustomerRepositoryInterface::class); + $this->persistentSessionFactory = $this->objectManager->get(SessionFactory::class); + $this->cookieManager = $this->objectManager->get(CookieManagerInterface::class); + $this->customerSession = $this->objectManager->get(CustomerSession::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->persistentSessionHelper->setRememberMeChecked(null); + $this->customerSession->logout(); + + parent::tearDown(); } /** * Test that persistent session is created on customer login + * + * @return void */ public function testSynchronizePersistentOnLogin(): void { - $sessionModel = $this->_objectManager->create(Session::class); - $sessionModel->loadByCustomerId($this->customer->getId()); + $customer = $this->customerRepository->get('customer@example.com'); + $sessionModel = $this->persistentSessionFactory->create(); + $sessionModel->loadByCustomerId($customer->getId()); $this->assertNull($sessionModel->getCustomerId()); - $event = new Event(); - $observer = new Observer(['event' => $event]); - $event->setData('customer', $this->customer); - $this->_persistentSession->setRememberMeChecked(true); - $this->_model->execute($observer); - // check that persistent session has been stored for Customer - /** @var Session $sessionModel */ - $sessionModel = $this->_objectManager->create(Session::class); - $sessionModel->loadByCustomerId($this->customer->getId()); - $this->assertEquals($this->customer->getId(), $sessionModel->getCustomerId()); + $this->persistentSessionHelper->setRememberMeChecked(true); + $this->customerSession->loginById($customer->getId()); + $sessionModel = $this->persistentSessionFactory->create(); + $sessionModel->loadByCustomerId($customer->getId()); + $this->assertEquals($customer->getId(), $sessionModel->getCustomerId()); } /** * Test that expired persistent session is renewed on customer login + * + * @return void */ public function testExpiredPersistentSessionShouldBeRenewedOnLogin(): void { + $customer = $this->customerRepository->get('customer@example.com'); $lastUpdatedAt = (new DateTime('-1day'))->setTimezone(new DateTimeZone('UTC'))->format('Y-m-d H:i:s'); - /** @var Session $sessionModel */ - $sessionModel = $this->_objectManager->create(SessionFactory::class)->create(); - $sessionModel->setCustomerId($this->customer->getId()); + $sessionModel = $this->persistentSessionFactory->create(); + $sessionModel->setCustomerId($customer->getId()); $sessionModel->setUpdatedAt($lastUpdatedAt); $sessionModel->save(); - $event = new Event(); - $observer = new Observer(['event' => $event]); - $event->setData('customer', $this->customer); - $this->_persistentSession->setRememberMeChecked(true); - $this->_model->execute($observer); - /** @var Session $sessionModel */ - $sessionModel = $this->_objectManager->create(Session::class); - $sessionModel->loadByCustomerId(1); + $this->persistentSessionHelper->setRememberMeChecked(true); + $this->customerSession->loginById($customer->getId()); + $sessionModel = $this->persistentSessionFactory->create(); + $sessionModel->loadByCustomerId($customer->getId()); $this->assertGreaterThan($lastUpdatedAt, $sessionModel->getUpdatedAt()); } + + /** + * @magentoDataFixture Magento/Persistent/_files/persistent_with_customer_quote_and_cookie.php + * @magentoConfigFixture current_store persistent/options/enabled 0 + * + * @return void + */ + public function testDisabledPersistentSession(): void + { + $customer = $this->customerRepository->get('customer@example.com'); + $this->customerSession->loginById($customer->getId()); + $this->assertNull($this->cookieManager->getCookie(Session::COOKIE_NAME)); + } + + /** + * @magentoDataFixture Magento/Persistent/_files/persistent_with_customer_quote_and_cookie.php + * @magentoConfigFixture current_store persistent/options/enabled 1 + * @magentoConfigFixture current_store persistent/options/lifetime 0 + * + * @return void + */ + public function testDisabledPersistentSessionLifetime(): void + { + $customer = $this->customerRepository->get('customer@example.com'); + $this->customerSession->loginById($customer->getId()); + $session = $this->persistentSessionFactory->create()->setLoadExpired()->loadByCustomerId($customer->getId()); + $this->assertNull($session->getId()); + $this->assertNull($this->cookieManager->getCookie(Session::COOKIE_NAME)); + } } diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Observer/SynchronizePersistentOnLogoutObserverTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Observer/SynchronizePersistentOnLogoutObserverTest.php index 2bf97fdb4953f..293f1d1890d92 100644 --- a/dev/tests/integration/testsuite/Magento/Persistent/Observer/SynchronizePersistentOnLogoutObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Persistent/Observer/SynchronizePersistentOnLogoutObserverTest.php @@ -3,54 +3,77 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Persistent\Observer; +use Magento\Customer\Model\Session as CustomerSession; +use Magento\Framework\ObjectManagerInterface; +use Magento\Persistent\Model\SessionFactory; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + /** + * Test for synchronize persistent on logout observer + * + * @see \Magento\Persistent\Observer\SynchronizePersistentOnLogoutObserver * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoAppArea frontend + * @magentoDbIsolation enabled */ -class SynchronizePersistentOnLogoutObserverTest extends \PHPUnit\Framework\TestCase +class SynchronizePersistentOnLogoutObserverTest extends TestCase { - /** - * @var \Magento\Framework\ObjectManagerInterface - */ - protected $_objectManager; + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var CustomerSession */ + private $customerSession; + + /** @var SessionFactory */ + private $sessionFactory; /** - * @var \Magento\Customer\Model\Session + * @inheritdoc */ - protected $_customerSession; - protected function setUp(): void { - $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_customerSession = $this->_objectManager->get(\Magento\Customer\Model\Session::class); + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->customerSession = $this->objectManager->get(CustomerSession::class); + $this->sessionFactory = $this->objectManager->get(SessionFactory::class); } /** * @magentoConfigFixture current_store persistent/options/enabled 1 * @magentoConfigFixture current_store persistent/options/logout_clear 1 - * @magentoAppArea frontend - * @magentoAppIsolation enabled + * + * @return void */ - public function testSynchronizePersistentOnLogout() + public function testSynchronizePersistentOnLogout(): void { - $this->_customerSession->loginById(1); - - // check that persistent session has been stored for Customer - /** @var \Magento\Persistent\Model\Session $sessionModel */ - $sessionModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Persistent\Model\Session::class - ); + $this->customerSession->loginById(1); + $sessionModel = $this->sessionFactory->create(); $sessionModel->loadByCookieKey(); $this->assertEquals(1, $sessionModel->getCustomerId()); - - $this->_customerSession->logout(); - - /** @var \Magento\Persistent\Model\Session $sessionModel */ - $sessionModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Persistent\Model\Session::class - ); + $this->customerSession->logout(); + $sessionModel = $this->sessionFactory->create(); $sessionModel->loadByCookieKey(); $this->assertNull($sessionModel->getCustomerId()); } + + /** + * @magentoConfigFixture current_store persistent/options/enabled 1 + * @magentoConfigFixture current_store persistent/options/logout_clear 0 + * + * @return void + */ + public function testSynchronizePersistentOnLogoutDisabled(): void + { + $this->customerSession->loginById(1); + $this->customerSession->logout(); + $sessionModel = $this->sessionFactory->create(); + $sessionModel->loadByCookieKey(); + $this->assertEquals(1, $sessionModel->getCustomerId()); + } } diff --git a/dev/tests/integration/testsuite/Magento/Persistent/_files/persistent_rollback.php b/dev/tests/integration/testsuite/Magento/Persistent/_files/persistent_rollback.php new file mode 100644 index 0000000000000..581ddb35e3678 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Persistent/_files/persistent_rollback.php @@ -0,0 +1,11 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_address_rollback.php'); +Resolver::getInstance()->requireDataFixture('Magento/Customer/_files/customer_rollback.php'); diff --git a/dev/tests/integration/testsuite/Magento/Persistent/_files/persistent_with_customer_quote_and_cookie.php b/dev/tests/integration/testsuite/Magento/Persistent/_files/persistent_with_customer_quote_and_cookie.php new file mode 100644 index 0000000000000..a2c68ad9b7f2a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Persistent/_files/persistent_with_customer_quote_and_cookie.php @@ -0,0 +1,19 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Persistent\Model\SessionFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +Resolver::getInstance()->requireDataFixture('Magento/Checkout/_files/quote_with_customer_without_address.php'); + +$objectManager = Bootstrap::getObjectManager(); +/** @var SessionFactory $persistentSessionFactory */ +$persistentSessionFactory = $objectManager->get(SessionFactory::class); +$session = $persistentSessionFactory->create(); +$session->setCustomerId(1)->save(); +$session->setPersistentCookie(10000, ''); diff --git a/dev/tests/integration/testsuite/Magento/Persistent/_files/persistent_with_customer_quote_and_cookie_rollback.php b/dev/tests/integration/testsuite/Magento/Persistent/_files/persistent_with_customer_quote_and_cookie_rollback.php new file mode 100644 index 0000000000000..252b3f4be7079 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Persistent/_files/persistent_with_customer_quote_and_cookie_rollback.php @@ -0,0 +1,17 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Persistent\Model\SessionFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +$objectManager = Bootstrap::getObjectManager(); +/** @var SessionFactory $sessionFactory */ +$sessionFactory = $objectManager->get(SessionFactory::class); +$sessionFactory->create()->deleteByCustomerId(1); + +Resolver::getInstance()->requireDataFixture('Magento/Checkout/_files/quote_with_customer_without_address_rollback.php'); From 9fd0330017d9ebf5b90229b10d4769284ad415bf Mon Sep 17 00:00:00 2001 From: IvanPletnyov <ivan.pletnyov@transoftgroup.com> Date: Wed, 2 Sep 2020 22:03:39 +0300 Subject: [PATCH 42/99] MC-37315: Customer configuration: Persistent shopping cart --- .../Observer/SynchronizePersistentOnLoginObserverTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Observer/SynchronizePersistentOnLoginObserverTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Observer/SynchronizePersistentOnLoginObserverTest.php index f3847b7cb5735..bd4d24211f1e3 100644 --- a/dev/tests/integration/testsuite/Magento/Persistent/Observer/SynchronizePersistentOnLoginObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/Persistent/Observer/SynchronizePersistentOnLoginObserverTest.php @@ -55,7 +55,6 @@ class SynchronizePersistentOnLoginObserverTest extends TestCase */ private $persistentSessionFactory; - /** * @var CookieManagerInterface */ From b4f2b131bbfe269650a2cef80fa4cc3ddd1922ae Mon Sep 17 00:00:00 2001 From: Roman Zhupanyn <roma.dj.elf@gmail.com> Date: Thu, 3 Sep 2020 13:00:11 +0300 Subject: [PATCH 43/99] MC-33493: Test render fields in composite configure block for simple and configurable product --- .../Composite/Fieldset/OptionsTest.php | 618 ++++++++++++++++++ .../Product/Composite/Fieldset/QtyTest.php | 128 ++++ .../Product/Composite/FieldsetTest.php | 120 ++++ .../AbstractRenderCustomOptionsTest.php | 119 +++- .../View/Options/RenderOptionsTest.php | 20 +- .../Composite/Fieldset/ConfigurableTest.php | 101 +++ .../View/CustomOptions/RenderOptionsTest.php | 19 +- .../Product/View/Type/ConfigurableTest.php | 33 + 8 files changed, 1123 insertions(+), 35 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/QtyTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/FieldsetTest.php create mode 100644 dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Adminhtml/Product/Composite/Fieldset/ConfigurableTest.php diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php new file mode 100644 index 0000000000000..ddf22614abaa4 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php @@ -0,0 +1,618 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset; + +use Magento\Catalog\Api\Data\ProductCustomOptionInterface; +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Block\Product\View\Options\AbstractRenderCustomOptionsTest; +use Magento\Catalog\Helper\Product as HelperProduct; +use Magento\Catalog\Model\Config\Source\ProductPriceOptionsInterface; +use Magento\Catalog\Model\Product\Option; +use Magento\Catalog\Model\Product\Option\Value; +use Magento\Framework\DataObject; +use Magento\TestFramework\Helper\Xpath; + +/** + * Test cases related to check that simple product custom option renders as expected. + * + * @magentoAppArea adminhtml + */ +class OptionsTest extends AbstractRenderCustomOptionsTest +{ + /** @var HelperProduct */ + private $helperProduct; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->helperProduct = $this->objectManager->get(HelperProduct::class); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/product_without_options_with_stock_data.php + * @throws \Magento\Framework\Exception\NoSuchEntityException + * @return void + */ + public function testRenderCustomOptionsWithoutOptions(): void + { + $product = $this->productRepository->get('simple'); + $optionHtml = $this->getOptionHtml($product); + $this->assertEquals( + 0, + Xpath::getElementsCountForXpath( + "//fieldset[@id='product_composite_configure_fields_options']", + $optionHtml + ), + 'The option block is expected to be empty!' + ); + } + + /** + * Check that options from text group(field, area) render as expected. + * + * @magentoDataFixture Magento/Catalog/_files/product_without_options_with_stock_data.php + * @dataProvider renderCustomOptionsFromTextGroupProvider + * @param array $optionData + * @param array $checkArray + * @return void + */ + public function testRenderCustomOptionsFromTextGroup(array $optionData, array $checkArray): void + { + $this->assertTextOptionRenderingOnProduct('simple', $optionData, $checkArray); + }//test bez opcij + + /** + * Provides test data to verify the display of text type options. + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @return array + */ + public function renderCustomOptionsFromTextGroupProvider(): array + { + return [ + 'type_text_required_field' => [ + [ + Option::KEY_TITLE => 'Test option type text 1', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_FIELD, + Option::KEY_IS_REQUIRE => 0, + Option::KEY_PRICE => 0, + Option::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + Option::KEY_MAX_CHARACTERS => 0, + ], + [ + 'contains' => [ + 'block_with_required_class' => '<div class="field admin__field">', + 'title' => 'Test option type text 1', + ], + 'equals_xpath' => [ + 'zero_price' => [ + 'xpath' => "//label[contains(@class, 'admin__field-label')]/span", + 'message' => 'Expected empty price is incorrect or missing!', + 'expected' => 0, + ], + ], + ], + ], + 'type_text_is_required_option' => [ + [ + Option::KEY_TITLE => 'Test option type text 2', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_FIELD, + Option::KEY_IS_REQUIRE => 1, + Option::KEY_PRICE => 0, + Option::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + Option::KEY_MAX_CHARACTERS => 0, + ], + [ + 'contains' => [ + 'block_with_required_class' => '<div class="field admin__field required _required">', + ], + ], + ], + 'type_text_fixed_positive_price' => [ + [ + Option::KEY_TITLE => 'Test option type text 3', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_FIELD, + Option::KEY_IS_REQUIRE => 0, + Option::KEY_PRICE => 50, + Option::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + Option::KEY_MAX_CHARACTERS => 0, + ], + [ + 'contains' => [ + 'price' => 'data-price-amount="50"', + ], + 'equals_xpath' => [ + 'sign_price' => [ + 'xpath' => "//label[contains(@class, 'admin__field-label')]/span[contains(text(), '+')]", + 'message' => 'Expected positive price is incorrect or missing!', + ], + ], + ], + ], + 'type_text_fixed_negative_price' => [ + [ + Option::KEY_TITLE => 'Test option type text 4', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_FIELD, + Option::KEY_IS_REQUIRE => 0, + Option::KEY_PRICE => -50, + Option::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + Option::KEY_MAX_CHARACTERS => 0, + ], + [ + 'contains' => [ + 'price' => 'data-price-amount="50"', + ], + 'equals_xpath' => [ + 'sign_price' => [ + 'xpath' => "//label[contains(@class, 'admin__field-label')]/span[contains(text(), '-')]", + 'message' => 'Expected negative price is incorrect or missing!', + ], + ], + ], + ], + 'type_text_percent_price' => [ + [ + Option::KEY_TITLE => 'Test option type text 5', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_FIELD, + Option::KEY_IS_REQUIRE => 0, + Option::KEY_PRICE => 50, + Option::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_PERCENT, + Option::KEY_MAX_CHARACTERS => 0, + ], + [ + 'contains' => [ + 'price' => 'data-price-amount="5"', + ], + ], + ], + 'type_text_max_characters' => [ + [ + Option::KEY_TITLE => 'Test option type text 6', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_FIELD, + Option::KEY_IS_REQUIRE => 0, + Option::KEY_PRICE => 10, + Option::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + Option::KEY_MAX_CHARACTERS => 99, + ], + [ + 'max_characters' => (string)__('Maximum number of characters:') . ' <strong>99</strong>', + ], + ], + 'type_field' => [ + [ + Option::KEY_TITLE => 'Test option type field 1', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_FIELD, + Option::KEY_IS_REQUIRE => 0, + Option::KEY_PRICE => 10, + Option::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + Option::KEY_MAX_CHARACTERS => 0, + 'configure_option_value' => 'Type field option value', + ], + [ + 'equals_xpath' => [ + 'control_price_attribute' => [ + 'xpath' => "//input[@id='options_%s_text' and @price='%s']", + 'message' => 'Expected input price is incorrect or missing!', + ], + 'default_option_value' => [ + 'xpath' => "//input[@id='options_%s_text' and @value='Type field option value']", + 'message' => 'Expected input default value is incorrect or missing!', + ], + ], + ], + ], + 'type_area' => [ + [ + Option::KEY_TITLE => 'Test option type area 1', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_AREA, + Option::KEY_IS_REQUIRE => 0, + Option::KEY_PRICE => 10, + Option::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + Option::KEY_MAX_CHARACTERS => 0, + 'configure_option_value' => 'Type area option value', + ], + [ + 'equals_xpath' => [ + 'control_price_attribute' => [ + 'xpath' => "//textarea[@id='options_%s_text' and @price='%s']", + 'message' => 'Expected textarea price is incorrect or missing!', + ], + 'default_option_value' => [ + 'xpath' => "//textarea[@id='options_%s_text' " + . "and contains(text(), 'Type area option value')]", + 'message' => 'Expected textarea default value is incorrect or missing!', + ], + ], + ], + ], + ]; + } + + /** + * Check that options from select group(drop-down, radio buttons, checkbox, multiple select) render as expected. + * + * @magentoDataFixture Magento/Catalog/_files/product_without_options_with_stock_data.php + * @dataProvider renderCustomOptionsFromSelectGroupProvider + * @param array $optionData + * @param array $optionValueData + * @param array $checkArray + * @return void + */ + public function testRenderCustomOptionsFromSelectGroup( + array $optionData, + array $optionValueData, + array $checkArray + ): void { + $this->assertSelectOptionRenderingOnProduct('simple', $optionData, $optionValueData, $checkArray); + } + + /** + * Provides test data to verify the display of select type options. + * + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @return array + */ + public function renderCustomOptionsFromSelectGroupProvider(): array + { + return [ + 'type_select_required_field' => [ + [ + Option::KEY_TITLE => 'Test option type select 1', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN, + Option::KEY_IS_REQUIRE => 0, + ], + [ + Value::KEY_TITLE => 'Select value 1', + Value::KEY_PRICE => 10, + Value::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + ], + [ + 'contains' => [ + 'block_with_required_class' => '<div class="admin__field field">', + 'title' => '<span>Test option type select 1</span>', + ], + 'equals_xpath' => [ + 'required_element' => [ + 'xpath' => "//select[@id='select_%s']", + 'message' => 'Expected select type is incorrect or missing!', + ], + ], + ], + ], + 'type_select_is_required_option' => [ + [ + Option::KEY_TITLE => 'Test option type select 2', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN, + Option::KEY_IS_REQUIRE => 1, + ], + [ + Value::KEY_TITLE => 'Select value 1', + Value::KEY_PRICE => 10, + Value::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + ], + [ + 'contains' => [ + 'block_with_required_class' => '<div class="admin__field field _required">', + ], + ], + ], + 'type_drop_down_with_selected' => [ + [ + Option::KEY_TITLE => 'Test option type drop-down 1', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN, + Option::KEY_IS_REQUIRE => 0, + 'configure_option_value' => 'Drop-down value 1', + ], + [ + Value::KEY_TITLE => 'Drop-down value 1', + Value::KEY_PRICE => 10, + Value::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + ], + [ + 'equals_xpath' => [ + 'element_type' => [ + 'xpath' => "//select[contains(@class, 'admin__control-select')]", + 'message' => 'Expected drop down type is incorrect or missing!', + ], + 'default_value' => [ + 'xpath' => "//option[contains(text(), '" . __('-- Please Select --') . "')]", + 'message' => 'Expected default value is incorrect or missing!', + ], + 'selected_value' => [ + 'xpath' => "//option[@selected='selected' and contains(text(), 'Drop-down value 1')]", + 'message' => 'Expected selected value is incorrect or missing!', + ], + ], + ], + ], + 'type_multiple_with_selected' => [ + [ + Option::KEY_TITLE => 'Test option type multiple 1', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_MULTIPLE, + Option::KEY_IS_REQUIRE => 0, + 'configure_option_value' => 'Multiple value 1', + ], + [ + Value::KEY_TITLE => 'Multiple value 1', + Value::KEY_PRICE => 10, + Value::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + ], + [ + 'equals_xpath' => [ + 'element_type' => [ + 'xpath' => "//select[contains(@class, 'admin__control-multiselect') " + . "and @multiple='multiple']", + 'message' => 'Expected multiple type is incorrect or missing!', + ], + 'selected_value' => [ + 'xpath' => "//option[@selected='selected' and contains(text(), 'Multiple value 1')]", + 'message' => 'Expected selected value is incorrect or missing!', + ], + ], + ], + ], + 'type_checkable_required_field' => [ + [ + Option::KEY_TITLE => 'Test option type checkable 1', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_RADIO, + Option::KEY_IS_REQUIRE => 0, + ], + [ + Value::KEY_TITLE => 'Checkable value 1', + Value::KEY_PRICE => 10, + Value::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + ], + [ + 'equals_xpath' => [ + 'required_checkable_option' => [ + 'xpath' => "//div[@id='options-%s-list']", + 'message' => 'Expected checkable option is incorrect or missing!', + ], + 'option_value_title' => [ + 'xpath' => "//label[@for='options_%s_2']/span[contains(text(), 'Checkable value 1')]", + 'message' => 'Expected option value title is incorrect or missing!', + ], + ], + ], + ], + 'type_radio_is_required_option' => [ + [ + Option::KEY_TITLE => 'Test option type radio 1', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_RADIO, + Option::KEY_IS_REQUIRE => 1, + ], + [ + Value::KEY_TITLE => 'Radio value 1', + Value::KEY_PRICE => 10, + Value::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + ], + [ + 'equals_xpath' => [ + 'span_container' => [ + 'xpath' => "//span[@id='options-%s-container']", + 'message' => 'Expected span container is incorrect or missing!', + ], + 'default_option_value' => [ + 'xpath' => "//label[@for='options_%s']/span[contains(text(), '" . __('None') . "')]", + 'message' => 'Expected default option value is incorrect or missing!', + 'expected' => 0, + ], + ], + ], + ], + 'type_radio_with_selected' => [ + [ + Option::KEY_TITLE => 'Test option type radio 2', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_RADIO, + Option::KEY_IS_REQUIRE => 0, + 'configure_option_value' => 'Radio value 1', + ], + [ + Value::KEY_TITLE => 'Radio value 1', + Value::KEY_PRICE => 10, + Value::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + ], + [ + 'equals_xpath' => [ + 'default_option_value' => [ + 'xpath' => "//label[@for='options_%s']/span[contains(text(), '" . __('None') . "')]", + 'message' => 'Expected default option value is incorrect or missing!', + ], + 'element_type' => [ + 'xpath' => "//input[@id='options_%s_2' and contains(@class, 'admin__control-radio')]", + 'message' => 'Expected radio type is incorrect or missing!', + ], + 'selected_value' => [ + 'xpath' => "//input[@id='options_%s_2' and @checked='checked']", + 'message' => 'Expected selected option value is incorrect or missing!', + ], + ], + ], + ], + 'type_checkbox_is_required_option' => [ + [ + Option::KEY_TITLE => 'Test option type checkbox 1', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_CHECKBOX, + Option::KEY_IS_REQUIRE => 1, + ], + [ + Value::KEY_TITLE => 'Checkbox value 1', + Value::KEY_PRICE => 10, + Value::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + Value::KEY_SKU => '', + ], + [ + 'equals_xpath' => [ + 'span_container' => [ + 'xpath' => "//span[@id='options-%s-container']", + 'message' => 'Expected span container is incorrect or missing!', + ], + ], + ], + ], + 'type_checkbox_with_selected' => [ + [ + Option::KEY_TITLE => 'Test option type checkbox 2', + Option::KEY_TYPE => ProductCustomOptionInterface::OPTION_TYPE_CHECKBOX, + Option::KEY_IS_REQUIRE => 0, + 'configure_option_value' => 'Checkbox value 1', + ], + [ + Value::KEY_TITLE => 'Checkbox value 1', + Value::KEY_PRICE => 10, + Value::KEY_PRICE_TYPE => ProductPriceOptionsInterface::VALUE_FIXED, + Value::KEY_SKU => '', + ], + [ + 'equals_xpath' => [ + 'element_type' => [ + 'xpath' => "//input[@id='options_%s_2' and contains(@class, 'admin__control-checkbox')]", + 'message' => 'Expected checkbox type is incorrect or missing!', + ], + 'selected_value' => [ + 'xpath' => "//input[@id='options_%s_2' and @checked='checked']", + 'message' => 'Expected selected option value is incorrect or missing!', + ], + ], + ], + ], + ]; + } + + /** + * @inheritdoc + */ + protected function addOptionToProduct( + ProductInterface $product, + array $optionData, + array $optionValueData = [] + ): ProductInterface { + $product = parent::addOptionToProduct($product, $optionData, $optionValueData); + + if (isset($optionData['configure_option_value'])) { + $optionValue = $optionData['configure_option_value']; + $option = $this->findOptionByTitle($product, $optionData[Option::KEY_TITLE]); + if (!empty($optionValueData)) { + $optionValueObject = $this->findOptionValueByTitle($option, $optionValue); + $optionValue = $option->getType() === Option::OPTION_TYPE_CHECKBOX + ? [$optionValueObject->getOptionTypeId()] + : $optionValueObject->getOptionTypeId(); + } + /** @var DataObject $request */ + $buyRequest = $this->objectManager->create(DataObject::class); + $buyRequest->setData([ + 'qty' => 1, + 'options' => [$option->getId() => $optionValue], + ]); + $this->helperProduct->prepareProductOptions($product, $buyRequest); + } + + return $product; + } + + /** + * @inheritdoc + */ + protected function baseOptionAsserts( + ProductCustomOptionInterface $option, + string $optionHtml, + array $checkArray + ): void { + if (isset($checkArray['contains'])) { + foreach ($checkArray['contains'] as $needle) { + $this->assertStringContainsString($needle, $optionHtml); + } + } + } + + /** + * @inheritdoc + */ + protected function additionalTypeTextAsserts( + ProductCustomOptionInterface $option, + string $optionHtml, + array $checkArray + ): void { + parent::additionalTypeTextAsserts($option, $optionHtml, $checkArray); + + if (isset($checkArray['equals_xpath'])) { + foreach ($checkArray['equals_xpath'] as $key => $value) { + $value['args'] = $key == 'control_price_attribute' ? [(float)$option->getPrice()] : []; + $this->assertEqualsXpath($option, $optionHtml, $value); + } + } + } + + /** + * @inheritdoc + */ + protected function additionalTypeSelectAsserts( + ProductCustomOptionInterface $option, + string $optionHtml, + array $checkArray + ): void { + parent::additionalTypeSelectAsserts($option, $optionHtml, $checkArray); + + if (isset($checkArray['equals_xpath'])) { + foreach ($checkArray['equals_xpath'] as $value) { + $this->assertEqualsXpath($option, $optionHtml, $value); + } + } + } + + /** + * @inheritdoc + */ + protected function getHandlesList(ProductInterface $product): array + { + return [ + 'default', + 'CATALOG_PRODUCT_COMPOSITE_CONFIGURE', + 'catalog_product_view_type_' . $product->getTypeId(), + ]; + } + + /** + * @inheritdoc + */ + protected function getMaxCharactersCssClass(): string + { + return 'class="note"'; + } + + /** + * @inheritdoc + */ + protected function getOptionsBlockName(): string + { + return 'product.composite.fieldset.options'; + } + + /** + * Checks that the xpath string is equal to the expected value + * + * @param ProductCustomOptionInterface $option + * @param string $html + * @param array $xpathData + * @return void + */ + private function assertEqualsXpath(ProductCustomOptionInterface $option, string $html, array $xpathData): void + { + $args = array_merge([$option->getOptionId()], $xpathData['args'] ?? []); + $expected = $xpathData['expected'] ?? 1; + $this->assertEquals( + $expected, + Xpath::getElementsCountForXpath(sprintf($xpathData['xpath'], ...$args), $html), + $xpathData['message'] + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/QtyTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/QtyTest.php new file mode 100644 index 0000000000000..b326215688f13 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/QtyTest.php @@ -0,0 +1,128 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset; + +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Helper\Product as HelperProduct; +use Magento\Framework\DataObject; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Registry; +use Magento\Framework\View\LayoutInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Test Qty block in composite product configuration layout + * + * @see \Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset\Qty + * @magentoAppArea adminhtml + */ +class QtyTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Qty */ + private $block; + + /** @var ProductRepositoryInterface */ + private $productRepository; + + /** @var Registry */ + private $registry; + + /** @var HelperProduct */ + private $helperProduct; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + $this->objectManager = Bootstrap::getObjectManager(); + $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Qty::class); + $this->registry = $this->objectManager->get(Registry::class); + $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class); + $this->productRepository->cleanCache(); + $this->helperProduct = $this->objectManager->get(HelperProduct::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->registry->unregister('current_product'); + $this->registry->unregister('product'); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/product_simple_duplicated.php + * @return void + */ + public function testGetProduct(): void + { + $product = $this->productRepository->get('simple-1'); + $this->registerProduct($product); + $this->assertSame($product, $this->block->getProduct()); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/product_simple_duplicated.php + * @dataProvider getQtyValueProvider + * @param bool $isQty + * @param int $qty + * @return void + */ + public function testGetQtyValue(bool $isQty, int $qty): void + { + $product = $this->productRepository->get('simple-1'); + if ($isQty) { + /** @var DataObject $request */ + $buyRequest = $this->objectManager->create(DataObject::class); + $buyRequest->setData(['qty' => $qty]); + $this->helperProduct->prepareProductOptions($product, $buyRequest); + } + $this->registerProduct($product); + $this->assertEquals($qty, $this->block->getQtyValue(), 'Expected block qty value is incorrect!'); + } + + /** + * Provides test data to verify block qty value. + * + * @return array + */ + public function getQtyValueProvider(): array + { + return [ + 'with_qty' => [ + 'is_qty' => true, + 'qty' => 5, + ], + 'without_qty' => [ + 'is_qty' => false, + 'qty' => 1, + ], + ]; + } + + /** + * Register the product + * + * @param ProductInterface $product + * @return void + */ + private function registerProduct(ProductInterface $product): void + { + $this->registry->unregister('current_product'); + $this->registry->unregister('product'); + $this->registry->register('current_product', $product); + $this->registry->register('product', $product); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/FieldsetTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/FieldsetTest.php new file mode 100644 index 0000000000000..3356d87a92794 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/FieldsetTest.php @@ -0,0 +1,120 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Block\Adminhtml\Product\Composite; + +use Magento\Backend\Model\View\Result\Page; +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Registry; +use Magento\Framework\View\Result\PageFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + +/** + * Test Fieldset block in composite product configuration layout + * + * @see \Magento\Catalog\Block\Adminhtml\Product\Composite\Fieldset + * @magentoAppArea adminhtml + */ +class FieldsetTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Page */ + private $page; + + /** @var Registry */ + private $registry; + + /** @var ProductRepositoryInterface */ + private $productRepository; + + /** @var string */ + private $fieldsetXpath = "//fieldset[@id='product_composite_configure_fields_%s']"; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->page = $this->objectManager->get(PageFactory::class)->create(); + $this->registry = $this->objectManager->get(Registry::class); + $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class); + $this->productRepository->cleanCache(); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->registry->unregister('current_product'); + $this->registry->unregister('product'); + + parent::tearDown(); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/product_simple_with_options.php + * @return void + */ + public function testRenderHtml(): void + { + $product = $this->productRepository->get('simple'); + $this->registerProduct($product); + $this->preparePage($product->getTypeId()); + $html = $this->page->getLayout()->getBlock('product.composite.fieldset')->toHtml(); + + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath(sprintf($this->fieldsetXpath, 'options'), $html), + 'Expected options block is missing!' + ); + $this->assertEquals( + 1, + Xpath::getElementsCountForXpath(sprintf($this->fieldsetXpath, 'qty'), $html), + 'Expected qty block is missing!' + ); + } + + /** + * Prepare page layout + * + * @param string $productType + * @return void + */ + private function preparePage(string $productType): void + { + $this->page->addHandle([ + 'default', + 'CATALOG_PRODUCT_COMPOSITE_CONFIGURE', + 'catalog_product_view_type_' . $productType, + ]); + $this->page->getLayout()->generateXml(); + } + + /** + * Register the product + * + * @param ProductInterface $product + * @return void + */ + private function registerProduct(ProductInterface $product): void + { + $this->registry->unregister('current_product'); + $this->registry->unregister('product'); + $this->registry->register('current_product', $product); + $this->registry->register('product', $product); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php index eb34696c70dbf..6e4df5dbacecb 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php @@ -9,14 +9,14 @@ use Magento\Catalog\Api\Data\ProductCustomOptionInterface; use Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory; +use Magento\Catalog\Api\Data\ProductCustomOptionValuesInterface; use Magento\Catalog\Api\Data\ProductCustomOptionValuesInterfaceFactory; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Block\Product\View\Options; use Magento\Catalog\Model\Product\Option; -use Magento\Catalog\Model\Product\Option\Value; -use Magento\Framework\View\Element\Template; use Magento\Framework\View\Result\Page; +use Magento\Framework\View\Result\PageFactory; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\ObjectManager; use PHPUnit\Framework\TestCase; @@ -29,12 +29,12 @@ abstract class AbstractRenderCustomOptionsTest extends TestCase /** * @var ObjectManager */ - private $objectManager; + protected $objectManager; /** * @var ProductRepositoryInterface */ - private $productRepository; + protected $productRepository; /** * @var ProductCustomOptionInterfaceFactory @@ -62,7 +62,7 @@ protected function setUp(): void $this->productCustomOptionValuesFactory = $this->objectManager->get( ProductCustomOptionValuesInterfaceFactory::class ); - $this->page = $this->objectManager->create(Page::class); + $this->page = $this->objectManager->get(PageFactory::class)->create(); parent::setUp(); } @@ -94,11 +94,26 @@ protected function assertTextOptionRenderingOnProduct( $option = $this->findOptionByTitle($product, $optionData[Option::KEY_TITLE]); $optionHtml = $this->getOptionHtml($product); $this->baseOptionAsserts($option, $optionHtml, $checkArray); + $this->additionalTypeTextAsserts($option, $optionHtml, $checkArray); + } - if ($optionData[Option::KEY_MAX_CHARACTERS] > 0) { + /** + * Additional asserts for rendering text type options. + * + * @param ProductCustomOptionInterface $option + * @param string $optionHtml + * @param array $checkArray + * @return void + */ + protected function additionalTypeTextAsserts( + ProductCustomOptionInterface $option, + string $optionHtml, + array $checkArray + ): void { + if ($option->getMaxCharacters() > 0) { $this->assertStringContainsString($checkArray['max_characters'], $optionHtml); } else { - $this->assertStringNotContainsString('class="character-counter', $optionHtml); + $this->assertStringNotContainsString($this->getMaxCharactersCssClass(), $optionHtml); } } @@ -153,22 +168,36 @@ protected function assertSelectOptionRenderingOnProduct( $product = $this->productRepository->get($productSku); $product = $this->addOptionToProduct($product, $optionData, $optionValueData); $option = $this->findOptionByTitle($product, $optionData[Option::KEY_TITLE]); - $optionValues = $option->getValues(); - $optionValue = reset($optionValues); $optionHtml = $this->getOptionHtml($product); $this->baseOptionAsserts($option, $optionHtml, $checkArray); + $this->additionalTypeSelectAsserts($option, $optionHtml, $checkArray); + } + /** + * Additional asserts for rendering select type options. + * + * @param ProductCustomOptionInterface $option + * @param string $optionHtml + * @param array $checkArray + * @return void + */ + protected function additionalTypeSelectAsserts( + ProductCustomOptionInterface $option, + string $optionHtml, + array $checkArray + ): void { + $optionValues = $option->getValues(); + $optionValue = reset($optionValues); if (isset($checkArray['not_contain_arr'])) { foreach ($checkArray['not_contain_arr'] as $notContainPattern) { $this->assertDoesNotMatchRegularExpression($notContainPattern, $optionHtml); } } - if (isset($checkArray['option_value_item'])) { $checkArray['option_value_item'] = sprintf( $checkArray['option_value_item'], $optionValue->getOptionTypeId(), - $optionValueData[Value::KEY_TITLE] + $optionValue->getTitle() ); $this->assertMatchesRegularExpression($checkArray['option_value_item'], $optionHtml); } @@ -284,7 +313,7 @@ protected function assertDateOptionRenderingOnProduct( * @param array $checkArray * @return void */ - private function baseOptionAsserts( + protected function baseOptionAsserts( ProductCustomOptionInterface $option, string $optionHtml, array $checkArray @@ -317,7 +346,7 @@ private function baseOptionAsserts( * @param array $optionValueData * @return ProductInterface */ - private function addOptionToProduct( + protected function addOptionToProduct( ProductInterface $product, array $optionData, array $optionValueData = [] @@ -341,30 +370,17 @@ private function addOptionToProduct( * @param ProductInterface $product * @return string */ - private function getOptionHtml(ProductInterface $product): string + protected function getOptionHtml(ProductInterface $product): string { - $optionsBlock = $this->getOptionsBlock(); + $this->page->addHandle($this->getHandlesList($product)); + $this->page->getLayout()->generateXml(); + /** @var Options $optionsBlock */ + $optionsBlock = $this->page->getLayout()->getBlock($this->getOptionsBlockName()); $optionsBlock->setProduct($product); return $optionsBlock->toHtml(); } - /** - * Get options block. - * - * @return Options - */ - private function getOptionsBlock(): Options - { - $this->page->addHandle($this->getHandlesList()); - $this->page->getLayout()->generateXml(); - /** @var Template $productInfoFormOptionsBlock */ - $productInfoFormOptionsBlock = $this->page->getLayout()->getBlock('product.info.form.options'); - $optionsWrapperBlock = $productInfoFormOptionsBlock->getChildBlock('product_options_wrapper'); - - return $optionsWrapperBlock->getChildBlock('product_options'); - } - /** * Find and return custom option. * @@ -372,7 +388,7 @@ private function getOptionsBlock(): Options * @param string $optionTitle * @return null|Option */ - private function findOptionByTitle(ProductInterface $product, string $optionTitle): ?Option + protected function findOptionByTitle(ProductInterface $product, string $optionTitle): ?Option { $option = null; foreach ($product->getOptions() as $customOption) { @@ -385,10 +401,47 @@ private function findOptionByTitle(ProductInterface $product, string $optionTitl return $option; } + /** + * Find and return custom option value. + * + * @param ProductCustomOptionInterface $option + * @param string $optionValueTitle + * @return null|ProductCustomOptionValuesInterface + */ + protected function findOptionValueByTitle( + ProductCustomOptionInterface $option, + string $optionValueTitle + ): ?ProductCustomOptionValuesInterface { + $optionValue = null; + foreach ($option->getValues() as $customOptionValue) { + if ($customOptionValue->getTitle() === $optionValueTitle) { + $optionValue = $customOptionValue; + break; + } + } + + return $optionValue; + } + /** * Return all need handles for load. * + * @param ProductInterface $product * @return array */ - abstract protected function getHandlesList(): array; + abstract protected function getHandlesList(ProductInterface $product): array; + + /** + * + * + * @return string + */ + abstract protected function getMaxCharactersCssClass(): string; + + /** + * + * + * @return string + */ + abstract protected function getOptionsBlockName(): string; } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/RenderOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/RenderOptionsTest.php index da31cfc74476a..fa05e5ece10e3 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/RenderOptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/RenderOptionsTest.php @@ -7,6 +7,8 @@ namespace Magento\Catalog\Block\Product\View\Options; +use Magento\Catalog\Api\Data\ProductInterface; + /** * Test cases related to check that simple product custom option renders as expected. * @@ -82,11 +84,27 @@ public function testRenderCustomOptionsFromDateGroup(array $optionData, array $c /** * @inheritdoc */ - protected function getHandlesList(): array + protected function getHandlesList(ProductInterface $product): array { return [ 'default', 'catalog_product_view', ]; } + + /** + * @inheritdoc + */ + protected function getMaxCharactersCssClass(): string + { + return 'class="character-counter'; + } + + /** + * @inheritdoc + */ + protected function getOptionsBlockName(): string + { + return 'product.info.options'; + } } diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Adminhtml/Product/Composite/Fieldset/ConfigurableTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Adminhtml/Product/Composite/Fieldset/ConfigurableTest.php new file mode 100644 index 0000000000000..3ada18a1849c9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Adminhtml/Product/Composite/Fieldset/ConfigurableTest.php @@ -0,0 +1,101 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\ConfigurableProduct\Block\Adminhtml\Product\Composite\Fieldset; + +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Registry; +use Magento\Framework\Serialize\SerializerInterface; +use Magento\Framework\View\LayoutInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Test Configurable block in composite product configuration layout + * + * @see \Magento\ConfigurableProduct\Block\Adminhtml\Product\Composite\Fieldset\Configurable + * @magentoAppArea adminhtml + */ +class ConfigurableTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var SerializerInterface */ + private $serializer; + + /** @var Configurable */ + private $block; + + /** @var ProductRepositoryInterface */ + private $productRepository; + + /** @var Registry */ + private $registry; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + $this->objectManager = Bootstrap::getObjectManager(); + $this->serializer = $this->objectManager->get(SerializerInterface::class); + $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class); + $this->productRepository->cleanCache(); + $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Configurable::class); + $this->registry = $this->objectManager->get(Registry::class); + } + + /** + * @inheritdoc + */ + protected function tearDown(): void + { + $this->registry->unregister('product'); + } + + /** + * @magentoDataFixture Magento/Catalog/_files/product_simple_duplicated.php + * @return void + */ + public function testGetProduct(): void + { + $product = $this->productRepository->get('simple-1'); + $this->registerProduct($product); + $blockProduct = $this->block->getProduct(); + $this->assertSame($product, $blockProduct); + $this->assertNotNull($blockProduct->getTypeInstance()->getStoreFilter($blockProduct)); + } + + /** + * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_products.php + * @return void + */ + public function testGetJsonConfig(): void + { + $product = $this->productRepository->get('configurable'); + $this->registerProduct($product); + $config = $this->serializer->unserialize($this->block->getJsonConfig()); + $this->assertTrue($config['disablePriceReload']); + $this->assertTrue($config['stablePrices']); + } + + /** + * Register the product + * + * @param ProductInterface $product + * @return void + */ + private function registerProduct(ProductInterface $product): void + { + $this->registry->unregister('product'); + $this->registry->register('product', $product); + } +} diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/CustomOptions/RenderOptionsTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/CustomOptions/RenderOptionsTest.php index 55f8b91f07093..8bac488718217 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/CustomOptions/RenderOptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/CustomOptions/RenderOptionsTest.php @@ -7,6 +7,7 @@ namespace Magento\ConfigurableProduct\Block\Product\View\CustomOptions; +use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Block\Product\View\Options\AbstractRenderCustomOptionsTest; /** @@ -85,7 +86,7 @@ public function testRenderCustomOptionsFromDateGroup(array $optionData, array $c /** * @inheritdoc */ - protected function getHandlesList(): array + protected function getHandlesList(ProductInterface $product): array { return [ 'default', @@ -93,4 +94,20 @@ protected function getHandlesList(): array 'catalog_product_view_type_configurable', ]; } + + /** + * @inheritdoc + */ + protected function getMaxCharactersCssClass(): string + { + return 'class="character-counter'; + } + + /** + * @inheritdoc + */ + protected function getOptionsBlockName(): string + { + return 'product.info.options'; + } } diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php index 39ed7965ea9e9..62b691d61efb3 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php @@ -9,9 +9,12 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Helper\Product as HelperProduct; use Magento\Catalog\Model\ResourceModel\Product as ProductResource; +use Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute as ConfigurableAttribute; use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\Collection; use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\DataObject; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Serialize\SerializerInterface; use Magento\Framework\View\LayoutInterface; @@ -26,6 +29,7 @@ * @magentoAppIsolation enabled * @magentoDbIsolation enabled * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ConfigurableTest extends TestCase { @@ -64,6 +68,11 @@ class ConfigurableTest extends TestCase */ private $product; + /** + * @var HelperProduct + */ + private $helperProduct; + /** * @inheritdoc */ @@ -79,6 +88,7 @@ protected function setUp(): void $this->product = $this->productRepository->get('configurable'); $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Configurable::class); $this->block->setProduct($this->product); + $this->helperProduct = $this->objectManager->get(HelperProduct::class); } /** @@ -128,6 +138,29 @@ public function testGetJsonConfig(): void $this->assertCount(0, $config['images']); } + /** + * @return void + */ + public function testGetJsonConfigWithPreconfiguredValues(): void + { + /** @var ConfigurableAttribute $attribute */ + $attribute = $this->product->getExtensionAttributes()->getConfigurableProductOptions()[0]; + $expectedAttributeValue = [ + $attribute->getAttributeId() => $attribute->getOptions()[0]['value_index'], + ]; + /** @var DataObject $request */ + $buyRequest = $this->objectManager->create(DataObject::class); + $buyRequest->setData([ + 'qty' => 1, + 'super_attribute' => $expectedAttributeValue, + ]); + $this->helperProduct->prepareProductOptions($this->product, $buyRequest); + + $config = $this->serializer->unserialize($this->block->getJsonConfig()); + $this->assertArrayHasKey('defaultValues', $config); + $this->assertEquals($expectedAttributeValue, $config['defaultValues']); + } + /** * @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_product_with_child_products_with_images.php * @return void From 2dea62c1c36f85ed8cd1a098d01366295cd15797 Mon Sep 17 00:00:00 2001 From: Roman Zhupanyn <roma.dj.elf@gmail.com> Date: Thu, 3 Sep 2020 17:01:54 +0300 Subject: [PATCH 44/99] MC-33493: Test render fields in composite configure block for simple and configurable product --- .../Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php | 2 +- .../Product/View/Options/AbstractRenderCustomOptionsTest.php | 2 +- .../Catalog/Block/Product/View/Options/RenderOptionsTest.php | 1 - .../Block/Product/View/CustomOptions/RenderOptionsTest.php | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php index ddf22614abaa4..36a7d37ecbd2b 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php @@ -68,7 +68,7 @@ public function testRenderCustomOptionsWithoutOptions(): void public function testRenderCustomOptionsFromTextGroup(array $optionData, array $checkArray): void { $this->assertTextOptionRenderingOnProduct('simple', $optionData, $checkArray); - }//test bez opcij + } /** * Provides test data to verify the display of text type options. diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php index 6e4df5dbacecb..553130deddbee 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php @@ -57,7 +57,7 @@ abstract class AbstractRenderCustomOptionsTest extends TestCase protected function setUp(): void { $this->objectManager = Bootstrap::getObjectManager(); - $this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class); + $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class); $this->productCustomOptionFactory = $this->objectManager->get(ProductCustomOptionInterfaceFactory::class); $this->productCustomOptionValuesFactory = $this->objectManager->get( ProductCustomOptionValuesInterfaceFactory::class diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/RenderOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/RenderOptionsTest.php index fa05e5ece10e3..89257dbd010a8 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/RenderOptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/RenderOptionsTest.php @@ -12,7 +12,6 @@ /** * Test cases related to check that simple product custom option renders as expected. * - * @magentoDbIsolation disabled * @magentoAppArea frontend */ class RenderOptionsTest extends AbstractRenderCustomOptionsTest diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/CustomOptions/RenderOptionsTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/CustomOptions/RenderOptionsTest.php index 8bac488718217..b38f6a4b6f0a7 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/CustomOptions/RenderOptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/CustomOptions/RenderOptionsTest.php @@ -13,7 +13,6 @@ /** * Test cases related to check that configurable product custom option renders as expected. * - * @magentoDbIsolation disabled * @magentoAppArea frontend */ class RenderOptionsTest extends AbstractRenderCustomOptionsTest From 96ea4d5f260113b010f385b22548410ee57e95f6 Mon Sep 17 00:00:00 2001 From: joweecaquicla <joie@abovethefray.io> Date: Fri, 4 Sep 2020 00:18:12 +0800 Subject: [PATCH 45/99] magento/adobe-stock-integration#1794: [MFTF] Unskip AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest - unskip test --- ...ediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml index 8191d5570f1e8..36df5bf736d1b 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml @@ -9,9 +9,6 @@ <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest"> <annotations> - <skip> - <issueId value="https://github.com/magento/adobe-stock-integration/issues/1794"/> - </skip> <features value="AdminMediaGalleryCategoryGrid"/> <useCaseId value="https://github.com/magento/adobe-stock-integration/issues/1503"/> <title value="User can open each entity the asset is associated with in a separate tab to manage association"/> @@ -84,9 +81,8 @@ <deleteData createDataKey="category" stepKey="deleteCategory"/> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openMediaGallery"/> - <actionGroup ref="AdminEnhancedMediaGalleryViewImageDetails" stepKey="openViewImageDetailsToVerfifyEmptyUsedIn"/> + <actionGroup ref="AdminEnhancedMediaGalleryViewImageDetails" stepKey="openViewImageDetailsToVerifyEmptyUsedIn"/> <actionGroup ref="AssertAdminEnhancedMediaGalleryUsedInSectionNotDisplayedActionGroup" stepKey="assertThereIsNoUsedInSection"/> <actionGroup ref="AdminEnhancedMediaGalleryCloseViewDetailsActionGroup" stepKey="closeDetails"/> - </test> </tests> From e4c0a818f6f02c057dcb3de7d3cf9cd353825dca Mon Sep 17 00:00:00 2001 From: Buba Suma <soumah@adobe.com> Date: Wed, 2 Sep 2020 18:13:38 -0500 Subject: [PATCH 46/99] MC-36214: Issue with saving video position in the first time - Fix new product image/video position is changed after saving product --- .../view/adminhtml/web/js/product-gallery.js | 11 +- .../adminhtml/js/product-gallery.test.js | 132 ++++++++++++++++++ 2 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Catalog/adminhtml/js/product-gallery.test.js diff --git a/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js b/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js index b2a12bea30150..1af0f10770c41 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/js/product-gallery.js @@ -188,12 +188,17 @@ define([ _addItem: function (event, imageData) { var count = this.element.find(this.options.imageSelector).length, element, - imgElement; + imgElement, + position = count + 1, + lastElement = this.element.find(this.options.imageSelector + ':last'); + if (lastElement.length === 1) { + position = parseInt(lastElement.data('imageData').position || count, 10) + 1; + } imageData = $.extend({ 'file_id': imageData['value_id'] ? imageData['value_id'] : Math.random().toString(33).substr(2, 18), 'disabled': imageData.disabled ? imageData.disabled : 0, - 'position': count + 1, + 'position': position, sizeLabel: bytesToSize(imageData.size) }, imageData); @@ -206,7 +211,7 @@ define([ if (count === 0) { element.prependTo(this.element); } else { - element.insertAfter(this.element.find(this.options.imageSelector + ':last')); + element.insertAfter(lastElement); } if (!this.options.initialized && diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Catalog/adminhtml/js/product-gallery.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Catalog/adminhtml/js/product-gallery.test.js new file mode 100644 index 0000000000000..2d6b6cc88fe78 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Catalog/adminhtml/js/product-gallery.test.js @@ -0,0 +1,132 @@ +/* + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +/*eslint-disable max-nested-callbacks*/ +/*jscs:disable jsDoc*/ +define([ + 'jquery', + 'Magento_Catalog/js/product-gallery' +], function ($) { + 'use strict'; + + var galleryEl, + defaultConfig = { + images: [ + { + disabled: 0, + file: '/e/a/earth.jpg', + position: 2, + url: 'http://localhost/media/catalog/product/e/a/earth.jpg', + size: 2048, + 'value_id': 2 + }, + { + disabled: 0, + file: '/m/a/mars.jpg', + position: 3, + url: 'http://localhost/media/catalog/product/m/a/mars.jpg', + size: 3072, + 'value_id': 3 + }, + { + disabled: 0, + file: '/j/u/jupiter.jpg', + position: 5, + size: 5120, + url: 'http://localhost/media/catalog/product/j/u/jupiter.jpg', + 'value_id': 5 + } + ], + types: { + 'image': { + code: 'image', + label: 'Base', + name: 'product[image]' + }, + 'small_image': { + code: 'small_image', + label: 'Small', + name: 'product[image]' + }, + 'thumbnail': { + code: 'thumbnail', + label: 'Thumbnail', + name: 'product[image]' + } + } + }; + + function init(config) { + $(galleryEl).productGallery($.extend({}, defaultConfig, config || {})); + } + + beforeEach(function () { + $('<form>' + + '<div id="media_gallery_content" class="gallery">' + + '<script id="media_gallery_content-template" data-template="image" type="text/x-magento-template">' + + '<div class="image item <% if(data.disabled == 1){ %>hidden-for-front<% } %>" data-role="image">' + + '<input type="hidden" name="product[media_gallery][images][<%- data.file_id %>][position]"' + + ' value="<%- data.position %>" data-form-part="product_form" class="position"/>' + + '<input type="hidden" name="product[media_gallery][images][<%- data.file_id %>][file]"' + + ' value="<%- data.file %>" data-form-part="product_form"/>' + + '<input type="hidden" name="product[media_gallery][images][<%- data.file_id %>][label]"' + + ' value="<%- data.label %>" data-form-part="product_form"/>' + + '<div class="product-image-wrapper">' + + '<img class="product-image" data-role="image-element" src="<%- data.url %>" alt=""/>' + + '<div class="actions"></div>' + + '</div>' + + '</div>' + + '</script>' + + '</div>' + + '</form>' + ).appendTo(document.body); + galleryEl = document.getElementById('media_gallery_content'); + }); + + afterEach(function () { + $(galleryEl).remove(); + galleryEl = undefined; + }); + + describe('Magento_Catalog/js/product-gallery', function () { + describe('_create()', function () { + it('check that existing images are rendered correctly', function () { + init(); + expect($(galleryEl).find('[data-role=image]').length).toBe(3); + expect($(galleryEl).find('[data-role=image]:nth-child(1) .position').val()).toBe('2'); + expect($(galleryEl).find('[data-role=image]:nth-child(2) .position').val()).toBe('3'); + expect($(galleryEl).find('[data-role=image]:nth-child(3) .position').val()).toBe('5'); + }); + }); + describe('_addItem()', function () { + it('check that new image is inserted at the first position if there were no existing images', function () { + init({ + images: [] + }); + $(galleryEl).trigger('addItem', { + file: '/s/a/saturn.jpg.tmp', + name: 'saturn.jpg', + size: 1024, + type: 'image/jpeg', + url: 'http://localhost/media/tmp/catalog/product/s/a/saturn.jpg' + }); + expect($(galleryEl).find('[data-role=image]').length).toBe(1); + expect($(galleryEl).find('[data-role=image]:nth-child(1) .position').val()).toBe('1'); + }); + it('check that new image is inserted at the last position if there were existing images', function () { + init(); + $(galleryEl).trigger('addItem', { + file: '/s/a/saturn.jpg.tmp', + name: 'saturn.jpg', + size: 1024, + type: 'image/jpeg', + url: 'http://localhost/media/tmp/catalog/product/s/a/saturn.jpg' + }); + expect($(galleryEl).find('[data-role=image]').length).toBe(4); + // check that new image position is the position of previous image in the list plus one + expect($(galleryEl).find('[data-role=image]:nth-child(4) .position').val()).toBe('6'); + }); + }); + }); +}); From cbca0326509f10f80085055bf67a241436e246b2 Mon Sep 17 00:00:00 2001 From: joweecaquicla <joie@abovethefray.io> Date: Fri, 4 Sep 2020 03:58:35 +0800 Subject: [PATCH 47/99] magento/adobe-stock-integration#1794: [MFTF] Unskip AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest - modified assert image column --- .../AssertAdminCategoryGridPageImageColumnActionGroup.xml | 7 ++++++- .../AdminMediaGalleryCatalogUiCategoryGridSection.xml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AssertAdminCategoryGridPageImageColumnActionGroup.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AssertAdminCategoryGridPageImageColumnActionGroup.xml index b110ce44a8469..9cd627e900873 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AssertAdminCategoryGridPageImageColumnActionGroup.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AssertAdminCategoryGridPageImageColumnActionGroup.xml @@ -15,6 +15,11 @@ <description>Assert category grid page image column a specific category</description> </annotations> - <seeElement selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.image(file)}}" stepKey="assertImageColumn"/> + <grabAttributeFrom selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.image}}" userInput="src" + stepKey="getImageSrc"/> + <assertStringContainsString stepKey="assertImageSrc"> + <actualResult type="string">{$getImageSrc}</actualResult> + <expectedResult type="string">{{file}}</expectedResult> + </assertStringContainsString> </actionGroup> </actionGroups> diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Section/AdminMediaGalleryCatalogUiCategoryGridSection.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Section/AdminMediaGalleryCatalogUiCategoryGridSection.xml index f65ec84bc2ec8..96b4bad5d5add 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Section/AdminMediaGalleryCatalogUiCategoryGridSection.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Section/AdminMediaGalleryCatalogUiCategoryGridSection.xml @@ -11,7 +11,7 @@ <section name="AdminMediaGalleryCatalogUiCategoryGridSection"> <element name="clearFilters" type="button" selector=".admin__data-grid-header [data-action='grid-filter-reset']" timeout="30"/> <element name="activeFilterPlaceholder" type="text" selector="//div[@class='admin__current-filters-list-wrap']//li//span[contains(text(), '{{filterPlaceholder}}')]" parameterized="true"/> - <element name="image" type="text" selector="//tr//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Image')]/preceding-sibling::th) +1]//img[contains(@src, '{{file}}')]" parameterized="true"/> + <element name="image" type="text" selector="//tr//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Image')]/preceding-sibling::th) +1]//img"/> <element name="columnValue" type="text" selector="//tr//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., '{{columnName}}')]/preceding-sibling::th) +1 ]//div" parameterized="true"/> <element name="edit" type="button" selector="//tr[td//text()[contains(., '{{categoryName}}')]]//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Action')]/preceding-sibling::th) +1 ]//*[text()='{{actionButton}}']" parameterized="true"/> </section> From ba8797a62f1a10370ab86dbc34975bc007c4d251 Mon Sep 17 00:00:00 2001 From: Roman Zhupanyn <roma.dj.elf@gmail.com> Date: Fri, 4 Sep 2020 13:58:43 +0300 Subject: [PATCH 48/99] MC-33493: Test render fields in composite configure block for simple and configurable product --- .../Composite/Fieldset/OptionsTest.php | 17 +++++++------ .../Product/Composite/Fieldset/QtyTest.php | 24 +++++++++++++------ .../Product/Composite/FieldsetTest.php | 11 +++++---- .../AbstractRenderCustomOptionsTest.php | 9 +++---- .../View/Options/RenderOptionsTest.php | 4 +--- .../Composite/Fieldset/ConfigurableTest.php | 7 ++++++ .../View/CustomOptions/RenderOptionsTest.php | 3 +-- .../Product/View/Type/ConfigurableTest.php | 7 +++++- 8 files changed, 51 insertions(+), 31 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php index 36a7d37ecbd2b..c50c21a3328ae 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/OptionsTest.php @@ -15,6 +15,7 @@ use Magento\Catalog\Model\Product\Option; use Magento\Catalog\Model\Product\Option\Value; use Magento\Framework\DataObject; +use Magento\Framework\DataObjectFactory; use Magento\TestFramework\Helper\Xpath; /** @@ -27,6 +28,9 @@ class OptionsTest extends AbstractRenderCustomOptionsTest /** @var HelperProduct */ private $helperProduct; + /** @var DataObjectFactory */ + private $dataObjectFactory; + /** * @inheritdoc */ @@ -35,22 +39,21 @@ protected function setUp(): void parent::setUp(); $this->helperProduct = $this->objectManager->get(HelperProduct::class); + $this->dataObjectFactory = $this->objectManager->get(DataObjectFactory::class); } /** * @magentoDataFixture Magento/Catalog/_files/product_without_options_with_stock_data.php - * @throws \Magento\Framework\Exception\NoSuchEntityException * @return void */ public function testRenderCustomOptionsWithoutOptions(): void { $product = $this->productRepository->get('simple'); - $optionHtml = $this->getOptionHtml($product); $this->assertEquals( 0, Xpath::getElementsCountForXpath( "//fieldset[@id='product_composite_configure_fields_options']", - $optionHtml + $this->getOptionHtml($product) ), 'The option block is expected to be empty!' ); @@ -508,7 +511,7 @@ protected function addOptionToProduct( : $optionValueObject->getOptionTypeId(); } /** @var DataObject $request */ - $buyRequest = $this->objectManager->create(DataObject::class); + $buyRequest = $this->dataObjectFactory->create(); $buyRequest->setData([ 'qty' => 1, 'options' => [$option->getId() => $optionValue], @@ -546,7 +549,7 @@ protected function additionalTypeTextAsserts( if (isset($checkArray['equals_xpath'])) { foreach ($checkArray['equals_xpath'] as $key => $value) { - $value['args'] = $key == 'control_price_attribute' ? [(float)$option->getPrice()] : []; + $value['args'] = $key === 'control_price_attribute' ? [(float)$option->getPrice()] : []; $this->assertEqualsXpath($option, $optionHtml, $value); } } @@ -572,12 +575,12 @@ protected function additionalTypeSelectAsserts( /** * @inheritdoc */ - protected function getHandlesList(ProductInterface $product): array + protected function getHandlesList(): array { return [ 'default', 'CATALOG_PRODUCT_COMPOSITE_CONFIGURE', - 'catalog_product_view_type_' . $product->getTypeId(), + 'catalog_product_view_type_simple', ]; } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/QtyTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/QtyTest.php index b326215688f13..a51b51a73645f 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/QtyTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/Fieldset/QtyTest.php @@ -11,6 +11,7 @@ use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Helper\Product as HelperProduct; use Magento\Framework\DataObject; +use Magento\Framework\DataObjectFactory; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Registry; use Magento\Framework\View\LayoutInterface; @@ -40,17 +41,23 @@ class QtyTest extends TestCase /** @var HelperProduct */ private $helperProduct; + /** @var DataObjectFactory */ + private $dataObjectFactory; + /** * @inheritdoc */ protected function setUp(): void { + parent::setUp(); + $this->objectManager = Bootstrap::getObjectManager(); $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Qty::class); $this->registry = $this->objectManager->get(Registry::class); $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class); $this->productRepository->cleanCache(); $this->helperProduct = $this->objectManager->get(HelperProduct::class); + $this->dataObjectFactory = $this->objectManager->get(DataObjectFactory::class); } /** @@ -60,6 +67,8 @@ protected function tearDown(): void { $this->registry->unregister('current_product'); $this->registry->unregister('product'); + + parent::tearDown(); } /** @@ -70,7 +79,11 @@ public function testGetProduct(): void { $product = $this->productRepository->get('simple-1'); $this->registerProduct($product); - $this->assertSame($product, $this->block->getProduct()); + $this->assertEquals( + $product->getId(), + $this->block->getProduct()->getId(), + 'The expected product is missing in the Qty block!' + ); } /** @@ -80,12 +93,12 @@ public function testGetProduct(): void * @param int $qty * @return void */ - public function testGetQtyValue(bool $isQty, int $qty): void + public function testGetQtyValue(bool $isQty = false, int $qty = 1): void { $product = $this->productRepository->get('simple-1'); if ($isQty) { /** @var DataObject $request */ - $buyRequest = $this->objectManager->create(DataObject::class); + $buyRequest = $this->dataObjectFactory->create(); $buyRequest->setData(['qty' => $qty]); $this->helperProduct->prepareProductOptions($product, $buyRequest); } @@ -105,10 +118,7 @@ public function getQtyValueProvider(): array 'is_qty' => true, 'qty' => 5, ], - 'without_qty' => [ - 'is_qty' => false, - 'qty' => 1, - ], + 'without_qty' => [], ]; } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/FieldsetTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/FieldsetTest.php index 3356d87a92794..ab09314e18cc8 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/FieldsetTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Adminhtml/Product/Composite/FieldsetTest.php @@ -73,8 +73,10 @@ public function testRenderHtml(): void { $product = $this->productRepository->get('simple'); $this->registerProduct($product); - $this->preparePage($product->getTypeId()); - $html = $this->page->getLayout()->getBlock('product.composite.fieldset')->toHtml(); + $this->preparePage(); + $fieldsetBlock = $this->page->getLayout()->getBlock('product.composite.fieldset'); + $this->assertNotFalse($fieldsetBlock, 'Expected fieldset block is missing!'); + $html = $fieldsetBlock->toHtml(); $this->assertEquals( 1, @@ -91,15 +93,14 @@ public function testRenderHtml(): void /** * Prepare page layout * - * @param string $productType * @return void */ - private function preparePage(string $productType): void + private function preparePage(): void { $this->page->addHandle([ 'default', 'CATALOG_PRODUCT_COMPOSITE_CONFIGURE', - 'catalog_product_view_type_' . $productType, + 'catalog_product_view_type_simple', ]); $this->page->getLayout()->generateXml(); } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php index 553130deddbee..44c9ada3cacab 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php @@ -58,6 +58,7 @@ protected function setUp(): void { $this->objectManager = Bootstrap::getObjectManager(); $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class); + $this->productRepository->cleanCache(); $this->productCustomOptionFactory = $this->objectManager->get(ProductCustomOptionInterfaceFactory::class); $this->productCustomOptionValuesFactory = $this->objectManager->get( ProductCustomOptionValuesInterfaceFactory::class @@ -376,6 +377,7 @@ protected function getOptionHtml(ProductInterface $product): string $this->page->getLayout()->generateXml(); /** @var Options $optionsBlock */ $optionsBlock = $this->page->getLayout()->getBlock($this->getOptionsBlockName()); + $this->assertNotFalse($optionsBlock); $optionsBlock->setProduct($product); return $optionsBlock->toHtml(); @@ -426,21 +428,16 @@ protected function findOptionValueByTitle( /** * Return all need handles for load. * - * @param ProductInterface $product * @return array */ - abstract protected function getHandlesList(ProductInterface $product): array; + abstract protected function getHandlesList(): array; /** - * - * * @return string */ abstract protected function getMaxCharactersCssClass(): string; /** - * - * * @return string */ abstract protected function getOptionsBlockName(): string; diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/RenderOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/RenderOptionsTest.php index 89257dbd010a8..83c249ed062e6 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/RenderOptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/RenderOptionsTest.php @@ -7,8 +7,6 @@ namespace Magento\Catalog\Block\Product\View\Options; -use Magento\Catalog\Api\Data\ProductInterface; - /** * Test cases related to check that simple product custom option renders as expected. * @@ -83,7 +81,7 @@ public function testRenderCustomOptionsFromDateGroup(array $optionData, array $c /** * @inheritdoc */ - protected function getHandlesList(ProductInterface $product): array + protected function getHandlesList(): array { return [ 'default', diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Adminhtml/Product/Composite/Fieldset/ConfigurableTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Adminhtml/Product/Composite/Fieldset/ConfigurableTest.php index 3ada18a1849c9..88c8fb726c472 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Adminhtml/Product/Composite/Fieldset/ConfigurableTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Adminhtml/Product/Composite/Fieldset/ConfigurableTest.php @@ -59,6 +59,8 @@ protected function setUp(): void protected function tearDown(): void { $this->registry->unregister('product'); + + parent::tearDown(); } /** @@ -71,6 +73,11 @@ public function testGetProduct(): void $this->registerProduct($product); $blockProduct = $this->block->getProduct(); $this->assertSame($product, $blockProduct); + $this->assertEquals( + $product->getId(), + $blockProduct->getId(), + 'The expected product is missing in the Configurable block!' + ); $this->assertNotNull($blockProduct->getTypeInstance()->getStoreFilter($blockProduct)); } diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/CustomOptions/RenderOptionsTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/CustomOptions/RenderOptionsTest.php index b38f6a4b6f0a7..303a32d34bf6c 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/CustomOptions/RenderOptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/CustomOptions/RenderOptionsTest.php @@ -7,7 +7,6 @@ namespace Magento\ConfigurableProduct\Block\Product\View\CustomOptions; -use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Block\Product\View\Options\AbstractRenderCustomOptionsTest; /** @@ -85,7 +84,7 @@ public function testRenderCustomOptionsFromDateGroup(array $optionData, array $c /** * @inheritdoc */ - protected function getHandlesList(ProductInterface $product): array + protected function getHandlesList(): array { return [ 'default', diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php index 62b691d61efb3..0344d467a3cc2 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php @@ -15,6 +15,7 @@ use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Attribute\Collection; use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\DataObject; +use Magento\Framework\DataObjectFactory; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Serialize\SerializerInterface; use Magento\Framework\View\LayoutInterface; @@ -73,6 +74,9 @@ class ConfigurableTest extends TestCase */ private $helperProduct; + /** @var DataObjectFactory */ + private $dataObjectFactory; + /** * @inheritdoc */ @@ -89,6 +93,7 @@ protected function setUp(): void $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Configurable::class); $this->block->setProduct($this->product); $this->helperProduct = $this->objectManager->get(HelperProduct::class); + $this->dataObjectFactory = $this->objectManager->get(DataObjectFactory::class); } /** @@ -149,7 +154,7 @@ public function testGetJsonConfigWithPreconfiguredValues(): void $attribute->getAttributeId() => $attribute->getOptions()[0]['value_index'], ]; /** @var DataObject $request */ - $buyRequest = $this->objectManager->create(DataObject::class); + $buyRequest = $this->dataObjectFactory->create(); $buyRequest->setData([ 'qty' => 1, 'super_attribute' => $expectedAttributeValue, From 2c6953783b2078a7f2a7de39644685e6e2a91e1d Mon Sep 17 00:00:00 2001 From: eduard13 <e.chitoraga@atwix.com> Date: Fri, 4 Sep 2020 14:45:25 +0300 Subject: [PATCH 49/99] Fixing the default value when wishlist item quantity isn't defined --- .../Wishlist/Model/Wishlist/Data/WishlistItemFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Wishlist/Model/Wishlist/Data/WishlistItemFactory.php b/app/code/Magento/Wishlist/Model/Wishlist/Data/WishlistItemFactory.php index aef3cbf571ff6..622f072e8d668 100644 --- a/app/code/Magento/Wishlist/Model/Wishlist/Data/WishlistItemFactory.php +++ b/app/code/Magento/Wishlist/Model/Wishlist/Data/WishlistItemFactory.php @@ -24,7 +24,7 @@ class WishlistItemFactory public function create(array $data): WishlistItem { return new WishlistItem( - $data['quantity'], + $data['quantity'] ?? 0, $data['sku'] ?? null, $data['parent_sku'] ?? null, isset($data['wishlist_item_id']) ? (int) $data['wishlist_item_id'] : null, From bb408984f2d58d301eef6d8faf3bff2c268f385f Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky <engcom-vendorworker-foxtrot@adobe.com> Date: Fri, 4 Sep 2020 15:24:24 +0300 Subject: [PATCH 50/99] magento/magento2#26526: OrderRepository does not check if there are no extensionAttributes. --- .../Test/Unit/Model/OrderRepositoryTest.php | 69 +++++++++++++++++-- 1 file changed, 64 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php index 84c66d12c10d8..407d158e6f8d4 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php @@ -18,12 +18,13 @@ use Magento\Sales\Api\Data\OrderInterface; use Magento\Sales\Api\Data\OrderPaymentInterface; use Magento\Sales\Api\Data\OrderSearchResultInterfaceFactory as SearchResultFactory; +use Magento\Sales\Model\Order; use Magento\Sales\Model\Order\Shipping; use Magento\Sales\Model\Order\ShippingAssignment; use Magento\Sales\Model\Order\ShippingAssignmentBuilder; use Magento\Sales\Model\OrderRepository; use Magento\Sales\Model\ResourceModel\Metadata; -use Magento\Sales\Model\ResourceModel\Order; +use Magento\Sales\Model\ResourceModel\Order as OrderResource; use Magento\Sales\Model\ResourceModel\Order\Collection; use Magento\Tax\Api\Data\OrderTaxDetailsInterface; use Magento\Tax\Api\OrderTaxManagementInterface; @@ -70,6 +71,11 @@ class OrderRepositoryTest extends TestCase */ private $paymentAdditionalInfoFactory; + /** + * @var OrderExtensionFactory|\PHPUnit_Framework_MockObject_MockObject + */ + private $orderExtensionFactoryMock; + /** * Setup the test * @@ -88,7 +94,7 @@ protected function setUp(): void $this->collectionProcessor = $this->createMock( CollectionProcessorInterface::class ); - $orderExtensionFactoryMock = $this->getMockBuilder(OrderExtensionFactory::class) + $this->orderExtensionFactoryMock = $this->getMockBuilder(OrderExtensionFactory::class) ->disableOriginalConstructor() ->getMock(); $this->orderTaxManagementMock = $this->getMockBuilder(OrderTaxManagementInterface::class) @@ -103,7 +109,7 @@ protected function setUp(): void 'metadata' => $this->metadata, 'searchResultFactory' => $this->searchResultFactory, 'collectionProcessor' => $this->collectionProcessor, - 'orderExtensionFactory' => $orderExtensionFactoryMock, + 'orderExtensionFactory' => $this->orderExtensionFactoryMock, 'orderTaxManagement' => $this->orderTaxManagementMock, 'paymentAdditionalInfoFactory' => $this->paymentAdditionalInfoFactory ] @@ -178,10 +184,10 @@ public function testGetList() */ public function testSave() { - $mapperMock = $this->getMockBuilder(Order::class) + $mapperMock = $this->getMockBuilder(OrderResource::class) ->disableOriginalConstructor() ->getMock(); - $orderEntity = $this->createMock(\Magento\Sales\Model\Order::class); + $orderEntity = $this->createMock(Order::class); $extensionAttributes = $this->getMockBuilder(OrderExtension::class) ->addMethods(['getShippingAssignments']) ->getMock(); @@ -207,4 +213,57 @@ public function testSave() $orderEntity->expects($this->any())->method('getEntityId')->willReturn(1); $this->orderRepository->save($orderEntity); } + + /** + * Test for method get. + * + * @return void + */ + public function testGet() + { + $orderId = 1; + $appliedTaxes = 'applied_taxes'; + $items = 'items'; + $paymentInfo = []; + + $orderEntity = $this->createMock(Order::class); + $paymentMock = $this->getMockBuilder(OrderPaymentInterface::class) + ->disableOriginalConstructor()->getMockForAbstractClass(); + $paymentMock->expects($this->once())->method('getAdditionalInformation')->willReturn($paymentInfo); + $orderExtension = $this->getMockBuilder(OrderExtension::class) + ->setMethods( + [ + 'getShippingAssignments', + 'setAppliedTaxes', + 'setConvertingFromQuote', + 'setItemAppliedTaxes', + 'setPaymentAdditionalInfo' + ] + ) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $orderExtension->expects($this->once())->method('getShippingAssignments')->willReturn(true); + $orderExtension->expects($this->once())->method('setAppliedTaxes')->with($appliedTaxes); + $orderExtension->expects($this->once())->method('setConvertingFromQuote')->with(true); + $orderExtension->expects($this->once())->method('setItemAppliedTaxes')->with($items); + $orderExtension->expects($this->once())->method('setPaymentAdditionalInfo')->with($paymentInfo); + $this->orderExtensionFactoryMock->expects($this->once())->method('create')->willReturn($orderExtension); + $orderEntity->expects($this->once())->method('load')->with($orderId)->willReturn($orderEntity); + $orderEntity->expects($this->exactly(2))->method('getEntityId')->willReturn($orderId); + $orderEntity->expects($this->once())->method('getPayment')->willReturn($paymentMock); + $orderEntity->expects($this->exactly(2))->method('setExtensionAttributes')->with($orderExtension); + $orderEntity->expects($this->exactly(3)) + ->method('getExtensionAttributes') + ->willReturnOnConsecutiveCalls(null, $orderExtension, $orderExtension); + $this->metadata->expects($this->once())->method('getNewInstance')->willReturn($orderEntity); + $orderTaxDetailsMock = $this->getMockBuilder(OrderTaxDetailsInterface::class) + ->disableOriginalConstructor() + ->setMethods(['setAppliedTaxes'])->getMockForAbstractClass(); + $orderTaxDetailsMock->expects($this->once())->method('getAppliedTaxes')->willReturn($appliedTaxes); + $orderTaxDetailsMock->expects($this->once())->method('getItems')->willReturn($items); + $this->orderTaxManagementMock->expects($this->atLeastOnce())->method('getOrderTaxDetails') + ->willReturn($orderTaxDetailsMock); + + $this->orderRepository->get($orderId); + } } From 86e96564509e78fb04670d2f2d7157d08e9d0189 Mon Sep 17 00:00:00 2001 From: joweecaquicla <joie@abovethefray.io> Date: Fri, 4 Sep 2020 21:06:15 +0800 Subject: [PATCH 51/99] magento/adobe-stock-integration#1794: [MFTF] Unskip AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest - fixed spacing on data --- .../Test/Mftf/Data/AdminEnhancedMediaGalleryImageData.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Data/AdminEnhancedMediaGalleryImageData.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Data/AdminEnhancedMediaGalleryImageData.xml index dbc298798ee8e..4adf92b1c4c09 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Data/AdminEnhancedMediaGalleryImageData.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Data/AdminEnhancedMediaGalleryImageData.xml @@ -24,7 +24,7 @@ <data key="fileName">png</data> <data key="extension">png</data> </entity> - <entity name="ImageUploadGif" type="uploadImage"> + <entity name="ImageUploadGif" type="uploadImage"> <data key="title" unique="suffix">Image1</data> <data key="file_type">Upload File</data> <data key="value">gif.gif</data> From 80c1f3ca7e0abffbf214c14292cd6fe322f0b484 Mon Sep 17 00:00:00 2001 From: joweecaquicla <joie@abovethefray.io> Date: Fri, 4 Sep 2020 22:25:01 +0800 Subject: [PATCH 52/99] magento/adobe-stock-integration#1795: [MFTF] Unskip AdminMediaGalleryCatalogUiUsedInProductFilterTest - modified test and actiongroup --- ...dminAssertMediaGalleryFilterPlaceHolderGridActionGroup.xml | 2 +- .../AdminMediaGalleryCatalogUiUsedInProductFilterTest.xml | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AdminAssertMediaGalleryFilterPlaceHolderGridActionGroup.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AdminAssertMediaGalleryFilterPlaceHolderGridActionGroup.xml index e21fa89965391..fbf4437b8266d 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AdminAssertMediaGalleryFilterPlaceHolderGridActionGroup.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AdminAssertMediaGalleryFilterPlaceHolderGridActionGroup.xml @@ -15,6 +15,6 @@ <argument name="filterPlaceholder" type="string"/> </arguments> - <see selector="{{AdminProductGridFilterSection.enabledFilters}}" userInput="{{filterPlaceholder}}" stepKey="seeFilter"/> + <see selector="{{AdminProductGridFilterSection.enabledFilters}}" userInput="SKU: {{filterPlaceholder}}" stepKey="seeFilter"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiUsedInProductFilterTest.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiUsedInProductFilterTest.xml index d2a04a7d21d11..11b64c596fb84 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiUsedInProductFilterTest.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiUsedInProductFilterTest.xml @@ -9,9 +9,6 @@ <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> <test name="AdminMediaGalleryCatalogUiUsedInProductFilterTest"> <annotations> - <skip> - <issueId value="https://github.com/magento/adobe-stock-integration/issues/1795"/> - </skip> <features value="AdminMediaGalleryUsedInProductsFilter"/> <useCaseId value="https://github.com/magento/adobe-stock-integration/issues/1503"/> <title value="User can open product entity the asset is associated"/> @@ -65,6 +62,7 @@ <deleteData createDataKey="product" stepKey="deleteProduct"/> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openMediaGallery"/> + <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> <actionGroup ref="AdminEnhancedMediaGalleryViewImageDetails" stepKey="openViewImageDetailsToAssertEmptyUsedIn"/> <actionGroup ref="AssertAdminEnhancedMediaGalleryUsedInSectionNotDisplayedActionGroup" stepKey="assertThereIsNoUsedInSection"/> <actionGroup ref="AdminEnhancedMediaGalleryCloseViewDetailsActionGroup" stepKey="closeDetails"/> From 055ad7e58e21ff7748493892c43eb980cddc3984 Mon Sep 17 00:00:00 2001 From: joweecaquicla <joie@abovethefray.io> Date: Fri, 4 Sep 2020 23:50:04 +0800 Subject: [PATCH 53/99] magento/adobe-stock-integration#1795: [MFTF] Unskip AdminMediaGalleryCatalogUiUsedInProductFilterTest - modified actiongroup --- .../AdminAssertMediaGalleryFilterPlaceHolderGridActionGroup.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AdminAssertMediaGalleryFilterPlaceHolderGridActionGroup.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AdminAssertMediaGalleryFilterPlaceHolderGridActionGroup.xml index fbf4437b8266d..e21fa89965391 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AdminAssertMediaGalleryFilterPlaceHolderGridActionGroup.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AdminAssertMediaGalleryFilterPlaceHolderGridActionGroup.xml @@ -15,6 +15,6 @@ <argument name="filterPlaceholder" type="string"/> </arguments> - <see selector="{{AdminProductGridFilterSection.enabledFilters}}" userInput="SKU: {{filterPlaceholder}}" stepKey="seeFilter"/> + <see selector="{{AdminProductGridFilterSection.enabledFilters}}" userInput="{{filterPlaceholder}}" stepKey="seeFilter"/> </actionGroup> </actionGroups> From f3ea93f27c2d7b6258bab7c165ede0ca5a219af0 Mon Sep 17 00:00:00 2001 From: joweecaquicla <joie@abovethefray.io> Date: Sat, 5 Sep 2020 01:02:06 +0800 Subject: [PATCH 54/99] magento/adobe-stock-integration#1794: [MFTF] Unskip AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest - modified actiongroup, test and added new category data entity --- ...eProductsInMenuEnabledColumnsActionGroup.xml | 5 +++++ .../AdminEnhancedMediaGalleryCategoryData.xml | 17 +++++++++++++++++ ...atalogUiVerifyUsedInLinkCategoryGridTest.xml | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Data/AdminEnhancedMediaGalleryCategoryData.xml diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AssertAdminCategoryGridPageProductsInMenuEnabledColumnsActionGroup.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AssertAdminCategoryGridPageProductsInMenuEnabledColumnsActionGroup.xml index e5d6f26e777fc..15b0ff149d807 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AssertAdminCategoryGridPageProductsInMenuEnabledColumnsActionGroup.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AssertAdminCategoryGridPageProductsInMenuEnabledColumnsActionGroup.xml @@ -12,6 +12,11 @@ <description>Assert category grid page products, in menu, and enabled column values for a specific category</description> </annotations> + <grabTextFrom selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.columnValue('Display Mode')}}" stepKey="grabDisplayModeColumnValue"/> + <assertEquals stepKey="assertDisplayModeColumn"> + <expectedResult type="string">PRODUCTS</expectedResult> + <actualResult type="variable">grabDisplayModeColumnValue</actualResult> + </assertEquals> <grabTextFrom selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.columnValue('Products')}}" stepKey="grabProductsColumnValue"/> <assertEquals stepKey="assertProductsColumn"> <expectedResult type="string">0</expectedResult> diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Data/AdminEnhancedMediaGalleryCategoryData.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Data/AdminEnhancedMediaGalleryCategoryData.xml new file mode 100644 index 0000000000000..34cc0f4fa752c --- /dev/null +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Data/AdminEnhancedMediaGalleryCategoryData.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> + <entity name="TestSubCategory" type="category"> + <data key="name">TestSubCategory</data> + <data key="name_lwr">testsubcategory</data> + <data key="is_active">true</data> + <data key="include_in_menu">true</data> + </entity> +</entities> diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml index 36df5bf736d1b..dba78d0cf5261 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml @@ -19,7 +19,7 @@ <group value="media_gallery_ui"/> </annotations> <before> - <createData entity="SimpleSubCategory" stepKey="category"/> + <createData entity="TestSubCategory" stepKey="category"/> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> </before> <after> From a298f3b7123ff5fce15822aa7b3d8c9186dec584 Mon Sep 17 00:00:00 2001 From: joweecaquicla <joie@abovethefray.io> Date: Sat, 5 Sep 2020 02:35:29 +0800 Subject: [PATCH 55/99] magento/adobe-stock-integration#1795: [MFTF] Unskip AdminMediaGalleryCatalogUiUsedInProductFilterTest - modified test file --- .../AdminMediaGalleryCatalogUiUsedInProductFilterTest.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiUsedInProductFilterTest.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiUsedInProductFilterTest.xml index 11b64c596fb84..3caa106ffa245 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiUsedInProductFilterTest.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiUsedInProductFilterTest.xml @@ -43,6 +43,8 @@ <actionGroup ref="AdminMediaGalleryClickAddSelectedActionGroup" stepKey="clickAddSelectedContentImage"/> <actionGroup ref="AdminMediaGalleryClickOkButtonTinyMce4ActionGroup" stepKey="clickOkButton"/> <actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/> + <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="openProductsGrid"/> + <actionGroup ref="AdminClearFiltersActionGroup" stepKey="clearFilters"/> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGallery"/> <actionGroup ref="AdminEnhancedMediaGalleryExpandFilterActionGroup" stepKey="expandFilters"/> <actionGroup ref="AdminEnhancedMediaGallerySelectUsedInFilterActionGroup" stepKey="setUsedInFilter"> @@ -57,7 +59,7 @@ </actionGroup> <actionGroup ref="AdminAssertMediaGalleryFilterPlaceHolderGridActionGroup" stepKey="assertFilterApplied"> - <argument name="filterPlaceholder" value="$$product.name$$"/> + <argument name="filterPlaceholder" value="{{ImageMetadata.title}}"/> </actionGroup> <deleteData createDataKey="product" stepKey="deleteProduct"/> @@ -71,7 +73,7 @@ <actionGroup ref="AdminEnhancedMediaGallerySelectImageForMassActionActionGroup" stepKey="selectFirstImageToDelete"> <argument name="imageName" value="{{ImageMetadata.title}}"/> </actionGroup> - <actionGroup ref="AdminEnhancedMediaGalleryClickDeleteImagesButtonActionGroup" stepKey="clikDeleteSelectedButton"/> + <actionGroup ref="AdminEnhancedMediaGalleryClickDeleteImagesButtonActionGroup" stepKey="clickDeleteSelectedButton"/> <actionGroup ref="AdminEnhancedMediaGalleryConfirmDeleteImagesActionGroup" stepKey="deleteImages"/> </test> From 27a9befc488ef2fd097d3779d150a0a9de75363c Mon Sep 17 00:00:00 2001 From: joweecaquicla <joie@abovethefray.io> Date: Sat, 5 Sep 2020 03:43:34 +0800 Subject: [PATCH 56/99] magento/adobe-stock-integration#1794: [MFTF] Unskip AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest - modified custom category entity, actiongroup, and test --- ...oryGridPageProductsInMenuEnabledColumnsActionGroup.xml | 5 ----- .../Mftf/Data/AdminEnhancedMediaGalleryCategoryData.xml | 4 ++-- ...iaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml | 8 ++++++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AssertAdminCategoryGridPageProductsInMenuEnabledColumnsActionGroup.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AssertAdminCategoryGridPageProductsInMenuEnabledColumnsActionGroup.xml index 15b0ff149d807..e5d6f26e777fc 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AssertAdminCategoryGridPageProductsInMenuEnabledColumnsActionGroup.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/ActionGroup/AssertAdminCategoryGridPageProductsInMenuEnabledColumnsActionGroup.xml @@ -12,11 +12,6 @@ <description>Assert category grid page products, in menu, and enabled column values for a specific category</description> </annotations> - <grabTextFrom selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.columnValue('Display Mode')}}" stepKey="grabDisplayModeColumnValue"/> - <assertEquals stepKey="assertDisplayModeColumn"> - <expectedResult type="string">PRODUCTS</expectedResult> - <actualResult type="variable">grabDisplayModeColumnValue</actualResult> - </assertEquals> <grabTextFrom selector="{{AdminMediaGalleryCatalogUiCategoryGridSection.columnValue('Products')}}" stepKey="grabProductsColumnValue"/> <assertEquals stepKey="assertProductsColumn"> <expectedResult type="string">0</expectedResult> diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Data/AdminEnhancedMediaGalleryCategoryData.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Data/AdminEnhancedMediaGalleryCategoryData.xml index 34cc0f4fa752c..d123cce516533 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Data/AdminEnhancedMediaGalleryCategoryData.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Data/AdminEnhancedMediaGalleryCategoryData.xml @@ -9,8 +9,8 @@ <entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> <entity name="TestSubCategory" type="category"> - <data key="name">TestSubCategory</data> - <data key="name_lwr">testsubcategory</data> + <data key="name" unique="suffix">TestSubCategory</data> + <data key="name_lwr" unique="suffix">testsubcategory</data> <data key="is_active">true</data> <data key="include_in_menu">true</data> </entity> diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml index dba78d0cf5261..aaba740930267 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml @@ -21,13 +21,16 @@ <before> <createData entity="TestSubCategory" stepKey="category"/> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> + <argument name="tags" value=""/> + </actionGroup> </before> <after> <actionGroup ref="AdminEnhancedMediaGalleryEnableMassActionModeActionGroup" stepKey="enableMassActionToDeleteImages"/> <actionGroup ref="AdminEnhancedMediaGallerySelectImageForMassActionActionGroup" stepKey="selectSecondImageToDelete"> <argument name="imageName" value="{{UpdatedImageDetails.title}}"/> </actionGroup> - <actionGroup ref="AdminEnhancedMediaGalleryClickDeleteImagesButtonActionGroup" stepKey="clikDeleteSelectedButton"/> + <actionGroup ref="AdminEnhancedMediaGalleryClickDeleteImagesButtonActionGroup" stepKey="clickDeleteSelectedButton"/> <actionGroup ref="AdminEnhancedMediaGalleryConfirmDeleteImagesActionGroup" stepKey="deleteImages"/> </after> @@ -36,6 +39,7 @@ <argument name="category" value="$$category$$"/> </actionGroup> <actionGroup ref="AdminOpenMediaGalleryFromCategoryImageUploaderActionGroup" stepKey="openMediaGalleryFromImageUploader"/> + <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetCategoryImageGalleryGridToDefaultView"/> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage"> <argument name="image" value="ImageUpload"/> </actionGroup> @@ -77,7 +81,7 @@ <actionGroup ref="AssertAdminMediaGalleryAssetFilterPlaceHolderActionGroup" stepKey="assertFilterAppliedAfterUrlFilterApplier"> <argument name="filterPlaceholder" value="{{UpdatedImageDetails.title}}"/> </actionGroup> - <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> + <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="secondResetAdminDataGridToDefaultView"/> <deleteData createDataKey="category" stepKey="deleteCategory"/> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openMediaGallery"/> From b308c33d0e0eeebbe5e3019263d4fcc724f36c86 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov <oiegorov@adobe.com> Date: Fri, 4 Sep 2020 16:27:14 -0500 Subject: [PATCH 57/99] MC-36942: HTML minification strips triple slashes from html string in phtml --- lib/internal/Magento/Framework/View/Template/Html/Minifier.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/View/Template/Html/Minifier.php b/lib/internal/Magento/Framework/View/Template/Html/Minifier.php index cdbce9d102a89..dba81a1547c44 100644 --- a/lib/internal/Magento/Framework/View/Template/Html/Minifier.php +++ b/lib/internal/Magento/Framework/View/Template/Html/Minifier.php @@ -144,7 +144,7 @@ function ($match) use (&$heredocs) { '#(?<!:|\\\\|\'|"|/)//(?!/)(?!\s*\<\!\[)(?!\s*]]\>)[^\n\r]*#', '', preg_replace( - '#(?<!:|\'|")//[^\n\r]*(\?\>)#', + '#(?<!:|\'|")//[^\n\r\<\?]*(\?\>)#', ' $1', preg_replace( '#(?<!:)//[^\n\r]*(\<\?php)[^\n\r]*(\s\?\>)[^\n\r]*#', From 4c6606600f01d963dd2f56cd850558efe5ba25f6 Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Sun, 6 Sep 2020 18:19:35 +0300 Subject: [PATCH 58/99] use depricated tag --- .../Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml index 29e100a7e9c37..4da29104797ac 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml @@ -7,10 +7,7 @@ --> <actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <actionGroup name="AdminOpenCmsBlockActionGroup"> - <annotations> - <description>DEPRECATED. Use AdminOpenCmsPageActionGroup instead.</description> - </annotations> + <actionGroup name="AdminOpenCmsBlockActionGroup" deprecated="Use AdminOpenCmsBlockActionGroup instead."> <arguments> <argument name="block_id" type="string"/> </arguments> From 811861c0609edcb71e7ae7cbb8e019e8e53aaa65 Mon Sep 17 00:00:00 2001 From: joweecaquicla <joie@abovethefray.io> Date: Mon, 7 Sep 2020 19:04:47 +0800 Subject: [PATCH 59/99] magento/adobe-stock-integration#1794: [MFTF] Unskip AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest - change to cache clean --- ...nMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml index aaba740930267..eb2f75dad0151 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml @@ -21,8 +21,8 @@ <before> <createData entity="TestSubCategory" stepKey="category"/> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> - <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> - <argument name="tags" value=""/> + <actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanFullPageCache"> + <argument name="tags" value="config full_page"/> </actionGroup> </before> <after> From d0ba33745ab8bedcd4a18f6757c7d5dd9ac4712a Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Mon, 7 Sep 2020 16:17:13 +0300 Subject: [PATCH 60/99] added AdminDeleteTaxRateActionGroup --- .../AdminDeleteTaxRateActionGroup.xml | 28 +++++++++++++++++++ .../AdminCreateTaxRateAllPostCodesTest.xml | 9 ++---- .../Test/AdminCreateTaxRateLargeRateTest.xml | 9 ++---- ...AdminCreateTaxRateSpecificPostcodeTest.xml | 9 ++---- ...dminCreateTaxRateWiderZipCodeRangeTest.xml | 9 ++---- .../AdminCreateTaxRateZipCodeRangeTest.xml | 9 ++---- .../Mftf/Test/DeleteTaxRateEntityTest.xml | 11 +++----- 7 files changed, 47 insertions(+), 37 deletions(-) create mode 100644 app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminDeleteTaxRateActionGroup.xml diff --git a/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminDeleteTaxRateActionGroup.xml b/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminDeleteTaxRateActionGroup.xml new file mode 100644 index 0000000000000..b609ef8827764 --- /dev/null +++ b/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminDeleteTaxRateActionGroup.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminDeleteTaxRateActionGroup"> + <annotations> + <description>Goes to the Admin Tax Rate grid page. Deletes the provided Tax Rate Code.</description> + </annotations> + <arguments> + <argument name="taxRateCode" type="string"/> + </arguments> + + <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters"/> + <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{taxRateCode}}" stepKey="fillNameFilter"/> + <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch"/> + <waitForPageLoad stepKey="waitForTaxRuleSearch"/> + <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + <click selector="{{AdminTaxRateFormSection.deleteRate}}" stepKey="clickDeleteRate"/> + <click selector="{{AdminTaxRateFormSection.ok}}" stepKey="clickOk"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml index be7185a5166a2..f2f7d78ea2650 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml @@ -23,12 +23,9 @@ </before> <after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> - <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{SimpleTaxRate.code}}" stepKey="fillNameFilter"/> - <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch"/> - <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow"/> - <click selector="{{AdminTaxRateFormSection.deleteRate}}" stepKey="clickDeleteRate"/> - <click selector="{{AdminTaxRateFormSection.ok}}" stepKey="clickOk"/> + <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"> + <argument name="taxRateCode" value="{{SimpleTaxRate.code}}" /> + </actionGroup> </after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml index 89cfdd0eb9943..144f6b644d168 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml @@ -23,12 +23,9 @@ </before> <after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> - <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{SimpleTaxRate.code}}" stepKey="fillNameFilter"/> - <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch"/> - <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow"/> - <click selector="{{AdminTaxRateFormSection.deleteRate}}" stepKey="clickDeleteRate"/> - <click selector="{{AdminTaxRateFormSection.ok}}" stepKey="clickOk"/> + <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"> + <argument name="taxRateCode" value="{{SimpleTaxRate.code}}" /> + </actionGroup> </after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml index a3386cada436f..49a89b33d55d0 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml @@ -23,12 +23,9 @@ </before> <after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> - <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{SimpleTaxRate.code}}" stepKey="fillNameFilter"/> - <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch"/> - <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow"/> - <click selector="{{AdminTaxRateFormSection.deleteRate}}" stepKey="clickDeleteRate"/> - <click selector="{{AdminTaxRateFormSection.ok}}" stepKey="clickOk"/> + <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"> + <argument name="taxRateCode" value="{{SimpleTaxRate.code}}" /> + </actionGroup> </after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml index 6ceeae953139c..620ad1909c6f8 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml @@ -23,12 +23,9 @@ </before> <after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> - <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{SimpleTaxRate.code}}" stepKey="fillNameFilter"/> - <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch"/> - <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow"/> - <click selector="{{AdminTaxRateFormSection.deleteRate}}" stepKey="clickDeleteRate"/> - <click selector="{{AdminTaxRateFormSection.ok}}" stepKey="clickOk"/> + <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"> + <argument name="taxRateCode" value="{{SimpleTaxRate.code}}" /> + </actionGroup> </after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml index 4f9e876fed696..fe8f67f880f49 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml @@ -23,12 +23,9 @@ </before> <after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> - <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{SimpleTaxRate.code}}" stepKey="fillNameFilter"/> - <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch"/> - <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow1"/> - <click selector="{{AdminTaxRateFormSection.deleteRate}}" stepKey="clickDeleteRate"/> - <click selector="{{AdminTaxRateFormSection.ok}}" stepKey="clickOk"/> + <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"> + <argument name="taxRateCode" value="{{SimpleTaxRate.code}}" /> + </actionGroup> </after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml index eb774297b8322..baae945bd8d1d 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml @@ -25,14 +25,11 @@ <!-- Search the tax rate on tax grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters1"/> - <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="$$initialTaxRate.code$$" stepKey="fillCode"/> - <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch1"/> - <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow1"/> - <!-- Delete values on the tax rate form page --> - <click selector="{{AdminTaxRateFormSection.deleteRate}}" stepKey="clickDeleteRate"/> - <click selector="{{AdminTaxRateFormSection.ok}}" stepKey="clickOk"/> + <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"> + <argument name="taxRateCode" value="{{initialTaxRate.code}}" /> + </actionGroup> + <see selector="{{AdminMessagesSection.success}}" userInput="You Deleted the tax rate." stepKey="seeSuccess1"/> <!-- Confirm Deleted TaxIdentifier(from the above step) on the tax rate grid page --> From 3095bbef26969e44446247f18fa0707f2aab2894 Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Mon, 7 Sep 2020 16:38:33 +0300 Subject: [PATCH 61/99] add clear description --- .../Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml index 4da29104797ac..0a2eaacfc613c 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.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="AdminOpenCmsBlockActionGroup" deprecated="Use AdminOpenCmsBlockActionGroup instead."> + <actionGroup name="AdminOpenCmsBlockActionGroup" deprecated="Use app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpenCmsBlockActionGroup.xml instead."> <arguments> <argument name="block_id" type="string"/> </arguments> From dbd414ca9fc800b9dbedf166c18993930e345b7e Mon Sep 17 00:00:00 2001 From: Buba Suma <soumah@adobe.com> Date: Fri, 28 Aug 2020 18:30:50 -0500 Subject: [PATCH 62/99] MC-33626: Unable to add product with multi-source inventory to wishlist with - Add multi-source inventory for wishlist module --- .../Model/ResourceModel/StockStatusFilter.php | 74 +++++++++++++++++++ .../StockStatusFilterInterface.php | 34 +++++++++ app/code/Magento/CatalogInventory/etc/di.xml | 1 + .../Model/ResourceModel/Item/Collection.php | 54 ++++++++++---- app/code/Magento/Wishlist/Model/Wishlist.php | 44 +++-------- .../Wishlist/Test/Unit/Model/WishlistTest.php | 60 +++++++++++---- .../_files/wishlist_with_disabled_product.php | 6 +- .../_files/wishlist_with_simple_product.php | 5 ++ 8 files changed, 212 insertions(+), 66 deletions(-) create mode 100644 app/code/Magento/CatalogInventory/Model/ResourceModel/StockStatusFilter.php create mode 100644 app/code/Magento/CatalogInventory/Model/ResourceModel/StockStatusFilterInterface.php diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/StockStatusFilter.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/StockStatusFilter.php new file mode 100644 index 0000000000000..e9497a1d44861 --- /dev/null +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/StockStatusFilter.php @@ -0,0 +1,74 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogInventory\Model\ResourceModel; + +use Magento\CatalogInventory\Api\Data\StockStatusInterface; +use Magento\CatalogInventory\Api\StockConfigurationInterface; +use Magento\CatalogInventory\Model\Stock; +use Magento\Framework\App\ResourceConnection; +use Magento\Framework\DB\Select; + +/** + * Generic in-stock status filter + */ +class StockStatusFilter implements StockStatusFilterInterface +{ + private const TABLE_NAME = 'cataloginventory_stock_status'; + /** + * @var ResourceConnection + */ + private $resource; + + /** + * @var StockConfigurationInterface + */ + private $stockConfiguration; + + /** + * @param ResourceConnection $resource + * @param StockConfigurationInterface $stockConfiguration + */ + public function __construct( + ResourceConnection $resource, + StockConfigurationInterface $stockConfiguration + ) { + $this->resource = $resource; + $this->stockConfiguration = $stockConfiguration; + } + + /** + * @inheritDoc + */ + public function execute( + Select $select, + string $productTableAlias, + string $stockStatusTableAlias = self::TABLE_ALIAS, + ?int $websiteId = null + ): Select { + $stockStatusTable = $this->resource->getTableName(self::TABLE_NAME); + $joinCondition = [ + "{$stockStatusTableAlias}.product_id = {$productTableAlias}.entity_id", + $select->getConnection()->quoteInto( + "{$stockStatusTableAlias}.website_id = ?", + $this->stockConfiguration->getDefaultScopeId() + ), + $select->getConnection()->quoteInto( + "{$stockStatusTableAlias}.stock_id = ?", + Stock::DEFAULT_STOCK_ID + ) + ]; + $select->join( + [$stockStatusTableAlias => $stockStatusTable], + implode(' AND ', $joinCondition), + [] + ); + $select->where("{$stockStatusTableAlias}.stock_status = ?", StockStatusInterface::STATUS_IN_STOCK); + + return $select; + } +} diff --git a/app/code/Magento/CatalogInventory/Model/ResourceModel/StockStatusFilterInterface.php b/app/code/Magento/CatalogInventory/Model/ResourceModel/StockStatusFilterInterface.php new file mode 100644 index 0000000000000..26eb4b0fa38eb --- /dev/null +++ b/app/code/Magento/CatalogInventory/Model/ResourceModel/StockStatusFilterInterface.php @@ -0,0 +1,34 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\CatalogInventory\Model\ResourceModel; + +use Magento\Framework\DB\Select; + +/** + * In stock status filter interface. + */ +interface StockStatusFilterInterface +{ + public const TABLE_ALIAS = 'stock_status'; + + /** + * Add in-stock status constraint to the select. + * + * @param Select $select + * @param string $productTableAliasAlias + * @param string $stockStatusTableAlias + * @param int|null $websiteId + * @return Select + */ + public function execute( + Select $select, + string $productTableAliasAlias, + string $stockStatusTableAlias = self::TABLE_ALIAS, + ?int $websiteId = null + ): Select; +} diff --git a/app/code/Magento/CatalogInventory/etc/di.xml b/app/code/Magento/CatalogInventory/etc/di.xml index 751fa465bdb17..d2807249cf574 100644 --- a/app/code/Magento/CatalogInventory/etc/di.xml +++ b/app/code/Magento/CatalogInventory/etc/di.xml @@ -32,6 +32,7 @@ <preference for="Magento\CatalogInventory\Model\Spi\StockStateProviderInterface" type="Magento\CatalogInventory\Model\StockStateProvider" /> <preference for="Magento\CatalogInventory\Model\ResourceModel\QtyCounterInterface" type="Magento\CatalogInventory\Model\ResourceModel\Stock" /> + <preference for="Magento\CatalogInventory\Model\ResourceModel\StockStatusFilterInterface" type="Magento\CatalogInventory\Model\ResourceModel\StockStatusFilter" /> <type name="Magento\Catalog\Model\Product\Attribute\Repository"> <plugin name="filterCustomAttribute" type="Magento\CatalogInventory\Model\Plugin\FilterCustomAttribute" /> </type> diff --git a/app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php b/app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php index 5d9b1911bc292..0fda2ef31347d 100644 --- a/app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php +++ b/app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php @@ -7,7 +7,7 @@ use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer; -use Magento\CatalogInventory\Model\Stock; +use Magento\CatalogInventory\Model\ResourceModel\StockStatusFilterInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\EntityManager\MetadataPool; use Magento\Sales\Model\ConfigInterface; @@ -162,6 +162,17 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab * @var CollectionBuilderInterface */ private $productCollectionBuilder; + /** + * @var StockStatusFilterInterface + */ + private $stockStatusFilter; + + /** + * Whether product table is joined in select + * + * @var bool + */ + private $isProductTableJoined = false; /** * @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory @@ -181,10 +192,11 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab * @param \Magento\Catalog\Model\Entity\AttributeFactory $catalogAttrFactory * @param \Magento\Wishlist\Model\ResourceModel\Item $resource * @param \Magento\Framework\App\State $appState - * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection + * @param \Magento\Framework\DB\Adapter\AdapterInterface|null $connection * @param TableMaintainer|null $tableMaintainer * @param ConfigInterface|null $salesConfig * @param CollectionBuilderInterface|null $productCollectionBuilder + * @param StockStatusFilterInterface|null $stockStatusFilter * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -208,7 +220,8 @@ public function __construct( \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, TableMaintainer $tableMaintainer = null, ConfigInterface $salesConfig = null, - ?CollectionBuilderInterface $productCollectionBuilder = null + ?CollectionBuilderInterface $productCollectionBuilder = null, + ?StockStatusFilterInterface $stockStatusFilter = null ) { $this->stockConfiguration = $stockConfiguration; $this->_adminhtmlSales = $adminhtmlSales; @@ -227,6 +240,8 @@ public function __construct( $this->salesConfig = $salesConfig ?: ObjectManager::getInstance()->get(ConfigInterface::class); $this->productCollectionBuilder = $productCollectionBuilder ?: ObjectManager::getInstance()->get(CollectionBuilderInterface::class); + $this->stockStatusFilter = $stockStatusFilter + ?: ObjectManager::getInstance()->get(StockStatusFilterInterface::class); } /** @@ -368,15 +383,8 @@ protected function _renderFiltersBefore() $connection = $this->getConnection(); if ($this->_productInStock && !$this->stockConfiguration->isShowOutOfStock()) { - $inStockConditions = [ - "stockItem.product_id = {$mainTableName}.product_id", - $connection->quoteInto('stockItem.stock_status = ?', Stock::STOCK_IN_STOCK), - ]; - $this->getSelect()->join( - ['stockItem' => $this->getTable('cataloginventory_stock_status')], - join(' AND ', $inStockConditions), - [] - ); + $this->joinProductTable(); + $this->stockStatusFilter->execute($this->getSelect(), 'product_entity', 'stockItem'); } if ($this->_productVisible) { @@ -583,12 +591,9 @@ protected function _joinProductNameTable() $entityMetadata = $this->getMetadataPool()->getMetadata(ProductInterface::class); $linkField = $entityMetadata->getLinkField(); + $this->joinProductTable(); $this->getSelect()->join( - ['product_entity' => $this->getTable('catalog_product_entity')], - 'product_entity.entity_id = main_table.product_id', - [] - )->join( ['product_name_table' => $attribute->getBackendTable()], 'product_name_table.' . $linkField . ' = product_entity.' . $linkField . ' AND product_name_table.store_id = ' . @@ -673,4 +678,21 @@ protected function _afterLoadData() return $this; } + + /** + * Join product table to select if not already joined + * + * @return void + */ + private function joinProductTable(): void + { + if (!$this->isProductTableJoined) { + $this->getSelect()->join( + ['product_entity' => $this->getTable('catalog_product_entity')], + 'product_entity.entity_id = main_table.product_id', + [] + ); + $this->isProductTableJoined = true; + } + } } diff --git a/app/code/Magento/Wishlist/Model/Wishlist.php b/app/code/Magento/Wishlist/Model/Wishlist.php index 437b3c757f9cf..f544dd374d734 100644 --- a/app/code/Magento/Wishlist/Model/Wishlist.php +++ b/app/code/Magento/Wishlist/Model/Wishlist.php @@ -12,9 +12,8 @@ use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\ProductFactory; -use Magento\CatalogInventory\Api\Data\StockItemInterface; +use Magento\CatalogInventory\Api\StockConfigurationInterface; use Magento\CatalogInventory\Api\StockRegistryInterface; -use Magento\CatalogInventory\Model\Configuration; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\DataObject; @@ -27,7 +26,6 @@ use Magento\Framework\Registry; use Magento\Framework\Serialize\Serializer\Json; use Magento\Framework\Stdlib\DateTime; -use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\Store; use Magento\Store\Model\StoreManagerInterface; use Magento\Wishlist\Helper\Data; @@ -150,14 +148,9 @@ class Wishlist extends AbstractModel implements IdentityInterface private $serializer; /** - * @var ScopeConfigInterface + * @var StockConfigurationInterface */ - private $scopeConfig; - - /** - * @var StockRegistryInterface|null - */ - private $stockRegistry; + private $stockConfiguration; /** * Constructor @@ -181,8 +174,9 @@ class Wishlist extends AbstractModel implements IdentityInterface * @param Json|null $serializer * @param StockRegistryInterface|null $stockRegistry * @param ScopeConfigInterface|null $scopeConfig - * + * @param StockConfigurationInterface|null $stockConfiguration * @SuppressWarnings(PHPMD.ExcessiveParameterList) + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function __construct( Context $context, @@ -203,7 +197,8 @@ public function __construct( array $data = [], Json $serializer = null, StockRegistryInterface $stockRegistry = null, - ScopeConfigInterface $scopeConfig = null + ScopeConfigInterface $scopeConfig = null, + ?StockConfigurationInterface $stockConfiguration = null ) { $this->_useCurrentWebsite = $useCurrentWebsite; $this->_catalogProduct = $catalogProduct; @@ -218,8 +213,8 @@ public function __construct( $this->serializer = $serializer ?: ObjectManager::getInstance()->get(Json::class); parent::__construct($context, $registry, $resource, $resourceCollection, $data); $this->productRepository = $productRepository; - $this->scopeConfig = $scopeConfig ?: ObjectManager::getInstance()->get(ScopeConfigInterface::class); - $this->stockRegistry = $stockRegistry ?: ObjectManager::getInstance()->get(StockRegistryInterface::class); + $this->stockConfiguration = $stockConfiguration + ?: ObjectManager::getInstance()->get(StockConfigurationInterface::class); } /** @@ -467,7 +462,7 @@ public function addNewItem($product, $buyRequest = null, $forciblySetQty = false throw new LocalizedException(__('Cannot specify product.')); } - if ($this->isInStock($productId)) { + if (!$this->stockConfiguration->isShowOutOfStock($storeId) && !$product->getIsSalable()) { throw new LocalizedException(__('Cannot add product without stock to wishlist.')); } @@ -672,25 +667,6 @@ public function isSalable() return false; } - /** - * Retrieve if product has stock or config is set for showing out of stock products - * - * @param int $productId - * - * @return bool - */ - private function isInStock($productId) - { - /** @var StockItemInterface $stockItem */ - $stockItem = $this->stockRegistry->getStockItem($productId); - $showOutOfStock = $this->scopeConfig->isSetFlag( - Configuration::XML_PATH_SHOW_OUT_OF_STOCK, - ScopeInterface::SCOPE_STORE - ); - $isInStock = $stockItem ? $stockItem->getIsInStock() : false; - return !$isInStock && !$showOutOfStock; - } - /** * Check customer is owner this wishlist * diff --git a/app/code/Magento/Wishlist/Test/Unit/Model/WishlistTest.php b/app/code/Magento/Wishlist/Test/Unit/Model/WishlistTest.php index e09491813877b..369f77e527287 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Model/WishlistTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Model/WishlistTest.php @@ -13,6 +13,7 @@ use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Type\AbstractType; use Magento\Catalog\Model\ProductFactory; +use Magento\CatalogInventory\Api\StockConfigurationInterface; use Magento\CatalogInventory\Api\StockRegistryInterface; use Magento\CatalogInventory\Model\Stock\Item as StockItem; use Magento\CatalogInventory\Model\Stock\StockItemRepository; @@ -132,6 +133,10 @@ class WishlistTest extends TestCase * @var StockRegistryInterface|MockObject */ private $stockRegistry; + /** + * @var StockConfigurationInterface|MockObject + */ + private $stockConfiguration; protected function setUp(): void { @@ -194,6 +199,8 @@ protected function setUp(): void ->method('getEventDispatcher') ->willReturn($this->eventDispatcher); + $this->stockConfiguration = $this->createMock(StockConfigurationInterface::class); + $this->wishlist = new Wishlist( $context, $this->registry, @@ -213,7 +220,8 @@ protected function setUp(): void [], $this->serializer, $this->stockRegistry, - $this->scopeConfig + $this->scopeConfig, + $this->stockConfiguration ); } @@ -300,6 +308,7 @@ public function testUpdateItem($itemId, $buyRequest, $param): void $newProduct->expects($this->once()) ->method('getTypeInstance') ->willReturn($instanceType); + $newProduct->expects($this->any())->method('getIsSalable')->willReturn(true); $item = $this->getMockBuilder(Item::class) ->disableOriginalConstructor() @@ -388,8 +397,19 @@ public function updateItemDataProvider(): array ]; } - public function testAddNewItem() + /** + * @param bool $getIsSalable + * @param bool $isShowOutOfStock + * @param string $throwException + * + * @dataProvider addNewItemDataProvider + */ + public function testAddNewItem(bool $getIsSalable, bool $isShowOutOfStock, string $throwException): void { + if ($throwException) { + $this->expectExceptionMessage($throwException); + } + $this->stockConfiguration->method('isShowOutOfStock')->willReturn($isShowOutOfStock); $productId = 1; $storeId = 1; $buyRequest = json_encode( @@ -407,34 +427,31 @@ public function testAddNewItem() $instanceType = $this->getMockBuilder(AbstractType::class) ->disableOriginalConstructor() ->getMock(); - $instanceType->expects($this->once()) - ->method('processConfiguration') + $instanceType->method('processConfiguration') ->willReturn('product'); $productMock = $this->getMockBuilder(Product::class) ->disableOriginalConstructor() - ->setMethods(['getId', 'hasWishlistStoreId', 'getStoreId', 'getTypeInstance']) + ->setMethods(['getId', 'hasWishlistStoreId', 'getStoreId', 'getTypeInstance', 'getIsSalable']) ->getMock(); - $productMock->expects($this->once()) - ->method('getId') + $productMock->method('getId') ->willReturn($productId); - $productMock->expects($this->once()) - ->method('hasWishlistStoreId') + $productMock->method('hasWishlistStoreId') ->willReturn(false); - $productMock->expects($this->once()) - ->method('getStoreId') + $productMock->method('getStoreId') ->willReturn($storeId); - $productMock->expects($this->once()) - ->method('getTypeInstance') + $productMock->method('getTypeInstance') ->willReturn($instanceType); + $productMock->expects($this->any()) + ->method('getIsSalable') + ->willReturn($getIsSalable); $this->productRepository->expects($this->once()) ->method('getById') ->with($productId, false, $storeId) ->willReturn($productMock); - $this->serializer->expects($this->once()) - ->method('unserialize') + $this->serializer->method('unserialize') ->willReturnCallback( function ($value) { return json_decode($value, true); @@ -453,4 +470,17 @@ function ($value) { $this->assertEquals($result, $this->wishlist->addNewItem($productMock, $buyRequest)); } + + /** + * @return array[] + */ + public function addNewItemDataProvider(): array + { + return [ + [false, false, 'Cannot add product without stock to wishlist'], + [false, true, ''], + [true, false, ''], + [true, true, ''], + ]; + } } diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_disabled_product.php b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_disabled_product.php index 22583483ddf69..7fe1983d3192f 100644 --- a/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_disabled_product.php +++ b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_disabled_product.php @@ -5,7 +5,6 @@ */ declare(strict_types=1); - use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\TestFramework\Helper\Bootstrap; @@ -30,6 +29,11 @@ $productRepository->cleanCache(); $product = $productRepository->get('product_disabled'); $wishlist->loadByCustomerId($customer->getId(), true); +/** @var \Magento\Catalog\Helper\Product $productHelper */ +$productHelper = $objectManager->get(\Magento\Catalog\Helper\Product::class); +$isSkipSaleableCheck = $productHelper->getSkipSaleableCheck(); +$productHelper->setSkipSaleableCheck(true); $item = $wishlist->addNewItem($product); +$productHelper->setSkipSaleableCheck($isSkipSaleableCheck); $wishlist->setSharingCode('wishlist_disabled_item'); $wishListResource->save($wishlist); diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_simple_product.php b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_simple_product.php index 4961d2403672c..54c26b73c70ba 100644 --- a/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_simple_product.php +++ b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_simple_product.php @@ -25,4 +25,9 @@ $wishlistFactory = $objectManager->get(WishlistFactory::class); $wishlist = $wishlistFactory->create(); $wishlist->loadByCustomerId($customer->getId(), true); +/** @var \Magento\Catalog\Helper\Product $productHelper */ +$productHelper = $objectManager->get(\Magento\Catalog\Helper\Product::class); +$isSkipSaleableCheck = $productHelper->getSkipSaleableCheck(); +$productHelper->setSkipSaleableCheck(true); $wishlist->addNewItem($product); +$productHelper->setSkipSaleableCheck($isSkipSaleableCheck); From c1410e7da82dad289b5efe172c9c0f5f67a13dd7 Mon Sep 17 00:00:00 2001 From: joweecaquicla <joie@abovethefray.io> Date: Tue, 8 Sep 2020 00:28:52 +0800 Subject: [PATCH 63/99] magento/adobe-stock-integration#1795: [MFTF] Unskip AdminMediaGalleryCatalogUiUsedInProductFilterTest - modified sorting mftf tests --- ...diaGallerySortByDirectoryAscendingTest.xml | 47 +++++------------- ...iaGallerySortByDirectoryDescendingTest.xml | 48 +++++-------------- .../AdminMediaGallerySortByNameAToZTest.xml | 47 +++++------------- .../AdminMediaGallerySortByNameZToATest.xml | 47 +++++------------- ...AdminMediaGallerySortByNewestFirstTest.xml | 46 +++++------------- ...AdminMediaGallerySortByOldestFirstTest.xml | 46 +++++------------- 6 files changed, 78 insertions(+), 203 deletions(-) diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByDirectoryAscendingTest.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByDirectoryAscendingTest.xml index 4dbf3da0752b2..365252095d49e 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByDirectoryAscendingTest.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByDirectoryAscendingTest.xml @@ -24,58 +24,37 @@ <after> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGalleryPage"/> <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> - <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectFirstFolderForDelete"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectParentFolderForDelete"> + <argument name="name" value="parentFolder"/> </actionGroup> - <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteFirstFolder"/> - <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertFirstFolderWasDeleted"> - <argument name="name" value="firstFolder"/> - </actionGroup> - <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear"/> - <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectSecondFolderForDelete"> - <argument name="name" value="secondFolder"/> - </actionGroup> - <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteSecondFolder"/> - <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertSecondFolderWasDeleted"> - <argument name="name" value="secondFolder"/> + <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteParentFolder"/> + <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertParentFolderWasDeleted"> + <argument name="name" value="parentFolder"/> </actionGroup> </after> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGalleryPage"/> - <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openFirstNewFolderForm"/> - <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createFirstNewFolder"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> + <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openParentFolderForm"/> + <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createParentFolder"> + <argument name="name" value="parentFolder"/> </actionGroup> - <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertFirstNewFolderCreated"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertParentFolderCreated"> + <argument name="name" value="parentFolder"/> </actionGroup> - + <waitForPageLoad stepKey="waitForGridToLoadAfterParentFolderCreated"/> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage"> <argument name="image" value="ImageUpload"/> </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadSecondImage"> <argument name="image" value="ImageUpload_1"/> </actionGroup> - - <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> - <waitForPageLoad stepKey="waitForGridToLoad"/> - <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openSecondNewFolderForm"/> - <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createSecondNewFolder"> - <argument name="name" value="secondFolder"/> - </actionGroup> - <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertSecondNewFolderCreated"> - <argument name="name" value="secondFolder"/> - </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadThirdImage"> <argument name="image" value="ImageUpload1"/> </actionGroup> - - <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="secondResetAdminDataGridToDefaultView"/> - <waitForPageLoad stepKey="secondWaitForGridToLoad"/> - + <waitForPageLoad stepKey="waitForGridToLoad"/> <actionGroup ref="AdminEnhancedMediaGalleryClickSortActionGroup" stepKey="sortByDirectoryAscending"> <argument name="sortName" value="directory_asc"/> </actionGroup> - <actionGroup ref="AssertAdminEnhancedMediaGallerySortByActionGroup" stepKey="assertImagePositionAfterSortByDirectoryAscending"> <argument name="firstImageFile" value="{{ImageUpload_1.file}}"/> <argument name="secondImageFile" value="{{ImageUpload.file}}"/> diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByDirectoryDescendingTest.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByDirectoryDescendingTest.xml index 025da24511b73..85c468996d515 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByDirectoryDescendingTest.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByDirectoryDescendingTest.xml @@ -21,62 +21,40 @@ <before> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> </before> - <after> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGalleryPage"/> <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> - <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectFirstFolderForDelete"> - <argument name="name" value="firstFolder"/> - </actionGroup> - <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteFirstFolder"/> - <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertFirstFolderWasDeleted"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectParentFolderForDelete"> + <argument name="name" value="parentFolder"/> </actionGroup> - <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear"/> - <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectSecondFolderForDelete"> - <argument name="name" value="secondFolder"/> - </actionGroup> - <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteSecondFolder"/> - <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertSecondFolderWasDeleted"> - <argument name="name" value="secondFolder"/> + <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteParentFolder"/> + <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertParentFolderWasDeleted"> + <argument name="name" value="parentFolder"/> </actionGroup> </after> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGalleryPage"/> - <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openFirstNewFolderForm"/> - <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createFirstNewFolder"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> + <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openParentFolderForm"/> + <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createParentFolder"> + <argument name="name" value="parentFolder"/> </actionGroup> - <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertFirstNewFolderCreated"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertParentFolderCreated"> + <argument name="name" value="parentFolder"/> </actionGroup> - + <waitForPageLoad stepKey="waitForGridToLoadAfterParentFolderCreated"/> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage"> <argument name="image" value="ImageUpload"/> </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadSecondImage"> <argument name="image" value="ImageUpload_1"/> </actionGroup> - - <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> - <waitForPageLoad stepKey="waitForGridToLoad"/> - <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openSecondNewFolderForm"/> - <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createSecondNewFolder"> - <argument name="name" value="secondFolder"/> - </actionGroup> - <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertSecondNewFolderCreated"> - <argument name="name" value="secondFolder"/> - </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadThirdImage"> <argument name="image" value="ImageUpload1"/> </actionGroup> - - <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="secondResetAdminDataGridToDefaultView"/> - <waitForPageLoad stepKey="secondWaitForGridToLoad"/> - + <waitForPageLoad stepKey="waitForGridToLoad"/> <actionGroup ref="AdminEnhancedMediaGalleryClickSortActionGroup" stepKey="sortByDirectoryDescending"> <argument name="sortName" value="directory_desc"/> </actionGroup> - <actionGroup ref="AssertAdminEnhancedMediaGallerySortByActionGroup" stepKey="assertImagePositionAfterSortByDirectoryDescending"> <argument name="firstImageFile" value="{{ImageUpload1.value}}"/> <argument name="secondImageFile" value="{{ImageUpload.file}}"/> diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByNameAToZTest.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByNameAToZTest.xml index da0d8a18b75e4..9dca51065124f 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByNameAToZTest.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByNameAToZTest.xml @@ -24,58 +24,37 @@ <after> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGalleryPage"/> <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> - <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectFirstFolderForDelete"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectParentFolderForDelete"> + <argument name="name" value="parentFolder"/> </actionGroup> - <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteFirstFolder"/> - <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertFirstFolderWasDeleted"> - <argument name="name" value="firstFolder"/> - </actionGroup> - <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear"/> - <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectSecondFolderForDelete"> - <argument name="name" value="secondFolder"/> - </actionGroup> - <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteSecondFolder"/> - <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertSecondFolderWasDeleted"> - <argument name="name" value="secondFolder"/> + <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteParentFolder"/> + <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertParentFolderWasDeleted"> + <argument name="name" value="parentFolder"/> </actionGroup> </after> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGalleryPage"/> - <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openFirstNewFolderForm"/> - <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createFirstNewFolder"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> + <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openParentFolderForm"/> + <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createParentFolder"> + <argument name="name" value="parentFolder"/> </actionGroup> - <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertFirstNewFolderCreated"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertParentFolderCreated"> + <argument name="name" value="parentFolder"/> </actionGroup> - + <waitForPageLoad stepKey="waitForGridToLoadAfterParentFolderCreated"/> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage"> <argument name="image" value="ImageUpload"/> </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadSecondImage"> <argument name="image" value="ImageUpload_1"/> </actionGroup> - - <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> - <waitForPageLoad stepKey="waitForGridToLoad"/> - <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openSecondNewFolderForm"/> - <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createSecondNewFolder"> - <argument name="name" value="secondFolder"/> - </actionGroup> - <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertSecondNewFolderCreated"> - <argument name="name" value="secondFolder"/> - </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadThirdImage"> <argument name="image" value="ImageUpload1"/> </actionGroup> - - <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="secondResetAdminDataGridToDefaultView"/> - <waitForPageLoad stepKey="secondWaitForGridToLoad"/> - + <waitForPageLoad stepKey="waitForGridToLoad"/> <actionGroup ref="AdminEnhancedMediaGalleryClickSortActionGroup" stepKey="sortByNameAToZ"> <argument name="sortName" value="name_az"/> </actionGroup> - <actionGroup ref="AssertAdminEnhancedMediaGallerySortByActionGroup" stepKey="assertImagePositionAfterSortByNameAToZ"> <argument name="firstImageFile" value="{{ImageUpload.file}}"/> <argument name="secondImageFile" value="{{ImageUpload_1.file}}"/> diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByNameZToATest.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByNameZToATest.xml index 4b5086e5d63ff..71d2020d08658 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByNameZToATest.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByNameZToATest.xml @@ -24,58 +24,37 @@ <after> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGalleryPage"/> <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> - <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectFirstFolderForDelete"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectParentFolderForDelete"> + <argument name="name" value="parentFolder"/> </actionGroup> - <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteFirstFolder"/> - <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertFirstFolderWasDeleted"> - <argument name="name" value="firstFolder"/> - </actionGroup> - <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear"/> - <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectSecondFolderForDelete"> - <argument name="name" value="secondFolder"/> - </actionGroup> - <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteSecondFolder"/> - <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertSecondFolderWasDeleted"> - <argument name="name" value="secondFolder"/> + <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteParentFolder"/> + <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertParentFolderWasDeleted"> + <argument name="name" value="parentFolder"/> </actionGroup> </after> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGalleryPage"/> - <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openFirstNewFolderForm"/> - <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createFirstNewFolder"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> + <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openParentFolderForm"/> + <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createParentFolder"> + <argument name="name" value="parentFolder"/> </actionGroup> - <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertFirstNewFolderCreated"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertParentFolderCreated"> + <argument name="name" value="parentFolder"/> </actionGroup> - + <waitForPageLoad stepKey="waitForGridToLoadAfterParentFolderCreated"/> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage"> <argument name="image" value="ImageUpload"/> </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadSecondImage"> <argument name="image" value="ImageUpload_1"/> </actionGroup> - - <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> - <waitForPageLoad stepKey="waitForGridToLoad"/> - <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openSecondNewFolderForm"/> - <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createSecondNewFolder"> - <argument name="name" value="secondFolder"/> - </actionGroup> - <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertSecondNewFolderCreated"> - <argument name="name" value="secondFolder"/> - </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadThirdImage"> <argument name="image" value="ImageUpload1"/> </actionGroup> - - <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="secondResetAdminDataGridToDefaultView"/> - <waitForPageLoad stepKey="secondWaitForGridToLoad"/> - + <waitForPageLoad stepKey="waitForGridToLoad"/> <actionGroup ref="AdminEnhancedMediaGalleryClickSortActionGroup" stepKey="sortByNameZToA"> <argument name="sortName" value="name_za"/> </actionGroup> - <actionGroup ref="AssertAdminEnhancedMediaGallerySortByActionGroup" stepKey="assertImagePositionAfterSortByNameZToA"> <argument name="firstImageFile" value="{{ImageUpload1.value}}"/> <argument name="secondImageFile" value="{{ImageUpload_1.file}}"/> diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByNewestFirstTest.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByNewestFirstTest.xml index 4274b26d5770f..3da0546db090a 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByNewestFirstTest.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByNewestFirstTest.xml @@ -21,57 +21,37 @@ <before> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> </before> - <after> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGalleryPage"/> <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> - <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectFirstFolderForDelete"> - <argument name="name" value="firstFolder"/> - </actionGroup> - <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteFirstFolder"/> - <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertFirstFolderWasDeleted"> - <argument name="name" value="firstFolder"/> - </actionGroup> - <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear"/> - <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectSecondFolderForDelete"> - <argument name="name" value="secondFolder"/> + <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectParentFolderForDelete"> + <argument name="name" value="parentFolder"/> </actionGroup> - <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteSecondFolder"/> - <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertSecondFolderWasDeleted"> - <argument name="name" value="secondFolder"/> + <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteParentFolder"/> + <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertParentFolderWasDeleted"> + <argument name="name" value="parentFolder"/> </actionGroup> </after> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGalleryPage"/> - <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openFirstNewFolderForm"/> - <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createFirstNewFolder"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> + <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openParentFolderForm"/> + <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createParentFolder"> + <argument name="name" value="parentFolder"/> </actionGroup> - <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertFirstNewFolderCreated"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertParentFolderCreated"> + <argument name="name" value="parentFolder"/> </actionGroup> - + <waitForPageLoad stepKey="waitForGridToLoadAfterParentFolderCreated"/> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage"> <argument name="image" value="ImageUpload"/> </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadSecondImage"> <argument name="image" value="ImageUpload_1"/> </actionGroup> - - <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> - <waitForPageLoad stepKey="waitForGridToLoad"/> - <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openSecondNewFolderForm"/> - <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createSecondNewFolder"> - <argument name="name" value="secondFolder"/> - </actionGroup> - <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertSecondNewFolderCreated"> - <argument name="name" value="secondFolder"/> - </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadThirdImage"> <argument name="image" value="ImageUpload1"/> </actionGroup> - - <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="secondResetAdminDataGridToDefaultView"/> - <waitForPageLoad stepKey="secondWaitForGridToLoad"/> + <waitForPageLoad stepKey="waitForGridToLoad"/> <actionGroup ref="AdminEnhancedMediaGalleryClickSortActionGroup" stepKey="sortByNewestFirst"> <argument name="sortName" value="newest_first"/> </actionGroup> diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByOldestFirstTest.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByOldestFirstTest.xml index e67fdcfcf40b3..e6191d2d02287 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByOldestFirstTest.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Test/AdminMediaGallerySortByOldestFirstTest.xml @@ -24,54 +24,34 @@ <after> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGalleryPage"/> <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> - <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectFirstFolderForDelete"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectParentFolderForDelete"> + <argument name="name" value="parentFolder"/> </actionGroup> - <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteFirstFolder"/> - <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertFirstFolderWasDeleted"> - <argument name="name" value="firstFolder"/> - </actionGroup> - <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear"/> - <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectSecondFolderForDelete"> - <argument name="name" value="secondFolder"/> - </actionGroup> - <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteSecondFolder"/> - <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertSecondFolderWasDeleted"> - <argument name="name" value="secondFolder"/> + <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteParentFolder"/> + <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertParentFolderWasDeleted"> + <argument name="name" value="parentFolder"/> </actionGroup> </after> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openStandaloneMediaGalleryPage"/> - <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openFirstNewFolderForm"/> - <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createFirstNewFolder"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> + <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openParentFolderForm"/> + <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createParentFolder"> + <argument name="name" value="parentFolder"/> </actionGroup> - <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertFirstNewFolderCreated"> - <argument name="name" value="firstFolder"/> + <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertParentFolderCreated"> + <argument name="name" value="parentFolder"/> </actionGroup> - + <waitForPageLoad stepKey="waitForGridToLoadAfterParentFolderCreated"/> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage"> <argument name="image" value="ImageUpload"/> </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadSecondImage"> <argument name="image" value="ImageUpload_1"/> </actionGroup> - - <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> - <waitForPageLoad stepKey="waitForGridToLoad"/> - <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openSecondNewFolderForm"/> - <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createSecondNewFolder"> - <argument name="name" value="secondFolder"/> - </actionGroup> - <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertSecondNewFolderCreated"> - <argument name="name" value="secondFolder"/> - </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadThirdImage"> <argument name="image" value="ImageUpload1"/> </actionGroup> - - <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="secondResetAdminDataGridToDefaultView"/> - <waitForPageLoad stepKey="secondWaitForGridToLoad"/> - + <waitForPageLoad stepKey="waitForGridToLoad"/> <actionGroup ref="AdminEnhancedMediaGalleryClickSortActionGroup" stepKey="sortByOldestFirst"> <argument name="sortName" value="oldest_first"/> </actionGroup> From 392fc3a4ca49f9c3fba7d8ecc7688d8f7ae77c1c Mon Sep 17 00:00:00 2001 From: Victor Rad <vrad@magento.com> Date: Mon, 7 Sep 2020 13:38:11 -0500 Subject: [PATCH 64/99] MC-37321: Quote customer_is_guest = false --- app/code/Magento/Checkout/Model/Session.php | 5 ++++- .../Magento/Checkout/Model/SessionTest.php | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/Model/Session.php b/app/code/Magento/Checkout/Model/Session.php index 618f745e77105..8ba6af2518057 100644 --- a/app/code/Magento/Checkout/Model/Session.php +++ b/app/code/Magento/Checkout/Model/Session.php @@ -291,6 +291,7 @@ public function getQuote() } } else { $quote->setIsCheckoutCart(true); + $quote->setCustomerIsGuest(true); $this->_eventManager->dispatch('checkout_quote_init', ['quote' => $quote]); } } @@ -382,8 +383,9 @@ public function loadCustomerQuote() if ($customerQuote->getId() && $this->getQuoteId() != $customerQuote->getId()) { if ($this->getQuoteId()) { + $quote = $this->getQuote()->setCustomerIsGuest(false); $this->quoteRepository->save( - $customerQuote->merge($this->getQuote())->collectTotals() + $customerQuote->merge($quote)->collectTotals() ); $newQuote = $this->quoteRepository->get($customerQuote->getId()); $this->quoteRepository->save( @@ -402,6 +404,7 @@ public function loadCustomerQuote() $this->getQuote()->getBillingAddress(); $this->getQuote()->getShippingAddress(); $this->getQuote()->setCustomer($this->_customerSession->getCustomerDataObject()) + ->setCustomerIsGuest(false) ->setTotalsCollectedFlag(false) ->collectTotals(); $this->quoteRepository->save($this->getQuote()); diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Model/SessionTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Model/SessionTest.php index 32968572b4ac8..5b47b8f51c228 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Model/SessionTest.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/Model/SessionTest.php @@ -199,6 +199,10 @@ public function testLoadCustomerQuoteCustomerWithoutQuote(): void $this->quote->getCustomerEmail(), 'Precondition failed: Customer data must not be set to quote' ); + $this->assertTrue( + $this->quote->getCustomerIsGuest(), + 'Precondition failed: Customer must be as guest in quote' + ); $customer = $this->customerRepository->getById(1); $this->customerSession->setCustomerDataObject($customer); $this->quote = $this->checkoutSession->getQuote(); @@ -244,6 +248,17 @@ public function testGetQuoteWithProductWithTierPrice(): void $this->assertEquals($tierPriceValue, $quoteProduct->getTierPrice(1)); } + /** + * Test covers case when quote is not yet initialized and customer is guest + * + * Expected result - quote object should be loaded with customer as guest + */ + public function testGetQuoteNotInitializedGuest() + { + $quote = $this->checkoutSession->getQuote(); + $this->assertTrue($quote->getCustomerIsGuest()); + } + /** * @magentoDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php * @magentoDataFixture Magento/Checkout/_files/quote_with_customer_without_address.php @@ -288,5 +303,9 @@ private function validateCustomerDataInQuote(CartInterface $quote): void $quote->getCustomerFirstname(), 'Customer first name was not set to Quote correctly.' ); + $this->assertFalse( + $quote->getCustomerIsGuest(), + 'Customer should not be as guest in Quote.' + ); } } From caaf4699d348236e951ea094a886b38e1391c6bf Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Mon, 7 Sep 2020 22:23:33 +0300 Subject: [PATCH 65/99] add code review recommendations --- .../AdminDeleteTaxRateActionGroup.xml | 16 +++---------- .../AdminFilterTaxRateByCodeActionGroup.xml | 23 +++++++++++++++++++ .../AdminCreateTaxRateAllPostCodesTest.xml | 7 +++++- .../Test/AdminCreateTaxRateLargeRateTest.xml | 7 +++++- ...AdminCreateTaxRateSpecificPostcodeTest.xml | 7 +++++- ...dminCreateTaxRateWiderZipCodeRangeTest.xml | 7 +++++- .../AdminCreateTaxRateZipCodeRangeTest.xml | 7 +++++- .../Mftf/Test/DeleteTaxRateEntityTest.xml | 10 +++++--- .../AdminClickRowInGridActionGroup.xml | 19 +++++++++++++++ .../Section/AdminDataGridTableSection.xml | 2 +- 10 files changed, 83 insertions(+), 22 deletions(-) create mode 100644 app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminFilterTaxRateByCodeActionGroup.xml create mode 100644 app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminClickRowInGridActionGroup.xml diff --git a/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminDeleteTaxRateActionGroup.xml b/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminDeleteTaxRateActionGroup.xml index b609ef8827764..1aab6ea2c4eec 100644 --- a/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminDeleteTaxRateActionGroup.xml +++ b/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminDeleteTaxRateActionGroup.xml @@ -10,19 +10,9 @@ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> <actionGroup name="AdminDeleteTaxRateActionGroup"> <annotations> - <description>Goes to the Admin Tax Rate grid page. Deletes the provided Tax Rate Code.</description> + <description>Delete Tax Rate.</description> </annotations> - <arguments> - <argument name="taxRateCode" type="string"/> - </arguments> - - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters"/> - <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{taxRateCode}}" stepKey="fillNameFilter"/> - <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch"/> - <waitForPageLoad stepKey="waitForTaxRuleSearch"/> - <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow"/> - <waitForPageLoad stepKey="waitForPageLoad"/> - <click selector="{{AdminTaxRateFormSection.deleteRate}}" stepKey="clickDeleteRate"/> - <click selector="{{AdminTaxRateFormSection.ok}}" stepKey="clickOk"/> + <click selector="{{AdminMainActionsSection.delete}}" stepKey="clickDeleteRate"/> + <click selector="{{AdminConfirmationModalSection.ok}}" stepKey="clickOk"/> </actionGroup> </actionGroups> diff --git a/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminFilterTaxRateByCodeActionGroup.xml b/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminFilterTaxRateByCodeActionGroup.xml new file mode 100644 index 0000000000000..2b110e969b113 --- /dev/null +++ b/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminFilterTaxRateByCodeActionGroup.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminFilterTaxRateByCodeActionGroup"> + <annotations> + <description>Filter Tax Rates by tax rate code.</description> + </annotations> + <arguments> + <argument name="taxRateCode" type="string"/> + </arguments> + + <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{taxRateCode}}" stepKey="fillNameFilter"/> + <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch"/> + <waitForPageLoad stepKey="waitForTaxRuleSearch"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml index f2f7d78ea2650..494c0ae74c375 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml @@ -23,9 +23,14 @@ </before> <after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex"/> - <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"> + <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clickClearFilters"/> + <actionGroup ref="AdminFilterTaxRateByCodeActionGroup" stepKey="filterByCode"> <argument name="taxRateCode" value="{{SimpleTaxRate.code}}" /> </actionGroup> + <actionGroup ref="AdminClickRowInGridActionGroup" stepKey="clickFirstRow"> + <argument name="row_number" value="1" /> + </actionGroup> + <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"/> </after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml index 144f6b644d168..e195a0b86cb26 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml @@ -23,9 +23,14 @@ </before> <after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex"/> - <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"> + <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clickClearFilters"/> + <actionGroup ref="AdminFilterTaxRateByCodeActionGroup" stepKey="filterByCode"> <argument name="taxRateCode" value="{{SimpleTaxRate.code}}" /> </actionGroup> + <actionGroup ref="AdminClickRowInGridActionGroup" stepKey="clickFirstRow"> + <argument name="row_number" value="1" /> + </actionGroup> + <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"/> </after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml index 49a89b33d55d0..bff1bb95e9540 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml @@ -23,9 +23,14 @@ </before> <after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex"/> - <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"> + <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clickClearFilters"/> + <actionGroup ref="AdminFilterTaxRateByCodeActionGroup" stepKey="filterByCode"> <argument name="taxRateCode" value="{{SimpleTaxRate.code}}" /> </actionGroup> + <actionGroup ref="AdminClickRowInGridActionGroup" stepKey="clickFirstRow"> + <argument name="row_number" value="1" /> + </actionGroup> + <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"/> </after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml index 620ad1909c6f8..570608bb6adf6 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml @@ -23,9 +23,14 @@ </before> <after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex"/> - <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"> + <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clickClearFilters"/> + <actionGroup ref="AdminFilterTaxRateByCodeActionGroup" stepKey="filterByCode"> <argument name="taxRateCode" value="{{SimpleTaxRate.code}}" /> </actionGroup> + <actionGroup ref="AdminClickRowInGridActionGroup" stepKey="clickFirstRow"> + <argument name="row_number" value="1" /> + </actionGroup> + <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"/> </after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml index fe8f67f880f49..a8e47b77e27c0 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml @@ -23,9 +23,14 @@ </before> <after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex"/> - <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"> + <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clickClearFilters"/> + <actionGroup ref="AdminFilterTaxRateByCodeActionGroup" stepKey="filterByCode"> <argument name="taxRateCode" value="{{SimpleTaxRate.code}}" /> </actionGroup> + <actionGroup ref="AdminClickRowInGridActionGroup" stepKey="clickFirstRow"> + <argument name="row_number" value="1" /> + </actionGroup> + <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"/> </after> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml index baae945bd8d1d..341b2e1aa6344 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml @@ -25,10 +25,14 @@ <!-- Search the tax rate on tax grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> - - <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"> - <argument name="taxRateCode" value="{{initialTaxRate.code}}" /> + <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clickClearFilters"/> + <actionGroup ref="AdminFilterTaxRateByCodeActionGroup" stepKey="filterByCode"> + <argument name="taxRateCode" value="$$initialTaxRate.code$$" /> + </actionGroup> + <actionGroup ref="AdminClickRowInGridActionGroup" stepKey="clickFirstRow"> + <argument name="row_number" value="1" /> </actionGroup> + <actionGroup ref="AdminDeleteTaxRateActionGroup" stepKey="deleteTaxRate"/> <see selector="{{AdminMessagesSection.success}}" userInput="You Deleted the tax rate." stepKey="seeSuccess1"/> diff --git a/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminClickRowInGridActionGroup.xml b/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminClickRowInGridActionGroup.xml new file mode 100644 index 0000000000000..c538a6d530645 --- /dev/null +++ b/app/code/Magento/Ui/Test/Mftf/ActionGroup/AdminClickRowInGridActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminClickRowInGridActionGroup"> + <arguments> + <argument name="row_number" type="string"/> + </arguments> + + <click selector="{{AdminDataGridTableSection.row(row_number)}}" stepKey="clickOnFirstRow"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridTableSection.xml b/app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridTableSection.xml index fcee31c0bd80c..11e42353a0663 100644 --- a/app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridTableSection.xml +++ b/app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridTableSection.xml @@ -13,7 +13,7 @@ <element name="columnHeader" type="button" selector="//div[@data-role='grid-wrapper']//table[contains(@class, 'data-grid')]/thead/tr/th[contains(@class, 'data-grid-th')]/span[text() = '{{label}}']" parameterized="true" timeout="30"/> <element name="column" type="text" selector="//tr//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., '{{col}}')]/preceding-sibling::th) +1 ]" parameterized="true"/> <element name="rowCheckbox" type="checkbox" selector="table.data-grid tbody > tr:nth-of-type({{row}}) td.data-grid-checkbox-cell input" parameterized="true"/> - <element name="row" type="text" selector="table.data-grid tbody > tr:nth-of-type({{row}})" parameterized="true"/> + <element name="row" type="text" selector="table.data-grid tbody > tr:nth-of-type({{row}})" parameterized="true" timeout="30"/> <element name="rows" type="text" selector="table.data-grid tbody > tr.data-row"/> <!--Specific cell e.g. {{Section.gridCell('1', 'Name')}}--> <element name="gridCell" type="text" selector="//tr[{{row}}]//td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., '{{column}}')]/preceding-sibling::th) +1 ]" parameterized="true"/> From ce46ca6b9b46a573522686c74e1059cc7ae9ba1c Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Tue, 8 Sep 2020 11:35:36 +0300 Subject: [PATCH 66/99] Update app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml Co-authored-by: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> --- .../Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml index 0a2eaacfc613c..4da29104797ac 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.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="AdminOpenCmsBlockActionGroup" deprecated="Use app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpenCmsBlockActionGroup.xml instead."> + <actionGroup name="AdminOpenCmsBlockActionGroup" deprecated="Use AdminOpenCmsBlockActionGroup instead."> <arguments> <argument name="block_id" type="string"/> </arguments> From 2577a871dc2da79d5a0b77424cd12718e83ff09f Mon Sep 17 00:00:00 2001 From: Mykhailo Matiola <mykhailo.matiola@transoftgroup.com> Date: Tue, 8 Sep 2020 12:25:22 +0300 Subject: [PATCH 67/99] MC-37438: Customer Configurations: Create new account options --- .../Customer/Block/Address/EditTest.php | 161 ++++++---- .../Controller/Account/CreatePostTest.php | 303 ++++++++++++++++++ .../Customer/Controller/AccountTest.php | 212 ------------ .../AccountManagement/CreateAccountTest.php | 166 ++++++++++ .../Model/Address/CreateAddressTest.php | 143 +++++++++ .../customer_confirmation_email_template.php | 30 ++ ...r_confirmation_email_template_rollback.php | 25 ++ .../customer_confirmed_email_template.php | 30 ++ ...omer_confirmed_email_template_rollback.php | 25 ++ .../customer_welcome_email_template.php | 30 ++ ...stomer_welcome_email_template_rollback.php | 23 ++ ...mer_welcome_no_password_email_template.php | 30 ++ ...me_no_password_email_template_rollback.php | 25 ++ 13 files changed, 935 insertions(+), 268 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Controller/Account/CreatePostTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_template.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_template_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmed_email_template.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmed_email_template_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_email_template.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_email_template_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_no_password_email_template.php create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_no_password_email_template_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Customer/Block/Address/EditTest.php b/dev/tests/integration/testsuite/Magento/Customer/Block/Address/EditTest.php index 9c382068ceebc..12585992d084c 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Block/Address/EditTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Block/Address/EditTest.php @@ -3,126 +3,175 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Customer\Block\Address; +use Magento\Customer\Model\AddressRegistry; +use Magento\Customer\Model\CustomerRegistry; +use Magento\Customer\Model\Session; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\Result\Page; +use Magento\Framework\View\Result\PageFactory; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Helper\Xpath; +use PHPUnit\Framework\TestCase; + /** * Tests Address Edit Block + * + * @magentoAppArea frontend + * @magentoAppIsolation enabled */ -class EditTest extends \PHPUnit\Framework\TestCase +class EditTest extends TestCase { + /** @var ObjectManagerInterface */ + private $objectManager; + /** @var Edit */ - protected $_block; + private $block; - /** @var \Magento\Customer\Model\Session */ - protected $_customerSession; + /** @var Session */ + private $customerSession; - /** @var \Magento\Backend\Block\Template\Context */ - protected $_context; + /** @var AddressRegistry */ + private $addressRegistry; - /** @var string */ - protected $_requestId; + /** @var CustomerRegistry */ + private $customerRegistry; + /** @var RequestInterface */ + private $request; + + /** + * @inheritdoc + */ protected function setUp(): void { - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - - $this->_customerSession = $objectManager->get(\Magento\Customer\Model\Session::class); - $this->_customerSession->setCustomerId(1); - - $this->_context = $objectManager->get(\Magento\Backend\Block\Template\Context::class); - $this->_requestId = $this->_context->getRequest()->getParam('id'); - $this->_context->getRequest()->setParam('id', '1'); - - $objectManager->get(\Magento\Framework\App\State::class)->setAreaCode('frontend'); - - /** @var $layout \Magento\Framework\View\Layout */ - $layout = $objectManager->get(\Magento\Framework\View\LayoutInterface::class); - $currentCustomer = $objectManager->create( - \Magento\Customer\Helper\Session\CurrentCustomer::class, - ['customerSession' => $this->_customerSession] - ); - $this->_block = $layout->createBlock( - \Magento\Customer\Block\Address\Edit::class, - '', - ['customerSession' => $this->_customerSession, 'currentCustomer' => $currentCustomer] - ); + parent::setUp(); + $this->objectManager = Bootstrap::getObjectManager(); + $this->customerSession = $this->objectManager->get(Session::class); + $this->customerSession->setCustomerId(1); + $this->request = $this->objectManager->get(RequestInterface::class); + $this->request->setParam('id', '1'); + /** @var Page $page */ + $page = $this->objectManager->get(PageFactory::class)->create(); + $page->addHandle(['default', 'customer_address_form']); + $page->getLayout()->generateXml(); + $this->block = $page->getLayout()->getBlock('customer_address_edit'); + $this->addressRegistry = $this->objectManager->get(AddressRegistry::class); + $this->customerRegistry = $this->objectManager->get(CustomerRegistry::class); } + /** + * @inheritdoc + */ protected function tearDown(): void { - $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); - $this->_customerSession->setCustomerId(null); - $this->_context->getRequest()->setParam('id', $this->_requestId); - /** @var \Magento\Customer\Model\AddressRegistry $addressRegistry */ - $addressRegistry = $objectManager->get(\Magento\Customer\Model\AddressRegistry::class); + parent::tearDown(); + $this->customerSession->setCustomerId(null); + $this->request->setParam('id', null); //Cleanup address from registry - $addressRegistry->remove(1); - $addressRegistry->remove(2); - - /** @var \Magento\Customer\Model\CustomerRegistry $customerRegistry */ - $customerRegistry = $objectManager->get(\Magento\Customer\Model\CustomerRegistry::class); + $this->addressRegistry->remove(1); + $this->addressRegistry->remove(2); //Cleanup customer from registry - $customerRegistry->remove(1); + $this->customerRegistry->remove(1); } /** * @magentoDataFixture Magento/Customer/_files/customer.php + * @return void */ - public function testGetSaveUrl() + public function testGetSaveUrl(): void { - $this->assertEquals('http://localhost/index.php/customer/address/formPost/', $this->_block->getSaveUrl()); + $this->assertEquals('http://localhost/index.php/customer/address/formPost/', $this->block->getSaveUrl()); } /** * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Customer/_files/customer_address.php + * @return void */ - public function testGetRegionId() + public function testGetRegionId(): void { - $this->assertEquals(1, $this->_block->getRegionId()); + $this->assertEquals(1, $this->block->getRegionId()); } /** * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Customer/_files/customer_address.php + * @return void */ - public function testGetCountryId() + public function testGetCountryId(): void { - $this->assertEquals('US', $this->_block->getCountryId()); + $this->assertEquals('US', $this->block->getCountryId()); } /** * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Customer/_files/customer_two_addresses.php + * @return void */ - public function testGetCustomerAddressCount() + public function testGetCustomerAddressCount(): void { - $this->assertEquals(2, $this->_block->getCustomerAddressCount()); + $this->assertEquals(2, $this->block->getCustomerAddressCount()); } /** * @magentoDataFixture Magento/Customer/_files/customer.php + * @return void */ - public function testCanSetAsDefaultShipping() + public function testCanSetAsDefaultShipping(): void { - $this->assertEquals(0, $this->_block->canSetAsDefaultShipping()); + $this->assertEquals(0, $this->block->canSetAsDefaultShipping()); } /** * @magentoDataFixture Magento/Customer/_files/customer.php + * @return void */ - public function testIsDefaultBilling() + public function testIsDefaultBilling(): void { - $this->assertFalse($this->_block->isDefaultBilling()); + $this->assertFalse($this->block->isDefaultBilling()); } /** * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Customer/_files/customer_address.php + * @return void + */ + public function testGetStreetLine(): void + { + $this->assertEquals('Green str, 67', $this->block->getStreetLine(1)); + $this->assertEquals('', $this->block->getStreetLine(2)); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoConfigFixture current_store customer/create_account/vat_frontend_visibility 1 + * @return void + */ + public function testVatIdFieldVisible(): void + { + $html = $this->block->toHtml(); + $labelXpath = "//div[contains(@class, 'taxvat')]//label/span[normalize-space(text()) = '%s']"; + $this->assertEquals(1, Xpath::getElementsCountForXpath(sprintf($labelXpath, __('VAT Number')), $html)); + $inputXpath = "//div[contains(@class, 'taxvat')]//div/input[contains(@id,'vat_id') and @type='text']"; + $this->assertEquals(1, Xpath::getElementsCountForXpath($inputXpath, $html)); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * @magentoConfigFixture current_store customer/create_account/vat_frontend_visibility 0 + * @return void */ - public function testGetStreetLine() + public function testVatIdFieldNotVisible(): void { - $this->assertEquals('Green str, 67', $this->_block->getStreetLine(1)); - $this->assertEquals('', $this->_block->getStreetLine(2)); + $html = $this->block->toHtml(); + $labelXpath = "//div[contains(@class, 'taxvat')]//label/span[normalize-space(text()) = '%s']"; + $this->assertEquals(0, Xpath::getElementsCountForXpath(sprintf($labelXpath, __('VAT Number')), $html)); + $inputXpath = "//div[contains(@class, 'taxvat')]//div/input[contains(@id,'vat_id') and @type='text']"; + $this->assertEquals(0, Xpath::getElementsCountForXpath($inputXpath, $html)); } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Account/CreatePostTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Account/CreatePostTest.php new file mode 100644 index 0000000000000..8ce1d2ae9ccf9 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Account/CreatePostTest.php @@ -0,0 +1,303 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Customer\Controller\Account; + +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Customer\Model\CustomerRegistry; +use Magento\Framework\App\Http; +use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Message\MessageInterface; +use Magento\Framework\Stdlib\CookieManagerInterface; +use Magento\Framework\UrlInterface; +use Magento\Store\Model\StoreManagerInterface; +use Magento\TestFramework\Mail\Template\TransportBuilderMock; +use Magento\TestFramework\Request; +use Magento\TestFramework\TestCase\AbstractController; +use Magento\Theme\Controller\Result\MessagePlugin; + +/** + * Tests from customer account create post action. + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ +class CreatePostTest extends AbstractController +{ + /** + * @var TransportBuilderMock + */ + private $transportBuilderMock; + + /** + * @var StoreManagerInterface + */ + private $storeManager; + + /** + * @var CustomerRepositoryInterface + */ + private $customerRepository; + + /** + * @var CustomerRegistry + */ + private $customerRegistry; + + /** + * @var CookieManagerInterface + */ + private $cookieManager; + + /** + * @var UrlInterface + */ + private $urlBuilder; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->transportBuilderMock = $this->_objectManager->get(TransportBuilderMock::class); + $this->storeManager = $this->_objectManager->get(StoreManagerInterface::class); + $this->customerRepository = $this->_objectManager->get(CustomerRepositoryInterface::class); + $this->customerRegistry = $this->_objectManager->get(CustomerRegistry::class); + $this->cookieManager = $this->_objectManager->get(CookieManagerInterface::class); + $this->urlBuilder = $this->_objectManager->get(UrlInterface::class); + } + + /** + * Tests that without form key user account won't be created + * and user will be redirected on account creation page again. + * + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @return void + */ + public function testNoFormKeyCreatePostAction(): void + { + $this->fillRequestWithAccountData('test1@email.com'); + $this->getRequest()->setPostValue('form_key', null); + $this->dispatch('customer/account/createPost'); + + $this->assertCustomerNotExists('test1@email.com'); + $this->assertRedirect($this->stringEndsWith('customer/account/create/')); + $this->assertSessionMessages( + $this->stringContains((string)__('Invalid Form Key. Please refresh the page.')), + MessageInterface::TYPE_ERROR + ); + } + + /** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_website customer/create_account/confirm 0 + * @magentoConfigFixture current_store customer/create_account/default_group 1 + * @magentoConfigFixture current_store customer/create_account/generate_human_friendly_id 0 + * + * @return void + */ + public function testNoConfirmCreatePostAction(): void + { + $this->fillRequestWithAccountData('test1@email.com'); + $this->dispatch('customer/account/createPost'); + $this->assertRedirect($this->stringEndsWith('customer/account/')); + $this->assertSessionMessages( + $this->containsEqual( + (string)__('Thank you for registering with %1.', $this->storeManager->getStore()->getFrontendName()) + ), + MessageInterface::TYPE_SUCCESS + ); + $customer = $this->customerRegistry->retrieveByEmail('test1@email.com'); + //Assert customer group + $this->assertEquals(1, $customer->getDataModel()->getGroupId()); + //Assert customer increment id generation + $this->assertNull($customer->getData('increment_id')); + } + + /** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_website customer/create_account/confirm 0 + * @magentoConfigFixture current_store customer/create_account/default_group 2 + * @magentoConfigFixture current_store customer/create_account/generate_human_friendly_id 1 + * @return void + */ + public function testCreatePostWithCustomConfiguration(): void + { + $this->fillRequestWithAccountData('test@email.com'); + $this->dispatch('customer/account/createPost'); + $this->assertRedirect($this->stringEndsWith('customer/account/')); + $this->assertSessionMessages( + $this->containsEqual( + (string)__('Thank you for registering with %1.', $this->storeManager->getStore()->getFrontendName()) + ), + MessageInterface::TYPE_SUCCESS + ); + $customer = $this->customerRegistry->retrieveByEmail('test@email.com'); + //Assert customer group + $this->assertEquals(2, $customer->getDataModel()->getGroupId()); + //Assert customer increment id generation + $this->assertNotNull($customer->getData('increment_id')); + $this->assertMatchesRegularExpression('/\d{8}/', $customer->getData('increment_id')); + } + + /** + * @magentoDbIsolation enabled + * @magentoAppIsolation enabled + * @magentoConfigFixture current_website customer/create_account/confirm 1 + * + * @return void + */ + public function testWithConfirmCreatePostAction(): void + { + $email = 'test2@email.com'; + $this->fillRequestWithAccountData($email); + $this->dispatch('customer/account/createPost'); + $this->assertRedirect($this->stringContains('customer/account/index/')); + $message = 'You must confirm your account.' + . ' Please check your email for the confirmation link or <a href="%1">click here</a> for a new link.'; + $url = $this->urlBuilder->getUrl('customer/account/confirmation', ['_query' => ['email' => $email]]); + $this->assertSessionMessages( + $this->containsEqual((string)__($message, $url)), + MessageInterface::TYPE_SUCCESS + ); + } + + /** + * @magentoDataFixture Magento/Customer/_files/customer.php + * + * @return void + */ + public function testExistingEmailCreatePostAction(): void + { + $this->fillRequestWithAccountData('customer@example.com'); + $this->dispatch('customer/account/createPost'); + $this->assertRedirect($this->stringContains('customer/account/create/')); + $message = 'There is already an account with this email address.' + . ' If you are sure that it is your email address, <a href="%1">click here</a> ' + . 'to get your password and access your account.'; + $url = $this->urlBuilder->getUrl('customer/account/forgotpassword'); + $this->assertSessionMessages($this->containsEqual((string)__($message, $url)), MessageInterface::TYPE_ERROR); + } + + /** + * Register Customer with email confirmation. + * + * @magentoAppArea frontend + * @magentoConfigFixture current_website customer/create_account/confirm 1 + * + * @return void + */ + public function testRegisterCustomerWithEmailConfirmation(): void + { + $email = 'test_example@email.com'; + $this->fillRequestWithAccountData($email); + $this->dispatch('customer/account/createPost'); + $this->assertRedirect($this->stringContains('customer/account/index/')); + $message = 'You must confirm your account.' + . ' Please check your email for the confirmation link or <a href="%1">click here</a> for a new link.'; + $url = $this->urlBuilder->getUrl('customer/account/confirmation', ['_query' => ['email' => $email]]); + $this->assertSessionMessages($this->containsEqual((string)__($message, $url)), MessageInterface::TYPE_SUCCESS); + /** @var CustomerInterface $customer */ + $customer = $this->customerRepository->get($email); + $confirmation = $customer->getConfirmation(); + $sendMessage = $this->transportBuilderMock->getSentMessage(); + $this->assertNotNull($sendMessage); + $rawMessage = $sendMessage->getBody()->getParts()[0]->getRawContent(); + $this->assertStringContainsString( + (string)__( + 'You must confirm your %customer_email email before you can sign in (link is only valid once):', + ['customer_email' => $email] + ), + $rawMessage + ); + $this->assertStringContainsString( + sprintf('customer/account/confirm/?id=%s&key=%s', $customer->getId(), $confirmation), + $rawMessage + ); + $this->resetRequest(); + $this->getRequest() + ->setParam('id', $customer->getId()) + ->setParam('key', $confirmation); + $this->dispatch('customer/account/confirm'); + $this->assertRedirect($this->stringContains('customer/account/index/')); + $this->assertSessionMessages( + $this->containsEqual( + (string)__('Thank you for registering with %1.', $this->storeManager->getStore()->getFrontendName()) + ), + MessageInterface::TYPE_SUCCESS + ); + $this->assertEmpty($this->customerRepository->get($email)->getConfirmation()); + } + + /** + * Fills request with customer data. + * + * @param string $email + * @return void + */ + private function fillRequestWithAccountData(string $email): void + { + $this->getRequest() + ->setMethod(HttpRequest::METHOD_POST) + ->setParam(CustomerInterface::FIRSTNAME, 'firstname1') + ->setParam(CustomerInterface::LASTNAME, 'lastname1') + ->setParam(CustomerInterface::EMAIL, $email) + ->setParam('password', '_Password1') + ->setParam('password_confirmation', '_Password1') + ->setParam('telephone', '5123334444') + ->setParam('street', ['1234 fake street', '']) + ->setParam('city', 'Austin') + ->setParam('postcode', '78701') + ->setParam('country_id', 'US') + ->setParam('default_billing', '1') + ->setParam('default_shipping', '1') + ->setParam('is_subscribed', '0') + ->setPostValue('create_address', true); + } + + /** + * Asserts that customer does not exists. + * + * @param string $email + * @return void + */ + private function assertCustomerNotExists(string $email): void + { + $this->expectException(NoSuchEntityException::class); + $this->expectExceptionMessage( + (string)__( + 'No such entity with %fieldName = %fieldValue, %field2Name = %field2Value', + [ + 'fieldName' => 'email', + 'fieldValue' => $email, + 'field2Name' => 'websiteId', + 'field2Value' => 1 + ] + ) + ); + $this->assertNull($this->customerRepository->get($email)); + } + + /** + * Clears request. + * + * @return void + */ + protected function resetRequest(): void + { + parent::resetRequest(); + $this->cookieManager->deleteCookie(MessagePlugin::MESSAGES_COOKIES_NAME); + $this->_objectManager->removeSharedInstance(Http::class); + $this->_objectManager->removeSharedInstance(Request::class); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php index 5527a39ce0507..6abbff18c645c 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php @@ -10,13 +10,10 @@ use Magento\Customer\Api\Data\CustomerInterface; use Magento\Customer\Model\CustomerRegistry; use Magento\Customer\Model\Session; -use Magento\Framework\Api\FilterBuilder; -use Magento\Framework\Api\SearchCriteriaBuilder; use Magento\Framework\App\Http; use Magento\Framework\App\Request\Http as HttpRequest; use Magento\Framework\Data\Form\FormKey; use Magento\Framework\Message\MessageInterface; -use Magento\Framework\Phrase; use Magento\Framework\Serialize\Serializer\Json; use Magento\Framework\Stdlib\CookieManagerInterface; use Magento\Store\Model\StoreManager; @@ -220,83 +217,6 @@ public function testConfirmActionAlreadyActive() $this->getResponse()->getBody(); } - /** - * Tests that without form key user account won't be created - * and user will be redirected on account creation page again. - */ - public function testNoFormKeyCreatePostAction() - { - $this->fillRequestWithAccountData('test1@email.com'); - $this->getRequest()->setPostValue('form_key', null); - $this->dispatch('customer/account/createPost'); - - $this->assertNull($this->getCustomerByEmail('test1@email.com')); - $this->assertRedirect($this->stringEndsWith('customer/account/create/')); - $this->assertSessionMessages( - $this->equalTo([new Phrase('Invalid Form Key. Please refresh the page.')]), - MessageInterface::TYPE_ERROR - ); - } - - /** - * @magentoDbIsolation enabled - * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Customer/_files/customer_confirmation_config_disable.php - */ - public function testNoConfirmCreatePostAction() - { - $this->fillRequestWithAccountDataAndFormKey('test1@email.com'); - $this->dispatch('customer/account/createPost'); - $this->assertRedirect($this->stringEndsWith('customer/account/')); - $this->assertSessionMessages( - $this->equalTo(['Thank you for registering with Main Website Store.']), - MessageInterface::TYPE_SUCCESS - ); - } - - /** - * @magentoDbIsolation enabled - * @magentoAppIsolation enabled - * @magentoDataFixture Magento/Customer/_files/customer_confirmation_config_enable.php - */ - public function testWithConfirmCreatePostAction() - { - $this->fillRequestWithAccountDataAndFormKey('test2@email.com'); - $this->dispatch('customer/account/createPost'); - $this->assertRedirect($this->stringContains('customer/account/index/')); - $this->assertSessionMessages( - $this->equalTo( - [ - 'You must confirm your account. Please check your email for the confirmation link or ' - . '<a href="http://localhost/index.php/customer/account/confirmation/' - . '?email=test2%40email.com">click here</a> for a new link.' - ] - ), - MessageInterface::TYPE_SUCCESS - ); - } - - /** - * @magentoDataFixture Magento/Customer/_files/customer.php - */ - public function testExistingEmailCreatePostAction() - { - $this->fillRequestWithAccountDataAndFormKey('customer@example.com'); - $this->dispatch('customer/account/createPost'); - $this->assertRedirect($this->stringContains('customer/account/create/')); - $this->assertSessionMessages( - $this->equalTo( - [ - 'There is already an account with this email address. ' . - 'If you are sure that it is your email address, ' . - '<a href="http://localhost/index.php/customer/account/forgotpassword/">click here</a>' . - ' to get your password and access your account.', - ] - ), - MessageInterface::TYPE_ERROR - ); - } - /** * @magentoDataFixture Magento/Customer/_files/inactive_customer.php */ @@ -613,70 +533,6 @@ public function testWrongConfirmationEditPostAction() ); } - /** - * Register Customer with email confirmation. - * - * @magentoDataFixture Magento/Customer/_files/customer_confirmation_config_enable.php - * @return void - * @throws \Magento\Framework\Exception\InputException - * @throws \Magento\Framework\Exception\LocalizedException - * @throws \Magento\Framework\Exception\NoSuchEntityException - * @throws \Magento\Framework\Stdlib\Cookie\FailureToSendException - */ - public function testRegisterCustomerWithEmailConfirmation(): void - { - $email = 'test_example@email.com'; - $this->fillRequestWithAccountDataAndFormKey($email); - $this->dispatch('customer/account/createPost'); - $this->assertRedirect($this->stringContains('customer/account/index/')); - $this->assertSessionMessages( - $this->equalTo( - [ - 'You must confirm your account. Please check your email for the confirmation link or ' - . '<a href="http://localhost/index.php/customer/account/confirmation/' - . '?email=test_example%40email.com">click here</a> for a new link.' - ] - ), - MessageInterface::TYPE_SUCCESS - ); - /** @var CustomerRepositoryInterface $customerRepository */ - $customerRepository = $this->_objectManager->create(CustomerRepositoryInterface::class); - /** @var CustomerInterface $customer */ - $customer = $customerRepository->get($email); - $confirmation = $customer->getConfirmation(); - $message = $this->transportBuilderMock->getSentMessage(); - $rawMessage = $message->getBody()->getParts()[0]->getRawContent(); - $messageConstraint = $this->logicalAnd( - new StringContains("You must confirm your {$email} email before you can sign in (link is only valid once"), - new StringContains("customer/account/confirm/?id={$customer->getId()}&key={$confirmation}") - ); - $this->assertThat($rawMessage, $messageConstraint); - - /** @var CookieManagerInterface $cookieManager */ - $cookieManager = $this->_objectManager->get(CookieManagerInterface::class); - $cookieManager->deleteCookie(MessagePlugin::MESSAGES_COOKIES_NAME); - - $this->_objectManager->removeSharedInstance(Http::class); - $this->_objectManager->removeSharedInstance(Request::class); - $this->_request = null; - - $this->getRequest() - ->setParam('id', $customer->getId()) - ->setParam('key', $confirmation); - $this->dispatch('customer/account/confirm'); - - /** @var StoreManager $store */ - $store = $this->_objectManager->get(StoreManagerInterface::class); - $name = $store->getStore()->getFrontendName(); - - $this->assertRedirect($this->stringContains('customer/account/index/')); - $this->assertSessionMessages( - $this->equalTo(["Thank you for registering with {$name}."]), - MessageInterface::TYPE_SUCCESS - ); - $this->assertEmpty($customerRepository->get($email)->getConfirmation()); - } - /** * Test that confirmation email address displays special characters correctly. * @@ -867,74 +723,6 @@ protected function resetRequest(): void parent::resetRequest(); } - /** - * @param string $email - * @return void - */ - private function fillRequestWithAccountData($email) - { - $this->getRequest() - ->setMethod('POST') - ->setParam('firstname', 'firstname1') - ->setParam('lastname', 'lastname1') - ->setParam('company', '') - ->setParam('email', $email) - ->setParam('password', '_Password1') - ->setParam('password_confirmation', '_Password1') - ->setParam('telephone', '5123334444') - ->setParam('street', ['1234 fake street', '']) - ->setParam('city', 'Austin') - ->setParam('region_id', 57) - ->setParam('region', '') - ->setParam('postcode', '78701') - ->setParam('country_id', 'US') - ->setParam('default_billing', '1') - ->setParam('default_shipping', '1') - ->setParam('is_subscribed', '0') - ->setPostValue('create_address', true); - } - - /** - * @param string $email - * @return void - */ - private function fillRequestWithAccountDataAndFormKey($email) - { - $this->fillRequestWithAccountData($email); - $formKey = $this->_objectManager->get(FormKey::class); - $this->getRequest()->setParam('form_key', $formKey->getFormKey()); - } - - /** - * Returns stored customer by email. - * - * @param string $email - * @return CustomerInterface - */ - private function getCustomerByEmail($email) - { - /** @var FilterBuilder $filterBuilder */ - $filterBuilder = $this->_objectManager->get(FilterBuilder::class); - $filters = [ - $filterBuilder->setField(CustomerInterface::EMAIL) - ->setValue($email) - ->create() - ]; - - /** @var SearchCriteriaBuilder $searchCriteriaBuilder */ - $searchCriteriaBuilder = $this->_objectManager->get(SearchCriteriaBuilder::class); - $searchCriteria = $searchCriteriaBuilder->addFilters($filters) - ->create(); - - $customerRepository = $this->_objectManager->get(CustomerRepositoryInterface::class); - $customers = $customerRepository->getList($searchCriteria) - ->getItems(); - - $customer = array_pop($customers); - - return $customer; - } - /** * Add new request info (request uri, path info, action name). * diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagement/CreateAccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagement/CreateAccountTest.php index e12068ef62b21..bd2c26e449d72 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagement/CreateAccountTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/AccountManagement/CreateAccountTest.php @@ -13,9 +13,12 @@ use Magento\Customer\Api\Data\CustomerInterfaceFactory; use Magento\Customer\Model\Customer; use Magento\Customer\Model\CustomerFactory; +use Magento\Customer\Model\EmailNotification; +use Magento\Email\Model\ResourceModel\Template\CollectionFactory as TemplateCollectionFactory; use Magento\Framework\Api\DataObjectHelper; use Magento\Framework\Api\ExtensibleDataObjectConverter; use Magento\Framework\Api\SimpleDataObjectConverter; +use Magento\Framework\App\Config\MutableScopeConfigInterface; use Magento\Framework\Encryption\EncryptorInterface; use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\LocalizedException; @@ -23,6 +26,7 @@ use Magento\Framework\Math\Random; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Validator\Exception; +use Magento\Store\Model\ScopeInterface; use Magento\Store\Model\StoreManagerInterface; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\Helper\Xpath; @@ -101,6 +105,16 @@ class CreateAccountTest extends TestCase */ private $encryptor; + /** + * @var MutableScopeConfigInterface + */ + private $mutableScopeConfig; + + /** + * @var TemplateCollectionFactory + */ + private $templateCollectionFactory; + /** * @inheritdoc */ @@ -117,9 +131,20 @@ protected function setUp(): void $this->customerModelFactory = $this->objectManager->get(CustomerFactory::class); $this->random = $this->objectManager->get(Random::class); $this->encryptor = $this->objectManager->get(EncryptorInterface::class); + $this->mutableScopeConfig = $this->objectManager->get(MutableScopeConfigInterface::class); + $this->templateCollectionFactory = $this->objectManager->get(TemplateCollectionFactory::class); parent::setUp(); } + /** + * @inheritdoc + */ + protected function tearDown(): void + { + parent::tearDown(); + $this->mutableScopeConfig->clean(); + } + /** * @dataProvider createInvalidAccountDataProvider * @param array $customerData @@ -220,6 +245,98 @@ public function createInvalidAccountDataProvider(): array ]; } + /** + * @magentoAppArea frontend + * @magentoDataFixture Magento/Customer/_files/customer_welcome_email_template.php + * @return void + */ + public function testCreateAccountWithConfiguredWelcomeEmail(): void + { + $emailTemplate = $this->getCustomTemplateId('customer_create_account_email_template'); + $this->setConfig([EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE => $emailTemplate,]); + $this->accountManagement->createAccount( + $this->populateCustomerEntity($this->defaultCustomerData), + '_Password1' + ); + $this->assertEmailData( + [ + 'name' => 'Owner', + 'email' => 'owner@example.com', + 'message' => 'Customer create account email template', + ] + ); + } + + /** + * @magentoAppArea frontend + * @magentoDataFixture Magento/Customer/_files/customer_welcome_no_password_email_template.php + * @magentoConfigFixture current_store customer/create_account/email_identity support + * @return void + */ + public function testCreateAccountWithConfiguredWelcomeNoPasswordEmail(): void + { + $emailTemplate = $this->getCustomTemplateId('customer_create_account_email_no_password_template'); + $this->setConfig([EmailNotification::XML_PATH_REGISTER_NO_PASSWORD_EMAIL_TEMPLATE => $emailTemplate,]); + $this->accountManagement->createAccount($this->populateCustomerEntity($this->defaultCustomerData)); + $this->assertEmailData( + [ + 'name' => 'CustomerSupport', + 'email' => 'support@example.com', + 'message' => 'Customer create account email no password template', + ] + ); + } + + /** + * @magentoAppArea frontend + * @magentoDataFixture Magento/Customer/_files/customer_confirmation_email_template.php + * @magentoConfigFixture current_website customer/create_account/confirm 1 + * @magentoConfigFixture current_store customer/create_account/email_identity custom1 + * @return void + */ + public function testCreateAccountWithConfiguredConfirmationEmail(): void + { + $emailTemplate = $this->getCustomTemplateId('customer_create_account_email_confirmation_template'); + $this->setConfig([EmailNotification::XML_PATH_CONFIRM_EMAIL_TEMPLATE => $emailTemplate,]); + $this->accountManagement->createAccount( + $this->populateCustomerEntity($this->defaultCustomerData), + '_Password1' + ); + $this->assertEmailData( + [ + 'name' => 'Custom 1', + 'email' => 'custom1@example.com', + 'message' => 'Customer create account email confirmation template', + ] + ); + } + + /** + * @magentoAppArea frontend + * @magentoDataFixture Magento/Customer/_files/customer_confirmed_email_template.php + * @magentoConfigFixture current_store customer/create_account/email_identity custom1 + * @magentoConfigFixture current_website customer/create_account/confirm 1 + * @return void + */ + public function testCreateAccountWithConfiguredConfirmedEmail(): void + { + $emailTemplate = $this->getCustomTemplateId('customer_create_account_email_confirmed_template'); + $this->setConfig([EmailNotification::XML_PATH_CONFIRMED_EMAIL_TEMPLATE => $emailTemplate,]); + $this->accountManagement->createAccount( + $this->populateCustomerEntity($this->defaultCustomerData), + '_Password1' + ); + $customer = $this->customerRepository->get('customer@example.com'); + $this->accountManagement->activate($customer->getEmail(), $customer->getConfirmation()); + $this->assertEmailData( + [ + 'name' => 'Custom 1', + 'email' => 'custom1@example.com', + 'message' => 'Customer create account email confirmed template', + ] + ); + } + /** * Assert that when you create customer account via admin, link with "set password" is send to customer email. * @@ -589,4 +706,53 @@ private function assertCustomerData( ); } } + + /** + * Sets config data. + * + * @param array $configs + * @return void + */ + private function setConfig(array $configs): void + { + foreach ($configs as $path => $value) { + $this->mutableScopeConfig->setValue($path, $value, ScopeInterface::SCOPE_STORE, 'default'); + } + } + + /** + * Assert email data. + * + * @param array $expectedData + * @return void + */ + private function assertEmailData(array $expectedData): void + { + $message = $this->transportBuilderMock->getSentMessage(); + $this->assertNotNull($message); + $messageFrom = $message->getFrom(); + $this->assertNotNull($messageFrom); + $messageFrom = reset($messageFrom); + $this->assertEquals($expectedData['name'], $messageFrom->getName()); + $this->assertEquals($expectedData['email'], $messageFrom->getEmail()); + $this->assertStringContainsString( + $expectedData['message'], + $message->getBody()->getParts()[0]->getRawContent(), + 'Expected message wasn\'t found in email content.' + ); + } + + /** + * Returns email template id by template code. + * + * @param string $templateCode + * @return int + */ + private function getCustomTemplateId(string $templateCode): int + { + return (int)$this->templateCollectionFactory->create() + ->addFieldToFilter('template_code', $templateCode) + ->getFirstItem() + ->getId(); + } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/Address/CreateAddressTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/Address/CreateAddressTest.php index ac55f93bc9e4b..eb638eeb329aa 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/Address/CreateAddressTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/Address/CreateAddressTest.php @@ -14,11 +14,16 @@ use Magento\Customer\Model\AddressRegistry; use Magento\Customer\Model\CustomerRegistry; use Magento\Customer\Model\ResourceModel\Address; +use Magento\Customer\Model\Vat; +use Magento\Customer\Observer\AfterAddressSaveObserver; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\DataObjectFactory; use Magento\Framework\Exception\InputException; use Magento\TestFramework\Directory\Model\GetRegionIdByName; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\ObjectManager; use PHPUnit\Framework\TestCase; +use Psr\Log\LoggerInterface as PsrLogger; /** * Assert that address was created as expected or address create throws expected error. @@ -88,6 +93,11 @@ class CreateAddressTest extends TestCase */ private $createdAddressesIds = []; + /** + * @var DataObjectFactory + */ + private $dataObjectFactory; + /** * @inheritdoc */ @@ -101,6 +111,7 @@ protected function setUp(): void $this->customerRepository = $this->objectManager->get(CustomerRepositoryInterface::class); $this->addressRegistry = $this->objectManager->get(AddressRegistry::class); $this->addressResource = $this->objectManager->get(Address::class); + $this->dataObjectFactory = $this->objectManager->get(DataObjectFactory::class); parent::setUp(); } @@ -112,6 +123,7 @@ protected function tearDown(): void foreach ($this->createdAddressesIds as $createdAddressesId) { $this->addressRegistry->remove($createdAddressesId); } + $this->objectManager->removeSharedInstance(AfterAddressSaveObserver::class); parent::tearDown(); } @@ -326,6 +338,92 @@ public function createWrongAddressesDataProvider(): array ]; } + /** + * Assert that after address creation customer group is Group for Valid VAT ID - Domestic. + * + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/Customer/_files/customer_no_address.php + * @magentoConfigFixture current_store general/store_information/country_id AT + * @magentoConfigFixture current_store customer/create_account/auto_group_assign 1 + * @magentoConfigFixture current_store customer/create_account/viv_domestic_group 2 + * @return void + */ + public function testAddressCreatedWithGroupAssignByDomesticVatId(): void + { + $this->createVatMock(true, true); + $addressData = array_merge( + self::STATIC_CUSTOMER_ADDRESS_DATA, + [AddressInterface::VAT_ID => '111', AddressInterface::COUNTRY_ID => 'AT'] + ); + $customer = $this->customerRepository->get('customer5@example.com'); + $this->createAddress((int)$customer->getId(), $addressData, false, true); + $this->assertEquals(2, $this->getCustomerGroupId('customer5@example.com')); + } + + /** + * Assert that after address creation customer group is Group for Valid VAT ID - Intra-Union. + * + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/Customer/_files/customer_no_address.php + * @magentoConfigFixture current_store general/store_information/country_id GR + * @magentoConfigFixture current_store customer/create_account/auto_group_assign 1 + * @magentoConfigFixture current_store customer/create_account/viv_intra_union_group 2 + * @return void + */ + public function testAddressCreatedWithGroupAssignByIntraUnionVatId(): void + { + $this->createVatMock(true, true); + $addressData = array_merge( + self::STATIC_CUSTOMER_ADDRESS_DATA, + [AddressInterface::VAT_ID => '111', AddressInterface::COUNTRY_ID => 'AT'] + ); + $customer = $this->customerRepository->get('customer5@example.com'); + $this->createAddress((int)$customer->getId(), $addressData, false, true); + $this->assertEquals(2, $this->getCustomerGroupId('customer5@example.com')); + } + + /** + * Assert that after address creation customer group is Group for Invalid VAT ID. + * + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/Customer/_files/customer_no_address.php + * @magentoConfigFixture current_store customer/create_account/auto_group_assign 1 + * @magentoConfigFixture current_store customer/create_account/viv_invalid_group 2 + * @return void + */ + public function testAddressCreatedWithGroupAssignByInvalidVatId(): void + { + $this->createVatMock(false, true); + $addressData = array_merge( + self::STATIC_CUSTOMER_ADDRESS_DATA, + [AddressInterface::VAT_ID => '111', AddressInterface::COUNTRY_ID => 'AT'] + ); + $customer = $this->customerRepository->get('customer5@example.com'); + $this->createAddress((int)$customer->getId(), $addressData, false, true); + $this->assertEquals(2, $this->getCustomerGroupId('customer5@example.com')); + } + + /** + * Assert that after address creation customer group is Validation Error Group. + * + * @magentoAppIsolation enabled + * @magentoDataFixture Magento/Customer/_files/customer_no_address.php + * @magentoConfigFixture current_store customer/create_account/auto_group_assign 1 + * @magentoConfigFixture current_store customer/create_account/viv_error_group 2 + * @return void + */ + public function testAddressCreatedWithGroupAssignByVatIdWithError(): void + { + $this->createVatMock(false, false); + $addressData = array_merge( + self::STATIC_CUSTOMER_ADDRESS_DATA, + [AddressInterface::VAT_ID => '111', AddressInterface::COUNTRY_ID => 'AT'] + ); + $customer = $this->customerRepository->get('customer5@example.com'); + $this->createAddress((int)$customer->getId(), $addressData, false, true); + $this->assertEquals(2, $this->getCustomerGroupId('customer5@example.com')); + } + /** * Create customer address with provided address data. * @@ -361,4 +459,49 @@ protected function createAddress( return $address; } + + /** + * Creates mock for vat id validation. + * + * @param bool $isValid + * @param bool $isRequestSuccess + * @return void + */ + private function createVatMock(bool $isValid = false, bool $isRequestSuccess = false): void + { + $gatewayResponse = $this->dataObjectFactory->create( + [ + 'data' => [ + 'is_valid' => $isValid, + 'request_date' => '', + 'request_identifier' => '123123123', + 'request_success' => $isRequestSuccess, + 'request_message' => __(''), + ], + ] + ); + $customerVat = $this->getMockBuilder(Vat::class) + ->setConstructorArgs( + [ + $this->objectManager->get(ScopeConfigInterface::class), + $this->objectManager->get(PsrLogger::class) + ] + ) + ->setMethods(['checkVatNumber']) + ->getMock(); + $customerVat->method('checkVatNumber')->willReturn($gatewayResponse); + $this->objectManager->removeSharedInstance(Vat::class); + $this->objectManager->addSharedInstance($customerVat, Vat::class); + } + + /** + * Returns customer group id by email. + * + * @param string $email + * @return int + */ + private function getCustomerGroupId(string $email): int + { + return (int)$this->customerRepository->get($email)->getGroupId(); + } } diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_template.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_template.php new file mode 100644 index 0000000000000..38b607230cbaf --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_template.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Email\Model\ResourceModel\Template as TemplateResource; +use Magento\Framework\Mail\TemplateInterface; +use Magento\Framework\Mail\TemplateInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +/** @var TemplateResource $templateResource */ +$templateResource = $objectManager->get(TemplateResource::class); +/** @var TemplateInterfaceFactory $templateFactory */ +$templateFactory = $objectManager->get(TemplateInterfaceFactory::class); +/** @var TemplateInterface $template */ +$template = $templateFactory->create(); + +$content = <<<HTML +{{template config_path="design/email/header_template"}} +<p>{{trans "Customer create account email confirmation template"}}</p> +{{template config_path="design/email/footer_template"}} +HTML; + +$template->setTemplateCode('customer_create_account_email_confirmation_template') + ->setTemplateText($content) + ->setTemplateType(TemplateInterface::TYPE_HTML); +$templateResource->save($template); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_template_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_template_rollback.php new file mode 100644 index 0000000000000..07fee6e81fe47 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmation_email_template_rollback.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Email\Model\ResourceModel\Template as TemplateResource; +use Magento\Email\Model\ResourceModel\Template\CollectionFactory; +use Magento\Email\Model\ResourceModel\Template\Collection; +use Magento\Framework\Mail\TemplateInterface; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +/** @var TemplateResource $templateResource */ +$templateResource = $objectManager->get(TemplateResource::class); +/** @var Collection $collection */ +$collection = $objectManager->get(CollectionFactory::class)->create(); +/** @var TemplateInterface $template */ +$template = $collection + ->addFieldToFilter('template_code', 'customer_create_account_email_confirmation_template') + ->getFirstItem(); +if ($template->getId()) { + $templateResource->delete($template); +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmed_email_template.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmed_email_template.php new file mode 100644 index 0000000000000..859cae92dbd27 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmed_email_template.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Email\Model\ResourceModel\Template as TemplateResource; +use Magento\Framework\Mail\TemplateInterface; +use Magento\Framework\Mail\TemplateInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +/** @var TemplateResource $templateResource */ +$templateResource = $objectManager->get(TemplateResource::class); +/** @var TemplateInterfaceFactory $templateFactory */ +$templateFactory = $objectManager->get(TemplateInterfaceFactory::class); +/** @var TemplateInterface $template */ +$template = $templateFactory->create(); + +$content = <<<HTML +{{template config_path="design/email/header_template"}} +<p>{{trans "Customer create account email confirmed template"}}</p> +{{template config_path="design/email/footer_template"}} +HTML; + +$template->setTemplateCode('customer_create_account_email_confirmed_template') + ->setTemplateText($content) + ->setTemplateType(TemplateInterface::TYPE_HTML); +$templateResource->save($template); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmed_email_template_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmed_email_template_rollback.php new file mode 100644 index 0000000000000..a4e03038d45bd --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_confirmed_email_template_rollback.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Email\Model\ResourceModel\Template as TemplateResource; +use Magento\Email\Model\ResourceModel\Template\CollectionFactory; +use Magento\Email\Model\ResourceModel\Template\Collection; +use Magento\Framework\Mail\TemplateInterface; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +/** @var TemplateResource $templateResource */ +$templateResource = $objectManager->get(TemplateResource::class); +/** @var Collection $collection */ +$collection = $objectManager->get(CollectionFactory::class)->create(); +/** @var TemplateInterface $template */ +$template = $collection + ->addFieldToFilter('template_code', 'customer_create_account_email_confirmed_template') + ->getFirstItem(); +if ($template->getId()) { + $templateResource->delete($template); +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_email_template.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_email_template.php new file mode 100644 index 0000000000000..6cc273dbe235a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_email_template.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Email\Model\ResourceModel\Template as TemplateResource; +use Magento\Framework\Mail\TemplateInterface; +use Magento\Framework\Mail\TemplateInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +/** @var TemplateResource $templateResource */ +$templateResource = $objectManager->get(TemplateResource::class); +/** @var TemplateInterfaceFactory $templateFactory */ +$templateFactory = $objectManager->get(TemplateInterfaceFactory::class); +/** @var TemplateInterface $template */ +$template = $templateFactory->create(); + +$content = <<<HTML +{{template config_path="design/email/header_template"}} +<p>{{trans "Customer create account email template"}}</p> +{{template config_path="design/email/footer_template"}} +HTML; + +$template->setTemplateCode('customer_create_account_email_template') + ->setTemplateText($content) + ->setTemplateType(TemplateInterface::TYPE_HTML); +$templateResource->save($template); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_email_template_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_email_template_rollback.php new file mode 100644 index 0000000000000..6bef9822d3e9a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_email_template_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\Email\Model\ResourceModel\Template as TemplateResource; +use Magento\Email\Model\ResourceModel\Template\CollectionFactory; +use Magento\Email\Model\ResourceModel\Template\Collection; +use Magento\Framework\Mail\TemplateInterface; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +/** @var TemplateResource $templateResource */ +$templateResource = $objectManager->get(TemplateResource::class); +/** @var Collection $collection */ +$collection = $objectManager->get(CollectionFactory::class)->create(); +/** @var TemplateInterface $template */ +$template = $collection->addFieldToFilter('template_code', 'customer_create_account_email_template')->getFirstItem(); +if ($template->getId()) { + $templateResource->delete($template); +} diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_no_password_email_template.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_no_password_email_template.php new file mode 100644 index 0000000000000..a936bb9a4eb02 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_no_password_email_template.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Email\Model\ResourceModel\Template as TemplateResource; +use Magento\Framework\Mail\TemplateInterface; +use Magento\Framework\Mail\TemplateInterfaceFactory; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +/** @var TemplateResource $templateResource */ +$templateResource = $objectManager->get(TemplateResource::class); +/** @var TemplateInterfaceFactory $templateFactory */ +$templateFactory = $objectManager->get(TemplateInterfaceFactory::class); +/** @var TemplateInterface $template */ +$template = $templateFactory->create(); + +$content = <<<HTML +{{template config_path="design/email/header_template"}} +<p>{{trans "Customer create account email no password template"}}</p> +{{template config_path="design/email/footer_template"}} +HTML; + +$template->setTemplateCode('customer_create_account_email_no_password_template') + ->setTemplateText($content) + ->setTemplateType(TemplateInterface::TYPE_HTML); +$templateResource->save($template); diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_no_password_email_template_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_no_password_email_template_rollback.php new file mode 100644 index 0000000000000..4e14b4293cbb5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_welcome_no_password_email_template_rollback.php @@ -0,0 +1,25 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Email\Model\ResourceModel\Template as TemplateResource; +use Magento\Email\Model\ResourceModel\Template\CollectionFactory; +use Magento\Email\Model\ResourceModel\Template\Collection; +use Magento\Framework\Mail\TemplateInterface; +use Magento\TestFramework\Helper\Bootstrap; + +$objectManager = Bootstrap::getObjectManager(); +/** @var TemplateResource $templateResource */ +$templateResource = $objectManager->get(TemplateResource::class); +/** @var Collection $collection */ +$collection = $objectManager->get(CollectionFactory::class)->create(); +/** @var TemplateInterface $template */ +$template = $collection + ->addFieldToFilter('template_code', 'customer_create_account_email_no_password_template') + ->getFirstItem(); +if ($template->getId()) { + $templateResource->delete($template); +} From 9b165382495928d340c4127a264eb636070f2532 Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Tue, 8 Sep 2020 12:27:59 +0300 Subject: [PATCH 68/99] minor fix --- .../Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml index 4da29104797ac..c43628f3e60b5 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.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="AdminOpenCmsBlockActionGroup" deprecated="Use AdminOpenCmsBlockActionGroup instead."> + <actionGroup name="AdminOpenCmsBlockActionGroup" deprecated="Use other ActionGroup with the same name instead."> <arguments> <argument name="block_id" type="string"/> </arguments> From d2c7d4cfd8a5c8f385709036990beba266767191 Mon Sep 17 00:00:00 2001 From: Oleh Usik <o.usik@atwix.com> Date: Tue, 8 Sep 2020 12:48:18 +0300 Subject: [PATCH 69/99] revert name --- .../Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml index c43628f3e60b5..4da29104797ac 100644 --- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.xml +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpentCmsBlockActionGroup.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="AdminOpenCmsBlockActionGroup" deprecated="Use other ActionGroup with the same name instead."> + <actionGroup name="AdminOpenCmsBlockActionGroup" deprecated="Use AdminOpenCmsBlockActionGroup instead."> <arguments> <argument name="block_id" type="string"/> </arguments> From e31ab0041482ae52f08da44548ca70b9e16cdb50 Mon Sep 17 00:00:00 2001 From: joweecaquicla <joie@abovethefray.io> Date: Tue, 8 Sep 2020 18:48:07 +0800 Subject: [PATCH 70/99] magento/adobe-stock-integration#1794: [MFTF] Unskip AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest - modified test --- ...alogUiVerifyUsedInLinkCategoryGridTest.xml | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml index eb2f75dad0151..40a5cf8e591fc 100644 --- a/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml +++ b/app/code/Magento/MediaGalleryCatalogUi/Test/Mftf/Test/AdminMediaGalleryCatalogUiVerifyUsedInLinkCategoryGridTest.xml @@ -21,25 +21,31 @@ <before> <createData entity="TestSubCategory" stepKey="category"/> <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> - <actionGroup ref="CliCacheCleanActionGroup" stepKey="cleanFullPageCache"> - <argument name="tags" value="config full_page"/> - </actionGroup> </before> <after> - <actionGroup ref="AdminEnhancedMediaGalleryEnableMassActionModeActionGroup" stepKey="enableMassActionToDeleteImages"/> - <actionGroup ref="AdminEnhancedMediaGallerySelectImageForMassActionActionGroup" stepKey="selectSecondImageToDelete"> - <argument name="imageName" value="{{UpdatedImageDetails.title}}"/> + <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetAdminDataGridToDefaultView"/> + <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectFolderForDelete"> + <argument name="name" value="categoryImage"/> + </actionGroup> + <actionGroup ref="AdminMediaGalleryFolderDeleteActionGroup" stepKey="deleteFolder"/> + <actionGroup ref="AdminMediaGalleryAssertFolderDoesNotExistActionGroup" stepKey="assertFolderWasDeleted"> + <argument name="name" value="categoryImage"/> </actionGroup> - <actionGroup ref="AdminEnhancedMediaGalleryClickDeleteImagesButtonActionGroup" stepKey="clickDeleteSelectedButton"/> - <actionGroup ref="AdminEnhancedMediaGalleryConfirmDeleteImagesActionGroup" stepKey="deleteImages"/> </after> - <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openCategoryPage"/> <actionGroup ref="AdminCategoriesOpenCategoryActionGroup" stepKey="openCategory"> <argument name="category" value="$$category$$"/> </actionGroup> <actionGroup ref="AdminOpenMediaGalleryFromCategoryImageUploaderActionGroup" stepKey="openMediaGalleryFromImageUploader"/> <actionGroup ref="ResetAdminDataGridToDefaultViewActionGroup" stepKey="resetCategoryImageGalleryGridToDefaultView"/> + <actionGroup ref="ClearFiltersAdminDataGridActionGroup" stepKey="clearFilter"/> + <actionGroup ref="AdminMediaGalleryOpenNewFolderFormActionGroup" stepKey="openNewFolderForm"/> + <actionGroup ref="AdminMediaGalleryCreateNewFolderActionGroup" stepKey="createCategoryImageFolder"> + <argument name="name" value="categoryImage"/> + </actionGroup> + <actionGroup ref="AdminMediaGalleryAssertFolderNameActionGroup" stepKey="assertCategoryImageFolderCreated"> + <argument name="name" value="categoryImage"/> + </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryUploadImageActionGroup" stepKey="uploadImage"> <argument name="image" value="ImageUpload"/> </actionGroup> @@ -52,6 +58,10 @@ <actionGroup ref="AdminMediaGalleryClickAddSelectedActionGroup" stepKey="clickAddSelectedCategoryImage"/> <actionGroup ref="AdminSaveCategoryActionGroup" stepKey="saveCategory"/> <actionGroup ref="AdminOpenMediaGalleryFromCategoryImageUploaderActionGroup" stepKey="openMediaGalleryFromImageUploaderToVerifyLink"/> + <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="selectCategoryImageFolder"> + <argument name="name" value="categoryImage"/> + </actionGroup> + <waitForLoadingMaskToDisappear stepKey="waitForLoadingMaskToDisappear"/> <actionGroup ref="AdminEnhancedMediaGalleryViewImageDetails" stepKey="openViewImageDetails"/> <actionGroup ref="AdminEnhancedMediaGalleryClickEntityUsedInActionGroup" stepKey="clickUsedInCategories"> <argument name="entityName" value="Categories"/> @@ -85,6 +95,9 @@ <deleteData createDataKey="category" stepKey="deleteCategory"/> <actionGroup ref="AdminOpenStandaloneMediaGalleryActionGroup" stepKey="openMediaGallery"/> + <actionGroup ref="AdminMediaGalleryFolderSelectActionGroup" stepKey="openCategoryImageFolder"> + <argument name="name" value="categoryImage"/> + </actionGroup> <actionGroup ref="AdminEnhancedMediaGalleryViewImageDetails" stepKey="openViewImageDetailsToVerifyEmptyUsedIn"/> <actionGroup ref="AssertAdminEnhancedMediaGalleryUsedInSectionNotDisplayedActionGroup" stepKey="assertThereIsNoUsedInSection"/> <actionGroup ref="AdminEnhancedMediaGalleryCloseViewDetailsActionGroup" stepKey="closeDetails"/> From ff12e395b639b2f3155efcd730c8c20fc9389b50 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky <engcom-vendorworker-foxtrot@adobe.com> Date: Tue, 8 Sep 2020 14:16:18 +0300 Subject: [PATCH 71/99] magento/magento2#25147: Totals Information Management - setting quote shipping method when address method is null - static test fix. --- app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php index 407d158e6f8d4..2e51bd8d75b89 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/OrderRepositoryTest.php @@ -72,7 +72,7 @@ class OrderRepositoryTest extends TestCase private $paymentAdditionalInfoFactory; /** - * @var OrderExtensionFactory|\PHPUnit_Framework_MockObject_MockObject + * @var OrderExtensionFactory|\MockObject */ private $orderExtensionFactoryMock; From 321a1365f7f45d0d71424c6dd1f4c58d1c3d26eb Mon Sep 17 00:00:00 2001 From: Roman Zhupanyn <roma.dj.elf@gmail.com> Date: Tue, 8 Sep 2020 14:48:38 +0300 Subject: [PATCH 72/99] MC-33493: Test render fields in composite configure block for simple and configurable product --- .../AbstractRenderCustomOptionsTest.php | 2 +- ...nd_store_with_second_currency_rollback.php | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php index 44c9ada3cacab..b575fc5e7033c 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/Options/AbstractRenderCustomOptionsTest.php @@ -373,7 +373,7 @@ protected function addOptionToProduct( */ protected function getOptionHtml(ProductInterface $product): string { - $this->page->addHandle($this->getHandlesList($product)); + $this->page->addHandle($this->getHandlesList()); $this->page->getLayout()->generateXml(); /** @var Options $optionsBlock */ $optionsBlock = $this->page->getLayout()->getBlock($this->getOptionsBlockName()); diff --git a/dev/tests/integration/testsuite/Magento/Store/_files/second_store_with_second_currency_rollback.php b/dev/tests/integration/testsuite/Magento/Store/_files/second_store_with_second_currency_rollback.php index 3151a76327397..547ce78500f49 100644 --- a/dev/tests/integration/testsuite/Magento/Store/_files/second_store_with_second_currency_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Store/_files/second_store_with_second_currency_rollback.php @@ -4,24 +4,35 @@ * See COPYING.txt for license details. */ declare(strict_types=1); + +use Magento\Config\Model\ResourceModel\Config; +use Magento\Directory\Model\Currency as ModelCurrency; +use Magento\Directory\Model\ResourceModel\Currency as ResourceCurrency; +use Magento\Store\Model\ScopeInterface; +use Magento\Store\Model\Store; +use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\Workaround\Override\Fixture\Resolver; -$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); -$store = $objectManager->create(\Magento\Store\Model\Store::class); +$objectManager = Bootstrap::getObjectManager(); +$store = $objectManager->create(Store::class); $storeId = $store->load('fixture_second_store', 'code')->getId(); if ($storeId) { - $configResource = $objectManager->get(\Magento\Config\Model\ResourceModel\Config::class); + $configResource = $objectManager->get(Config::class); $configResource->deleteConfig( - \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_DEFAULT, - \Magento\Store\Model\ScopeInterface::SCOPE_STORES, + ModelCurrency::XML_PATH_CURRENCY_DEFAULT, + ScopeInterface::SCOPE_STORES, $storeId ); $configResource->deleteConfig( - \Magento\Directory\Model\Currency::XML_PATH_CURRENCY_ALLOW, - \Magento\Store\Model\ScopeInterface::SCOPE_STORES, + ModelCurrency::XML_PATH_CURRENCY_ALLOW, + ScopeInterface::SCOPE_STORES, $storeId ); } Resolver::getInstance()->requireDataFixture('Magento/Store/_files/second_store_rollback.php'); +$reflectionClass = new \ReflectionClass(ResourceCurrency::class); +$staticProperty = $reflectionClass->getProperty('_rateCache'); +$staticProperty->setAccessible(true); +$staticProperty->setValue(null); From b0f065c9b978f4e6b4e5d61a852b0fa4eca9bd6f Mon Sep 17 00:00:00 2001 From: Buba Suma <soumah@adobe.com> Date: Mon, 10 Aug 2020 16:39:28 -0500 Subject: [PATCH 73/99] MC-35692: Admin Order place order spinner do not disappear - Fix unable to create order with zero subtotal and reward points in admin --- .../view/adminhtml/web/js/transparent.js | 15 +- .../adminhtml/web/order/create/scripts.js | 16 +- .../adminhtml/web/js/transparent.test.js | 84 ++++++ .../adminhtml/js/order/create/scripts.test.js | 260 ++++++++++++++++++ 4 files changed, 366 insertions(+), 9 deletions(-) create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Payment/adminhtml/web/js/transparent.test.js create mode 100644 dev/tests/js/jasmine/tests/app/code/Magento/Sales/adminhtml/js/order/create/scripts.test.js diff --git a/app/code/Magento/Payment/view/adminhtml/web/js/transparent.js b/app/code/Magento/Payment/view/adminhtml/web/js/transparent.js index 0ec866ee6a831..296d542f3adf6 100644 --- a/app/code/Magento/Payment/view/adminhtml/web/js/transparent.js +++ b/app/code/Magento/Payment/view/adminhtml/web/js/transparent.js @@ -52,28 +52,29 @@ define([ * @param {String} method */ _setPlaceOrderHandler: function (event, method) { + var $editForm = $(this.options.editFormSelector); + + $editForm.off('beforeSubmitOrder.' + this.options.gateway); + if (method === this.options.gateway) { - $(this.options.editFormSelector) - .off('submitOrder') - .on('submitOrder.' + this.options.gateway, this._placeOrderHandler.bind(this)); - } else { - $(this.options.editFormSelector) - .off('submitOrder.' + this.options.gateway); + $editForm.on('beforeSubmitOrder.' + this.options.gateway, this._placeOrderHandler.bind(this)); } }, /** * Handler for form submit to call gateway for credit card validation. * + * @param {Event} event * @return {Boolean} * @private */ - _placeOrderHandler: function () { + _placeOrderHandler: function (event) { if ($(this.options.editFormSelector).valid()) { this._orderSave(); } else { $('body').trigger('processStop'); } + event.stopImmediatePropagation(); return false; }, diff --git a/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js b/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js index bbdd6f8fe8437..a329524c58d41 100644 --- a/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js +++ b/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js @@ -481,6 +481,13 @@ define([ }, switchPaymentMethod: function(method){ + if (this.paymentMethod !== method) { + jQuery('#edit_form') + .off('submitOrder') + .on('submitOrder', function(){ + jQuery(this).trigger('realOrder'); + }); + } jQuery('#edit_form').trigger('changePaymentMethod', [method]); this.setPaymentMethod(method); var data = {}; @@ -1308,11 +1315,16 @@ define([ }, submit: function () { - var $editForm = jQuery('#edit_form'); + var $editForm = jQuery('#edit_form'), + beforeSubmitOrderEvent; if ($editForm.valid()) { $editForm.trigger('processStart'); - $editForm.trigger('submitOrder'); + beforeSubmitOrderEvent = jQuery.Event('beforeSubmitOrder'); + $editForm.trigger(beforeSubmitOrderEvent); + if (beforeSubmitOrderEvent.result !== false) { + $editForm.trigger('submitOrder'); + } } }, diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Payment/adminhtml/web/js/transparent.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Payment/adminhtml/web/js/transparent.test.js new file mode 100644 index 0000000000000..4902fbad26ff3 --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Payment/adminhtml/web/js/transparent.test.js @@ -0,0 +1,84 @@ +/* + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +/*eslint-disable max-nested-callbacks*/ +/*jscs:disable jsDoc*/ +define([ + 'jquery', + 'jquery/validate', + 'Magento_Payment/js/transparent' +], function ($) { + 'use strict'; + + var containerEl, + formEl, + jQueryAjax; + + function init(config) { + var defaultConfig = { + orderSaveUrl: '/', + gateway: 'payflowpro', + editFormSelector: '#' + formEl.id + }; + + $(formEl).find(':radio[value="payflowpro"]').prop('checked', 'checked'); + $(formEl).transparent($.extend({}, defaultConfig, config || {})); + } + + beforeEach(function () { + if (!window.FORM_KEY) { + window.FORM_KEY = '61d0c9da0aa473d214f61913967cc0ea'; + } + $('<div id="admin_edit_order_form_container">' + + '<form id="admin_edit_order_form" action="/">' + + '<input type="radio" name="payment[method]" value="payflowpro"/>' + + '<input type="radio" name="payment[method]" value="money_order"/>' + + '</form>' + + '</div>' + ).appendTo(document.body); + containerEl = document.getElementById('admin_edit_order_form_container'); + formEl = document.getElementById('admin_edit_order_form'); + jQueryAjax = $.ajax; + }); + + afterEach(function () { + $(containerEl).remove(); + formEl = undefined; + containerEl = undefined; + $.ajax = jQueryAjax; + jQueryAjax = undefined; + }); + + describe('Magento_Payment/js/transparent', function () { + describe('beforeSubmitOrder handler', function () { + it('is registered when selected payment method requires transparent', function () { + init(); + expect(($._data(formEl, 'events') || {}).beforeSubmitOrder[0].type).toBe('beforeSubmitOrder'); + expect(($._data(formEl, 'events') || {}).beforeSubmitOrder[0].namespace).toBe('payflowpro'); + }); + it('is not registered when selected payment method does not require transparent', function () { + init(); + $(formEl).find(':radio[value="money_order"]').prop('checked', 'checked'); + $(formEl).trigger('changePaymentMethod', ['money_order']); + expect(($._data(formEl, 'events') || {}).beforeSubmitOrder).toBeUndefined(); + }); + it('returns false to prevent normal order creation', function () { + var beforeSubmitOrderEvent; + + $.ajax = jasmine.createSpy(); + init({ + orderSaveUrl: '/admin/paypal/transparent/requestSecureToken' + }); + beforeSubmitOrderEvent = $.Event('beforeSubmitOrder'); + $(formEl).trigger(beforeSubmitOrderEvent); + expect($.ajax).toHaveBeenCalledWith(jasmine.objectContaining({ + url: '/admin/paypal/transparent/requestSecureToken', + type: 'post' + })); + expect(beforeSubmitOrderEvent.result).toBe(false); + expect(beforeSubmitOrderEvent.isImmediatePropagationStopped()).toBe(true); + }); + }); + }); +}); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Sales/adminhtml/js/order/create/scripts.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Sales/adminhtml/js/order/create/scripts.test.js new file mode 100644 index 0000000000000..0071d5af7df4e --- /dev/null +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Sales/adminhtml/js/order/create/scripts.test.js @@ -0,0 +1,260 @@ +/* + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +/*eslint-disable max-nested-callbacks*/ +/*jscs:disable jsDoc*/ +define([ + 'jquery', + 'squire', + 'jquery/validate' +], function ($, Squire) { + 'use strict'; + + var formEl, + jQueryAjax, + order, + tmpl = '<form id="edit_form" action="/">' + + '<section id="order-methods">' + + '<div id="order-billing_method"></div>' + + '<div id="order-shipping_method"></div>' + + '</section>' + + '<div id="order-billing_method_form">' + + '<input id="p_method_payment1" type="radio" name="payment[method]" value="payment1"/>' + + '<fieldset id="payment_form_payment1">' + + '<input type="number" name="payment[cc_number]"/>' + + '<input type="number" name="payment[cc_cid]"/>' + + '</fieldset>' + + '<input id="p_method_payment2" type="radio" name="payment[method]" value="payment2"/>' + + '<fieldset id="payment_form_payment2">' + + '<input type="number" name="payment[cc_number]"/>' + + '<input type="number" name="payment[cc_cid]"/>' + + '</fieldset>' + + '<input id="p_method_free" type="radio" name="payment[method]" value="free"/>' + + '</div>' + + '</form>'; + + $.widget('magetest.testPaymentMethodA', { + options: { + code: null, + orderSaveUrl: null, + orderFormSelector: null + }, + + _create: function () { + var $editForm = $(this.options.orderFormSelector); + + $editForm.off('changePaymentMethod.' + this.options.code) + .on('changePaymentMethod.' + this.options.code, this._onChangePaymentMethod.bind(this)); + }, + + _onChangePaymentMethod: function (event, method) { + var $editForm = $(this.options.orderFormSelector); + + $editForm.off('beforeSubmitOrder.' + this.options.code); + + if (method === this.options.code) { + $editForm.on('beforeSubmitOrder.' + this.options.code, this._submitOrder.bind(this)); + } + }, + + _submitOrder: function (event) { + $.ajax({ + url: this.options.orderSaveUrl, + type: 'POST', + context: this, + data: { + code: this.options.code + }, + dataType: 'JSON' + }); + event.stopImmediatePropagation(); + + return false; + } + + }); + + $.widget('magetest.testPaymentMethodB', $.magetest.testPaymentMethodA, { + isActive: false, + _onChangePaymentMethod: function (event, method) { + var $editForm = $(this.options.orderFormSelector), + isActive = method === this.options.code; + + if (this.isActive !== isActive) { + this.isActive = isActive; + + if (!isActive) { + $editForm.off('submitOrder.' + this.options.code); + } else { + $editForm.off('submitOrder') + .on('submitOrder.' + this.options.code, this._submitOrder.bind(this)); + } + } + } + }); + + function init(config) { + config = config || {}; + order = new window.AdminOrder({}); + $(formEl).validate({}); + $(formEl).find(':radio[value="payment1"]').testPaymentMethodA({ + code: 'payment1', + orderSaveUrl: '/admin/sales/order/create/payment_method/payment1', + orderFormSelector: '#' + formEl.id + }); + $(formEl).find(':radio[value="payment2"]').testPaymentMethodB({ + code: 'payment2', + orderSaveUrl: '/admin/sales/order/create/payment_method/payment2', + orderFormSelector: '#' + formEl.id + }); + $(formEl).off('realOrder').on('realOrder', function () { + $.ajax({ + url: '/admin/sales/order/create', + type: 'POST', + context: this, + data: $(this).serializeArray(), + dataType: 'JSON' + }); + }); + + if (config.method) { + $(formEl).find(':radio[value="' + config.method + '"]').prop('checked', true); + order.switchPaymentMethod(config.method); + } + } + + describe('Magento_Sales/order/create/scripts', function () { + var injector = new Squire(), + mocks = { + 'jquery': $, + 'Magento_Catalog/catalog/product/composite/configure': jasmine.createSpy(), + 'Magento_Ui/js/modal/confirm': jasmine.createSpy(), + 'Magento_Ui/js/modal/alert': jasmine.createSpy(), + 'Magento_Ui/js/lib/view/utils/async': jasmine.createSpy() + }; + + beforeEach(function (done) { + jQueryAjax = $.ajax; + injector.mock(mocks); + injector.require(['Magento_Sales/order/create/scripts'], function () { + window.FORM_KEY = window.FORM_KEY || '61d0c9da0aa473d214f61913967cc0ea'; + $(tmpl).appendTo(document.body); + formEl = document.getElementById('edit_form'); + $(formEl).off(); + done(); + }); + }); + + afterEach(function () { + try { + injector.clean(); + injector.remove(); + } catch (e) { + } + $(formEl).off().remove(); + formEl = undefined; + order = undefined; + $.ajax = jQueryAjax; + jQueryAjax = undefined; + }); + + describe('submit()', function () { + function testSubmit(currentPaymentMethod, paymentMethod, ajaxParams) { + $.ajax = jasmine.createSpy('$.ajax'); + init({ + method: currentPaymentMethod + }); + $(formEl).find(':radio[value="' + paymentMethod + '"]').prop('checked', true); + order.switchPaymentMethod(paymentMethod); + order.submit(); + expect($.ajax).toHaveBeenCalledTimes(1); + expect($.ajax).toHaveBeenCalledWith(jasmine.objectContaining(ajaxParams)); + } + + it('Check that payment custom handler is executed #1', function () { + testSubmit( + null, + 'payment1', + { + url: '/admin/sales/order/create/payment_method/payment1', + data: { + code: 'payment1' + } + } + ); + }); + + it('Check that payment custom handler is executed #2', function () { + testSubmit( + 'payment1', + 'payment1', + { + url: '/admin/sales/order/create/payment_method/payment1', + data: { + code: 'payment1' + } + } + ); + }); + + it('Check that payment custom handler is executed #3', function () { + testSubmit( + null, + 'payment2', + { + url: '/admin/sales/order/create/payment_method/payment2', + data: { + code: 'payment2' + } + } + ); + }); + + it('Check that payment custom handler is executed #4', function () { + testSubmit( + 'payment2', + 'payment2', + { + url: '/admin/sales/order/create/payment_method/payment2', + data: { + code: 'payment2' + } + } + ); + }); + + it('Check that native handler is executed for payment without custom handler #1', function () { + testSubmit( + 'payment1', + 'free', + { + url: '/admin/sales/order/create', + data: [ + { + name: 'payment[method]', + value: 'free' + } + ] + } + ); + }); + + it('Check that native handler is executed for payment without custom handler #2', function () { + testSubmit( + 'payment2', + 'free', + { + url: '/admin/sales/order/create', + data: [ + { + name: 'payment[method]', + value: 'free' + } + ] + } + ); + }); + }); + }); +}); From 5ab1f14706e098548eb71d9a1b09de25b2cf8aba Mon Sep 17 00:00:00 2001 From: Victor Rad <vrad@magento.com> Date: Tue, 8 Sep 2020 11:12:02 -0500 Subject: [PATCH 74/99] MC-37321: Quote customer_is_guest = false --- app/code/Magento/Quote/Model/QuoteManagement.php | 1 + .../Magento/GraphQl/Quote/Guest/CreateEmptyCartTest.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php index 3a81341e2b02a..c9c814fcaf52a 100644 --- a/app/code/Magento/Quote/Model/QuoteManagement.php +++ b/app/code/Magento/Quote/Model/QuoteManagement.php @@ -250,6 +250,7 @@ public function createEmptyCart() $quote->setBillingAddress($this->quoteAddressFactory->create()); $quote->setShippingAddress($this->quoteAddressFactory->create()); + $quote->setCustomerIsGuest(true); try { $quote->getShippingAddress()->setCollectShippingRates(true); diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CreateEmptyCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CreateEmptyCartTest.php index be183fe93815a..6f8d45aca5be4 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CreateEmptyCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CreateEmptyCartTest.php @@ -61,6 +61,7 @@ public function testCreateEmptyCart() self::assertNotNull($guestCart->getId()); self::assertNull($guestCart->getCustomer()->getId()); self::assertEquals('default', $guestCart->getStore()->getCode()); + self::assertTrue($guestCart->getCustomerIsGuest()); } /** @@ -81,6 +82,7 @@ public function testCreateEmptyCartWithNotDefaultStore() self::assertNotNull($guestCart->getId()); self::assertNull($guestCart->getCustomer()->getId()); self::assertSame('fixture_second_store', $guestCart->getStore()->getCode()); + self::assertTrue($guestCart->getCustomerIsGuest()); } /** From 03db1d60e9ea46144d06899745cb0a44bbb5626d Mon Sep 17 00:00:00 2001 From: Victor Rad <vrad@magento.com> Date: Tue, 8 Sep 2020 11:13:39 -0500 Subject: [PATCH 75/99] MC-37321: Quote customer_is_guest = false --- app/code/Magento/Checkout/Model/Session.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/Model/Session.php b/app/code/Magento/Checkout/Model/Session.php index 8ba6af2518057..22135e5528f97 100644 --- a/app/code/Magento/Checkout/Model/Session.php +++ b/app/code/Magento/Checkout/Model/Session.php @@ -383,7 +383,8 @@ public function loadCustomerQuote() if ($customerQuote->getId() && $this->getQuoteId() != $customerQuote->getId()) { if ($this->getQuoteId()) { - $quote = $this->getQuote()->setCustomerIsGuest(false); + $quote = $this->getQuote(); + $quote->setCustomerIsGuest(false); $this->quoteRepository->save( $customerQuote->merge($quote)->collectTotals() ); From 4ecc5d2eb3b55c61fd4f013579da0232a79bd900 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov <oiegorov@adobe.com> Date: Tue, 8 Sep 2020 13:05:38 -0500 Subject: [PATCH 76/99] MC-36942: HTML minification strips triple slashes from html string in phtml --- .../Magento/Framework/View/Template/Html/Minifier.php | 2 +- .../Framework/View/Test/Unit/Template/Html/MinifierTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/View/Template/Html/Minifier.php b/lib/internal/Magento/Framework/View/Template/Html/Minifier.php index dba81a1547c44..c6ac7917871b0 100644 --- a/lib/internal/Magento/Framework/View/Template/Html/Minifier.php +++ b/lib/internal/Magento/Framework/View/Template/Html/Minifier.php @@ -144,7 +144,7 @@ function ($match) use (&$heredocs) { '#(?<!:|\\\\|\'|"|/)//(?!/)(?!\s*\<\!\[)(?!\s*]]\>)[^\n\r]*#', '', preg_replace( - '#(?<!:|\'|")//[^\n\r\<\?]*(\?\>)#', + '#(?<!:|\'|")//[^\n\r\<]*(\?\>)#', ' $1', preg_replace( '#(?<!:)//[^\n\r]*(\<\?php)[^\n\r]*(\s\?\>)[^\n\r]*#', diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php index 3b13a2f723617..bb6edcd3fa0ff 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php @@ -139,7 +139,7 @@ public function testMinify() <body> <a href="http://somelink.com/text.html">Text Link</a> <img src="test.png" alt="some text" /> - <?php echo \$block->someMethod(); ?> + <img src="data:image/gif;base64,P///yH5BAEAAAA" data-component="main-image"><?= \$block->someMethod(); ?> <div style="width: 800px" class="<?php echo \$block->getClass() ?>" /> <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-component="main-image"> <script> @@ -182,7 +182,7 @@ public function testMinify() TEXT; $expectedContent = <<<TEXT -<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ ?> <?php ?> <html><head><title>Test titleText Link some textsomeMethod(); ?>