From b2b29eae364b0e39579874328d09dd2c0d506eca Mon Sep 17 00:00:00 2001 From: Ravi Chandra Date: Sat, 29 Aug 2020 12:27:00 +0530 Subject: [PATCH 01/68] Fixed Unable to apply data patch issue #29365 --- .../Setup/Patch/Data/UpdateUrlKeyForProducts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogUrlRewrite/Setup/Patch/Data/UpdateUrlKeyForProducts.php b/app/code/Magento/CatalogUrlRewrite/Setup/Patch/Data/UpdateUrlKeyForProducts.php index 5e7039912999b..7714dc8340496 100644 --- a/app/code/Magento/CatalogUrlRewrite/Setup/Patch/Data/UpdateUrlKeyForProducts.php +++ b/app/code/Magento/CatalogUrlRewrite/Setup/Patch/Data/UpdateUrlKeyForProducts.php @@ -58,7 +58,7 @@ public function apply() $table = $this->moduleDataSetup->getTable('catalog_product_entity_varchar'); $select = $this->moduleDataSetup->getConnection()->select()->from( $table, - ['value_id', 'value'] + ['entity_id', 'attribute_id', 'store_id', 'value_id', 'value'] )->where( 'attribute_id = ?', $this->eavSetup->getAttributeId($productTypeId, 'url_key') From a06ec39035650062d2486a5cb2d42f36b1b0c66c Mon Sep 17 00:00:00 2001 From: Ravi Chandra Date: Sat, 5 Sep 2020 15:37:18 +0530 Subject: [PATCH 02/68] Fixed Unable to apply data patch issue for commerce and opensource --- .../Patch/Data/UpdateUrlKeyForProducts.php | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/CatalogUrlRewrite/Setup/Patch/Data/UpdateUrlKeyForProducts.php b/app/code/Magento/CatalogUrlRewrite/Setup/Patch/Data/UpdateUrlKeyForProducts.php index 7714dc8340496..f74d8ca358b3f 100644 --- a/app/code/Magento/CatalogUrlRewrite/Setup/Patch/Data/UpdateUrlKeyForProducts.php +++ b/app/code/Magento/CatalogUrlRewrite/Setup/Patch/Data/UpdateUrlKeyForProducts.php @@ -34,19 +34,27 @@ class UpdateUrlKeyForProducts implements DataPatchInterface, PatchVersionInterfa */ private $urlProduct; + /** + * @var \Magento\Framework\EntityManager\MetadataPool + */ + private $metadataPool; + /** * @param ModuleDataSetupInterface $moduleDataSetup * @param EavSetupFactory $eavSetupFactory * @param Url $urlProduct + * @param \Magento\Framework\EntityManager\MetadataPool $metadataPool */ public function __construct( ModuleDataSetupInterface $moduleDataSetup, EavSetupFactory $eavSetupFactory, - Url $urlProduct + Url $urlProduct, + \Magento\Framework\EntityManager\MetadataPool $metadataPool ) { $this->moduleDataSetup = $moduleDataSetup; $this->eavSetup = $eavSetupFactory->create(['setup' => $moduleDataSetup]); $this->urlProduct = $urlProduct; + $this->metadataPool = $metadataPool; } /** @@ -58,7 +66,7 @@ public function apply() $table = $this->moduleDataSetup->getTable('catalog_product_entity_varchar'); $select = $this->moduleDataSetup->getConnection()->select()->from( $table, - ['entity_id', 'attribute_id', 'store_id', 'value_id', 'value'] + [$this->getProductLinkField(), 'attribute_id', 'store_id', 'value_id', 'value'] )->where( 'attribute_id = ?', $this->eavSetup->getAttributeId($productTypeId, 'url_key') @@ -99,4 +107,17 @@ public function getAliases() { return []; } + + /** + * Return product id field name - entity_id|row_id + * + * @return string + * @throws \Exception + */ + private function getProductLinkField() + { + return $this->metadataPool + ->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class) + ->getLinkField(); + } } From 9f3ab3acac277256fed0a71b6f45cab01cd1ef7b Mon Sep 17 00:00:00 2001 From: Eduard Muradov Date: Tue, 10 Nov 2020 17:37:34 +0300 Subject: [PATCH 03/68] Remove recursion in location of static files. --- nginx.conf.sample | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nginx.conf.sample b/nginx.conf.sample index ead80ccb22ece..5edf30675979d 100644 --- a/nginx.conf.sample +++ b/nginx.conf.sample @@ -105,8 +105,8 @@ location /static/ { # expires max; # Remove signature of the static files that is used to overcome the browser cache - location ~ ^/static/version { - rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last; + location ~ ^/static/version\d*/ { + rewrite ^/static/version\d*/(.*)$ /static/$1 last; } location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|html|json)$ { From 94a7467140e09f9d6fc14705c35cdd8002da3cd2 Mon Sep 17 00:00:00 2001 From: larsroettig Date: Tue, 17 Nov 2020 08:22:55 +0100 Subject: [PATCH 04/68] FIX Perfomance Issue for Backend EDIT of CMS #30936 --- .../Magento/Cms/Model/Page/DataProvider.php | 115 ++++++++++-------- 1 file changed, 65 insertions(+), 50 deletions(-) diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php index 41010575a1f27..fd4b71090e6eb 100644 --- a/app/code/Magento/Cms/Model/Page/DataProvider.php +++ b/app/code/Magento/Cms/Model/Page/DataProvider.php @@ -5,11 +5,13 @@ */ namespace Magento\Cms\Model\Page; +use Magento\Cms\Api\PageRepositoryInterface; use Magento\Cms\Model\Page; use Magento\Cms\Model\ResourceModel\Page\CollectionFactory; use Magento\Framework\App\ObjectManager; use Magento\Framework\App\Request\DataPersistorInterface; use Magento\Framework\App\RequestInterface; +use Magento\Framework\Exception\LocalizedException; use Magento\Ui\DataProvider\Modifier\PoolInterface; use Magento\Framework\AuthorizationInterface; @@ -18,21 +20,16 @@ */ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider { - /** - * @var \Magento\Cms\Model\ResourceModel\Page\Collection - */ - protected $collection; - /** * @var DataPersistorInterface */ protected $dataPersistor; - /** * @var array */ protected $loadedData; - + /** @var PageRepositoryInterface */ + private $pageRepository; /** * @var AuthorizationInterface */ @@ -47,11 +44,10 @@ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider * @var CustomLayoutManagerInterface */ private $customLayoutManager; - /** - * @var CollectionFactory + * @var null|array */ - private $collectionFactory; + private $loadedPages; /** * @param string $name @@ -65,6 +61,7 @@ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider * @param AuthorizationInterface|null $auth * @param RequestInterface|null $request * @param CustomLayoutManagerInterface|null $customLayoutManager + * @param PageRepositoryInterface|null $pageRepository * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -78,33 +75,20 @@ public function __construct( PoolInterface $pool = null, ?AuthorizationInterface $auth = null, ?RequestInterface $request = null, - ?CustomLayoutManagerInterface $customLayoutManager = null + ?CustomLayoutManagerInterface $customLayoutManager = null, + ?PageRepositoryInterface $pageRepository = null ) { + + parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool); + $this->collection = $pageCollectionFactory->create(); - $this->collectionFactory = $pageCollectionFactory; $this->dataPersistor = $dataPersistor; - parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool); $this->auth = $auth ?? ObjectManager::getInstance()->get(AuthorizationInterface::class); $this->meta = $this->prepareMeta($this->meta); $this->request = $request ?? ObjectManager::getInstance()->get(RequestInterface::class); $this->customLayoutManager = $customLayoutManager ?? ObjectManager::getInstance()->get(CustomLayoutManagerInterface::class); - } - - /** - * Find requested page. - * - * @return Page|null - */ - private function findCurrentPage(): ?Page - { - if ($this->getRequestFieldName() && ($pageId = (int)$this->request->getParam($this->getRequestFieldName()))) { - //Loading data for the collection. - $this->getData(); - return $this->collection->getItemById($pageId); - } - - return null; + $this->pageRepository = $pageRepository ?? ObjectManager::getInstance()->get(PageRepositoryInterface::class); } /** @@ -113,7 +97,7 @@ private function findCurrentPage(): ?Page * @param array $meta * @return array */ - public function prepareMeta(array $meta) + public function prepareMeta(array $meta): array { return $meta; } @@ -123,40 +107,71 @@ public function prepareMeta(array $meta) * * @return array */ - public function getData() + public function getData(): array { if (isset($this->loadedData)) { return $this->loadedData; } - $this->collection = $this->collectionFactory->create(); - $items = $this->collection->getItems(); - /** @var $page \Magento\Cms\Model\Page */ - foreach ($items as $page) { - $this->loadedData[$page->getId()] = $page->getData(); - if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) { - //Deprecated layout update exists. - $this->loadedData[$page->getId()]['layout_update_selected'] = '_existing_'; - } + + $page = $this->getCurrentPage(); + if ($page === null) { + return []; + } + + $pageId = $page->getId(); + $this->loadedData[$pageId] = $page->getData(); + if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) { + //Deprecated layout update exists. + $this->loadedData[$pageId]['layout_update_selected'] = '_existing_'; } $data = $this->dataPersistor->get('cms_page'); - if (!empty($data)) { - $page = $this->collection->getNewEmptyItem(); - $page->setData($data); - $this->loadedData[$page->getId()] = $page->getData(); - if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) { - $this->loadedData[$page->getId()]['layout_update_selected'] = '_existing_'; - } - $this->dataPersistor->clear('cms_page'); + if (empty($data)) { + return $this->loadedData; } + $page = $this->collection->getNewEmptyItem(); + $page->setData($data); + $this->loadedData[$pageId] = $page->getData(); + if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) { + $this->loadedData[$pageId]['layout_update_selected'] = '_existing_'; + } + $this->dataPersistor->clear('cms_page'); + return $this->loadedData; } + /** + * Loads the current page by current request params. + * @return Page|null + */ + public function getCurrentPage(): ?Page + { + if (!$this->getRequestFieldName()) { + return null; + } + + $pageId = (int)$this->request->getParam($this->getRequestFieldName()); + if ($pageId === 0) { + return null; + } + + if (isset($this->loadedPages[$pageId])) { + return $this->loadedPages[$pageId]; + } + + try { + $this->loadedPages[$pageId] = $this->pageRepository->getById($pageId); + return $this->loadedPages[$pageId]; + } catch (LocalizedException $exception) { + return null; + } + } + /** * @inheritDoc */ - public function getMeta() + public function getMeta(): array { $meta = parent::getMeta(); @@ -186,7 +201,7 @@ public function getMeta() //List of custom layout files available for current page. $options = [['label' => 'No update', 'value' => '_no_update_']]; - if ($page = $this->findCurrentPage()) { + if ($page = $this->getCurrentPage()) { //We must have a specific page selected. //If custom layout XML is set then displaying this special option. if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) { From 3819438618718006dd7d7f1732941d6ca42f1ea5 Mon Sep 17 00:00:00 2001 From: Lars Roettig Date: Thu, 3 Dec 2020 17:58:39 +0100 Subject: [PATCH 05/68] Apply suggestions from code review Co-authored-by: Gabriel da Gama --- app/code/Magento/Cms/Model/Page/DataProvider.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php index fd4b71090e6eb..24b24099d0e7a 100644 --- a/app/code/Magento/Cms/Model/Page/DataProvider.php +++ b/app/code/Magento/Cms/Model/Page/DataProvider.php @@ -78,9 +78,7 @@ public function __construct( ?CustomLayoutManagerInterface $customLayoutManager = null, ?PageRepositoryInterface $pageRepository = null ) { - parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool); - $this->collection = $pageCollectionFactory->create(); $this->dataPersistor = $dataPersistor; $this->auth = $auth ?? ObjectManager::getInstance()->get(AuthorizationInterface::class); @@ -145,7 +143,7 @@ public function getData(): array * Loads the current page by current request params. * @return Page|null */ - public function getCurrentPage(): ?Page + private function getCurrentPage(): ?Page { if (!$this->getRequestFieldName()) { return null; From 3041fc6e29936050d07c487d9134246de78b8c99 Mon Sep 17 00:00:00 2001 From: larsroettig Date: Thu, 3 Dec 2020 18:19:10 +0100 Subject: [PATCH 06/68] #30936: Code Review Fixes --- .../Magento/Cms/Model/Page/DataProvider.php | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php index 24b24099d0e7a..ea46f8d14d1ac 100644 --- a/app/code/Magento/Cms/Model/Page/DataProvider.php +++ b/app/code/Magento/Cms/Model/Page/DataProvider.php @@ -28,8 +28,12 @@ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider * @var array */ protected $loadedData; - /** @var PageRepositoryInterface */ + + /** + * @var PageRepositoryInterface + */ private $pageRepository; + /** * @var AuthorizationInterface */ @@ -44,6 +48,7 @@ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider * @var CustomLayoutManagerInterface */ private $customLayoutManager; + /** * @var null|array */ @@ -111,8 +116,9 @@ public function getData(): array return $this->loadedData; } - $page = $this->getCurrentPage(); - if ($page === null) { + try { + $page = $this->getCurrentPage(); + } catch (LocalizedException $exception) { return []; } @@ -141,29 +147,26 @@ public function getData(): array /** * Loads the current page by current request params. - * @return Page|null + * @return Page + * @throws LocalizedException */ - private function getCurrentPage(): ?Page + private function getCurrentPage(): Page { if (!$this->getRequestFieldName()) { - return null; + throw new LocalizedException(__('RequestFieldName is not spefied')); } $pageId = (int)$this->request->getParam($this->getRequestFieldName()); if ($pageId === 0) { - return null; + throw new LocalizedException(__('Page size must be given')); } if (isset($this->loadedPages[$pageId])) { return $this->loadedPages[$pageId]; } - try { - $this->loadedPages[$pageId] = $this->pageRepository->getById($pageId); - return $this->loadedPages[$pageId]; - } catch (LocalizedException $exception) { - return null; - } + $this->loadedPages[$pageId] = $this->pageRepository->getById($pageId); + return $this->loadedPages[$pageId]; } /** @@ -199,16 +202,19 @@ public function getMeta(): array //List of custom layout files available for current page. $options = [['label' => 'No update', 'value' => '_no_update_']]; - if ($page = $this->getCurrentPage()) { - //We must have a specific page selected. - //If custom layout XML is set then displaying this special option. + + try { + $page = $this->getCurrentPage(); if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) { $options[] = ['label' => 'Use existing layout update XML', 'value' => '_existing_']; } foreach ($this->customLayoutManager->fetchAvailableFiles($page) as $layoutFile) { $options[] = ['label' => $layoutFile, 'value' => $layoutFile]; } + } catch (LocalizedException $exception) { + } + $customLayoutMeta = [ 'design' => [ 'children' => [ From b9987d149128d634bdaae236d4722455408cb818 Mon Sep 17 00:00:00 2001 From: larsroettig Date: Thu, 3 Dec 2020 18:22:38 +0100 Subject: [PATCH 07/68] #30936: Code Review Fixes --- app/code/Magento/Cms/Model/Page/DataProvider.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php index ea46f8d14d1ac..ca7ddb089f601 100644 --- a/app/code/Magento/Cms/Model/Page/DataProvider.php +++ b/app/code/Magento/Cms/Model/Page/DataProvider.php @@ -24,6 +24,7 @@ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider * @var DataPersistorInterface */ protected $dataPersistor; + /** * @var array */ From 17d38950192a474e6307498ef3c6fcee2bcff065 Mon Sep 17 00:00:00 2001 From: Lars Roettig Date: Mon, 7 Dec 2020 13:48:51 +0100 Subject: [PATCH 08/68] Update app/code/Magento/Cms/Model/Page/DataProvider.php Co-authored-by: Gabriel da Gama --- app/code/Magento/Cms/Model/Page/DataProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php index ca7ddb089f601..ffcdac2d76796 100644 --- a/app/code/Magento/Cms/Model/Page/DataProvider.php +++ b/app/code/Magento/Cms/Model/Page/DataProvider.php @@ -159,7 +159,7 @@ private function getCurrentPage(): Page $pageId = (int)$this->request->getParam($this->getRequestFieldName()); if ($pageId === 0) { - throw new LocalizedException(__('Page size must be given')); + throw new LocalizedException(__('Page ID must be given')); } if (isset($this->loadedPages[$pageId])) { From cdecd308da195b7ac1071bfd8f63c685a46c15a1 Mon Sep 17 00:00:00 2001 From: Lars Roettig Date: Mon, 7 Dec 2020 13:49:11 +0100 Subject: [PATCH 09/68] Update app/code/Magento/Cms/Model/Page/DataProvider.php Co-authored-by: Gabriel da Gama --- app/code/Magento/Cms/Model/Page/DataProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php index ffcdac2d76796..ba059bf4aa69b 100644 --- a/app/code/Magento/Cms/Model/Page/DataProvider.php +++ b/app/code/Magento/Cms/Model/Page/DataProvider.php @@ -154,7 +154,7 @@ public function getData(): array private function getCurrentPage(): Page { if (!$this->getRequestFieldName()) { - throw new LocalizedException(__('RequestFieldName is not spefied')); + throw new LocalizedException(__('RequestFieldName is not specified')); } $pageId = (int)$this->request->getParam($this->getRequestFieldName()); From 912374cc3aef261f45085c5fe241fc5287e0c482 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Fri, 11 Dec 2020 16:25:51 +0200 Subject: [PATCH 10/68] add logging, move operation from try block --- .../Magento/Cms/Model/Page/DataProvider.php | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php index ba059bf4aa69b..03dd2cc6866e0 100644 --- a/app/code/Magento/Cms/Model/Page/DataProvider.php +++ b/app/code/Magento/Cms/Model/Page/DataProvider.php @@ -11,14 +11,16 @@ use Magento\Framework\App\ObjectManager; use Magento\Framework\App\Request\DataPersistorInterface; use Magento\Framework\App\RequestInterface; +use Magento\Framework\AuthorizationInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Ui\DataProvider\Modifier\PoolInterface; -use Magento\Framework\AuthorizationInterface; +use Magento\Ui\DataProvider\ModifierPoolDataProvider; +use Psr\Log\LoggerInterface; /** - * Class DataProvider + * Cms Page DataProvider */ -class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider +class DataProvider extends ModifierPoolDataProvider { /** * @var DataPersistorInterface @@ -55,6 +57,11 @@ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider */ private $loadedPages; + /** + * @var LoggerInterface + */ + private $logger; + /** * @param string $name * @param string $primaryFieldName @@ -68,6 +75,7 @@ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider * @param RequestInterface|null $request * @param CustomLayoutManagerInterface|null $customLayoutManager * @param PageRepositoryInterface|null $pageRepository + * @param LoggerInterface|null $logger * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -82,7 +90,8 @@ public function __construct( ?AuthorizationInterface $auth = null, ?RequestInterface $request = null, ?CustomLayoutManagerInterface $customLayoutManager = null, - ?PageRepositoryInterface $pageRepository = null + ?PageRepositoryInterface $pageRepository = null, + ?LoggerInterface $logger = null ) { parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool); $this->collection = $pageCollectionFactory->create(); @@ -93,6 +102,7 @@ public function __construct( $this->customLayoutManager = $customLayoutManager ?? ObjectManager::getInstance()->get(CustomLayoutManagerInterface::class); $this->pageRepository = $pageRepository ?? ObjectManager::getInstance()->get(PageRepositoryInterface::class); + $this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class); } /** @@ -132,7 +142,7 @@ public function getData(): array $data = $this->dataPersistor->get('cms_page'); if (empty($data)) { - return $this->loadedData; + return $this->loadedData; } $page = $this->collection->getNewEmptyItem(); @@ -148,6 +158,7 @@ public function getData(): array /** * Loads the current page by current request params. + * * @return Page * @throws LocalizedException */ @@ -204,16 +215,20 @@ public function getMeta(): array //List of custom layout files available for current page. $options = [['label' => 'No update', 'value' => '_no_update_']]; + $page = null; try { $page = $this->getCurrentPage(); + } catch (LocalizedException $e) { + $this->logger->error($e->getMessage()); + } + + if ($page) { if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) { $options[] = ['label' => 'Use existing layout update XML', 'value' => '_existing_']; } foreach ($this->customLayoutManager->fetchAvailableFiles($page) as $layoutFile) { $options[] = ['label' => $layoutFile, 'value' => $layoutFile]; } - } catch (LocalizedException $exception) { - } $customLayoutMeta = [ From 376676f1ed8638e37cceb50cf0dc6a4a4a803953 Mon Sep 17 00:00:00 2001 From: Pierpaolo Wurzburger Date: Wed, 16 Dec 2020 10:19:37 +0100 Subject: [PATCH 11/68] fix reference layout cms_noroute_index core --- .../layout/{cms_index_noroute.xml => cms_noroute_index.xml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/code/Magento/Cms/view/frontend/layout/{cms_index_noroute.xml => cms_noroute_index.xml} (100%) diff --git a/app/code/Magento/Cms/view/frontend/layout/cms_index_noroute.xml b/app/code/Magento/Cms/view/frontend/layout/cms_noroute_index.xml similarity index 100% rename from app/code/Magento/Cms/view/frontend/layout/cms_index_noroute.xml rename to app/code/Magento/Cms/view/frontend/layout/cms_noroute_index.xml From 8ca6c5ae77c4f11d3ed31248a0cdf9ee315b4528 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Wed, 16 Dec 2020 14:32:35 +0200 Subject: [PATCH 12/68] removed loadedPages --- .../Magento/Cms/Model/Page/DataProvider.php | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php index 03dd2cc6866e0..a8943fdeb95bb 100644 --- a/app/code/Magento/Cms/Model/Page/DataProvider.php +++ b/app/code/Magento/Cms/Model/Page/DataProvider.php @@ -52,11 +52,6 @@ class DataProvider extends ModifierPoolDataProvider */ private $customLayoutManager; - /** - * @var null|array - */ - private $loadedPages; - /** * @var LoggerInterface */ @@ -111,7 +106,7 @@ public function __construct( * @param array $meta * @return array */ - public function prepareMeta(array $meta): array + public function prepareMeta(array $meta) { return $meta; } @@ -121,7 +116,7 @@ public function prepareMeta(array $meta): array * * @return array */ - public function getData(): array + public function getData() { if (isset($this->loadedData)) { return $this->loadedData; @@ -173,18 +168,13 @@ private function getCurrentPage(): Page throw new LocalizedException(__('Page ID must be given')); } - if (isset($this->loadedPages[$pageId])) { - return $this->loadedPages[$pageId]; - } - - $this->loadedPages[$pageId] = $this->pageRepository->getById($pageId); - return $this->loadedPages[$pageId]; + return $this->pageRepository->getById($pageId); } /** * @inheritDoc */ - public function getMeta(): array + public function getMeta() { $meta = parent::getMeta(); From 77ad90dc3fa80d4eb22e8d46fd536e58a00b3195 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Fri, 18 Dec 2020 10:57:00 +0200 Subject: [PATCH 13/68] remove exception --- app/code/Magento/Cms/Model/Page/DataProvider.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php index a8943fdeb95bb..7b6bb303b844a 100644 --- a/app/code/Magento/Cms/Model/Page/DataProvider.php +++ b/app/code/Magento/Cms/Model/Page/DataProvider.php @@ -159,14 +159,7 @@ public function getData() */ private function getCurrentPage(): Page { - if (!$this->getRequestFieldName()) { - throw new LocalizedException(__('RequestFieldName is not specified')); - } - - $pageId = (int)$this->request->getParam($this->getRequestFieldName()); - if ($pageId === 0) { - throw new LocalizedException(__('Page ID must be given')); - } + $pageId = $this->request->getParam($this->getRequestFieldName(), 0); return $this->pageRepository->getById($pageId); } From dc965fca722e25323061c18ac7f29ce1b89ddbd0 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Fri, 18 Dec 2020 11:56:56 +0200 Subject: [PATCH 14/68] adjusted integration test --- .../Cms/Model/Page/DataProviderTest.php | 93 +++++++++++-------- 1 file changed, 55 insertions(+), 38 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php index 5197daa759e04..247a9ab34eb36 100644 --- a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php +++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php @@ -9,11 +9,12 @@ namespace Magento\Cms\Model\Page; use Magento\Cms\Api\GetPageByIdentifierInterface; +use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\ObjectManagerInterface; use Magento\TestFramework\Cms\Model\CustomLayoutManager; use Magento\TestFramework\Helper\Bootstrap; use PHPUnit\Framework\TestCase; -use Magento\Cms\Model\Page as PageModel; -use Magento\Framework\App\Request\Http as HttpRequest; /** * Test pages data provider. @@ -22,6 +23,12 @@ */ class DataProviderTest extends TestCase { + private $providerData = [ + 'name' => 'test', + 'primaryFieldName' => 'page_id', + 'requestFieldName' => 'page_id', + ]; + /** * @var DataProvider */ @@ -42,29 +49,26 @@ class DataProviderTest extends TestCase */ private $request; + /** + * @var ObjectManagerInterface + */ + private $objectManager; + /** * @inheritDoc */ protected function setUp(): void { - $objectManager = Bootstrap::getObjectManager(); - $objectManager->configure([ - 'preferences' => [ - \Magento\Cms\Model\Page\CustomLayoutManagerInterface::class => - \Magento\TestFramework\Cms\Model\CustomLayoutManager::class - ] + $this->objectManager = Bootstrap::getObjectManager(); + $this->objectManager->configure([ + 'preferences' => [CustomLayoutManagerInterface::class => CustomLayoutManager::class] ]); - $this->repo = $objectManager->get(GetPageByIdentifierInterface::class); - $this->filesFaker = $objectManager->get(CustomLayoutManager::class); - $this->request = $objectManager->get(HttpRequest::class); - $this->provider = $objectManager->create( + $this->repo = $this->objectManager->get(GetPageByIdentifierInterface::class); + $this->filesFaker = $this->objectManager->get(CustomLayoutManager::class); + $this->request = $this->objectManager->get(HttpRequest::class); + $this->provider = $this->objectManager->create( DataProvider::class, - [ - 'name' => 'test', - 'primaryFieldName' => 'page_id', - 'requestFieldName' => 'page_id', - 'customLayoutManager' => $this->filesFaker - ] + array_merge($this->providerData, ['customLayoutManager' => $this->filesFaker]) ); } @@ -72,29 +76,42 @@ protected function setUp(): void * Check that custom layout date is handled properly. * * @magentoDataFixture Magento/Cms/_files/pages_with_layout_xml.php - * @throws \Throwable + * @dataProvider customLayoutDataProvider + * + * @param string $identifier + * @param string|null $layoutUpdateSelected * @return void */ - public function testCustomLayoutData(): void + public function testCustomLayoutData(string $identifier, ?string $layoutUpdateSelected): void { - $data = $this->provider->getData(); - $page1Data = null; - $page2Data = null; - $page3Data = null; - foreach ($data as $pageData) { - if ($pageData[PageModel::IDENTIFIER] === 'test_custom_layout_page_1') { - $page1Data = $pageData; - } elseif ($pageData[PageModel::IDENTIFIER] === 'test_custom_layout_page_2') { - $page2Data = $pageData; - } elseif ($pageData[PageModel::IDENTIFIER] === 'test_custom_layout_page_3') { - $page3Data = $pageData; - } - } - $this->assertNotEmpty($page1Data); - $this->assertNotEmpty($page2Data); - $this->assertEquals('_existing_', $page1Data['layout_update_selected']); - $this->assertNull($page2Data['layout_update_selected']); - $this->assertEquals('test_selected', $page3Data['layout_update_selected']); + $page = $this->repo->execute($identifier, 0); + + $request = $this->objectManager->create(RequestInterface::class); + $request->setParam('page_id', $page->getId()); + + $provider = $this->objectManager->create( + DataProvider::class, + array_merge($this->providerData, ['request' => $request]) + ); + + $data = $provider->getData(); + $pageData = $data[$page->getId()]; + + $this->assertEquals($layoutUpdateSelected, $pageData['layout_update_selected']); + } + + /** + * DataProvider for testCustomLayoutData + * + * @return array + */ + public function customLayoutDataProvider(): array + { + return [ + ['test_custom_layout_page_1', '_existing_'], + ['test_custom_layout_page_2', null], + ['test_custom_layout_page_3', 'test_selected'], + ]; } /** From 8fde38be1a6df2041286292a69e197630a0edfa6 Mon Sep 17 00:00:00 2001 From: Anna Pak Date: Thu, 24 Dec 2020 16:07:36 +0200 Subject: [PATCH 15/68] added AdminFillTaxIdentifierFilterOnTaxRateGridActionGroup --- ...entifierFilterOnTaxRateGridActionGroup.xml | 21 +++++++++++++++++++ .../AdminCreateTaxRateAllPostCodesTest.xml | 8 +++++-- .../Test/AdminCreateTaxRateLargeRateTest.xml | 4 +++- ...AdminCreateTaxRateSpecificPostcodeTest.xml | 4 +++- ...dminCreateTaxRateWiderZipCodeRangeTest.xml | 4 +++- .../AdminCreateTaxRateZipCodeRangeTest.xml | 4 +++- .../Mftf/Test/DeleteTaxRateEntityTest.xml | 4 +++- .../Mftf/Test/Update01TaxRateEntityTest.xml | 8 +++++-- .../Mftf/Test/Update100TaxRateEntityTest.xml | 8 +++++-- .../Mftf/Test/Update1299TaxRateEntityTest.xml | 8 +++++-- .../Test/UpdateAnyRegionTaxRateEntityTest.xml | 8 +++++-- .../Test/UpdateDecimalTaxRateEntityTest.xml | 8 +++++-- .../Test/UpdateLargeTaxRateEntityTest.xml | 9 +++++--- 13 files changed, 78 insertions(+), 20 deletions(-) create mode 100644 app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminFillTaxIdentifierFilterOnTaxRateGridActionGroup.xml diff --git a/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminFillTaxIdentifierFilterOnTaxRateGridActionGroup.xml b/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminFillTaxIdentifierFilterOnTaxRateGridActionGroup.xml new file mode 100644 index 0000000000000..1c2c72a661ce1 --- /dev/null +++ b/app/code/Magento/Tax/Test/Mftf/ActionGroup/AdminFillTaxIdentifierFilterOnTaxRateGridActionGroup.xml @@ -0,0 +1,21 @@ + + + + + + + Fill the Filter By Tax Identifier field with taxRateCode. + + + + + + + + diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml index ceb04a9c42e66..5f744d1b9eafd 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateAllPostCodesTest.xml @@ -44,7 +44,9 @@ - + + + @@ -55,7 +57,9 @@ - + + + diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml index 7497b950a8c0e..45d50eecc851d 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateLargeRateTest.xml @@ -46,7 +46,9 @@ - + + + diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml index da89ad3e9337c..784f886410c43 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateSpecificPostcodeTest.xml @@ -46,7 +46,9 @@ - + + + diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml index da30157d94182..3963f032cded7 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateWiderZipCodeRangeTest.xml @@ -46,7 +46,9 @@ - + + + diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml index 93e0f6514e83b..6eb7f3d6210ab 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml @@ -47,7 +47,9 @@ - + + + diff --git a/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml index 751989497d10e..0e77e4116ddc1 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/DeleteTaxRateEntityTest.xml @@ -37,7 +37,9 @@ - + + + diff --git a/app/code/Magento/Tax/Test/Mftf/Test/Update01TaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/Update01TaxRateEntityTest.xml index ff75b1e95646a..a6c54136f2eac 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/Update01TaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/Update01TaxRateEntityTest.xml @@ -29,7 +29,9 @@ - + + + @@ -46,7 +48,9 @@ - + + + diff --git a/app/code/Magento/Tax/Test/Mftf/Test/Update100TaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/Update100TaxRateEntityTest.xml index ebfa1288b59dd..e1975b5ae7552 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/Update100TaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/Update100TaxRateEntityTest.xml @@ -29,7 +29,9 @@ - + + + @@ -45,7 +47,9 @@ - + + + diff --git a/app/code/Magento/Tax/Test/Mftf/Test/Update1299TaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/Update1299TaxRateEntityTest.xml index ed1c126930df8..12883ee18bb54 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/Update1299TaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/Update1299TaxRateEntityTest.xml @@ -29,7 +29,9 @@ - + + + @@ -46,7 +48,9 @@ - + + + diff --git a/app/code/Magento/Tax/Test/Mftf/Test/UpdateAnyRegionTaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/UpdateAnyRegionTaxRateEntityTest.xml index 7a2f0664d7757..b7fd81fda156e 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/UpdateAnyRegionTaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/UpdateAnyRegionTaxRateEntityTest.xml @@ -29,7 +29,9 @@ - + + + @@ -45,7 +47,9 @@ - + + + diff --git a/app/code/Magento/Tax/Test/Mftf/Test/UpdateDecimalTaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/UpdateDecimalTaxRateEntityTest.xml index 03aba8da8ae19..6d7022b656da1 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/UpdateDecimalTaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/UpdateDecimalTaxRateEntityTest.xml @@ -29,7 +29,9 @@ - + + + @@ -47,7 +49,9 @@ - + + + diff --git a/app/code/Magento/Tax/Test/Mftf/Test/UpdateLargeTaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/UpdateLargeTaxRateEntityTest.xml index 37b8bb8d95618..55a431eac61e7 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/UpdateLargeTaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/UpdateLargeTaxRateEntityTest.xml @@ -29,7 +29,9 @@ - + + + @@ -44,8 +46,9 @@ - - + + + From de30e9c13e22227be421e4d0c06bd0148608d4a0 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Tue, 29 Dec 2020 16:55:42 +0200 Subject: [PATCH 16/68] fix delete special prices only for specified store --- .../Product/Price/SpecialPrice.php | 137 +++++++++++------- .../Catalog/Api/SpecialPriceStorageTest.php | 84 ++++++++--- 2 files changed, 152 insertions(+), 69 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Price/SpecialPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Price/SpecialPrice.php index 7eb19193f8bdd..5a7bf93af9e8f 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Price/SpecialPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Price/SpecialPrice.php @@ -6,10 +6,19 @@ namespace Magento\Catalog\Model\ResourceModel\Product\Price; +use Magento\Catalog\Api\ProductAttributeRepositoryInterface; +use Magento\Catalog\Api\SpecialPriceInterface; +use Magento\Catalog\Helper\Data; +use Magento\Catalog\Model\ProductIdLocatorInterface; +use Magento\Catalog\Model\ResourceModel\Attribute; +use Magento\Framework\EntityManager\MetadataPool; +use Magento\Framework\Exception\CouldNotDeleteException; +use Magento\Framework\App\ObjectManager; + /** * Special price resource. */ -class SpecialPrice implements \Magento\Catalog\Api\SpecialPriceInterface +class SpecialPrice implements SpecialPriceInterface { /** * Price storage table. @@ -26,24 +35,24 @@ class SpecialPrice implements \Magento\Catalog\Api\SpecialPriceInterface private $datetimeTable = 'catalog_product_entity_datetime'; /** - * @var \Magento\Catalog\Model\ResourceModel\Attribute + * @var Attribute */ private $attributeResource; /** - * @var \Magento\Catalog\Api\ProductAttributeRepositoryInterface + * @var ProductAttributeRepositoryInterface */ private $attributeRepository; /** - * @var \Magento\Catalog\Model\ProductIdLocatorInterface + * @var ProductIdLocatorInterface */ private $productIdLocator; /** * Metadata pool. * - * @var \Magento\Framework\EntityManager\MetadataPool + * @var MetadataPool */ private $metadataPool; @@ -68,6 +77,11 @@ class SpecialPrice implements \Magento\Catalog\Api\SpecialPriceInterface */ private $priceToAttributeId; + /** + * @var Data + */ + private $catalogData; + /** * Items per operation. * @@ -76,25 +90,28 @@ class SpecialPrice implements \Magento\Catalog\Api\SpecialPriceInterface private $itemsPerOperation = 500; /** - * @param \Magento\Catalog\Model\ResourceModel\Attribute $attributeResource - * @param \Magento\Catalog\Api\ProductAttributeRepositoryInterface $attributeRepository - * @param \Magento\Catalog\Model\ProductIdLocatorInterface $productIdLocator - * @param \Magento\Framework\EntityManager\MetadataPool $metadataPool + * @param Attribute $attributeResource + * @param ProductAttributeRepositoryInterface $attributeRepository + * @param ProductIdLocatorInterface $productIdLocator + * @param MetadataPool $metadataPool + * @param Data|null $catalogData */ public function __construct( - \Magento\Catalog\Model\ResourceModel\Attribute $attributeResource, - \Magento\Catalog\Api\ProductAttributeRepositoryInterface $attributeRepository, - \Magento\Catalog\Model\ProductIdLocatorInterface $productIdLocator, - \Magento\Framework\EntityManager\MetadataPool $metadataPool + Attribute $attributeResource, + ProductAttributeRepositoryInterface $attributeRepository, + ProductIdLocatorInterface $productIdLocator, + MetadataPool $metadataPool, + ?Data $catalogData = null ) { $this->attributeResource = $attributeResource; $this->attributeRepository = $attributeRepository; $this->productIdLocator = $productIdLocator; $this->metadataPool = $metadataPool; + $this->catalogData = $catalogData ?: ObjectManager::getInstance()->get(Data::class); } /** - * {@inheritdoc} + * @inheritdoc */ public function get(array $skus) { @@ -132,7 +149,7 @@ public function get(array $skus) } /** - * {@inheritdoc} + * @inheritdoc */ public function update(array $prices) { @@ -187,47 +204,69 @@ public function update(array $prices) } /** - * {@inheritdoc} + * @inheritdoc */ public function delete(array $prices) { - $skus = array_unique( - array_map(function ($price) { - return $price->getSku(); - }, $prices) - ); - $ids = $this->retrieveAffectedIds($skus); $connection = $this->attributeResource->getConnection(); - $connection->beginTransaction(); - try { - foreach (array_chunk($ids, $this->itemsPerOperation) as $idsBunch) { - $this->attributeResource->getConnection()->delete( - $this->attributeResource->getTable($this->priceTable), - [ - 'attribute_id = ?' => $this->getPriceAttributeId(), - $this->getEntityLinkField() . ' IN (?)' => $idsBunch - ] - ); + + foreach ($this->getStoreSkus($prices) as $storeId => $skus) { + + $ids = $this->retrieveAffectedIds(array_unique($skus)); + $connection->beginTransaction(); + try { + foreach (array_chunk($ids, $this->itemsPerOperation) as $idsBunch) { + $connection->delete( + $this->attributeResource->getTable($this->priceTable), + [ + 'attribute_id = ?' => $this->getPriceAttributeId(), + 'store_id = ?' => $storeId, + $this->getEntityLinkField() . ' IN (?)' => $idsBunch + ] + ); + } + foreach (array_chunk($ids, $this->itemsPerOperation) as $idsBunch) { + $connection->delete( + $this->attributeResource->getTable($this->datetimeTable), + [ + 'attribute_id IN (?)' => [$this->getPriceFromAttributeId(), $this->getPriceToAttributeId()], + 'store_id = ?' => $storeId, + $this->getEntityLinkField() . ' IN (?)' => $idsBunch + ] + ); + } + $connection->commit(); + } catch (\Exception $e) { + $connection->rollBack(); + throw new CouldNotDeleteException(__('Could not delete Prices'), $e); } - foreach (array_chunk($ids, $this->itemsPerOperation) as $idsBunch) { - $this->attributeResource->getConnection()->delete( - $this->attributeResource->getTable($this->datetimeTable), - [ - 'attribute_id IN (?)' => [$this->getPriceFromAttributeId(), $this->getPriceToAttributeId()], - $this->getEntityLinkField() . ' IN (?)' => $idsBunch - ] + } + + return true; + } + + /** + * Returns associative arrays of store_id as key and array of skus as value. + * + * @param \Magento\Catalog\Api\Data\SpecialPriceInterface[] $priceItems + * @return array + * @throws CouldNotDeleteException + */ + private function getStoreSkus(array $priceItems): array + { + $isPriceGlobal = $this->catalogData->isPriceGlobal(); + + $storeSkus = []; + foreach ($priceItems as $priceItem) { + if ($isPriceGlobal && $priceItem->getStoreId() !== 0) { + throw new CouldNotDeleteException( + __('Could not delete Prices for non-default store when price scope is global.') ); } - $connection->commit(); - } catch (\Exception $e) { - $connection->rollBack(); - throw new \Magento\Framework\Exception\CouldNotDeleteException( - __('Could not delete Prices'), - $e - ); + $storeSkus[$priceItem->getStoreId()][] = $priceItem->getSku(); } - return true; + return $storeSkus; } /** @@ -312,9 +351,9 @@ private function retrieveAffectedIds(array $skus) $affectedIds = []; foreach ($this->productIdLocator->retrieveProductIdsBySkus($skus) as $productIds) { - $affectedIds = array_merge($affectedIds, array_keys($productIds)); + $affectedIds[] = array_keys($productIds); } - return array_unique($affectedIds); + return array_unique(array_merge([], ...$affectedIds)); } } diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php index 90fe075f91e30..a5cbcbe3a0d22 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php @@ -6,11 +6,8 @@ namespace Magento\Catalog\Api; use Magento\Catalog\Api\Data\ProductInterface; -use Magento\Framework\Exception\CouldNotSaveException; -use Magento\Framework\Exception\InputException; -use Magento\Framework\Exception\NoSuchEntityException; -use Magento\Framework\Exception\StateException; use Magento\Framework\Webapi\Rest\Request; +use Magento\Catalog\Model\ResourceModel\Product as ProductResource; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\ObjectManager; use Magento\TestFramework\TestCase\WebapiAbstract; @@ -31,11 +28,17 @@ class SpecialPriceStorageTest extends WebapiAbstract private $objectManager; /** - * Set up. + * @var ProductResource + */ + private $productResource; + + /** + * @ingeritdoc */ protected function setUp(): void { $this->objectManager = Bootstrap::getObjectManager(); + $this->productResource = $this->objectManager->get(ProductResource::class); } /** @@ -128,28 +131,67 @@ public function testUpdate(array $data) $this->assertEmpty($response); } + /** + * Delete special price for specified store when price scope is global + * + * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php + * + * @return void + */ + public function testDeleteWhenPriceIsGlobal(): void + { + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => '/V1/products/special-price-delete', + 'httpMethod' => Request::HTTP_METHOD_POST + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'Delete', + ], + ]; + + $this->expectErrorMessage('Could not delete Prices for non-default store when price scope is global.'); + + $this->_webApiCall( + $serviceInfo, + [ + 'prices' => [ + ['price' => 777, 'store_id' => 1, 'sku' => self::SIMPLE_PRODUCT_SKU] + ] + ] + ); + } + /** * Test delete method. * * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php + * @magentoConfigFixture catalog/price/scope 1 * @dataProvider deleteData * @param array $data - * @throws CouldNotSaveException - * @throws InputException - * @throws NoSuchEntityException - * @throws StateException + * @return void */ - public function testDelete(array $data) + public function testDelete(array $data): void { /** @var ProductRepositoryInterface $productRepository */ $productRepository = $this->objectManager->create(ProductRepositoryInterface::class); - $product = $productRepository->get($data['sku'], true); + $product = $productRepository->get($data['sku'], true, $data['store_id'], true); $product->setData('special_price', $data['price']); $product->setData('special_from_date', $data['price_from']); if ($data['price_to']) { $product->setData('special_to_date', $data['price_to']); } - $productRepository->save($product); + $this->productResource->saveAttribute($product, 'special_price'); + $this->productResource->saveAttribute($product, 'special_from_date'); + $this->productResource->saveAttribute($product, 'special_to_date'); + + $product->setData('store_id', 1); + $this->productResource->saveAttribute($product, 'special_price'); + $this->productResource->saveAttribute($product, 'special_from_date'); + $this->productResource->saveAttribute($product, 'special_to_date'); + $serviceInfo = [ 'rest' => [ 'resourcePath' => '/V1/products/special-price-delete', @@ -161,17 +203,21 @@ public function testDelete(array $data) 'operation' => self::SERVICE_NAME . 'Delete', ], ]; + $response = $this->_webApiCall( $serviceInfo, [ - 'prices' => [ - $data - ] + 'prices' => [$data] ] ); - $product = $productRepository->get($data['sku'], false, null, true); + $this->assertEmpty($response); + + $product = $productRepository->get($data['sku'], false, $data['store_id'], true); $this->assertNull($product->getSpecialPrice()); + + $product = $productRepository->get($data['sku'], false, 1, true); + $this->assertNotNull($product->getSpecialPrice()); } /** @@ -219,8 +265,7 @@ public function deleteData(): array $toDate = '2038-01-19 03:14:07'; return [ - [ - // data set with 'price_to' specified + 'data set with price_to specified' => [ [ 'price' => 3057, 'store_id' => 0, @@ -229,8 +274,7 @@ public function deleteData(): array 'price_to' => $toDate ] ], - [ - // data set without 'price_to' specified + 'data set without price_to specified' => [ [ 'price' => 3057, 'store_id' => 0, From 8f843efc05cd048cd8405d0f79eada2ed841df78 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Wed, 30 Dec 2020 12:02:59 +0200 Subject: [PATCH 17/68] fix webapi test --- .../Magento/Catalog/Api/SpecialPriceStorageTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php index a5cbcbe3a0d22..782b2cbbe4b3b 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php @@ -21,6 +21,7 @@ class SpecialPriceStorageTest extends WebapiAbstract const SERVICE_VERSION = 'V1'; const SIMPLE_PRODUCT_SKU = 'simple'; const VIRTUAL_PRODUCT_SKU = 'virtual-product'; + private const PRODUCT_SKU_TWO_WEBSITES = 'simple-on-two-websites'; /** * @var ObjectManager @@ -167,7 +168,7 @@ public function testDeleteWhenPriceIsGlobal(): void /** * Test delete method. * - * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php + * @magentoApiDataFixture Magento/Catalog/_files/product_two_websites.php * @magentoConfigFixture catalog/price/scope 1 * @dataProvider deleteData * @param array $data @@ -269,7 +270,7 @@ public function deleteData(): array [ 'price' => 3057, 'store_id' => 0, - 'sku' => self::SIMPLE_PRODUCT_SKU, + 'sku' => self::PRODUCT_SKU_TWO_WEBSITES, 'price_from' => $fromDate, 'price_to' => $toDate ] @@ -278,7 +279,7 @@ public function deleteData(): array [ 'price' => 3057, 'store_id' => 0, - 'sku' => self::SIMPLE_PRODUCT_SKU, + 'sku' => self::PRODUCT_SKU_TWO_WEBSITES, 'price_from' => $fromDate, 'price_to' => false ] From e840a57d52a96efde7d7af88eb2ad4faeaef4af4 Mon Sep 17 00:00:00 2001 From: Anna Pak Date: Mon, 4 Jan 2021 11:39:43 +0200 Subject: [PATCH 18/68] refactored AdminPanelIsFrozenIfStorefrontIsOpenedViaCustomerViewTest --- ...intOrderLinkOnViewOrderPageActionGroup.xml | 19 ++++++ ...ViewOrderLinkOnMyOrdersPageActionGroup.xml | 19 ++++++ ...fStorefrontIsOpenedViaCustomerViewTest.xml | 64 ++++++++++--------- 3 files changed, 72 insertions(+), 30 deletions(-) create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontClickPrintOrderLinkOnViewOrderPageActionGroup.xml create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontClickViewOrderLinkOnMyOrdersPageActionGroup.xml diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontClickPrintOrderLinkOnViewOrderPageActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontClickPrintOrderLinkOnViewOrderPageActionGroup.xml new file mode 100644 index 0000000000000..cbe227c1809f3 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontClickPrintOrderLinkOnViewOrderPageActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + Clicks the "Print Order" link on the My Account->My Orders->Order View page + + + + + + diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontClickViewOrderLinkOnMyOrdersPageActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontClickViewOrderLinkOnMyOrdersPageActionGroup.xml new file mode 100644 index 0000000000000..232667cd9a8e5 --- /dev/null +++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontClickViewOrderLinkOnMyOrdersPageActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + Clicks the top "View Order" link on the My Account->My Orders page + + + + + + diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminPanelIsFrozenIfStorefrontIsOpenedViaCustomerViewTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminPanelIsFrozenIfStorefrontIsOpenedViaCustomerViewTest.xml index 77422c6e8da3f..b975cf62765c1 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/AdminPanelIsFrozenIfStorefrontIsOpenedViaCustomerViewTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminPanelIsFrozenIfStorefrontIsOpenedViaCustomerViewTest.xml @@ -6,7 +6,8 @@ */ --> - + @@ -23,37 +24,41 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -61,12 +66,11 @@ - - - + + + - From 0406e7685b320761cad78fd5d91cbdfaf9d8304f Mon Sep 17 00:00:00 2001 From: Anna Pak Date: Mon, 4 Jan 2021 11:58:25 +0200 Subject: [PATCH 19/68] refactored AdminValidateShippingTrackingNumberTest --- .../Test/AdminAttributeSetSelectionTest.xml | 18 ++- .../AdminBasicBundleProductAttributesTest.xml | 8 +- ...tributeSetOnEditProductPageActionGroup.xml | 23 +++ ...tHoverProductOnCategoryPageActionGroup.xml | 19 +++ .../AddOutOfStockProductToCompareListTest.xml | 145 ++++++++++-------- .../AdminChangeProductAttributeSetTest.xml | 8 +- .../AdminCreateAttributeSetEntityTest.xml | 8 +- ...minCreateProductCustomAttributeSetTest.xml | 8 +- .../Adminhtml/Order/Creditmemo/View.php | 9 +- .../Adminhtml/Order/CreditmemoLoader.php | 21 ++- .../Adminhtml/Order/Invoice/View.php | 7 +- .../AdminGoToCreditmemoViewActionGroup.xml | 22 +++ .../Mftf/Page/AdminCreditMemoViewPage.xml | 2 +- ...tmemoViewPageWithWrongCreditmemoIdTest.xml | 35 +++++ .../Adminhtml/Order/Creditmemo/ViewTest.php | 62 ++++++-- .../Adminhtml/Order/Invoice/ViewTest.php | 63 ++++++-- app/code/Magento/Sales/i18n/en_US.csv | 1 + .../Adminhtml/Order/Shipment/View.php | 9 +- .../Adminhtml/Order/ShipmentLoader.php | 10 +- .../AdminGoToShipmentViewActionGroup.xml | 22 +++ .../Test/Mftf/Page/AdminShipmentViewPage.xml | 13 ++ ...hipmentViewPageWithWrongShipmentIdTest.xml | 36 +++++ ...dminValidateShippingTrackingNumberTest.xml | 27 +++- .../Adminhtml/Order/Shipment/ViewTest.php | 63 ++++++-- app/code/Magento/Shipping/i18n/en_US.csv | 1 + 25 files changed, 489 insertions(+), 151 deletions(-) create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSelectAttributeSetOnEditProductPageActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontHoverProductOnCategoryPageActionGroup.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminGoToCreditmemoViewActionGroup.xml create mode 100644 app/code/Magento/Sales/Test/Mftf/Test/AdminOpenCreditmemoViewPageWithWrongCreditmemoIdTest.xml create mode 100644 app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminGoToShipmentViewActionGroup.xml create mode 100644 app/code/Magento/Shipping/Test/Mftf/Page/AdminShipmentViewPage.xml create mode 100644 app/code/Magento/Shipping/Test/Mftf/Test/AdminOpenShipmentViewPageWithWrongShipmentIdTest.xml diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdminAttributeSetSelectionTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdminAttributeSetSelectionTest.xml index ca8a35ee7a363..ceed14e76fb4b 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/AdminAttributeSetSelectionTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdminAttributeSetSelectionTest.xml @@ -42,9 +42,13 @@ - - - + + + + + + + @@ -64,9 +68,11 @@ - - - + + + + + diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdminBasicBundleProductAttributesTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdminBasicBundleProductAttributesTest.xml index 79d85c6ced957..228c1d3cf1def 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/AdminBasicBundleProductAttributesTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdminBasicBundleProductAttributesTest.xml @@ -109,9 +109,11 @@ - - - + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSelectAttributeSetOnEditProductPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSelectAttributeSetOnEditProductPageActionGroup.xml new file mode 100644 index 0000000000000..31a4521331664 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminSelectAttributeSetOnEditProductPageActionGroup.xml @@ -0,0 +1,23 @@ + + + + + + + Selects the specified value from the Attribute Set dropdown on the opened product edit page. + + + + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontHoverProductOnCategoryPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontHoverProductOnCategoryPageActionGroup.xml new file mode 100644 index 0000000000000..10d85a91a02c6 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/StorefrontHoverProductOnCategoryPageActionGroup.xml @@ -0,0 +1,19 @@ + + + + + + + Hover product on the Category page + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml index 92be79fdfe720..995fa4c7e5977 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AddOutOfStockProductToCompareListTest.xml @@ -20,7 +20,7 @@ - + @@ -30,6 +30,7 @@ + @@ -37,74 +38,92 @@ - + - - - - - - + + + + + + + + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - ($grabTextFromSuccessMessage) - You added product $$product.name$$ to the comparison list. - - - - - - - - - - - - - - - - - - - - - - - - ($grabTextFromSuccessMessage) - You added product $$product.name$$ to the comparison list. - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminChangeProductAttributeSetTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminChangeProductAttributeSetTest.xml index 3b8c2cb736721..e7d4241500bfb 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminChangeProductAttributeSetTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminChangeProductAttributeSetTest.xml @@ -60,9 +60,11 @@ - - - + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateAttributeSetEntityTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateAttributeSetEntityTest.xml index 9fef5e4203167..8d3fbbaa34355 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateAttributeSetEntityTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateAttributeSetEntityTest.xml @@ -64,9 +64,11 @@ - - - + + + + + diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductCustomAttributeSetTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductCustomAttributeSetTest.xml index d2278f3ddae1d..d1110f593545d 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductCustomAttributeSetTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateProductCustomAttributeSetTest.xml @@ -62,9 +62,11 @@ - - - + + + + + diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/View.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/View.php index be0afdb4a043b..c5832f64547c1 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/View.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/View.php @@ -6,8 +6,9 @@ namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo; use Magento\Backend\App\Action; +use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface; -class View extends \Magento\Backend\App\Action +class View extends \Magento\Backend\App\Action implements HttpGetActionInterface { /** * Authorization level of a basic admin session @@ -75,9 +76,9 @@ public function execute() } return $resultPage; } else { - $resultForward = $this->resultForwardFactory->create(); - $resultForward->forward('noroute'); - return $resultForward; + $resultRedirect = $this->resultRedirectFactory->create(); + $resultRedirect->setPath('sales/creditmemo'); + return $resultRedirect; } } } diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoader.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoader.php index 0c5864e954a4f..c1e79b95af038 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoader.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/CreditmemoLoader.php @@ -8,12 +8,12 @@ use Magento\Framework\DataObject; use Magento\Sales\Api\CreditmemoRepositoryInterface; -use \Magento\Sales\Model\Order\CreditmemoFactory; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\Order\CreditmemoFactory; /** - * Class CreditmemoLoader + * Loader for creditmemo * - * @package Magento\Sales\Controller\Adminhtml\Order * @method CreditmemoLoader setCreditmemoId($id) * @method CreditmemoLoader setCreditmemo($creditMemo) * @method CreditmemoLoader setInvoiceId($id) @@ -22,6 +22,7 @@ * @method string getCreditmemo() * @method int getInvoiceId() * @method int getOrderId() + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) */ class CreditmemoLoader extends DataObject { @@ -129,7 +130,8 @@ protected function _getItemData() /** * Check if creditmeno can be created for order - * @param \Magento\Sales\Model\Order $order + * + * @param Order $order * @return bool */ protected function _canCreditmemo($order) @@ -153,7 +155,9 @@ protected function _canCreditmemo($order) } /** - * @param \Magento\Sales\Model\Order $order + * Inits invoice + * + * @param Order $order * @return $this|bool */ protected function _initInvoice($order) @@ -181,7 +185,12 @@ public function load() $creditmemoId = $this->getCreditmemoId(); $orderId = $this->getOrderId(); if ($creditmemoId) { - $creditmemo = $this->creditmemoRepository->get($creditmemoId); + try { + $creditmemo = $this->creditmemoRepository->get($creditmemoId); + } catch (\Exception $e) { + $this->messageManager->addErrorMessage(__('This creditmemo no longer exists.')); + return false; + } } elseif ($orderId) { $data = $this->getCreditmemo(); $order = $this->orderFactory->create()->load($orderId); diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php index da700aae2f78a..b0e860d7f2e2d 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php @@ -44,9 +44,10 @@ public function execute() { $invoice = $this->getInvoice(); if (!$invoice) { - /** @var \Magento\Framework\Controller\Result\Forward $resultForward */ - $resultForward = $this->resultForwardFactory->create(); - return $resultForward->forward('noroute'); + /** @var \Magento\Framework\Controller\Result\RedirectFactory $resultRedirect */ + $resultRedirect = $this->resultRedirectFactory->create(); + $resultRedirect->setPath('sales/invoice'); + return $resultRedirect; } /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminGoToCreditmemoViewActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminGoToCreditmemoViewActionGroup.xml new file mode 100644 index 0000000000000..08d02fe2b7bb1 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminGoToCreditmemoViewActionGroup.xml @@ -0,0 +1,22 @@ + + + + + + + Goes to the Order Creditmemo View Page. + + + + + + + + + diff --git a/app/code/Magento/Sales/Test/Mftf/Page/AdminCreditMemoViewPage.xml b/app/code/Magento/Sales/Test/Mftf/Page/AdminCreditMemoViewPage.xml index 2e61424b29a56..2a3bc814364ae 100644 --- a/app/code/Magento/Sales/Test/Mftf/Page/AdminCreditMemoViewPage.xml +++ b/app/code/Magento/Sales/Test/Mftf/Page/AdminCreditMemoViewPage.xml @@ -8,7 +8,7 @@ - +
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminOpenCreditmemoViewPageWithWrongCreditmemoIdTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminOpenCreditmemoViewPageWithWrongCreditmemoIdTest.xml new file mode 100644 index 0000000000000..38b85828c3421 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminOpenCreditmemoViewPageWithWrongCreditmemoIdTest.xml @@ -0,0 +1,35 @@ + + + + + + + + + <description value="Open Creditmemo View Page with Wrong Creditmemo Id."/> + <severity value="BLOCKER"/> + <testCaseId value="MC-39500"/> + <group value="sales"/> + </annotations> + <before> + <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> + </before> + <after> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> + </after> + + <actionGroup ref="AdminGoToCreditmemoViewActionGroup" stepKey="navigateOpenCreditmemoViewPage"> + <argument name="identifier" value="test"/> + </actionGroup> + + <waitForPageLoad stepKey="waitForPageLoad"/> + <seeInCurrentUrl url="{{AdminCreditMemosGridPage.url}}" stepKey="redirectToCreditMemosGridPage"/> + <see selector="{{AdminMessagesSection.error}}" userInput='This creditmemo no longer exists.' stepKey="seeErrorMessage"/> + </test> +</tests> diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/ViewTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/ViewTest.php index 46c3113c8edc2..b7249e2af295c 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/ViewTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/ViewTest.php @@ -13,6 +13,8 @@ use Magento\Backend\Model\View\Result\Forward; use Magento\Backend\Model\View\Result\ForwardFactory; use Magento\Backend\Model\View\Result\Page; +use Magento\Backend\Model\View\Result\Redirect; +use Magento\Backend\Model\View\Result\RedirectFactory; use Magento\Framework\App\ActionFlag; use Magento\Framework\App\Request\Http; use Magento\Framework\Message\Manager; @@ -105,6 +107,17 @@ class ViewTest extends TestCase */ protected $pageTitleMock; + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\View + * @var RedirectFactory|MockObject + */ + protected $resultRedirectFactoryMock; + + /** + * @var Redirect|MockObject + */ + protected $resultRedirectMock; + /** * @var PageFactory|MockObject */ @@ -130,9 +143,6 @@ class ViewTest extends TestCase */ protected function setUp(): void { - $titleMock = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class) - ->disableOriginalConstructor() - ->getMock(); $this->invoiceMock = $this->getMockBuilder(Invoice::class) ->disableOriginalConstructor() ->getMock(); @@ -203,7 +213,13 @@ protected function setUp(): void $this->resultForwardMock = $this->getMockBuilder(Forward::class) ->disableOriginalConstructor() ->getMock(); - + $this->resultRedirectFactoryMock = $this->getMockBuilder(RedirectFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->resultRedirectMock = $this->getMockBuilder(Redirect::class) + ->disableOriginalConstructor() + ->getMock(); $this->contextMock->expects($this->any()) ->method('getSession') ->willReturn($this->sessionMock); @@ -219,9 +235,6 @@ protected function setUp(): void $this->contextMock->expects($this->any()) ->method('getObjectManager') ->willReturn($this->objectManagerMock); - $this->contextMock->expects($this->any()) - ->method('getTitle') - ->willReturn($titleMock); $this->contextMock->expects($this->any()) ->method('getMessageManager') ->willReturn($this->messageManagerMock); @@ -239,7 +252,8 @@ protected function setUp(): void 'context' => $this->contextMock, 'creditmemoLoader' => $this->loaderMock, 'resultPageFactory' => $this->resultPageFactoryMock, - 'resultForwardFactory' => $this->resultForwardFactoryMock + 'resultForwardFactory' => $this->resultForwardFactoryMock, + 'resultRedirectFactory' => $this->resultRedirectFactoryMock ] ); } @@ -252,16 +266,11 @@ public function testExecuteNoCreditMemo() $this->loaderMock->expects($this->once()) ->method('load') ->willReturn(false); - $this->resultForwardFactoryMock->expects($this->once()) - ->method('create') - ->willReturn($this->resultForwardMock); - $this->resultForwardMock->expects($this->once()) - ->method('forward') - ->with('noroute') - ->willReturnSelf(); + $this->prepareRedirect(); + $this->setPath('sales/creditmemo'); $this->assertInstanceOf( - Forward::class, + Redirect::class, $this->controller->execute() ); } @@ -322,4 +331,25 @@ public function executeDataProvider() [$this->invoiceMock] ]; } + + /** + * prepareRedirect + */ + protected function prepareRedirect() + { + $this->resultRedirectFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($this->resultRedirectMock); + } + + /** + * @param string $path + * @param array $params + */ + protected function setPath($path, $params = []) + { + $this->resultRedirectMock->expects($this->once()) + ->method('setPath') + ->with($path, $params); + } } diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php index c8376ab379b6f..3429b3df85b8a 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php @@ -13,6 +13,8 @@ use Magento\Backend\Model\View\Result\Forward; use Magento\Backend\Model\View\Result\ForwardFactory; use Magento\Backend\Model\View\Result\Page; +use Magento\Backend\Model\View\Result\Redirect; +use Magento\Backend\Model\View\Result\RedirectFactory; use Magento\Framework\App\ActionFlag; use Magento\Framework\App\Request\Http; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -29,6 +31,7 @@ /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + * @SuppressWarnings(PHPMD.TooManyFields) */ class ViewTest extends TestCase { @@ -82,6 +85,17 @@ class ViewTest extends TestCase */ protected $pageTitleMock; + /** + * @var \Magento\Sales\Controller\Adminhtml\Order\Invoice\View + * @var RedirectFactory|MockObject + */ + protected $resultRedirectFactoryMock; + + /** + * @var Redirect|MockObject + */ + protected $resultRedirectMock; + /** * @var View */ @@ -114,10 +128,6 @@ protected function setUp(): void ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->titleMock = $this->getMockBuilder(\Magento\Framework\App\Action\Title::class) - ->disableOriginalConstructor() - ->setMethods([]) - ->getMock(); $this->viewMock = $this->getMockBuilder(\Magento\Framework\App\View::class) ->disableOriginalConstructor() ->setMethods([]) @@ -163,9 +173,6 @@ protected function setUp(): void $contextMock->expects($this->any()) ->method('getResponse') ->willReturn($this->responseMock); - $contextMock->expects($this->any()) - ->method('getTitle') - ->willReturn($this->titleMock); $contextMock->expects($this->any()) ->method('getView') ->willReturn($this->viewMock); @@ -194,6 +201,13 @@ protected function setUp(): void )->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); + $this->resultRedirectFactoryMock = $this->getMockBuilder(RedirectFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->resultRedirectMock = $this->getMockBuilder(Redirect::class) + ->disableOriginalConstructor() + ->getMock(); $this->invoiceRepository = $this->getMockBuilder(InvoiceRepositoryInterface::class) ->disableOriginalConstructor() ->getMockForAbstractClass(); @@ -203,7 +217,8 @@ protected function setUp(): void [ 'context' => $contextMock, 'resultPageFactory' => $this->resultPageFactoryMock, - 'resultForwardFactory' => $this->resultForwardFactoryMock + 'resultForwardFactory' => $this->resultForwardFactoryMock, + 'resultRedirectFactory' => $this->resultRedirectFactoryMock ] ); @@ -287,16 +302,32 @@ public function testExecuteNoInvoice() ->method('get') ->willReturn(null); - $resultForward = $this->getMockBuilder(Forward::class) - ->disableOriginalConstructor() - ->setMethods([]) - ->getMock(); - $resultForward->expects($this->once())->method('forward')->with(('noroute'))->willReturnSelf(); + $this->prepareRedirect(); + $this->setPath('sales/invoice'); + $this->assertInstanceOf( + Redirect::class, + $this->controller->execute() + ); + } - $this->resultForwardFactoryMock->expects($this->once()) + /** + * prepareRedirect + */ + protected function prepareRedirect() + { + $this->resultRedirectFactoryMock->expects($this->once()) ->method('create') - ->willReturn($resultForward); + ->willReturn($this->resultRedirectMock); + } - $this->assertSame($resultForward, $this->controller->execute()); + /** + * @param string $path + * @param array $params + */ + protected function setPath($path, $params = []) + { + $this->resultRedirectMock->expects($this->once()) + ->method('setPath') + ->with($path, $params); } } diff --git a/app/code/Magento/Sales/i18n/en_US.csv b/app/code/Magento/Sales/i18n/en_US.csv index 13afa0832086e..ce8cbcb181dcd 100644 --- a/app/code/Magento/Sales/i18n/en_US.csv +++ b/app/code/Magento/Sales/i18n/en_US.csv @@ -804,4 +804,5 @@ If set YES Email field will be required during Admin order creation for new Cust "Please enter a coupon code!","Please enter a coupon code!" "Reorder is not available.","Reorder is not available." "The coupon code has been removed.","The coupon code has been removed." +"This creditmemo no longer exists.","This creditmemo no longer exists." "Add to address book","Add to address book" diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/View.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/View.php index d8fda0bfe781b..d903a1a7d5889 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/View.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/View.php @@ -7,8 +7,9 @@ namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment; use Magento\Backend\App\Action; +use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface; -class View extends \Magento\Backend\App\Action +class View extends \Magento\Backend\App\Action implements HttpGetActionInterface { /** * Authorization level of a basic admin session @@ -71,9 +72,9 @@ public function execute() $resultPage->getConfig()->getTitle()->prepend("#" . $shipment->getIncrementId()); return $resultPage; } else { - $resultForward = $this->resultForwardFactory->create(); - $resultForward->forward('noroute'); - return $resultForward; + $resultRedirect = $this->resultRedirectFactory->create(); + $resultRedirect->setPath('sales/shipment'); + return $resultRedirect; } } } diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoader.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoader.php index c4094a63ec527..5f0a2fb24c96f 100644 --- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoader.php +++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/ShipmentLoader.php @@ -18,9 +18,8 @@ use Magento\Sales\Api\Data\ShipmentItemCreationInterface; /** - * Class ShipmentLoader + * Loader for shipment * - * @package Magento\Shipping\Controller\Adminhtml\Order * @method ShipmentLoader setOrderId($id) * @method ShipmentLoader setShipmentId($id) * @method ShipmentLoader setShipment($shipment) @@ -110,7 +109,12 @@ public function load() $orderId = $this->getOrderId(); $shipmentId = $this->getShipmentId(); if ($shipmentId) { - $shipment = $this->shipmentRepository->get($shipmentId); + try { + $shipment = $this->shipmentRepository->get($shipmentId); + } catch (\Exception $e) { + $this->messageManager->addErrorMessage(__('This shipment no longer exists.')); + return false; + } } elseif ($orderId) { $order = $this->orderRepository->get($orderId); diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminGoToShipmentViewActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminGoToShipmentViewActionGroup.xml new file mode 100644 index 0000000000000..14587e17f75ba --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminGoToShipmentViewActionGroup.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminGoToShipmentViewActionGroup"> + <annotations> + <description>Goes to the Order Shipment View Page.</description> + </annotations> + <arguments> + <argument name="identifier" type="string"/> + </arguments> + + <amOnPage url="{{AdminShipmentViewPage.url}}/{{identifier}}" stepKey="amOnShipmentViewPage"/> + <waitForPageLoad stepKey="waitForPageLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Shipping/Test/Mftf/Page/AdminShipmentViewPage.xml b/app/code/Magento/Shipping/Test/Mftf/Page/AdminShipmentViewPage.xml new file mode 100644 index 0000000000000..e78a4d5b2701c --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/Page/AdminShipmentViewPage.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> + <page name="AdminShipmentViewPage" url="sales/shipment/view/shipment_id" area="admin" module="Shipping"> + </page> +</pages> diff --git a/app/code/Magento/Shipping/Test/Mftf/Test/AdminOpenShipmentViewPageWithWrongShipmentIdTest.xml b/app/code/Magento/Shipping/Test/Mftf/Test/AdminOpenShipmentViewPageWithWrongShipmentIdTest.xml new file mode 100644 index 0000000000000..d60dca08e6813 --- /dev/null +++ b/app/code/Magento/Shipping/Test/Mftf/Test/AdminOpenShipmentViewPageWithWrongShipmentIdTest.xml @@ -0,0 +1,36 @@ +<?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="AdminOpenShipmentViewPageWithWrongShipmentIdTest"> + <annotations> + <stories value="Shipment Page With Wrong Shipment Id"/> + <title value="Open Shipment View Page with Wrong Shipment Id"/> + <description value="Open Shipment View Page with Wrong Shipment Id."/> + <severity value="BLOCKER"/> + <testCaseId value="MC-39502"/> + <group value="shipping"/> + </annotations> + <before> + <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> + </before> + <after> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> + </after> + + <actionGroup ref="AdminGoToShipmentViewActionGroup" stepKey="navigateOpenShipmentViewPage"> + <argument name="identifier" value="test"/> + </actionGroup> + + <waitForPageLoad stepKey="waitForPageLoad"/> + <seeInCurrentUrl url="{{AdminShipmentsGridPage.url}}" stepKey="redirectToShipmentsGridPage"/> + <see selector="{{AdminMessagesSection.error}}" userInput='This shipment no longer exists.' + stepKey="seeErrorMessage"/> + </test> +</tests> diff --git a/app/code/Magento/Shipping/Test/Mftf/Test/AdminValidateShippingTrackingNumberTest.xml b/app/code/Magento/Shipping/Test/Mftf/Test/AdminValidateShippingTrackingNumberTest.xml index 0d709e1d08006..de45cbf9bb2fe 100644 --- a/app/code/Magento/Shipping/Test/Mftf/Test/AdminValidateShippingTrackingNumberTest.xml +++ b/app/code/Magento/Shipping/Test/Mftf/Test/AdminValidateShippingTrackingNumberTest.xml @@ -19,6 +19,22 @@ <before> <createData entity="Simple_US_Customer" stepKey="createCustomer"/> <createData entity="SimpleProduct2" stepKey="createSimpleProduct"/> + <createData entity="CustomerCart" stepKey="createCustomerCart"> + <requiredEntity createDataKey="createCustomer"/> + </createData> + <createData entity="CustomerCartItem" stepKey="addCartItem"> + <requiredEntity createDataKey="createCustomerCart"/> + <requiredEntity createDataKey="createSimpleProduct"/> + </createData> + <createData entity="CustomerAddressInformation" stepKey="addCustomerOrderAddress"> + <requiredEntity createDataKey="createCustomerCart"/> + </createData> + <updateData createDataKey="createCustomerCart" entity="CustomerOrderPaymentMethod" stepKey="sendCustomerPaymentInformation"> + <requiredEntity createDataKey="createCustomerCart"/> + </updateData> + <createData entity="Shipment" stepKey="shipOrder"> + <requiredEntity createDataKey="createCustomerCart"/> + </createData> <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> </before> <after> @@ -26,12 +42,11 @@ <deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> - <actionGroup ref="CreateOrderActionGroup" stepKey="goToCreateOrderPage"> - <argument name="customer" value="$$createCustomer$$"/> - <argument name="product" value="$$createSimpleProduct$$"/> - </actionGroup> - <grabTextFrom selector="|Order # (\d+)|" stepKey="orderId"/> - <actionGroup ref="AdminShipThePendingOrderActionGroup" stepKey="createShipmentForOrder"/> + <comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="goToCreateOrderPage"/> + <actionGroup ref="AdminOrdersPageOpenActionGroup" stepKey="openOrdersGrid"/> + <actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearFilters"/> + <grabTextFrom selector="{{AdminOrdersGridSection.orderIdByIncrementId($createCustomerCart.return$)}}" stepKey="orderId"/> + <comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="createShipmentForOrder"/> <actionGroup ref="FilterShipmentGridByOrderIdActionGroup" stepKey="filterForNewlyCreatedShipment"> <argument name="orderId" value="$orderId"/> </actionGroup> diff --git a/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/ViewTest.php b/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/ViewTest.php index 04b357eeaefca..aa983aa5c86ce 100644 --- a/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/ViewTest.php +++ b/app/code/Magento/Shipping/Test/Unit/Controller/Adminhtml/Order/Shipment/ViewTest.php @@ -11,6 +11,8 @@ use Magento\Backend\Model\View\Result\Forward; use Magento\Backend\Model\View\Result\ForwardFactory; use Magento\Backend\Model\View\Result\Page; +use Magento\Backend\Model\View\Result\Redirect; +use Magento\Backend\Model\View\Result\RedirectFactory; use Magento\Framework\App\RequestInterface; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; @@ -21,6 +23,7 @@ use Magento\Sales\Model\Order\Shipment; use Magento\Shipping\Block\Adminhtml\View; use Magento\Shipping\Controller\Adminhtml\Order\ShipmentLoader; +use Magento\Shipping\Controller\Adminhtml\Order\Shipment\View as OrderShipmentView; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -86,6 +89,17 @@ class ViewTest extends TestCase /** * @var \Magento\Shipping\Controller\Adminhtml\Order\Shipment\View + * @var RedirectFactory|MockObject + */ + protected $resultRedirectFactoryMock; + + /** + * @var Redirect|MockObject + */ + protected $resultRedirectMock; + + /** + * @var OrderShipmentView */ protected $controller; @@ -130,16 +144,25 @@ protected function setUp(): void ['updateBackButtonUrl'] ); + $this->resultRedirectFactoryMock = $this->getMockBuilder(RedirectFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->resultRedirectMock = $this->getMockBuilder(Redirect::class) + ->disableOriginalConstructor() + ->getMock(); + $objectManager = new ObjectManager($this); $context = $objectManager->getObject( Context::class, [ 'request' => $this->requestMock, - 'objectManager' => $this->objectManagerMock + 'objectManager' => $this->objectManagerMock, + 'resultRedirectFactory' => $this->resultRedirectFactoryMock ] ); $this->controller = $objectManager->getObject( - \Magento\Shipping\Controller\Adminhtml\Order\Shipment\View::class, + OrderShipmentView::class, [ 'context' => $context, 'shipmentLoader' => $this->shipmentLoaderMock, @@ -216,15 +239,12 @@ public function testExecuteNoShipment() $tracking = []; $this->loadShipment($orderId, $shipmentId, $shipment, $tracking, null, false); - $this->resultForwardFactoryMock->expects($this->once()) - ->method('create') - ->willReturn($this->resultForwardMock); - $this->resultForwardMock->expects($this->once()) - ->method('forward') - ->with('noroute') - ->willReturnSelf(); - - $this->assertEquals($this->resultForwardMock, $this->controller->execute()); + $this->prepareRedirect(); + $this->setPath('sales/shipment'); + $this->assertInstanceOf( + Redirect::class, + $this->controller->execute() + ); } /** @@ -255,4 +275,25 @@ protected function loadShipment($orderId, $shipmentId, $shipment, $tracking, $co ->method('load') ->willReturn($returnShipment); } + + /** + * prepareRedirect + */ + protected function prepareRedirect() + { + $this->resultRedirectFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($this->resultRedirectMock); + } + + /** + * @param string $path + * @param array $params + */ + protected function setPath($path, $params = []) + { + $this->resultRedirectMock->expects($this->once()) + ->method('setPath') + ->with($path, $params); + } } diff --git a/app/code/Magento/Shipping/i18n/en_US.csv b/app/code/Magento/Shipping/i18n/en_US.csv index f777e64ef98c9..0989f1bab4a3d 100644 --- a/app/code/Magento/Shipping/i18n/en_US.csv +++ b/app/code/Magento/Shipping/i18n/en_US.csv @@ -177,3 +177,4 @@ City,City "Shipping Methods","Shipping Methods" "Track your order","Track your order" "Track All Shipments","Track All Shipments" +"This shipment no longer exists.","This shipment no longer exists." From 909865a0c4cb53cb2e4cbac3c8319279d580f6d6 Mon Sep 17 00:00:00 2001 From: Anna Pak <a.pak@atwix.com> Date: Mon, 4 Jan 2021 12:32:56 +0200 Subject: [PATCH 20/68] added missed clickSearch2 stepKey --- .../Magento/Tax/Test/Mftf/Test/UpdateLargeTaxRateEntityTest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Tax/Test/Mftf/Test/UpdateLargeTaxRateEntityTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/UpdateLargeTaxRateEntityTest.xml index 55a431eac61e7..07f81928dd1f2 100644 --- a/app/code/Magento/Tax/Test/Mftf/Test/UpdateLargeTaxRateEntityTest.xml +++ b/app/code/Magento/Tax/Test/Mftf/Test/UpdateLargeTaxRateEntityTest.xml @@ -49,6 +49,7 @@ <actionGroup ref="AdminFillTaxIdentifierFilterOnTaxRateGridActionGroup" stepKey="fillTaxIdentifierField3"> <argument name="taxRateCode" value="{{defaultTaxRateWithLargeRate.code}}"/> </actionGroup> + <click selector="{{AdminTaxRateGridSection.search}}" stepKey="clickSearch2"/> <click selector="{{AdminTaxRateGridSection.nthRow('1')}}" stepKey="clickFirstRow2"/> <!-- Verify we see updated large tax rate on the tax rate form page --> <seeInField selector="{{AdminTaxRateFormSection.taxIdentifier}}" userInput="{{defaultTaxRateWithLargeRate.code}}" stepKey="seeRTaxIdentifier"/> From 8fccf4643debc6f54d2b0d401a7794191eee34c1 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" <engcom-vendorworker-charlie@adobe.com> Date: Mon, 4 Jan 2021 14:19:37 +0200 Subject: [PATCH 21/68] add error to aggregator when trying to delete price when price scope is global --- .../Product/Price/SpecialPriceStorage.php | 224 +++++++++--------- .../Product/Price/SpecialPrice.php | 19 +- .../Catalog/Api/SpecialPriceStorageTest.php | 16 +- 3 files changed, 124 insertions(+), 135 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Price/SpecialPriceStorage.php b/app/code/Magento/Catalog/Model/Product/Price/SpecialPriceStorage.php index 83a2d1340794c..00872d19b29fd 100644 --- a/app/code/Magento/Catalog/Model/Product/Price/SpecialPriceStorage.php +++ b/app/code/Magento/Catalog/Model/Product/Price/SpecialPriceStorage.php @@ -6,12 +6,22 @@ namespace Magento\Catalog\Model\Product\Price; +use Magento\Catalog\Api\Data\SpecialPriceInterface; +use Magento\Catalog\Api\Data\SpecialPriceInterfaceFactory; +use Magento\Catalog\Api\SpecialPriceStorageInterface; +use Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor; +use Magento\Catalog\Model\Product\Price\Validation\Result; +use Magento\Catalog\Model\ProductIdLocatorInterface; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Catalog\Helper\Data; +use Magento\Store\Api\StoreRepositoryInterface; /** * Special price storage presents efficient price API and is used to retrieve, update or delete special prices. + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class SpecialPriceStorage implements \Magento\Catalog\Api\SpecialPriceStorageInterface +class SpecialPriceStorage implements SpecialPriceStorageInterface { /** * @var \Magento\Catalog\Api\SpecialPriceInterface @@ -19,52 +29,59 @@ class SpecialPriceStorage implements \Magento\Catalog\Api\SpecialPriceStorageInt private $specialPriceResource; /** - * @var \Magento\Catalog\Api\Data\SpecialPriceInterfaceFactory + * @var SpecialPriceInterfaceFactory */ private $specialPriceFactory; /** - * @var \Magento\Catalog\Model\ProductIdLocatorInterface + * @var ProductIdLocatorInterface */ private $productIdLocator; /** - * @var \Magento\Store\Api\StoreRepositoryInterface + * @var StoreRepositoryInterface */ private $storeRepository; /** - * @var \Magento\Catalog\Model\Product\Price\Validation\Result + * @var Result */ private $validationResult; /** - * @var \Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor + * @var InvalidSkuProcessor */ private $invalidSkuProcessor; /** * @var array */ - private $allowedProductTypes = []; + private $allowedProductTypes; + + /** + * @var Data + */ + private $catalogData; /** * @param \Magento\Catalog\Api\SpecialPriceInterface $specialPriceResource - * @param \Magento\Catalog\Api\Data\SpecialPriceInterfaceFactory $specialPriceFactory - * @param \Magento\Catalog\Model\ProductIdLocatorInterface $productIdLocator - * @param \Magento\Store\Api\StoreRepositoryInterface $storeRepository - * @param \Magento\Catalog\Model\Product\Price\Validation\Result $validationResult - * @param \Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor $invalidSkuProcessor - * @param array $allowedProductTypes [optional] + * @param SpecialPriceInterfaceFactory $specialPriceFactory + * @param ProductIdLocatorInterface $productIdLocator + * @param StoreRepositoryInterface $storeRepository + * @param Result $validationResult + * @param InvalidSkuProcessor $invalidSkuProcessor + * @param array $allowedProductTypes + * @param Data|null $catalogData */ public function __construct( \Magento\Catalog\Api\SpecialPriceInterface $specialPriceResource, - \Magento\Catalog\Api\Data\SpecialPriceInterfaceFactory $specialPriceFactory, - \Magento\Catalog\Model\ProductIdLocatorInterface $productIdLocator, - \Magento\Store\Api\StoreRepositoryInterface $storeRepository, - \Magento\Catalog\Model\Product\Price\Validation\Result $validationResult, - \Magento\Catalog\Model\Product\Price\Validation\InvalidSkuProcessor $invalidSkuProcessor, - array $allowedProductTypes = [] + SpecialPriceInterfaceFactory $specialPriceFactory, + ProductIdLocatorInterface $productIdLocator, + StoreRepositoryInterface $storeRepository, + Result $validationResult, + InvalidSkuProcessor $invalidSkuProcessor, + array $allowedProductTypes = [], + ?Data $catalogData = null ) { $this->specialPriceResource = $specialPriceResource; $this->specialPriceFactory = $specialPriceFactory; @@ -73,10 +90,11 @@ public function __construct( $this->validationResult = $validationResult; $this->invalidSkuProcessor = $invalidSkuProcessor; $this->allowedProductTypes = $allowedProductTypes; + $this->catalogData = $catalogData ?: ObjectManager::getInstance()->get(Data::class); } /** - * {@inheritdoc} + * @inheritdoc */ public function get(array $skus) { @@ -85,7 +103,7 @@ public function get(array $skus) $prices = []; foreach ($rawPrices as $rawPrice) { - /** @var \Magento\Catalog\Api\Data\SpecialPriceInterface $price */ + /** @var SpecialPriceInterface $price */ $price = $this->specialPriceFactory->create(); $sku = isset($rawPrice['sku']) ? $rawPrice['sku'] @@ -102,7 +120,7 @@ public function get(array $skus) } /** - * {@inheritdoc} + * @inheritdoc */ public function update(array $prices) { @@ -113,7 +131,7 @@ public function update(array $prices) } /** - * {@inheritdoc} + * @inheritdoc */ public function delete(array $prices) { @@ -140,52 +158,13 @@ private function retrieveValidPrices(array $prices) foreach ($prices as $key => $price) { if (!$price->getSku() || in_array($price->getSku(), $failedSkus)) { - $this->validationResult->addFailedItem( - $key, - __( - 'The product that was requested doesn\'t exist. Verify the product and try again. ' - . 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.', - [ - 'SKU' => $price->getSku(), - 'storeId' => $price->getStoreId(), - 'priceFrom' => $price->getPriceFrom(), - 'priceTo' => $price->getPriceTo() - ] - ), - [ - 'SKU' => $price->getSku(), - 'storeId' => $price->getStoreId(), - 'priceFrom' => $price->getPriceFrom(), - 'priceTo' => $price->getPriceTo() - ] - ); + $errorMessage = 'The product that was requested doesn\'t exist. Verify the product and try again.'; + $this->addFailedItemPrice($price, $key, $errorMessage, []); } + $this->checkStore($price, $key); $this->checkPrice($price, $key); $this->checkDate($price, $price->getPriceFrom(), 'Price From', $key); $this->checkDate($price, $price->getPriceTo(), 'Price To', $key); - try { - $this->storeRepository->getById($price->getStoreId()); - } catch (NoSuchEntityException $e) { - $this->validationResult->addFailedItem( - $key, - __( - 'Requested store is not found. ' - . 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.', - [ - 'SKU' => $price->getSku(), - 'storeId' => $price->getStoreId(), - 'priceFrom' => $price->getPriceFrom(), - 'priceTo' => $price->getPriceTo() - ] - ), - [ - 'SKU' => $price->getSku(), - 'storeId' => $price->getStoreId(), - 'priceFrom' => $price->getPriceFrom(), - 'priceTo' => $price->getPriceTo() - ] - ); - } } foreach ($this->validationResult->getFailedRowIds() as $id) { @@ -195,77 +174,98 @@ private function retrieveValidPrices(array $prices) return $prices; } + /** + * Check that store exists and is global when price scope is global and otherwise add error to aggregator. + * + * @param SpecialPriceInterface $price + * @param int $key + * @return void + */ + private function checkStore(SpecialPriceInterface $price, int $key): void + { + if ($this->catalogData->isPriceGlobal() && $price->getStoreId() !== 0) { + $errorMessage = 'Could not change non global Price when price scope is global.'; + $this->addFailedItemPrice($price, $key, $errorMessage, []); + } + + try { + $this->storeRepository->getById($price->getStoreId()); + } catch (NoSuchEntityException $e) { + $errorMessage = 'Requested store is not found.'; + $this->addFailedItemPrice($price, $key, $errorMessage, []); + } + } + /** * Check that date value is correct and add error to aggregator if it contains incorrect data. * - * @param \Magento\Catalog\Api\Data\SpecialPriceInterface $price + * @param SpecialPriceInterface $price * @param string $value * @param string $label * @param int $key * @return void */ - private function checkDate(\Magento\Catalog\Api\Data\SpecialPriceInterface $price, $value, $label, $key) + private function checkDate(SpecialPriceInterface $price, $value, $label, $key) { if ($value && !$this->isCorrectDateValue($value)) { - $this->validationResult->addFailedItem( - $key, - __( - 'Invalid attribute %label = %priceTo. ' - . 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.', - [ - 'label' => $label, - 'SKU' => $price->getSku(), - 'storeId' => $price->getStoreId(), - 'priceFrom' => $price->getPriceFrom(), - 'priceTo' => $price->getPriceTo() - ] - ), - [ - 'label' => $label, - 'SKU' => $price->getSku(), - 'storeId' => $price->getStoreId(), - 'priceFrom' => $price->getPriceFrom(), - 'priceTo' => $price->getPriceTo() - ] - ); + $errorMessage = 'Invalid attribute %label = %priceTo.'; + $this->addFailedItemPrice($price, $key, $errorMessage, ['label' => $label]); } } /** - * Check that provided price value is not empty and not lower then zero and add error to aggregator if price + * Check price. + * + * Verify that provided price value is not empty and not lower then zero and add error to aggregator if price * contains not valid data. * - * @param \Magento\Catalog\Api\Data\SpecialPriceInterface $price + * @param SpecialPriceInterface $price * @param int $key * @return void */ - private function checkPrice(\Magento\Catalog\Api\Data\SpecialPriceInterface $price, $key) + private function checkPrice(SpecialPriceInterface $price, int $key): void { if (null === $price->getPrice() || $price->getPrice() < 0) { - $this->validationResult->addFailedItem( - $key, - __( - 'Invalid attribute Price = %price. ' - . 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.', - [ - 'price' => $price->getPrice(), - 'SKU' => $price->getSku(), - 'storeId' => $price->getStoreId(), - 'priceFrom' => $price->getPriceFrom(), - 'priceTo' => $price->getPriceTo() - ] - ), - [ - 'price' => $price->getPrice(), - 'SKU' => $price->getSku(), - 'storeId' => $price->getStoreId(), - 'priceFrom' => $price->getPriceFrom(), - 'priceTo' => $price->getPriceTo() - ] - ); + $errorMessage = 'Invalid attribute Price = %price.'; + $this->addFailedItemPrice($price, $key, $errorMessage, ['price' => $price->getPrice()]); } } + /** + * Adds failed item price to validation result + * + * @param SpecialPriceInterface $price + * @param int $key + * @param string $message + * @param array $firstParam + * @return void + */ + private function addFailedItemPrice( + SpecialPriceInterface $price, + int $key, + string $message, + array $firstParam + ): void { + $additionalInfo = []; + if ($firstParam) { + $additionalInfo = array_merge($additionalInfo, $firstParam); + } + + $additionalInfo['SKU'] = $price->getSku(); + $additionalInfo['storeId'] = $price->getStoreId(); + $additionalInfo['priceFrom'] = $price->getPriceFrom(); + $additionalInfo['priceTo'] = $price->getPriceTo(); + + $this->validationResult->addFailedItem( + $key, + __( + $message . ' Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.', + $additionalInfo + ), + $additionalInfo + ); + } + /** * Retrieve SKU by product ID. * diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Price/SpecialPrice.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Price/SpecialPrice.php index 5a7bf93af9e8f..448b3769c7157 100644 --- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Price/SpecialPrice.php +++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Price/SpecialPrice.php @@ -8,7 +8,6 @@ use Magento\Catalog\Api\ProductAttributeRepositoryInterface; use Magento\Catalog\Api\SpecialPriceInterface; -use Magento\Catalog\Helper\Data; use Magento\Catalog\Model\ProductIdLocatorInterface; use Magento\Catalog\Model\ResourceModel\Attribute; use Magento\Framework\EntityManager\MetadataPool; @@ -77,11 +76,6 @@ class SpecialPrice implements SpecialPriceInterface */ private $priceToAttributeId; - /** - * @var Data - */ - private $catalogData; - /** * Items per operation. * @@ -94,20 +88,17 @@ class SpecialPrice implements SpecialPriceInterface * @param ProductAttributeRepositoryInterface $attributeRepository * @param ProductIdLocatorInterface $productIdLocator * @param MetadataPool $metadataPool - * @param Data|null $catalogData */ public function __construct( Attribute $attributeResource, ProductAttributeRepositoryInterface $attributeRepository, ProductIdLocatorInterface $productIdLocator, - MetadataPool $metadataPool, - ?Data $catalogData = null + MetadataPool $metadataPool ) { $this->attributeResource = $attributeResource; $this->attributeRepository = $attributeRepository; $this->productIdLocator = $productIdLocator; $this->metadataPool = $metadataPool; - $this->catalogData = $catalogData ?: ObjectManager::getInstance()->get(Data::class); } /** @@ -250,19 +241,11 @@ public function delete(array $prices) * * @param \Magento\Catalog\Api\Data\SpecialPriceInterface[] $priceItems * @return array - * @throws CouldNotDeleteException */ private function getStoreSkus(array $priceItems): array { - $isPriceGlobal = $this->catalogData->isPriceGlobal(); - $storeSkus = []; foreach ($priceItems as $priceItem) { - if ($isPriceGlobal && $priceItem->getStoreId() !== 0) { - throw new CouldNotDeleteException( - __('Could not delete Prices for non-default store when price scope is global.') - ); - } $storeSkus[$priceItem->getStoreId()][] = $priceItem->getSku(); } diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php index 782b2cbbe4b3b..a8685a20309eb 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php @@ -141,6 +141,8 @@ public function testUpdate(array $data) */ public function testDeleteWhenPriceIsGlobal(): void { + $fromDate = '2037-01-19 03:14:07'; + $serviceInfo = [ 'rest' => [ 'resourcePath' => '/V1/products/special-price-delete', @@ -153,23 +155,27 @@ public function testDeleteWhenPriceIsGlobal(): void ], ]; - $this->expectErrorMessage('Could not delete Prices for non-default store when price scope is global.'); - - $this->_webApiCall( + $response = $this->_webApiCall( $serviceInfo, [ 'prices' => [ - ['price' => 777, 'store_id' => 1, 'sku' => self::SIMPLE_PRODUCT_SKU] + ['price' => 777, 'store_id' => 1, 'sku' => self::SIMPLE_PRODUCT_SKU, 'price_from' => $fromDate] ] ] ); + + $errorMessage = current(array_column($response, 'message')); + $this->assertStringContainsString( + 'Could not change non global Price when price scope is global.', + $errorMessage + ); } /** * Test delete method. * * @magentoApiDataFixture Magento/Catalog/_files/product_two_websites.php - * @magentoConfigFixture catalog/price/scope 1 + * @magentoConfigFixture default_store catalog/price/scope 1 * @dataProvider deleteData * @param array $data * @return void From 7c478a9c6cd4c159efd9a537a03a8c8c6a334a75 Mon Sep 17 00:00:00 2001 From: Anna Pak <a.pak@atwix.com> Date: Mon, 4 Jan 2021 15:32:32 +0200 Subject: [PATCH 22/68] Refactored AdminMassOrdersCancelProcessingAndClosedTest --- ...assOrdersCancelClosedAndProcessingTest.xml | 100 ++++++++++++++++++ ...assOrdersCancelProcessingAndClosedTest.xml | 7 +- 2 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelClosedAndProcessingTest.xml diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelClosedAndProcessingTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelClosedAndProcessingTest.xml new file mode 100644 index 0000000000000..2671cd6989c51 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelClosedAndProcessingTest.xml @@ -0,0 +1,100 @@ +<?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="AdminMassOrdersCancelClosedAndProcessingTest"> + <annotations> + <stories value="Mass Update Orders"/> + <title value="Mass cancel orders in status Processing, Closed"/> + <description value="Try to cancel orders in status Processing, Closed"/> + <severity value="MAJOR"/> + <testCaseId value="MC-16184"/> + <group value="sales"/> + <group value="mtf_migrated"/> + </annotations> + <before> + <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> + + <createData entity="Simple_US_Customer" stepKey="createCustomer"/> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="defaultSimpleProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + + <createData entity="CustomerCart" stepKey="createCustomerCartOne"> + <requiredEntity createDataKey="createCustomer"/> + </createData> + <createData entity="CustomerCartItem" stepKey="addCartItemOne"> + <requiredEntity createDataKey="createCustomerCartOne"/> + <requiredEntity createDataKey="createProduct"/> + </createData> + <createData entity="CustomerAddressInformation" stepKey="addCustomerOrderAddress"> + <requiredEntity createDataKey="createCustomerCartOne"/> + </createData> + <updateData createDataKey="createCustomerCartOne" entity="CustomerOrderPaymentMethod" stepKey="sendCustomerPaymentInformationOne"> + <requiredEntity createDataKey="createCustomerCartOne"/> + </updateData> + <createData entity="Invoice" stepKey="invoiceOrderOne"> + <requiredEntity createDataKey="createCustomerCartOne"/> + </createData> + + <createData entity="CustomerCart" stepKey="createCustomerCartTwo"> + <requiredEntity createDataKey="createCustomer"/> + </createData> + <createData entity="CustomerCartItem" stepKey="addCartItemTwo"> + <requiredEntity createDataKey="createCustomerCartTwo"/> + <requiredEntity createDataKey="createProduct"/> + </createData> + <createData entity="CustomerAddressInformation" stepKey="addCustomerOrderAddressTwo"> + <requiredEntity createDataKey="createCustomerCartTwo"/> + </createData> + <updateData createDataKey="createCustomerCartTwo" entity="CustomerOrderPaymentMethod" stepKey="sendCustomerPaymentInformationTwo"> + <requiredEntity createDataKey="createCustomerCartTwo"/> + </updateData> + <createData entity="Invoice" stepKey="invoiceOrderTwo"> + <requiredEntity createDataKey="createCustomerCartTwo"/> + </createData> + <createData entity="CreditMemo" stepKey="refundOrderTwo"> + <requiredEntity createDataKey="createCustomerCartTwo"/> + </createData> + </before> + <after> + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> + </after> + + <actionGroup ref="AdminOrdersPageOpenActionGroup" stepKey="onOrderPage"/> + <actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearFilters"/> + <grabTextFrom selector="{{AdminOrdersGridSection.orderIdByIncrementId($createCustomerCartOne.return$)}}" stepKey="getFirstOrderId"/> + <grabTextFrom selector="{{AdminOrdersGridSection.orderIdByIncrementId($createCustomerCartTwo.return$)}}" stepKey="getSecondOrderId"/> + + <actionGroup ref="AdminTwoOrderActionOnGridActionGroup" stepKey="massActionCancel"> + <argument name="action" value="Cancel"/> + <argument name="orderId" value="{$getFirstOrderId}"/> + <argument name="secondOrderId" value="{$getSecondOrderId}"/> + </actionGroup> + <see userInput="You cannot cancel the order(s)." stepKey="assertOrderCancelMassActionFailMessage"/> + + <actionGroup ref="AdminOrderFilterByOrderIdAndStatusActionGroup" stepKey="seeFirstOrder"> + <argument name="orderId" value="{$getFirstOrderId}"/> + <argument name="orderStatus" value="Processing"/> + </actionGroup> + <see userInput="{$getFirstOrderId}" selector="{{AdminOrdersGridSection.gridCell('1','ID')}}" stepKey="assertFirstOrderID"/> + <see userInput="Processing" selector="{{AdminOrdersGridSection.gridCell('1','Status')}}" stepKey="assertFirstOrderStatus"/> + + <actionGroup ref="AdminOrderFilterByOrderIdAndStatusActionGroup" stepKey="seeSecondOrder"> + <argument name="orderId" value="{$getSecondOrderId}"/> + <argument name="orderStatus" value="Closed"/> + </actionGroup> + <see userInput="{$getSecondOrderId}" selector="{{AdminOrdersGridSection.gridCell('1','ID')}}" stepKey="assertSecondOrderID"/> + <see userInput="Closed" selector="{{AdminOrdersGridSection.gridCell('1','Status')}}" stepKey="assertSecondStatus"/> + </test> +</tests> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelProcessingAndClosedTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelProcessingAndClosedTest.xml index 6eb4195524224..3400e07373f54 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelProcessingAndClosedTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersCancelProcessingAndClosedTest.xml @@ -8,15 +8,18 @@ <tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> - <test name="AdminMassOrdersCancelProcessingAndClosedTest"> + <test name="AdminMassOrdersCancelProcessingAndClosedTest" deprecated="Use AdminMassOrdersCancelClosedAndProcessingTest instead"> <annotations> <stories value="Mass Update Orders"/> - <title value="Mass cancel orders in status Processing, Closed"/> + <title value="DEPRECATED. Mass cancel orders in status Processing, Closed"/> <description value="Try to cancel orders in status Processing, Closed"/> <severity value="MAJOR"/> <testCaseId value="MC-16184"/> <group value="sales"/> <group value="mtf_migrated"/> + <skip> + <issueId value="DEPRECATED">Use AdminMassOrdersCancelClosedAndProcessingTest instead</issueId> + </skip> </annotations> <before> <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> From 287084c615ec26b037712f014413afa568a27c1d Mon Sep 17 00:00:00 2001 From: "vadim.malesh" <engcom-vendorworker-charlie@adobe.com> Date: Mon, 4 Jan 2021 15:38:59 +0200 Subject: [PATCH 23/68] pass full error message text --- .../Product/Price/SpecialPriceStorage.php | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/app/code/Magento/Catalog/Model/Product/Price/SpecialPriceStorage.php b/app/code/Magento/Catalog/Model/Product/Price/SpecialPriceStorage.php index 00872d19b29fd..a0f6fcf315c7f 100644 --- a/app/code/Magento/Catalog/Model/Product/Price/SpecialPriceStorage.php +++ b/app/code/Magento/Catalog/Model/Product/Price/SpecialPriceStorage.php @@ -158,7 +158,8 @@ private function retrieveValidPrices(array $prices) foreach ($prices as $key => $price) { if (!$price->getSku() || in_array($price->getSku(), $failedSkus)) { - $errorMessage = 'The product that was requested doesn\'t exist. Verify the product and try again.'; + $errorMessage = 'The product that was requested doesn\'t exist. Verify the product and try again. ' + . 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.'; $this->addFailedItemPrice($price, $key, $errorMessage, []); } $this->checkStore($price, $key); @@ -184,14 +185,16 @@ private function retrieveValidPrices(array $prices) private function checkStore(SpecialPriceInterface $price, int $key): void { if ($this->catalogData->isPriceGlobal() && $price->getStoreId() !== 0) { - $errorMessage = 'Could not change non global Price when price scope is global.'; + $errorMessage = 'Could not change non global Price when price scope is global. ' + . 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.'; $this->addFailedItemPrice($price, $key, $errorMessage, []); } try { $this->storeRepository->getById($price->getStoreId()); } catch (NoSuchEntityException $e) { - $errorMessage = 'Requested store is not found.'; + $errorMessage = 'Requested store is not found. ' + . 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.'; $this->addFailedItemPrice($price, $key, $errorMessage, []); } } @@ -208,7 +211,8 @@ private function checkStore(SpecialPriceInterface $price, int $key): void private function checkDate(SpecialPriceInterface $price, $value, $label, $key) { if ($value && !$this->isCorrectDateValue($value)) { - $errorMessage = 'Invalid attribute %label = %priceTo.'; + $errorMessage = 'Invalid attribute %label = %priceTo. ' + . 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.'; $this->addFailedItemPrice($price, $key, $errorMessage, ['label' => $label]); } } @@ -226,7 +230,8 @@ private function checkDate(SpecialPriceInterface $price, $value, $label, $key) private function checkPrice(SpecialPriceInterface $price, int $key): void { if (null === $price->getPrice() || $price->getPrice() < 0) { - $errorMessage = 'Invalid attribute Price = %price.'; + $errorMessage = 'Invalid attribute Price = %price. ' + . 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.'; $this->addFailedItemPrice($price, $key, $errorMessage, ['price' => $price->getPrice()]); } } @@ -256,14 +261,7 @@ private function addFailedItemPrice( $additionalInfo['priceFrom'] = $price->getPriceFrom(); $additionalInfo['priceTo'] = $price->getPriceTo(); - $this->validationResult->addFailedItem( - $key, - __( - $message . ' Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo.', - $additionalInfo - ), - $additionalInfo - ); + $this->validationResult->addFailedItem($key, __($message, $additionalInfo), $additionalInfo); } /** From 9efb10544ea75c01d8348ee2b58a301f72b310a6 Mon Sep 17 00:00:00 2001 From: Anna Pak <a.pak@atwix.com> Date: Mon, 4 Jan 2021 17:21:06 +0200 Subject: [PATCH 24/68] Refactored AdminMassOrdersHoldOnCompleteTest --- .../AdminMassOrdersHoldOnCompleteTest.xml | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersHoldOnCompleteTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersHoldOnCompleteTest.xml index 41964cbf605da..592c8b7981bed 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersHoldOnCompleteTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersHoldOnCompleteTest.xml @@ -21,7 +21,6 @@ <before> <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> - <!-- Create Data --> <createData entity="Simple_US_Customer" stepKey="createCustomer"/> <createData entity="_defaultCategory" stepKey="createCategory"/> <createData entity="defaultSimpleProduct" stepKey="createProduct"> @@ -29,43 +28,49 @@ </createData> </before> <after> - <!-- Delete data --> <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> - <!-- Create order --> - <actionGroup ref="CreateOrderActionGroup" stepKey="createFirstOrder"> - <argument name="product" value="$$createProduct$$"/> - <argument name="customer" value="$$createCustomer$$"/> - </actionGroup> - <grabTextFrom selector="|Order # (\d+)|" stepKey="getOrderId"/> - <assertNotEmpty stepKey="assertOrderIdIsNotEmpty" after="getOrderId"> - <actualResult type="const">$getOrderId</actualResult> - </assertNotEmpty> - - <!-- Create Shipment for Order --> - <actionGroup ref="AdminCreateInvoiceAndShipmentActionGroup" stepKey="createShipment"/> + <createData entity="CustomerCart" stepKey="createCustomerCart"> + <requiredEntity createDataKey="createCustomer"/> + </createData> + <createData entity="CustomerCartItem" stepKey="addCartItem"> + <requiredEntity createDataKey="createCustomerCart"/> + <requiredEntity createDataKey="createProduct"/> + </createData> + <createData entity="CustomerAddressInformation" stepKey="addCustomerOrderAddress"> + <requiredEntity createDataKey="createCustomerCart"/> + </createData> + <updateData createDataKey="createCustomerCart" entity="CustomerOrderPaymentMethod" stepKey="createFirstOrder"> + <requiredEntity createDataKey="createCustomerCart"/> + </updateData> + <createData entity="Invoice" stepKey="invoiceOrder"> + <requiredEntity createDataKey="createCustomerCart"/> + </createData> + <comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="getOrderId"/> + <comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="assertOrderIdIsNotEmpty"/> + <createData entity="Shipment" stepKey="createShipment"> + <requiredEntity createDataKey="createCustomerCart"/> + </createData> - <!-- Navigate to backend: Go to Sales > Orders --> <actionGroup ref="AdminOrdersPageOpenActionGroup" stepKey="onOrderPage"/> <actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearFilters"/> + <grabTextFrom selector="{{AdminOrdersGridSection.orderIdByIncrementId($createCustomerCart.return$)}}" stepKey="grabOrderId"/> - <!-- Select Mass Action according to dataset: Hold --> <actionGroup ref="AdminOrderActionOnGridActionGroup" stepKey="actionHold"> <argument name="action" value="Hold"/> - <argument name="orderId" value="$getOrderId"/> + <argument name="orderId" value="$grabOrderId"/> </actionGroup> <see userInput="No order(s) were put on hold." stepKey="assertOrderOnHoldFailMessage"/> - <!--Assert order in orders grid --> <actionGroup ref="AdminOrderFilterByOrderIdAndStatusActionGroup" stepKey="seeFirstOrder"> - <argument name="orderId" value="{$getOrderId}"/> + <argument name="orderId" value="{$grabOrderId}"/> <argument name="orderStatus" value="Complete"/> </actionGroup> - <see userInput="{$getOrderId}" selector="{{AdminOrdersGridSection.gridCell('1','ID')}}" stepKey="assertOrderID"/> + <see userInput="{$grabOrderId}" selector="{{AdminOrdersGridSection.gridCell('1','ID')}}" stepKey="assertOrderID"/> <see userInput="Complete" selector="{{AdminOrdersGridSection.gridCell('1','Status')}}" stepKey="assertOrderStatus"/> </test> </tests> From 7aea8c5733e12e633632154e4cc537322db48cb2 Mon Sep 17 00:00:00 2001 From: Anna Pak <a.pak@atwix.com> Date: Mon, 4 Jan 2021 17:43:22 +0200 Subject: [PATCH 25/68] Refactored AdminMassOrdersUpdateCancelPendingOrderTest --- ...MassOrdersUpdateCancelPendingOrderTest.xml | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersUpdateCancelPendingOrderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersUpdateCancelPendingOrderTest.xml index 163da4917b50a..e8b842a48890e 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersUpdateCancelPendingOrderTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminMassOrdersUpdateCancelPendingOrderTest.xml @@ -20,7 +20,6 @@ </annotations> <before> <actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/> - <!-- Create Data --> <createData entity="Simple_US_Customer" stepKey="createCustomer"/> <createData entity="_defaultCategory" stepKey="createCategory"/> <createData entity="defaultSimpleProduct" stepKey="createProduct"> @@ -28,40 +27,43 @@ </createData> </before> <after> - <!-- Delete data --> <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> - <!-- Create order --> - <actionGroup ref="CreateOrderActionGroup" stepKey="createOrder"> - <argument name="product" value="$$createProduct$$"/> - <argument name="customer" value="$$createCustomer$$"/> - </actionGroup> - <grabTextFrom selector="|Order # (\d+)|" stepKey="getOrderId"/> - <assertNotEmpty stepKey="assertOrderIdIsNotEmpty" after="getOrderId"> - <actualResult type="const">$getOrderId</actualResult> - </assertNotEmpty> + <createData entity="CustomerCart" stepKey="createCustomerCart"> + <requiredEntity createDataKey="createCustomer"/> + </createData> + <createData entity="CustomerCartItem" stepKey="addCartItem"> + <requiredEntity createDataKey="createCustomerCart"/> + <requiredEntity createDataKey="createProduct"/> + </createData> + <createData entity="CustomerAddressInformation" stepKey="addCustomerOrderAddress"> + <requiredEntity createDataKey="createCustomerCart"/> + </createData> + <updateData createDataKey="createCustomerCart" entity="CustomerOrderPaymentMethod" stepKey="createOrder"> + <requiredEntity createDataKey="createCustomerCart"/> + </updateData> + <comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="getOrderId"/> + <comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="assertOrderIdIsNotEmpty"/> - <!-- Navigate to backend: Go to Sales > Orders --> <actionGroup ref="AdminOrdersPageOpenActionGroup" stepKey="onOrderPage"/> <actionGroup ref="AdminOrdersGridClearFiltersActionGroup" stepKey="clearFilters"/> + <grabTextFrom selector="{{AdminOrdersGridSection.orderIdByIncrementId($createCustomerCart.return$)}}" stepKey="grabOrderId"/> - <!-- Select Mass Action according to dataset: Cancel --> <actionGroup ref="AdminOrderActionOnGridActionGroup" stepKey="ActionCancel"> <argument name="action" value="Cancel"/> - <argument name="orderId" value="$getOrderId"/> + <argument name="orderId" value="$grabOrderId"/> </actionGroup> <see userInput="We canceled 1 order(s)." stepKey="assertOrderCancelMassActionSuccessMessage"/> - <!--Assert orders in orders grid --> <actionGroup ref="AdminOrderFilterByOrderIdAndStatusActionGroup" stepKey="filterOrder"> - <argument name="orderId" value="{$getOrderId}"/> + <argument name="orderId" value="{$grabOrderId}"/> <argument name="orderStatus" value="Canceled"/> </actionGroup> - <see userInput="{$getOrderId}" selector="{{AdminOrdersGridSection.gridCell('1','ID')}}" stepKey="assertOrderID"/> + <see userInput="{$grabOrderId}" selector="{{AdminOrdersGridSection.gridCell('1','ID')}}" stepKey="assertOrderID"/> <see userInput="Canceled" selector="{{AdminOrdersGridSection.gridCell('1','Status')}}" stepKey="assertOrderStatus"/> </test> </tests> From d30fea04920b2101425ac4accd63d6cdab3b44e3 Mon Sep 17 00:00:00 2001 From: Vadim Malesh <51680850+engcom-Charlie@users.noreply.github.com> Date: Mon, 4 Jan 2021 20:43:19 +0200 Subject: [PATCH 26/68] fix webapi test --- .../Magento/Catalog/Api/SpecialPriceStorageTest.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php index a8685a20309eb..da40c9ee01c82 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php @@ -141,8 +141,6 @@ public function testUpdate(array $data) */ public function testDeleteWhenPriceIsGlobal(): void { - $fromDate = '2037-01-19 03:14:07'; - $serviceInfo = [ 'rest' => [ 'resourcePath' => '/V1/products/special-price-delete', @@ -159,7 +157,13 @@ public function testDeleteWhenPriceIsGlobal(): void $serviceInfo, [ 'prices' => [ - ['price' => 777, 'store_id' => 1, 'sku' => self::SIMPLE_PRODUCT_SKU, 'price_from' => $fromDate] + [ + 'price' => 777, + 'store_id' => 1, + 'sku' => self::SIMPLE_PRODUCT_SKU, + 'price_from' => '2037-01-19 03:14:07', + 'price_to' => '2038-01-19 03:14:07' + ] ] ] ); From cb230b52106a6ced398efd8aa6d3e65ae81b49be Mon Sep 17 00:00:00 2001 From: "vadim.malesh" <engcom-vendorworker-charlie@adobe.com> Date: Fri, 8 Jan 2021 12:35:14 +0200 Subject: [PATCH 27/68] improve test coverage --- .../Catalog/Api/SpecialPriceStorageTest.php | 114 +++++++++++++----- 1 file changed, 87 insertions(+), 27 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php index a8685a20309eb..9963f9b5ad820 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php @@ -6,14 +6,20 @@ namespace Magento\Catalog\Api; use Magento\Catalog\Api\Data\ProductInterface; -use Magento\Framework\Webapi\Rest\Request; use Magento\Catalog\Model\ResourceModel\Product as ProductResource; +use Magento\Framework\Exception\CouldNotSaveException; +use Magento\Framework\Exception\InputException; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Exception\StateException; +use Magento\Framework\Webapi\Rest\Request; +use Magento\Store\Model\StoreManagerInterface; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\ObjectManager; use Magento\TestFramework\TestCase\WebapiAbstract; /** * SpecialPriceStorage API operations test + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class SpecialPriceStorageTest extends WebapiAbstract { @@ -33,6 +39,11 @@ class SpecialPriceStorageTest extends WebapiAbstract */ private $productResource; + /** + * @var StoreManagerInterface + */ + private $storeManager; + /** * @ingeritdoc */ @@ -40,6 +51,7 @@ protected function setUp(): void { $this->objectManager = Bootstrap::getObjectManager(); $this->productResource = $this->objectManager->get(ProductResource::class); + $this->storeManager = $this->objectManager->get(StoreManagerInterface::class); } /** @@ -174,31 +186,25 @@ public function testDeleteWhenPriceIsGlobal(): void /** * Test delete method. * - * @magentoApiDataFixture Magento/Catalog/_files/product_two_websites.php - * @magentoConfigFixture default_store catalog/price/scope 1 + * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php * @dataProvider deleteData * @param array $data - * @return void + * @throws CouldNotSaveException + * @throws InputException + * @throws NoSuchEntityException + * @throws StateException */ - public function testDelete(array $data): void + public function testDelete(array $data) { /** @var ProductRepositoryInterface $productRepository */ $productRepository = $this->objectManager->create(ProductRepositoryInterface::class); - $product = $productRepository->get($data['sku'], true, $data['store_id'], true); + $product = $productRepository->get($data['sku'], true); $product->setData('special_price', $data['price']); $product->setData('special_from_date', $data['price_from']); if ($data['price_to']) { $product->setData('special_to_date', $data['price_to']); } - $this->productResource->saveAttribute($product, 'special_price'); - $this->productResource->saveAttribute($product, 'special_from_date'); - $this->productResource->saveAttribute($product, 'special_to_date'); - - $product->setData('store_id', 1); - $this->productResource->saveAttribute($product, 'special_price'); - $this->productResource->saveAttribute($product, 'special_from_date'); - $this->productResource->saveAttribute($product, 'special_to_date'); - + $productRepository->save($product); $serviceInfo = [ 'rest' => [ 'resourcePath' => '/V1/products/special-price-delete', @@ -210,21 +216,17 @@ public function testDelete(array $data): void 'operation' => self::SERVICE_NAME . 'Delete', ], ]; - $response = $this->_webApiCall( $serviceInfo, [ - 'prices' => [$data] + 'prices' => [ + $data + ] ] ); - + $product = $productRepository->get($data['sku'], false, null, true); $this->assertEmpty($response); - - $product = $productRepository->get($data['sku'], false, $data['store_id'], true); $this->assertNull($product->getSpecialPrice()); - - $product = $productRepository->get($data['sku'], false, 1, true); - $this->assertNotNull($product->getSpecialPrice()); } /** @@ -272,24 +274,82 @@ public function deleteData(): array $toDate = '2038-01-19 03:14:07'; return [ - 'data set with price_to specified' => [ + [ + // data set with 'price_to' specified [ 'price' => 3057, 'store_id' => 0, - 'sku' => self::PRODUCT_SKU_TWO_WEBSITES, + 'sku' => self::SIMPLE_PRODUCT_SKU, 'price_from' => $fromDate, 'price_to' => $toDate ] ], - 'data set without price_to specified' => [ + [ + // data set without 'price_to' specified [ 'price' => 3057, 'store_id' => 0, - 'sku' => self::PRODUCT_SKU_TWO_WEBSITES, + 'sku' => self::SIMPLE_PRODUCT_SKU, 'price_from' => $fromDate, 'price_to' => false ] ], ]; } + + /** + * Test delete method for specific store. + * + * @magentoApiDataFixture Magento/Catalog/_files/product_two_websites.php + * @magentoConfigFixture default_store catalog/price/scope 1 + * @return void + */ + public function testDeleteDataForSpecificStore(): void + { + $secondStoreViewId = $this->storeManager->getStore('fixture_second_store') + ->getId(); + + $data = [ + 'price' => 777, + 'store_id' => $secondStoreViewId, + 'sku' => self::PRODUCT_SKU_TWO_WEBSITES, + 'price_from' => '1970-01-01 00:00:01', + 'price_to' => false + ]; + + /** @var ProductRepositoryInterface $productRepository */ + $productRepository = $this->objectManager->create(ProductRepositoryInterface::class); + $product = $productRepository->get($data['sku'], true, 1, true); + $product->setData('special_price', $data['price']); + $product->setData('special_from_date', $data['price_from']); + + $this->productResource->saveAttribute($product, 'special_price'); + $this->productResource->saveAttribute($product, 'special_from_date'); + $this->productResource->saveAttribute($product, 'special_to_date'); + + $product->setData('store_id', $secondStoreViewId); + $this->productResource->saveAttribute($product, 'special_price'); + $this->productResource->saveAttribute($product, 'special_from_date'); + $this->productResource->saveAttribute($product, 'special_to_date'); + + $serviceInfo = [ + 'rest' => [ + 'resourcePath' => '/V1/products/special-price-delete', + 'httpMethod' => Request::HTTP_METHOD_POST + ], + 'soap' => [ + 'service' => self::SERVICE_NAME, + 'serviceVersion' => self::SERVICE_VERSION, + 'operation' => self::SERVICE_NAME . 'Delete', + ], + ]; + + $this->_webApiCall($serviceInfo, ['prices' => [$data]]); + + $product = $productRepository->get($data['sku'], false, 1, true); + $this->assertNotNull($product->getSpecialPrice()); + + $product = $productRepository->get($data['sku'], false, $secondStoreViewId, true); + $this->assertNull($product->getSpecialPrice()); + } } From 031c1dd4c6460ebd42aecdda5c5c2dbf70ababf2 Mon Sep 17 00:00:00 2001 From: Anna Pak <a.pak@atwix.com> Date: Sat, 9 Jan 2021 23:26:15 +0200 Subject: [PATCH 28/68] added AdminClickCreateNewStatusButtonOnOrderStatusPageActionGroup --- ...atusButtonOnOrderStatusPageActionGroup.xml | 19 +++++++++++++++++++ ...inCreateOrderStatusDuplicatingCodeTest.xml | 2 +- ...nCreateOrderStatusDuplicatingLabelTest.xml | 2 +- .../Mftf/Test/AdminCreateOrderStatusTest.xml | 2 +- .../AdminUnassignCustomOrderStatusTest.xml | 2 +- ...mOrderStatusNotVisibleOnStorefrontTest.xml | 2 +- 6 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickCreateNewStatusButtonOnOrderStatusPageActionGroup.xml diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickCreateNewStatusButtonOnOrderStatusPageActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickCreateNewStatusButtonOnOrderStatusPageActionGroup.xml new file mode 100644 index 0000000000000..f91d0c54c3a2c --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminClickCreateNewStatusButtonOnOrderStatusPageActionGroup.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AdminClickCreateNewStatusButtonOnOrderStatusPageActionGroup"> + <annotations> + <description></description> + </annotations> + + <click selector="{{AdminMainActionsSection.add}}" stepKey="clickCreateNewStatus"/> + <waitForPageLoad stepKey="waitForPageLoaded"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingCodeTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingCodeTest.xml index 23dca916781f1..4d957654cf7eb 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingCodeTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingCodeTest.xml @@ -27,7 +27,7 @@ <!-- Go to new order status page --> <amOnPage url="{{AdminOrderStatusPage.url}}" stepKey="goToOrderStatusPage"/> - <click selector="{{AdminMainActionsSection.add}}" stepKey="clickCreateNewStatus"/> + <actionGroup ref="AdminClickCreateNewStatusButtonOnOrderStatusPageActionGroup" stepKey="clickCreateNewStatus"/> <!-- Fill the form and validate message --> <actionGroup ref="AdminOrderStatusFormFillAndSave" stepKey="fillFormAndClickSave"> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingLabelTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingLabelTest.xml index d3cd3e8b8549c..c81f09644707a 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingLabelTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusDuplicatingLabelTest.xml @@ -27,7 +27,7 @@ <!-- Go to new order status page --> <amOnPage url="{{AdminOrderStatusPage.url}}" stepKey="goToOrderStatusPage"/> - <click selector="{{AdminMainActionsSection.add}}" stepKey="clickCreateNewStatus"/> + <actionGroup ref="AdminClickCreateNewStatusButtonOnOrderStatusPageActionGroup" stepKey="clickCreateNewStatus"/> <!-- Fill the form and validate message --> <actionGroup ref="AdminOrderStatusFormFillAndSave" stepKey="fillFormAndClickSave"> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusTest.xml index a30040045a4ca..51422d027a6a0 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderStatusTest.xml @@ -27,7 +27,7 @@ <!-- Go to new order status page --> <amOnPage url="{{AdminOrderStatusPage.url}}" stepKey="goToOrderStatusPage"/> - <click selector="{{AdminMainActionsSection.add}}" stepKey="clickCreateNewStatus"/> + <actionGroup ref="AdminClickCreateNewStatusButtonOnOrderStatusPageActionGroup" stepKey="clickCreateNewStatus"/> <!-- Fill the form and validate message --> <actionGroup ref="AdminOrderStatusFormFillAndSave" stepKey="fillFormAndClickSave"> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminUnassignCustomOrderStatusTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminUnassignCustomOrderStatusTest.xml index 226524341efdd..501214f84e282 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminUnassignCustomOrderStatusTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminUnassignCustomOrderStatusTest.xml @@ -26,7 +26,7 @@ <!--Go to new order status page--> <amOnPage url="{{AdminOrderStatusPage.url}}" stepKey="goToOrderStatusPage"/> - <click selector="{{AdminMainActionsSection.add}}" stepKey="clickCreateNewStatus"/> + <actionGroup ref="AdminClickCreateNewStatusButtonOnOrderStatusPageActionGroup" stepKey="clickCreateNewStatus"/> <!--Fill the form and validate save success message--> <actionGroup ref="AdminOrderStatusFormFillAndSave" stepKey="fillFormAndClickSave"> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AssignCustomOrderStatusNotVisibleOnStorefrontTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AssignCustomOrderStatusNotVisibleOnStorefrontTest.xml index a5d210a9765ad..aec402a5ab3cb 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AssignCustomOrderStatusNotVisibleOnStorefrontTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AssignCustomOrderStatusNotVisibleOnStorefrontTest.xml @@ -49,7 +49,7 @@ <!-- Create order status --> <amOnPage url="{{AdminOrderStatusPage.url}}" stepKey="goToOrderStatusPage"/> <waitForPageLoad stepKey="waitForOrderStatusPageLoad"/> - <click selector="{{AdminMainActionsSection.add}}" stepKey="clickCreateNewStatus"/> + <actionGroup ref="AdminClickCreateNewStatusButtonOnOrderStatusPageActionGroup" stepKey="clickCreateNewStatus"/> <!-- Fill form and validate message --> <actionGroup ref="AdminOrderStatusFormFillAndSave" stepKey="fillFormAndClickSave"> From a2327c974a9d25b2d4d1ddf8bc391cd3a0a3d797 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" <engcom-vendorworker-charlie@adobe.com> Date: Wed, 13 Jan 2021 11:25:57 +0200 Subject: [PATCH 29/68] fixed clearing form after saving with error --- .../Magento/Cms/Model/Page/DataProvider.php | 60 +++++++++++-------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php index 7b6bb303b844a..19e9db02d83a9 100644 --- a/app/code/Magento/Cms/Model/Page/DataProvider.php +++ b/app/code/Magento/Cms/Model/Page/DataProvider.php @@ -5,6 +5,7 @@ */ namespace Magento\Cms\Model\Page; +use Magento\Cms\Api\Data\PageInterface; use Magento\Cms\Api\PageRepositoryInterface; use Magento\Cms\Model\Page; use Magento\Cms\Model\ResourceModel\Page\CollectionFactory; @@ -122,46 +123,53 @@ public function getData() return $this->loadedData; } - try { - $page = $this->getCurrentPage(); - } catch (LocalizedException $exception) { - return []; - } - - $pageId = $page->getId(); - $this->loadedData[$pageId] = $page->getData(); + $page = $this->getCurrentPage(); + $this->loadedData[$page->getId()] = $page->getData(); if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) { //Deprecated layout update exists. - $this->loadedData[$pageId]['layout_update_selected'] = '_existing_'; + $this->loadedData[$page->getId()]['layout_update_selected'] = '_existing_'; } - $data = $this->dataPersistor->get('cms_page'); - if (empty($data)) { - return $this->loadedData; + return $this->loadedData; + } + + /** + * Return current page + * + * @return PageInterface + */ + private function getCurrentPage(): PageInterface + { + $newPage = $this->collection->getNewEmptyItem(); + $pageId = $this->getPageId(); + if ($pageId) { + try { + $page = $this->pageRepository->getById($pageId); + } catch (LocalizedException $exception) { + $page = $newPage; + } + + return $page; } - $page = $this->collection->getNewEmptyItem(); - $page->setData($data); - $this->loadedData[$pageId] = $page->getData(); - if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) { - $this->loadedData[$pageId]['layout_update_selected'] = '_existing_'; + $data = $this->dataPersistor->get('cms_page'); + if (empty($data)) { + return $newPage; } $this->dataPersistor->clear('cms_page'); + $page = $newPage->setData($data); - return $this->loadedData; + return $page; } /** - * Loads the current page by current request params. + * Returns current page id from request * - * @return Page - * @throws LocalizedException + * @return int */ - private function getCurrentPage(): Page + private function getPageId(): int { - $pageId = $this->request->getParam($this->getRequestFieldName(), 0); - - return $this->pageRepository->getById($pageId); + return (int) $this->request->getParam($this->getRequestFieldName()); } /** @@ -200,7 +208,7 @@ public function getMeta() $page = null; try { - $page = $this->getCurrentPage(); + $page = $this->pageRepository->getById($this->getPageId()); } catch (LocalizedException $e) { $this->logger->error($e->getMessage()); } From 36c031a6f303cfe21f735c1b4db953595cf2ade7 Mon Sep 17 00:00:00 2001 From: Adam Mellen <github@mellen.io> Date: Wed, 13 Jan 2021 13:53:26 +0000 Subject: [PATCH 30/68] Moving array access for captcha _.isEmpty check When upgrading to 2.3.6 from 2.3.5-p2, a new CAPTCHA zone "payment_processing_request" is added. If a customer has an existing session (from 2.3.5-p2 or prior), and tries to access checkout with their existing session data, checkout will fail to load because the check to see if captchaData[formId] exists is not a valid function call. _.isEmpty() only returns a boolean value, so it cannot be enumerated like an array. Array access syntax has been moved in to the check, rather than outside it. --- .../view/frontend/web/js/view/checkout/defaultCaptcha.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Captcha/view/frontend/web/js/view/checkout/defaultCaptcha.js b/app/code/Magento/Captcha/view/frontend/web/js/view/checkout/defaultCaptcha.js index d79c42a711565..1d46084020220 100644 --- a/app/code/Magento/Captcha/view/frontend/web/js/view/checkout/defaultCaptcha.js +++ b/app/code/Magento/Captcha/view/frontend/web/js/view/checkout/defaultCaptcha.js @@ -56,7 +56,7 @@ define([ */ checkCustomerData: function (formId, captchaData, captcha) { if (!_.isEmpty(captchaData) && - !_.isEmpty(captchaData)[formId] && + !_.isEmpty(captchaData[formId]) && captchaData[formId].timestamp > captcha.timestamp ) { if (!captcha.isRequired() && captchaData[formId].isRequired) { From 9ee832e5a3eda2df4d87449fb8cc7145a92ccd00 Mon Sep 17 00:00:00 2001 From: Vadim Malesh <51680850+engcom-Charlie@users.noreply.github.com> Date: Fri, 15 Jan 2021 11:02:55 +0200 Subject: [PATCH 31/68] creating new page via factory --- .../Magento/Cms/Model/Page/DataProvider.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php index 19e9db02d83a9..fc2e89ae726bd 100644 --- a/app/code/Magento/Cms/Model/Page/DataProvider.php +++ b/app/code/Magento/Cms/Model/Page/DataProvider.php @@ -7,7 +7,7 @@ use Magento\Cms\Api\Data\PageInterface; use Magento\Cms\Api\PageRepositoryInterface; -use Magento\Cms\Model\Page; +use Magento\Cms\Model\PageFactory; use Magento\Cms\Model\ResourceModel\Page\CollectionFactory; use Magento\Framework\App\ObjectManager; use Magento\Framework\App\Request\DataPersistorInterface; @@ -53,6 +53,11 @@ class DataProvider extends ModifierPoolDataProvider */ private $customLayoutManager; + /** + * @var PageFactory + */ + private $pageFactory; + /** * @var LoggerInterface */ @@ -71,6 +76,7 @@ class DataProvider extends ModifierPoolDataProvider * @param RequestInterface|null $request * @param CustomLayoutManagerInterface|null $customLayoutManager * @param PageRepositoryInterface|null $pageRepository + * @param PageFactory|null $pageFactory * @param LoggerInterface|null $logger * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -87,6 +93,7 @@ public function __construct( ?RequestInterface $request = null, ?CustomLayoutManagerInterface $customLayoutManager = null, ?PageRepositoryInterface $pageRepository = null, + ?PageFactory $pageFactory = null, ?LoggerInterface $logger = null ) { parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool); @@ -98,6 +105,7 @@ public function __construct( $this->customLayoutManager = $customLayoutManager ?? ObjectManager::getInstance()->get(CustomLayoutManagerInterface::class); $this->pageRepository = $pageRepository ?? ObjectManager::getInstance()->get(PageRepositoryInterface::class); + $this->pageFactory = $pageFactory ?: ObjectManager::getInstance()->get(PageFactory::class); $this->logger = $logger ?: ObjectManager::getInstance()->get(LoggerInterface::class); } @@ -140,13 +148,12 @@ public function getData() */ private function getCurrentPage(): PageInterface { - $newPage = $this->collection->getNewEmptyItem(); $pageId = $this->getPageId(); if ($pageId) { try { $page = $this->pageRepository->getById($pageId); } catch (LocalizedException $exception) { - $page = $newPage; + $page = $this->pageFactory->create(); } return $page; @@ -154,10 +161,11 @@ private function getCurrentPage(): PageInterface $data = $this->dataPersistor->get('cms_page'); if (empty($data)) { - return $newPage; + return $this->pageFactory->create(); } $this->dataPersistor->clear('cms_page'); - $page = $newPage->setData($data); + $page = $this->pageFactory->create() + ->setData($data); return $page; } From b27192192625201017270454c210c22b40c1c039 Mon Sep 17 00:00:00 2001 From: Anna Pak <a.pak@atwix.com> Date: Sun, 17 Jan 2021 23:05:26 +0200 Subject: [PATCH 32/68] fixed typo --- .../Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminCreateTaxRateZipCodeRangeTest.xml index 231718994236a..0e541b8939053 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 --> - <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/>> + <actionGroup ref="AdminClearGridFiltersActionGroup" stepKey="clickClearFilters2"/> <actionGroup ref="AdminFillTaxIdentifierFilterOnTaxRateGridActionGroup" stepKey="fillTaxIdentifierField2"> <argument name="taxRateCode" value="{{SimpleTaxRate.code}}"/> </actionGroup> From 499c1fc1d6422e2b0f18234460e7f9aaca54ce82 Mon Sep 17 00:00:00 2001 From: Sergiy Vasiutynskyi <s.vasiutynskyi@atwix.com> Date: Wed, 20 Jan 2021 17:17:26 +0200 Subject: [PATCH 33/68] Removed usage or changed value of CliIndexerReindexActionGroup action group for Customer and GroupedProduct modules --- .../Customer/Test/Mftf/Test/AdminCreateCustomerTest.xml | 8 ++------ .../Test/AdminDeleteCustomerAddressesFromTheGridTest.xml | 4 +--- ...leteCustomerAddressesFromTheGridViaMassActionsTest.xml | 4 +--- .../Test/AdminDeleteDefaultBillingCustomerAddressTest.xml | 4 +--- .../Test/Mftf/Test/AdminResetCustomerPasswordTest.xml | 4 +--- .../Mftf/Test/AdminSearchCustomerAddressByKeywordTest.xml | 4 +--- .../AdminDeleteCustomerAddressTest.xml | 4 +--- ...AdminUpdateCustomerInfoFromDefaultToNonDefaultTest.xml | 4 +--- .../AllowedCountriesRestrictionApplyOnBackendTest.xml | 8 ++------ .../Mftf/Test/StorefrontClearAllCompareProductsTest.xml | 4 +--- .../Test/StorefrontCreateCustomerWithDateOfBirthTest.xml | 2 +- .../Test/AdminAssociateGroupedProductToWebsitesTest.xml | 6 +----- ...dvanceCatalogSearchGroupedProductByDescriptionTest.xml | 4 +--- .../AdvanceCatalogSearchGroupedProductByNameTest.xml | 4 +--- .../AdvanceCatalogSearchGroupedProductByPriceTest.xml | 4 +--- ...eCatalogSearchGroupedProductByShortDescriptionTest.xml | 4 +--- .../AdvanceCatalogSearchGroupedProductBySkuTest.xml | 4 +--- 17 files changed, 19 insertions(+), 57 deletions(-) diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerTest.xml index 5b6c4fd23e038..dd8b576ad7bb7 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerTest.xml @@ -21,9 +21,7 @@ </annotations> <before> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindexCustomerGrid"> - <argument name="indices" value="customer_grid"/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindexCustomerGrid"/> </before> <after> @@ -40,9 +38,7 @@ <fillField userInput="{{CustomerEntityOne.email}}" selector="{{AdminCustomerAccountInformationSection.email}}" stepKey="fillEmail"/> <click selector="{{AdminCustomerMainActionsSection.saveButton}}" stepKey="saveCustomer"/> <seeElement selector="{{AdminCustomerMessagesSection.successMessage}}" stepKey="assertSuccessMessage"/> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="ReloadPageActionGroup" stepKey="reloadPage"/> <comment userInput="Replacing reload action and preserve Backward Compatibility" stepKey="waitForLoad2"/> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminDeleteCustomerAddressesFromTheGridTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminDeleteCustomerAddressesFromTheGridTest.xml index 62dcd6fc4d894..b3d432b7776aa 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/AdminDeleteCustomerAddressesFromTheGridTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminDeleteCustomerAddressesFromTheGridTest.xml @@ -20,9 +20,7 @@ <before> <createData entity="Simple_US_Customer_Multiple_Addresses" stepKey="createCustomer"/> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="AdminLoginActionGroup" stepKey="login"/> </before> <after> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminDeleteCustomerAddressesFromTheGridViaMassActionsTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminDeleteCustomerAddressesFromTheGridViaMassActionsTest.xml index c6e72901b062c..15eae933ccdda 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/AdminDeleteCustomerAddressesFromTheGridViaMassActionsTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminDeleteCustomerAddressesFromTheGridViaMassActionsTest.xml @@ -20,9 +20,7 @@ <before> <createData entity="Simple_US_Customer_Multiple_Addresses" stepKey="createCustomer"/> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="AdminLoginActionGroup" stepKey="login"/> </before> <after> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminDeleteDefaultBillingCustomerAddressTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminDeleteDefaultBillingCustomerAddressTest.xml index 52c8029b8f778..55c9315f42fa9 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/AdminDeleteDefaultBillingCustomerAddressTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminDeleteDefaultBillingCustomerAddressTest.xml @@ -20,9 +20,7 @@ <before> <createData entity="Simple_US_Customer_Multiple_Addresses" stepKey="createCustomer"/> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="AdminLoginActionGroup" stepKey="login"/> </before> <after> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminResetCustomerPasswordTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminResetCustomerPasswordTest.xml index 257d4c9b2e3c2..4ffb59dd7c658 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/AdminResetCustomerPasswordTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminResetCustomerPasswordTest.xml @@ -25,9 +25,7 @@ <deleteData createDataKey="customer" stepKey="deleteCustomer"/> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> </after> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminSearchCustomerAddressByKeywordTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminSearchCustomerAddressByKeywordTest.xml index bac1c665cbe78..7a9743482f81e 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/AdminSearchCustomerAddressByKeywordTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminSearchCustomerAddressByKeywordTest.xml @@ -20,9 +20,7 @@ <before> <createData entity="Simple_US_Customer_Multiple_Addresses" stepKey="createCustomer"/> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="AdminLoginActionGroup" stepKey="login"/> </before> <after> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminUpdateCustomerTest/AdminDeleteCustomerAddressTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminUpdateCustomerTest/AdminDeleteCustomerAddressTest.xml index 3f95e55c56132..3fa29aef9908e 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/AdminUpdateCustomerTest/AdminDeleteCustomerAddressTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminUpdateCustomerTest/AdminDeleteCustomerAddressTest.xml @@ -20,9 +20,7 @@ </annotations> <before> <createData stepKey="customer" entity="Simple_US_Customer_Multiple_Addresses"/> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="AdminLoginActionGroup" stepKey="login"/> </before> <after> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminUpdateCustomerTest/AdminUpdateCustomerInfoFromDefaultToNonDefaultTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminUpdateCustomerTest/AdminUpdateCustomerInfoFromDefaultToNonDefaultTest.xml index fb6793b1751a6..971a93f64d800 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/AdminUpdateCustomerTest/AdminUpdateCustomerInfoFromDefaultToNonDefaultTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminUpdateCustomerTest/AdminUpdateCustomerInfoFromDefaultToNonDefaultTest.xml @@ -20,9 +20,7 @@ </annotations> <before> <createData stepKey="customer" entity="Simple_Customer_Without_Address"/> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="AdminLoginActionGroup" stepKey="login"/> </before> <after> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AllowedCountriesRestrictionApplyOnBackendTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AllowedCountriesRestrictionApplyOnBackendTest.xml index 6a157c6312530..34cd34425815a 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/AllowedCountriesRestrictionApplyOnBackendTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/AllowedCountriesRestrictionApplyOnBackendTest.xml @@ -42,9 +42,7 @@ <!--Set account sharing option - Default value is 'Per Website'--> <comment userInput="Set account sharing option - Default value is 'Per Website'" stepKey="setAccountSharingOption"/> <createData entity="CustomerAccountSharingDefault" stepKey="setToAccountSharingToDefault"/> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> </before> <after> <!--delete all created data and set main website country options to default--> @@ -62,9 +60,7 @@ <actionGroup ref="SetWebsiteCountryOptionsToDefaultActionGroup" stepKey="setCountryOptionsToDefault"/> <createData entity="CustomerAccountSharingSystemValue" stepKey="setAccountSharingToSystemValue"/> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontClearAllCompareProductsTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontClearAllCompareProductsTest.xml index 130e1ba6723ae..9371a51e7770f 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontClearAllCompareProductsTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontClearAllCompareProductsTest.xml @@ -102,9 +102,7 @@ <requiredEntity createDataKey="createDownloadableProduct1"/> </createData> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontCreateCustomerWithDateOfBirthTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontCreateCustomerWithDateOfBirthTest.xml index 47b61b332f571..148afb6d67c21 100644 --- a/app/code/Magento/Customer/Test/Mftf/Test/StorefrontCreateCustomerWithDateOfBirthTest.xml +++ b/app/code/Magento/Customer/Test/Mftf/Test/StorefrontCreateCustomerWithDateOfBirthTest.xml @@ -36,7 +36,7 @@ <argument name="dob" value="{{EN_US_DATE.short4DigitYear}}"/> </actionGroup> <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> + <argument name="indices" value="customer_grid"/> </actionGroup> <actionGroup ref="DeleteCustomerByEmailActionGroup" stepKey="deleteNewUser"> <argument name="email" value="{{CustomerEntityOne.email}}"/> diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAssociateGroupedProductToWebsitesTest.xml b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAssociateGroupedProductToWebsitesTest.xml index a909582c32b3d..16a3ad59b5494 100644 --- a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAssociateGroupedProductToWebsitesTest.xml +++ b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdminAssociateGroupedProductToWebsitesTest.xml @@ -51,11 +51,7 @@ <argument name="StoreGroup" value="SecondStoreGroupUnique"/> <argument name="customStore" value="SecondStoreUnique"/> </actionGroup> - - <!-- Reindex --> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindexAllIndexes"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindexAllIndexes"/> </before> <after> diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByDescriptionTest.xml b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByDescriptionTest.xml index 4aa4e99e79489..b4a3bb88d2e28 100644 --- a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByDescriptionTest.xml +++ b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByDescriptionTest.xml @@ -30,9 +30,7 @@ <requiredEntity createDataKey="product"/> <requiredEntity createDataKey="simple2"/> </updateData> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByNameTest.xml b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByNameTest.xml index 06dde74de20f9..0e620992ad6be 100644 --- a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByNameTest.xml +++ b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByNameTest.xml @@ -30,9 +30,7 @@ <requiredEntity createDataKey="product"/> <requiredEntity createDataKey="simple2"/> </updateData> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByPriceTest.xml b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByPriceTest.xml index 66e1b60331e97..79691face4911 100644 --- a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByPriceTest.xml +++ b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByPriceTest.xml @@ -39,9 +39,7 @@ <getData entity="GetProduct" stepKey="arg3"> <requiredEntity createDataKey="simple2"/> </getData> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByShortDescriptionTest.xml b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByShortDescriptionTest.xml index 79b465abe2ac6..2d7c2aee05cb0 100644 --- a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByShortDescriptionTest.xml +++ b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductByShortDescriptionTest.xml @@ -30,9 +30,7 @@ <requiredEntity createDataKey="product"/> <requiredEntity createDataKey="simple2"/> </updateData> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductBySkuTest.xml b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductBySkuTest.xml index c196abbce99ed..5142558eaff66 100644 --- a/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductBySkuTest.xml +++ b/app/code/Magento/GroupedProduct/Test/Mftf/Test/AdvanceCatalogSearchGroupedProductTest/AdvanceCatalogSearchGroupedProductBySkuTest.xml @@ -29,9 +29,7 @@ <requiredEntity createDataKey="product"/> <requiredEntity createDataKey="simple2"/> </updateData> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> From 9dd746a38e70856602ac385d1b1a5f89bbc6cbc3 Mon Sep 17 00:00:00 2001 From: Sergiy Vasiutynskyi <s.vasiutynskyi@atwix.com> Date: Wed, 20 Jan 2021 22:15:14 +0200 Subject: [PATCH 34/68] Removed usage or changed value of CliIndexerReindexActionGroup action group for Sales, SalesRule, Search, Store, Swatches modules --- ...elTheCreatedOrderWithCheckMoneyOrderPaymentMethodTest.xml | 4 +--- ...ncelTheCreatedOrderWithPurchaseOrderPaymentMethodTest.xml | 4 +--- .../Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml | 5 +---- .../Test/AdminReorderWithCatalogPriceRuleDiscountTest.xml | 4 +--- .../Test/Mftf/Test/CreateOrderFromEditCustomerPageTest.xml | 4 +--- .../MoveRecentlyViewedBundleFixedProductOnOrderPageTest.xml | 4 +--- .../Test/Mftf/Test/StorefrontOrderPagerDisplayedTest.xml | 5 +---- ...efrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml | 4 +--- ...refrontVerifySearchSuggestionByProductDescriptionTest.xml | 5 +---- .../StorefrontVerifySearchSuggestionByProductNameTest.xml | 5 +---- ...ntVerifySearchSuggestionByProductShortDescriptionTest.xml | 5 +---- .../StorefrontVerifySearchSuggestionByProductSkuTest.xml | 5 +---- .../Test/Mftf/Test/StorefrontCheckSortOrderStoreViewTest.xml | 4 +--- .../Test/StorefrontDisplayAllCharactersOnTextSwatchTest.xml | 5 +---- .../Test/Mftf/Test/StorefrontFilterByImageSwatchTest.xml | 5 +---- .../Test/Mftf/Test/StorefrontFilterByTextSwatchTest.xml | 5 +---- .../Test/Mftf/Test/StorefrontFilterByVisualSwatchTest.xml | 5 +---- .../Test/StorefrontImageColorWhenFilterByColorFilterTest.xml | 5 +---- 18 files changed, 18 insertions(+), 65 deletions(-) diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCancelTheCreatedOrderWithCheckMoneyOrderPaymentMethodTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCancelTheCreatedOrderWithCheckMoneyOrderPaymentMethodTest.xml index 7d6e2048c9432..9c99b3140bc0c 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCancelTheCreatedOrderWithCheckMoneyOrderPaymentMethodTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCancelTheCreatedOrderWithCheckMoneyOrderPaymentMethodTest.xml @@ -94,9 +94,7 @@ <requiredEntity createDataKey="createConfigProduct"/> <requiredEntity createDataKey="createConfigChildProduct1"/> </createData> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCancelTheCreatedOrderWithPurchaseOrderPaymentMethodTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCancelTheCreatedOrderWithPurchaseOrderPaymentMethodTest.xml index 9f09a59fa8d5e..9680cbd1e289a 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCancelTheCreatedOrderWithPurchaseOrderPaymentMethodTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCancelTheCreatedOrderWithPurchaseOrderPaymentMethodTest.xml @@ -35,9 +35,7 @@ <createData entity="SimpleProduct2" stepKey="simpleProduct"> <field key="price">10.00</field> </createData> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml index 33bc1a39ca11a..fa11b567fee95 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCorrectnessInvoicedItemInBundleProductTest.xml @@ -57,10 +57,7 @@ </actionGroup> <actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/> - <!--Run re-index task--> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <!--Go to bundle product page--> <amOnPage url="{{StorefrontProductPage.url($$createCategory.name$$)}}" stepKey="navigateToBundleProductPage"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminReorderWithCatalogPriceRuleDiscountTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminReorderWithCatalogPriceRuleDiscountTest.xml index 4799984b76745..f24ac5c587913 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/AdminReorderWithCatalogPriceRuleDiscountTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminReorderWithCatalogPriceRuleDiscountTest.xml @@ -29,9 +29,7 @@ <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <amOnPage url="{{AdminCatalogPriceRuleGridPage.url}}" stepKey="goToAdminCatalogPriceRuleGridPage2"/> <!-- It sometimes is loading too long for default 10s --> <waitForPageLoad time="60" stepKey="waitForPageFullyLoaded2"/> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/CreateOrderFromEditCustomerPageTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/CreateOrderFromEditCustomerPageTest.xml index 08d5776b79ea0..32668bc5c857d 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/CreateOrderFromEditCustomerPageTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/CreateOrderFromEditCustomerPageTest.xml @@ -75,9 +75,7 @@ <requiredEntity createDataKey="createConfigProduct"/> <requiredEntity createDataKey="createConfigChildProduct1"/> </createData> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/MoveRecentlyViewedBundleFixedProductOnOrderPageTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/MoveRecentlyViewedBundleFixedProductOnOrderPageTest.xml index 452d65ea5ae57..850dd9e1b5795 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/MoveRecentlyViewedBundleFixedProductOnOrderPageTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/MoveRecentlyViewedBundleFixedProductOnOrderPageTest.xml @@ -57,9 +57,7 @@ <!-- Change configuration --> <magentoCLI command="config:set reports/options/enabled 1" stepKey="enableReportModule"/> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> </before> <after> <!-- Admin logout --> diff --git a/app/code/Magento/Sales/Test/Mftf/Test/StorefrontOrderPagerDisplayedTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/StorefrontOrderPagerDisplayedTest.xml index 6b6b0b2ef4a16..8e41247a37b54 100644 --- a/app/code/Magento/Sales/Test/Mftf/Test/StorefrontOrderPagerDisplayedTest.xml +++ b/app/code/Magento/Sales/Test/Mftf/Test/StorefrontOrderPagerDisplayedTest.xml @@ -89,10 +89,7 @@ <!-- Customer is created --> <createData entity="Simple_US_Customer" stepKey="createCustomer"/> - <!-- Reindex and flush the cache to display products on the category page --> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml index 8df45937bb542..7e5daa3d31ddb 100644 --- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml +++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml @@ -56,9 +56,7 @@ <createData entity="SimpleProduct2" stepKey="createSimpleProductThird"> <field key="price">5.50</field> </createData> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductDescriptionTest.xml b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductDescriptionTest.xml index 8c468cce91829..ce2a9a7691fbb 100644 --- a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductDescriptionTest.xml +++ b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductDescriptionTest.xml @@ -23,10 +23,7 @@ <!-- Create product with description --> <createData entity="SimpleProductWithDescription" stepKey="simpleProduct"/> - <!-- Perform reindex and flush cache --> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductNameTest.xml b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductNameTest.xml index fb1f35730fd80..57fc8fbf343c1 100644 --- a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductNameTest.xml +++ b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductNameTest.xml @@ -25,10 +25,7 @@ <!--Create Simple Product --> <createData entity="defaultSimpleProduct" stepKey="simpleProduct"/> - <!-- Perform reindex and flush cache --> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductShortDescriptionTest.xml b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductShortDescriptionTest.xml index 1558f9aa5342b..567f88c0d612c 100644 --- a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductShortDescriptionTest.xml +++ b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductShortDescriptionTest.xml @@ -25,10 +25,7 @@ <!-- Create product with short description --> <createData entity="ApiProductWithDescription" stepKey="product"/> - <!-- Perform reindex and flush cache --> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductSkuTest.xml b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductSkuTest.xml index 19c12843c23a2..1f9213ced0144 100644 --- a/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductSkuTest.xml +++ b/app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductSkuTest.xml @@ -25,10 +25,7 @@ <!--Create Simple Product --> <createData entity="defaultSimpleProduct" stepKey="simpleProduct"/> - <!-- Perform reindex and flush cache --> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/Store/Test/Mftf/Test/StorefrontCheckSortOrderStoreViewTest.xml b/app/code/Magento/Store/Test/Mftf/Test/StorefrontCheckSortOrderStoreViewTest.xml index 442ee99e12793..3219877cc6426 100644 --- a/app/code/Magento/Store/Test/Mftf/Test/StorefrontCheckSortOrderStoreViewTest.xml +++ b/app/code/Magento/Store/Test/Mftf/Test/StorefrontCheckSortOrderStoreViewTest.xml @@ -38,9 +38,7 @@ <argument name="storeGroupName" value="SecondStoreGroupUnique.name"/> </actionGroup> <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontDisplayAllCharactersOnTextSwatchTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontDisplayAllCharactersOnTextSwatchTest.xml index b661ecb338bde..91b918714a9c4 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontDisplayAllCharactersOnTextSwatchTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontDisplayAllCharactersOnTextSwatchTest.xml @@ -29,10 +29,7 @@ <fillField selector="{{AdminManageSwatchSection.swatchTextByIndex('3')}}" userInput="123456789012345678901" stepKey="fillSwatch3" after="clickAddSwatch3"/> <fillField selector="{{AdminManageSwatchSection.swatchAdminDescriptionByIndex('3')}}" userInput="123456789012345678901BrownD" stepKey="fillDescription3" after="fillSwatch3"/> - <!--Run re-index task--> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <see selector="{{StorefrontCategorySidebarSection.attributeNthOption(ProductAttributeFrontendLabel.label, '3')}}" userInput="123456789012345678901" stepKey="seeGreen" after="seeBlue"/> <see selector="{{StorefrontCategorySidebarSection.attributeNthOption(ProductAttributeFrontendLabel.label, '4')}}" userInput="123456789012345678901" stepKey="seeBrown" after="seeGreen"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByImageSwatchTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByImageSwatchTest.xml index 4ed8824d9e39b..159b57f3a39f8 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByImageSwatchTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByImageSwatchTest.xml @@ -103,10 +103,7 @@ <argument name="image" value="TestImageAdobe"/> </actionGroup> - <!-- Run re-index task--> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <!-- Go to the category page --> <amOnPage url="$$createCategory.name$$.html" stepKey="amOnCategoryPage"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByTextSwatchTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByTextSwatchTest.xml index 4a78b4380fb68..a7aff1a7c89ff 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByTextSwatchTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByTextSwatchTest.xml @@ -80,10 +80,7 @@ <argument name="attributeCode" value="{{ProductAttributeFrontendLabel.label}}"/> </actionGroup> - <!--Run re-index task--> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <!-- Go to the category page --> <amOnPage url="$$createCategory.name$$.html" stepKey="amOnCategoryPage"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByVisualSwatchTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByVisualSwatchTest.xml index 2a986463a3d14..902d1a8f21c33 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByVisualSwatchTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontFilterByVisualSwatchTest.xml @@ -92,10 +92,7 @@ <argument name="attributeCode" value="{{ProductAttributeFrontendLabel.label}}"/> </actionGroup> - <!-- Run re-index task--> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <!-- Go to the category page --> <amOnPage url="$$createCategory.name$$.html" stepKey="amOnCategoryPage"/> diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontImageColorWhenFilterByColorFilterTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontImageColorWhenFilterByColorFilterTest.xml index 734294ba977ba..f7211d9ef8516 100644 --- a/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontImageColorWhenFilterByColorFilterTest.xml +++ b/app/code/Magento/Swatches/Test/Mftf/Test/StorefrontImageColorWhenFilterByColorFilterTest.xml @@ -70,10 +70,7 @@ <click selector="{{AdminCreateProductConfigurationsPanel.next}}" stepKey="clickOnGenerateProductsButton"/> <actionGroup ref="SaveProductFormActionGroup" stepKey="saveProductForm"/> - <!-- Perform reindex and flush cache --> - <actionGroup ref="CliIndexerReindexActionGroup" stepKey="reindex"> - <argument name="indices" value=""/> - </actionGroup> + <comment userInput="Adding the comment to replace CliIndexerReindexActionGroup action group ('indexer:reindex' commands) for preserving Backward Compatibility" stepKey="reindex"/> <actionGroup ref="CliCacheFlushActionGroup" stepKey="flushCache"> <argument name="tags" value=""/> </actionGroup> From f11d2779c59cc11a7dd7d3e1b291241db0789d95 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" <engcom-vendorworker-charlie@adobe.com> Date: Thu, 21 Jan 2021 15:27:48 +0200 Subject: [PATCH 35/68] introduced requested changes --- app/code/Magento/Cms/Model/Page/DataProvider.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php index fc2e89ae726bd..6afde01cfe6c6 100644 --- a/app/code/Magento/Cms/Model/Page/DataProvider.php +++ b/app/code/Magento/Cms/Model/Page/DataProvider.php @@ -164,10 +164,9 @@ private function getCurrentPage(): PageInterface return $this->pageFactory->create(); } $this->dataPersistor->clear('cms_page'); - $page = $this->pageFactory->create() - ->setData($data); - return $page; + return $this->pageFactory->create() + ->setData($data); } /** @@ -217,17 +216,14 @@ public function getMeta() $page = null; try { $page = $this->pageRepository->getById($this->getPageId()); - } catch (LocalizedException $e) { - $this->logger->error($e->getMessage()); - } - - if ($page) { if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) { $options[] = ['label' => 'Use existing layout update XML', 'value' => '_existing_']; } foreach ($this->customLayoutManager->fetchAvailableFiles($page) as $layoutFile) { $options[] = ['label' => $layoutFile, 'value' => $layoutFile]; } + } catch (LocalizedException $e) { + $this->logger->error($e->getMessage()); } $customLayoutMeta = [ From 5924f9f46b3cc5212659455809c4a7ab7beba2fe Mon Sep 17 00:00:00 2001 From: Serhii Balko <serhii.balko@transogtgroup.com> Date: Thu, 21 Jan 2021 16:20:48 +0200 Subject: [PATCH 36/68] MC-38625: Storefront Order History product count is doubled if has more than 10 configurables --- app/code/Magento/Sales/Block/Order/Items.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Sales/Block/Order/Items.php b/app/code/Magento/Sales/Block/Order/Items.php index d7255a24aead5..27ba2dca5d152 100644 --- a/app/code/Magento/Sales/Block/Order/Items.php +++ b/app/code/Magento/Sales/Block/Order/Items.php @@ -71,6 +71,7 @@ protected function _prepareLayout() $this->itemCollection = $this->itemCollectionFactory->create(); $this->itemCollection->setOrderFilter($this->getOrder()); + $this->itemCollection->addFieldToFilter('parent_item_id', ['null' => true]); /** @var \Magento\Theme\Block\Html\Pager $pagerBlock */ $pagerBlock = $this->getChildBlock('sales_order_item_pager'); From ca34ef7210e8ef42426b2268726054a960cc31e1 Mon Sep 17 00:00:00 2001 From: Serhii Balko <serhii.balko@transogtgroup.com> Date: Thu, 21 Jan 2021 17:09:01 +0200 Subject: [PATCH 37/68] MC-38625: Storefront Order History product count is doubled if has more than 10 configurables --- .../Magento/Sales/Block/Order/ItemsTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/ItemsTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/ItemsTest.php index 7fdfc79b3fdfe..d4db5f1dd96f1 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/ItemsTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/ItemsTest.php @@ -81,6 +81,19 @@ public function testGetOrderItems(): void $this->assertCount(1, $this->block->getItems()); } + /** + * @magentoDataFixture Magento/Sales/_files/order_configurable_product.php + * + * @return void + */ + public function testGetOrderItemsConfigurable(): void + { + $order = $this->orderFactory->create()->loadByIncrementId('100000001'); + $this->registerOrder($order); + $this->block = $this->layout->createBlock(Items::class); + $this->assertCount(1, $this->block->getItems()); + } + /** * @magentoConfigFixture default/sales/orders/items_per_page 3 * @magentoDataFixture Magento/Sales/_files/order_item_list.php From cc6d01699525b567f28ae4adf5a0c8e5c2964977 Mon Sep 17 00:00:00 2001 From: TuNa <ladiesman9x@gmail.com> Date: Wed, 11 Nov 2020 08:10:26 +0700 Subject: [PATCH 38/68] Update sortOrder load for async css plugin --- app/code/Magento/Theme/etc/frontend/di.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Theme/etc/frontend/di.xml b/app/code/Magento/Theme/etc/frontend/di.xml index 35eb9d4f8b53c..f0b7f19911e12 100644 --- a/app/code/Magento/Theme/etc/frontend/di.xml +++ b/app/code/Magento/Theme/etc/frontend/di.xml @@ -27,7 +27,7 @@ <plugin name="result-messages" type="Magento\Theme\Controller\Result\MessagePlugin"/> </type> <type name="Magento\Framework\View\Result\Layout"> - <plugin name="asyncCssLoad" type="Magento\Theme\Controller\Result\AsyncCssPlugin" /> + <plugin name="asyncCssLoad" type="Magento\Theme\Controller\Result\AsyncCssPlugin" sortOrder="-20" /> <plugin name="deferJsToFooter" type="Magento\Theme\Controller\Result\JsFooterPlugin" sortOrder="-10" /> </type> <type name="Magento\Theme\Block\Html\Header\CriticalCss"> From d5870527d6b1fef3fe3b0f1d4c797a0698231411 Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi <tsviklinskyi@gmail.com> Date: Mon, 25 Jan 2021 14:31:55 +0200 Subject: [PATCH 39/68] MC-40240: Product grid date filters does not work for en_GB locale --- app/code/Magento/Ui/Component/Filters.php | 32 +++++++++++++++++-- .../view/base/web/js/grid/filters/filters.js | 5 ++- .../Ui/view/base/web/js/grid/filters/range.js | 5 ++- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Ui/Component/Filters.php b/app/code/Magento/Ui/Component/Filters.php index 5bf89ae7936e9..aa418a4522044 100644 --- a/app/code/Magento/Ui/Component/Filters.php +++ b/app/code/Magento/Ui/Component/Filters.php @@ -5,6 +5,8 @@ */ namespace Magento\Ui\Component; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponent\ObserverInterface; use Magento\Framework\View\Element\UiComponentFactory; @@ -47,16 +49,42 @@ class Filters extends AbstractComponent implements ObserverInterface protected $uiComponentFactory; /** - * @inheritDoc + * @var TimezoneInterface + */ + private $localeDate; + + /** + * Filters constructor. + * + * @param ContextInterface $context + * @param UiComponentFactory $uiComponentFactory + * @param array $components + * @param array $data + * @param TimezoneInterface|null $localeDate */ public function __construct( ContextInterface $context, UiComponentFactory $uiComponentFactory, array $components = [], - array $data = [] + array $data = [], + ?TimezoneInterface $localeDate = null ) { parent::__construct($context, $components, $data); $this->uiComponentFactory = $uiComponentFactory; + $this->localeDate = $localeDate ?? ObjectManager::getInstance()->get(TimezoneInterface::class); + } + + /** + * @inheritDoc + */ + public function prepare() + { + $config = $this->getData('config'); + // Set date format pattern by current locale + $localeDateFormat = $this->localeDate->getDateFormat(); + $config['options']['dateFormat'] = $localeDateFormat; + $this->setData('config', $config); + parent::prepare(); } /** diff --git a/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js b/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js index 848ad60219a2b..9377d25b82e2e 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js @@ -124,7 +124,10 @@ define([ * * @returns {Filters} Chainable. */ - initialize: function () { + initialize: function (config) { + if (typeof config.options !== 'undefined' && config.options.dateFormat) { + this.constructor.defaults.templates.filters.dateRange.dateFormat = config.options.dateFormat; + } _.bindAll(this, 'updateActive'); this._super() diff --git a/app/code/Magento/Ui/view/base/web/js/grid/filters/range.js b/app/code/Magento/Ui/view/base/web/js/grid/filters/range.js index 1949234c89324..39f2da98b3cba 100644 --- a/app/code/Magento/Ui/view/base/web/js/grid/filters/range.js +++ b/app/code/Magento/Ui/view/base/web/js/grid/filters/range.js @@ -59,7 +59,10 @@ define([ * * @returns {Range} Chainable. */ - initialize: function () { + initialize: function (config) { + if (config.dateFormat) { + this.constructor.defaults.templates.date.pickerDefaultDateFormat = config.dateFormat; + } this._super() .initChildren(); From f5ccdbae904a3e09bc3ccbc12083b939608a157f Mon Sep 17 00:00:00 2001 From: Serhiy Yelahin <serhiy.yelahin@transoftgroup.com> Date: Tue, 26 Jan 2021 17:39:31 +0200 Subject: [PATCH 40/68] MC-40579: [Magento Cloud] Customer Account created time not filtered correctly --- .../Model/ResourceModel/Grid/Collection.php | 21 +++++++++- .../ResourceModel/Grid/CollectionTest.php | 40 ++++++++++++++----- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php b/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php index 0fab27161ce25..e14594daf8011 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php +++ b/app/code/Magento/Customer/Model/ResourceModel/Grid/Collection.php @@ -7,10 +7,12 @@ use Magento\Customer\Model\ResourceModel\Customer; use Magento\Customer\Ui\Component\DataProvider\Document; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy; use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory; use Magento\Framework\Event\ManagerInterface as EventManager; use Magento\Framework\Locale\ResolverInterface; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult; use Psr\Log\LoggerInterface as Logger; @@ -24,6 +26,11 @@ class Collection extends SearchResult */ private $localeResolver; + /** + * @var TimezoneInterface + */ + private $timeZone; + /** * @inheritdoc */ @@ -42,6 +49,7 @@ class Collection extends SearchResult * @param ResolverInterface $localeResolver * @param string $mainTable * @param string $resourceModel + * @param TimezoneInterface|null $timeZone */ public function __construct( EntityFactory $entityFactory, @@ -50,10 +58,13 @@ public function __construct( EventManager $eventManager, ResolverInterface $localeResolver, $mainTable = 'customer_grid_flat', - $resourceModel = Customer::class + $resourceModel = Customer::class, + TimezoneInterface $timeZone = null ) { $this->localeResolver = $localeResolver; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel); + $this->timeZone = $timeZone ?: ObjectManager::getInstance() + ->get(TimezoneInterface::class); } /** @@ -81,6 +92,14 @@ public function addFieldToFilter($field, $condition = null) return $this; } + if ($field === 'created_at') { + if (is_array($condition)) { + foreach ($condition as $key => $value) { + $condition[$key] = $this->timeZone->convertConfigTimeToUtc($value); + } + } + } + if (is_string($field) && count(explode('.', $field)) === 1) { $field = 'main_table.' . $field; } diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/Grid/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/Grid/CollectionTest.php index 321cb24a7fee5..1525065dcf4d3 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/Grid/CollectionTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/Grid/CollectionTest.php @@ -8,16 +8,19 @@ use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Customer\Api\Data\CustomerInterface; +use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Indexer\TestCase; /** * Customer grid collection tests. */ -class CollectionTest extends \Magento\TestFramework\Indexer\TestCase +class CollectionTest extends TestCase { public static function setUpBeforeClass(): void { - $db = Bootstrap::getInstance()->getBootstrap() + $db = Bootstrap::getInstance() + ->getBootstrap() ->getApplication() ->getDbInstance(); if (!$db->isDbDumpExists()) { @@ -42,12 +45,10 @@ public static function setUpBeforeClass(): void */ public function testGetItemByIdForUpdateOnSchedule() { - $targetObject = Bootstrap::getObjectManager()->create( - \Magento\Customer\Model\ResourceModel\Grid\Collection::class - ); - $customerRepository = Bootstrap::getObjectManager()->create( - CustomerRepositoryInterface::class - ); + $targetObject = Bootstrap::getObjectManager() + ->create(Collection::class); + $customerRepository = Bootstrap::getObjectManager() + ->create(CustomerRepositoryInterface::class); /** Verify after first save */ /** @var CustomerInterface $newCustomer */ @@ -68,7 +69,28 @@ public function testGetItemByIdForUpdateOnSchedule() } /** - * teardown + * Verifies that filter condition date is being converted to config timezone before select sql query + * + * @return void + */ + public function testAddFieldToFilter(): void + { + $filterDate = "2021-01-26 00:00:00"; + /** @var TimezoneInterface $timeZone */ + $timeZone = Bootstrap::getObjectManager() + ->get(TimezoneInterface::class); + /** @var Collection $gridCollection */ + $gridCollection = Bootstrap::getObjectManager() + ->get(Collection::class); + $convertedDate = $timeZone->convertConfigTimeToUtc($filterDate); + $collection = $gridCollection->addFieldToFilter('created_at', ['qteq' => $filterDate]); + $expectedSelect = "WHERE (((`main_table`.`created_at` = '{$convertedDate}')))"; + + $this->assertStringContainsString($expectedSelect, $collection->getSelectSql(true)); + } + + /** + * @inheritDoc */ protected function tearDown(): void { From 29e010511cee1545158feb5e1c5163ac1315c853 Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi <tsviklinskyi@gmail.com> Date: Wed, 27 Jan 2021 09:36:51 +0200 Subject: [PATCH 41/68] MC-40240: Product grid date filters does not work for en_GB locale --- ...roductGridByCustomDateRangeActionGroup.xml | 27 +++++ .../AdminProductFormSection.xml | 1 + ...ridFilteringByDateWithCustomLocaleTest.xml | 99 +++++++++++++++++++ ...ateUserWithRoleAndSetLocaleActionGroup.xml | 18 ++++ 4 files changed, 145 insertions(+) create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/FilterProductGridByCustomDateRangeActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByDateWithCustomLocaleTest.xml create mode 100644 app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleAndSetLocaleActionGroup.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/FilterProductGridByCustomDateRangeActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/FilterProductGridByCustomDateRangeActionGroup.xml new file mode 100644 index 0000000000000..30b15abb234d5 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/FilterProductGridByCustomDateRangeActionGroup.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="FilterProductGridByCustomDateRangeActionGroup"> + <annotations> + <description>Filters the Admin Products grid by the provided Date Filter.</description> + </annotations> + <arguments> + <argument name="code" type="string"/> + <argument name="date" type="string"/> + </arguments> + + <conditionalClick selector="{{AdminProductGridFilterSection.clearFilters}}" dependentSelector="{{AdminProductGridFilterSection.clearFilters}}" visible="true" stepKey="clickClearFiltersInitial"/> + <click selector="{{AdminProductGridFilterSection.filters}}" stepKey="openProductFilters"/> + <fillField selector="{{AdminProductGridFilterSection.inputByCodeRangeFrom(code)}}" userInput="{{date}}" stepKey="fillProductDatetimeFromFilter"/> + <fillField selector="{{AdminProductGridFilterSection.inputByCodeRangeTo(code)}}" userInput="{{date}}" stepKey="fillProductDatetimeToFilter"/> + <click selector="{{AdminProductGridFilterSection.applyFilters}}" stepKey="clickApplyFilters"/> + <waitForElementNotVisible selector="{{AdminProductGridSection.loadingMask}}" stepKey="waitForFilteredGridLoad" time="30"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection/AdminProductFormSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection/AdminProductFormSection.xml index d70c48f2b00e3..590b9a185e5e4 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection/AdminProductFormSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection/AdminProductFormSection.xml @@ -75,6 +75,7 @@ <element name="selectMultipleCategories" type="input" selector="//*[@data-index='container_category_ids']//*[contains(@class, '_selected')]"/> <element name="countryOfManufacture" type="select" selector="select[name='product[country_of_manufacture]']"/> <element name="newAddedAttribute" type="text" selector="//fieldset[@class='admin__fieldset']//div[contains(@data-index,'{{attributeCode}}')]" parameterized="true"/> + <element name="newAddedAttributeInput" type="text" selector="//fieldset[@class='admin__fieldset']//div[contains(@data-index,'{{attributeCode}}')]//input" parameterized="true"/> <element name="newCategoryButton" type="button" selector="button[data-index='create_category_button']" timeout="30"/> <element name="footerBlock" type="block" selector="//footer"/> <element name="categories" type="text" selector="//*[@class='admin__action-multiselect-crumb']/span[contains(text(), '{{categoryName}}')]" parameterized="true"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByDateWithCustomLocaleTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByDateWithCustomLocaleTest.xml new file mode 100644 index 0000000000000..a19595ed93339 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByDateWithCustomLocaleTest.xml @@ -0,0 +1,99 @@ +<?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="AdminProductGridFilteringByDateWithCustomLocaleTest"> + <annotations> + <features value="Catalog"/> + <stories value="Filter products"/> + <title value="Product grid date filters does not work for en_GB locale"/> + <description value="Product grid date filters does not work for en_GB locale"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-40644"/> + <useCaseId value="MC-40240"/> + <group value="catalog"/> + </annotations> + + <before> + <createData entity="_defaultCategory" stepKey="createCategory"/> + <createData entity="SimpleProduct" stepKey="createProduct"> + <requiredEntity createDataKey="createCategory"/> + </createData> + + <!-- Create new User --> + <actionGroup ref="AdminLoginActionGroup" stepKey="adminLogin"/> + <actionGroup ref="AdminCreateUserWithRoleAndLocaleActionGroup" stepKey="createAdminUser"> + <argument name="user" value="activeAdmin"/> + <argument name="role" value="roleDefaultAdministrator"/> + <argument name="interfaceLocale" value="en_GB"/> + </actionGroup> + </before> + <after> + <deleteData createDataKey="createCategory" stepKey="deleteCategory"/> + <deleteData createDataKey="createProduct" stepKey="deleteProduct"/> + <actionGroup ref="DeleteProductAttributeActionGroup" stepKey="deleteAttribute"> + <argument name="ProductAttribute" value="dateProductAttribute"/> + </actionGroup> + <actionGroup ref="AdminGridFilterResetActionGroup" stepKey="resetGridFilter"/> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> + </after> + + <!-- Generate date for use as default value, needs to be MM/d/YYYY and mm/d/yy --> + <generateDate date="now" format="m/j/Y" stepKey="generateDefaultDate"/> + <generateDate date="now" format="j/m/Y" stepKey="generateDefaultDateGB"/> + + <!-- Navigate to Stores > Attributes > Product. --> + <actionGroup ref="AdminOpenProductAttributePageActionGroup" stepKey="goToProductAttributes"/> + + <!-- Create new Product Attribute as TextField, with code and default value. --> + <actionGroup ref="CreateProductAttributeWithDateFieldActionGroup" stepKey="createAttribute"> + <argument name="attribute" value="dateProductAttribute"/> + <argument name="date" value="{$generateDefaultDate}"/> + </actionGroup> + + <!-- Go to default attribute set edit page --> + <amOnPage url="{{AdminProductAttributeSetEditPage.url}}/{{AddToDefaultSet.attributeSetId}}/" stepKey="onAttributeSetEdit"/> + <!-- Assert created attribute in unassigned section --> + <see userInput="{{dateProductAttribute.attribute_code}}" selector="{{AdminProductAttributeSetEditSection.unassignedAttributesTree}}" stepKey="seeAttributeInUnassigned"/> + <!-- Assign attribute to a group --> + <actionGroup ref="AssignAttributeToGroupActionGroup" stepKey="assignAttributeToGroup"> + <argument name="group" value="Product Details"/> + <argument name="attribute" value="{{dateProductAttribute.attribute_code}}"/> + </actionGroup> + <!-- Assert attribute in a group --> + <see userInput="{{dateProductAttribute.attribute_code}}" selector="{{AdminProductAttributeSetEditSection.groupTree}}" stepKey="seeAttributeInGroup"/> + <!-- Save attribute set --> + <actionGroup ref="SaveAttributeSetActionGroup" stepKey="SaveAttributeSet"/> + + <!-- Open Product Edit Page and set custom attribute value --> + <actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForProduct"> + <argument name="product" value="$createProduct$"/> + </actionGroup> + <actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct"> + <argument name="product" value="$createProduct$"/> + </actionGroup> + <fillField selector="{{AdminProductFormSection.newAddedAttributeInput(dateProductAttribute.attribute_code)}}" userInput="{$generateDefaultDate}" stepKey="fillCustomDateValue"/> + <actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/> + + <!-- Logout master admin and Login as new User --> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logoutMasterAdmin"/> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginToNewAdmin"> + <argument name="username" value="{{activeAdmin.username}}"/> + <argument name="password" value="{{activeAdmin.password}}"/> + </actionGroup> + + <!-- Open Product Index Page and filter the product --> + <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="navigateToProductIndex2"/> + <actionGroup ref="FilterProductGridByCustomDateRangeActionGroup" stepKey="filterProductGridByCustomDateRange"> + <argument name="code" value="{{dateProductAttribute.attribute_code}}"/> + <argument name="date" value="{$generateDefaultDateGB}"/> + </actionGroup> + <!-- Check products filtering --> + <see selector="{{AdminProductGridSection.productGridNameProduct($createProduct.name$)}}" userInput="$createProduct.name$" stepKey="seeProductName"/> + </test> +</tests> diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleAndSetLocaleActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleAndSetLocaleActionGroup.xml new file mode 100644 index 0000000000000..d9fc4e488f2c8 --- /dev/null +++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleAndSetLocaleActionGroup.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <!-- Create new user with role and locale setting--> + <actionGroup name="AdminCreateUserWithRoleAndLocaleActionGroup" extends="AdminCreateUserWithRoleActionGroup"> + <arguments> + <argument name="interfaceLocale" defaultValue="en_US" type="string"/> + </arguments> + + <selectOption selector="{{AdminNewUserFormSection.interfaceLocale}}" userInput="{{interfaceLocale}}" stepKey="setInterfaceLocate" after="confirmPassword"/> + </actionGroup> +</actionGroups> From fb38d86539d4a053942a4cf579d01f0546e23788 Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi <tsviklinskyi@gmail.com> Date: Wed, 27 Jan 2021 12:46:47 +0200 Subject: [PATCH 42/68] MC-40240: Product grid date filters does not work for en_GB locale --- ...GridFilteringByDateWithCustomLocaleTest.xml | 8 ++++++-- ...eateUserWithRoleAndSetLocaleActionGroup.xml | 18 ------------------ 2 files changed, 6 insertions(+), 20 deletions(-) delete mode 100644 app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleAndSetLocaleActionGroup.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByDateWithCustomLocaleTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByDateWithCustomLocaleTest.xml index a19595ed93339..e6a51b696b457 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByDateWithCustomLocaleTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByDateWithCustomLocaleTest.xml @@ -27,10 +27,9 @@ <!-- Create new User --> <actionGroup ref="AdminLoginActionGroup" stepKey="adminLogin"/> - <actionGroup ref="AdminCreateUserWithRoleAndLocaleActionGroup" stepKey="createAdminUser"> + <actionGroup ref="AdminCreateUserWithRoleActionGroup" stepKey="createAdminUser"> <argument name="user" value="activeAdmin"/> <argument name="role" value="roleDefaultAdministrator"/> - <argument name="interfaceLocale" value="en_GB"/> </actionGroup> </before> <after> @@ -87,6 +86,11 @@ <argument name="password" value="{{activeAdmin.password}}"/> </actionGroup> + <!--Set Admin "Interface Locale" to "English (United Kingdom)"--> + <actionGroup ref="SetAdminAccountActionGroup" stepKey="setAdminInterfaceLocaleToFrance"> + <argument name="InterfaceLocaleByValue" value="en_GB"/> + </actionGroup> + <!-- Open Product Index Page and filter the product --> <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="navigateToProductIndex2"/> <actionGroup ref="FilterProductGridByCustomDateRangeActionGroup" stepKey="filterProductGridByCustomDateRange"> diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleAndSetLocaleActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleAndSetLocaleActionGroup.xml deleted file mode 100644 index d9fc4e488f2c8..0000000000000 --- a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleAndSetLocaleActionGroup.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - /** - * Copyright © Magento, Inc. All rights reserved. - * See COPYING.txt for license details. - */ ---> -<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> - <!-- Create new user with role and locale setting--> - <actionGroup name="AdminCreateUserWithRoleAndLocaleActionGroup" extends="AdminCreateUserWithRoleActionGroup"> - <arguments> - <argument name="interfaceLocale" defaultValue="en_US" type="string"/> - </arguments> - - <selectOption selector="{{AdminNewUserFormSection.interfaceLocale}}" userInput="{{interfaceLocale}}" stepKey="setInterfaceLocate" after="confirmPassword"/> - </actionGroup> -</actionGroups> From 9f9b35dc96cfc2733971767164f1a3f6849e01eb Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi <tsviklinskyi@gmail.com> Date: Wed, 27 Jan 2021 14:36:19 +0200 Subject: [PATCH 43/68] MC-40240: Product grid date filters does not work for en_GB locale --- ...GridFilteringByDateWithCustomLocaleTest.xml | 10 ++++------ ...eateUserWithRoleAndSetLocaleActionGroup.xml | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleAndSetLocaleActionGroup.xml diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByDateWithCustomLocaleTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByDateWithCustomLocaleTest.xml index e6a51b696b457..eae9cebd7e638 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByDateWithCustomLocaleTest.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByDateWithCustomLocaleTest.xml @@ -20,6 +20,8 @@ </annotations> <before> + <!-- Deploy static content with United Kingdom locale--> + <magentoCLI command="setup:static-content:deploy en_GB" stepKey="deployStaticContentWithUnitedKingdomLocale"/> <createData entity="_defaultCategory" stepKey="createCategory"/> <createData entity="SimpleProduct" stepKey="createProduct"> <requiredEntity createDataKey="createCategory"/> @@ -27,9 +29,10 @@ <!-- Create new User --> <actionGroup ref="AdminLoginActionGroup" stepKey="adminLogin"/> - <actionGroup ref="AdminCreateUserWithRoleActionGroup" stepKey="createAdminUser"> + <actionGroup ref="AdminCreateUserWithRoleAndLocaleActionGroup" stepKey="createAdminUser"> <argument name="user" value="activeAdmin"/> <argument name="role" value="roleDefaultAdministrator"/> + <argument name="interfaceLocale" value="en_GB"/> </actionGroup> </before> <after> @@ -86,11 +89,6 @@ <argument name="password" value="{{activeAdmin.password}}"/> </actionGroup> - <!--Set Admin "Interface Locale" to "English (United Kingdom)"--> - <actionGroup ref="SetAdminAccountActionGroup" stepKey="setAdminInterfaceLocaleToFrance"> - <argument name="InterfaceLocaleByValue" value="en_GB"/> - </actionGroup> - <!-- Open Product Index Page and filter the product --> <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="navigateToProductIndex2"/> <actionGroup ref="FilterProductGridByCustomDateRangeActionGroup" stepKey="filterProductGridByCustomDateRange"> diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleAndSetLocaleActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleAndSetLocaleActionGroup.xml new file mode 100644 index 0000000000000..d9fc4e488f2c8 --- /dev/null +++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserWithRoleAndSetLocaleActionGroup.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <!-- Create new user with role and locale setting--> + <actionGroup name="AdminCreateUserWithRoleAndLocaleActionGroup" extends="AdminCreateUserWithRoleActionGroup"> + <arguments> + <argument name="interfaceLocale" defaultValue="en_US" type="string"/> + </arguments> + + <selectOption selector="{{AdminNewUserFormSection.interfaceLocale}}" userInput="{{interfaceLocale}}" stepKey="setInterfaceLocate" after="confirmPassword"/> + </actionGroup> +</actionGroups> From 421a73f23daf10b091f4bcfba2e33c0462d7d657 Mon Sep 17 00:00:00 2001 From: Yurii Sapiha <yurasapiga93@gmail.com> Date: Thu, 28 Jan 2021 14:59:51 +0200 Subject: [PATCH 44/68] MC-39709: Create automated test for: "Display a hidden product image using layered navigation" --- .../_files/product_with_disabled_image.php | 42 +++++++++++++++++++ .../product_with_disabled_image_rollback.php | 11 +++++ .../Magento/Swatches/Helper/DataTest.php | 12 ++++++ 3 files changed, 65 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image.php create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image_rollback.php diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image.php new file mode 100644 index 0000000000000..b182cffee74c5 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image.php @@ -0,0 +1,42 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface; +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Store\Model\Store; +use Magento\TestFramework\Helper\Bootstrap; +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_image.php'); +Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple.php'); + +$objectManager = Bootstrap::getObjectManager(); +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->get(ProductRepositoryInterface::class); +$productRepository->cleanCache(); +$product = $productRepository->get('simple'); +$product->setStoreId(Store::DEFAULT_STORE_ID) + ->setImage('/m/a/magento_image.jpg') + ->setSmallImage('/m/a/magento_image.jpg') + ->setThumbnail('/m/a/magento_image.jpg') + ->setData( + 'media_gallery', + [ + 'images' => [ + [ + ProductAttributeMediaGalleryEntryInterface::FILE => '/m/a/magento_image.jpg', + ProductAttributeMediaGalleryEntryInterface::POSITION => 1, + ProductAttributeMediaGalleryEntryInterface::LABEL => 'Image Alt Text', + ProductAttributeMediaGalleryEntryInterface::DISABLED => 1, + ProductAttributeMediaGalleryEntryInterface::MEDIA_TYPE => 'image', + ], + ], + ] + ) + ->setCanSaveCustomOptions(true); + +$productRepository->save($product); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image_rollback.php new file mode 100644 index 0000000000000..cb67b194fffed --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image_rollback.php @@ -0,0 +1,11 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +use Magento\TestFramework\Workaround\Override\Fixture\Resolver; + +Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_rollback.php'); +Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_image_rollback.php'); diff --git a/dev/tests/integration/testsuite/Magento/Swatches/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Swatches/Helper/DataTest.php index 2e9ea5aba536c..1a9d9c222db9f 100644 --- a/dev/tests/integration/testsuite/Magento/Swatches/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Swatches/Helper/DataTest.php @@ -44,6 +44,7 @@ protected function setUp(): void /** * @magentoDataFixture Magento/Catalog/_files/second_product_simple.php + * * @return void */ public function testGetSwatchAttributesAsArray(): void @@ -51,4 +52,15 @@ public function testGetSwatchAttributesAsArray(): void $product = $this->productRepository->get('simple2'); $this->assertEmpty($this->helper->getSwatchAttributesAsArray($product)); } + + /** + * @magentoDataFixture Magento/Catalog/_files/product_with_disabled_image.php + * + * @return void + */ + public function testGetProductMediaGalleryWithHiddenImage(): void + { + $result = $this->helper->getProductMediaGallery($this->productRepository->get('simple')); + $this->assertEmpty($result); + } } From 85d7d876d08e6af4cb75d6895d803fbaaa63d964 Mon Sep 17 00:00:00 2001 From: Serhii Balko <serhii.balko@transogtgroup.com> Date: Thu, 28 Jan 2021 15:49:12 +0200 Subject: [PATCH 45/68] MC-38625: Storefront Order History product count is doubled if has more than 10 configurables --- app/code/Magento/Sales/Block/Order/Items.php | 83 ++++++++++++++------ 1 file changed, 58 insertions(+), 25 deletions(-) diff --git a/app/code/Magento/Sales/Block/Order/Items.php b/app/code/Magento/Sales/Block/Order/Items.php index 27ba2dca5d152..748378dd252eb 100644 --- a/app/code/Magento/Sales/Block/Order/Items.php +++ b/app/code/Magento/Sales/Block/Order/Items.php @@ -9,18 +9,29 @@ */ namespace Magento\Sales\Block\Order; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\DataObject; +use Magento\Framework\Registry; +use Magento\Framework\View\Element\AbstractBlock; +use Magento\Framework\View\Element\Template\Context; +use Magento\Sales\Block\Items\AbstractItems; +use Magento\Sales\Model\Order; +use Magento\Sales\Model\ResourceModel\Order\Item\Collection; +use Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory; +use Magento\Theme\Block\Html\Pager; + /** * Sales order view items block. * * @api * @since 100.0.2 */ -class Items extends \Magento\Sales\Block\Items\AbstractItems +class Items extends AbstractItems { /** * Core registry * - * @var \Magento\Framework\Registry + * @var Registry */ protected $_coreRegistry = null; @@ -32,30 +43,30 @@ class Items extends \Magento\Sales\Block\Items\AbstractItems private $itemsPerPage; /** - * @var \Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory + * @var CollectionFactory */ private $itemCollectionFactory; /** - * @var \Magento\Sales\Model\ResourceModel\Order\Item\Collection|null + * @var Collection|null */ private $itemCollection; /** - * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Framework\Registry $registry + * @param Context $context + * @param Registry $registry * @param array $data - * @param \Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory|null $itemCollectionFactory + * @param CollectionFactory|null $itemCollectionFactory */ public function __construct( - \Magento\Framework\View\Element\Template\Context $context, - \Magento\Framework\Registry $registry, + Context $context, + Registry $registry, array $data = [], - \Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory $itemCollectionFactory = null + CollectionFactory $itemCollectionFactory = null ) { $this->_coreRegistry = $registry; - $this->itemCollectionFactory = $itemCollectionFactory ?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory::class); + $this->itemCollectionFactory = $itemCollectionFactory ?: ObjectManager::getInstance() + ->get(CollectionFactory::class); parent::__construct($context, $data); } @@ -68,19 +79,12 @@ public function __construct( protected function _prepareLayout() { $this->itemsPerPage = $this->_scopeConfig->getValue('sales/orders/items_per_page'); + $this->itemCollection = $this->createItemsCollection(); - $this->itemCollection = $this->itemCollectionFactory->create(); - $this->itemCollection->setOrderFilter($this->getOrder()); - $this->itemCollection->addFieldToFilter('parent_item_id', ['null' => true]); - - /** @var \Magento\Theme\Block\Html\Pager $pagerBlock */ + /** @var Pager $pagerBlock */ $pagerBlock = $this->getChildBlock('sales_order_item_pager'); if ($pagerBlock) { - $pagerBlock->setLimit($this->itemsPerPage); - //here pager updates collection parameters - $pagerBlock->setCollection($this->itemCollection); - $pagerBlock->setAvailableLimit([$this->itemsPerPage]); - $pagerBlock->setShowAmounts($this->isPagerDisplayed()); + $this->preparePager($pagerBlock); } return parent::_prepareLayout(); @@ -105,7 +109,7 @@ public function isPagerDisplayed() * * To be called from templates(after _prepareLayout()). * - * @return \Magento\Framework\DataObject[] + * @return DataObject[] * @since 100.1.7 */ public function getItems() @@ -123,7 +127,7 @@ public function getItems() */ public function getPagerHtml() { - /** @var \Magento\Theme\Block\Html\Pager $pagerBlock */ + /** @var Pager $pagerBlock */ $pagerBlock = $this->getChildBlock('sales_order_item_pager'); return $pagerBlock ? $pagerBlock->toHtml() : ''; } @@ -131,10 +135,39 @@ public function getPagerHtml() /** * Retrieve current order model instance * - * @return \Magento\Sales\Model\Order + * @return Order */ public function getOrder() { return $this->_coreRegistry->registry('current_order'); } + + /** + * Prepare pager block + * + * @param AbstractBlock $pagerBlock + */ + private function preparePager(AbstractBlock $pagerBlock): void + { + $collectionToPager = $this->createItemsCollection(); + $collectionToPager->addFieldToFilter('parent_item_id', ['null' => true]); + $pagerBlock->setCollection($collectionToPager); + + $pagerBlock->setLimit($this->itemsPerPage); + $pagerBlock->setAvailableLimit([$this->itemsPerPage]); + $pagerBlock->setShowAmounts($this->isPagerDisplayed()); + } + + /** + * Create items collection + * + * @return Collection + */ + private function createItemsCollection(): Collection + { + $collection = $this->itemCollectionFactory->create(); + $collection->setOrderFilter($this->getOrder()); + + return $collection; + } } From 442e7e787038343e0e9b39c0f316aeeab5fc5906 Mon Sep 17 00:00:00 2001 From: Yurii Sapiha <yurasapiga93@gmail.com> Date: Thu, 28 Jan 2021 18:38:07 +0200 Subject: [PATCH 46/68] MC-39709: Create automated test for: "Display a hidden product image using layered navigation" --- .../_files/product_with_disabled_image.php | 34 +++++++++++++++---- .../product_with_disabled_image_rollback.php | 23 ++++++++++++- .../Magento/Swatches/Helper/DataTest.php | 2 +- 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image.php index b182cffee74c5..00f96f7a285ca 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image.php @@ -6,20 +6,42 @@ declare(strict_types=1); use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface; +use Magento\Catalog\Api\Data\ProductInterfaceFactory; use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Catalog\Model\Product\Attribute\Source\Status; +use Magento\Catalog\Model\Product\Type; +use Magento\Catalog\Model\Product\Visibility; +use Magento\Catalog\Model\ResourceModel\Product as ProductResource; +use Magento\Store\Api\WebsiteRepositoryInterface; use Magento\Store\Model\Store; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\Workaround\Override\Fixture\Resolver; Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_image.php'); -Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple.php'); $objectManager = Bootstrap::getObjectManager(); +/** @var ProductResource $productResource */ +$productResource = $objectManager->get(ProductResource::class); +/** @var ProductInterfaceFactory $productFactory */ +$productFactory = $objectManager->get(ProductInterfaceFactory::class); +/** @var WebsiteRepositoryInterface $websiteRepository */ +$websiteRepository = $objectManager->get(WebsiteRepositoryInterface::class); +$baseWebsiteId = (int)$websiteRepository->get('base')->getId(); +$product = $productFactory->create(); /** @var ProductRepositoryInterface $productRepository */ -$productRepository = $objectManager->get(ProductRepositoryInterface::class); -$productRepository->cleanCache(); -$product = $productRepository->get('simple'); -$product->setStoreId(Store::DEFAULT_STORE_ID) +$product->setTypeId(Type::TYPE_SIMPLE) + ->setAttributeSetId($product->getDefaultAttributeSetId()) + ->setWebsiteIds([$baseWebsiteId]) + ->setName('Simple Product2') + ->setSku('simple_with_disabled_img') + ->setPrice(10) + ->setMetaTitle('meta title2') + ->setMetaKeyword('meta keyword2') + ->setMetaDescription('meta description2') + ->setVisibility(Visibility::VISIBILITY_BOTH) + ->setStatus(Status::STATUS_ENABLED) + ->setStockData(['use_config_manage_stock' => 0]) + ->setStoreId(Store::DEFAULT_STORE_ID) ->setImage('/m/a/magento_image.jpg') ->setSmallImage('/m/a/magento_image.jpg') ->setThumbnail('/m/a/magento_image.jpg') @@ -39,4 +61,4 @@ ) ->setCanSaveCustomOptions(true); -$productRepository->save($product); +$productResource->save($product); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image_rollback.php index cb67b194fffed..a6d78e7ffb40f 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image_rollback.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image_rollback.php @@ -5,7 +5,28 @@ */ declare(strict_types=1); +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Registry; +use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\Workaround\Override\Fixture\Resolver; -Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_simple_rollback.php'); +$objectManager = Bootstrap::getObjectManager(); +/** @var ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->get(ProductRepositoryInterface::class); +/** @var Registry $registry */ +$registry = $objectManager->get(Registry::class); + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +try { + $productRepository->deleteById('simple_with_disabled_img'); +} catch (NoSuchEntityException $e) { + //already deleted +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); + Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_image_rollback.php'); diff --git a/dev/tests/integration/testsuite/Magento/Swatches/Helper/DataTest.php b/dev/tests/integration/testsuite/Magento/Swatches/Helper/DataTest.php index 1a9d9c222db9f..c91155ce15fa5 100644 --- a/dev/tests/integration/testsuite/Magento/Swatches/Helper/DataTest.php +++ b/dev/tests/integration/testsuite/Magento/Swatches/Helper/DataTest.php @@ -60,7 +60,7 @@ public function testGetSwatchAttributesAsArray(): void */ public function testGetProductMediaGalleryWithHiddenImage(): void { - $result = $this->helper->getProductMediaGallery($this->productRepository->get('simple')); + $result = $this->helper->getProductMediaGallery($this->productRepository->get('simple_with_disabled_img')); $this->assertEmpty($result); } } From 097e25569010f0f981530f57d40d9b2d5403f882 Mon Sep 17 00:00:00 2001 From: Yurii Sapiha <yurasapiga93@gmail.com> Date: Fri, 29 Jan 2021 11:56:37 +0200 Subject: [PATCH 47/68] MC-39638: Create automated test for: "Try to add the category without parent category" --- .../Controller/Adminhtml/Category/AddTest.php | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/AddTest.php diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/AddTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/AddTest.php new file mode 100644 index 0000000000000..a076b47678b68 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/AddTest.php @@ -0,0 +1,60 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Controller\Adminhtml\Category; + +use Magento\TestFramework\TestCase\AbstractBackendController; + +/** + * Tests for catalog category Add controller + * + * @see \Magento\Catalog\Controller\Adminhtml\Category\Add + * + * @magentoAppArea adminhtml + */ +class AddTest extends AbstractBackendController +{ + /** + * @var int + */ + const DEFAULT_ROOT_CATEGORY = 2; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->getRequest()->setParams([]); + } + + + /** + * @magentoDbIsolation enabled + * + * @return void + */ + public function testExecuteWithoutParams(): void + { + $this->dispatch('backend/catalog/category/add'); + $this->assertRedirect($this->stringContains('catalog/category/index')); + } + + /** + * @magentoDbIsolation enabled + * + * @return void + */ + public function testExecuteAsAjax(): void + { + $this->getRequest()->setQueryValue('isAjax', true); + $this->getRequest()->setParam('parent', self::DEFAULT_ROOT_CATEGORY); + $this->dispatch('backend/catalog/category/add'); + $this->assertJson($this->getResponse()->getBody()); + } +} From 74942b050c12aee43d1016fafe82f1c696b8f295 Mon Sep 17 00:00:00 2001 From: Yurii Sapiha <yurasapiga93@gmail.com> Date: Fri, 29 Jan 2021 14:44:51 +0200 Subject: [PATCH 48/68] MC-39709: Create automated test for: "Display a hidden product image using layered navigation" --- .../Magento/Catalog/_files/product_with_disabled_image.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image.php index 00f96f7a285ca..fac0144dd1332 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_disabled_image.php @@ -7,7 +7,6 @@ use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface; use Magento\Catalog\Api\Data\ProductInterfaceFactory; -use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Catalog\Model\Product\Attribute\Source\Status; use Magento\Catalog\Model\Product\Type; use Magento\Catalog\Model\Product\Visibility; @@ -28,11 +27,10 @@ $websiteRepository = $objectManager->get(WebsiteRepositoryInterface::class); $baseWebsiteId = (int)$websiteRepository->get('base')->getId(); $product = $productFactory->create(); -/** @var ProductRepositoryInterface $productRepository */ $product->setTypeId(Type::TYPE_SIMPLE) ->setAttributeSetId($product->getDefaultAttributeSetId()) ->setWebsiteIds([$baseWebsiteId]) - ->setName('Simple Product2') + ->setName('Simple product with disabled image') ->setSku('simple_with_disabled_img') ->setPrice(10) ->setMetaTitle('meta title2') From 33834ab0fda9af7f6ed3c90d722d9be99952a1ea Mon Sep 17 00:00:00 2001 From: rostyslav-hymon <rostyslav.hymon@transoftgroup.com> Date: Fri, 29 Jan 2021 16:21:40 +0200 Subject: [PATCH 49/68] MC-39757: Email to reset admin password shows "Your password reset link has expired", when using custom template --- .../email/password_reset_confirmation.html | 4 +- ...plate_reset_password_user_notification.php | 15 ++++++++ .../testsuite/Magento/User/Model/UserTest.php | 37 +++++++++++++++++-- 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Email/Model/_files/email_template_reset_password_user_notification.php diff --git a/app/code/Magento/User/view/adminhtml/email/password_reset_confirmation.html b/app/code/Magento/User/view/adminhtml/email/password_reset_confirmation.html index 42240bff3b8db..af4fb6d70e32e 100644 --- a/app/code/Magento/User/view/adminhtml/email/password_reset_confirmation.html +++ b/app/code/Magento/User/view/adminhtml/email/password_reset_confirmation.html @@ -10,7 +10,7 @@ "var user.id":"Account Holder Id", "var user.rp_token":"Reset Password Token", "var user.name":"Account Holder Name", -"store url=\"admin\/auth\/resetpassword\/\" _query_id=$user.id _query_token=$user.rp_token":"Reset Password URL", +"store url=\"admin\/auth\/resetpassword\/\" _query_id=$user.user_id _query_token=$user.rp_token":"Reset Password URL", "var username":"Account Holder Name" } @--> @@ -20,7 +20,7 @@ {{trans "If you requested this change, reset your password here:"}} -{{store url="admin/auth/resetpassword/" _query_id=$user.id _query_token=$user.rp_token _nosid=1}} +{{store url="admin/auth/resetpassword/" _query_id=$user.user_id _query_token=$user.rp_token _nosid=1}} {{trans "If you did not make this request, you can ignore this email and your password will remain the same."}} diff --git a/dev/tests/integration/testsuite/Magento/Email/Model/_files/email_template_reset_password_user_notification.php b/dev/tests/integration/testsuite/Magento/Email/Model/_files/email_template_reset_password_user_notification.php new file mode 100644 index 0000000000000..7b43b6b4b411f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Email/Model/_files/email_template_reset_password_user_notification.php @@ -0,0 +1,15 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); +$origTemplateCode = 'admin_emails_forgot_email_template'; +/** @var \Magento\Email\Model\Template $template */ +$template = $objectManager->create(\Magento\Email\Model\Template::class); +$template->loadDefault($origTemplateCode); +$template->setTemplateCode('Reset Password User Notification Custom Code'); +$template->setOrigTemplateCode('admin_emails_forgot_email_template'); +$template->setId(null); +$template->save(); diff --git a/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php b/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php index e20c4a4b60e62..10413062023d0 100644 --- a/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php +++ b/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php @@ -591,7 +591,9 @@ public function testSendNotificationEmailsIfRequired() ->get(MutableScopeConfigInterface::class); $config->setValue( 'admin/emails/new_user_notification_template', - $this->getCustomEmailTemplateIdForNewUserNotification() + $this->getCustomEmailTemplateIdForNewUserNotification( + 'admin_emails_new_user_notification_template' + ) ); $userModel = Bootstrap::getObjectManager() ->create(User::class); @@ -621,15 +623,15 @@ public function testSendNotificationEmailsIfRequired() /** * Return email template id for new user notification * + * @param string $origTemplateCode * @return int|null * @throws NotFoundException */ - private function getCustomEmailTemplateIdForNewUserNotification(): ?int + private function getCustomEmailTemplateIdForNewUserNotification(string $origTemplateCode): ?int { $templateId = null; $templateCollection = Bootstrap::getObjectManager() ->get(TemplateCollection::class); - $origTemplateCode = 'admin_emails_new_user_notification_template'; foreach ($templateCollection as $template) { if ($template->getOrigTemplateCode() == $origTemplateCode) { $templateId = (int) $template->getId(); @@ -643,4 +645,33 @@ private function getCustomEmailTemplateIdForNewUserNotification(): ?int } return $templateId; } + + /** + * Verify custom notification is correctly when reset admin password + * + * @magentoDataFixture Magento/Email/Model/_files/email_template_reset_password_user_notification.php + * @magentoDataFixture Magento/User/_files/user_with_role.php + */ + public function testNotificationEmailsIfResetPassword() + { + /** @var MutableScopeConfigInterface $config */ + $config = Bootstrap::getObjectManager() + ->get(MutableScopeConfigInterface::class); + $config->setValue( + 'admin/emails/forgot_email_template', + $this->getCustomEmailTemplateIdForNewUserNotification( + 'admin_emails_forgot_email_template' + ) + ); + $userModel = $this->_model->loadByUsername('adminUser'); + $notificator = $this->objectManager->get(\Magento\User\Model\Spi\NotificatorInterface::class); + $notificator->sendForgotPassword($userModel); + /** @var TransportBuilderMock $transportBuilderMock */ + $transportBuilderMock = $this->objectManager->get(TransportBuilderMock::class); + $sentMessage = $transportBuilderMock->getSentMessage(); + $this->assertStringContainsString( + 'id='.$userModel->getId(), + quoted_printable_decode($sentMessage->getBodyText()) + ); + } } From 7dcf01fcf9c48a06718cec4806cb8d68d1e4438d Mon Sep 17 00:00:00 2001 From: Serhii Bohomaz <serhii.bohomaz@transoftgroup.com> Date: Mon, 1 Feb 2021 10:18:20 +0200 Subject: [PATCH 50/68] MC-39714: Create automated test for: "Try to add option with unique validation one more time" --- .../Product/Attribute/CreateOptionsTest.php | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptionsTest.php diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptionsTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptionsTest.php new file mode 100644 index 0000000000000..2d750b289a334 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptionsTest.php @@ -0,0 +1,81 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\ConfigurableProduct\Controller\Adminhtml\Product\Attribute; + +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Framework\App\Request\Http as HttpRequest; +use Magento\Framework\Serialize\SerializerInterface; +use Magento\TestFramework\TestCase\AbstractBackendController; + +/** + * Test for creates options for product attributes. + * + * @see \Magento\ConfigurableProduct\Controller\Adminhtml\Product\Attribute\CreateOptions + * @magentoAppArea adminhtml + * @magentoDbIsolation enabled + */ +class CreateOptionsTest extends AbstractBackendController +{ + /** @var ProductRepositoryInterface */ + private $productRepository; + + /** @var SerializerInterface */ + private $json; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class); + $this->json = $this->_objectManager->get(SerializerInterface::class); + } + + /** + * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php + * + * @return void + */ + public function testAddOptionWithUniqueValidationOneMoreTime(): void + { + $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $this->getRequest()->setParams([ + 'options' => [0 => [ + 'label' => 'Option 1', + 'is_new' => true, + 'attribute_id' => $this->getFirstAttributeId() + ] + ] + ]); + $this->dispatch('backend/catalog/product_attribute/createOptions'); + $responseBody = $this->json->unserialize($this->getResponse()->getBody()); + $this->assertNotEmpty($responseBody['message']); + $this->assertStringContainsString( + (string)__('The value of attribute ""test_configurable"" must be unique'), + $responseBody['message'] + ); + } + + /** + * Get first attribute id + * + * @return int + */ + private function getFirstAttributeId(): int + { + $configurableProduct = $this->productRepository->get('configurable'); + $options = $configurableProduct->getExtensionAttributes()->getConfigurableProductOptions(); + foreach ($options as $option) { + $attributeIds[] = $option->getAttributeId(); + } + + return (int)array_shift($attributeIds); + } +} From 9cc436f1723c643e676ec73d9bd2c6f97424806e Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi <tsviklinskyi@gmail.com> Date: Mon, 1 Feb 2021 11:09:36 +0200 Subject: [PATCH 51/68] MC-40657: "Terms and Condition" validation message shows when we switching payment method. --- .../Model/Checkout/Plugin/Validation.php | 24 ----------- .../Model/Checkout/Plugin/ValidationTest.php | 42 +------------------ 2 files changed, 2 insertions(+), 64 deletions(-) diff --git a/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php b/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php index 5338a16004a00..ceb0240af1dfd 100644 --- a/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php +++ b/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php @@ -86,30 +86,6 @@ public function beforeSavePaymentInformationAndPlaceOrder( } } - /** - * Check validation before saving the payment information - * - * @param \Magento\Checkout\Api\PaymentInformationManagementInterface $subject - * @param int $cartId - * @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod - * @param \Magento\Quote\Api\Data\AddressInterface|null $billingAddress - * @return void - * @SuppressWarnings(PHPMD.UnusedFormalParameter) - * @throws \Magento\Framework\Exception\NoSuchEntityException - * @throws \Magento\Framework\Exception\CouldNotSaveException - */ - public function beforeSavePaymentInformation( - \Magento\Checkout\Api\PaymentInformationManagementInterface $subject, - $cartId, - \Magento\Quote\Api\Data\PaymentInterface $paymentMethod, - \Magento\Quote\Api\Data\AddressInterface $billingAddress = null - ) { - $quote = $this->quoteRepository->getActive($cartId); - if ($this->isAgreementEnabled() && !$quote->getIsMultiShipping()) { - $this->validateAgreements($paymentMethod); - } - } - /** * Validate agreements base on the payment method * diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php index b7e5127df1f8b..6aa3d62230091 100644 --- a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php +++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php @@ -126,11 +126,9 @@ public function testBeforeSavePaymentInformationAndPlaceOrder() ->willReturn(true); $searchCriteriaMock = $this->createMock(SearchCriteria::class); $this->quoteMock - ->expects($this->once()) ->method('getIsMultiShipping') ->willReturn(false); $this->quoteRepositoryMock - ->expects($this->once()) ->method('getActive') ->with($cartId) ->willReturn($this->quoteMock); @@ -146,7 +144,7 @@ public function testBeforeSavePaymentInformationAndPlaceOrder() $this->paymentMock->expects(static::atLeastOnce()) ->method('getExtensionAttributes') ->willReturn($this->extensionAttributesMock); - $this->model->beforeSavePaymentInformation( + $this->model->beforeSavePaymentInformationAndPlaceOrder( $this->subjectMock, $cartId, $this->paymentMock, @@ -166,11 +164,9 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali ->willReturn(true); $searchCriteriaMock = $this->createMock(SearchCriteria::class); $this->quoteMock - ->expects($this->once()) ->method('getIsMultiShipping') ->willReturn(false); $this->quoteRepositoryMock - ->expects($this->once()) ->method('getActive') ->with($cartId) ->willReturn($this->quoteMock); @@ -186,7 +182,7 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali $this->paymentMock->expects(static::atLeastOnce()) ->method('getExtensionAttributes') ->willReturn($this->extensionAttributesMock); - $this->model->beforeSavePaymentInformation( + $this->model->beforeSavePaymentInformationAndPlaceOrder( $this->subjectMock, $cartId, $this->paymentMock, @@ -198,40 +194,6 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali ); } - public function testBeforeSavePaymentInformation() - { - $cartId = 100; - $agreements = [1, 2, 3]; - $this->scopeConfigMock - ->expects($this->once()) - ->method('isSetFlag') - ->with(AgreementsProvider::PATH_ENABLED, ScopeInterface::SCOPE_STORE) - ->willReturn(true); - $this->quoteMock - ->expects($this->once()) - ->method('getIsMultiShipping') - ->willReturn(false); - $this->quoteRepositoryMock - ->expects($this->once()) - ->method('getActive') - ->with($cartId) - ->willReturn($this->quoteMock); - $searchCriteriaMock = $this->createMock(SearchCriteria::class); - $this->agreementsFilterMock->expects($this->once()) - ->method('buildSearchCriteria') - ->willReturn($searchCriteriaMock); - $this->checkoutAgreementsListMock->expects($this->once()) - ->method('getList') - ->with($searchCriteriaMock) - ->willReturn([1]); - $this->extensionAttributesMock->expects($this->once())->method('getAgreementIds')->willReturn($agreements); - $this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($agreements)->willReturn(true); - $this->paymentMock->expects(static::atLeastOnce()) - ->method('getExtensionAttributes') - ->willReturn($this->extensionAttributesMock); - $this->model->beforeSavePaymentInformation($this->subjectMock, $cartId, $this->paymentMock, $this->addressMock); - } - /** * Build payment extension mock. * From b2e3c302845989ed4e454b90095a73309362649b Mon Sep 17 00:00:00 2001 From: Yurii Sapiha <yurasapiga93@gmail.com> Date: Mon, 1 Feb 2021 11:22:05 +0200 Subject: [PATCH 52/68] MC-39638: Create automated test for: "Try to add the category without parent category" --- .../Controller/Adminhtml/Category/AddTest.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/AddTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/AddTest.php index a076b47678b68..aaa98f1733061 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/AddTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/AddTest.php @@ -7,6 +7,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Category; +use Magento\Catalog\Helper\DefaultCategory; use Magento\TestFramework\TestCase\AbstractBackendController; /** @@ -15,13 +16,14 @@ * @see \Magento\Catalog\Controller\Adminhtml\Category\Add * * @magentoAppArea adminhtml + * @magentoDbIsolation enabled */ class AddTest extends AbstractBackendController { /** - * @var int + * @var DefaultCategory */ - const DEFAULT_ROOT_CATEGORY = 2; + private $defaultCategoryHelper; /** * @inheritdoc @@ -30,13 +32,10 @@ protected function setUp(): void { parent::setUp(); - $this->getRequest()->setParams([]); + $this->defaultCategoryHelper = $this->_objectManager->get(DefaultCategory::class); } - /** - * @magentoDbIsolation enabled - * * @return void */ public function testExecuteWithoutParams(): void @@ -46,14 +45,12 @@ public function testExecuteWithoutParams(): void } /** - * @magentoDbIsolation enabled - * * @return void */ public function testExecuteAsAjax(): void { $this->getRequest()->setQueryValue('isAjax', true); - $this->getRequest()->setParam('parent', self::DEFAULT_ROOT_CATEGORY); + $this->getRequest()->setParam('parent', $this->defaultCategoryHelper->getId()); $this->dispatch('backend/catalog/category/add'); $this->assertJson($this->getResponse()->getBody()); } From 6e6844d8521414292c2a93f7d915eb6a66ff1f94 Mon Sep 17 00:00:00 2001 From: rostyslav-hymon <rostyslav.hymon@transoftgroup.com> Date: Mon, 1 Feb 2021 11:29:19 +0200 Subject: [PATCH 53/68] MC-39757: Email to reset admin password shows "Your password reset link has expired", when using custom template --- .../adminhtml/email/password_reset_confirmation.html | 2 +- .../testsuite/Magento/User/Model/UserTest.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/User/view/adminhtml/email/password_reset_confirmation.html b/app/code/Magento/User/view/adminhtml/email/password_reset_confirmation.html index af4fb6d70e32e..374713cad91d6 100644 --- a/app/code/Magento/User/view/adminhtml/email/password_reset_confirmation.html +++ b/app/code/Magento/User/view/adminhtml/email/password_reset_confirmation.html @@ -7,7 +7,7 @@ <!--@subject {{trans "Password Reset Confirmation for %name" name=$username}} @--> <!--@vars { "var store.frontend_name":"Store Name", -"var user.id":"Account Holder Id", +"var user.user_id":"Account Holder Id", "var user.rp_token":"Reset Password Token", "var user.name":"Account Holder Name", "store url=\"admin\/auth\/resetpassword\/\" _query_id=$user.user_id _query_token=$user.rp_token":"Reset Password URL", diff --git a/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php b/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php index 10413062023d0..9380e3ccbabdc 100644 --- a/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php +++ b/dev/tests/integration/testsuite/Magento/User/Model/UserTest.php @@ -591,7 +591,7 @@ public function testSendNotificationEmailsIfRequired() ->get(MutableScopeConfigInterface::class); $config->setValue( 'admin/emails/new_user_notification_template', - $this->getCustomEmailTemplateIdForNewUserNotification( + $this->getCustomEmailTemplateId( 'admin_emails_new_user_notification_template' ) ); @@ -621,17 +621,17 @@ public function testSendNotificationEmailsIfRequired() } /** - * Return email template id for new user notification + * Return email template id by origin template code * * @param string $origTemplateCode * @return int|null * @throws NotFoundException */ - private function getCustomEmailTemplateIdForNewUserNotification(string $origTemplateCode): ?int + private function getCustomEmailTemplateId(string $origTemplateCode): ?int { $templateId = null; $templateCollection = Bootstrap::getObjectManager() - ->get(TemplateCollection::class); + ->create(TemplateCollection::class); foreach ($templateCollection as $template) { if ($template->getOrigTemplateCode() == $origTemplateCode) { $templateId = (int) $template->getId(); @@ -659,7 +659,7 @@ public function testNotificationEmailsIfResetPassword() ->get(MutableScopeConfigInterface::class); $config->setValue( 'admin/emails/forgot_email_template', - $this->getCustomEmailTemplateIdForNewUserNotification( + $this->getCustomEmailTemplateId( 'admin_emails_forgot_email_template' ) ); From 3cb72cbd308eaa645eee3a159b5c9b346641db73 Mon Sep 17 00:00:00 2001 From: Yurii Sapiha <yurasapiga93@gmail.com> Date: Mon, 1 Feb 2021 12:17:34 +0200 Subject: [PATCH 54/68] MC-39552: Create product, add cross-sell product to it and save, after, add one more cross-sell product --- .../AbstractRelationsDataProviderTest.php | 125 ++++++++++++++++++ .../Related/CrossSellDataProviderTest.php | 53 ++++++++ .../Related/UpSellDataProviderTest.php | 101 +------------- 3 files changed, 180 insertions(+), 99 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/AbstractRelationsDataProviderTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/CrossSellDataProviderTest.php diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/AbstractRelationsDataProviderTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/AbstractRelationsDataProviderTest.php new file mode 100644 index 0000000000000..371110b63f40d --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/AbstractRelationsDataProviderTest.php @@ -0,0 +1,125 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Ui\DataProvider\Product\Related; + +use Magento\Catalog\Api\ProductRepositoryInterface; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\View\Element\UiComponentFactory; +use Magento\Framework\View\Element\UiComponentInterface; +use Magento\Store\Model\StoreManagerInterface; +use PHPUnit\Framework\TestCase; +use Magento\TestFramework\Helper\Bootstrap; + +/** + * Base logic for relations data providers checks + */ +abstract class AbstractRelationsDataProviderTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var UiComponentFactory */ + private $componentFactory; + + /** @var RequestInterface */ + private $request; + + /** @var ProductRepositoryInterface */ + private $productRepository; + + /** @var StoreManagerInterface */ + private $storeManager; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->request = $this->objectManager->get(RequestInterface::class); + $this->componentFactory = $this->objectManager->get(UiComponentFactory::class); + $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class); + $this->storeManager = $this->objectManager->get(StoreManagerInterface::class); + } + + /** + * Assert grid result data + * + * @param $expectedCount + * @param array $expectedData + * @param array $actualResult + * @return void + */ + protected function assertResult($expectedCount, array $expectedData, array $actualResult): void + { + $this->assertCount($expectedCount, $actualResult); + $item = reset($actualResult); + foreach ($expectedData as $key => $data) { + $this->assertEquals($item[$key], $data); + } + } + + /** + * Get component provided data + * + * @param string $namespace + * @return array + */ + protected function getComponentProvidedData(string $namespace): array + { + $component = $this->componentFactory->create($namespace); + $this->prepareChildComponents($component); + + return $component->getContext()->getDataProvider()->getData(); + } + + /** + * Prepare request + * + * @param string $productSku + * @param string $relatedProductSku + * @param string $storeCode + * @return void + */ + protected function prepareRequest(string $productSku, string $relatedProductSku, string $storeCode): void + { + $storeId = (int)$this->storeManager->getStore($storeCode)->getId(); + $productId = (int)$this->productRepository->get($productSku)->getId(); + $relatedProductId = (int)$this->productRepository->get($relatedProductSku)->getId(); + $params = [ + 'current_product_id' => $productId, + 'current_store_id' => $storeId, + 'filters_modifier' => [ + 'entity_id' => [ + 'condition_type' => 'nin', + 'value' => [$relatedProductId], + ], + ], + ]; + + $this->request->setParams($params); + } + + /** + * Call prepare method in the child components + * + * @param UiComponentInterface $component + * @return void + */ + private function prepareChildComponents(UiComponentInterface $component): void + { + foreach ($component->getChildComponents() as $child) { + $this->prepareChildComponents($child); + } + + $component->prepare(); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/CrossSellDataProviderTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/CrossSellDataProviderTest.php new file mode 100644 index 0000000000000..43662b6bb15f2 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/CrossSellDataProviderTest.php @@ -0,0 +1,53 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Ui\DataProvider\Product\Related; + +/** + * Checks cross-sell products data provider + * + * @see \Magento\Catalog\Ui\DataProvider\Product\Related\CrossSellDataProvider + * + * @magentoAppArea adminhtml + * @magentoDbIsolation disabled + */ +class CrossSellDataProviderTest extends AbstractRelationsDataProviderTest +{ + /** + * @dataProvider productDataProvider + * + * @magentoDataFixture Magento/Catalog/_files/products_crosssell.php + * @magentoDataFixture Magento/Catalog/_files/product_with_price_on_second_website.php + * + * @param string $storeCode + * @param float $price + * @return void + */ + public function testGetData(string $storeCode, float $price): void + { + $this->prepareRequest('simple_with_cross', 'simple', $storeCode); + $result = $this->getComponentProvidedData('crosssell_product_listing')['items']; + $this->assertResult(1, ['sku' => 'second-website-price-product', 'price' => $price], $result); + } + + /** + * @return array + */ + public function productDataProvider(): array + { + return [ + 'without_store_code' => [ + 'store_code' => 'default', + 'product_price' => 20, + ], + 'with_store_code' => [ + 'store_code' => 'fixture_second_store', + 'product_price' => 10, + ], + ]; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/UpSellDataProviderTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/UpSellDataProviderTest.php index a256b0bbee08a..268ae8becccf1 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/UpSellDataProviderTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/UpSellDataProviderTest.php @@ -7,15 +7,6 @@ namespace Magento\Catalog\Ui\DataProvider\Product\Related; -use Magento\Catalog\Api\ProductRepositoryInterface; -use Magento\Framework\App\RequestInterface; -use Magento\Framework\ObjectManagerInterface; -use Magento\Framework\View\Element\UiComponentFactory; -use Magento\Framework\View\Element\UiComponentInterface; -use Magento\Store\Model\StoreManagerInterface; -use PHPUnit\Framework\TestCase; -use Magento\TestFramework\Helper\Bootstrap; - /** * Checks up-sell products data provider * @@ -24,37 +15,8 @@ * @magentoAppArea adminhtml * @magentoDbIsolation disabled */ -class UpSellDataProviderTest extends TestCase +class UpSellDataProviderTest extends AbstractRelationsDataProviderTest { - /** @var ObjectManagerInterface */ - private $objectManager; - - /** @var UiComponentFactory */ - private $componentFactory; - - /** @var RequestInterface */ - private $request; - - /** @var ProductRepositoryInterface */ - private $productRepository; - - /** @var StoreManagerInterface */ - private $storeManager; - - /** - * @inheritdoc - */ - protected function setUp(): void - { - parent::setUp(); - - $this->objectManager = Bootstrap::getObjectManager(); - $this->request = $this->objectManager->get(RequestInterface::class); - $this->componentFactory = $this->objectManager->get(UiComponentFactory::class); - $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class); - $this->storeManager = $this->objectManager->get(StoreManagerInterface::class); - } - /** * @dataProvider productDataProvider * @@ -69,10 +31,7 @@ public function testGetData(string $storeCode, float $price): void { $this->prepareRequest('simple_with_upsell', 'simple', $storeCode); $result = $this->getComponentProvidedData('upsell_product_listing')['items']; - $this->assertCount(1, $result); - $item = reset($result); - $this->assertEquals($item['sku'], 'second-website-price-product'); - $this->assertEquals($price, (float)$item['price']); + $this->assertResult(1, ['sku' => 'second-website-price-product', 'price' => $price], $result); } /** @@ -91,60 +50,4 @@ public function productDataProvider(): array ], ]; } - - /** - * Get component provided data - * - * @param string $namespace - * @return array - */ - private function getComponentProvidedData(string $namespace): array - { - $component = $this->componentFactory->create($namespace); - $this->prepareChildComponents($component); - - return $component->getContext()->getDataProvider()->getData(); - } - - /** - * Call prepare method in the child components - * - * @param UiComponentInterface $component - * @return void - */ - private function prepareChildComponents(UiComponentInterface $component): void - { - foreach ($component->getChildComponents() as $child) { - $this->prepareChildComponents($child); - } - - $component->prepare(); - } - - /** - * Prepare request - * - * @param string $productSku - * @param string $relatedProductSku - * @param string $storeCode - * @return void - */ - private function prepareRequest(string $productSku, string $relatedProductSku, string $storeCode): void - { - $storeId = (int)$this->storeManager->getStore($storeCode)->getId(); - $productId = (int)$this->productRepository->get($productSku)->getId(); - $relatedProductId = (int)$this->productRepository->get($relatedProductSku)->getId(); - $params = [ - 'current_product_id' => $productId, - 'current_store_id' => $storeId, - 'filters_modifier' => [ - 'entity_id' => [ - 'condition_type' => 'nin', - 'value' => [$relatedProductId], - ], - ], - ]; - - $this->request->setParams($params); - } } From 86da4c859c7d08a12103d45594d09ccd08c16b96 Mon Sep 17 00:00:00 2001 From: Serhii Balko <serhii.balko@transogtgroup.com> Date: Mon, 1 Feb 2021 13:09:53 +0200 Subject: [PATCH 55/68] MC-38625: Storefront Order History product count is doubled if has more than 10 configurables --- app/code/Magento/Sales/Block/Order/Items.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Block/Order/Items.php b/app/code/Magento/Sales/Block/Order/Items.php index 748378dd252eb..be3f9ce14c98d 100644 --- a/app/code/Magento/Sales/Block/Order/Items.php +++ b/app/code/Magento/Sales/Block/Order/Items.php @@ -10,7 +10,6 @@ namespace Magento\Sales\Block\Order; use Magento\Framework\App\ObjectManager; -use Magento\Framework\DataObject; use Magento\Framework\Registry; use Magento\Framework\View\Element\AbstractBlock; use Magento\Framework\View\Element\Template\Context; @@ -109,7 +108,7 @@ public function isPagerDisplayed() * * To be called from templates(after _prepareLayout()). * - * @return DataObject[] + * @return \Magento\Framework\DataObject[] * @since 100.1.7 */ public function getItems() From d833b623f0c394f55496020450875aaa6ac153e6 Mon Sep 17 00:00:00 2001 From: Serhii Balko <serhii.balko@transogtgroup.com> Date: Mon, 1 Feb 2021 14:03:17 +0200 Subject: [PATCH 56/68] MC-38625: Storefront Order History product count is doubled if has more than 10 configurables --- .../Magento/Sales/Block/Order/ItemsTest.php | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/ItemsTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/ItemsTest.php index d4db5f1dd96f1..f1b6ca9c09b34 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Block/Order/ItemsTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Order/ItemsTest.php @@ -86,12 +86,15 @@ public function testGetOrderItems(): void * * @return void */ - public function testGetOrderItemsConfigurable(): void + public function testGetPagerCountConfigurable(): void { $order = $this->orderFactory->create()->loadByIncrementId('100000001'); $this->registerOrder($order); - $this->block = $this->layout->createBlock(Items::class); - $this->assertCount(1, $this->block->getItems()); + $this->prepareBlockWithPager(); + + /** @var Pager $pagerBlock */ + $pagerBlock = $this->block->getChildBlock('sales_order_item_pager'); + $this->assertCount(1, $pagerBlock->getCollection()->getItems()); } /** @@ -104,13 +107,7 @@ public function testPagerIsDisplayed(): void { $order = $this->orderFactory->create()->loadByIncrementId('100000001'); $this->registerOrder($order); - $this->block = $this->layout->createBlock(Items::class, 'items_block'); - $this->layout->addBlock( - $this->objectManager->get(Pager::class), - 'sales_order_item_pager', - 'items_block' - ); - $this->block->setLayout($this->layout); + $this->prepareBlockWithPager(); $this->assertTrue($this->block->isPagerDisplayed()); } @@ -123,13 +120,7 @@ public function testPagerIsNotDisplayed(): void { $order = $this->orderFactory->create()->loadByIncrementId('100000001'); $this->registerOrder($order); - $this->block = $this->layout->createBlock(Items::class, 'items_block'); - $this->layout->addBlock( - $this->objectManager->get(Pager::class), - 'sales_order_item_pager', - 'items_block' - ); - $this->block->setLayout($this->layout); + $this->prepareBlockWithPager(); $this->assertFalse($this->block->isPagerDisplayed()); $this->assertEmpty(preg_replace('/\s+/', '', strip_tags($this->block->getPagerHtml()))); } @@ -144,13 +135,7 @@ public function testGetPagerHtml(): void { $order = $this->orderFactory->create()->loadByIncrementId('100000001'); $this->registerOrder($order); - $this->block = $this->layout->createBlock(Items::class, 'items_block'); - $this->layout->addBlock( - $this->objectManager->get(Pager::class), - 'sales_order_item_pager', - 'items_block' - ); - $this->block->setLayout($this->layout); + $this->prepareBlockWithPager(); $this->assertNotEmpty(preg_replace('/\s+/', '', strip_tags($this->block->getPagerHtml()))); $this->assertTrue($this->block->isPagerDisplayed()); } @@ -240,4 +225,18 @@ private function registerOrder(OrderInterface $order): void $this->registry->unregister('current_order'); $this->registry->register('current_order', $order); } + + /** + * Create items block with pager + */ + private function prepareBlockWithPager(): void + { + $this->block = $this->layout->createBlock(Items::class, 'items_block'); + $this->layout->addBlock( + $this->objectManager->get(Pager::class), + 'sales_order_item_pager', + 'items_block' + ); + $this->block->setLayout($this->layout); + } } From d8faece4a20010e21f7ce9b7a33994a5052ebc5d Mon Sep 17 00:00:00 2001 From: Yurii Sapiha <yurasapiga93@gmail.com> Date: Mon, 1 Feb 2021 16:56:33 +0200 Subject: [PATCH 57/68] MC-39552: Create product, add cross-sell product to it and save, after, add one more cross-sell product --- .../Product/Related/AbstractRelationsDataProviderTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/AbstractRelationsDataProviderTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/AbstractRelationsDataProviderTest.php index 371110b63f40d..1254468ada10f 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/AbstractRelationsDataProviderTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Related/AbstractRelationsDataProviderTest.php @@ -53,12 +53,12 @@ protected function setUp(): void /** * Assert grid result data * - * @param $expectedCount + * @param int $expectedCount * @param array $expectedData * @param array $actualResult * @return void */ - protected function assertResult($expectedCount, array $expectedData, array $actualResult): void + protected function assertResult(int $expectedCount, array $expectedData, array $actualResult): void { $this->assertCount($expectedCount, $actualResult); $item = reset($actualResult); From 03fef7e93c5c28a3315d3b8d8abf2f93dbad2dea Mon Sep 17 00:00:00 2001 From: Serhii Bohomaz <serhii.bohomaz@transoftgroup.com> Date: Mon, 1 Feb 2021 17:11:15 +0200 Subject: [PATCH 58/68] MC-39714: Create automated test for: "Try to add option with unique validation one more time" --- .../Product/Attribute/CreateOptionsTest.php | 42 ++++++++----------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptionsTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptionsTest.php index 2d750b289a334..91719a9ec0c85 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptionsTest.php @@ -7,13 +7,14 @@ namespace Magento\ConfigurableProduct\Controller\Adminhtml\Product\Attribute; +use Magento\Catalog\Api\ProductAttributeRepositoryInterface; use Magento\Catalog\Api\ProductRepositoryInterface; use Magento\Framework\App\Request\Http as HttpRequest; use Magento\Framework\Serialize\SerializerInterface; use Magento\TestFramework\TestCase\AbstractBackendController; /** - * Test for creates options for product attributes. + * Cheks creating attribute options process. * * @see \Magento\ConfigurableProduct\Controller\Adminhtml\Product\Attribute\CreateOptions * @magentoAppArea adminhtml @@ -27,6 +28,9 @@ class CreateOptionsTest extends AbstractBackendController /** @var SerializerInterface */ private $json; + /** @var ProductAttributeRepositoryInterface */ + private $attributeRepository; + /** * @inheritdoc */ @@ -35,7 +39,9 @@ protected function setUp(): void parent::setUp(); $this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class); + $this->productRepository->cleanCache(); $this->json = $this->_objectManager->get(SerializerInterface::class); + $this->attributeRepository = $this->_objectManager->get(ProductAttributeRepositoryInterface::class); } /** @@ -43,39 +49,25 @@ protected function setUp(): void * * @return void */ - public function testAddOptionWithUniqueValidationOneMoreTime(): void + public function testAddAlreadyAddedOption(): void { $this->getRequest()->setMethod(HttpRequest::METHOD_POST); + $attr = $this->attributeRepository->get('test_configurable'); $this->getRequest()->setParams([ - 'options' => [0 => [ + 'options' => [ + [ 'label' => 'Option 1', 'is_new' => true, - 'attribute_id' => $this->getFirstAttributeId() - ] - ] - ]); + 'attribute_id' => (int)$attr->getAttributeId(), + ], + ], + ]); $this->dispatch('backend/catalog/product_attribute/createOptions'); $responseBody = $this->json->unserialize($this->getResponse()->getBody()); - $this->assertNotEmpty($responseBody['message']); + $this->assertNotEmpty($responseBody); $this->assertStringContainsString( - (string)__('The value of attribute ""test_configurable"" must be unique'), + (string)__('The value of attribute ""%1"" must be unique', $attr->getAttributeCode()), $responseBody['message'] ); } - - /** - * Get first attribute id - * - * @return int - */ - private function getFirstAttributeId(): int - { - $configurableProduct = $this->productRepository->get('configurable'); - $options = $configurableProduct->getExtensionAttributes()->getConfigurableProductOptions(); - foreach ($options as $option) { - $attributeIds[] = $option->getAttributeId(); - } - - return (int)array_shift($attributeIds); - } } From fe3f411fcc4f79f4f582714842f4909e7fd9f8cf Mon Sep 17 00:00:00 2001 From: Serhii Bohomaz <serhii.bohomaz@transoftgroup.com> Date: Mon, 1 Feb 2021 17:19:05 +0200 Subject: [PATCH 59/68] MC-39714: Create automated test for: "Try to add option with unique validation one more time" --- .../Adminhtml/Product/Attribute/CreateOptionsTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptionsTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptionsTest.php index 91719a9ec0c85..8c6f3b3b5977d 100644 --- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptionsTest.php +++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptionsTest.php @@ -14,7 +14,7 @@ use Magento\TestFramework\TestCase\AbstractBackendController; /** - * Cheks creating attribute options process. + * Checks creating attribute options process. * * @see \Magento\ConfigurableProduct\Controller\Adminhtml\Product\Attribute\CreateOptions * @magentoAppArea adminhtml @@ -52,13 +52,13 @@ protected function setUp(): void public function testAddAlreadyAddedOption(): void { $this->getRequest()->setMethod(HttpRequest::METHOD_POST); - $attr = $this->attributeRepository->get('test_configurable'); + $attribute = $this->attributeRepository->get('test_configurable'); $this->getRequest()->setParams([ 'options' => [ [ 'label' => 'Option 1', 'is_new' => true, - 'attribute_id' => (int)$attr->getAttributeId(), + 'attribute_id' => (int)$attribute->getAttributeId(), ], ], ]); @@ -66,7 +66,7 @@ public function testAddAlreadyAddedOption(): void $responseBody = $this->json->unserialize($this->getResponse()->getBody()); $this->assertNotEmpty($responseBody); $this->assertStringContainsString( - (string)__('The value of attribute ""%1"" must be unique', $attr->getAttributeCode()), + (string)__('The value of attribute ""%1"" must be unique', $attribute->getAttributeCode()), $responseBody['message'] ); } From 411be090557368ffb5dc3201c025670a0ce91256 Mon Sep 17 00:00:00 2001 From: Yurii Sapiha <yurasapiga93@gmail.com> Date: Tue, 2 Feb 2021 11:47:38 +0200 Subject: [PATCH 60/68] MC-40044: Create automated test for: "Delete product link by API call" --- .../ProductLinkRepositoryInterfaceTest.php | 162 +++++++++++++----- 1 file changed, 117 insertions(+), 45 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php index 94c2b74e8ea96..7645eb75daa32 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php @@ -4,61 +4,84 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Catalog\Api; +use Magento\Framework\ObjectManagerInterface; +use Magento\Framework\Webapi\Rest\Request; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\TestCase\WebapiAbstract; +/** + * Class ProductLinkRepositoryInterfaceTest + * + * @see \Magento\Catalog\Api\ProductLinkRepository + */ class ProductLinkRepositoryInterfaceTest extends WebapiAbstract { + /** + * @var string + */ const SERVICE_NAME = 'catalogProductLinkRepositoryV1'; + + /** + * @var string + */ const SERVICE_VERSION = 'V1'; + + /** + * @var string + */ const RESOURCE_PATH = '/V1/products/'; /** - * @var \Magento\Framework\ObjectManagerInterface + * @var ObjectManagerInterface */ - protected $objectManager; + private $objectManager; + /** + * @var ProductLinkManagementInterface + */ + private $linkManagement; + + /** + * @inheritdoc + */ protected function setUp(): void { + parent::setUp(); + $this->objectManager = Bootstrap::getObjectManager(); + $this->linkManagement = $this->objectManager->get(ProductLinkManagementInterface::class); } /** * @magentoApiDataFixture Magento/Catalog/_files/products_related_multiple.php - * @magentoAppIsolation enabled + * + * @return void */ - public function testDelete() + public function testDelete(): void { $productSku = 'simple_with_cross'; - $linkedSku = 'simple'; $linkType = 'related'; - $this->_webApiCall( - [ - 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $productSku . '/links/' . $linkType . '/' . $linkedSku, - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_DELETE, - ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'DeleteById', - ], - ], - [ - 'sku' => $productSku, - 'type' => $linkType, - 'linkedProductSku' => $linkedSku - ] - ); - /** @var \Magento\Catalog\Model\ProductLink\Management $linkManagement */ - $linkManagement = $this->objectManager->create(\Magento\Catalog\Api\ProductLinkManagementInterface::class); - $linkedProducts = $linkManagement->getLinkedItemsByType($productSku, $linkType); + $this->deleteApiCall($productSku, $linkType, 'simple'); + $linkedProducts = $this->linkManagement->getLinkedItemsByType($productSku, $linkType); $this->assertCount(1, $linkedProducts); - /** @var \Magento\Catalog\Api\Data\ProductLinkInterface $product */ $product = current($linkedProducts); - $this->assertEquals($product->getLinkedProductSku(), 'simple_with_cross_two'); + $this->assertEquals('simple_with_cross_two', $product->getLinkedProductSku()); + } + + /** + * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php + * + * @return void + */ + public function testDeleteNotExistedProductLink(): void + { + $this->expectException(\Exception::class); + $this->expectExceptionMessage((string)__("Product %1 doesn't have linked %2 as %3")); + $this->deleteApiCall('simple', 'related', 'not_exists_product'); } /** @@ -68,36 +91,85 @@ public function testSave() { $productSku = 'simple_with_cross'; $linkType = 'related'; + $data = [ + 'entity' => [ + 'sku' => 'simple_with_cross', + 'link_type' => 'related', + 'linked_product_sku' => 'simple', + 'linked_product_type' => 'simple', + 'position' => 1000, + ], + ]; + $this->saveApiCall($productSku, $data); + $actual = $this->linkManagement->getLinkedItemsByType($productSku, $linkType); + $this->assertCount(1, $actual, 'Invalid actual linked products count'); + $this->assertEquals(1000, $actual[0]->getPosition(), 'Product position is not updated'); + } - $serviceInfo = [ + /** + * Get service info for api call + * + * @param string $resourcePath + * @param string $httpMethod + * @param string $operation + * @return array + */ + private function getServiceInfo(string $resourcePath, string $httpMethod, string $operation): array + { + return [ 'rest' => [ - 'resourcePath' => self::RESOURCE_PATH . $productSku . '/links', - 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, + 'resourcePath' => self::RESOURCE_PATH . $resourcePath, + 'httpMethod' => $httpMethod, ], 'soap' => [ 'service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, - 'operation' => self::SERVICE_NAME . 'Save', + 'operation' => self::SERVICE_NAME . $operation, ], ]; + } - $this->_webApiCall( + /** + * Make api call to delete product link + * + * @param string $productSku + * @param string $linkType + * @param string $linkedSku + * @return array|int|string|float|bool + */ + private function deleteApiCall(string $productSku, string $linkType, string $linkedSku) + { + $serviceInfo = $this->getServiceInfo( + $productSku . '/links/' . $linkType . '/' . $linkedSku, + Request::HTTP_METHOD_DELETE, + 'DeleteById' + ); + + return $this->_webApiCall( $serviceInfo, [ - 'entity' => [ - 'sku' => 'simple_with_cross', - 'link_type' => 'related', - 'linked_product_sku' => 'simple', - 'linked_product_type' => 'simple', - 'position' => 1000, - ] + 'sku' => $productSku, + 'type' => $linkType, + 'linkedProductSku' => $linkedSku, ] ); + } - /** @var \Magento\Catalog\Model\ProductLink\Management $linkManagement */ - $linkManagement = $this->objectManager->get(\Magento\Catalog\Api\ProductLinkManagementInterface::class); - $actual = $linkManagement->getLinkedItemsByType($productSku, $linkType); - $this->assertCount(1, $actual, 'Invalid actual linked products count'); - $this->assertEquals(1000, $actual[0]->getPosition(), 'Product position is not updated'); + /** + * Make api call to save product link + * + * @param $productSku + * @param $data + * @return array|bool|float|int|string + */ + private function saveApiCall($productSku, $data) + { + $serviceInfo = $this->getServiceInfo( + $productSku . '/links', + Request::HTTP_METHOD_PUT, + 'Save' + ); + + return $this->_webApiCall($serviceInfo, $data); } } From 488c507b890a01251112fbdc13be8fde568b2013 Mon Sep 17 00:00:00 2001 From: Yurii Sapiha <yurasapiga93@gmail.com> Date: Tue, 2 Feb 2021 15:27:22 +0200 Subject: [PATCH 61/68] MC-40044: Create automated test for: "Delete product link by API call" --- .../ProductLinkRepositoryInterfaceTest.php | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php index 7645eb75daa32..b10018aa07332 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductLinkRepositoryInterfaceTest.php @@ -8,15 +8,16 @@ namespace Magento\Catalog\Api; +use Magento\Catalog\Model\ProductLink\Link; use Magento\Framework\ObjectManagerInterface; use Magento\Framework\Webapi\Rest\Request; use Magento\TestFramework\Helper\Bootstrap; use Magento\TestFramework\TestCase\WebapiAbstract; /** - * Class ProductLinkRepositoryInterfaceTest + * Class checks product relations functionality * - * @see \Magento\Catalog\Api\ProductLinkRepository + * @see \Magento\Catalog\Api\ProductLinkRepositoryInterface */ class ProductLinkRepositoryInterfaceTest extends WebapiAbstract { @@ -86,18 +87,20 @@ public function testDeleteNotExistedProductLink(): void /** * @magentoApiDataFixture Magento/Catalog/_files/products_related.php + * + * @return void */ - public function testSave() + public function testSave(): void { $productSku = 'simple_with_cross'; $linkType = 'related'; $data = [ 'entity' => [ - 'sku' => 'simple_with_cross', - 'link_type' => 'related', - 'linked_product_sku' => 'simple', - 'linked_product_type' => 'simple', - 'position' => 1000, + Link::KEY_SKU => 'simple_with_cross', + Link::KEY_LINK_TYPE => 'related', + Link::KEY_LINKED_PRODUCT_SKU => 'simple', + Link::KEY_LINKED_PRODUCT_TYPE => 'simple', + Link::KEY_POSITION => 1000, ], ]; $this->saveApiCall($productSku, $data); @@ -158,11 +161,11 @@ private function deleteApiCall(string $productSku, string $linkType, string $lin /** * Make api call to save product link * - * @param $productSku - * @param $data + * @param string $productSku + * @param array $data * @return array|bool|float|int|string */ - private function saveApiCall($productSku, $data) + private function saveApiCall(string $productSku, array $data) { $serviceInfo = $this->getServiceInfo( $productSku . '/links', From d6cb1c3b050a2f6e11eb56e5470d23d125c132de Mon Sep 17 00:00:00 2001 From: engcom-Kilo <grp-engcom-vendorworker-Kilo@adobe.com> Date: Tue, 26 Jan 2021 17:44:46 +0200 Subject: [PATCH 62/68] MC-40541: Magento 2. Admin Place Order not working as expected. --- ...ateOrderFormShippingAddressActionGroup.xml | 52 +++++++++++++++++++ .../templates/order/create/form/address.phtml | 7 +-- 2 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertAdminCreateOrderFormShippingAddressActionGroup.xml diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertAdminCreateOrderFormShippingAddressActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertAdminCreateOrderFormShippingAddressActionGroup.xml new file mode 100644 index 0000000000000..32cedca015c97 --- /dev/null +++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertAdminCreateOrderFormShippingAddressActionGroup.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * seeInField COPYING.txt for license details. + */ +--> + +<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> + <actionGroup name="AssertAdminCreateOrderFormShippingAddressActionGroup"> + <annotations> + <description>Verify shipping address inputs on admin create order page. Start on admin create new order page.</description> + </annotations> + <arguments> + <argument name="prefix" type="string" defaultValue="{{CustomerAddressSimple.prefix}}"/> + <argument name="firstname" type="string" defaultValue="{{CustomerAddressSimple.firstname}}"/> + <argument name="middleName" type="string" defaultValue="{{CustomerAddressSimple.middlename}}"/> + <argument name="lastname" type="string" defaultValue="{{CustomerAddressSimple.lastname}}"/> + <argument name="suffix" type="string" defaultValue="{{CustomerAddressSimple.suffix}}"/> + <argument name="company" type="string" defaultValue="{{CustomerAddressSimple.company}}"/> + <argument name="streetLine1" type="string" defaultValue="{{CustomerAddressSimple.street[0]}}"/> + <argument name="streetLine2" type="string" defaultValue="{{CustomerAddressSimple.street[1]}}"/> + <argument name="city" type="string" defaultValue="{{CustomerAddressSimple.city}}"/> + <argument name="countryId" type="string" defaultValue="{{CustomerAddressSimple.country_id}}"/> + <argument name="state" type="string" defaultValue="{{CustomerAddressSimple.state}}"/> + <argument name="province" type="string" defaultValue=""/> + <argument name="postcode" type="string" defaultValue="{{CustomerAddressSimple.postcode}}"/> + <argument name="telephone" type="string" defaultValue="{{CustomerAddressSimple.telephone}}"/> + <argument name="fax" type="string" defaultValue="{{CustomerAddressSimple.fax}}"/> + <argument name="vatNumber" type="string" defaultValue=""/> + </arguments> + + <waitForElementVisible selector="{{AdminOrderFormShippingAddressSection.NamePrefix}}" stepKey="waitForInputVisible"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.NamePrefix}}" userInput="{{prefix}}" stepKey="verifyPrefix"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.FirstName}}" userInput="{{firstname}}" stepKey="verifyFirstName"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.MiddleName}}" userInput="{{middleName}}" stepKey="verifyMiddleName"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.LastName}}" userInput="{{lastname}}" stepKey="verifyLastName"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.NameSuffix}}" userInput="{{suffix}}" stepKey="verifySuffix"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.Company}}" userInput="{{company}}" stepKey="verifyCompany"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.StreetLine1}}" userInput="{{streetLine1}}" stepKey="verifyStreetLine1"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.StreetLine2}}" userInput="{{streetLine2}}" stepKey="verifyStreetLine2"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.City}}" userInput="{{city}}" stepKey="verifyCity"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.Country}}" userInput="{{countryId}}" stepKey="verifyCountry"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.State}}" userInput="{{state}}" stepKey="verifyState"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.Province}}" userInput="{{province}}" stepKey="verifyProvince"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.PostalCode}}" userInput="{{postcode}}" stepKey="verifyPostalCode"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.Phone}}" userInput="{{telephone}}" stepKey="verifyPhone"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.Fax}}" userInput="{{fax}}" stepKey="verifyFax"/> + <seeInField selector="{{AdminOrderFormShippingAddressSection.VatNumber}}" userInput="{{vatNumber}}" stepKey="verifyVatNumber"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml index 638ac7e66f769..79bc1e3a8df36 100644 --- a/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml +++ b/app/code/Magento/Sales/view/adminhtml/templates/order/create/form/address.phtml @@ -142,9 +142,10 @@ endif; ?> order.bindAddressFields('{$block->escapeJs($_addressChoiceContainerId)}'); script; - if ($block->getIsShipping() && $block->getIsAsBilling()): - $scriptString .= <<<script - order.disableShippingAddress(true); + if ($block->getIsShipping()): + $disable = $block->getIsAsBilling() ? 'true' : 'false'; + $scriptString .= <<<script + order.disableShippingAddress({$disable}); script; endif; From cd8cead8f3ac96ce87d6be6e33e5a0dd0182098d Mon Sep 17 00:00:00 2001 From: Serhii Bohomaz <serhii.bohomaz@transoftgroup.com> Date: Wed, 3 Feb 2021 12:40:27 +0200 Subject: [PATCH 63/68] MC-39629: Increase coverage of "Magento/Catalog/Model/Layer/Category/ItemCollectionProvider.php" --- .../Category/ItemCollectionProviderTest.php | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Category/ItemCollectionProviderTest.php diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Category/ItemCollectionProviderTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Category/ItemCollectionProviderTest.php new file mode 100644 index 0000000000000..fb055fac912fd --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Category/ItemCollectionProviderTest.php @@ -0,0 +1,58 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Catalog\Model\Layer\Category; + +use Magento\Catalog\Api\CategoryRepositoryInterface; +use Magento\Framework\ObjectManagerInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +/** + * Test cases item collection provider. + * + * @see \Magento\Catalog\Model\Layer\Category\ItemCollectionProvider + * @magentoAppArea frontend + */ +class ItemCollectionProviderTest extends TestCase +{ + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var CategoryRepositoryInterface */ + private $categoryRepository; + + /** @var ItemCollectionProvider */ + private $itemCollectionProvider; + + /** + * @inheritdoc + */ + protected function setUp(): void + { + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->itemCollectionProvider = $this->objectManager->get(ItemCollectionProvider::class); + $this->categoryRepository = $this->objectManager->get(CategoryRepositoryInterface::class); + } + + /** + * @magentoDbIsolation disabled + * @magentoDataFixture Magento/Catalog/_files/category_product.php + * @magentoDataFixture Magento/Catalog/_files/second_product_simple.php + * + * @return void + */ + public function testGetCollection(): void + { + $category = $this->categoryRepository->get(333); + $collectionProduct = $this->itemCollectionProvider->getCollection($category); + $this->assertEquals('simple333', $collectionProduct->getFirstItem()->getSku()); + $this->assertCount(1, $collectionProduct->getItems()); + } +} From 3f934a8088072478c5ff11d331dba3b1e622c707 Mon Sep 17 00:00:00 2001 From: Roman Zhupanyn <roma.dj.elf@gmail.com> Date: Wed, 3 Feb 2021 13:02:46 +0200 Subject: [PATCH 64/68] MC-39626: Create automated test for: "Apply price filter with interval on layered navigation on category page" --- .../Layer/Filter/DataProvider/PriceTest.php | 131 ++++++++++++++---- 1 file changed, 105 insertions(+), 26 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/DataProvider/PriceTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/DataProvider/PriceTest.php index f7444ca1caaae..9010d2b3b092f 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/DataProvider/PriceTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/DataProvider/PriceTest.php @@ -3,32 +3,48 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); namespace Magento\Catalog\Model\Layer\Filter\DataProvider; +use Magento\Catalog\Model\Layer\Category; +use Magento\Catalog\Model\Layer\Resolver; +use Magento\Framework\ObjectManagerInterface; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + /** * Test class for \Magento\Catalog\Model\Layer\Filter\DataProvider\Price. - * - * @magentoAppIsolation enabled */ -class PriceTest extends \PHPUnit\Framework\TestCase +class PriceTest extends TestCase { + /** @var ObjectManagerInterface */ + private $objectManager; + + /** @var Price */ + private $model; + + /** @var Resolver */ + private $layerResolver; + + /** @var Category */ + private $layer; + + /** @var PriceFactory */ + private $dataProviderPriceFactory; + /** - * @var \Magento\Catalog\Model\Layer\Filter\DataProvider\Price + * @inheritdoc */ - protected $_model; - protected function setUp(): void { - $category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( - \Magento\Catalog\Model\Category::class - ); - $category->load(4); - $layer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get(\Magento\Catalog\Model\Layer\Category::class); - $layer->setCurrentCategory($category); - $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->create(\Magento\Catalog\Model\Layer\Filter\DataProvider\Price::class, ['layer' => $layer]); + parent::setUp(); + + $this->objectManager = Bootstrap::getObjectManager(); + $this->layerResolver = $this->objectManager->get(Resolver::class); + $this->layer = $this->layerResolver->get(); + $this->dataProviderPriceFactory = $this->objectManager->get(PriceFactory::class); + $this->model = $this->dataProviderPriceFactory->create(['layer' => $this->layer]); } /** @@ -36,10 +52,12 @@ protected function setUp(): void * @magentoAppIsolation enabled * @magentoDbIsolation disabled * @magentoConfigFixture current_store catalog/layered_navigation/price_range_calculation auto + * @return void */ - public function testGetPriceRangeAuto() + public function testGetPriceRangeAuto(): void { - $this->assertEquals(10, $this->_model->getPriceRange()); + $this->layer->setCurrentCategory(4); + $this->assertEquals(10, $this->model->getPriceRange()); } /** @@ -48,45 +66,106 @@ public function testGetPriceRangeAuto() * @magentoDbIsolation disabled * @magentoConfigFixture current_store catalog/layered_navigation/price_range_calculation manual * @magentoConfigFixture current_store catalog/layered_navigation/price_range_step 1.5 + * @return void */ - public function testGetPriceRangeManual() + public function testGetPriceRangeManual(): void { // what you set is what you get - $this->assertEquals(1.5, $this->_model->getPriceRange()); + $this->layer->setCurrentCategory(4); + $this->assertEquals(1.5, $this->model->getPriceRange()); } /** * @magentoDataFixture Magento/Catalog/_files/categories.php * @magentoAppIsolation enabled * @magentoDbIsolation disabled + * @return void */ - public function testGetMaxPriceInt() + public function testGetMaxPriceInt(): void { - $this->assertEquals(45.00, $this->_model->getMaxPrice()); + $this->layer->setCurrentCategory(4); + $this->assertEquals(45.00, $this->model->getMaxPrice()); } /** * @return array */ - public function getRangeItemCountsDataProvider() + public function getRangeItemCountsDataProvider(): array { return [ // These are $inputRange, [$expectedItemCounts] values [1, [11 => 2, 46 => 1, 16 => '1']], [10, [2 => 3, 5 => 1]], [20, [1 => 3, 3 => 1]], - [50, [1 => 4]] + [50, [1 => 4]], ]; } /** + * @dataProvider getRangeItemCountsDataProvider * @magentoDataFixture Magento/Catalog/_files/categories.php + * @magentoAppIsolation enabled * @magentoDbIsolation disabled - * @dataProvider getRangeItemCountsDataProvider + * @param int $inputRange + * @param array $expectedItemCounts + * @return void + */ + public function testGetRangeItemCounts(int $inputRange, array $expectedItemCounts): void + { + $this->layer->setCurrentCategory(4); + $actualItemCounts = $this->model->getRangeItemCounts($inputRange); + $this->assertEquals($expectedItemCounts, $actualItemCounts); + } + + /** + * @magentoConfigFixture current_store catalog/layered_navigation/price_range_max_intervals 3 + * @magentoConfigFixture current_store catalog/layered_navigation/price_range_calculation manual + * @magentoDataFixture Magento/Catalog/_files/products_for_search.php + * @return void */ - public function testGetRangeItemCounts($inputRange, $expectedItemCounts) + public function testGetRangeItemCountsManualCalculation(): void { - $actualItemCounts = $this->_model->getRangeItemCounts($inputRange); + $expectedItemCounts = [11 => '2', 21 => '1', 31 => 2]; + $this->layer->setCurrentCategory(333); + $actualItemCounts = $this->model->getRangeItemCounts(1); $this->assertEquals($expectedItemCounts, $actualItemCounts); } + + /** + * @dataProvider getAdditionalRequestDataDataProvider + * @magentoDataFixture Magento/Catalog/_files/products_for_search.php + * @param array $priceFilters + * @param string $expectedRequest + * @return void + */ + public function testGetAdditionalRequestData(array $priceFilters, string $expectedRequest): void + { + $this->layer->setCurrentCategory(333); + $filter = explode('-', $priceFilters[0]); + $this->model->setInterval($filter); + $priorFilters = $this->model->getPriorFilters($priceFilters); + if ($priorFilters) { + $this->model->setPriorIntervals($priorFilters); + } + + $actualRequest = $this->model->getAdditionalRequestData(); + $this->assertEquals($expectedRequest, $actualRequest); + } + + /** + * @return array + */ + public function getAdditionalRequestDataDataProvider(): array + { + return [ + 'with_prior_filters' => [ + 'price_filters' => ['10-11', '20-21', '30-31'], + 'expected_request' => ',10-11,20-21,30-31', + ], + 'without_prior_filters' => [ + 'price_filters' => ['10-11'], + 'expected_request' => ',10-11', + ], + ]; + } } From 8780f32d2af23d0a71502be549ca6f28dba4c090 Mon Sep 17 00:00:00 2001 From: Roman Zhupanyn <roma.dj.elf@gmail.com> Date: Wed, 3 Feb 2021 17:05:00 +0200 Subject: [PATCH 65/68] MC-39626: Create automated test for: "Apply price filter with interval on layered navigation on category page" --- .../Catalog/Model/Layer/Filter/DataProvider/PriceTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/DataProvider/PriceTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/DataProvider/PriceTest.php index 9010d2b3b092f..db438fb0b2c98 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/DataProvider/PriceTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/DataProvider/PriceTest.php @@ -133,14 +133,12 @@ public function testGetRangeItemCountsManualCalculation(): void /** * @dataProvider getAdditionalRequestDataDataProvider - * @magentoDataFixture Magento/Catalog/_files/products_for_search.php * @param array $priceFilters * @param string $expectedRequest * @return void */ public function testGetAdditionalRequestData(array $priceFilters, string $expectedRequest): void { - $this->layer->setCurrentCategory(333); $filter = explode('-', $priceFilters[0]); $this->model->setInterval($filter); $priorFilters = $this->model->getPriorFilters($priceFilters); @@ -166,6 +164,10 @@ public function getAdditionalRequestDataDataProvider(): array 'price_filters' => ['10-11'], 'expected_request' => ',10-11', ], + 'not_valid_prior_filters' => [ + 'price_filters' => ['10-11', '20-21', '31', '40-41'], + 'expected_request' => ',10-11', + ], ]; } } From 6837b59255febf13420afe2bb961d9deb5cf4c8e Mon Sep 17 00:00:00 2001 From: Roman Zhupanyn <roma.dj.elf@gmail.com> Date: Thu, 4 Feb 2021 11:32:09 +0200 Subject: [PATCH 66/68] MC-39626: Create automated test for: "Apply price filter with interval on layered navigation on category page" --- .../Catalog/Model/Layer/Filter/DataProvider/PriceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/DataProvider/PriceTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/DataProvider/PriceTest.php index db438fb0b2c98..321a8b996c32e 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/DataProvider/PriceTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/DataProvider/PriceTest.php @@ -142,7 +142,7 @@ public function testGetAdditionalRequestData(array $priceFilters, string $expect $filter = explode('-', $priceFilters[0]); $this->model->setInterval($filter); $priorFilters = $this->model->getPriorFilters($priceFilters); - if ($priorFilters) { + if (!empty($priorFilters)) { $this->model->setPriorIntervals($priorFilters); } From 40ac15ee6584dfd5b6a71f9ddfac2022cb02e1e4 Mon Sep 17 00:00:00 2001 From: Serhii Bohomaz <serhii.bohomaz@transoftgroup.com> Date: Thu, 4 Feb 2021 13:34:43 +0200 Subject: [PATCH 67/68] MC-39629: Increase coverage of "Magento/Catalog/Model/Layer/Category/ItemCollectionProvider.php" --- .../Model/Layer/Category/ItemCollectionProviderTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Category/ItemCollectionProviderTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Category/ItemCollectionProviderTest.php index fb055fac912fd..a533c7805a812 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Category/ItemCollectionProviderTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Category/ItemCollectionProviderTest.php @@ -13,7 +13,7 @@ use PHPUnit\Framework\TestCase; /** - * Test cases item collection provider. + * Tests for category collection provider. * * @see \Magento\Catalog\Model\Layer\Category\ItemCollectionProvider * @magentoAppArea frontend @@ -51,8 +51,8 @@ protected function setUp(): void public function testGetCollection(): void { $category = $this->categoryRepository->get(333); - $collectionProduct = $this->itemCollectionProvider->getCollection($category); - $this->assertEquals('simple333', $collectionProduct->getFirstItem()->getSku()); - $this->assertCount(1, $collectionProduct->getItems()); + $categoryProductsCollection = $this->itemCollectionProvider->getCollection($category); + $this->assertCount(1, $categoryProductsCollection); + $this->assertEquals('simple333', $categoryProductsCollection->getFirstItem()->getSku()); } } From a4803ef1eec79862b30b18d86aefd5bd02c06360 Mon Sep 17 00:00:00 2001 From: Myroslav Dobra <dmaraptor@gmail.com> Date: Fri, 5 Feb 2021 17:30:18 +0200 Subject: [PATCH 68/68] MC-38817: [MFTF] fix some ASI tests because of bad design --- .../AdminEnhancedMediaGalleryDeletedAllImagesActionGroup.xml | 2 +- .../Mftf/Section/AdminEnhancedMediaGalleryFiltersSection.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryDeletedAllImagesActionGroup.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryDeletedAllImagesActionGroup.xml index 4aa460327578a..33e9838f2c443 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryDeletedAllImagesActionGroup.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/ActionGroup/AdminEnhancedMediaGalleryDeletedAllImagesActionGroup.xml @@ -12,7 +12,7 @@ <amOnPage url="{{AdminStandaloneMediaGalleryPage.url}}" stepKey="openMediaGalleryPage"/> <!-- It sometimes is loading too long for default 10s --> <waitForPageLoad time="60" stepKey="waitForPageFullyLoaded"/> - <conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clearExistingFilters"/> + <conditionalClick selector="{{AdminEnhancedMediaGalleryFiltersSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clearExistingFilters"/> <helper class="\Magento\MediaGalleryUi\Test\Mftf\Helper\MediaGalleryUiHelper" method="deleteAllImagesUsingMassAction" stepKey="deleteAllImagesUsingMassAction"> <argument name="emptyRow">{{AdminMediaGalleryGridSection.noDataMessage}}</argument> <argument name="deleteImagesButton">{{AdminEnhancedMediaGalleryMassActionSection.deleteImages}}</argument> diff --git a/app/code/Magento/MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryFiltersSection.xml b/app/code/Magento/MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryFiltersSection.xml index da9f773d0f75e..77e42b780df81 100644 --- a/app/code/Magento/MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryFiltersSection.xml +++ b/app/code/Magento/MediaGalleryUi/Test/Mftf/Section/AdminEnhancedMediaGalleryFiltersSection.xml @@ -26,5 +26,6 @@ <element name="searchOptionsFilterDone" type="button" selector="//div[label/span[contains(text(), '{{filterName}}')]]//button[@data-action='close-advanced-select']" parameterized="true"/> <element name="duplicatedFilterCheckbox" type="button" selector="//input[@name='duplicated']"/> <element name="activeFilterValue" type="text" selector="//div[@class='media-gallery-container']//div[@class='admin__current-filters-list-wrap']//li//span[contains(text(), '{{filterPlaceholder}}')]" parameterized="true"/> + <element name="clearFilters" type="button" selector="//div[@class='media-gallery-container']//div[@class='admin__data-grid-header']//button[@data-action='grid-filter-reset']" timeout="30"/> </section> </sections>