diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/Save.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/Save.php index b67f1f23f16ba..8845042cb8b0a 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/Save.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/Save.php @@ -7,6 +7,9 @@ namespace Magento\Backend\Controller\Adminhtml\System\Store; use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; +use Magento\Store\Model\Group as StoreGroup; +use Magento\Store\Model\Store; +use Magento\Framework\Exception\LocalizedException; /** * Class Save @@ -33,6 +36,17 @@ private function processWebsiteSave($postData) $websiteModel->setId(null); } + $groupModel = $this->_objectManager->create(StoreGroup::class); + $groupModel->load($websiteModel->getDefaultGroupId()); + $storeModel = $this->_objectManager->create(Store::class); + $storeModel->load($groupModel->getDefaultStoreId()); + + if ($websiteModel->getIsDefault() && !$storeModel->isActive()) { + throw new LocalizedException( + __('Please enable your Store View before using this Web Site as Default') + ); + } + $websiteModel->save(); $this->messageManager->addSuccessMessage(__('You saved the website.')); @@ -43,13 +57,13 @@ private function processWebsiteSave($postData) * Process Store model save * * @param array $postData - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException * @return array */ private function processStoreSave($postData) { - /** @var \Magento\Store\Model\Store $storeModel */ - $storeModel = $this->_objectManager->create(\Magento\Store\Model\Store::class); + /** @var Store $storeModel */ + $storeModel = $this->_objectManager->create(Store::class); $postData['store']['name'] = $this->filterManager->removeTags($postData['store']['name']); if ($postData['store']['store_id']) { $storeModel->load($postData['store']['store_id']); @@ -59,13 +73,13 @@ private function processStoreSave($postData) $storeModel->setId(null); } $groupModel = $this->_objectManager->create( - \Magento\Store\Model\Group::class + StoreGroup::class )->load( $storeModel->getGroupId() ); $storeModel->setWebsiteId($groupModel->getWebsiteId()); if (!$storeModel->isActive() && $storeModel->isDefault()) { - throw new \Magento\Framework\Exception\LocalizedException( + throw new LocalizedException( __('The default store cannot be disabled') ); } @@ -79,14 +93,14 @@ private function processStoreSave($postData) * Process StoreGroup model save * * @param array $postData - * @throws \Magento\Framework\Exception\LocalizedException + * @throws LocalizedException * @return array */ private function processGroupSave($postData) { $postData['group']['name'] = $this->filterManager->removeTags($postData['group']['name']); - /** @var \Magento\Store\Model\Group $groupModel */ - $groupModel = $this->_objectManager->create(\Magento\Store\Model\Group::class); + /** @var StoreGroup $groupModel */ + $groupModel = $this->_objectManager->create(StoreGroup::class); if ($postData['group']['group_id']) { $groupModel->load($postData['group']['group_id']); } @@ -95,10 +109,11 @@ private function processGroupSave($postData) $groupModel->setId(null); } if (!$this->isSelectedDefaultStoreActive($postData, $groupModel)) { - throw new \Magento\Framework\Exception\LocalizedException( + throw new LocalizedException( __('An inactive store view cannot be saved as default store view') ); } + $groupModel->save(); $this->messageManager->addSuccessMessage(__('You saved the store.')); @@ -135,7 +150,7 @@ public function execute() } $redirectResult->setPath('adminhtml/*/'); return $redirectResult; - } catch (\Magento\Framework\Exception\LocalizedException $e) { + } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); $this->_getSession()->setPostData($postData); } catch (\Exception $e) { @@ -156,10 +171,10 @@ public function execute() * Verify if selected default store is active * * @param array $postData - * @param \Magento\Store\Model\Group $groupModel + * @param StoreGroup $groupModel * @return bool */ - private function isSelectedDefaultStoreActive(array $postData, \Magento\Store\Model\Group $groupModel) + private function isSelectedDefaultStoreActive(array $postData, StoreGroup $groupModel) { if (!empty($postData['group']['default_store_id'])) { $defaultStoreId = $postData['group']['default_store_id']; diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AdminClearGridFiltersActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AdminClearGridFiltersActionGroup.xml new file mode 100644 index 0000000000000..b5ae4d1eca59a --- /dev/null +++ b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AdminClearGridFiltersActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + Click the Clear filters on the grid. + + + + + + diff --git a/app/code/Magento/Backend/i18n/en_US.csv b/app/code/Magento/Backend/i18n/en_US.csv index 74633141c89fe..d5870de8b7132 100644 --- a/app/code/Magento/Backend/i18n/en_US.csv +++ b/app/code/Magento/Backend/i18n/en_US.csv @@ -198,6 +198,7 @@ System,System "All Stores","All Stores" "You saved the website.","You saved the website." "The default store cannot be disabled","The default store cannot be disabled" +"Please enable your Store View before using this Web Site as Default","Please enable your Store View before using this Web Site as Default" "You saved the store view.","You saved the store view." "An inactive store view cannot be saved as default store view","An inactive store view cannot be saved as default store view" "You saved the store.","You saved the store." diff --git a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php index 2e9b8ba413af3..635811e3d0f81 100644 --- a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php +++ b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php @@ -184,10 +184,6 @@ public function getJsonConfig() $configValue = $preConfiguredValues->getData('bundle_option/' . $optionId); if ($configValue) { $defaultValues[$optionId] = $configValue; - $configQty = $preConfiguredValues->getData('bundle_option_qty/' . $optionId); - if ($configQty) { - $options[$optionId]['selections'][$configValue]['qty'] = $configQty; - } } $options = $this->processOptions($optionId, $options, $preConfiguredValues); } diff --git a/app/code/Magento/Bundle/Model/CartItemProcessor.php b/app/code/Magento/Bundle/Model/CartItemProcessor.php index dc51f3e3969b4..e5c6990574f01 100644 --- a/app/code/Magento/Bundle/Model/CartItemProcessor.php +++ b/app/code/Magento/Bundle/Model/CartItemProcessor.php @@ -51,7 +51,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritDoc */ public function convertToBuyRequest(CartItemInterface $cartItem) { @@ -73,7 +73,7 @@ public function convertToBuyRequest(CartItemInterface $cartItem) } /** - * {@inheritdoc} + * @inheritDoc * @SuppressWarnings(PHPMD.NPathComplexity) */ public function processOptions(CartItemInterface $cartItem) @@ -84,19 +84,21 @@ public function processOptions(CartItemInterface $cartItem) $productOptions = []; $bundleOptions = $cartItem->getBuyRequest()->getBundleOption(); $bundleOptionsQty = $cartItem->getBuyRequest()->getBundleOptionQty(); + $bundleOptionsQty = is_array($bundleOptionsQty) ? $bundleOptionsQty : []; if (is_array($bundleOptions)) { foreach ($bundleOptions as $optionId => $optionSelections) { if (empty($optionSelections)) { continue; } $optionSelections = is_array($optionSelections) ? $optionSelections : [$optionSelections]; - $optionQty = isset($bundleOptionsQty[$optionId]) ? $bundleOptionsQty[$optionId] : 1; /** @var \Magento\Bundle\Api\Data\BundleOptionInterface $productOption */ $productOption = $this->bundleOptionFactory->create(); $productOption->setOptionId($optionId); $productOption->setOptionSelections($optionSelections); - $productOption->setOptionQty($optionQty); + if (isset($bundleOptionsQty[$optionId])) { + $productOption->setOptionQty($bundleOptionsQty[$optionId]); + } $productOptions[] = $productOption; } diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php index c929c04ee83f0..9f3d4a908f062 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php @@ -214,6 +214,8 @@ public function testGetJsonConfigFixedPriceBundleNoOption() public function testGetJsonConfigFixedPriceBundle() { + $optionId = 1; + $optionQty = 2; $baseAmount = 123; $basePriceValue = 123123; $selections = [ @@ -230,7 +232,6 @@ public function testGetJsonConfigFixedPriceBundle() true ) ]; - $bundleProductPrice = $this->getMockBuilder(Price::class) ->disableOriginalConstructor() ->setMethods(['getLowestPrice']) @@ -246,10 +247,8 @@ public function testGetJsonConfigFixedPriceBundle() $this->bundleProductPriceFactory->expects($this->once()) ->method('create') ->willReturn($bundleProductPrice); + $options = [$this->createOption($optionId, 'Title `1', $selections)]; - $options = [ - $this->createOption(1, 'Title `1', $selections), - ]; $finalPriceMock = $this->getPriceMock( [ 'getPriceWithoutOption' => new DataObject( @@ -289,7 +288,10 @@ public function testGetJsonConfigFixedPriceBundle() $preconfiguredValues = new DataObject( [ 'bundle_option' => [ - 1 => 123123111, + $optionId => [123123111], + ], + 'bundle_option_qty' => [ + $optionId => $optionQty, ], ] ); @@ -306,7 +308,8 @@ public function testGetJsonConfigFixedPriceBundle() $this->assertEquals(110, $jsonConfig['prices']['oldPrice']['amount']); $this->assertEquals(100, $jsonConfig['prices']['basePrice']['amount']); $this->assertEquals(100, $jsonConfig['prices']['finalPrice']['amount']); - $this->assertEquals([1], $jsonConfig['positions']); + $this->assertEquals([$optionId], $jsonConfig['positions']); + $this->assertEquals($optionQty, $jsonConfig['options'][$optionId]['selections'][1123]['qty']); } /** diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php index b7041051591d8..9c4d4ce00b7c0 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php @@ -11,7 +11,6 @@ use Magento\Bundle\Model\Product\Type; use Magento\Bundle\Model\ResourceModel\BundleFactory; use Magento\Bundle\Model\ResourceModel\Option\Collection; -use Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor; use Magento\Bundle\Model\ResourceModel\Selection\Collection as SelectionCollection; use Magento\Bundle\Model\ResourceModel\Selection\CollectionFactory; use Magento\Bundle\Model\Selection; @@ -28,6 +27,7 @@ use Magento\CatalogInventory\Api\StockStateInterface; use Magento\CatalogInventory\Model\StockRegistry; use Magento\CatalogInventory\Model\StockState; +use Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor; use Magento\Framework\DataObject; use Magento\Framework\EntityManager\EntityMetadataInterface; use Magento\Framework\EntityManager\MetadataPool; @@ -1548,6 +1548,10 @@ public function testPrepareForCartAdvancedSpecifyProductOptions() ->disableOriginalConstructor() ->getMock(); + $buyRequest->method('getOptions') + ->willReturn([333 => ['type' => 'image/jpeg']]); + $option->method('getId') + ->willReturn(333); $this->parentClass($group, $option, $buyRequest, $product); $product->expects($this->any()) @@ -1556,6 +1560,8 @@ public function testPrepareForCartAdvancedSpecifyProductOptions() $buyRequest->expects($this->once()) ->method('getBundleOption') ->willReturn([0, '', 'str']); + $group->expects($this->once()) + ->method('validateUserValue'); $result = $this->model->prepareForCartAdvanced($buyRequest, $product); $this->assertEquals('Please specify product option(s).', $result); diff --git a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php index f90b097415661..19f6461d44b6a 100644 --- a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php +++ b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php @@ -3,7 +3,6 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -declare(strict_types=1); namespace Magento\Catalog\Model\Product\Type; @@ -605,7 +604,11 @@ protected function _prepareOptions(\Magento\Framework\DataObject $buyRequest, $p if ($product->getSkipCheckRequiredOption() !== true) { $group->validateUserValue($optionsFromRequest); } elseif ($optionsFromRequest !== null && isset($optionsFromRequest[$option->getId()])) { - $transport->options[$option->getId()] = $optionsFromRequest[$option->getId()]; + if (is_array($optionsFromRequest[$option->getId()])) { + $group->validateUserValue($optionsFromRequest); + } else { + $transport->options[$option->getId()] = $optionsFromRequest[$option->getId()]; + } } } catch (LocalizedException $e) { diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminChangeWebSiteAssignedToProductActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminChangeWebSiteAssignedToProductActionGroup.xml new file mode 100644 index 0000000000000..76a0af8f63fd5 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminChangeWebSiteAssignedToProductActionGroup.xml @@ -0,0 +1,21 @@ + + + + + + + Extends AddWebsiteToProductActionGroup. Changes website assigned to product from websiteToDeselect to website + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCheckProductOnProductGridActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCheckProductOnProductGridActionGroup.xml index 64fab5575e392..8cb737f50c620 100644 --- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCheckProductOnProductGridActionGroup.xml +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCheckProductOnProductGridActionGroup.xml @@ -1,22 +1,21 @@ - - + + - - - - Check the checkbox for the product on the Product Grid - - - - + + + + Check the checkbox for the product on the Product Grid + + + + - + - - + + diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSetPriceForMassUpdateActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSetPriceForMassUpdateActionGroup.xml new file mode 100644 index 0000000000000..b00f181c92360 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSetPriceForMassUpdateActionGroup.xml @@ -0,0 +1,24 @@ + + + + + + + Click the "Change" checkbox for the "Price" field. Set new price. + + + + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSortProductsGridByActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSortProductsGridByActionGroup.xml new file mode 100644 index 0000000000000..92c714c2478b0 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSortProductsGridByActionGroup.xml @@ -0,0 +1,22 @@ + + + + + + + Sorts the Product Grid by field + + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminProductPriceUpdatedOnEditPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminProductPriceUpdatedOnEditPageActionGroup.xml new file mode 100644 index 0000000000000..c7a665119b328 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminProductPriceUpdatedOnEditPageActionGroup.xml @@ -0,0 +1,25 @@ + + + + + + + Validate if Product price is updated on the Product creation/edit page + + + + + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml index 995fa4c7e5977..e1499a2484353 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml @@ -56,7 +56,7 @@ - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml index 94d3b46aaa5f1..73019bb5ec0e0 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminAddInStockProductToTheCartTest.xml @@ -58,10 +58,7 @@ - - - - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckCustomAttributeValuesAfterProductSaveTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckCustomAttributeValuesAfterProductSaveTest.xml index 0bdf19c9b8950..ca0616213c593 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckCustomAttributeValuesAfterProductSaveTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckCustomAttributeValuesAfterProductSaveTest.xml @@ -33,9 +33,7 @@ - - - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassProductPriceUpdateTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassProductPriceUpdateTest.xml index 070c07d9feb7d..8a5da6d6e3640 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassProductPriceUpdateTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassProductPriceUpdateTest.xml @@ -29,52 +29,60 @@ - - - - - + - - - - + + + + + + + + + + - - - - - - - - - - + + + + + + + + + - - + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminRequiredFieldsHaveRequiredFieldIndicatorTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminRequiredFieldsHaveRequiredFieldIndicatorTest.xml index dfe83338c7b6f..b2ed7b9628f38 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminRequiredFieldsHaveRequiredFieldIndicatorTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminRequiredFieldsHaveRequiredFieldIndicatorTest.xml @@ -60,7 +60,7 @@ - + pageTitleRequiredFieldIndicator diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminSimpleProductImagesTest/AdminSimpleProductImagesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminSimpleProductImagesTest/AdminSimpleProductImagesTest.xml index de116b26d1414..8a33f6132aeb9 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminSimpleProductImagesTest/AdminSimpleProductImagesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminSimpleProductImagesTest/AdminSimpleProductImagesTest.xml @@ -141,9 +141,7 @@ - - - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminSortingByWebsitesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminSortingByWebsitesTest.xml index f5046faf82b6f..a9f8eab9a582f 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminSortingByWebsitesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminSortingByWebsitesTest.xml @@ -25,7 +25,7 @@ - + @@ -52,31 +52,30 @@ - - - - + + - - - - - - - - + + + + + + + + + + - - - - + + + - - - + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryNameAndDescriptionTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryNameAndDescriptionTest.xml index 27a834833ed76..2124efed31293 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryNameAndDescriptionTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateFlatCategoryNameAndDescriptionTest.xml @@ -34,10 +34,7 @@ - - - - + @@ -45,9 +42,7 @@ - - - + @@ -71,7 +66,7 @@ - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductTieredPriceTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductTieredPriceTest.xml index 53d9beb6169ee..420a0604f0382 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductTieredPriceTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductTieredPriceTest.xml @@ -26,10 +26,7 @@ - - - - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogAndSearchTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogAndSearchTest.xml index c5f6e70be046c..9cb326ca6d804 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogAndSearchTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogAndSearchTest.xml @@ -95,10 +95,7 @@ - - - - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogOnlyTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogOnlyTest.xml index c3f7240537293..38c0a7449210c 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogOnlyTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateSimpleProductWithRegularPriceInStockVisibleInCatalogOnlyTest.xml @@ -95,10 +95,7 @@ - - - - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithNoRedirectTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithNoRedirectTest.xml index 616c38e326a62..92fd18cc24c31 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithNoRedirectTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithNoRedirectTest.xml @@ -79,8 +79,8 @@ - - + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithRedirectTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithRedirectTest.xml index 9d4bc5f184c9c..f88636fa767e8 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithRedirectTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminUpdateTopCategoryUrlWithRedirectTest.xml @@ -77,8 +77,8 @@ - - + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/CheckTierPricingOfProductsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/CheckTierPricingOfProductsTest.xml index 5f7e9c4225c00..2095d56ce6c59 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/CheckTierPricingOfProductsTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/CheckTierPricingOfProductsTest.xml @@ -332,10 +332,7 @@ - - - - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserTest.xml index ff68bba78cae8..aed2976df8f73 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CGuestUserTest/EndToEndB2CGuestUserTest.xml @@ -56,10 +56,7 @@ - - - - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml index 7fd752d7df98d..654dc727b24ca 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/ProductAvailableAfterEnablingSubCategoriesTest.xml @@ -50,7 +50,7 @@ - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontProductsDisplayUsingElasticSearchTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontProductsDisplayUsingElasticSearchTest.xml index cde7b14614f8e..3d3867d1efcf1 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontProductsDisplayUsingElasticSearchTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontProductsDisplayUsingElasticSearchTest.xml @@ -114,9 +114,7 @@ - - - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreLevelTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreLevelTest.xml index e1b5aca6382e9..64ad348257853 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreLevelTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreLevelTest.xml @@ -74,9 +74,7 @@ - - - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml index 0117493906de1..4d04a25c8d12f 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StoreFrontRecentlyViewedAtStoreViewLevelTest.xml @@ -66,9 +66,7 @@ - - - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckDefaultNumberProductsToDisplayTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckDefaultNumberProductsToDisplayTest.xml index a73bd5a533ad0..ca561e4af70de 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckDefaultNumberProductsToDisplayTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCheckDefaultNumberProductsToDisplayTest.xml @@ -187,10 +187,7 @@ - - - - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontProductNameWithDoubleQuoteTest/StorefrontProductNameWithHTMLEntitiesTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontProductNameWithDoubleQuoteTest/StorefrontProductNameWithHTMLEntitiesTest.xml index 2156178ea88d0..9819357704d44 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontProductNameWithDoubleQuoteTest/StorefrontProductNameWithHTMLEntitiesTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontProductNameWithDoubleQuoteTest/StorefrontProductNameWithHTMLEntitiesTest.xml @@ -33,9 +33,7 @@ - - - + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/VerifyCategoryProductAndProductCategoryPartialReindexTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/VerifyCategoryProductAndProductCategoryPartialReindexTest.xml index ce04b377300f8..cf1bb065349b6 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/VerifyCategoryProductAndProductCategoryPartialReindexTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/VerifyCategoryProductAndProductCategoryPartialReindexTest.xml @@ -65,9 +65,7 @@ - - - + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogPriceRuleByProductAttributeTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogPriceRuleByProductAttributeTest.xml index 547ef356f099d..724664917fecc 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogPriceRuleByProductAttributeTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogPriceRuleByProductAttributeTest.xml @@ -154,10 +154,7 @@ - - - - + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogRuleByCategoryTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogRuleByCategoryTest.xml index e6b825ff3cf70..3109c56122d1b 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogRuleByCategoryTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogRuleByCategoryTest.xml @@ -77,9 +77,7 @@ - - - + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithSpecialPricesTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithSpecialPricesTest.xml index 1de036d1026dd..97e93c8f762c5 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithSpecialPricesTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminApplyCatalogRuleForConfigurableProductWithSpecialPricesTest.xml @@ -126,10 +126,7 @@ - - - - + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleByPercentTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleByPercentTest.xml index d45c3af1c2da0..946a25d721cba 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleByPercentTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleByPercentTest.xml @@ -24,10 +24,7 @@ - - - - + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleForCustomerGroupTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleForCustomerGroupTest.xml index 3c08fbdf641e4..e55cabd506466 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleForCustomerGroupTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest/AdminCreateCatalogPriceRuleForCustomerGroupTest.xml @@ -48,10 +48,7 @@ - - - - + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromConfigurableProductTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromConfigurableProductTest.xml index 7247d61bea87c..831470e0d64ca 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromConfigurableProductTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromConfigurableProductTest.xml @@ -71,10 +71,7 @@ - - - - + @@ -117,10 +114,7 @@ - - - - + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromSimpleProductTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromSimpleProductTest.xml index a3b1729102390..5a62b1a373f94 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromSimpleProductTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest/AdminDeleteCatalogPriceRuleEntityFromSimpleProductTest.xml @@ -59,10 +59,7 @@ - - - - + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml index 64fe4d8a130a7..d03ca6b22d66a 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml @@ -84,7 +84,7 @@ - + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminEnableAttributeIsUndefinedCatalogPriceRuleTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminEnableAttributeIsUndefinedCatalogPriceRuleTest.xml index 745025073dceb..da62981c99202 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminEnableAttributeIsUndefinedCatalogPriceRuleTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminEnableAttributeIsUndefinedCatalogPriceRuleTest.xml @@ -79,9 +79,7 @@ - - - + @@ -129,9 +127,7 @@ - - - + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogRuleForSimpleAndConfigurableProductTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogRuleForSimpleAndConfigurableProductTest.xml index 1651f8425ec1c..c3690e72e084f 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogRuleForSimpleAndConfigurableProductTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogRuleForSimpleAndConfigurableProductTest.xml @@ -112,9 +112,7 @@ - - - + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogRuleForSimpleProductForNewCustomerGroupTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogRuleForSimpleProductForNewCustomerGroupTest.xml index a40bf63c5a388..3b7c9c181f1b1 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogRuleForSimpleProductForNewCustomerGroupTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogRuleForSimpleProductForNewCustomerGroupTest.xml @@ -71,9 +71,7 @@ - - - + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/CatalogPriceRuleAndCustomerGroupMembershipArePersistedUnderLongTermCookieTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/CatalogPriceRuleAndCustomerGroupMembershipArePersistedUnderLongTermCookieTest.xml index b678e379a603d..702e046272cb4 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/CatalogPriceRuleAndCustomerGroupMembershipArePersistedUnderLongTermCookieTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/CatalogPriceRuleAndCustomerGroupMembershipArePersistedUnderLongTermCookieTest.xml @@ -40,10 +40,7 @@ - - - - + diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/StorefrontInactiveCatalogRuleTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/StorefrontInactiveCatalogRuleTest.xml index bebf6ce5302d6..6a09f870705d2 100644 --- a/app/code/Magento/CatalogRule/Test/Mftf/Test/StorefrontInactiveCatalogRuleTest.xml +++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/StorefrontInactiveCatalogRuleTest.xml @@ -33,10 +33,7 @@ - - - - + diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontCartDiscountActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontCartDiscountActionGroup.xml new file mode 100644 index 0000000000000..ed34b460d6158 --- /dev/null +++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontCartDiscountActionGroup.xml @@ -0,0 +1,21 @@ + + + + + + + Assert that the provided Discount is present in the Storefront Shopping Cart. + + + + + + + + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleDynamicProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleDynamicProductFromShoppingCartTest.xml index 96a236336993f..a30f118bd6207 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleDynamicProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleDynamicProductFromShoppingCartTest.xml @@ -56,7 +56,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleFixedProductFromShoppingCartTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleFixedProductFromShoppingCartTest.xml index b64b59ef6109c..d1f452896c84f 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleFixedProductFromShoppingCartTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/DeleteBundleFixedProductFromShoppingCartTest.xml @@ -48,7 +48,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml index 38e2203b45258..73a2e4757e954 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/OnePageCheckoutWithAllProductTypesTest.xml @@ -159,7 +159,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutDisabledBundleProductTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutDisabledBundleProductTest.xml index f16f577a4088c..3aa93d72571f9 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutDisabledBundleProductTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckoutDisabledBundleProductTest.xml @@ -59,7 +59,7 @@ - + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml index c58e4ab7513af..f81ee2fc19d5b 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutWithCouponAndZeroSubtotalTest.xml @@ -47,8 +47,10 @@ - - + + + + diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml index a8b8cf66f545b..43dd3ead0160c 100644 --- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml +++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontUKCustomerCheckoutWithCouponTest.xml @@ -75,8 +75,10 @@ - - + + + + diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/item/default.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/item/default.phtml index 0267f68c5f81d..c3bddbac56487 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/item/default.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/cart/item/default.phtml @@ -48,8 +48,8 @@ $canApplyMsrp = $helper->isShowBeforeOrderConfirm($product) && $helper->isMinima
escapeHtml($_option['label']) ?>
- escapeHtml($_formatedOptionValue['full_view']) ?> - + escapeHtml($_formatedOptionValue['full_view']) ?> + escapeHtml($_formatedOptionValue['value'], ['span', 'a']) ?>
diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminClickAddNewPageOnPagesGridActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminClickAddNewPageOnPagesGridActionGroup.xml new file mode 100644 index 0000000000000..4f48400f53efa --- /dev/null +++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminClickAddNewPageOnPagesGridActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + Clicks the "Add New Page" button on the Pages Grid + + + + + + diff --git a/app/code/Magento/Cms/Test/Mftf/Test/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageTest.xml index 82e725de46249..711e126afc553 100644 --- a/app/code/Magento/Cms/Test/Mftf/Test/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageTest.xml +++ b/app/code/Magento/Cms/Test/Mftf/Test/VerifyTinyMCEv4IsNativeWYSIWYGOnCMSPageTest.xml @@ -25,7 +25,7 @@ - + diff --git a/app/code/Magento/Csp/etc/config.xml b/app/code/Magento/Csp/etc/config.xml index 6e2235479da93..07761995fdbca 100644 --- a/app/code/Magento/Csp/etc/config.xml +++ b/app/code/Magento/Csp/etc/config.xml @@ -92,6 +92,9 @@ 1 0 0 + + data + frame-src @@ -120,6 +123,9 @@ 1 0 0 + + data + @@ -197,6 +203,9 @@ 1 0 0 + + data + frame-src @@ -225,6 +234,9 @@ 1 0 0 + + data + diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithDefaultSetLinksTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithDefaultSetLinksTest.xml index e711add69b8c8..43f2f07b83cde 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithDefaultSetLinksTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithDefaultSetLinksTest.xml @@ -23,10 +23,7 @@ - - - - + @@ -79,9 +76,7 @@ - - - + diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml index 2ced91731e4ba..0d37c353052ec 100644 --- a/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml +++ b/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontAccountDownloadableProductLinkAfterPartialRefundTest.xml @@ -97,8 +97,8 @@ - - + + diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/SearchAdapter/Query/Builder.php b/app/code/Magento/Elasticsearch/Elasticsearch5/SearchAdapter/Query/Builder.php index ac99c91dcfac1..a310e30d0fc70 100644 --- a/app/code/Magento/Elasticsearch/Elasticsearch5/SearchAdapter/Query/Builder.php +++ b/app/code/Magento/Elasticsearch/Elasticsearch5/SearchAdapter/Query/Builder.php @@ -22,6 +22,8 @@ */ class Builder { + private const ELASTIC_INT_MAX = 2147483647; + /** * @var Config * @since 100.2.2 @@ -83,18 +85,18 @@ public function initQuery(RequestInterface $request) { $dimension = current($request->getDimensions()); $storeId = $this->scopeResolver->getScope($dimension->getValue())->getId(); - $searchQuery = [ 'index' => $this->searchIndexNameResolver->getIndexName($storeId, $request->getIndex()), 'type' => $this->clientConfig->getEntityType(), 'body' => [ - 'from' => $request->getFrom(), + 'from' => min(self::ELASTIC_INT_MAX, $request->getFrom()), 'size' => $request->getSize(), 'stored_fields' => ['_id', '_score'], 'sort' => $this->sortBuilder->getSort($request), 'query' => [], ], ]; + return $searchQuery; } diff --git a/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder.php b/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder.php index 778e73e6518e8..a37290f331bc3 100644 --- a/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder.php +++ b/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder.php @@ -23,6 +23,8 @@ */ class Builder extends Elasticsearch5Builder { + private const ELASTIC_INT_MAX = 2147483647; + /** * @var Sort */ @@ -61,7 +63,7 @@ public function initQuery(RequestInterface $request) 'index' => $this->searchIndexNameResolver->getIndexName($storeId, $request->getIndex()), 'type' => $this->clientConfig->getEntityType(), 'body' => [ - 'from' => $request->getFrom(), + 'from' => min(self::ELASTIC_INT_MAX, $request->getFrom()), 'size' => $request->getSize(), 'fields' => ['_id', '_score'], 'sort' => $this->sortBuilder->getSort($request), diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/SearchAdapter/Query/BuilderTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/SearchAdapter/Query/BuilderTest.php new file mode 100644 index 0000000000000..8d30cd0db1ec0 --- /dev/null +++ b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/SearchAdapter/Query/BuilderTest.php @@ -0,0 +1,189 @@ +clientConfig = $this->getMockBuilder(Config::class) + ->onlyMethods(['getEntityType']) + ->disableOriginalConstructor() + ->getMock(); + $this->searchIndexNameResolver = $this + ->getMockBuilder(SearchIndexNameResolver::class) + ->onlyMethods(['getIndexName']) + ->disableOriginalConstructor() + ->getMock(); + $this->aggregationBuilder = $this + ->getMockBuilder(\Magento\Elasticsearch\SearchAdapter\Query\Builder\Aggregation::class) + ->onlyMethods(['build']) + ->disableOriginalConstructor() + ->getMock(); + $this->request = $this->getMockBuilder(RequestInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->scopeResolver = $this->getMockForAbstractClass( + ScopeResolverInterface::class, + [], + '', + false + ); + $this->scopeInterface = $this->getMockForAbstractClass( + ScopeInterface::class, + [], + '', + false + ); + + $this->model = new Builder( + $this->clientConfig, + $this->searchIndexNameResolver, + $this->aggregationBuilder, + $this->scopeResolver, + ); + } + + /** + * Test initQuery() method + */ + public function testInitQuery() + { + $dimensionValue = 1; + $dimension = $this->getMockBuilder(Dimension::class) + ->onlyMethods(['getValue']) + ->disableOriginalConstructor() + ->getMock(); + + $this->request->expects($this->once()) + ->method('getDimensions') + ->willReturn([$dimension]); + $dimension->expects($this->once()) + ->method('getValue') + ->willReturn($dimensionValue); + $this->scopeResolver->expects($this->once()) + ->method('getScope') + ->willReturn($this->scopeInterface); + $this->scopeInterface->expects($this->once()) + ->method('getId') + ->willReturn($dimensionValue); + $this->request->expects($this->once()) + ->method('getFrom') + ->willReturn(0); + $this->request->expects($this->once()) + ->method('getSize') + ->willReturn(10); + $this->request->expects($this->once()) + ->method('getIndex') + ->willReturn('catalogsearch_fulltext'); + $this->searchIndexNameResolver->expects($this->once()) + ->method('getIndexName') + ->willReturn('indexName'); + $this->clientConfig->expects($this->once()) + ->method('getEntityType') + ->willReturn('document'); + $this->model->initQuery($this->request); + } + + /** + * Test initQuery() method with update from value + */ + public function testInitQueryLimitFrom() + { + $dimensionValue = 1; + $dimension = $this->getMockBuilder(Dimension::class) + ->onlyMethods(['getValue']) + ->disableOriginalConstructor() + ->getMock(); + + $this->request->expects($this->once()) + ->method('getDimensions') + ->willReturn([$dimension]); + $dimension->expects($this->once()) + ->method('getValue') + ->willReturn($dimensionValue); + $this->scopeResolver->expects($this->once()) + ->method('getScope') + ->willReturn($this->scopeInterface); + $this->scopeInterface->expects($this->once()) + ->method('getId') + ->willReturn($dimensionValue); + $this->request->expects($this->once()) + ->method('getFrom') + ->willReturn(PHP_INT_MAX); + $this->request->expects($this->once()) + ->method('getSize') + ->willReturn(10); + $this->request->expects($this->once()) + ->method('getIndex') + ->willReturn('catalogsearch_fulltext'); + $this->searchIndexNameResolver->expects($this->once()) + ->method('getIndexName') + ->willReturn('indexName'); + $this->clientConfig->expects($this->once()) + ->method('getEntityType') + ->willReturn('document'); + $query = $this->model->initQuery($this->request); + $this->assertLessThanOrEqual(2147483647, $query['body']['from']); + } +} diff --git a/app/code/Magento/Elasticsearch/Test/Unit/SearchAdapter/Query/BuilderTest.php b/app/code/Magento/Elasticsearch/Test/Unit/SearchAdapter/Query/BuilderTest.php index e3ce50b303595..39c0b9ad40410 100644 --- a/app/code/Magento/Elasticsearch/Test/Unit/SearchAdapter/Query/BuilderTest.php +++ b/app/code/Magento/Elasticsearch/Test/Unit/SearchAdapter/Query/BuilderTest.php @@ -10,6 +10,7 @@ use Magento\Elasticsearch\Model\Config; use Magento\Elasticsearch\SearchAdapter\Query\Builder; use Magento\Elasticsearch\SearchAdapter\Query\Builder\Aggregation as AggregationBuilder; +use Magento\Elasticsearch\SearchAdapter\Query\Builder\Sort; use Magento\Elasticsearch\SearchAdapter\SearchIndexNameResolver; use Magento\Framework\App\ScopeInterface; use Magento\Framework\App\ScopeResolverInterface; @@ -66,17 +67,17 @@ class BuilderTest extends TestCase protected function setUp(): void { $this->clientConfig = $this->getMockBuilder(Config::class) - ->setMethods(['getEntityType']) + ->onlyMethods(['getEntityType']) ->disableOriginalConstructor() ->getMock(); $this->searchIndexNameResolver = $this ->getMockBuilder(SearchIndexNameResolver::class) - ->setMethods(['getIndexName']) + ->onlyMethods(['getIndexName']) ->disableOriginalConstructor() ->getMock(); $this->aggregationBuilder = $this ->getMockBuilder(\Magento\Elasticsearch\SearchAdapter\Query\Builder\Aggregation::class) - ->setMethods(['build']) + ->onlyMethods(['build']) ->disableOriginalConstructor() ->getMock(); $this->request = $this->getMockBuilder(RequestInterface::class) @@ -94,16 +95,19 @@ protected function setUp(): void '', false ); + $sortBuilder = $this->getMockForAbstractClass( + Sort::class, + [], + '', + false + ); - $objectManagerHelper = new ObjectManagerHelper($this); - $this->model = $objectManagerHelper->getObject( - Builder::class, - [ - 'clientConfig' => $this->clientConfig, - 'searchIndexNameResolver' => $this->searchIndexNameResolver, - 'aggregationBuilder' => $this->aggregationBuilder, - 'scopeResolver' => $this->scopeResolver - ] + $this->model = new Builder( + $this->clientConfig, + $this->searchIndexNameResolver, + $this->aggregationBuilder, + $this->scopeResolver, + $sortBuilder, ); } @@ -114,7 +118,7 @@ public function testInitQuery() { $dimensionValue = 1; $dimension = $this->getMockBuilder(Dimension::class) - ->setMethods(['getValue']) + ->onlyMethods(['getValue']) ->disableOriginalConstructor() ->getMock(); @@ -148,6 +152,48 @@ public function testInitQuery() $this->model->initQuery($this->request); } + /** + * Test initQuery() method with update from value + */ + public function testInitQueryLimitFrom() + { + $dimensionValue = 1; + $dimension = $this->getMockBuilder(Dimension::class) + ->onlyMethods(['getValue']) + ->disableOriginalConstructor() + ->getMock(); + + $this->request->expects($this->once()) + ->method('getDimensions') + ->willReturn([$dimension]); + $dimension->expects($this->once()) + ->method('getValue') + ->willReturn($dimensionValue); + $this->scopeResolver->expects($this->once()) + ->method('getScope') + ->willReturn($this->scopeInterface); + $this->scopeInterface->expects($this->once()) + ->method('getId') + ->willReturn($dimensionValue); + $this->request->expects($this->once()) + ->method('getFrom') + ->willReturn(PHP_INT_MAX); + $this->request->expects($this->once()) + ->method('getSize') + ->willReturn(10); + $this->request->expects($this->once()) + ->method('getIndex') + ->willReturn('catalogsearch_fulltext'); + $this->searchIndexNameResolver->expects($this->once()) + ->method('getIndexName') + ->willReturn('indexName'); + $this->clientConfig->expects($this->once()) + ->method('getEntityType') + ->willReturn('document'); + $query = $this->model->initQuery($this->request); + $this->assertLessThanOrEqual(2147483647, $query['body']['from']); + } + /** * Test initQuery() method */ diff --git a/app/code/Magento/Email/Test/Mftf/Test/AdminEmailTemplatePreviewTest.xml b/app/code/Magento/Email/Test/Mftf/Test/AdminEmailTemplatePreviewTest.xml index 22e70b72e5401..8cf6320736bb4 100644 --- a/app/code/Magento/Email/Test/Mftf/Test/AdminEmailTemplatePreviewTest.xml +++ b/app/code/Magento/Email/Test/Mftf/Test/AdminEmailTemplatePreviewTest.xml @@ -29,7 +29,7 @@ - + diff --git a/app/code/Magento/Email/Test/Mftf/Test/AdminEmailTemplatePreviewWithDirectivesTest.xml b/app/code/Magento/Email/Test/Mftf/Test/AdminEmailTemplatePreviewWithDirectivesTest.xml index 7683591e8f37f..e1632c98a1cf0 100644 --- a/app/code/Magento/Email/Test/Mftf/Test/AdminEmailTemplatePreviewWithDirectivesTest.xml +++ b/app/code/Magento/Email/Test/Mftf/Test/AdminEmailTemplatePreviewWithDirectivesTest.xml @@ -29,7 +29,7 @@ - + diff --git a/app/code/Magento/Indexer/Model/Indexer/State.php b/app/code/Magento/Indexer/Model/Indexer/State.php index ffef44281a024..25fbcb7d15a53 100644 --- a/app/code/Magento/Indexer/Model/Indexer/State.php +++ b/app/code/Magento/Indexer/Model/Indexer/State.php @@ -23,23 +23,59 @@ class State extends \Magento\Framework\Model\AbstractModel implements StateInter */ protected $_eventObject = 'indexer_state'; + /** + * @var \Magento\Framework\Lock\LockManagerInterface + */ + private $lockManager; + + /** + * Prefix for lock mechanism + * + * @var string + */ + private $lockPrefix = 'INDEXER'; + + /** + * DeploymentConfig + * + * @var \Magento\Framework\App\DeploymentConfig + */ + private $configReader; + + /** + * Parameter with path to indexer use_application_lock config + * + * @var string + */ + private $useApplicationLockConfig = 'indexer/use_application_lock'; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Indexer\Model\ResourceModel\Indexer\State $resource * @param \Magento\Indexer\Model\ResourceModel\Indexer\State\Collection $resourceCollection * @param array $data + * @param \Magento\Framework\Lock\LockManagerInterface $lockManager + * @param \Magento\Framework\App\DeploymentConfig $configReader */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Indexer\Model\ResourceModel\Indexer\State $resource, \Magento\Indexer\Model\ResourceModel\Indexer\State\Collection $resourceCollection, - array $data = [] + array $data = [], + \Magento\Framework\Lock\LockManagerInterface $lockManager = null, + \Magento\Framework\App\DeploymentConfig $configReader = null ) { if (!isset($data['status'])) { $data['status'] = self::STATUS_INVALID; } + $this->lockManager = $lockManager ?: \Magento\Framework\App\ObjectManager::getInstance()->get( + \Magento\Framework\Lock\LockManagerInterface::class + ); + $this->configReader = $configReader ?: \Magento\Framework\App\ObjectManager::getInstance()->get( + \Magento\Framework\App\DeploymentConfig::class + ); parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -71,6 +107,15 @@ public function setIndexerId($value) */ public function getStatus() { + if ($this->isUseApplicationLock()) { + if ( + parent::getStatus() == StateInterface::STATUS_WORKING && + !$this->lockManager->isLocked($this->lockPrefix . $this->getIndexerId()) + ) { + return StateInterface::STATUS_INVALID; + } + } + return parent::getStatus(); } @@ -118,6 +163,13 @@ public function loadByIndexer($indexerId) */ public function setStatus($status) { + if ($this->isUseApplicationLock()) { + if ($status == StateInterface::STATUS_WORKING) { + $this->lockManager->lock($this->lockPrefix . $this->getIndexerId()); + } else { + $this->lockManager->unlock($this->lockPrefix . $this->getIndexerId()); + } + } return parent::setStatus($status); } @@ -131,4 +183,14 @@ public function beforeSave() $this->setUpdated(time()); return parent::beforeSave(); } + + /** + * The indexer application locking mechanism is used + * + * @return bool + */ + private function isUseApplicationLock() + { + return $this->configReader->get($this->useApplicationLockConfig) ?: false; + } } diff --git a/app/code/Magento/Indexer/Model/Mview/View/State.php b/app/code/Magento/Indexer/Model/Mview/View/State.php index fe1a3a1e8766d..66cc423f189c7 100644 --- a/app/code/Magento/Indexer/Model/Mview/View/State.php +++ b/app/code/Magento/Indexer/Model/Mview/View/State.php @@ -24,19 +24,49 @@ class State extends \Magento\Framework\Model\AbstractModel implements \Magento\F */ protected $_eventObject = 'mview_state'; + /** + * @var \Magento\Framework\Lock\LockManagerInterface + */ + private $lockManager; + + /** + * Prefix for lock mechanism + * + * @var string + */ + private $lockPrefix = 'MVIEW'; + + /** + * DeploymentConfig + * + * @var \Magento\Framework\App\DeploymentConfig + */ + private $configReader; + + /** + * Parameter with path to indexer use_application_lock config + * + * @var string + */ + private $useApplicationLockConfig = 'indexer/use_application_lock'; + /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param \Magento\Indexer\Model\ResourceModel\Mview\View\State $resource * @param \Magento\Indexer\Model\ResourceModel\Mview\View\State\Collection $resourceCollection * @param array $data + * @param \Magento\Framework\Lock\LockManagerInterface $lockManager + * @param \Magento\Framework\App\DeploymentConfig $configReader */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Indexer\Model\ResourceModel\Mview\View\State $resource, \Magento\Indexer\Model\ResourceModel\Mview\View\State\Collection $resourceCollection, - array $data = [] + array $data = [], + \Magento\Framework\Lock\LockManagerInterface $lockManager = null, + \Magento\Framework\App\DeploymentConfig $configReader = null ) { if (!isset($data['mode'])) { $data['mode'] = self::MODE_DISABLED; @@ -44,6 +74,12 @@ public function __construct( if (!isset($data['status'])) { $data['status'] = self::STATUS_IDLE; } + $this->lockManager = $lockManager ?: \Magento\Framework\App\ObjectManager::getInstance()->get( + \Magento\Framework\Lock\LockManagerInterface::class + ); + $this->configReader = $configReader ?: \Magento\Framework\App\ObjectManager::getInstance()->get( + \Magento\Framework\App\DeploymentConfig::class + ); parent::__construct($context, $registry, $resource, $resourceCollection, $data); } @@ -112,7 +148,17 @@ public function setMode($mode) */ public function getStatus() { - return $this->getData('status'); + $status = $this->getData('status'); + if ($this->isUseApplicationLock()) { + if ( + $status == \Magento\Framework\Mview\View\StateInterface::STATUS_WORKING && + !$this->lockManager->isLocked($this->lockPrefix . $this->getViewId()) + ) { + return \Magento\Framework\Mview\View\StateInterface::STATUS_IDLE; + } + } + + return $status; } /** @@ -123,6 +169,13 @@ public function getStatus() */ public function setStatus($status) { + if ($this->isUseApplicationLock()) { + if ($status == \Magento\Framework\Mview\View\StateInterface::STATUS_WORKING) { + $this->lockManager->lock($this->lockPrefix . $this->getViewId()); + } else { + $this->lockManager->unlock($this->lockPrefix . $this->getViewId()); + } + } $this->setData('status', $status); return $this; } @@ -170,4 +223,14 @@ public function setVersionId($versionId) $this->setData('version_id', $versionId); return $this; } + + /** + * The indexer application locking mechanism is used + * + * @return bool + */ + private function isUseApplicationLock() + { + return $this->configReader->get($this->useApplicationLockConfig) ?: false; + } } diff --git a/app/code/Magento/Indexer/Test/Mftf/Test/AdminSystemIndexManagementGridChangesTest.xml b/app/code/Magento/Indexer/Test/Mftf/Test/AdminSystemIndexManagementGridChangesTest.xml index 51cf4aa26a1b1..adb0b9d059d81 100644 --- a/app/code/Magento/Indexer/Test/Mftf/Test/AdminSystemIndexManagementGridChangesTest.xml +++ b/app/code/Magento/Indexer/Test/Mftf/Test/AdminSystemIndexManagementGridChangesTest.xml @@ -23,9 +23,7 @@ - - - + @@ -34,9 +32,7 @@ - - - + diff --git a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php index 5ad07f914dcbb..35a003ba2f28a 100644 --- a/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Console/Command/IndexerStatusCommandTest.php @@ -41,10 +41,7 @@ private function attachViewToIndexerMock($indexerMock, array $data) ->willReturn(range(0, $data['view']['changelog']['list_size']-1)); /** @var State|MockObject $stateMock */ - $stateMock = $this->getMockBuilder(State::class) - ->disableOriginalConstructor() - ->setMethods(null) - ->getMock(); + $stateMock = $this->getStateMock(); $stateMock->addData($data['view']['state']); @@ -67,6 +64,33 @@ private function attachViewToIndexerMock($indexerMock, array $data) return $indexerMock; } + /** + * @return State + */ + private function getStateMock() + { + $contextMock = $this->createPartialMock(\Magento\Framework\Model\Context::class, ['getEventDispatcher']); + $eventManagerMock = $this->getMockForAbstractClass(\Magento\Framework\Event\ManagerInterface::class); + $contextMock->expects($this->any())->method('getEventDispatcher')->willReturn($eventManagerMock); + $registryMock = $this->createMock(\Magento\Framework\Registry::class); + $resourceMock = $this->createMock(\Magento\Indexer\Model\ResourceModel\Mview\View\State::class); + $resourceCollectionMock = $this->createMock( + \Magento\Indexer\Model\ResourceModel\Mview\View\State\Collection::class + ); + $lockManagerMock = $this->createMock(\Magento\Framework\Lock\LockManagerInterface::class); + $configReaderMock = $this->createMock(\Magento\Framework\App\DeploymentConfig::class); + + return new State( + $contextMock, + $registryMock, + $resourceMock, + $resourceCollectionMock, + [], + $lockManagerMock, + $configReaderMock + ); + } + /** * @param array $indexers * diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/StateTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/StateTest.php index 5c5ab24a75910..31411bcbc96f0 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Indexer/StateTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Indexer/StateTest.php @@ -42,6 +42,16 @@ class StateTest extends TestCase */ protected $_resourceCollectionMock; + /** + * @var \Magento\Framework\Lock\LockManagerInterface|MockObject + */ + protected $lockManagerMock; + + /** + * @var \Magento\Framework\App\DeploymentConfig|MockObject + */ + protected $configReaderMock; + protected function setUp(): void { $this->_contextMock = $this->createPartialMock(Context::class, ['getEventDispatcher']); @@ -52,12 +62,17 @@ protected function setUp(): void $this->_resourceCollectionMock = $this->createMock( Collection::class ); + $this->lockManagerMock = $this->createMock(\Magento\Framework\Lock\LockManagerInterface::class); + $this->configReaderMock = $this->createMock(\Magento\Framework\App\DeploymentConfig::class); $this->model = new State( $this->_contextMock, $this->_registryMock, $this->_resourceMock, - $this->_resourceCollectionMock + $this->_resourceCollectionMock, + [], + $this->lockManagerMock, + $this->configReaderMock ); } @@ -82,4 +97,67 @@ public function testSetStatus() $this->model->setStatus($setData); $this->assertEquals($setData, $this->model->getStatus()); } + + public function testSetterAndGetterWithoutApplicationLock() + { + $this->configReaderMock->expects($this->any())->method('get')->willReturn(false); + + $this->lockManagerMock->expects($this->any())->method('isLocked')->willReturn(false); + + $status = \Magento\Framework\Indexer\StateInterface::STATUS_WORKING; + $this->model->setStatus($status); + $this->assertEquals($status, $this->model->getStatus()); + + $date = time(); + $this->model->setUpdated($date); + $this->assertEquals($date, $this->model->getUpdated()); + } + + /** + * @return array + */ + public function executeProvider() + { + return [ + [ + 'setStatus' => \Magento\Framework\Indexer\StateInterface::STATUS_WORKING, + 'getStatus' => \Magento\Framework\Indexer\StateInterface::STATUS_WORKING, + 'lock' => 'lock', + 'isLocked' => true + ], + [ + 'setStatus' => \Magento\Framework\Indexer\StateInterface::STATUS_WORKING, + 'getStatus' => \Magento\Framework\Indexer\StateInterface::STATUS_INVALID, + 'lock' => 'lock', + 'isLocked' => false + ], + [ + 'setStatus' => \Magento\Framework\Indexer\StateInterface::STATUS_INVALID, + 'getStatus' => \Magento\Framework\Indexer\StateInterface::STATUS_INVALID, + 'lock' => 'unlock', + 'isLocked' => false + ], + [ + 'setStatus' => \Magento\Framework\Indexer\StateInterface::STATUS_VALID, + 'getStatus' => \Magento\Framework\Indexer\StateInterface::STATUS_VALID, + 'lock' => 'unlock', + 'isLocked' => false + ] + ]; + } + + /** + * @param string $setStatus + * @param string $getStatus + * @param bool $isLocked + * @dataProvider executeProvider + */ + public function testSetterAndGetterWithApplicationLock($setStatus, $getStatus, $lock, $isLocked) + { + $this->configReaderMock->expects($this->any())->method('get')->willReturn(true); + $this->lockManagerMock->expects($this->any())->method('isLocked')->willReturn($isLocked); + $this->lockManagerMock->expects($this->once())->method($lock); + $this->model->setStatus($setStatus); + $this->assertEquals($getStatus, $this->model->getStatus()); + } } diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Mview/View/StateTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Mview/View/StateTest.php index 80d78bedffc73..2841a0415ae94 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Mview/View/StateTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Mview/View/StateTest.php @@ -42,23 +42,34 @@ class StateTest extends TestCase */ protected $_resourceCollectionMock; + /** + * @var \Magento\Framework\Lock\LockManagerInterface|MockObject + */ + protected $lockManagerMock; + + /** + * @var \Magento\Framework\App\DeploymentConfig|MockObject + */ + protected $configReaderMock; + protected function setUp(): void { $this->_contextMock = $this->createPartialMock(Context::class, ['getEventDispatcher']); $eventManagerMock = $this->getMockForAbstractClass(ManagerInterface::class); $this->_contextMock->expects($this->any())->method('getEventDispatcher')->willReturn($eventManagerMock); $this->_registryMock = $this->createMock(Registry::class); - $this->_resourceMock = - $this->createMock(\Magento\Indexer\Model\ResourceModel\Mview\View\State::class); - $this->_resourceCollectionMock = $this->createMock( - Collection::class - ); - + $this->_resourceMock = $this->createMock(\Magento\Indexer\Model\ResourceModel\Mview\View\State::class); + $this->_resourceCollectionMock = $this->createMock(Collection::class); + $this->lockManagerMock = $this->createMock(\Magento\Framework\Lock\LockManagerInterface::class); + $this->configReaderMock = $this->createMock(\Magento\Framework\App\DeploymentConfig::class); $this->model = new State( $this->_contextMock, $this->_registryMock, $this->_resourceMock, - $this->_resourceCollectionMock + $this->_resourceCollectionMock, + [], + $this->lockManagerMock, + $this->configReaderMock ); } @@ -77,16 +88,74 @@ public function testBeforeSave() $this->assertNotNull($this->model->getUpdated()); } - public function testSetterAndGetter() + public function testSetterAndGetterWithoutApplicationLock() + { + $this->configReaderMock->expects($this->any())->method('get')->willReturn(false); + + $this->lockManagerMock->expects($this->any())->method('isLocked')->willReturn(false); + + $mode = \Magento\Framework\Mview\View\StateInterface::MODE_ENABLED; + $this->model->setMode($mode); + $this->assertEquals($mode, $this->model->getMode()); + + $status = \Magento\Framework\Mview\View\StateInterface::STATUS_WORKING; + $this->model->setStatus($status); + $this->assertEquals($status, $this->model->getStatus()); + + $date = time(); + $this->model->setUpdated($date); + $this->assertEquals($date, $this->model->getUpdated()); + + $versionId = 99; + $this->model->setVersionId($versionId); + $this->assertEquals($versionId, $this->model->getVersionId()); + } + + /** + * @return array + */ + public function executeProvider() + { + return [ + [ + 'setStatus' => \Magento\Framework\Mview\View\StateInterface::STATUS_WORKING, + 'getStatus' => \Magento\Framework\Mview\View\StateInterface::STATUS_WORKING, + 'lock' => 'lock', + 'isLocked' => true + ], + [ + 'setStatus' => \Magento\Framework\Mview\View\StateInterface::STATUS_WORKING, + 'getStatus' => \Magento\Framework\Mview\View\StateInterface::STATUS_IDLE, + 'lock' => 'lock', + 'isLocked' => false + ], + [ + 'setStatus' => \Magento\Framework\Mview\View\StateInterface::STATUS_IDLE, + 'getStatus' => \Magento\Framework\Mview\View\StateInterface::STATUS_IDLE, + 'lock' => 'unlock', + 'isLocked' => false + ], + [ + 'setStatus' => \Magento\Framework\Mview\View\StateInterface::STATUS_SUSPENDED, + 'getStatus' => \Magento\Framework\Mview\View\StateInterface::STATUS_SUSPENDED, + 'lock' => 'unlock', + 'isLocked' => false + ] + ]; + } + + /** + * @param string $setStatus + * @param string $getStatus + * @param bool $isLocked + * @dataProvider executeProvider + */ + public function testSetterAndGetterWithApplicationLock($setStatus, $getStatus, $lock, $isLocked) { - $setData = 'data'; - $this->model->setMode($setData); - $this->assertEquals($setData, $this->model->getMode()); - $this->model->setStatus($setData); - $this->assertEquals($setData, $this->model->getStatus()); - $this->model->setUpdated($setData); - $this->assertEquals($setData, $this->model->getUpdated()); - $this->model->setVersionId($setData); - $this->assertEquals($setData, $this->model->getVersionId()); + $this->configReaderMock->expects($this->any())->method('get')->willReturn(true); + $this->lockManagerMock->expects($this->any())->method('isLocked')->willReturn($isLocked); + $this->lockManagerMock->expects($this->once())->method($lock); + $this->model->setStatus($setStatus); + $this->assertEquals($getStatus, $this->model->getStatus()); } } diff --git a/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityNegativeScenarioTest.xml b/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityNegativeScenarioTest.xml index ecbff39807f30..c81c6d36786eb 100644 --- a/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityNegativeScenarioTest.xml +++ b/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityNegativeScenarioTest.xml @@ -129,7 +129,7 @@ - + diff --git a/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityTest.xml b/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityTest.xml index 59697bb6f5bdf..865852c10acfd 100644 --- a/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityTest.xml +++ b/app/code/Magento/InstantPurchase/Test/Mftf/Test/StorefrontInstantPurchaseFunctionalityTest.xml @@ -109,7 +109,7 @@ - + diff --git a/app/code/Magento/PageCache/etc/varnish6.vcl b/app/code/Magento/PageCache/etc/varnish6.vcl index bce89fe263573..cc381baaf313a 100644 --- a/app/code/Magento/PageCache/etc/varnish6.vcl +++ b/app/code/Magento/PageCache/etc/varnish6.vcl @@ -62,13 +62,13 @@ sub vcl_recv { return (pass); } - # Bypass shopping cart and checkout - if (req.url ~ "/checkout") { + # Bypass customer, shopping cart, checkout + if (req.url ~ "/customer" || req.url ~ "/checkout") { return (pass); } # Bypass health check requests - if (req.url ~ "/pub/health_check.php") { + if (req.url ~ "^/(pub/)?(health_check.php)$") { return (pass); } diff --git a/app/code/Magento/Quote/Model/Quote/Address.php b/app/code/Magento/Quote/Model/Quote/Address.php index 1ad98aa3e0263..6a06deb9cbbef 100644 --- a/app/code/Magento/Quote/Model/Quote/Address.php +++ b/app/code/Magento/Quote/Model/Quote/Address.php @@ -1115,7 +1115,13 @@ public function requestShippingRates(AbstractItem $item = null) */ public function getTotals() { - $totalsData = array_merge($this->getData(), ['address_quote_items' => $this->getAllItems()]); + $totalsData = array_merge( + $this->getData(), + [ + 'address_quote_items' => $this->getAllItems(), + 'quote_items' => $this->getQuote()->getAllItems(), + ] + ); $totals = $this->totalsReader->fetch($this->getQuote(), $totalsData); foreach ($totals as $total) { $this->addTotal($total); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php index 77765b242001f..98fd4d9bae994 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php @@ -71,9 +71,10 @@ public function getItemCollection() public function getItemPrice(Product $product) { $customPrice = $this->getCartItemCustomPrice($product); - $price = $customPrice ?? $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue(); - return $this->convertPrice($price); + return $customPrice !== null + ? $this->convertPrice($customPrice) + : $this->priceCurrency->format($product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue()); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Totals/Tax.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Totals/Tax.php index e923b006a0ac6..1f8d0a0bc265d 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Totals/Tax.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Totals/Tax.php @@ -95,7 +95,7 @@ public function getFullTaxInfo() $taxClassAmount = $this->_taxHelper->getCalculatedTaxes($source); if (empty($taxClassAmount)) { - $rates = $this->_taxOrderFactory->create()->getCollection()->loadByOrder($source)->toArray(); + $rates = $this->_taxOrderFactory->create()->getCollection()->loadByOrder($this->getOrder())->toArray(); $taxClassAmount = $this->_taxCalculation->reproduceProcess($rates['items']); } diff --git a/app/code/Magento/Sales/Model/RtlTextHandler.php b/app/code/Magento/Sales/Model/RtlTextHandler.php index cfb88dc63f58b..b943320e0f897 100644 --- a/app/code/Magento/Sales/Model/RtlTextHandler.php +++ b/app/code/Magento/Sales/Model/RtlTextHandler.php @@ -48,7 +48,7 @@ public function reverseRtlText(string $string): string for ($i = 0; $i < $splitTextAmount; $i++) { if ($this->isRtlText($splitText[$i])) { - for ($j = $i + 1; $j < $splitTextAmount; $j++) { + for ($j = $i; $j < $splitTextAmount; $j++) { $tmp = $this->isRtlText($splitText[$j]) ? $this->stringUtils->strrev($splitText[$j]) : $splitText[$j]; $splitText[$j] = $this->isRtlText($splitText[$i]) diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickRefundOfflineOnNewMemoPageActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickRefundOfflineOnNewMemoPageActionGroup.xml new file mode 100644 index 0000000000000..21ca2d51a364e --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickRefundOfflineOnNewMemoPageActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + Click the Refund Offline button on the New Memo page + + + + + + diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoBankTransferPaymentTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoBankTransferPaymentTest.xml index 6ed8510db777c..9d1daf0d2ded1 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoBankTransferPaymentTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoBankTransferPaymentTest.xml @@ -85,8 +85,8 @@ - - + + diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundTest.xml index 68301187d3d31..5d2f76b80e3f8 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundTest.xml @@ -78,8 +78,8 @@ - - + + diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoWithPurchaseOrderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoWithPurchaseOrderTest.xml index 141fa2a9e5d06..32c3a5e0a5846 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoWithPurchaseOrderTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoWithPurchaseOrderTest.xml @@ -88,8 +88,8 @@ - - + + diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml index d5128dc3f8b0c..96007caf0f8ba 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateInvoiceTest.xml @@ -8,15 +8,18 @@ - + - + <title value="DEPRECATED. Admin should be able to create an invoice"/> <description value="Admin should be able to create an invoice"/> <severity value="MAJOR"/> <testCaseId value="MAGETWO-72096"/> <group value="sales"/> + <skip> + <issueId value="DEPRECATED">Use AdminInvoiceOrderTest instead</issueId> + </skip> </annotations> <before> <createData entity="_defaultCategory" stepKey="createCategory"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminInvoiceOrderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminInvoiceOrderTest.xml new file mode 100644 index 0000000000000..922037fe4a3cd --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminInvoiceOrderTest.xml @@ -0,0 +1,66 @@ +<?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="AdminInvoiceOrderTest"> + <annotations> + <features value="Sales"/> + <stories value="Create an Invoice via the Admin"/> + <title value="Admin should be able to create an invoice"/> + <description value="Admin should be able to create an invoice"/> + <severity value="MAJOR"/> + <testCaseId value="MAGETWO-72096"/> + <group value="sales"/> + </annotations> + + <before> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="_defaultProduct" stepKey="createSimpleProductApi"> + <requiredEntity createDataKey="createCategory"/> + </createData> + <createData entity="GuestCart" stepKey="createGuestCart"/> + <createData entity="SimpleCartItem" stepKey="addCartItem"> + <requiredEntity createDataKey="createGuestCart"/> + <requiredEntity createDataKey="createSimpleProductApi"/> + </createData> + <createData entity="GuestAddressInformation" stepKey="addGuestOrderAddress"> + <requiredEntity createDataKey="createGuestCart"/> + </createData> + <updateData createDataKey="createGuestCart" entity="GuestOrderPaymentMethod" stepKey="sendGuestPaymentInformation"> + <requiredEntity createDataKey="createGuestCart"/> + </updateData> + + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + + </before> + + <after> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createSimpleProductApi" stepKey="deleteSimpleProductApi"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogout"/> + </after> + + <actionGroup ref="AdminOpenOrderByEntityIdActionGroup" stepKey="openOrder"> + <argument name="entityId" value="$createGuestCart.return$"/> + </actionGroup> + + <actionGroup ref="AdminCreateInvoiceActionGroup" stepKey="createInvoice"/> + + <actionGroup ref="FilterInvoiceGridByOrderIdWithCleanFiltersActionGroup" stepKey="filterInvoiceGridByOrderId"> + <argument name="orderId" value="$createGuestCart.return$"/> + </actionGroup> + + <actionGroup ref="AdminSelectFirstGridRowActionGroup" stepKey="openInvoiceFromGrid"/> + + <actionGroup ref="AdminOrderViewCheckStatusActionGroup" stepKey="checkIfOrderStatusIsProcessing"> + <argument name="status" value="Processing"/> + </actionGroup> + + </test> +</tests> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/EndToEndB2CAdminTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/EndToEndB2CAdminTest.xml index 6ba1c3ac3deec..2a3284e7e8e35 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/EndToEndB2CAdminTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/EndToEndB2CAdminTest.xml @@ -140,8 +140,8 @@ <argument name="billingAddress" value="US_Address_TX"/> </actionGroup> <!--Submit credit memo--> - <click selector="{{AdminCreditMemoTotalSection.submitRefundOffline}}" stepKey="clickRefundOffline" after="verifyOrderCreditMemoInformation"/> - <see selector="{{AdminOrderDetailsMessagesSection.successMessage}}" userInput="You created the credit memo." stepKey="seeCreditMemoSuccess" after="clickRefundOffline"/> + <actionGroup ref="AdminClickRefundOfflineOnNewMemoPageActionGroup" stepKey="clickRefundOffline" after="verifyOrderCreditMemoInformation"/> + <comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="seeCreditMemoSuccess" after="clickRefundOffline"/> <click selector="{{AdminOrderDetailsOrderViewSection.creditMemos}}" stepKey="clickOrderCreditMemosTab" after="seeCreditMemoSuccess"/> <waitForLoadingMaskToDisappear stepKey="waitForCreditMemoTabLoadingMask" after="clickOrderCreditMemosTab"/> <see selector="{{AdminOrderCreditMemosTabSection.gridRow('1')}}" userInput="{{Simple_US_Customer.firstname}}" stepKey="seeOrderCreditMemoInTabGrid" after="waitForCreditMemoTabLoadingMask"/> diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Totals/TaxTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Totals/TaxTest.php index 80563623e0050..b0c053a36de0f 100644 --- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Totals/TaxTest.php +++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/Totals/TaxTest.php @@ -5,9 +5,6 @@ */ declare(strict_types=1); -/** - * Test class for \Magento\Sales\Block\Adminhtml\Order\Totals\TaxTest - */ namespace Magento\Sales\Test\Unit\Block\Adminhtml\Order\Totals; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -16,46 +13,75 @@ use Magento\Sales\Model\Order\Creditmemo; use Magento\Sales\Model\Order\Invoice; use Magento\Tax\Helper\Data; +use Magento\Tax\Model\ResourceModel\Sales\Order\Tax\Collection; +use Magento\Tax\Model\Sales\Order\Tax as TaxModel; +use Magento\Tax\Model\Sales\Order\TaxFactory; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +/** + * Test for \Magento\Sales\Block\Adminhtml\Order\Totals\Tax + */ class TaxTest extends TestCase { - /** @var MockObject|Tax */ + /** + * @var array + */ + private $calculatedData = [ + 'tax' => 'tax', + 'shipping_tax' => 'shipping_tax', + ]; + + /** + * @var MockObject|Tax + */ private $taxMock; + /** + * @var Data|MockObject + */ + private $taxHelperMock; + + /** + * @var TaxFactory|MockObject + */ + private $taxOrderFactory; + + /** + * @inheridoc + */ protected function setUp(): void { - $getCalculatedTax = [ - 'tax' => 'tax', - 'shipping_tax' => 'shipping_tax', - ]; - $taxHelperMock = $this->getMockBuilder(Data::class) - ->setMethods(['getCalculatedTaxes']) + $this->taxHelperMock = $this->getMockBuilder(Data::class) + ->onlyMethods(['getCalculatedTaxes']) ->disableOriginalConstructor() ->getMock(); - $taxHelperMock->expects($this->any()) - ->method('getCalculatedTaxes') - ->willReturn($getCalculatedTax); + $this->taxOrderFactory = $this->createMock(TaxFactory::class); + + $arguments = $this->getModelArguments( + ['taxHelper' => $this->taxHelperMock, 'taxOrderFactory' => $this->taxOrderFactory] + ); $this->taxMock = $this->getMockBuilder(Tax::class) - ->setConstructorArgs($this->_getConstructArguments($taxHelperMock)) - ->setMethods(['getOrder', 'getSource']) + ->setConstructorArgs($arguments) + ->onlyMethods(['getOrder', 'getSource']) ->getMock(); } /** * Test method for getFullTaxInfo * - * @param Order $source - * @param array $getCalculatedTax - * @param array $getShippingTax + * @param Order|null $source * @param array $expectedResult + * @return void * * @dataProvider getFullTaxInfoDataProvider */ - public function testGetFullTaxInfo($source, $expectedResult) + public function testGetFullTaxInfo(?Order $source, array $expectedResult): void { + $this->taxHelperMock->expects($this->any()) + ->method('getCalculatedTaxes') + ->willReturn($this->calculatedData); $this->taxMock->expects($this->once()) ->method('getOrder') ->willReturn($source); @@ -69,13 +95,15 @@ public function testGetFullTaxInfo($source, $expectedResult) * * @param Invoice|Creditmemo $source * @param array $expectedResult + * @return void * * @dataProvider getCreditAndInvoiceFullTaxInfoDataProvider */ - public function testGetFullTaxInfoWithCreditAndInvoice( - $source, - $expectedResult - ) { + public function testGetFullTaxInfoWithCreditAndInvoice($source, array $expectedResult): void + { + $this->taxHelperMock->expects($this->any()) + ->method('getCalculatedTaxes') + ->willReturn($this->calculatedData); $this->taxMock->expects($this->once()) ->method('getSource') ->willReturn($source); @@ -84,19 +112,57 @@ public function testGetFullTaxInfoWithCreditAndInvoice( $this->assertSame($expectedResult, $actualResult); } + /** + * Test method for getFullTaxInfo when order doesn't have tax + * + * @return void + */ + public function testGetFullTaxInfoOrderWithoutTax(): void + { + $this->taxHelperMock->expects($this->once()) + ->method('getCalculatedTaxes') + ->willReturn(null); + + $orderMock = $this->createMock(Order::class); + $taxCollection = $this->createMock(Collection::class); + $taxCollection->expects($this->once()) + ->method('loadByOrder') + ->with($orderMock) + ->willReturnSelf(); + $taxCollection->expects($this->once()) + ->method('toArray') + ->willReturn(['items' => []]); + + $taxOrder = $this->createMock(TaxModel::class); + $taxOrder->expects($this->once()) + ->method('getCollection') + ->willReturn($taxCollection); + $this->taxOrderFactory->expects($this->once()) + ->method('create') + ->willReturn($taxOrder); + + $invoiceMock = $this->createMock(Invoice::class); + $this->taxMock->expects($this->once()) + ->method('getSource') + ->willReturn($invoiceMock); + $this->taxMock->expects($this->once()) + ->method('getOrder') + ->willReturn($orderMock); + + $this->assertNull($this->taxMock->getFullTaxInfo()); + } + /** * Provide the tax helper mock as a constructor argument * - * @param $taxHelperMock + * @param array $arguments * @return array */ - protected function _getConstructArguments($taxHelperMock) + private function getModelArguments(array $arguments): array { $objectManagerHelper = new ObjectManager($this); - return $objectManagerHelper->getConstructArguments( - Tax::class, - ['taxHelper' => $taxHelperMock] - ); + + return $objectManagerHelper->getConstructArguments(Tax::class, $arguments); } /** @@ -106,19 +172,15 @@ protected function _getConstructArguments($taxHelperMock) * * @return array */ - public function getFullTaxInfoDataProvider() + public function getFullTaxInfoDataProvider(): array { - $salesModelOrderMock = $this->getMockBuilder(Order::class) - ->disableOriginalConstructor() - ->getMock(); + $salesModelOrderMock = $this->createMock(Order::class); + return [ 'source is not an instance of \Magento\Sales\Model\Order' => [null, []], 'source is an instance of \Magento\Sales\Model\Order and has reasonable data' => [ $salesModelOrderMock, - [ - 'tax' => 'tax', - 'shipping_tax' => 'shipping_tax', - ], + $this->calculatedData, ] ]; } @@ -130,22 +192,14 @@ public function getFullTaxInfoDataProvider() * * @return array */ - public function getCreditAndInvoiceFullTaxInfoDataProvider() + public function getCreditAndInvoiceFullTaxInfoDataProvider(): array { - $invoiceMock = $this->getMockBuilder(Invoice::class) - ->disableOriginalConstructor() - ->getMock(); - $creditMemoMock = $this->getMockBuilder(Creditmemo::class) - ->disableOriginalConstructor() - ->getMock(); + $invoiceMock = $this->createMock(Invoice::class); + $creditMemoMock = $this->createMock(Creditmemo::class); - $expected = [ - 'tax' => 'tax', - 'shipping_tax' => 'shipping_tax', - ]; return [ - 'invoice' => [$invoiceMock, $expected], - 'creditMemo' => [$creditMemoMock, $expected] + 'invoice' => [$invoiceMock, $this->calculatedData], + 'creditMemo' => [$creditMemoMock, $this->calculatedData] ]; } } diff --git a/app/code/Magento/Sales/Test/Unit/Model/RtlTextHandlerTest.php b/app/code/Magento/Sales/Test/Unit/Model/RtlTextHandlerTest.php index 2faeb17dc2395..1a8159dbf4cbb 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/RtlTextHandlerTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/RtlTextHandlerTest.php @@ -62,6 +62,7 @@ public function provideRtlTexts(): array ['Herr Prof. Dr. Gerald Schüler B.A.', false],//German ['نديم مقداد نعمان القحطاني', true],//Arabic ['شهاب الفرحان', true],//Arabic + ['مرحبا ماجنت اثنان', true],//Arabic ['צבר קרליבך', true],//Hebrew ['גורי מייזליש', true],//Hebrew ['اتابک بهشتی', true],//Persian diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php index 4a9061c3f3c5c..449ab230b568d 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php @@ -17,6 +17,9 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +/** + * Contains tests for Price class + */ class PriceTest extends TestCase { /** @@ -34,6 +37,9 @@ class PriceTest extends TestCase */ private $storeManagerMock; + /** + * @inheritDoc + */ protected function setUp(): void { $objectManager = new ObjectManager($this); @@ -57,12 +63,20 @@ protected function setUp(): void } /** - * @param $hasCurrency - * @param $dataSource - * @param $currencyCode + * Test for prepareDataSource method + * + * @param bool $hasCurrency + * @param array $dataSource + * @param string $currencyCode + * @param int|null $expectedStoreId * @dataProvider testPrepareDataSourceDataProvider */ - public function testPrepareDataSource($hasCurrency, $dataSource, $currencyCode) + public function testPrepareDataSource( + bool $hasCurrency, + array $dataSource, + string $currencyCode, + ?int $expectedStoreId = null + ): void { $itemName = 'itemName'; $oldItemValue = 'oldItemValue'; @@ -79,6 +93,7 @@ public function testPrepareDataSource($hasCurrency, $dataSource, $currencyCode) ->willReturn($currencyCode); $this->storeManagerMock->expects($hasCurrency ? $this->never() : $this->once()) ->method('getStore') + ->with($expectedStoreId) ->willReturn($store); $store->expects($hasCurrency ? $this->never() : $this->once()) ->method('getBaseCurrency') @@ -98,7 +113,12 @@ public function testPrepareDataSource($hasCurrency, $dataSource, $currencyCode) $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]); } - public function testPrepareDataSourceDataProvider() + /** + * Provider for testPrepareDataSource + * + * @return array + */ + public function testPrepareDataSourceDataProvider(): array { $dataSource1 = [ 'data' => [ @@ -119,9 +139,31 @@ public function testPrepareDataSourceDataProvider() ] ] ]; + $dataSource3 = [ + 'data' => [ + 'items' => [ + [ + 'itemName' => 'oldItemValue', + 'store_id' => '2' + ] + ] + ] + ]; + $dataSource4 = [ + 'data' => [ + 'items' => [ + [ + 'itemName' => 'oldItemValue', + 'store_id' => 'abc' + ] + ] + ] + ]; return [ [true, $dataSource1, 'US'], [false, $dataSource2, 'SAR'], + [false, $dataSource3, 'SAR', 2], + [false, $dataSource4, 'SAR'], ]; } } diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php index 4ffb6f98447c7..cc323730f14b4 100644 --- a/app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php @@ -10,6 +10,7 @@ use Magento\Framework\App\ObjectManager; use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponentFactory; +use Magento\Store\Model\Store; use Magento\Store\Model\StoreManagerInterface; use Magento\Ui\Component\Listing\Columns\Column; use Magento\Framework\Pricing\PriceCurrencyInterface; @@ -77,8 +78,10 @@ public function prepareDataSource(array $dataSource) foreach ($dataSource['data']['items'] as & $item) { $currencyCode = isset($item['base_currency_code']) ? $item['base_currency_code'] : null; if (!$currencyCode) { + $storeId = isset($item['store_id']) && (int)$item['store_id'] !== 0 ? $item['store_id'] : + $this->context->getFilterParam('store_id', Store::DEFAULT_STORE_ID); $store = $this->storeManager->getStore( - $this->context->getFilterParam('store_id', \Magento\Store\Model\Store::DEFAULT_STORE_ID) + $storeId ); $currencyCode = $store->getBaseCurrency()->getCurrencyCode(); } diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleAndVerifyRuleConditionAndFreeShippingIsAppliedTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleAndVerifyRuleConditionAndFreeShippingIsAppliedTest.xml index 88853b2c40d9a..96da616818ae1 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleAndVerifyRuleConditionAndFreeShippingIsAppliedTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleAndVerifyRuleConditionAndFreeShippingIsAppliedTest.xml @@ -107,6 +107,8 @@ <argument name="total" value="$280.00"/> </actionGroup> <see selector="{{CheckoutCartSummarySection.shipping}}" userInput="$0.00" stepKey="seeAssertFreeShippingConditionApplied"/> - <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$280.00" stepKey="seeAssertDiscountAmountAppliedForMatchingItemsConditionIsTrue"/> + <actionGroup ref="AssertStorefrontCartDiscountActionGroup" stepKey="seeAssertDiscountAmountAppliedForMatchingItemsConditionIsTrue"> + <argument name="discount" value="280.00"/> + </actionGroup> </test> </tests> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleEmptyFromDateTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleEmptyFromDateTest.xml index e206633808057..65bb0b4cbfb99 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleEmptyFromDateTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleEmptyFromDateTest.xml @@ -87,8 +87,10 @@ <argument name="coupon" value="_defaultCoupon"/> </actionGroup> <waitForPageLoad stepKey="waitForProductPageLoad2"/> - <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/> - <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$5.00" stepKey="seeDiscountTotal"/> + <comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="waitForDiscountElement"/> + <actionGroup ref="AssertStorefrontCartDiscountActionGroup" stepKey="seeDiscountTotal"> + <argument name="discount" value="5.00"/> + </actionGroup> <!--Reset timezone--> <actionGroup ref="AdminOpenGeneralConfigurationPageActionGroup" stepKey="goToGeneralConfigReset"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForCouponCodeTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForCouponCodeTest.xml index 16af210066997..198ba1cd64f35 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForCouponCodeTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForCouponCodeTest.xml @@ -80,7 +80,9 @@ <argument name="coupon" value="_defaultCoupon"/> </actionGroup> <waitForPageLoad stepKey="waitForProductPageLoad2"/> - <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/> - <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$5.00" stepKey="seeDiscountTotal"/> + <comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="waitForDiscountElement"/> + <actionGroup ref="AssertStorefrontCartDiscountActionGroup" stepKey="seeDiscountTotal"> + <argument name="discount" value="5.00"/> + </actionGroup> </test> </tests> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml index b3d81cea7f97f..bc2f115b46873 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForGeneratedCouponTest.xml @@ -84,7 +84,9 @@ <waitForElementVisible selector="{{StorefrontSalesRuleCartCouponSection.couponField}}" stepKey="waitForCouponField" /> <fillField selector="{{StorefrontSalesRuleCartCouponSection.couponField}}" userInput="{$grabCouponCode}" stepKey="fillCouponField"/> <click selector="{{StorefrontSalesRuleCartCouponSection.applyButton}}" stepKey="clickApplyButton"/> - <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/> - <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$0.99" stepKey="seeDiscountTotal"/> + <comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="waitForDiscountElement"/> + <actionGroup ref="AssertStorefrontCartDiscountActionGroup" stepKey="seeDiscountTotal"> + <argument name="discount" value="0.99"/> + </actionGroup> </test> </tests> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForMatchingSubtotalAndVerifyRuleConditionIsAppliedTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForMatchingSubtotalAndVerifyRuleConditionIsAppliedTest.xml index da8c8e4bc1f9d..1fe97b1f45036 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForMatchingSubtotalAndVerifyRuleConditionIsAppliedTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleForMatchingSubtotalAndVerifyRuleConditionIsAppliedTest.xml @@ -116,6 +116,8 @@ <argument name="shippingMethod" value="Flat Rate - Fixed"/> <argument name="total" value="$285.00"/> </actionGroup> - <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$280.00" stepKey="seeAssertDiscountAmountAppliedForSubtotalConditionIsTrue"/> + <actionGroup ref="AssertStorefrontCartDiscountActionGroup" stepKey="seeAssertDiscountAmountAppliedForSubtotalConditionIsTrue"> + <argument name="discount" value="280.00"/> + </actionGroup> </test> </tests> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingCategoryAndVerifyRuleConditionIsAppliedTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingCategoryAndVerifyRuleConditionIsAppliedTest.xml index f6e736c73db74..c80f43385d166 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingCategoryAndVerifyRuleConditionIsAppliedTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingCategoryAndVerifyRuleConditionIsAppliedTest.xml @@ -118,6 +118,8 @@ <argument name="shippingMethod" value="Flat Rate - Fixed"/> <argument name="total" value="$66.50"/> </actionGroup> - <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$61.50" stepKey="seeAssertDiscountAmountAppliedForMatchingCategory"/> + <actionGroup ref="AssertStorefrontCartDiscountActionGroup" stepKey="seeAssertDiscountAmountAppliedForMatchingCategory"> + <argument name="discount" value="61.50"/> + </actionGroup> </test> </tests> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingTotalWeightAndVerifyRuleConditionIsAppliedTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingTotalWeightAndVerifyRuleConditionIsAppliedTest.xml index 5f110f7074f6f..cd72ec8529816 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingTotalWeightAndVerifyRuleConditionIsAppliedTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateCartPriceRuleWithMatchingTotalWeightAndVerifyRuleConditionIsAppliedTest.xml @@ -106,6 +106,8 @@ <argument name="shippingMethod" value="Flat Rate - Fixed"/> <argument name="total" value="$285.00"/> </actionGroup> - <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$280.00" stepKey="seeAssertDiscountAmountAppliedForWeightConditionIsTrue"/> + <actionGroup ref="AssertStorefrontCartDiscountActionGroup" stepKey="seeAssertDiscountAmountAppliedForWeightConditionIsTrue"> + <argument name="discount" value="280.00"/> + </actionGroup> </test> </tests> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleCountryTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleCountryTest.xml index ea96fa41e5cad..3b54df544210f 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleCountryTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleCountryTest.xml @@ -77,8 +77,10 @@ <!-- See discount if we use valid country --> <selectOption selector="{{CheckoutCartSummarySection.country}}" userInput="Brazil" stepKey="fillCountry"/> <waitForPageLoad stepKey="waitForCountry1"/> - <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/> - <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$9.99" stepKey="seeDiscountTotal"/> + <comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="waitForDiscountElement"/> + <actionGroup ref="AssertStorefrontCartDiscountActionGroup" stepKey="seeDiscountTotal"> + <argument name="discount" value="9.99"/> + </actionGroup> <!-- Do not see discount with other country --> <selectOption selector="{{CheckoutCartSummarySection.country}}" userInput="United States" stepKey="fillCountry2"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRulePostcodeTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRulePostcodeTest.xml index 62c494b988bbd..d0cba156f635e 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRulePostcodeTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRulePostcodeTest.xml @@ -81,8 +81,10 @@ <!-- See discount if we use valid postcode --> <fillField selector="{{CheckoutCartSummarySection.postcode}}" userInput="78613" stepKey="fillPostcode"/> <waitForPageLoad stepKey="waitForPostcode1"/> - <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/> - <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$9.99" stepKey="seeDiscountTotal"/> + <comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="waitForDiscountElement"/> + <actionGroup ref="AssertStorefrontCartDiscountActionGroup" stepKey="seeDiscountTotal"> + <argument name="discount" value="9.99"/> + </actionGroup> <!-- Do not see discount with other postcode --> <fillField selector="{{CheckoutCartSummarySection.postcode}}" userInput="90210" stepKey="fillPostcode2"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleQuantityTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleQuantityTest.xml index 70ed09df7a2cc..1a449017e0386 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleQuantityTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleQuantityTest.xml @@ -83,7 +83,9 @@ <!-- Now we should see the discount because we have more than 1 item --> <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage2"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$246.00" stepKey="seeSubtotal2"/> - <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/> - <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$1.00" stepKey="seeDiscountTotal"/> + <comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="waitForDiscountElement"/> + <actionGroup ref="AssertStorefrontCartDiscountActionGroup" stepKey="seeDiscountTotal"> + <argument name="discount" value="1.00"/> + </actionGroup> </test> </tests> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleStateTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleStateTest.xml index da9ca9055d31b..68f6fc93eab94 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleStateTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleStateTest.xml @@ -77,8 +77,10 @@ <!-- See discount if we use valid postcode --> <selectOption selector="{{CheckoutCartSummarySection.stateProvince}}" userInput="Indiana" stepKey="fillState"/> <waitForPageLoad stepKey="waitForPostcode1"/> - <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/> - <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$9.99" stepKey="seeDiscountTotal"/> + <comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="waitForDiscountElement"/> + <actionGroup ref="AssertStorefrontCartDiscountActionGroup" stepKey="seeDiscountTotal"> + <argument name="discount" value="9.99"/> + </actionGroup> <!-- Do not see discount with other postcode --> <selectOption selector="{{CheckoutCartSummarySection.stateProvince}}" userInput="Texas" stepKey="fillState2"/> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleSubtotalTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleSubtotalTest.xml index ce0d814e50308..0ffe1516d0232 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleSubtotalTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartPriceRuleSubtotalTest.xml @@ -81,7 +81,9 @@ <!-- Now we should see the discount because we exceeded $200 --> <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="goToCartPage2"/> <see selector="{{CheckoutCartSummarySection.subtotal}}" userInput="$246.00" stepKey="seeSubtotal2"/> - <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForDiscountElement"/> - <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$0.01" stepKey="seeDiscountTotal"/> + <comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="waitForDiscountElement"/> + <actionGroup ref="AssertStorefrontCartDiscountActionGroup" stepKey="seeDiscountTotal"> + <argument name="discount" value="0.01"/> + </actionGroup> </test> </tests> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml index 1178ca2cfb328..8df45937bb542 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml @@ -117,8 +117,10 @@ <actionGroup ref="StorefrontCartPageOpenActionGroup" stepKey="amOnPageShoppingCart"/> <waitForElementVisible selector="{{CheckoutCartSummarySection.orderTotal}}" stepKey="waitForOrderTotalVisible"/> <selectOption selector="{{CheckoutCartSummarySection.country}}" userInput="United States" stepKey="selectCountry"/> - <waitForElementVisible selector="{{CheckoutCartSummarySection.discountAmount}}" stepKey="waitForOrderTotalUpdate"/> - <see selector="{{CheckoutCartSummarySection.discountAmount}}" userInput="-$29.00" stepKey="seeDiscountAmount"/> + <comment userInput="Adding the comment to replace action for preserving Backward Compatibility" stepKey="waitForOrderTotalUpdate"/> + <actionGroup ref="AssertStorefrontCartDiscountActionGroup" stepKey="seeDiscountAmount"> + <argument name="discount" value="29.00"/> + </actionGroup> <see selector="{{CheckoutCartSummarySection.subTotal}}" userInput="$29.00" stepKey="seeSubTotal"/> <see selector="{{CheckoutCartSummarySection.orderTotal}}" userInput="0.00" stepKey="seeOrderTotal"/> </test> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateDefaultsTaxRuleTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateDefaultsTaxRuleTest.xml index 5e7ce53a3a3fc..2f418dddf3884 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateDefaultsTaxRuleTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateDefaultsTaxRuleTest.xml @@ -42,7 +42,7 @@ <see selector="{{AdminTaxRuleGridSection.successMessage}}" userInput="You saved the tax rule." stepKey="assertTaxRuleSuccessMessage" /> <!-- Verify we see created tax rule with defaults(from the above step) on the tax rule grid page --> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRuleGridSection.code}}" userInput="{{SimpleTaxRule.code}}" stepKey="fillTaxRuleCode2"/> <click selector="{{AdminTaxRuleGridSection.search}}" stepKey="clickSearch2"/> <waitForPageLoad stepKey="waitForTaxRuleSearch" /> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml index ceb04a9c42e66..7fa1daeb063ca 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml @@ -43,7 +43,7 @@ <!-- Verify the tax rate grid page shows the tax rate we just created --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex2"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters1"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters1"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{SimpleTaxRate.code}}" stepKey="fillNameFilter"/> <selectOption selector="{{AdminTaxRateGridSection.filterByCountry}}" userInput="Australia" stepKey="fillCountryFilter"/> <fillField selector="{{AdminTaxRateGridSection.filterByPostCode}}" userInput="*" stepKey="fillPostCodeFilter"/> @@ -54,7 +54,7 @@ <!-- Go to the tax rate edit page for our new tax rate --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex3"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{SimpleTaxRate.code}}" stepKey="fillNameFilter2"/> <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch2"/> <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml index 7497b950a8c0e..e189e45483197 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml @@ -45,7 +45,7 @@ <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex2"/> <!-- Create a tax rate for large postcodes and verify we see expected values on the tax rate grid page --> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{SimpleTaxRate.code}}" stepKey="fillTaxIdentifierField2"/> <selectOption selector="{{AdminTaxRateGridSection.filterByCountry}}" userInput="France" stepKey="selectCountry2" /> <fillField selector="{{AdminTaxRateGridSection.filterByPostCode}}" userInput="*" stepKey="seeTaxPostCode1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml index da89ad3e9337c..9a5566c2db881 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml @@ -45,7 +45,7 @@ <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex2"/> <!-- Verify the tax rate grid page shows the specific postcode we just created --> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters1"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters1"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{SimpleTaxRate.code}}" stepKey="fillTaxIdentifierField2"/> <selectOption selector="{{AdminTaxRateGridSection.filterByCountry}}" userInput="Canada" stepKey="fillCountryFilter"/> <fillField selector="{{AdminTaxRateGridSection.filterByPostCode}}" userInput="180" stepKey="fillPostCodeFilter"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml index da30157d94182..48217628b927a 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml @@ -45,7 +45,7 @@ <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex2"/> <!-- Create a tax rate for zipCodeRange and verify we see expected values on the tax rate grid page --> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{SimpleTaxRate.code}}" stepKey="fillTaxIdentifierField2"/> <selectOption selector="{{AdminTaxRateGridSection.filterByCountry}}" userInput="United Kingdom" stepKey="selectCountry2" /> <fillField selector="{{AdminTaxRateGridSection.filterByPostCode}}" userInput="1-7800935" stepKey="seeTaxPostCode1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml index 93e0f6514e83b..d237e52a60472 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml @@ -46,7 +46,7 @@ <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex2"/> <!-- Create a tax rate for zipCodeRange and verify we see expected values on the tax rate grid page --> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{SimpleTaxRate.code}}" stepKey="fillTaxIdentifierField2"/> <selectOption selector="{{AdminTaxRateGridSection.filterByCountry}}" userInput="United States" stepKey="selectCountry2" /> <fillField selector="{{AdminTaxRateGridSection.filterByPostCode}}" userInput="90001-96162" stepKey="seeTaxPostCode1"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithCustomerAndProductTaxClassTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithCustomerAndProductTaxClassTest.xml index f1a48af741cd6..5ae2742ad21fb 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithCustomerAndProductTaxClassTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithCustomerAndProductTaxClassTest.xml @@ -68,7 +68,7 @@ <see selector="{{AdminTaxRuleGridSection.successMessage}}" userInput="You saved the tax rule." stepKey="seeAssertTaxRuleSuccessMessage"/> <!-- Verify we see created tax rule with customer and product class(from the above step) on the tax rule grid page --> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRuleGridSection.code}}" userInput="{{SimpleTaxRule.code}}" stepKey="fillTaxRuleCode2"/> <click selector="{{AdminTaxRuleGridSection.search}}" stepKey="clickSearch2"/> <waitForPageLoad stepKey="waitForTaxRuleSearch"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewAndExistingTaxRateAndCustomerAndProductTaxClassTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewAndExistingTaxRateAndCustomerAndProductTaxClassTest.xml index de7a0fb2d9144..21f8b844adb58 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewAndExistingTaxRateAndCustomerAndProductTaxClassTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewAndExistingTaxRateAndCustomerAndProductTaxClassTest.xml @@ -63,7 +63,7 @@ <see selector="{{AdminTaxRuleGridSection.successMessage}}" userInput="You saved the tax rule." stepKey="seeAssertTaxRuleSuccessMessage"/> <!-- Verify we see created tax rule with new and existing tax rate, customer tax class, product tax class(from the above step) on the tax rule grid page --> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRuleGridSection.code}}" userInput="{{SimpleTaxRule.code}}" stepKey="fillTaxRuleCode2"/> <click selector="{{AdminTaxRuleGridSection.search}}" stepKey="clickSearch2"/> <waitForPageLoad stepKey="waitForTaxRuleSearch"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewTaxClassesAndTaxRateTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewTaxClassesAndTaxRateTest.xml index 4798ec60ab898..25b919722ced9 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewTaxClassesAndTaxRateTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithNewTaxClassesAndTaxRateTest.xml @@ -67,7 +67,7 @@ <see selector="{{AdminTaxRuleGridSection.successMessage}}" userInput="You saved the tax rule." stepKey="seeAssertTaxRuleSuccessMessage"/> <!-- Verify we see created tax rule with new tax classes and tax rate(from the above step) on the tax rule grid page --> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRuleGridSection.code}}" userInput="{{SimpleTaxRule.code}}" stepKey="fillTaxRuleCode2"/> <click selector="{{AdminTaxRuleGridSection.search}}" stepKey="clickSearch2"/> <waitForPageLoad stepKey="waitForTaxRuleSearch"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithZipRangeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithZipRangeTest.xml index a08c878ba2063..7ba6caf5402b1 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithZipRangeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRuleWithZipRangeTest.xml @@ -65,7 +65,7 @@ <see selector="{{AdminTaxRuleGridSection.successMessage}}" userInput="You saved the tax rule." stepKey="seeAssertTaxRuleSuccessMessage"/> <!-- Verify we see created tax rule with zip range(from the above step) on the tax rule grid page --> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRuleGridSection.code}}" userInput="{{SimpleTaxRule.code}}" stepKey="fillTaxRuleCode2"/> <click selector="{{AdminTaxRuleGridSection.search}}" stepKey="clickSearch2"/> <waitForPageLoad stepKey="waitForTaxRuleSearch"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminDeleteTaxRuleTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminDeleteTaxRuleTest.xml index 37b90300aad28..2fde2e2cd02d0 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminDeleteTaxRuleTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminDeleteTaxRuleTest.xml @@ -31,7 +31,7 @@ </after> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex1"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters1"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters1"/> <fillField selector="{{AdminTaxRuleGridSection.code}}" userInput="$$initialTaxRule.code$$" stepKey="fillTaxCodeSearch"/> <click selector="{{AdminTaxRuleGridSection.search}}" stepKey="clickSearch1"/> <click selector="{{AdminTaxRuleGridSection.nthRow('1')}}" stepKey="clickFirstRow1"/> @@ -46,7 +46,7 @@ <!-- Confirm Deleted Tax Rule(from the above step) on the tax rule grid page --> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex2"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRuleGridSection.code}}" userInput="$$initialTaxRule.code$$" stepKey="fillTaxCodeSearch2"/> <click selector="{{AdminTaxRuleGridSection.search}}" stepKey="clickSearch2"/> <see selector="{{AdminTaxRuleGridSection.emptyText}}" userInput="We couldn't find any records." stepKey="seeAssertTaxRuleNotFound"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminUpdateDefaultTaxRuleTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminUpdateDefaultTaxRuleTest.xml index fd445326976e4..addd8d2832417 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminUpdateDefaultTaxRuleTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminUpdateDefaultTaxRuleTest.xml @@ -39,7 +39,7 @@ </after> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex1"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters1"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters1"/> <fillField selector="{{AdminTaxRuleGridSection.code}}" userInput="$$initialTaxRule.code$$" stepKey="fillTaxCodeSearch"/> <click selector="{{AdminTaxRuleGridSection.search}}" stepKey="clickSearch1"/> <click selector="{{AdminTaxRuleGridSection.nthRow('1')}}" stepKey="clickFirstRow1"/> @@ -64,7 +64,7 @@ <see selector="{{AdminTaxRuleGridSection.successMessage}}" userInput="You saved the tax rule." stepKey="seeAssertTaxRuleSuccessMessage"/> <!-- Verify we see updated tax rule with default(from the above step) on the tax rule grid page --> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRuleGridSection.code}}" userInput="{{SimpleTaxRule.code}}" stepKey="fillTaxRuleCode2"/> <click selector="{{AdminTaxRuleGridSection.search}}" stepKey="clickSearch2"/> <waitForPageLoad stepKey="waitForTaxRuleSearch"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminUpdateTaxRuleWithCustomClassesTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminUpdateTaxRuleWithCustomClassesTest.xml index 3a5607ea598ca..65945f80048ad 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminUpdateTaxRuleWithCustomClassesTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminUpdateTaxRuleWithCustomClassesTest.xml @@ -40,7 +40,7 @@ </after> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex1"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters1"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters1"/> <fillField selector="{{AdminTaxRuleGridSection.code}}" userInput="$$initialTaxRule.code$$" stepKey="fillTaxCodeSearch"/> <click selector="{{AdminTaxRuleGridSection.search}}" stepKey="clickSearch1"/> <click selector="{{AdminTaxRuleGridSection.nthRow('1')}}" stepKey="clickFirstRow1"/> @@ -62,7 +62,7 @@ <see selector="{{AdminTaxRuleGridSection.successMessage}}" userInput="You saved the tax rule." stepKey="seeAssertTaxRuleSuccessMessage"/> <!-- Verify we see updated tax rule with default(from the above step) on the tax rule grid page --> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRuleGridSection.code}}" userInput="{{SimpleTaxRule.code}}" stepKey="fillTaxRuleCode2"/> <click selector="{{AdminTaxRuleGridSection.search}}" stepKey="clickSearch2"/> <waitForPageLoad stepKey="waitForTaxRuleSearch"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminUpdateTaxRuleWithFixedZipUtahTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminUpdateTaxRuleWithFixedZipUtahTest.xml index fa42ce5ddafa3..c208912654fdb 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminUpdateTaxRuleWithFixedZipUtahTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminUpdateTaxRuleWithFixedZipUtahTest.xml @@ -44,7 +44,7 @@ </after> <actionGroup ref="AdminTaxRuleGridOpenPageActionGroup" stepKey="goToTaxRuleIndex1"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters1"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters1"/> <fillField selector="{{AdminTaxRuleGridSection.code}}" userInput="$$initialTaxRule.code$$" stepKey="fillTaxCodeSearch"/> <click selector="{{AdminTaxRuleGridSection.search}}" stepKey="clickSearch1"/> <click selector="{{AdminTaxRuleGridSection.nthRow('1')}}" stepKey="clickFirstRow1"/> @@ -66,7 +66,7 @@ <see selector="{{AdminTaxRuleGridSection.successMessage}}" userInput="You saved the tax rule." stepKey="seeAssertTaxRuleSuccessMessage"/> <!-- Verify we see updated tax rule with fixed zip Utah(from the above step) on the tax rule grid page --> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRuleGridSection.code}}" userInput="{{SimpleTaxRule.code}}" stepKey="fillTaxRuleCode2"/> <click selector="{{AdminTaxRuleGridSection.search}}" stepKey="clickSearch2"/> <waitForPageLoad stepKey="waitForTaxRuleSearch"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml index 751989497d10e..3abdb45faf95a 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml @@ -36,7 +36,7 @@ <!-- Confirm Deleted TaxIdentifier(from the above step) on the tax rate grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex2"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{defaultTaxRate.code}}" stepKey="fillTaxIdentifierField3"/> <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch2"/> <see selector="{{AdminTaxRateGridSection.emptyText}}" userInput="We couldn't find any records." stepKey="seeSuccess"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/Update01TaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/Update01TaxRateEntityTest.xml index ff75b1e95646a..b102b4d945019 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/Update01TaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/Update01TaxRateEntityTest.xml @@ -28,7 +28,7 @@ <!-- Search the tax rate on tax grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters1"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters1"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="$$initialTaxRate.code$$" stepKey="fillCode"/> <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch1"/> <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow1"/> @@ -45,7 +45,7 @@ <!-- Verify we see updated 0.1 tax rate(from the above step) on the tax rate grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex4"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{taxRateCustomRateFrance.code}}" stepKey="fillTaxIdentifierField3"/> <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch2"/> <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow2"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/Update100TaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/Update100TaxRateEntityTest.xml index ebfa1288b59dd..115a1df4631e5 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/Update100TaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/Update100TaxRateEntityTest.xml @@ -28,7 +28,7 @@ <!-- Search the tax rate on tax grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters1"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters1"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="$$initialTaxRate.code$$" stepKey="fillCode"/> <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch1"/> <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow1"/> @@ -44,7 +44,7 @@ <!-- Verify we see updated TaxIdentifier(from the above step) on the tax rate grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex4"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{taxRateCustomRateUS.code}}" stepKey="fillTaxIdentifierField3"/> <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch2"/> <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow2"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/Update1299TaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/Update1299TaxRateEntityTest.xml index ed1c126930df8..5594cf58e7b21 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/Update1299TaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/Update1299TaxRateEntityTest.xml @@ -28,7 +28,7 @@ <!-- Search the tax identifier on tax grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters1"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters1"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="$$initialTaxRate.code$$" stepKey="fillCode1"/> <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch1"/> <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow1"/> @@ -45,7 +45,7 @@ <!-- Verify we see updated tax rate(from the above step) on the tax rate grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex2"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{taxRateCustomRateUK.code}}" stepKey="fillTaxIdentifierField2"/> <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch2"/> <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow2"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/UpdateAnyRegionTaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/UpdateAnyRegionTaxRateEntityTest.xml index 7a2f0664d7757..da531ea373aa1 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/UpdateAnyRegionTaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/UpdateAnyRegionTaxRateEntityTest.xml @@ -28,7 +28,7 @@ <!-- Search the tax rate on tax grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters1"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters1"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="$$initialTaxRate.code$$" stepKey="fillCode"/> <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch1"/> <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow1"/> @@ -44,7 +44,7 @@ <!-- Verify we see updated any region tax rate(from the above step) on the tax rate grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex2"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{taxRateCustomRateCanada.code}}" stepKey="fillTaxIdentifierField3"/> <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch2"/> <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow2"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/UpdateDecimalTaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/UpdateDecimalTaxRateEntityTest.xml index 03aba8da8ae19..717d9b9428267 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/UpdateDecimalTaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/UpdateDecimalTaxRateEntityTest.xml @@ -28,7 +28,7 @@ <!-- Search the tax rate on tax grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters1"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters1"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="$$initialTaxRate.code$$" stepKey="fillCode"/> <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch1"/> <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow1"/> @@ -46,7 +46,7 @@ <!-- Verify we see updated tax rate(from the above step) on the tax rate grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex2"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{defaultTaxRateWithZipRange.code}}" stepKey="fillTaxIdentifierField3"/> <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch2"/> <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow2"/> diff --git a/app/code/Magento/Tax/Test/Mftf/Test/UpdateLargeTaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/UpdateLargeTaxRateEntityTest.xml index 37b8bb8d95618..b664d334162ed 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/UpdateLargeTaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/UpdateLargeTaxRateEntityTest.xml @@ -28,7 +28,7 @@ <!-- Search the tax rate on tax grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex1"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters1"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters1"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="$$initialTaxRate.code$$" stepKey="fillCode"/> <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch1"/> <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow1"/> @@ -43,7 +43,7 @@ <!-- Verify we see updated large tax rate(from the above step) on the tax rate grid page --> <actionGroup ref="AdminTaxRateGridOpenPageActionGroup" stepKey="goToTaxRateIndex4"/> - <click selector="{{AdminDataGridHeaderSection.clearFilters}}" stepKey="clickClearFilters2"/> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <fillField selector="{{AdminTaxRateGridSection.filterByTaxIdentifier}}" userInput="{{defaultTaxRateWithLargeRate.code}}" stepKey="fillTaxIdentifierField3"/> <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch2"/> <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow2"/> diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/date.js b/app/code/Magento/Ui/view/base/web/js/form/element/date.js index af9142745206b..a5447b290fc5d 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/date.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/date.js @@ -124,7 +124,7 @@ define([ var shiftedValue; if (value) { - if (this.options.showsTime) { + if (this.options.showsTime && !this.options.timeOnly) { shiftedValue = moment.tz(value, 'UTC').tz(this.storeTimeZone); } else { shiftedValue = moment(value, this.outputDateFormat, true); @@ -157,7 +157,7 @@ define([ if (shiftedValue) { momentValue = moment(shiftedValue, this.pickerDateTimeFormat); - if (this.options.showsTime) { + if (this.options.showsTime && !this.options.timeOnly) { formattedValue = moment(momentValue).format(this.timezoneFormat); value = moment.tz(formattedValue, this.storeTimeZone).tz('UTC').toISOString(); } else { @@ -177,10 +177,14 @@ define([ * with moment.js library. */ prepareDateTimeFormats: function () { - this.pickerDateTimeFormat = this.options.dateFormat; + if (this.options.timeOnly) { + this.pickerDateTimeFormat = this.options.timeFormat; + } else { + this.pickerDateTimeFormat = this.options.dateFormat; - if (this.options.showsTime) { - this.pickerDateTimeFormat += ' ' + this.options.timeFormat; + if (this.options.showsTime) { + this.pickerDateTimeFormat += ' ' + this.options.timeFormat; + } } this.pickerDateTimeFormat = utils.convertToMomentFormat(this.pickerDateTimeFormat); @@ -189,8 +193,12 @@ define([ this.outputDateFormat = this.options.dateFormat; } - this.inputDateFormat = utils.convertToMomentFormat(this.inputDateFormat); - this.outputDateFormat = utils.convertToMomentFormat(this.outputDateFormat); + this.inputDateFormat = this.options.timeOnly ? + utils.convertToMomentFormat(this.pickerDefaultTimeFormat) : + utils.convertToMomentFormat(this.inputDateFormat); + this.outputDateFormat = this.options.timeOnly ? + utils.convertToMomentFormat(this.options.timeFormat) : + utils.convertToMomentFormat(this.outputDateFormat); this.validationParams.dateFormat = this.outputDateFormat; } diff --git a/app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/datepicker.js b/app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/datepicker.js index 284d395d8120b..ff09835df61f3 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/datepicker.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/datepicker.js @@ -87,8 +87,10 @@ define([ ).toDate(); } - $element.datepicker('setDate', newVal); - $element.blur(); + if (!options.timeOnly) { + $element.datepicker('setDate', newVal); + $element.blur(); + } }); } }; diff --git a/app/code/Magento/Ups/Model/Carrier.php b/app/code/Magento/Ups/Model/Carrier.php index 452f488050202..24904ae79abb0 100644 --- a/app/code/Magento/Ups/Model/Carrier.php +++ b/app/code/Magento/Ups/Model/Carrier.php @@ -807,21 +807,24 @@ protected function _getXmlQuotes() $httpResponse = $this->asyncHttpClient->request( new Request($url, Request::METHOD_POST, ['Content-Type' => 'application/xml'], $xmlRequest) ); - + $debugData['request'] = $xmlParams; return $this->deferredProxyFactory->create( [ 'deferred' => new CallbackDeferred( - function () use ($httpResponse) { + function () use ($httpResponse, $debugData) { $responseResult = null; $xmlResponse = ''; try { $responseResult = $httpResponse->get(); - } catch (HttpException $exception) { - $this->_logger->critical($exception); + } catch (HttpException $e) { + $debugData['result'] = ['error' => $e->getMessage(), 'code' => $e->getCode()]; + $this->_logger->critical($e); } if ($responseResult) { $xmlResponse = $responseResult->getStatusCode() >= 400 ? '' : $responseResult->getBody(); } + $debugData['result'] = $xmlResponse; + $this->_debug($debugData); return $this->_parseXmlResponse($xmlResponse); } @@ -1125,6 +1128,7 @@ protected function _getXmlTracking($trackings) /** @var HttpResponseDeferredInterface[] $trackingResponses */ $trackingResponses = []; $tracking = ''; + $debugData = []; foreach ($trackings as $tracking) { /** * RequestOption==>'1' to request all activities @@ -1141,7 +1145,7 @@ protected function _getXmlTracking($trackings) <IncludeFreight>01</IncludeFreight> </TrackRequest> XMLAuth; - + $debugData[$tracking] = ['request' => $this->filterDebugData($this->_xmlAccessRequest) . $xmlRequest]; $trackingResponses[$tracking] = $this->asyncHttpClient->request( new Request( $url, @@ -1155,6 +1159,8 @@ protected function _getXmlTracking($trackings) $httpResponse = $response->get(); $xmlResponse = $httpResponse->getStatusCode() >= 400 ? '' : $httpResponse->getBody(); + $debugData[$tracking]['result'] = $xmlResponse; + $this->_debug($debugData); $this->_parseXmlTrackingResponse($tracking, $xmlResponse); } diff --git a/app/code/Magento/Weee/Model/Total/Quote/WeeeTax.php b/app/code/Magento/Weee/Model/Total/Quote/WeeeTax.php index c6825958d2178..7429f875eda98 100644 --- a/app/code/Magento/Weee/Model/Total/Quote/WeeeTax.php +++ b/app/code/Magento/Weee/Model/Total/Quote/WeeeTax.php @@ -5,8 +5,11 @@ */ namespace Magento\Weee\Model\Total\Quote; +use Magento\Quote\Api\Data\ShippingAssignmentInterface; +use Magento\Quote\Model\Quote; +use Magento\Quote\Model\Quote\Address; +use Magento\Quote\Model\Quote\Address\Total; use Magento\Quote\Model\Quote\Address\Total\AbstractTotal; -use Magento\Store\Model\Store; use Magento\Tax\Model\Sales\Total\Quote\CommonTaxCollector; class WeeeTax extends Weee @@ -14,19 +17,19 @@ class WeeeTax extends Weee /** * Collect Weee taxes amount and prepare items prices for taxation and discount * - * @param \Magento\Quote\Model\Quote $quote - * @param \Magento\Quote\Api\Data\ShippingAssignmentInterface|\Magento\Quote\Model\Quote\Address $shippingAssignment - * @param \Magento\Quote\Model\Quote\Address\Total $total + * @param Quote $quote + * @param ShippingAssignmentInterface|Address $shippingAssignment + * @param Total $total * @return $this * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function collect( - \Magento\Quote\Model\Quote $quote, - \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment, - \Magento\Quote\Model\Quote\Address\Total $total + Quote $quote, + ShippingAssignmentInterface $shippingAssignment, + Total $total ) { - \Magento\Quote\Model\Quote\Address\Total\AbstractTotal::collect($quote, $shippingAssignment, $total); + AbstractTotal::collect($quote, $shippingAssignment, $total); $this->_store = $quote->getStore(); if (!$this->weeeData->isEnabled($this->_store)) { return $this; @@ -65,13 +68,12 @@ public function collect( $weeeCodeToWeeeTaxDetailsMap[$weeeCode] = $weeeTaxDetails; } } - + $productTaxes = []; //Process each item that has taxable weee foreach ($itemToWeeeCodeMap as $mapping) { $item = $mapping['item']; $this->weeeData->setApplied($item, []); - $productTaxes = []; $totalValueInclTax = 0; $baseTotalValueInclTax = 0; @@ -113,15 +115,17 @@ public function collect( $baseTotalRowValueExclTax += $baseRowValueExclTax; $productTaxes[] = [ - 'title' => $attributeCode, //TODO: fix this - 'base_amount' => $baseValueExclTax, - 'amount' => $valueExclTax, - 'row_amount' => $rowValueExclTax, - 'base_row_amount' => $baseRowValueExclTax, - 'base_amount_incl_tax' => $baseValueInclTax, - 'amount_incl_tax' => $valueInclTax, - 'row_amount_incl_tax' => $rowValueInclTax, - 'base_row_amount_incl_tax' => $baseRowValueInclTax, + [ + 'title' => $attributeCode, //TODO: fix this + 'base_amount' => $baseValueExclTax, + 'amount' => $valueExclTax, + 'row_amount' => $rowValueExclTax, + 'base_row_amount' => $baseRowValueExclTax, + 'base_amount_incl_tax' => $baseValueInclTax, + 'amount_incl_tax' => $valueInclTax, + 'row_amount_incl_tax' => $rowValueInclTax, + 'base_row_amount_incl_tax' => $baseRowValueInclTax, + ], ]; } @@ -143,8 +147,11 @@ public function collect( $baseTotalRowValueInclTax ); - $this->weeeData->setApplied($item, array_merge($this->weeeData->getApplied($item), $productTaxes)); } + $this->weeeData->setApplied( + $item, + array_merge($this->weeeData->getApplied($item), ...$productTaxes) + ); } return $this; } @@ -196,7 +203,7 @@ protected function createItemToWeeeCodeMapping($weeeCodeToItemMap) /** * Process row amount based on FPT total amount configuration setting * - * @param \Magento\Quote\Model\Quote\Address\Total $total + * @param Total $total * @param float $rowValueExclTax * @param float $baseRowValueExclTax * @param float $rowValueInclTax @@ -226,14 +233,13 @@ protected function processTotalAmount( /** * Fetch the Weee total amount for display in totals block when building the initial quote * - * @param \Magento\Quote\Model\Quote $quote - * @param \Magento\Quote\Model\Quote\Address\Total $total + * @param Quote $quote + * @param Total $total * @return array */ - public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total) + public function fetch(Quote $quote, Total $total) { - /** @var $items \Magento\Sales\Model\Order\Item[] */ - $items = isset($total['address_quote_items']) ? $total['address_quote_items'] : []; + $items = $total['quote_items'] ?? []; $weeeTotal = $this->weeeData->getTotalAmounts($items, $quote->getStore()); if ($weeeTotal) { diff --git a/app/code/Magento/Widget/Test/Mftf/Test/NewProductsListWidgetTest.xml b/app/code/Magento/Widget/Test/Mftf/Test/NewProductsListWidgetTest.xml index 04218c76a4b7b..ef9093667d479 100644 --- a/app/code/Magento/Widget/Test/Mftf/Test/NewProductsListWidgetTest.xml +++ b/app/code/Magento/Widget/Test/Mftf/Test/NewProductsListWidgetTest.xml @@ -34,7 +34,7 @@ <amOnPage url="{{CmsPagesPage.url}}" stepKey="amOnCmsList"/> <waitForPageLoad stepKey="waitForCmsList"/> - <click selector="{{CmsPagesPageActionsSection.addNewPageButton}}" stepKey="clickAddNewPageButton"/> + <actionGroup ref="AdminClickAddNewPageOnPagesGridActionGroup" stepKey="clickAddNewPageButton"/> <fillField selector="{{CmsNewPagePageBasicFieldsSection.pageTitle}}" userInput="{{_newDefaultCmsPage.title}}" stepKey="fillPageTitle"/> <click selector="{{CmsNewPagePageContentSection.header}}" stepKey="expandContentSection"/> <waitForPageLoad stepKey="waitForContentSection"/> diff --git a/app/code/Magento/Widget/Test/Mftf/Test/ProductsListWidgetTest.xml b/app/code/Magento/Widget/Test/Mftf/Test/ProductsListWidgetTest.xml index 593b0df3f3a02..e9fcdf436d90b 100644 --- a/app/code/Magento/Widget/Test/Mftf/Test/ProductsListWidgetTest.xml +++ b/app/code/Magento/Widget/Test/Mftf/Test/ProductsListWidgetTest.xml @@ -35,7 +35,7 @@ <amOnPage url="{{CmsPagesPage.url}}" stepKey="amOnCmsList"/> <waitForPageLoad stepKey="waitForCmsList"/> <conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/> - <click selector="{{CmsPagesPageActionsSection.addNewPageButton}}" stepKey="clickAddNewPageButton"/> + <actionGroup ref="AdminClickAddNewPageOnPagesGridActionGroup" stepKey="clickAddNewPageButton"/> <fillField selector="{{CmsNewPagePageBasicFieldsSection.pageTitle}}" userInput="{{_newDefaultCmsPage.title}}" stepKey="fillPageTitle"/> <click selector="{{CmsNewPagePageContentSection.header}}" stepKey="expandContentSection"/> <waitForPageLoad stepKey="waitForContentSection"/> diff --git a/app/design/frontend/Magento/blank/web/css/source/_extends.less b/app/design/frontend/Magento/blank/web/css/source/_extends.less index 690b89f42b419..32e18921a1c48 100644 --- a/app/design/frontend/Magento/blank/web/css/source/_extends.less +++ b/app/design/frontend/Magento/blank/web/css/source/_extends.less @@ -51,6 +51,7 @@ display: inline-block; float: left; margin: 0 0 @indent__xs; + word-break: break-all; } }; diff --git a/app/design/frontend/Magento/luma/web/css/source/_extends.less b/app/design/frontend/Magento/luma/web/css/source/_extends.less index 8ae1776daf239..4d5e6f55908da 100644 --- a/app/design/frontend/Magento/luma/web/css/source/_extends.less +++ b/app/design/frontend/Magento/luma/web/css/source/_extends.less @@ -127,6 +127,7 @@ display: inline-block; float: left; margin: 0 0 @indent__xs; + word-break: break-all; } }; diff --git a/dev/tests/api-functional/testsuite/Magento/WebapiAsync/Model/AsyncScheduleMultiStoreTest.php b/dev/tests/api-functional/testsuite/Magento/WebapiAsync/Model/AsyncScheduleMultiStoreTest.php index 3f5d4c70a30ce..b065f638cba0d 100644 --- a/dev/tests/api-functional/testsuite/Magento/WebapiAsync/Model/AsyncScheduleMultiStoreTest.php +++ b/dev/tests/api-functional/testsuite/Magento/WebapiAsync/Model/AsyncScheduleMultiStoreTest.php @@ -8,20 +8,20 @@ namespace Magento\WebapiAsync\Model; -use Magento\Catalog\Api\Data\ProductInterface as Product; -use Magento\TestFramework\MessageQueue\PreconditionFailedException; -use Magento\TestFramework\MessageQueue\PublisherConsumerController; -use Magento\TestFramework\MessageQueue\EnvironmentPreconditionException; -use Magento\TestFramework\TestCase\WebapiAbstract; -use Magento\TestFramework\Helper\Bootstrap; +use Magento\Catalog\Api\Data\ProductInterface; +use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Model\ResourceModel\Product\Collection; +use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Phrase; use Magento\Framework\Registry; use Magento\Framework\Webapi\Exception; -use Magento\Catalog\Api\ProductRepositoryInterface; -use Magento\Framework\ObjectManagerInterface; -use Magento\Store\Model\Store; use Magento\Framework\Webapi\Rest\Request; +use Magento\Store\Model\Store; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\MessageQueue\EnvironmentPreconditionException; +use Magento\TestFramework\MessageQueue\PreconditionFailedException; +use Magento\TestFramework\MessageQueue\PublisherConsumerController; +use Magento\TestFramework\TestCase\WebapiAbstract; /** * Check async request for multistore product creation service, scheduling bulk @@ -86,27 +86,24 @@ class AsyncScheduleMultiStoreTest extends WebapiAbstract */ private $registry; + /** + * @inheritDoc + */ protected function setUp(): void { + $logFilePath = TESTS_TEMP_DIR . "/MessageQueueTestLog.txt"; $this->objectManager = Bootstrap::getObjectManager(); - $this->logFilePath = TESTS_TEMP_DIR . "/MessageQueueTestLog.txt"; $this->registry = $this->objectManager->get(Registry::class); - $params = array_merge_recursive( - Bootstrap::getInstance()->getAppInitParams(), - ['MAGE_DIRS' => ['cache' => ['path' => TESTS_TEMP_DIR . '/cache']]] - ); - - /** @var PublisherConsumerController publisherConsumerController */ $this->publisherConsumerController = $this->objectManager->create( PublisherConsumerController::class, [ 'consumers' => $this->consumers, - 'logFilePath' => $this->logFilePath, - 'appInitParams' => $params, + 'logFilePath' => $logFilePath, + 'appInitParams' => Bootstrap::getInstance()->getAppInitParams(), ] ); - $this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class); + $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class); try { $this->publisherConsumerController->initialize(); @@ -124,21 +121,16 @@ protected function setUp(): void /** * @dataProvider storeProvider * @magentoApiDataFixture Magento/Store/_files/core_fixturestore.php + * @param string|null $storeCode + * @return void */ - public function testAsyncScheduleBulkMultistore($storeCode) + public function testAsyncScheduleBulkMultistore(?string $storeCode): void { - if ($storeCode === self::STORE_CODE_FROM_FIXTURE) { - /** @var \Magento\Config\Model\Config $config */ - $config = Bootstrap::getObjectManager()->get(\Magento\Config\Model\Config::class); - if (strpos($config->getConfigDataValue('catalog/search/engine'), 'elasticsearch') !== false) { - $this->markTestSkipped('MC-20452'); - } - } $product = $this->getProductData(); $this->_markTestAsRestOnly(); /** @var Store $store */ - $store = $this->objectManager->create(Store::class); + $store = $this->objectManager->get(Store::class); $store->load(self::STORE_CODE_FROM_FIXTURE); $this->assertEquals( self::STORE_NAME_FROM_FIXTURE, @@ -147,9 +139,9 @@ public function testAsyncScheduleBulkMultistore($storeCode) ); try { - /** @var Product $productModel */ + /** @var ProductInterface $productModel */ $productModel = $this->objectManager->create( - Product::class, + ProductInterface::class, ['data' => $product['product']] ); $this->productRepository->save($productModel); @@ -161,16 +153,21 @@ public function testAsyncScheduleBulkMultistore($storeCode) $this->clearProducts(); } - private function asyncScheduleAndTest($product, $storeCode = null) + /** + * @param array $product + * @param string|null $storeCode + * @return void + */ + private function asyncScheduleAndTest(array $product, $storeCode = null): void { - $sku = $product['product'][Product::SKU]; - $productName = $product['product'][Product::NAME]; - $newProductName = $product['product'][Product::NAME] . $storeCode; + $sku = $product['product'][ProductInterface::SKU]; + $productName = $product['product'][ProductInterface::NAME]; + $newProductName = $product['product'][ProductInterface::NAME] . $storeCode; $this->skus[] = $sku; - $product['product'][Product::NAME] = $newProductName; - $product['product'][Product::TYPE_ID] = 'virtual'; + $product['product'][ProductInterface::NAME] = $newProductName; + $product['product'][ProductInterface::TYPE_ID] = 'virtual'; $response = $this->updateProductAsync($product, $sku, $storeCode); @@ -197,14 +194,14 @@ private function asyncScheduleAndTest($product, $storeCode = null) $serviceInfo = [ 'rest' => [ 'resourcePath' => self::REST_RESOURCE_PATH . '/' . $sku, - 'httpMethod' => Request::HTTP_METHOD_GET + 'httpMethod' => Request::HTTP_METHOD_GET, ] ]; $storeResponse = $this->_webApiCall($serviceInfo, $requestData, null, $checkingStore); if ($checkingStore == $storeCode || $storeCode == self::STORE_CODE_ALL) { $this->assertEquals( $newProductName, - $storeResponse[Product::NAME], + $storeResponse[ProductInterface::NAME], sprintf( 'Product name in %s store is invalid after updating in store %s.', $checkingStore, @@ -214,7 +211,7 @@ private function asyncScheduleAndTest($product, $storeCode = null) } else { $this->assertEquals( $productName, - $storeResponse[Product::NAME], + $storeResponse[ProductInterface::NAME], sprintf( 'Product name in %s store is invalid after updating in store %s.', $checkingStore, @@ -225,6 +222,9 @@ private function asyncScheduleAndTest($product, $storeCode = null) } } + /** + * @inheritDoc + */ protected function tearDown(): void { $this->clearProducts(); @@ -232,7 +232,10 @@ protected function tearDown(): void parent::tearDown(); } - private function clearProducts() + /** + * @return void + */ + private function clearProducts(): void { $size = $this->objectManager->create(Collection::class) ->addAttributeToFilter('sku', ['in' => $this->skus]) @@ -270,7 +273,7 @@ private function clearProducts() /** * @return array */ - public function getProductData() + public function getProductData(): array { $productBuilder = function ($data) { return array_replace_recursive( @@ -280,23 +283,26 @@ public function getProductData() }; return [ - 'product' => - $productBuilder( - [ - Product::TYPE_ID => 'simple', - Product::SKU => 'multistore-sku-test-1', - Product::NAME => 'Test Name ', - ] - ), + 'product' => $productBuilder( + [ + ProductInterface::TYPE_ID => 'simple', + ProductInterface::SKU => 'multistore-sku-test-1', + ProductInterface::NAME => 'Test Name ', + ] + ), ]; } - public function storeProvider() + /** + * @return array + */ + public function storeProvider(): array { $dataSets = []; foreach ($this->stores as $store) { $dataSets[$store] = [$store]; } + return $dataSets; } @@ -306,28 +312,28 @@ public function storeProvider() * @param array $productData * @return array */ - private function getSimpleProductData($productData = []) + private function getSimpleProductData($productData = []): array { return [ - Product::SKU => isset($productData[Product::SKU]) - ? $productData[Product::SKU] : uniqid('sku-', true), - Product::NAME => isset($productData[Product::NAME]) - ? $productData[Product::NAME] : uniqid('sku-', true), - Product::VISIBILITY => 4, - Product::TYPE_ID => 'simple', - Product::PRICE => 3.62, - Product::STATUS => 1, - Product::TYPE_ID => 'simple', - Product::ATTRIBUTE_SET_ID => 4, + ProductInterface::SKU => isset($productData[ProductInterface::SKU]) + ? $productData[ProductInterface::SKU] : uniqid('sku-', true), + ProductInterface::NAME => isset($productData[ProductInterface::NAME]) + ? $productData[ProductInterface::NAME] : uniqid('sku-', true), + ProductInterface::VISIBILITY => 4, + ProductInterface::TYPE_ID => 'simple', + ProductInterface::PRICE => 3.62, + ProductInterface::STATUS => 1, + ProductInterface::ATTRIBUTE_SET_ID => 4, ]; } /** - * @param $requestData + * @param array $requestData + * @param string $sku * @param string|null $storeCode * @return mixed */ - private function updateProductAsync($requestData, $sku, $storeCode = null) + private function updateProductAsync(array $requestData, string $sku, $storeCode = null) { $serviceInfo = [ 'rest' => [ @@ -339,40 +345,19 @@ private function updateProductAsync($requestData, $sku, $storeCode = null) return $this->_webApiCall($serviceInfo, $requestData, null, $storeCode); } - public function assertProductCreation($product) + /** + * @param array $product + * @return bool + */ + public function assertProductCreation(array $product): bool { - $sku = $product['product'][Product::SKU]; + $sku = $product['product'][ProductInterface::SKU]; $collection = $this->objectManager->create(Collection::class) - ->addAttributeToFilter(Product::SKU, ['eq' => $sku]) - ->addAttributeToFilter(Product::TYPE_ID, ['eq' => 'virtual']) + ->addAttributeToFilter(ProductInterface::SKU, ['eq' => $sku]) + ->addAttributeToFilter(ProductInterface::TYPE_ID, ['eq' => 'virtual']) ->load(); $size = $collection->getSize(); return $size > 0; } - - /** - * Remove test store - * //phpcs:disable - */ - public static function tearDownAfterClass(): void - { - parent::tearDownAfterClass(); - //phpcs:enable - /** @var Registry $registry */ - $registry = Bootstrap::getObjectManager()->get(Registry::class); - - $registry->unregister('isSecureArea'); - $registry->register('isSecureArea', true); - - /** @var Store $store*/ - $store = Bootstrap::getObjectManager()->create(Store::class); - $store->load('fixturestore'); - if ($store->getId()) { - $store->delete(); - } - - $registry->unregister('isSecureArea'); - $registry->register('isSecureArea', false); - } } diff --git a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/System/StoreTest.php b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/System/StoreTest.php index 37c85be7d5e09..d2dd05f57d534 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/System/StoreTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/System/StoreTest.php @@ -3,13 +3,56 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Backend\Controller\Adminhtml\System; +use Magento\Store\Model\ResourceModel\Store as StoreResource; +use Magento\Store\Api\Data\StoreInterfaceFactory; +use Magento\Store\Api\WebsiteRepositoryInterface; +use Magento\Framework\Data\Form\FormKey; +use Magento\Framework\Message\MessageInterface; +use Magento\Framework\Message\ManagerInterface; +use Magento\Framework\App\Request\Http as HttpRequest; + /** * @magentoAppArea adminhtml */ class StoreTest extends \Magento\TestFramework\TestCase\AbstractBackendController { + /** + * @var FormKey + */ + private $formKey; + + /** + * @var StoreResource + */ + private $storeResource; + + /** + * @var StoreInterfaceFactory + */ + private $storeFactory; + + /** + * @var WebsiteRepositoryInterface + */ + private $websiteRepository; + + /** + * @inheritDoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->formKey = $this->_objectManager->get(FormKey::class); + $this->storeResource = $this->_objectManager->get(StoreResource::class); + $this->storeFactory = $this->_objectManager->get(StoreInterfaceFactory::class); + $this->websiteRepository = $this->_objectManager->get(WebsiteRepositoryInterface::class); + } + public function testIndexAction() { $this->dispatch('backend/admin/system_store/index'); @@ -67,17 +110,53 @@ public function testIndexAction() */ public function testSaveActionWithExistCode($post, $message) { - /** @var $formKey \Magento\Framework\Data\Form\FormKey */ - $formKey = $this->_objectManager->get(\Magento\Framework\Data\Form\FormKey::class); - $post['form_key'] = $formKey->getFormKey(); - $this->getRequest()->setMethod('POST'); + $post['form_key'] = $this->formKey->getFormKey(); + $this->getRequest()->setMethod(HttpRequest::METHOD_POST); $this->getRequest()->setPostValue($post); $this->dispatch('backend/admin/system_store/save'); //Check that errors was generated and set to session $this->assertSessionMessages( $this->containsEqual($message), - \Magento\Framework\Message\MessageInterface::TYPE_ERROR, - \Magento\Framework\Message\ManagerInterface::class + MessageInterface::TYPE_ERROR, + ManagerInterface::class + ); + } + + /** + * Save action test. + * Changing of a default website when a target website doesn't have a default store view. + * + * @return void + * @magentoDataFixture Magento/Store/_files/second_website_with_store_group_and_store.php + */ + public function testSaveActionChangeDefaultWebsiteThatDoesntHaveDefaultStoreView(): void + { + $secondWebsite = $this->websiteRepository->get('test'); + // inactivate default store view of second store + $secondStore = $this->storeFactory->create(); + $this->storeResource->load($secondStore, 'fixture_second_store', 'code'); + $secondStore->setIsActive(0); + $this->storeResource->save($secondStore); + + $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setPostValue([ + 'website' => [ + 'name' => 'Test Website', + 'code' => 'test', + 'sort_order' => '0', + 'default_group_id' => $secondWebsite->getDefaultGroupId(), + 'is_default' => '1', + 'website_id' => $secondWebsite->getId(), + ], + 'store_type' => 'website', + 'store_action' => 'edit', + ],); + $this->dispatch('backend/admin/system_store/save'); + //Check that errors was generated and set to session + $this->assertSessionMessages( + $this->containsEqual('Please enable your Store View before using this Web Site as Default'), + MessageInterface::TYPE_ERROR, + ManagerInterface::class ); } diff --git a/dev/tests/integration/testsuite/Magento/Csp/Model/Collector/ConfigCollectorTest.php b/dev/tests/integration/testsuite/Magento/Csp/Model/Collector/ConfigCollectorTest.php index 2d8cbbeedeab9..cf6287ed5b4e1 100644 --- a/dev/tests/integration/testsuite/Magento/Csp/Model/Collector/ConfigCollectorTest.php +++ b/dev/tests/integration/testsuite/Magento/Csp/Model/Collector/ConfigCollectorTest.php @@ -62,9 +62,9 @@ private function getExpectedPolicies(): array [], true ), - 'font-src' => new FetchPolicy('font-src', false, [], [], true), + 'font-src' => new FetchPolicy('font-src', false, [], ['data'], true), 'frame-src' => new FetchPolicy('frame-src', false, [], [], true, false, false, [], [], true), - 'img-src' => new FetchPolicy('img-src', false, [], [], true), + 'img-src' => new FetchPolicy('img-src', false, [], ['data'], true), 'manifest-src' => new FetchPolicy('manifest-src', false, [], [], true), 'media-src' => new FetchPolicy('media-src', false, [], [], true), 'object-src' => new FetchPolicy('object-src', false, [], [], true), 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 index 291fda6e2494f..13caf308259a1 100644 --- 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 @@ -8,9 +8,11 @@ namespace Magento\Sales\Block\Adminhtml\Order\Create\Sidebar; use Magento\Backend\Model\Session\Quote; -use Magento\Framework\ObjectManagerInterface; +use Magento\Catalog\Model\ProductRepository; use Magento\Framework\View\LayoutInterface; +use Magento\Quote\Model\QuoteRepository; use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\ObjectManager; use PHPUnit\Framework\TestCase; /** @@ -23,7 +25,7 @@ */ class CartTest extends TestCase { - /** @var ObjectManagerInterface */ + /** @var ObjectManager */ private $objectManager; /** @var Cart */ @@ -32,6 +34,9 @@ class CartTest extends TestCase /** @var Quote */ private $session; + /** @var ProductRepository */ + private $productRepository; + /** * @inheritdoc */ @@ -42,6 +47,7 @@ protected function setUp(): void $this->objectManager = Bootstrap::getObjectManager(); $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Cart::class); $this->session = $this->objectManager->get(Quote::class); + $this->productRepository = $this->objectManager->get(ProductRepository::class); } /** @@ -50,7 +56,8 @@ protected function setUp(): void protected function tearDown(): void { $this->session->clearStorage(); - + $this->objectManager->removeSharedInstance(\Magento\Sales\Model\AdminOrder\Create::class, true); + $this->objectManager->removeSharedInstance(QuoteRepository::class); parent::tearDown(); } @@ -77,4 +84,21 @@ public function testClearShoppingCartButton(): void $this->assertEquals(sprintf("order.clearShoppingCart('%s')", $confirmation), $button->getOnclick()); $this->assertEquals(__('Clear Shopping Cart'), $button->getLabel()); } + + /** + * @magentoDataFixture Magento/Directory/_files/usd_cny_rate.php + * @magentoDataFixture Magento/Sales/_files/quote_with_two_products_and_customer_and_custom_price.php + * + * @magentoConfigFixture default/currency/options/base USD + * @magentoConfigFixture current_store currency/options/default CNY + * @magentoConfigFixture current_store currency/options/allow CNY,USD + */ + public function testGetItemPriceConvert() + { + $this->session->setCustomerId(1); + $customPrice = $this->block->getItemPrice($this->productRepository->get('simple')); + $this->assertStringContainsString('84.00', $customPrice); + $price = $this->block->getItemPrice($this->productRepository->get('custom-design-simple-product')); + $this->assertStringContainsString('70.00', $price); + } } diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_two_products_and_customer_and_custom_price.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_two_products_and_customer_and_custom_price.php new file mode 100644 index 0000000000000..456dbd6b86abd --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_two_products_and_customer_and_custom_price.php @@ -0,0 +1,36 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Catalog\Model\ProductRepository; +use Magento\Quote\Model\Quote\Item\Updater; +use Magento\Quote\Model\QuoteFactory; +use Magento\Quote\Model\ResourceModel\Quote; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +Resolver::getInstance()->requireDataFixture('Magento/Sales/_files/quote_with_two_products_and_customer.php'); + +$objectManager = Bootstrap::getObjectManager(); +/** @var QuoteFactory $quoteFactory */ +$quoteFactory = $objectManager->get(QuoteFactory::class); +/** @var Quote $quoteResource */ +$quoteResource = $objectManager->get(Quote::class); +$quote = $quoteFactory->create(); +$quoteResource->load($quote, 'test01', 'reserved_order_id'); +$productRepository = $objectManager->get(ProductRepository::class); +$quoteItem = $quote->getItemByProduct($productRepository->get('simple')); +/** @var Updater $updater */ +$updater = $objectManager->get(Updater::class); +$updater->update( + $quoteItem, + [ + 'qty' => 1, + 'custom_price' => 12, + ] +); +$quote->collectTotals(); +$quoteResource->save($quote); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_two_products_and_customer_and_custom_price_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_two_products_and_customer_and_custom_price_rollback.php new file mode 100644 index 0000000000000..6405d3b9b959a --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_two_products_and_customer_and_custom_price_rollback.php @@ -0,0 +1,12 @@ +<?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/Sales/_files/quote_with_two_products_and_customer_rollback.php' +); diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_two_products_and_customer_rollback.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_two_products_and_customer_rollback.php new file mode 100644 index 0000000000000..6a66c6515cf44 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quote_with_two_products_and_customer_rollback.php @@ -0,0 +1,13 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Quote\Model\Quote; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +Resolver::getInstance()->requireDataFixture('Magento/Checkout/_files/quote_with_address_rollback.php'); diff --git a/dev/tests/integration/testsuite/Magento/Store/_files/core_fixturestore.php b/dev/tests/integration/testsuite/Magento/Store/_files/core_fixturestore.php index a4a640a24de50..a60c672df6192 100644 --- a/dev/tests/integration/testsuite/Magento/Store/_files/core_fixturestore.php +++ b/dev/tests/integration/testsuite/Magento/Store/_files/core_fixturestore.php @@ -4,23 +4,28 @@ * See COPYING.txt for license details. */ +use Magento\Store\Model\ResourceModel\Store as StoreResource; +use Magento\Store\Model\StoreFactory; +use Magento\Store\Model\StoreManagerInterface; use Magento\TestFramework\Helper\Bootstrap; -/** @var \Magento\Store\Model\StoreManagerInterface $storeManager */ -$storeManager = Bootstrap::getObjectManager()->get(\Magento\Store\Model\StoreManagerInterface::class); - -/** @var \Magento\Store\Model\Store $store */ -$store = Bootstrap::getObjectManager()->create(\Magento\Store\Model\Store::class); +$objectManager = Bootstrap::getObjectManager(); +/** @var StoreManagerInterface $storeManager */ +$storeManager = $objectManager->get(StoreManagerInterface::class); +/** @var StoreFactory $storeFactory */ +$storeFactory = $objectManager->get(StoreFactory::class); +/** @var StoreResource $storeResource */ +$storeResource = $objectManager->get(StoreResource::class); $storeCode = 'fixturestore'; -if (!$store->load($storeCode)->getId()) { - $store->setCode($storeCode) - ->setWebsiteId($storeManager->getWebsite()->getId()) - ->setGroupId($storeManager->getWebsite()->getDefaultGroupId()) - ->setName('Fixture Store') - ->setSortOrder(10) - ->setIsActive(1); - $store->save(); -} +$store = $storeFactory->create(); +$store->setCode($storeCode) + ->setWebsiteId($storeManager->getWebsite()->getId()) + ->setGroupId($storeManager->getWebsite()->getDefaultGroupId()) + ->setName('Fixture Store') + ->setSortOrder(10) + ->setIsActive(1); +$storeResource->save($store); +$storeManager->reinitStores(); //if test using this fixture relies on full text functionality it is required to explicitly perform re-indexation diff --git a/dev/tests/integration/testsuite/Magento/Ups/Model/CarrierTest.php b/dev/tests/integration/testsuite/Magento/Ups/Model/CarrierTest.php index 7000fadd5154d..0cedcca254f80 100644 --- a/dev/tests/integration/testsuite/Magento/Ups/Model/CarrierTest.php +++ b/dev/tests/integration/testsuite/Magento/Ups/Model/CarrierTest.php @@ -19,7 +19,9 @@ use Magento\Quote\Model\Quote\Address\RateRequestFactory; use Magento\TestFramework\HTTP\AsyncClientInterfaceMock; use PHPUnit\Framework\TestCase; +use PHPUnit\Framework\MockObject\MockObject; use Magento\Shipping\Model\Shipment\Request; +use Psr\Log\LoggerInterface; /** * Integration tests for Carrier model class @@ -43,14 +45,32 @@ class CarrierTest extends TestCase */ private $config; + /** + * @var LoggerInterface|MockObject + */ + private $loggerMock; + + /** + * @var string[] + */ + private $logs = []; + /** * @inheritDoc */ protected function setUp(): void { - $this->carrier = Bootstrap::getObjectManager()->create(Carrier::class); $this->httpClient = Bootstrap::getObjectManager()->get(AsyncClientInterface::class); $this->config = Bootstrap::getObjectManager()->get(ReinitableConfigInterface::class); + $this->logs = []; + $this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class); + $this->loggerMock->method('debug') + ->willReturnCallback( + function (string $message) { + $this->logs[] = $message; + } + ); + $this->carrier = Bootstrap::getObjectManager()->create(Carrier::class, ['logger' => $this->loggerMock]); } /** @@ -136,6 +156,7 @@ public function testCollectFreeRates() * @magentoConfigFixture default_store carriers/ups/username user * @magentoConfigFixture default_store carriers/ups/password pass * @magentoConfigFixture default_store carriers/ups/access_license_number acn + * @magentoConfigFixture default_store carriers/ups/debug 1 * @magentoConfigFixture default_store currency/options/allow GBP,USD,EUR * @magentoConfigFixture default_store currency/options/base GBP */ @@ -172,6 +193,17 @@ public function testCollectRates(int $negotiable, int $tax, int $responseId, str $rates = $this->carrier->collectRates($request)->getAllRates(); $this->assertEquals($price, $rates[0]->getPrice()); $this->assertEquals($method, $rates[0]->getMethod()); + + $requestFound = false; + foreach ($this->logs as $log) { + if (mb_stripos($log, 'RatingServiceSelectionRequest') && + mb_stripos($log, 'RatingServiceSelectionResponse') + ) { + $requestFound = true; + break; + } + } + $this->assertTrue($requestFound); } /** @@ -304,6 +336,7 @@ public function testRequestToShipment(): void * @magentoConfigFixture default_store carriers/ups/username user * @magentoConfigFixture default_store carriers/ups/password pass * @magentoConfigFixture default_store carriers/ups/access_license_number acn + * @magentoConfigFixture default_store carriers/ups/debug 1 * @magentoConfigFixture default_store currency/options/allow GBP,USD,EUR * @magentoConfigFixture default_store currency/options/base GBP */ diff --git a/dev/tests/integration/testsuite/Magento/Weee/Model/Total/Quote/CalculateTest.php b/dev/tests/integration/testsuite/Magento/Weee/Model/Total/Quote/CalculateTest.php new file mode 100644 index 0000000000000..97cde94a60abe --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Weee/Model/Total/Quote/CalculateTest.php @@ -0,0 +1,80 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Weee\Model\Total\Quote; + +use Magento\Checkout\Api\Data\TotalsInformationInterface; +use Magento\Checkout\Model\TotalsInformationManagement; +use Magento\Quote\Model\Quote\Address; +use Magento\Quote\Model\Quote\AddressFactory; +use Magento\Quote\Model\QuoteFactory; +use Magento\Quote\Model\ResourceModel\Quote as QuoteResource; +use Magento\TestFramework\ObjectManager; +use PHPUnit\Framework\TestCase; + +/** + * Quote totals calculate tests class + */ +class CalculateTest extends TestCase +{ + /** + * @var ObjectManager + */ + private $objectManager; + + /** + * @var TotalsInformationManagement + */ + private $totalsManagement; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + $this->objectManager = ObjectManager::getInstance(); + $this->totalsManagement = $this->objectManager->get(TotalsInformationManagement::class); + } + + /** + * Multishipping quote with FPT Weee TAX totals calculation test + * + * @magentoDataFixture Magento/Weee/_files/quote_multishipping.php + * @magentoConfigFixture default_store tax/weee/enable 1 + * @magentoConfigFixture default_store tax/weee/apply_vat 1 + */ + public function testGetWeeTaxTotals() + { + /** @var QuoteFactory $quoteFactory */ + $quoteFactory = $this->objectManager->get(QuoteFactory::class); + /** @var QuoteResource $quoteResource */ + $quoteResource = $this->objectManager->get(QuoteResource::class); + $quote = $quoteFactory->create(); + $quoteResource->load($quote, 'multishipping_fpt_quote_id', 'reserved_order_id'); + $cartId = $quote->getId(); + $addressFactory = $this->objectManager->get(AddressFactory::class); + /** @var Address $newAddress */ + $newAddress = $addressFactory->create()->setAddressType('shipping'); + $newAddress->setCountryId('US')->setRegionId(12)->setRegion('California')->setPostcode('90230'); + $addressInformation = $this->objectManager->create( + TotalsInformationInterface::class, + [ + 'data' => [ + 'address' => $newAddress, + 'shipping_method_code' => 'flatrate', + 'shipping_carrier_code' => 'flatrate', + ], + ] + ); + + $actual = $this->totalsManagement->calculate($cartId, $addressInformation); + + $items = $actual->getTotalSegments(); + $this->assertTrue(array_key_exists('weee_tax', $items)); + $this->assertEquals(25.4, $items['weee_tax']->getValue()); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Weee/_files/quote_multishipping.php b/dev/tests/integration/testsuite/Magento/Weee/_files/quote_multishipping.php new file mode 100644 index 0000000000000..79ed227c2e5fb --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Weee/_files/quote_multishipping.php @@ -0,0 +1,117 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Model\Product; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\Quote\Api\Data\AddressInterface; +use Magento\Quote\Api\Data\PaymentInterface; +use Magento\Quote\Model\Quote; +use Magento\Quote\Model\Quote\Address\Rate; +use Magento\Quote\Model\Quote\Item; +use Magento\Quote\Model\QuoteFactory; +use Magento\Quote\Model\ResourceModel\Quote as QuoteResource; +use Magento\Store\Model\StoreManagerInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\ObjectManager; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +/** @var ObjectManager $objectManager */ +$objectManager = Bootstrap::getObjectManager(); +/** @var QuoteFactory $quoteFactory */ +$quoteFactory = Bootstrap::getObjectManager()->get(QuoteFactory::class); +/** @var QuoteResource $quoteResource */ +$quoteResource = Bootstrap::getObjectManager()->get(QuoteResource::class); +/** @var StoreManagerInterface $storeManager */ +$storeManager = $objectManager->get(StoreManagerInterface::class); +/** @var CartRepositoryInterface $quoteRepository */ +$quoteRepository = $objectManager->get(CartRepositoryInterface::class); +$store = $storeManager->getStore(); +/** @var Quote $quote */ +$quote = $quoteFactory->create(); +$quote->setReservedOrderId('multishipping_fpt_quote_id') + ->setCustomerEmail('customer001@test.com') + ->setStoreId($storeManager->getStore()->getId()); + +$shipping = [ + 'firstname' => 'Jonh', + 'lastname' => 'Doe', + 'telephone' => '0333-233-221', + 'street' => ['Main Division 1'], + 'city' => 'Culver City', + 'region' => 'CA', + 'postcode' => 90800, + 'country_id' => 'US', + 'email' => 'customer001@shipping.test', + 'address_type' => 'shipping', +]; +$methodCode = 'flatrate_flatrate'; + /** @var Rate $rate */ + $rate = $objectManager->create(Rate::class); + $rate->setCode($methodCode) + ->setPrice(5.00); + + $address = $objectManager->create(AddressInterface::class, ['data' => $shipping]); + $address->setShippingMethod($methodCode) + ->addShippingRate($rate) + ->setShippingAmount(5.00) + ->setBaseShippingAmount(5.00); + + $quote->addAddress($address); + +/** @var AddressInterface $address */ +$address = $objectManager->create( + AddressInterface::class, + [ + 'data' => [ + 'firstname' => 'Jonh', + 'lastname' => 'Doe', + 'telephone' => '0333-233-221', + 'street' => ['Third Division 1'], + 'city' => 'New York', + 'region' => 'NY', + 'postcode' => 10029, + 'country_id' => 'US', + 'email' => 'customer001@billing.test', + 'address_type' => 'billing', + ], + ] +); +$quote->setBillingAddress($address); + +$quote->setIsMultiShipping(1); +$quoteRepository->save($quote); + +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->create(ProductRepositoryInterface::class); +Resolver::getInstance()->requireDataFixture('Magento/Weee/_files/product_with_fpt.php'); +/** @var Product $product */ +$product = $productRepository->get('simple-with-ftp'); + +/** @var Item $item */ +$item = $objectManager->create(Item::class); +$item->setProduct($product) + ->setPrice($product->getPrice()) + ->setQty(2); +$quote->addItem($item); +$quoteRepository->save($quote); + +$addressList = $quote->getAllShippingAddresses(); +$address = reset($addressList); +$item->setQty(2); +$address->setTotalQty(2); +$address->addItem($item); +$quoteRepository->save($quote); + +$quote = $quoteFactory->create(); +$quoteResource->load($quote, 'multishipping_fpt_quote_id', 'reserved_order_id'); +/** @var PaymentInterface $payment */ +$payment = $objectManager->create(PaymentInterface::class); +$payment->setMethod('checkmo'); +$quote->setPayment($payment); +$quote->collectTotals(); +$quoteRepository->save($quote); diff --git a/dev/tests/integration/testsuite/Magento/Weee/_files/quote_multishipping_rollback.php b/dev/tests/integration/testsuite/Magento/Weee/_files/quote_multishipping_rollback.php new file mode 100644 index 0000000000000..a5542ca236eba --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Weee/_files/quote_multishipping_rollback.php @@ -0,0 +1,31 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Quote\Api\CartRepositoryInterface; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\ObjectManager; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +/** @var ObjectManager $objectManager */ +$objectManager = Bootstrap::getObjectManager(); + +/** @var SearchCriteriaBuilder $searchCriteriaBuilder */ +$searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class); +$searchCriteria = $searchCriteriaBuilder + ->addFilter('reserved_order_id', 'multishipping_fpt_quote_id') + ->create(); +/** @var CartRepositoryInterface $quoteRepository */ +$quoteRepository = $objectManager->get(CartRepositoryInterface::class); +$quotesList = $quoteRepository->getList($searchCriteria)->getItems(); + +if (!empty($quotesList)) { + $quote = array_pop($quotesList); + $quoteRepository->delete($quote); +} + +Resolver::getInstance()->requireDataFixture('Magento/Weee/_files/product_with_fpt_rollback.php'); diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/date.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/date.test.js index 91f37e20cca87..a70eef170a4ea 100644 --- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/date.test.js +++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/element/date.test.js @@ -65,5 +65,22 @@ define([ expect(model.getPreview()).toBe('28-11-2020'); }); + it('Check date will have correct value with timeOnly config value.', function () { + model.options.timeOnly = true; + model.options.timeFormat = 'h:mm a'; + model.prepareDateTimeFormats(); + model.value('02:43:58'); + expect(model.getPreview()).toBe('2:43 am'); + + model.options.timeFormat = 'HH:mm:ss'; + model.prepareDateTimeFormats(); + model.value('02:43:58'); + expect(model.getPreview()).toBe('02:43:58'); + + model.options.timeFormat = 'HH:mm:ss'; + model.prepareDateTimeFormats(); + model.value('2:43 am'); + expect(model.getPreview()).toBe('02:43:00'); + }); }); }); diff --git a/lib/internal/Magento/Framework/Filesystem/Io/Ftp.php b/lib/internal/Magento/Framework/Filesystem/Io/Ftp.php index 04df5fd3f3a6c..0027329e7d54c 100644 --- a/lib/internal/Magento/Framework/Filesystem/Io/Ftp.php +++ b/lib/internal/Magento/Framework/Filesystem/Io/Ftp.php @@ -313,9 +313,10 @@ public function chmod($filename, $mode) */ public function ls($grep = null) { - $ls = @ftp_nlist($this->_conn, '.'); + $ls = @ftp_nlist($this->_conn, '.') ?: []; $list = []; + foreach ($ls as $file) { $list[] = ['text' => $file, 'id' => $this->pwd() . '/' . $file]; } diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php index a5fe6f6c61506..64f04c62bbf64 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php @@ -212,7 +212,10 @@ private function checkAbilityToSendCookie($name, $value) if ($numCookies > static::MAX_NUM_COOKIES) { $this->logger->warning( new Phrase('Unable to send the cookie. Maximum number of cookies would be exceeded.'), - array_merge($_COOKIE, ['user-agent' => $this->httpHeader->getHttpUserAgent()]) + [ + 'cookies' => $_COOKIE, + 'user-agent' => $this->httpHeader->getHttpUserAgent() + ] ); } diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php index e41cbdfe51638..87e10981c802c 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php @@ -565,7 +565,10 @@ public function testSetTooManyCookies() ->method('warning') ->with( new Phrase('Unable to send the cookie. Maximum number of cookies would be exceeded.'), - array_merge($_COOKIE, ['user-agent' => $userAgent]) + [ + 'cookies' => $_COOKIE, + 'user-agent' => $userAgent + ] ); $this->cookieManager->setPublicCookie(