From c5ca58cfcec9cff2e99610058757bd8174bc91df Mon Sep 17 00:00:00 2001 From: Antonino Bonumore Date: Fri, 7 Feb 2020 11:24:48 +0100 Subject: [PATCH 01/26] magento#26745 add method setAdditionalInformation to OrderPaymentInterface --- app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php b/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php index ea0cf5d7b32be..ac400206b8a2f 100644 --- a/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php @@ -1042,6 +1042,14 @@ public function setCcNumberEnc($ccNumberEnc); */ public function setCcTransId($id); + /** + * Set the additional information for the order payment. + * + * @param string[] $additionalInformation + * @return $this + */ + public function setAdditionalInformation($additionalInformation); + /** * Sets the address status for the order payment. * From c2a27c36e9884c74825a7a5c6d1205bb3b3c8082 Mon Sep 17 00:00:00 2001 From: Michele Fantetti Date: Sun, 1 Mar 2020 19:55:52 +0100 Subject: [PATCH 02/26] Add Italy States --- .../Setup/Patch/Data/AddDataForItaly.php | 194 ++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 app/code/Magento/Directory/Setup/Patch/Data/AddDataForItaly.php diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForItaly.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForItaly.php new file mode 100644 index 0000000000000..6da0792d0a3e9 --- /dev/null +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForItaly.php @@ -0,0 +1,194 @@ +moduleDataSetup = $moduleDataSetup; + $this->dataInstallerFactory = $dataInstallerFactory; + } + + /** + * @inheritdoc + */ + public function apply() + { + /** @var DataInstaller $dataInstaller */ + $dataInstaller = $this->dataInstallerFactory->create(); + $dataInstaller->addCountryRegions( + $this->moduleDataSetup->getConnection(), + $this->getDataForItaly() + ); + } + + /** + * Italy states data. + * + * @return array + */ + private function getDataForItaly() + { + return [ + ['IT', 'AG', 'Agrigento'], + ['IT', 'AL', 'Alessandria'], + ['IT', 'AN', 'Ancona'], + ['IT', 'AO', 'Aosta'], + ['IT', 'AQ', 'L\'Aquila'], + ['IT', 'AR', 'Arezzo'], + ['IT', 'AP', 'Ascoli-Piceno'], + ['IT', 'AT', 'Asti'], + ['IT', 'AV', 'Avellino'], + ['IT', 'BA', 'Bari'], + ['IT', 'BT', 'Barletta-Andria-Trani'], + ['IT', 'BL', 'Belluno'], + ['IT', 'BN', 'Benevento'], + ['IT', 'BG', 'Bergamo'], + ['IT', 'BI', 'Biella'], + ['IT', 'BO', 'Bologna'], + ['IT', 'BZ', 'Bolzano'], + ['IT', 'BS', 'Brescia'], + ['IT', 'BR', 'Brindisi'], + ['IT', 'CA', 'Cagliari'], + ['IT', 'CL', 'Caltanissetta'], + ['IT', 'CB', 'Campobasso'], + ['IT', 'CI', 'Carbonia Iglesias'], + ['IT', 'CE', 'Caserta'], + ['IT', 'CT', 'Catania'], + ['IT', 'CZ', 'Catanzaro'], + ['IT', 'CH', 'Chieti'], + ['IT', 'CO', 'Como'], + ['IT', 'CS', 'Cosenza'], + ['IT', 'CR', 'Cremona'], + ['IT', 'KR', 'Crotone'], + ['IT', 'CN', 'Cuneo'], + ['IT', 'EN', 'Enna'], + ['IT', 'FM', 'Fermo'], + ['IT', 'FE', 'Ferrara'], + ['IT', 'FI', 'Firenze'], + ['IT', 'FG', 'Foggia'], + ['IT', 'FC', 'Forli-Cesena'], + ['IT', 'FR', 'Frosinone'], + ['IT', 'GE', 'Genova'], + ['IT', 'GO', 'Gorizia'], + ['IT', 'GR', 'Grosseto'], + ['IT', 'IM', 'Imperia'], + ['IT', 'IS', 'Isernia'], + ['IT', 'SP', 'La-Spezia'], + ['IT', 'LT', 'Latina'], + ['IT', 'LE', 'Lecce'], + ['IT', 'LC', 'Lecco'], + ['IT', 'LI', 'Livorno'], + ['IT', 'LO', 'Lodi'], + ['IT', 'LU', 'Lucca'], + ['IT', 'MC', 'Macerata'], + ['IT', 'MN', 'Mantova'], + ['IT', 'MS', 'Massa-Carrara'], + ['IT', 'MT', 'Matera'], + ['IT', 'VS', 'Medio Campidano'], + ['IT', 'ME', 'Messina'], + ['IT', 'MI', 'Milano'], + ['IT', 'MO', 'Modena'], + ['IT', 'MB', 'Monza-Brianza'], + ['IT', 'NA', 'Napoli'], + ['IT', 'NO', 'Novara'], + ['IT', 'NU', 'Nuoro'], + ['IT', 'OG', 'Ogliastra'], + ['IT', 'OT', 'Olbia Tempio'], + ['IT', 'OR', 'Oristano'], + ['IT', 'PD', 'Padova'], + ['IT', 'PA', 'Palermo'], + ['IT', 'PR', 'Parma'], + ['IT', 'PV', 'Pavia'], + ['IT', 'PG', 'Perugia'], + ['IT', 'PU', 'Pesaro-Urbino'], + ['IT', 'PE', 'Pescara'], + ['IT', 'PC', 'Piacenza'], + ['IT', 'PI', 'Pisa'], + ['IT', 'PT', 'Pistoia'], + ['IT', 'PN', 'Pordenone'], + ['IT', 'PZ', 'Potenza'], + ['IT', 'PO', 'Prato'], + ['IT', 'RG', 'Ragusa'], + ['IT', 'RA', 'Ravenna'], + ['IT', 'RC', 'Reggio-Calabria'], + ['IT', 'RE', 'Reggio-Emilia'], + ['IT', 'RI', 'Rieti'], + ['IT', 'RN', 'Rimini'], + ['IT', 'RM', 'Roma'], + ['IT', 'RO', 'Rovigo'], + ['IT', 'SA', 'Salerno'], + ['IT', 'SS', 'Sassari'], + ['IT', 'SV', 'Savona'], + ['IT', 'SI', 'Siena'], + ['IT', 'SR', 'Siracusa'], + ['IT', 'SO', 'Sondrio'], + ['IT', 'TA', 'Taranto'], + ['IT', 'TE', 'Teramo'], + ['IT', 'TR', 'Terni'], + ['IT', 'TO', 'Torino'], + ['IT', 'TP', 'Trapani'], + ['IT', 'TN', 'Trento'], + ['IT', 'TV', 'Treviso'], + ['IT', 'TS', 'Trieste'], + ['IT', 'UD', 'Udine'], + ['IT', 'VA', 'Varese'], + ['IT', 'VE', 'Venezia'], + ['IT', 'VB', 'Verbania'], + ['IT', 'VC', 'Vercelli'], + ['IT', 'VR', 'Verona'], + ['IT', 'VV', 'Vibo-Valentia'], + ['IT', 'VI', 'Vicenza'], + ['IT', 'VT', 'Viterbo'], + ]; + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return [ + InitializeDirectoryData::class, + ]; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } +} From 972d382359bbd00286fa1a64ff62fed432db6e5b Mon Sep 17 00:00:00 2001 From: WaPoNe Date: Sun, 1 Mar 2020 20:01:51 +0100 Subject: [PATCH 03/26] Add Italy States --- app/code/Magento/Directory/Setup/Patch/Data/AddDataForItaly.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForItaly.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForItaly.php index 6da0792d0a3e9..44288c9f2a276 100644 --- a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForItaly.php +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForItaly.php @@ -1,7 +1,7 @@ Date: Mon, 9 Mar 2020 17:34:38 +0100 Subject: [PATCH 04/26] DEPRECATED: AbstractAccount for Magento_Customer controllers --- .../Customer/Controller/AbstractAccount.php | 4 ++-- .../Customer/Controller/Plugin/Account.php | 23 ++++++++++++------- app/code/Magento/Customer/etc/frontend/di.xml | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/code/Magento/Customer/Controller/AbstractAccount.php b/app/code/Magento/Customer/Controller/AbstractAccount.php index 21611329ed9bc..aa0eca1423c17 100644 --- a/app/code/Magento/Customer/Controller/AbstractAccount.php +++ b/app/code/Magento/Customer/Controller/AbstractAccount.php @@ -9,9 +9,9 @@ use Magento\Framework\App\Action\Action; /** - * Class AbstractAccount - * @package Magento\Customer\Controller * @SuppressWarnings(PHPMD.NumberOfChildren) + * @deprecated 2.4.0 + * @see \Magento\Customer\Controller\AccountInterface */ abstract class AbstractAccount extends Action implements AccountInterface { diff --git a/app/code/Magento/Customer/Controller/Plugin/Account.php b/app/code/Magento/Customer/Controller/Plugin/Account.php index 179da148e7f78..5fc65eb845563 100644 --- a/app/code/Magento/Customer/Controller/Plugin/Account.php +++ b/app/code/Magento/Customer/Controller/Plugin/Account.php @@ -3,13 +3,15 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Customer\Controller\Plugin; +use Magento\Customer\Controller\AccountInterface; use Magento\Customer\Model\Session; use Magento\Framework\App\ActionInterface; use Magento\Framework\App\RequestInterface; use Magento\Framework\App\ResponseInterface; -use Magento\Framework\App\Action\AbstractAction; use Magento\Framework\Controller\ResultInterface; class Account @@ -23,29 +25,35 @@ class Account * @var array */ private $allowedActions = []; + /** + * @var RequestInterface + */ + private $request; /** + * @param RequestInterface $request * @param Session $customerSession * @param array $allowedActions List of actions that are allowed for not authorized users */ public function __construct( + RequestInterface $request, Session $customerSession, array $allowedActions = [] ) { $this->session = $customerSession; $this->allowedActions = $allowedActions; + $this->request = $request; } /** * Dispatch actions allowed for not authorized users * - * @param AbstractAction $subject - * @param RequestInterface $request + * @param AccountInterface $subject * @return void */ - public function beforeDispatch(AbstractAction $subject, RequestInterface $request) + public function beforeExecute(AccountInterface $subject) { - $action = strtolower($request->getActionName()); + $action = strtolower($this->request->getActionName()); $pattern = '/^(' . implode('|', $this->allowedActions) . ')$/i'; if (!preg_match($pattern, $action)) { @@ -60,13 +68,12 @@ public function beforeDispatch(AbstractAction $subject, RequestInterface $reques /** * Remove No-referer flag from customer session * - * @param AbstractAction $subject + * @param AccountInterface $subject * @param ResponseInterface|ResultInterface $result - * @param RequestInterface $request * @return ResponseInterface|ResultInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function afterDispatch(AbstractAction $subject, $result, RequestInterface $request) + public function afterExecute(AccountInterface $subject, $result) { $this->session->unsNoReferer(false); return $result; diff --git a/app/code/Magento/Customer/etc/frontend/di.xml b/app/code/Magento/Customer/etc/frontend/di.xml index a479d0d2af328..8867042cc6dc9 100644 --- a/app/code/Magento/Customer/etc/frontend/di.xml +++ b/app/code/Magento/Customer/etc/frontend/di.xml @@ -51,7 +51,7 @@ - + From 26aa6bdeba46c180e05941f2592a457537ef83be Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Mon, 9 Mar 2020 18:10:20 +0100 Subject: [PATCH 05/26] Missing PHPDoc to modified files --- .../Magento/Customer/Controller/AbstractAccount.php | 2 ++ .../Magento/Customer/Controller/Plugin/Account.php | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Customer/Controller/AbstractAccount.php b/app/code/Magento/Customer/Controller/AbstractAccount.php index aa0eca1423c17..36a96521cc6d1 100644 --- a/app/code/Magento/Customer/Controller/AbstractAccount.php +++ b/app/code/Magento/Customer/Controller/AbstractAccount.php @@ -9,6 +9,8 @@ use Magento\Framework\App\Action\Action; /** + * AbstractAccount class is deprecated, in favour of Composition approach to build Controllers + * * @SuppressWarnings(PHPMD.NumberOfChildren) * @deprecated 2.4.0 * @see \Magento\Customer\Controller\AccountInterface diff --git a/app/code/Magento/Customer/Controller/Plugin/Account.php b/app/code/Magento/Customer/Controller/Plugin/Account.php index 5fc65eb845563..b7352873269e9 100644 --- a/app/code/Magento/Customer/Controller/Plugin/Account.php +++ b/app/code/Magento/Customer/Controller/Plugin/Account.php @@ -14,6 +14,9 @@ use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\ResultInterface; +/** + * Plugin verifies permissions using Action Name against injected (`fontend/di.xml`) rules + */ class Account { /** @@ -21,15 +24,16 @@ class Account */ protected $session; - /** - * @var array - */ - private $allowedActions = []; /** * @var RequestInterface */ private $request; + /** + * @var array + */ + private $allowedActions = []; + /** * @param RequestInterface $request * @param Session $customerSession From 54ae63a63dd0fd7101299cf4b4390c98a33a3f29 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Mon, 9 Mar 2020 18:19:49 +0100 Subject: [PATCH 06/26] Adjust Unit Tests for the change --- .../Unit/Controller/Plugin/AccountTest.php | 90 +++++++++---------- 1 file changed, 41 insertions(+), 49 deletions(-) diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php index 2c70a8bda28fe..7dd376d57bdb0 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php @@ -3,18 +3,22 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ + namespace Magento\Customer\Test\Unit\Controller\Plugin; +use Magento\Customer\Controller\AccountInterface; use Magento\Customer\Controller\Plugin\Account; use Magento\Customer\Model\Session; use Magento\Framework\App\ActionFlag; use Magento\Framework\App\ActionInterface; -use Magento\Framework\App\Action\AbstractAction; use Magento\Framework\App\Request\Http; +use Magento\Framework\App\Request\Http as HttpRequest; use Magento\Framework\Controller\ResultInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; -class AccountTest extends \PHPUnit\Framework\TestCase +class AccountTest extends TestCase { /** * @var string @@ -27,59 +31,51 @@ class AccountTest extends \PHPUnit\Framework\TestCase protected $plugin; /** - * @var Session | \PHPUnit_Framework_MockObject_MockObject + * @var Session|MockObject */ - protected $session; + protected $sessionMock; /** - * @var AbstractAction | \PHPUnit_Framework_MockObject_MockObject + * @var AccountInterface|MockObject */ - protected $subject; + protected $actionMock; /** - * @var Http | \PHPUnit_Framework_MockObject_MockObject + * @var Http|MockObject */ - protected $request; + protected $requestMock; /** - * @var ActionFlag | \PHPUnit_Framework_MockObject_MockObject + * @var ActionFlag|MockObject */ - protected $actionFlag; + protected $actionFlagMock; /** - * @var ResultInterface|\PHPUnit_Framework_MockObject_MockObject + * @var ResultInterface|MockObject */ - private $resultInterface; + private $resultMock; protected function setUp() { - $this->session = $this->getMockBuilder(\Magento\Customer\Model\Session::class) + $this->sessionMock = $this->getMockBuilder(Session::class) ->disableOriginalConstructor() - ->setMethods([ - 'setNoReferer', - 'unsNoReferer', - 'authenticate', - ]) + ->setMethods(['setNoReferer', 'unsNoReferer', 'authenticate']) ->getMock(); - $this->subject = $this->getMockBuilder(AbstractAction::class) - ->setMethods([ - 'getActionFlag', - ]) + $this->actionMock = $this->getMockBuilder(AccountInterface::class) + ->setMethods(['getActionFlag']) ->disableOriginalConstructor() ->getMockForAbstractClass(); - $this->request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class) + $this->requestMock = $this->getMockBuilder(HttpRequest::class) ->disableOriginalConstructor() - ->setMethods([ - 'getActionName', - ]) + ->setMethods(['getActionName']) ->getMock(); - $this->resultInterface = $this->getMockBuilder(ResultInterface::class) + $this->resultMock = $this->getMockBuilder(ResultInterface::class) ->getMockForAbstractClass(); - $this->actionFlag = $this->getMockBuilder(\Magento\Framework\App\ActionFlag::class) + $this->actionFlagMock = $this->getMockBuilder(ActionFlag::class) ->disableOriginalConstructor() ->getMock(); } @@ -90,47 +86,43 @@ protected function setUp() * @param boolean $isActionAllowed * @param boolean $isAuthenticated * - * @dataProvider beforeDispatchDataProvider + * @dataProvider beforeExecuteDataProvider */ - public function testBeforeDispatch( - $action, - $allowedActions, - $isActionAllowed, - $isAuthenticated - ) { - $this->request->expects($this->once()) + public function testBeforeExecute($action, $allowedActions, $isActionAllowed, $isAuthenticated) + { + $this->requestMock->expects($this->once()) ->method('getActionName') ->willReturn($action); if ($isActionAllowed) { - $this->session->expects($this->once()) + $this->sessionMock->expects($this->once()) ->method('setNoReferer') ->with(true) ->willReturnSelf(); } else { - $this->session->expects($this->once()) + $this->sessionMock->expects($this->once()) ->method('authenticate') ->willReturn($isAuthenticated); if (!$isAuthenticated) { - $this->subject->expects($this->once()) + $this->actionMock->expects($this->once()) ->method('getActionFlag') - ->willReturn($this->actionFlag); + ->willReturn($this->actionFlagMock); - $this->actionFlag->expects($this->once()) + $this->actionFlagMock->expects($this->once()) ->method('set') ->with('', ActionInterface::FLAG_NO_DISPATCH, true) ->willReturnSelf(); } } - $plugin = new Account($this->session, $allowedActions); - $plugin->beforeDispatch($this->subject, $this->request); + $plugin = new Account($this->requestMock, $this->sessionMock, $allowedActions); + $plugin->beforeExecute($this->actionMock); } /** * @return array */ - public function beforeDispatchDataProvider() + public function beforeExecuteDataProvider() { return [ [ @@ -166,9 +158,9 @@ public function beforeDispatchDataProvider() ]; } - public function testAfterDispatch() + public function testAfterExecute() { - $this->session->expects($this->once()) + $this->sessionMock->expects($this->once()) ->method('unsNoReferer') ->with(false) ->willReturnSelf(); @@ -176,13 +168,13 @@ public function testAfterDispatch() $plugin = (new ObjectManager($this))->getObject( Account::class, [ - 'session' => $this->session, + 'session' => $this->sessionMock, 'allowedActions' => ['testaction'] ] ); $this->assertSame( - $this->resultInterface, - $plugin->afterDispatch($this->subject, $this->resultInterface, $this->request) + $this->resultMock, + $plugin->afterExecute($this->actionMock, $this->resultMock, $this->requestMock) ); } } From 8bbebf38a52474069a672b93bd9d5ecca6cf1852 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Wed, 11 Mar 2020 20:04:12 +0100 Subject: [PATCH 07/26] Avoid executing original `execute` method when no permission to do so --- .../Customer/Controller/Plugin/Account.php | 50 +++++++++++-------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/app/code/Magento/Customer/Controller/Plugin/Account.php b/app/code/Magento/Customer/Controller/Plugin/Account.php index b7352873269e9..6974ce92daed1 100644 --- a/app/code/Magento/Customer/Controller/Plugin/Account.php +++ b/app/code/Magento/Customer/Controller/Plugin/Account.php @@ -7,8 +7,10 @@ namespace Magento\Customer\Controller\Plugin; +use Closure; use Magento\Customer\Controller\AccountInterface; use Magento\Customer\Model\Session; +use Magento\Framework\App\ActionFlag; use Magento\Framework\App\ActionInterface; use Magento\Framework\App\RequestInterface; use Magento\Framework\App\ResponseInterface; @@ -33,53 +35,61 @@ class Account * @var array */ private $allowedActions = []; + /** + * @var ActionFlag + */ + private $actionFlag; /** * @param RequestInterface $request * @param Session $customerSession + * @param ActionFlag $actionFlag * @param array $allowedActions List of actions that are allowed for not authorized users */ public function __construct( RequestInterface $request, Session $customerSession, + ActionFlag $actionFlag, array $allowedActions = [] ) { $this->session = $customerSession; $this->allowedActions = $allowedActions; $this->request = $request; + $this->actionFlag = $actionFlag; } /** - * Dispatch actions allowed for not authorized users + * Executes original method if allowed, otherwise - redirects to log in * - * @param AccountInterface $subject - * @return void + * @param AccountInterface $controllerAction + * @param Closure $proceed + * @return ResultInterface|ResponseInterface|void */ - public function beforeExecute(AccountInterface $subject) + public function aroundExecute(AccountInterface $controllerAction, Closure $proceed) { - $action = strtolower($this->request->getActionName()); - $pattern = '/^(' . implode('|', $this->allowedActions) . ')$/i'; - - if (!preg_match($pattern, $action)) { - if (!$this->session->authenticate()) { - $subject->getActionFlag()->set('', ActionInterface::FLAG_NO_DISPATCH, true); - } - } else { + if ($this->isActionAllowed()) { $this->session->setNoReferer(true); + $response = $proceed(); + $this->session->unsNoReferer(false); + + return $response; + } + + if (!$this->session->authenticate()) { + $this->actionFlag->set('', ActionInterface::FLAG_NO_DISPATCH, true); } } /** - * Remove No-referer flag from customer session + * Validates whether currently requested action is one of the allowed * - * @param AccountInterface $subject - * @param ResponseInterface|ResultInterface $result - * @return ResponseInterface|ResultInterface - * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @return bool */ - public function afterExecute(AccountInterface $subject, $result) + private function isActionAllowed(): bool { - $this->session->unsNoReferer(false); - return $result; + $action = strtolower($this->request->getActionName()); + $pattern = '/^(' . implode('|', $this->allowedActions) . ')$/i'; + + return (bool)preg_match($pattern, $action); } } From 501e370f7dcfd98bfd068b6af6fa3344676e27d3 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Wed, 11 Mar 2020 21:27:30 +0100 Subject: [PATCH 08/26] Fix implementation and Unit Tests --- .../Customer/Controller/Plugin/Account.php | 20 ++---- .../Unit/Controller/Plugin/AccountTest.php | 61 ++++++------------- 2 files changed, 24 insertions(+), 57 deletions(-) diff --git a/app/code/Magento/Customer/Controller/Plugin/Account.php b/app/code/Magento/Customer/Controller/Plugin/Account.php index 6974ce92daed1..7d0b954523fa6 100644 --- a/app/code/Magento/Customer/Controller/Plugin/Account.php +++ b/app/code/Magento/Customer/Controller/Plugin/Account.php @@ -35,27 +35,20 @@ class Account * @var array */ private $allowedActions = []; - /** - * @var ActionFlag - */ - private $actionFlag; /** * @param RequestInterface $request * @param Session $customerSession - * @param ActionFlag $actionFlag * @param array $allowedActions List of actions that are allowed for not authorized users */ public function __construct( RequestInterface $request, Session $customerSession, - ActionFlag $actionFlag, array $allowedActions = [] ) { + $this->request = $request; $this->session = $customerSession; $this->allowedActions = $allowedActions; - $this->request = $request; - $this->actionFlag = $actionFlag; } /** @@ -68,16 +61,11 @@ public function __construct( public function aroundExecute(AccountInterface $controllerAction, Closure $proceed) { if ($this->isActionAllowed()) { - $this->session->setNoReferer(true); - $response = $proceed(); - $this->session->unsNoReferer(false); - - return $response; + return $proceed(); } - if (!$this->session->authenticate()) { - $this->actionFlag->set('', ActionInterface::FLAG_NO_DISPATCH, true); - } + /** @FIXME Move Authentication and redirect out of Session model */ + $this->session->authenticate(); } /** diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php index 7dd376d57bdb0..8986675d963a4 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php @@ -6,6 +6,7 @@ namespace Magento\Customer\Test\Unit\Controller\Plugin; +use Closure; use Magento\Customer\Controller\AccountInterface; use Magento\Customer\Controller\Plugin\Account; use Magento\Customer\Model\Session; @@ -83,40 +84,38 @@ protected function setUp() /** * @param string $action * @param array $allowedActions - * @param boolean $isActionAllowed + * @param boolean $isAllowed * @param boolean $isAuthenticated * * @dataProvider beforeExecuteDataProvider */ - public function testBeforeExecute($action, $allowedActions, $isActionAllowed, $isAuthenticated) + public function testAroundExecuteInterruptsOriginalCallWhenNotAllowed(string $action, array $allowedActions, bool $isAllowed, bool $isAuthenticated) { + /** @var callable|MockObject $proceedMock */ + $proceedMock = $this->getMockBuilder(\stdClass::class) + ->setMethods(['__invoke']) + ->getMock(); + + $closureMock = Closure::fromCallable($proceedMock); + $this->requestMock->expects($this->once()) ->method('getActionName') ->willReturn($action); - if ($isActionAllowed) { - $this->sessionMock->expects($this->once()) - ->method('setNoReferer') - ->with(true) - ->willReturnSelf(); + if ($isAllowed) { + $proceedMock->expects($this->once())->method('__invoke')->willReturn($this->resultMock); } else { - $this->sessionMock->expects($this->once()) - ->method('authenticate') - ->willReturn($isAuthenticated); - if (!$isAuthenticated) { - $this->actionMock->expects($this->once()) - ->method('getActionFlag') - ->willReturn($this->actionFlagMock); - - $this->actionFlagMock->expects($this->once()) - ->method('set') - ->with('', ActionInterface::FLAG_NO_DISPATCH, true) - ->willReturnSelf(); - } + $proceedMock->expects($this->never())->method('__invoke'); } $plugin = new Account($this->requestMock, $this->sessionMock, $allowedActions); - $plugin->beforeExecute($this->actionMock); + $result = $plugin->aroundExecute($this->actionMock, $closureMock); + + if ($isAllowed) { + $this->assertSame($this->resultMock, $result); + } else { + $this->assertNull($result); + } } /** @@ -157,24 +156,4 @@ public function beforeExecuteDataProvider() ], ]; } - - public function testAfterExecute() - { - $this->sessionMock->expects($this->once()) - ->method('unsNoReferer') - ->with(false) - ->willReturnSelf(); - - $plugin = (new ObjectManager($this))->getObject( - Account::class, - [ - 'session' => $this->sessionMock, - 'allowedActions' => ['testaction'] - ] - ); - $this->assertSame( - $this->resultMock, - $plugin->afterExecute($this->actionMock, $this->resultMock, $this->requestMock) - ); - } } From 79a3a1a1ad97dcd04a96a37625541b19881d1583 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Wed, 11 Mar 2020 21:33:51 +0100 Subject: [PATCH 09/26] Fix logical issue --- app/code/Magento/Customer/Controller/Plugin/Account.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Customer/Controller/Plugin/Account.php b/app/code/Magento/Customer/Controller/Plugin/Account.php index 7d0b954523fa6..ee927525f2315 100644 --- a/app/code/Magento/Customer/Controller/Plugin/Account.php +++ b/app/code/Magento/Customer/Controller/Plugin/Account.php @@ -60,12 +60,10 @@ public function __construct( */ public function aroundExecute(AccountInterface $controllerAction, Closure $proceed) { - if ($this->isActionAllowed()) { + /** @FIXME Move Authentication and redirect out of Session model */ + if ($this->isActionAllowed() || $this->session->authenticate()) { return $proceed(); } - - /** @FIXME Move Authentication and redirect out of Session model */ - $this->session->authenticate(); } /** From 302392701655d6458d8c976b8491a96a16eb97bb Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Wed, 11 Mar 2020 21:50:47 +0100 Subject: [PATCH 10/26] Code Review changes --- app/code/Magento/Customer/Controller/AbstractAccount.php | 2 +- app/code/Magento/Customer/Controller/Plugin/Account.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/code/Magento/Customer/Controller/AbstractAccount.php b/app/code/Magento/Customer/Controller/AbstractAccount.php index 36a96521cc6d1..4f2c80711d292 100644 --- a/app/code/Magento/Customer/Controller/AbstractAccount.php +++ b/app/code/Magento/Customer/Controller/AbstractAccount.php @@ -12,7 +12,7 @@ * AbstractAccount class is deprecated, in favour of Composition approach to build Controllers * * @SuppressWarnings(PHPMD.NumberOfChildren) - * @deprecated 2.4.0 + * @deprecated * @see \Magento\Customer\Controller\AccountInterface */ abstract class AbstractAccount extends Action implements AccountInterface diff --git a/app/code/Magento/Customer/Controller/Plugin/Account.php b/app/code/Magento/Customer/Controller/Plugin/Account.php index ee927525f2315..f02b333b70f7a 100644 --- a/app/code/Magento/Customer/Controller/Plugin/Account.php +++ b/app/code/Magento/Customer/Controller/Plugin/Account.php @@ -10,8 +10,6 @@ use Closure; use Magento\Customer\Controller\AccountInterface; use Magento\Customer\Model\Session; -use Magento\Framework\App\ActionFlag; -use Magento\Framework\App\ActionInterface; use Magento\Framework\App\RequestInterface; use Magento\Framework\App\ResponseInterface; use Magento\Framework\Controller\ResultInterface; From b5fda4c69bf1268f35e2758355e764c11a02a807 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Wed, 11 Mar 2020 21:56:52 +0100 Subject: [PATCH 11/26] Code style --- app/code/Magento/Customer/Controller/Plugin/Account.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/Controller/Plugin/Account.php b/app/code/Magento/Customer/Controller/Plugin/Account.php index f02b333b70f7a..bbdb58d626108 100644 --- a/app/code/Magento/Customer/Controller/Plugin/Account.php +++ b/app/code/Magento/Customer/Controller/Plugin/Account.php @@ -22,7 +22,7 @@ class Account /** * @var Session */ - protected $session; + private $session; /** * @var RequestInterface @@ -55,6 +55,7 @@ public function __construct( * @param AccountInterface $controllerAction * @param Closure $proceed * @return ResultInterface|ResponseInterface|void + * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundExecute(AccountInterface $controllerAction, Closure $proceed) { From 1917781506ff523a94514fa63a0a04637ef51f05 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Wed, 11 Mar 2020 22:55:29 +0100 Subject: [PATCH 12/26] Fix code style --- .../Customer/Test/Unit/Controller/Plugin/AccountTest.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php index 8986675d963a4..01ff1ced05ff9 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Plugin/AccountTest.php @@ -85,12 +85,14 @@ protected function setUp() * @param string $action * @param array $allowedActions * @param boolean $isAllowed - * @param boolean $isAuthenticated * * @dataProvider beforeExecuteDataProvider */ - public function testAroundExecuteInterruptsOriginalCallWhenNotAllowed(string $action, array $allowedActions, bool $isAllowed, bool $isAuthenticated) - { + public function testAroundExecuteInterruptsOriginalCallWhenNotAllowed( + string $action, + array $allowedActions, + bool $isAllowed + ) { /** @var callable|MockObject $proceedMock */ $proceedMock = $this->getMockBuilder(\stdClass::class) ->setMethods(['__invoke']) From 1e8ed89642906a7e20684da2f63cf72f149b52f8 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Sun, 15 Mar 2020 03:44:34 +0100 Subject: [PATCH 13/26] Magento_Bundle / Remove `cache:flush` and extract Tests to separate files --- ...ndEditBundleProductOptionsNegativeTest.xml | 122 +++++++ ...CreateAndEditBundleProductSettingsTest.xml | 111 ------ ...alogSearchBundleByDescriptionMysqlTest.xml | 47 +++ ...ceCatalogSearchBundleByDescriptionTest.xml | 51 +++ ...anceCatalogSearchBundleByNameMysqlTest.xml | 47 +++ ...nceCatalogSearchBundleByPriceMysqlTest.xml | 56 +++ .../AdvanceCatalogSearchBundleByPriceTest.xml | 60 ++++ ...earchBundleByShortDescriptionMysqlTest.xml | 47 +++ ...alogSearchBundleByShortDescriptionTest.xml | 51 +++ .../AdvanceCatalogSearchBundleBySkuTest.xml | 46 +++ .../AdvanceCatalogSearchBundleProductTest.xml | 321 +----------------- .../MassEnableDisableBundleProductsTest.xml | 4 +- ...CatalogSearchBundleBySkuWithHyphenTest.xml | 3 +- .../StorefrontBundleAddToCartSuccessTest.xml | 114 +++++++ .../Mftf/Test/StorefrontBundleCartTest.xml | 104 ------ ...undleProductShownInCategoryListAndGrid.xml | 4 +- 16 files changed, 646 insertions(+), 542 deletions(-) create mode 100644 app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductOptionsNegativeTest.xml create mode 100644 app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByDescriptionMysqlTest.xml create mode 100644 app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByDescriptionTest.xml create mode 100644 app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByNameMysqlTest.xml create mode 100644 app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByPriceMysqlTest.xml create mode 100644 app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByPriceTest.xml create mode 100644 app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByShortDescriptionMysqlTest.xml create mode 100644 app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByShortDescriptionTest.xml create mode 100644 app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleBySkuTest.xml create mode 100644 app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartSuccessTest.xml diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductOptionsNegativeTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductOptionsNegativeTest.xml new file mode 100644 index 0000000000000..8a8e9dd275ee4 --- /dev/null +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductOptionsNegativeTest.xml @@ -0,0 +1,122 @@ + + + + + + + + + + <description value="Admin should be able to set/edit other product information when creating/editing a bundle product"/> + <severity value="MAJOR"/> + <testCaseId value="MC-224"/> + <skip> + <issueId value="https://github.com/magento/magento2/issues/25468"/> + </skip> + <group value="Catalog"/> + </annotations> + <before> + <!-- Create a Website --> + <createData entity="customWebsite" stepKey="createWebsite"/> + + <!-- Create first simple product for a bundle option --> + <createData entity="SimpleProduct2" stepKey="createFirstSimpleProduct"/> + + <!-- Create second simple product for a bundle option --> + <createData entity="SimpleProduct2" stepKey="createSecondSimpleProduct"/> + + <!-- Login as admin --> + <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> + </before> + <after> + <!-- Delete the simple product --> + <deleteData createDataKey="createFirstSimpleProduct" stepKey="deleteFirstSimpleProduct"/> + + <!-- Delete the simple product --> + <deleteData createDataKey="createSecondSimpleProduct" stepKey="deleteSecondSimpleProduct"/> + + <!-- Delete a Website --> + <actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite"> + <argument name="websiteName" value="Second Website"/> + </actionGroup> + + <!-- Log out --> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> + </after> + + <!-- Create new bundle product --> + <actionGroup ref="GoToSpecifiedCreateProductPageActionGroup" stepKey="createBundleProduct"> + <argument name="productType" value="bundle"/> + </actionGroup> + + <!-- Fill all main fields --> + <actionGroup ref="FillMainBundleProductFormActionGroup" stepKey="fillMainProductFields"/> + + <!-- Add first bundle option to the product --> + <actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addFirstBundleOption"> + <argument name="x" value="0"/> + <argument name="n" value="1"/> + <argument name="prodOneSku" value="$$createFirstSimpleProduct.sku$$"/> + <argument name="prodTwoSku" value="$$createSecondSimpleProduct.sku$$"/> + <argument name="optionTitle" value="{{RadioButtonsOption.title}}"/> + <argument name="inputType" value="{{RadioButtonsOption.type}}"/> + </actionGroup> + + <!-- Add second bundle option to the product --> + <actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addSecondBundleOption"> + <argument name="x" value="1"/> + <argument name="n" value="2"/> + <argument name="prodOneSku" value="$$createFirstSimpleProduct.sku$$"/> + <argument name="prodTwoSku" value="$$createSecondSimpleProduct.sku$$"/> + <argument name="optionTitle" value="{{CheckboxOption.title}}"/> + <argument name="inputType" value="{{CheckboxOption.type}}"/> + </actionGroup> + + <!-- Add third bundle option to the product --> + <actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addThirdBundleOption"> + <argument name="x" value="2"/> + <argument name="n" value="3"/> + <argument name="prodOneSku" value="$$createFirstSimpleProduct.sku$$"/> + <argument name="prodTwoSku" value="$$createSecondSimpleProduct.sku$$"/> + <argument name="optionTitle" value="{{RadioButtonsOption.title}}"/> + <argument name="inputType" value="{{RadioButtonsOption.type}}"/> + </actionGroup> + + <!-- Set product in created Website --> + <actionGroup ref="AdminAssignProductInWebsiteActionGroup" stepKey="selectProductInWebsites"> + <argument name="website" value="$createWebsite.website[name]$"/> + </actionGroup> + + <!-- Save product form --> + <actionGroup ref="SaveProductFormActionGroup" stepKey="saveWithThreeOptions"/> + + <!-- Open created product --> + <actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct"> + <argument name="product" value="BundleProduct"/> + </actionGroup> + <actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct"> + <argument name="product" value="BundleProduct"/> + </actionGroup> + + <!-- Remove second option --> + <actionGroup ref="DeleteBundleOptionByIndexActionGroup" stepKey="deleteSecondOption"> + <argument name="deleteIndex" value="1"/> + </actionGroup> + + <!-- Save product form --> + <actionGroup ref="SaveProductFormActionGroup" stepKey="clickSaveProduct"/> + <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveWithTwoOptions"/> + <seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="messageYouSavedTheProductIsShown"/> + + <!-- Delete created bundle product --> + <actionGroup ref="DeleteProductUsingProductGridActionGroup" stepKey="deleteProduct"> + <argument name="product" value="BundleProduct"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml index b143bd63280ea..8442f9e583cab 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml @@ -136,117 +136,6 @@ <actionGroup ref="StorefrontOpenCartFromMinicartActionGroup" stepKey="openCart"/> <dontSeeElement selector="{{StorefrontProductCartGiftOptionSection.giftOptions}}" stepKey="dontSeeGiftOptionBtn"/> - <!-- Delete created bundle product --> - <actionGroup ref="DeleteProductUsingProductGridActionGroup" stepKey="deleteProduct"> - <argument name="product" value="BundleProduct"/> - </actionGroup> - </test> - <test name="AdminCreateAndEditBundleProductOptionsNegativeTest"> - <annotations> - <features value="Bundle"/> - <stories value="Modify bundle product in Admin"/> - <title value="Admin should be able to remove any bundle option a bundle product"/> - <description value="Admin should be able to set/edit other product information when creating/editing a bundle product"/> - <severity value="MAJOR"/> - <testCaseId value="MC-224"/> - <skip> - <issueId value="https://github.com/magento/magento2/issues/25468"/> - </skip> - <group value="Catalog"/> - </annotations> - <before> - <!-- Create a Website --> - <createData entity="customWebsite" stepKey="createWebsite"/> - - <!-- Create first simple product for a bundle option --> - <createData entity="SimpleProduct2" stepKey="createFirstSimpleProduct"/> - - <!-- Create second simple product for a bundle option --> - <createData entity="SimpleProduct2" stepKey="createSecondSimpleProduct"/> - - <!-- Login as admin --> - <actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/> - </before> - <after> - <!-- Delete the simple product --> - <deleteData createDataKey="createFirstSimpleProduct" stepKey="deleteFirstSimpleProduct"/> - - <!-- Delete the simple product --> - <deleteData createDataKey="createSecondSimpleProduct" stepKey="deleteSecondSimpleProduct"/> - - <!-- Delete a Website --> - <actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite"> - <argument name="websiteName" value="Second Website"/> - </actionGroup> - - <!-- Log out --> - <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> - </after> - - <!-- Create new bundle product --> - <actionGroup ref="GoToSpecifiedCreateProductPageActionGroup" stepKey="createBundleProduct"> - <argument name="productType" value="bundle"/> - </actionGroup> - - <!-- Fill all main fields --> - <actionGroup ref="FillMainBundleProductFormActionGroup" stepKey="fillMainProductFields"/> - - <!-- Add first bundle option to the product --> - <actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addFirstBundleOption"> - <argument name="x" value="0"/> - <argument name="n" value="1"/> - <argument name="prodOneSku" value="$$createFirstSimpleProduct.sku$$"/> - <argument name="prodTwoSku" value="$$createSecondSimpleProduct.sku$$"/> - <argument name="optionTitle" value="{{RadioButtonsOption.title}}"/> - <argument name="inputType" value="{{RadioButtonsOption.type}}"/> - </actionGroup> - - <!-- Add second bundle option to the product --> - <actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addSecondBundleOption"> - <argument name="x" value="1"/> - <argument name="n" value="2"/> - <argument name="prodOneSku" value="$$createFirstSimpleProduct.sku$$"/> - <argument name="prodTwoSku" value="$$createSecondSimpleProduct.sku$$"/> - <argument name="optionTitle" value="{{CheckboxOption.title}}"/> - <argument name="inputType" value="{{CheckboxOption.type}}"/> - </actionGroup> - - <!-- Add third bundle option to the product --> - <actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addThirdBundleOption"> - <argument name="x" value="2"/> - <argument name="n" value="3"/> - <argument name="prodOneSku" value="$$createFirstSimpleProduct.sku$$"/> - <argument name="prodTwoSku" value="$$createSecondSimpleProduct.sku$$"/> - <argument name="optionTitle" value="{{RadioButtonsOption.title}}"/> - <argument name="inputType" value="{{RadioButtonsOption.type}}"/> - </actionGroup> - - <!-- Set product in created Website --> - <actionGroup ref="AdminAssignProductInWebsiteActionGroup" stepKey="selectProductInWebsites"> - <argument name="website" value="$createWebsite.website[name]$"/> - </actionGroup> - - <!-- Save product form --> - <actionGroup ref="SaveProductFormActionGroup" stepKey="saveWithThreeOptions"/> - - <!-- Open created product --> - <actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct"> - <argument name="product" value="BundleProduct"/> - </actionGroup> - <actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct"> - <argument name="product" value="BundleProduct"/> - </actionGroup> - - <!-- Remove second option --> - <actionGroup ref="DeleteBundleOptionByIndexActionGroup" stepKey="deleteSecondOption"> - <argument name="deleteIndex" value="1"/> - </actionGroup> - - <!-- Save product form --> - <actionGroup ref="SaveProductFormActionGroup" stepKey="clickSaveProduct"/> - <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveWithTwoOptions"/> - <seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="messageYouSavedTheProductIsShown"/> - <!-- Delete created bundle product --> <actionGroup ref="DeleteProductUsingProductGridActionGroup" stepKey="deleteProduct"> <argument name="product" value="BundleProduct"/> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByDescriptionMysqlTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByDescriptionMysqlTest.xml new file mode 100644 index 0000000000000..e9525e2a144fb --- /dev/null +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByDescriptionMysqlTest.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdvanceCatalogSearchBundleByDescriptionMysqlTest" extends="AdvanceCatalogSearchSimpleProductByDescriptionTest"> + <annotations> + <features value="Bundle"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Bundle product with product description using the MySQL search engine"/> + <description value="Guest customer should be able to advance search Bundle product with product description using the MySQL search engine"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20473"/> + <group value="Bundle"/> + <group value="SearchEngineMysql"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiBundleProduct" stepKey="product"/> + <createData entity="DropDownBundleOption" stepKey="bundleOption"> + <requiredEntity createDataKey="product"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink1"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink2"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple2"/> + </createData> + + <magentoCron stepKey="runCronReindex" groups="index"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + </test> +</tests> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByDescriptionTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByDescriptionTest.xml new file mode 100644 index 0000000000000..95b4e06678af2 --- /dev/null +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByDescriptionTest.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdvanceCatalogSearchBundleByDescriptionTest" extends="AdvanceCatalogSearchSimpleProductByDescriptionTest"> + <annotations> + <features value="Bundle"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Bundle product with product description"/> + <description value="Guest customer should be able to advance search Bundle product with product description"/> + <severity value="MAJOR"/> + <testCaseId value="MC-242"/> + <group value="Bundle"/> + <group value="SearchEngineElasticsearch"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiBundleProduct" stepKey="product"/> + <createData entity="DropDownBundleOption" stepKey="bundleOption"> + <requiredEntity createDataKey="product"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink1"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink2"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple2"/> + </createData> + + <magentoCron stepKey="runCronReindex" groups="index"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + <see userInput="3 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> + <see userInput="$$product.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('1')}}" stepKey="seeProductName"/> + <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> + <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> + </test> +</tests> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByNameMysqlTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByNameMysqlTest.xml new file mode 100644 index 0000000000000..05fe8dd7de27e --- /dev/null +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByNameMysqlTest.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdvanceCatalogSearchBundleByNameMysqlTest" extends="AdvanceCatalogSearchSimpleProductByNameTest"> + <annotations> + <features value="Bundle"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Bundle product with product name using the MySQL search engine"/> + <description value="Guest customer should be able to advance search Bundle product with product name using the MySQL search engine"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20472"/> + <group value="Bundle"/> + <group value="SearchEngineMysql"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiBundleProduct" stepKey="product"/> + <createData entity="DropDownBundleOption" stepKey="bundleOption"> + <requiredEntity createDataKey="product"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink1"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink2"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple2"/> + </createData> + + <magentoCron stepKey="runCronReindex" groups="index"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + </test> +</tests> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByPriceMysqlTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByPriceMysqlTest.xml new file mode 100644 index 0000000000000..c70e9a95ab532 --- /dev/null +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByPriceMysqlTest.xml @@ -0,0 +1,56 @@ +<?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="AdvanceCatalogSearchBundleByPriceMysqlTest" extends="AdvanceCatalogSearchSimpleProductByPriceTest"> + <annotations> + <features value="Bundle"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Bundle product with product price using the MySQL search engine"/> + <description value="Guest customer should be able to advance search Bundle product with product price the MySQL search engine"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20475"/> + <group value="Bundle"/> + <group value="SearchEngineMysql"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiBundleProduct" stepKey="product"/> + <createData entity="DropDownBundleOption" stepKey="bundleOption"> + <requiredEntity createDataKey="product"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink1"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink2"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple2"/> + </createData> + <getData entity="GetProduct" stepKey="arg1"> + <requiredEntity createDataKey="product"/> + </getData> + <getData entity="GetProduct" stepKey="arg2"> + <requiredEntity createDataKey="simple1"/> + </getData> + <getData entity="GetProduct" stepKey="arg3"> + <requiredEntity createDataKey="simple2"/> + </getData> + + <magentoCron stepKey="runCronReindex" groups="index"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + </test> +</tests> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByPriceTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByPriceTest.xml new file mode 100644 index 0000000000000..f45c9ceba635f --- /dev/null +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByPriceTest.xml @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdvanceCatalogSearchBundleByPriceTest" extends="AdvanceCatalogSearchSimpleProductByPriceTest"> + <annotations> + <features value="Bundle"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Bundle product with product price"/> + <description value="Guest customer should be able to advance search Bundle product with product price"/> + <severity value="MAJOR"/> + <testCaseId value="MC-251"/> + <group value="Bundle"/> + <group value="SearchEngineElasticsearch"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiBundleProduct" stepKey="product"/> + <createData entity="DropDownBundleOption" stepKey="bundleOption"> + <requiredEntity createDataKey="product"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink1"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink2"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple2"/> + </createData> + <getData entity="GetProduct" stepKey="arg1"> + <requiredEntity createDataKey="product"/> + </getData> + <getData entity="GetProduct" stepKey="arg2"> + <requiredEntity createDataKey="simple1"/> + </getData> + <getData entity="GetProduct" stepKey="arg3"> + <requiredEntity createDataKey="simple2"/> + </getData> + + <magentoCron stepKey="runCronReindex" groups="index"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + <see userInput="3 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> + <see userInput="$$product.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('1')}}" stepKey="seeProductName"/> + <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> + <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> + </test> +</tests> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByShortDescriptionMysqlTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByShortDescriptionMysqlTest.xml new file mode 100644 index 0000000000000..2bb2974b78555 --- /dev/null +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByShortDescriptionMysqlTest.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdvanceCatalogSearchBundleByShortDescriptionMysqlTest" extends="AdvanceCatalogSearchSimpleProductByShortDescriptionTest"> + <annotations> + <features value="Bundle"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Bundle product with product short description using the MySQL search engine"/> + <description value="Guest customer should be able to advance search Bundle product with product short description using the MySQL search engine"/> + <severity value="MAJOR"/> + <testCaseId value="MC-20474"/> + <group value="Bundle"/> + <group value="SearchEngineMysql"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiBundleProduct" stepKey="product"/> + <createData entity="DropDownBundleOption" stepKey="bundleOption"> + <requiredEntity createDataKey="product"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink1"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink2"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple2"/> + </createData> + + <magentoCron stepKey="runCronReindex" groups="index"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + </test> +</tests> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByShortDescriptionTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByShortDescriptionTest.xml new file mode 100644 index 0000000000000..05e14174d14a5 --- /dev/null +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleByShortDescriptionTest.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + /** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +--> + +<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> + <test name="AdvanceCatalogSearchBundleByShortDescriptionTest" extends="AdvanceCatalogSearchSimpleProductByShortDescriptionTest"> + <annotations> + <features value="Bundle"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Bundle product with product short description"/> + <description value="Guest customer should be able to advance search Bundle product with product short description"/> + <severity value="MAJOR"/> + <testCaseId value="MC-250"/> + <group value="Bundle"/> + <group value="SearchEngineElasticsearch"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiBundleProduct" stepKey="product"/> + <createData entity="DropDownBundleOption" stepKey="bundleOption"> + <requiredEntity createDataKey="product"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink1"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink2"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple2"/> + </createData> + + <magentoCron stepKey="runCronReindex" groups="index"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + <see userInput="3 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> + <see userInput="$$product.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('1')}}" stepKey="seeProductName"/> + <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> + <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> + </test> +</tests> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleBySkuTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleBySkuTest.xml new file mode 100644 index 0000000000000..eadf7667b010b --- /dev/null +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleBySkuTest.xml @@ -0,0 +1,46 @@ +<?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="AdvanceCatalogSearchBundleBySkuTest" extends="AdvanceCatalogSearchSimpleProductBySkuTest"> + <annotations> + <features value="Bundle"/> + <stories value="Advanced Catalog Product Search for all product types"/> + <title value="Guest customer should be able to advance search Bundle product with product sku"/> + <description value="Guest customer should be able to advance search Bundle product with product sku"/> + <severity value="MAJOR"/> + <testCaseId value="MC-143"/> + <group value="Bundle"/> + </annotations> + <before> + <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> + <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> + <createData entity="ApiBundleProductUnderscoredSku" stepKey="product"/> + <createData entity="DropDownBundleOption" stepKey="bundleOption"> + <requiredEntity createDataKey="product"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink1"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple1"/> + </createData> + <createData entity="ApiBundleLink" stepKey="createBundleLink2"> + <requiredEntity createDataKey="product"/> + <requiredEntity createDataKey="bundleOption"/> + <requiredEntity createDataKey="simple2"/> + </createData> + + <magentoCron stepKey="runCronReindex" groups="index"/> + </before> + <after> + <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> + <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> + </after> + </test> +</tests> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleProductTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleProductTest.xml index c6aab0ea54ea2..e6af89181e558 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleProductTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdvanceCatalogSearchBundleProductTest.xml @@ -36,280 +36,8 @@ <requiredEntity createDataKey="bundleOption"/> <requiredEntity createDataKey="simple2"/> </createData> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> - </before> - <after> - <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> - <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> - </after> - <see userInput="3 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> - <see userInput="$$product.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('1')}}" stepKey="seeProductName"/> - <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> - <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> - </test> - <test name="AdvanceCatalogSearchBundleByNameMysqlTest" extends="AdvanceCatalogSearchSimpleProductByNameTest"> - <annotations> - <features value="Bundle"/> - <stories value="Advanced Catalog Product Search for all product types"/> - <title value="Guest customer should be able to advance search Bundle product with product name using the MySQL search engine"/> - <description value="Guest customer should be able to advance search Bundle product with product name using the MySQL search engine"/> - <severity value="MAJOR"/> - <testCaseId value="MC-20472"/> - <group value="Bundle"/> - <group value="SearchEngineMysql"/> - </annotations> - <before> - <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> - <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> - <createData entity="ApiBundleProduct" stepKey="product"/> - <createData entity="DropDownBundleOption" stepKey="bundleOption"> - <requiredEntity createDataKey="product"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink1"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple1"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink2"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple2"/> - </createData> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> - </before> - <after> - <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> - <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> - </after> - </test> - <test name="AdvanceCatalogSearchBundleBySkuTest" extends="AdvanceCatalogSearchSimpleProductBySkuTest"> - <annotations> - <features value="Bundle"/> - <stories value="Advanced Catalog Product Search for all product types"/> - <title value="Guest customer should be able to advance search Bundle product with product sku"/> - <description value="Guest customer should be able to advance search Bundle product with product sku"/> - <severity value="MAJOR"/> - <testCaseId value="MC-143"/> - <group value="Bundle"/> - </annotations> - <before> - <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> - <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> - <createData entity="ApiBundleProductUnderscoredSku" stepKey="product"/> - <createData entity="DropDownBundleOption" stepKey="bundleOption"> - <requiredEntity createDataKey="product"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink1"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple1"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink2"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple2"/> - </createData> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> - </before> - <after> - <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> - <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> - </after> - </test> - <test name="AdvanceCatalogSearchBundleByDescriptionTest" extends="AdvanceCatalogSearchSimpleProductByDescriptionTest"> - <annotations> - <features value="Bundle"/> - <stories value="Advanced Catalog Product Search for all product types"/> - <title value="Guest customer should be able to advance search Bundle product with product description"/> - <description value="Guest customer should be able to advance search Bundle product with product description"/> - <severity value="MAJOR"/> - <testCaseId value="MC-242"/> - <group value="Bundle"/> - <group value="SearchEngineElasticsearch"/> - </annotations> - <before> - <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> - <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> - <createData entity="ApiBundleProduct" stepKey="product"/> - <createData entity="DropDownBundleOption" stepKey="bundleOption"> - <requiredEntity createDataKey="product"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink1"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple1"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink2"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple2"/> - </createData> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> - </before> - <after> - <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> - <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> - </after> - <see userInput="3 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> - <see userInput="$$product.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('1')}}" stepKey="seeProductName"/> - <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> - <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> - </test> - <test name="AdvanceCatalogSearchBundleByDescriptionMysqlTest" extends="AdvanceCatalogSearchSimpleProductByDescriptionTest"> - <annotations> - <features value="Bundle"/> - <stories value="Advanced Catalog Product Search for all product types"/> - <title value="Guest customer should be able to advance search Bundle product with product description using the MySQL search engine"/> - <description value="Guest customer should be able to advance search Bundle product with product description using the MySQL search engine"/> - <severity value="MAJOR"/> - <testCaseId value="MC-20473"/> - <group value="Bundle"/> - <group value="SearchEngineMysql"/> - </annotations> - <before> - <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> - <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> - <createData entity="ApiBundleProduct" stepKey="product"/> - <createData entity="DropDownBundleOption" stepKey="bundleOption"> - <requiredEntity createDataKey="product"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink1"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple1"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink2"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple2"/> - </createData> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> - </before> - <after> - <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> - <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> - </after> - </test> - <test name="AdvanceCatalogSearchBundleByShortDescriptionTest" extends="AdvanceCatalogSearchSimpleProductByShortDescriptionTest"> - <annotations> - <features value="Bundle"/> - <stories value="Advanced Catalog Product Search for all product types"/> - <title value="Guest customer should be able to advance search Bundle product with product short description"/> - <description value="Guest customer should be able to advance search Bundle product with product short description"/> - <severity value="MAJOR"/> - <testCaseId value="MC-250"/> - <group value="Bundle"/> - <group value="SearchEngineElasticsearch"/> - </annotations> - <before> - <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> - <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> - <createData entity="ApiBundleProduct" stepKey="product"/> - <createData entity="DropDownBundleOption" stepKey="bundleOption"> - <requiredEntity createDataKey="product"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink1"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple1"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink2"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple2"/> - </createData> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> - </before> - <after> - <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> - <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> - </after> - <see userInput="3 items" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.itemFound}}" stepKey="see"/> - <see userInput="$$product.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('1')}}" stepKey="seeProductName"/> - <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> - <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> - </test> - <test name="AdvanceCatalogSearchBundleByShortDescriptionMysqlTest" extends="AdvanceCatalogSearchSimpleProductByShortDescriptionTest"> - <annotations> - <features value="Bundle"/> - <stories value="Advanced Catalog Product Search for all product types"/> - <title value="Guest customer should be able to advance search Bundle product with product short description using the MySQL search engine"/> - <description value="Guest customer should be able to advance search Bundle product with product short description using the MySQL search engine"/> - <severity value="MAJOR"/> - <testCaseId value="MC-20474"/> - <group value="Bundle"/> - <group value="SearchEngineMysql"/> - </annotations> - <before> - <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> - <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> - <createData entity="ApiBundleProduct" stepKey="product"/> - <createData entity="DropDownBundleOption" stepKey="bundleOption"> - <requiredEntity createDataKey="product"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink1"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple1"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink2"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple2"/> - </createData> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> - </before> - <after> - <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> - <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> - </after> - </test> - <test name="AdvanceCatalogSearchBundleByPriceTest" extends="AdvanceCatalogSearchSimpleProductByPriceTest"> - <annotations> - <features value="Bundle"/> - <stories value="Advanced Catalog Product Search for all product types"/> - <title value="Guest customer should be able to advance search Bundle product with product price"/> - <description value="Guest customer should be able to advance search Bundle product with product price"/> - <severity value="MAJOR"/> - <testCaseId value="MC-251"/> - <group value="Bundle"/> - <group value="SearchEngineElasticsearch"/> - </annotations> - <before> - <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> - <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> - <createData entity="ApiBundleProduct" stepKey="product"/> - <createData entity="DropDownBundleOption" stepKey="bundleOption"> - <requiredEntity createDataKey="product"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink1"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple1"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink2"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple2"/> - </createData> - <getData entity="GetProduct" stepKey="arg1"> - <requiredEntity createDataKey="product"/> - </getData> - <getData entity="GetProduct" stepKey="arg2"> - <requiredEntity createDataKey="simple1"/> - </getData> - <getData entity="GetProduct" stepKey="arg3"> - <requiredEntity createDataKey="simple2"/> - </getData> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> + + <magentoCron stepKey="runCronReindex" groups="index"/> </before> <after> <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> @@ -320,49 +48,4 @@ <see userInput="$$simple1.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('2')}}" stepKey="seeSimple1ProductName"/> <see userInput="$$simple2.name$$" selector="{{StorefrontCatalogSearchAdvancedResultMainSection.nthProductName('3')}}" stepKey="seeSimple2ProductName"/> </test> - <test name="AdvanceCatalogSearchBundleByPriceMysqlTest" extends="AdvanceCatalogSearchSimpleProductByPriceTest"> - <annotations> - <features value="Bundle"/> - <stories value="Advanced Catalog Product Search for all product types"/> - <title value="Guest customer should be able to advance search Bundle product with product price using the MySQL search engine"/> - <description value="Guest customer should be able to advance search Bundle product with product price the MySQL search engine"/> - <severity value="MAJOR"/> - <testCaseId value="MC-20475"/> - <group value="Bundle"/> - <group value="SearchEngineMysql"/> - </annotations> - <before> - <createData entity="ApiProductWithDescription" stepKey="simple1" before="simple2"/> - <createData entity="ApiProductWithDescription" stepKey="simple2" before="product"/> - <createData entity="ApiBundleProduct" stepKey="product"/> - <createData entity="DropDownBundleOption" stepKey="bundleOption"> - <requiredEntity createDataKey="product"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink1"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple1"/> - </createData> - <createData entity="ApiBundleLink" stepKey="createBundleLink2"> - <requiredEntity createDataKey="product"/> - <requiredEntity createDataKey="bundleOption"/> - <requiredEntity createDataKey="simple2"/> - </createData> - <getData entity="GetProduct" stepKey="arg1"> - <requiredEntity createDataKey="product"/> - </getData> - <getData entity="GetProduct" stepKey="arg2"> - <requiredEntity createDataKey="simple1"/> - </getData> - <getData entity="GetProduct" stepKey="arg3"> - <requiredEntity createDataKey="simple2"/> - </getData> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> - </before> - <after> - <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> - <deleteData createDataKey="simple2" stepKey="deleteSimple2" before="delete"/> - </after> - </test> </tests> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/MassEnableDisableBundleProductsTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/MassEnableDisableBundleProductsTest.xml index 97e509db39fa7..4760570adfa2e 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/MassEnableDisableBundleProductsTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/MassEnableDisableBundleProductsTest.xml @@ -120,9 +120,7 @@ <click selector="{{AdminProductFiltersSection.disable}}" stepKey="ClickOnDisable"/> <waitForPageLoad stepKey="waitForPageloadToExecute"/> - <!--Clear Cache - reindex - resets products according to enabled/disabled view--> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> + <magentoCron stepKey="runCronReindex" groups="index"/> <actionGroup ref="ClearPageCacheActionGroup" stepKey="clearing"/> <!--Confirm bundle products have been disabled--> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdvanceCatalogSearchBundleBySkuWithHyphenTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdvanceCatalogSearchBundleBySkuWithHyphenTest.xml index d8d6034cd1a21..07be59b998dec 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdvanceCatalogSearchBundleBySkuWithHyphenTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontAdvanceCatalogSearchBundleBySkuWithHyphenTest.xml @@ -36,8 +36,7 @@ <requiredEntity createDataKey="bundleOption"/> <requiredEntity createDataKey="simple2"/> </createData> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> + <magentoCron stepKey="runCronReindex" groups="index"/> </before> <after> <deleteData createDataKey="simple1" stepKey="deleteSimple1" before="deleteSimple2"/> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartSuccessTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartSuccessTest.xml new file mode 100644 index 0000000000000..9fc19f5c5750f --- /dev/null +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleAddToCartSuccessTest.xml @@ -0,0 +1,114 @@ +<?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="StorefrontBundleAddToCartSuccessTest"> + <annotations> + <features value="Bundle"/> + <stories value="Bundle product details page"/> + <title value="Customer should be able to add the bundle product to the cart"/> + <description value="Customer should be able to add the bundle product to the cart"/> + <severity value="CRITICAL"/> + <testCaseId value="MC-232"/> + <group value="Bundle"/> + </annotations> + <before> + <actionGroup ref="LoginAsAdmin" stepKey="login"/> + <createData entity="SimpleProduct2" stepKey="simpleProduct1"/> + <createData entity="SimpleProduct2" stepKey="simpleProduct2"/> + </before> + <after> + <amOnPage url="{{AdminLogoutPage.url}}" stepKey="logout"/> + <deleteData createDataKey="simpleProduct1" stepKey="deleteSimpleProduct1"/> + <deleteData createDataKey="simpleProduct2" stepKey="deleteSimpleProduct2"/> + </after> + + <!-- Start creating a bundle product --> + <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="goToProductList"/> + <waitForPageLoad stepKey="waitForProductList"/> + <actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goToCreateProduct"> + <argument name="product" value="BundleProduct"/> + </actionGroup> + <actionGroup ref="FillProductNameAndSkuInProductFormActionGroup" stepKey="fillNameAndSku"> + <argument name="product" value="BundleProduct"/> + </actionGroup> + + <!-- Add Option One, a "Drop-down" type option --> + <actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addBundleOptionWithTwoProducts1"> + <argument name="x" value="0"/> + <argument name="n" value="1"/> + <argument name="prodOneSku" value="$$simpleProduct1.sku$$"/> + <argument name="prodTwoSku" value="$$simpleProduct2.sku$$"/> + <argument name="optionTitle" value="Option One"/> + <argument name="inputType" value="select"/> + </actionGroup> + + <!-- Add Option Two, a "Radio Buttons" type option --> + <actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addBundleOptionWithTwoProducts2"> + <argument name="x" value="1"/> + <argument name="n" value="2"/> + <argument name="prodOneSku" value="$$simpleProduct1.sku$$"/> + <argument name="prodTwoSku" value="$$simpleProduct2.sku$$"/> + <argument name="optionTitle" value="Option Two"/> + <argument name="inputType" value="radio"/> + </actionGroup> + + <!-- Add Option Three, a "Checkbox" type option --> + <actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addBundleOptionWithTwoProducts3"> + <argument name="x" value="2"/> + <argument name="n" value="3"/> + <argument name="prodOneSku" value="$$simpleProduct1.sku$$"/> + <argument name="prodTwoSku" value="$$simpleProduct2.sku$$"/> + <argument name="optionTitle" value="Option Three"/> + <argument name="inputType" value="checkbox"/> + </actionGroup> + + <!-- Add Option Four, a "Multi Select" type option --> + <actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addBundleOptionWithTwoProducts4"> + <argument name="x" value="3"/> + <argument name="n" value="4"/> + <argument name="prodOneSku" value="$$simpleProduct1.sku$$"/> + <argument name="prodTwoSku" value="$$simpleProduct2.sku$$"/> + <argument name="optionTitle" value="Option Four"/> + <argument name="inputType" value="multi"/> + </actionGroup> + + <!-- Save product and go to storefront --> + <actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/> + <amOnPage url="{{BundleProduct.sku}}.html" stepKey="goToStorefront"/> + <waitForPageLoad stepKey="waitForStorefront"/> + <click selector="{{StorefrontBundledSection.addToCart}}" stepKey="clickCustomize"/> + + <!-- Select all applicable options --> + <selectOption selector="select.bundle-option-select" userInput="$$simpleProduct1.name$$ +$123.00" stepKey="selectOption1"/> + <click selector="input[type='radio']:nth-of-type(1)" stepKey="selectOption2"/> + <checkOption selector="input[type='checkbox']:nth-of-type(1)" stepKey="selectOption3"/> + <selectOption selector="select[multiple='multiple']" userInput="$$simpleProduct1.name$$ +$123.00" stepKey="selectOption4"/> + + <!-- Customize and add the bundle product to our cart --> + <click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="clickAddToCart1"/> + <dontSee selector="{{StorefrontBundledSection.nthOptionDiv('1')}}" userInput="This is a required field." stepKey="validForm1"/> + <dontSee selector="{{StorefrontBundledSection.nthOptionDiv('2')}}" userInput="Please select one of the options." stepKey="validForm2"/> + <dontSee selector="{{StorefrontBundledSection.nthOptionDiv('3')}}" userInput="Please select one of the options." stepKey="validForm3"/> + <dontSee selector="{{StorefrontBundledSection.nthOptionDiv('4')}}" userInput="This is a required field." stepKey="validForm4"/> + <see selector="{{StorefrontMessagesSection.success}}" userInput="You added {{BundleProduct.name}} to your shopping cart." stepKey="seeAddToCartSuccessMessage"/> + + <!-- Verify cart contents --> + <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCart"/> + <waitForPageLoad stepKey="waitForCart"/> + <see selector="{{StorefrontBundledSection.nthItemOptionsTitle('1')}}" userInput="Option One" stepKey="seeOption1"/> + <see selector="{{StorefrontBundledSection.nthItemOptionsTitle('2')}}" userInput="Option Two" stepKey="seeOption2"/> + <see selector="{{StorefrontBundledSection.nthItemOptionsTitle('3')}}" userInput="Option Three" stepKey="seeOption3"/> + <see selector="{{StorefrontBundledSection.nthItemOptionsTitle('4')}}" userInput="Option Four" stepKey="seeOption4"/> + <see selector="{{StorefrontBundledSection.nthItemOptionsValue('1')}}" userInput="50 x $$simpleProduct1.name$$ $123.00" stepKey="seeOptionValue1"/> + <see selector="{{StorefrontBundledSection.nthItemOptionsValue('2')}}" userInput="50 x $$simpleProduct1.name$$ $123.00" stepKey="seeOptionValue2"/> + <see selector="{{StorefrontBundledSection.nthItemOptionsValue('3')}}" userInput="50 x $$simpleProduct1.name$$ $123.00" stepKey="seeOptionValue3"/> + <see selector="{{StorefrontBundledSection.nthItemOptionsValue('4')}}" userInput="50 x $$simpleProduct1.name$$ $123.00" stepKey="seeOptionValue4"/> + </test> +</tests> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleCartTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleCartTest.xml index d617ced82074e..ed4a592b0d71e 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleCartTest.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleCartTest.xml @@ -124,108 +124,4 @@ <dontSee selector="{{StorefrontBundledSection.nthOptionDiv('3')}}" userInput="Please select one of the options." stepKey="error19"/> <dontSee selector="{{StorefrontBundledSection.nthOptionDiv('4')}}" userInput="This is a required field." stepKey="error20"/> </test> - - <test name="StorefrontBundleAddToCartSuccessTest"> - <annotations> - <features value="Bundle"/> - <stories value="Bundle product details page"/> - <title value="Customer should be able to add the bundle product to the cart"/> - <description value="Customer should be able to add the bundle product to the cart"/> - <severity value="CRITICAL"/> - <testCaseId value="MC-232"/> - <group value="Bundle"/> - </annotations> - <before> - <actionGroup ref="LoginAsAdmin" stepKey="login"/> - <createData entity="SimpleProduct2" stepKey="simpleProduct1"/> - <createData entity="SimpleProduct2" stepKey="simpleProduct2"/> - </before> - <after> - <amOnPage url="{{AdminLogoutPage.url}}" stepKey="logout"/> - <deleteData createDataKey="simpleProduct1" stepKey="deleteSimpleProduct1"/> - <deleteData createDataKey="simpleProduct2" stepKey="deleteSimpleProduct2"/> - </after> - - <!-- Start creating a bundle product --> - <amOnPage url="{{AdminProductIndexPage.url}}" stepKey="goToProductList"/> - <waitForPageLoad stepKey="waitForProductList"/> - <actionGroup ref="GoToCreateProductPageActionGroup" stepKey="goToCreateProduct"> - <argument name="product" value="BundleProduct"/> - </actionGroup> - <actionGroup ref="FillProductNameAndSkuInProductFormActionGroup" stepKey="fillNameAndSku"> - <argument name="product" value="BundleProduct"/> - </actionGroup> - - <!-- Add Option One, a "Drop-down" type option --> - <actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addBundleOptionWithTwoProducts1"> - <argument name="x" value="0"/> - <argument name="n" value="1"/> - <argument name="prodOneSku" value="$$simpleProduct1.sku$$"/> - <argument name="prodTwoSku" value="$$simpleProduct2.sku$$"/> - <argument name="optionTitle" value="Option One"/> - <argument name="inputType" value="select"/> - </actionGroup> - - <!-- Add Option Two, a "Radio Buttons" type option --> - <actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addBundleOptionWithTwoProducts2"> - <argument name="x" value="1"/> - <argument name="n" value="2"/> - <argument name="prodOneSku" value="$$simpleProduct1.sku$$"/> - <argument name="prodTwoSku" value="$$simpleProduct2.sku$$"/> - <argument name="optionTitle" value="Option Two"/> - <argument name="inputType" value="radio"/> - </actionGroup> - - <!-- Add Option Three, a "Checkbox" type option --> - <actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addBundleOptionWithTwoProducts3"> - <argument name="x" value="2"/> - <argument name="n" value="3"/> - <argument name="prodOneSku" value="$$simpleProduct1.sku$$"/> - <argument name="prodTwoSku" value="$$simpleProduct2.sku$$"/> - <argument name="optionTitle" value="Option Three"/> - <argument name="inputType" value="checkbox"/> - </actionGroup> - - <!-- Add Option Four, a "Multi Select" type option --> - <actionGroup ref="AddBundleOptionWithTwoProductsActionGroup" stepKey="addBundleOptionWithTwoProducts4"> - <argument name="x" value="3"/> - <argument name="n" value="4"/> - <argument name="prodOneSku" value="$$simpleProduct1.sku$$"/> - <argument name="prodTwoSku" value="$$simpleProduct2.sku$$"/> - <argument name="optionTitle" value="Option Four"/> - <argument name="inputType" value="multi"/> - </actionGroup> - - <!-- Save product and go to storefront --> - <actionGroup ref="SaveProductFormActionGroup" stepKey="saveProduct"/> - <amOnPage url="{{BundleProduct.sku}}.html" stepKey="goToStorefront"/> - <waitForPageLoad stepKey="waitForStorefront"/> - <click selector="{{StorefrontBundledSection.addToCart}}" stepKey="clickCustomize"/> - - <!-- Select all applicable options --> - <selectOption selector="select.bundle-option-select" userInput="$$simpleProduct1.name$$ +$123.00" stepKey="selectOption1"/> - <click selector="input[type='radio']:nth-of-type(1)" stepKey="selectOption2"/> - <checkOption selector="input[type='checkbox']:nth-of-type(1)" stepKey="selectOption3"/> - <selectOption selector="select[multiple='multiple']" userInput="$$simpleProduct1.name$$ +$123.00" stepKey="selectOption4"/> - - <!-- Customize and add the bundle product to our cart --> - <click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="clickAddToCart1"/> - <dontSee selector="{{StorefrontBundledSection.nthOptionDiv('1')}}" userInput="This is a required field." stepKey="validForm1"/> - <dontSee selector="{{StorefrontBundledSection.nthOptionDiv('2')}}" userInput="Please select one of the options." stepKey="validForm2"/> - <dontSee selector="{{StorefrontBundledSection.nthOptionDiv('3')}}" userInput="Please select one of the options." stepKey="validForm3"/> - <dontSee selector="{{StorefrontBundledSection.nthOptionDiv('4')}}" userInput="This is a required field." stepKey="validForm4"/> - <see selector="{{StorefrontMessagesSection.success}}" userInput="You added {{BundleProduct.name}} to your shopping cart." stepKey="seeAddToCartSuccessMessage"/> - - <!-- Verify cart contents --> - <amOnPage url="{{CheckoutCartPage.url}}" stepKey="goToCart"/> - <waitForPageLoad stepKey="waitForCart"/> - <see selector="{{StorefrontBundledSection.nthItemOptionsTitle('1')}}" userInput="Option One" stepKey="seeOption1"/> - <see selector="{{StorefrontBundledSection.nthItemOptionsTitle('2')}}" userInput="Option Two" stepKey="seeOption2"/> - <see selector="{{StorefrontBundledSection.nthItemOptionsTitle('3')}}" userInput="Option Three" stepKey="seeOption3"/> - <see selector="{{StorefrontBundledSection.nthItemOptionsTitle('4')}}" userInput="Option Four" stepKey="seeOption4"/> - <see selector="{{StorefrontBundledSection.nthItemOptionsValue('1')}}" userInput="50 x $$simpleProduct1.name$$ $123.00" stepKey="seeOptionValue1"/> - <see selector="{{StorefrontBundledSection.nthItemOptionsValue('2')}}" userInput="50 x $$simpleProduct1.name$$ $123.00" stepKey="seeOptionValue2"/> - <see selector="{{StorefrontBundledSection.nthItemOptionsValue('3')}}" userInput="50 x $$simpleProduct1.name$$ $123.00" stepKey="seeOptionValue3"/> - <see selector="{{StorefrontBundledSection.nthItemOptionsValue('4')}}" userInput="50 x $$simpleProduct1.name$$ $123.00" stepKey="seeOptionValue4"/> - </test> </tests> diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGrid.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGrid.xml index 364d4fa68e590..11984bc200e15 100644 --- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGrid.xml +++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGrid.xml @@ -76,9 +76,7 @@ <click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveButton"/> <seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="messageYouSavedTheProductIsShown"/> - <!-- Perform reindex and flush cache --> - <magentoCLI command="indexer:reindex" stepKey="reindex"/> - <magentoCLI command="cache:flush" stepKey="flushCache"/> + <magentoCron stepKey="runCronReindex" groups="index"/> <!--Go to category page--> <amOnPage url="{{StorefrontHomePage.url}}" stepKey="goToHomePage"/> From f49060be8ffa842445f7f8b2488e37bd6bd4ffbb Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Mon, 16 Mar 2020 00:17:27 +0100 Subject: [PATCH 14/26] magento/module-cms Replace inheritance with Composition `cms/page/view` --- app/code/Magento/Cms/Controller/Page/View.php | 54 ++++++++++---- app/code/Magento/Cms/Helper/Page.php | 21 +++--- .../Test/Unit/Controller/Page/ViewTest.php | 71 ++++++++++--------- 3 files changed, 93 insertions(+), 53 deletions(-) diff --git a/app/code/Magento/Cms/Controller/Page/View.php b/app/code/Magento/Cms/Controller/Page/View.php index 9d5785450ec71..da35e7a9ea9e4 100644 --- a/app/code/Magento/Cms/Controller/Page/View.php +++ b/app/code/Magento/Cms/Controller/Page/View.php @@ -1,50 +1,78 @@ <?php /** - * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Cms\Controller\Page; -use Magento\Framework\App\Action\HttpPostActionInterface; +use Magento\Cms\Helper\Page as PageHelper; use Magento\Framework\App\Action\HttpGetActionInterface; -use Magento\Framework\App\Action\Action; +use Magento\Framework\App\Action\HttpPostActionInterface; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\Controller\Result\ForwardFactory; +use Magento\Framework\Controller\ResultInterface; /** * Custom page for storefront. Needs to be accessible by POST because of the store switching. */ -class View extends Action implements HttpGetActionInterface, HttpPostActionInterface +class View implements HttpGetActionInterface, HttpPostActionInterface { /** - * @var \Magento\Framework\Controller\Result\ForwardFactory + * @var ForwardFactory */ protected $resultForwardFactory; /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory + * @var RequestInterface + */ + private $request; + + /** + * @var PageHelper + */ + private $pageHelper; + + /** + * @param RequestInterface $request + * @param PageHelper $pageHelper + * @param ForwardFactory $resultForwardFactory */ public function __construct( - \Magento\Framework\App\Action\Context $context, - \Magento\Framework\Controller\Result\ForwardFactory $resultForwardFactory + RequestInterface $request, + PageHelper $pageHelper, + ForwardFactory $resultForwardFactory ) { + $this->request = $request; + $this->pageHelper = $pageHelper; $this->resultForwardFactory = $resultForwardFactory; - parent::__construct($context); } /** * View CMS page action * - * @return \Magento\Framework\Controller\ResultInterface + * @return ResultInterface */ public function execute() { - $pageId = $this->getRequest()->getParam('page_id', $this->getRequest()->getParam('id', false)); - $resultPage = $this->_objectManager->get(\Magento\Cms\Helper\Page::class)->prepareResultPage($this, $pageId); + $resultPage = $this->pageHelper->prepareResultPage($this, $this->getPageId()); if (!$resultPage) { $resultForward = $this->resultForwardFactory->create(); return $resultForward->forward('noroute'); } return $resultPage; } + + /** + * Returns Page ID if provided or null + * + * @return int|null + */ + private function getPageId(): ?int + { + $id = $this->request->getParam('page_id') ?? $this->request->getParam('id'); + + return $id ? (int)$id : null; + } } diff --git a/app/code/Magento/Cms/Helper/Page.php b/app/code/Magento/Cms/Helper/Page.php index 39b292bf07239..501c2a5b051a2 100644 --- a/app/code/Magento/Cms/Helper/Page.php +++ b/app/code/Magento/Cms/Helper/Page.php @@ -3,22 +3,27 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Cms\Helper; use Magento\Cms\Model\Page\CustomLayoutManagerInterface; use Magento\Cms\Model\Page\CustomLayoutRepositoryInterface; use Magento\Cms\Model\Page\IdentityMap; -use Magento\Framework\App\Action\Action; +use Magento\Framework\App\ActionInterface; +use Magento\Framework\App\Helper\AbstractHelper; use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\View\Result\Page as ResultPage; /** * CMS Page Helper + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) */ -class Page extends \Magento\Framework\App\Helper\AbstractHelper +class Page extends AbstractHelper { /** * CMS no-route config path @@ -146,11 +151,11 @@ public function __construct( /** * Return result CMS page * - * @param Action $action + * @param ActionInterface $action * @param int $pageId - * @return \Magento\Framework\View\Result\Page|bool + * @return ResultPage|bool */ - public function prepareResultPage(Action $action, $pageId = null) + public function prepareResultPage(ActionInterface $action, $pageId = null) { if ($pageId !== null && $pageId !== $this->_page->getId()) { $delimiterPosition = strrpos($pageId, '|'); @@ -180,7 +185,7 @@ public function prepareResultPage(Action $action, $pageId = null) $this->_design->setDesignTheme($this->_page->getCustomTheme()); } } - /** @var \Magento\Framework\View\Result\Page $resultPage */ + /** @var ResultPage $resultPage */ $resultPage = $this->resultPageFactory->create(); $this->setLayoutType($inRange, $resultPage); $resultPage->addHandle('cms_page_view'); @@ -247,8 +252,8 @@ public function getPageUrl($pageId = null) * Set layout type * * @param bool $inRange - * @param \Magento\Framework\View\Result\Page $resultPage - * @return \Magento\Framework\View\Result\Page + * @param ResultPage $resultPage + * @return ResultPage */ protected function setLayoutType($inRange, $resultPage) { diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Page/ViewTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Page/ViewTest.php index f15e6ff3e3bf2..e4c2beaa75aa7 100644 --- a/app/code/Magento/Cms/Test/Unit/Controller/Page/ViewTest.php +++ b/app/code/Magento/Cms/Test/Unit/Controller/Page/ViewTest.php @@ -3,73 +3,80 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Cms\Test\Unit\Controller\Page; -class ViewTest extends \PHPUnit\Framework\TestCase +use Magento\Cms\Controller\Page\View; +use Magento\Cms\Helper\Page as PageHelper; +use Magento\Framework\App\RequestInterface; +use Magento\Framework\Controller\Result\Forward; +use Magento\Framework\Controller\Result\ForwardFactory; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; +use Magento\Framework\View\Result\Page; +use PHPUnit\Framework\MockObject\MockObject; +use PHPUnit\Framework\TestCase; + +class ViewTest extends TestCase { + private const STUB_PAGE_ID = 2; + /** - * @var \Magento\Cms\Controller\Page\View + * @var View */ protected $controller; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject */ - protected $cmsHelperMock; + protected $pageHelperMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var MockObject|RequestInterface */ protected $requestMock; /** - * @var \Magento\Framework\Controller\Result\ForwardFactory|\PHPUnit_Framework_MockObject_MockObject + * @var MockObject|ForwardFactory */ protected $forwardFactoryMock; /** - * @var \Magento\Framework\Controller\Result\Forward|\PHPUnit_Framework_MockObject_MockObject + * @var MockObject|Forward */ protected $forwardMock; /** - * @var \Magento\Framework\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject + * @var MockObject|Page */ protected $resultPageMock; - /** - * @var string - */ - protected $pageId = '2'; - protected function setUp() { - $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class); - $responseMock = $this->createMock(\Magento\Framework\App\Response\Http::class); - $this->resultPageMock = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class) + $objectManager = new ObjectManagerHelper($this); + + $this->resultPageMock = $this->getMockBuilder(Page::class) ->disableOriginalConstructor() ->getMock(); - $this->forwardFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\ForwardFactory::class) + $this->forwardFactoryMock = $this->getMockBuilder(ForwardFactory::class) ->setMethods(['create']) ->disableOriginalConstructor() ->getMock(); - $this->forwardMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Forward::class) + $this->forwardMock = $this->getMockBuilder(Forward::class) ->disableOriginalConstructor() ->getMock(); $this->forwardFactoryMock->expects($this->any()) ->method('create') ->willReturn($this->forwardMock); - $this->requestMock = $this->createMock(\Magento\Framework\App\Request\Http::class); - $this->cmsHelperMock = $this->createMock(\Magento\Cms\Helper\Page::class); - $objectManagerMock->expects($this->once())->method('get')->willReturn($this->cmsHelperMock); - $this->controller = $helper->getObject( - \Magento\Cms\Controller\Page\View::class, + $this->requestMock = $this->createMock(RequestInterface::class); + $this->pageHelperMock = $this->createMock(PageHelper::class); + + $this->controller = $objectManager->getObject( + View::class, [ - 'response' => $responseMock, - 'objectManager' => $objectManagerMock, 'request' => $this->requestMock, + 'pageHelper' => $this->pageHelperMock, 'resultForwardFactory' => $this->forwardFactoryMock ] ); @@ -81,13 +88,13 @@ public function testExecuteResultPage() ->method('getParam') ->willReturnMap( [ - ['page_id', $this->pageId, $this->pageId], - ['id', false, $this->pageId] + ['page_id', null, self::STUB_PAGE_ID], + ['id', null, self::STUB_PAGE_ID] ] ); - $this->cmsHelperMock->expects($this->once()) + $this->pageHelperMock->expects($this->once()) ->method('prepareResultPage') - ->with($this->controller, $this->pageId) + ->with($this->controller, self::STUB_PAGE_ID) ->willReturn($this->resultPageMock); $this->assertSame($this->resultPageMock, $this->controller->execute()); } @@ -98,8 +105,8 @@ public function testExecuteResultForward() ->method('getParam') ->willReturnMap( [ - ['page_id', $this->pageId, $this->pageId], - ['id', false, $this->pageId] + ['page_id', null, self::STUB_PAGE_ID], + ['id', null, self::STUB_PAGE_ID] ] ); $this->forwardMock->expects($this->once()) From 4fd4f99410b3fd10069c14f3ab38cd42a063c05f Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Mon, 16 Mar 2020 01:19:51 +0100 Subject: [PATCH 15/26] Fix failing Unit Test due to Page ID that can be INT --- app/code/Magento/Cms/Helper/Page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Cms/Helper/Page.php b/app/code/Magento/Cms/Helper/Page.php index 501c2a5b051a2..24581cb9ee90e 100644 --- a/app/code/Magento/Cms/Helper/Page.php +++ b/app/code/Magento/Cms/Helper/Page.php @@ -158,7 +158,7 @@ public function __construct( public function prepareResultPage(ActionInterface $action, $pageId = null) { if ($pageId !== null && $pageId !== $this->_page->getId()) { - $delimiterPosition = strrpos($pageId, '|'); + $delimiterPosition = strrpos((string)$pageId, '|'); if ($delimiterPosition) { $pageId = substr($pageId, 0, $delimiterPosition); } From 4a7adebc2060d561626981ba65a66609d2d4ed40 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Mon, 16 Mar 2020 03:11:22 +0100 Subject: [PATCH 16/26] We are not ready for `strict_types` in this Class --- app/code/Magento/Cms/Helper/Page.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Cms/Helper/Page.php b/app/code/Magento/Cms/Helper/Page.php index 24581cb9ee90e..d899a5cea985a 100644 --- a/app/code/Magento/Cms/Helper/Page.php +++ b/app/code/Magento/Cms/Helper/Page.php @@ -3,8 +3,6 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ -declare(strict_types=1); - namespace Magento\Cms\Helper; use Magento\Cms\Model\Page\CustomLayoutManagerInterface; From 4da150c13e2540a886ddf1cfaf74ba9e2b167eea Mon Sep 17 00:00:00 2001 From: Vaha <vaha@atwix.com> Date: Mon, 16 Mar 2020 16:01:31 +0200 Subject: [PATCH 17/26] Added improvements to category repository (save method) to fix level issue --- .../Catalog/Model/CategoryRepository.php | 1 + ...ntChildCategoryTreeElementsActionGroup.xml | 22 ++++++++++ .../AdminExpandCategoryTreeActionGroup.xml | 19 ++++++++ .../AdminOpenCategoryPageActionGroup.xml | 19 ++++++++ ...yLevelByParentCategoryLevelActionGroup.xml | 22 ++++++++++ .../Catalog/Test/Mftf/Data/CategoryData.xml | 6 +++ .../AdminCategorySidebarTreeSection.xml | 1 + ...inCheckNewCategoryLevelAddedViaApiTest.xml | 44 +++++++++++++++++++ .../Unit/Model/CategoryRepositoryTest.php | 2 +- 9 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssertParentChildCategoryTreeElementsActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminExpandCategoryTreeActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminOpenCategoryPageActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminCategoryLevelByParentCategoryLevelActionGroup.xml create mode 100644 app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckNewCategoryLevelAddedViaApiTest.xml diff --git a/app/code/Magento/Catalog/Model/CategoryRepository.php b/app/code/Magento/Catalog/Model/CategoryRepository.php index a8636306f5e5b..0ce52b966c32c 100644 --- a/app/code/Magento/Catalog/Model/CategoryRepository.php +++ b/app/code/Magento/Catalog/Model/CategoryRepository.php @@ -108,6 +108,7 @@ public function save(\Magento\Catalog\Api\Data\CategoryInterface $category) $parentCategory = $this->get($parentId, $storeId); $existingData['path'] = $parentCategory->getPath(); $existingData['parent_id'] = $parentId; + $existingData['level'] = null; } $category->addData($existingData); try { diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssertParentChildCategoryTreeElementsActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssertParentChildCategoryTreeElementsActionGroup.xml new file mode 100644 index 0000000000000..b1ed08db05b9a --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssertParentChildCategoryTreeElementsActionGroup.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="AdminAssertParentChildCategoryTreeElementsActionGroup"> + <annotations> + <description>Checks category tree, parent category has child category element.</description> + </annotations> + <arguments> + <argument name="parentCategoryName" type="string" defaultValue="parent"/> + <argument name="childCategoryName" type="string" defaultValue="child"/> + </arguments> + + <seeElement selector="{{AdminCategorySidebarTreeSection.childCategoryUnderParent(parentCategoryName, childCategoryName)}}" stepKey="seeSubcategoryIsUnderParent"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminExpandCategoryTreeActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminExpandCategoryTreeActionGroup.xml new file mode 100644 index 0000000000000..f2cce9b9a42fe --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminExpandCategoryTreeActionGroup.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="AdminExpandCategoryTreeActionGroup"> + <annotations> + <description>Expands category tree.</description> + </annotations> + + <click selector="{{AdminCategorySidebarTreeSection.expandAll}}" stepKey="clickOnExpandTree"/> + <waitForPageLoad stepKey="waitForCategoryToLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminOpenCategoryPageActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminOpenCategoryPageActionGroup.xml new file mode 100644 index 0000000000000..14c4f5234ba67 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminOpenCategoryPageActionGroup.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="AdminOpenCategoryPageActionGroup"> + <annotations> + <description>Navigates to category page.</description> + </annotations> + + <amOnPage url="{{AdminCategoryPage.url}}" stepKey="openAdminCategoryIndexPage"/> + <waitForPageLoad stepKey="waitForCategoryPageToLoad"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminCategoryLevelByParentCategoryLevelActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminCategoryLevelByParentCategoryLevelActionGroup.xml new file mode 100644 index 0000000000000..1830a6abc992e --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminCategoryLevelByParentCategoryLevelActionGroup.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="AssertAdminCategoryLevelByParentCategoryLevelActionGroup"> + <annotations> + <description>Checks category level by parent category level.</description> + </annotations> + <arguments> + <argument name="parentCategoryLevel" type="string" defaultValue="2"/> + <argument name="categoryLevel" type="string" defaultValue="3"/> + </arguments> + + <assertEquals expected="{{parentCategoryLevel}} + 1" actual="{{categoryLevel}}" message="wrongCategoryLevel" stepKey="compareCategoryLevel"/> + </actionGroup> +</actionGroups> diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/CategoryData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/CategoryData.xml index f54ce9af83e88..976ed5a3ed17a 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Data/CategoryData.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Data/CategoryData.xml @@ -243,4 +243,10 @@ <data key="include_in_menu">true</data> <var key="parent_id" entityType="category" entityKey="id"/> </entity> + <entity name="ApiSubCategoryWithLevelZero" type="category"> + <data key="name" unique="suffix">cat with level 1</data> + <data key="is_active">true</data> + <data key="level">0</data> + <var key="parent_id" entityType="category" entityKey="id"/> + </entity> </entities> diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategorySidebarTreeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategorySidebarTreeSection.xml index 304c34b404ea5..c35e775152ac9 100644 --- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategorySidebarTreeSection.xml +++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategorySidebarTreeSection.xml @@ -16,6 +16,7 @@ <element name="categoryTreeRoot" type="text" selector="div.x-tree-root-node>li.x-tree-node:first-of-type>div.x-tree-node-el:first-of-type" timeout="30"/> <element name="categoryInTree" type="text" selector="//a/span[contains(text(), '{{name}}')]" parameterized="true" timeout="30"/> <element name="categoryInTreeUnderRoot" type="text" selector="//li/ul/li[@class='x-tree-node']/div/a/span[contains(text(), '{{name}}')]" parameterized="true"/> + <element name="childCategoryUnderParent" type="text" selector="//li/ul/li[@class='x-tree-node']/div/a/span[contains(text(), '{{parentCategoryName}}')]/../../../ul/li[@class='x-tree-node']/div/a/span[contains(text(), '{{childCategoryName}}')]" parameterized="true"/> <element name="lastCreatedCategory" type="block" selector=".x-tree-root-ct li li:last-child" /> <element name="treeContainer" type="block" selector=".tree-holder" /> <element name="expandRootCategory" type="text" selector="img.x-tree-elbow-end-plus"/> diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckNewCategoryLevelAddedViaApiTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckNewCategoryLevelAddedViaApiTest.xml new file mode 100644 index 0000000000000..427ef6551ce9b --- /dev/null +++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCheckNewCategoryLevelAddedViaApiTest.xml @@ -0,0 +1,44 @@ +<?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="AdminCheckNewCategoryLevelAddedViaApiTest"> + <annotations> + <stories value="Add parent and child categories via API"/> + <title value="Add parent and child categories via API"/> + <description value="Login as admin, create parent and child categories via API. + Check category level for child category entity based on parent level. + Check category tree: parent element has child element. "/> + <group value="catalog"/> + </annotations> + <before> + <actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminPanel"/> + <createData entity="ApiCategoryWithChildren" stepKey="createCategoryWithChildrenBlank"/> + <createData entity="ApiSubCategoryWithLevelZero" stepKey="createSubCategoryWithLevelZero"> + <requiredEntity createDataKey="createCategoryWithChildrenBlank"/> + </createData> + </before> + <after> + <deleteData createDataKey="createCategoryWithChildrenBlank" stepKey="deleteCategoryWithChildrenBlank"/> + <actionGroup ref="logout" stepKey="logout"/> + </after> + + <actionGroup ref="AssertAdminCategoryLevelByParentCategoryLevelActionGroup" stepKey="assertCategoryLevelByParentCategory"> + <argument name="parentCategoryLevel" value="$createCategoryWithChildrenBlank.level$"/> + <argument name="categoryLevel" value="$createSubCategoryWithLevelZero.level$"/> + </actionGroup> + + <actionGroup ref="AdminOpenCategoryPageActionGroup" stepKey="openCategoryPage"/> + <actionGroup ref="AdminExpandCategoryTreeActionGroup" stepKey="expandCategoryTree"/> + <actionGroup ref="AdminAssertParentChildCategoryTreeElementsActionGroup" stepKey="assertParentChildCategoryTreeElements"> + <argument name="parentCategoryName" value="$createCategoryWithChildrenBlank.name$"/> + <argument name="childCategoryName" value="$createSubCategoryWithLevelZero.name$"/> + </actionGroup> + </test> +</tests> diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php index 864b91b20d017..3799e6e5fa4aa 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryRepositoryTest.php @@ -204,7 +204,7 @@ public function testCreateNewCategory() $parentCategoryId = 15; $newCategoryId = 25; $categoryData = ['level' => '1', 'path' => '1/2', 'parent_id' => 1, 'name' => 'category']; - $dataForSave = ['store_id' => 1, 'name' => 'category', 'path' => 'path', 'parent_id' => 15]; + $dataForSave = ['store_id' => 1, 'name' => 'category', 'path' => 'path', 'parent_id' => 15, 'level' => null]; $this->extensibleDataObjectConverterMock ->expects($this->once()) ->method('toNestedArray') From 1b014f8272390816c9a1c7edc038c80c11bbe5f7 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Mon, 16 Mar 2020 19:24:11 +0100 Subject: [PATCH 18/26] Integration Tests for Authentication feature on Customer Account --- .../Controller/AuthenticationTest.php | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Customer/Controller/AuthenticationTest.php diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AuthenticationTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AuthenticationTest.php new file mode 100644 index 0000000000000..3ccd415a16c4f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AuthenticationTest.php @@ -0,0 +1,70 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Customer\Controller; + +use Magento\Customer\Controller\Plugin\Account as AccountPlugin; +use Magento\TestFramework\TestCase\AbstractController; + +/** + * Set of Tests to verify that Authentication methods work properly + */ +class AuthenticationTest extends AbstractController +{ + /** + * Make sure that customized AccountPlugin was reverted. + */ + protected function tearDown() + { + $this->resetAllowedActions(); + parent::tearDown(); + } + + /** + * After changes to `di.xml` and overriding list of allowed actions, unallowed ones should cause redirect. + */ + public function testExpectRedirectResponseWhenDispatchNotAllowedAction() + { + $this->overrideAllowedActions(['notExistingRoute']); + + $this->dispatch('customer/account/create'); + $this->assertRedirect($this->stringContains('customer/account/login')); + } + + /** + * Allowed actions should be displayed + */ + public function testExpectPageDispatchWhenAllowedAction() + { + $this->overrideAllowedActions(['create']); + + $this->dispatch('customer/account/create'); + $this->assertEquals(200, $this->getResponse()->getStatusCode()); + } + + /** + * Overrides list of `allowedActions` for Authorization Plugin + * + * @param string[] $allowedActions + * @see \Magento\Customer\Controller\Plugin\Account + */ + private function overrideAllowedActions(array $allowedActions): void + { + $allowedActions = array_combine($allowedActions, $allowedActions); + $pluginMock = $this->_objectManager->create(AccountPlugin::class, ['allowedActions' => $allowedActions]); + $this->_objectManager->addSharedInstance($pluginMock, AccountPlugin::class); + } + + /** + * Removes all the customizations applied to `allowedActions` + * @see \Magento\Customer\Controller\Plugin\Account + */ + private function resetAllowedActions() + { + $this->_objectManager->removeSharedInstance(AccountPlugin::class); + } +} From 65ac7b743f8e02105bedecc5a2ff7048e53cca0f Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Mon, 16 Mar 2020 19:27:30 +0100 Subject: [PATCH 19/26] Invalid name (was `Mock` instead of `Fake`) --- .../Magento/Customer/Controller/AuthenticationTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AuthenticationTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AuthenticationTest.php index 3ccd415a16c4f..83f30e730e683 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AuthenticationTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AuthenticationTest.php @@ -55,8 +55,8 @@ public function testExpectPageDispatchWhenAllowedAction() private function overrideAllowedActions(array $allowedActions): void { $allowedActions = array_combine($allowedActions, $allowedActions); - $pluginMock = $this->_objectManager->create(AccountPlugin::class, ['allowedActions' => $allowedActions]); - $this->_objectManager->addSharedInstance($pluginMock, AccountPlugin::class); + $pluginFake = $this->_objectManager->create(AccountPlugin::class, ['allowedActions' => $allowedActions]); + $this->_objectManager->addSharedInstance($pluginFake, AccountPlugin::class); } /** From fe21a4348816c95397887ea13690579f39b734c2 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz <lukasz.bajsarowicz@gmail.com> Date: Mon, 16 Mar 2020 19:30:23 +0100 Subject: [PATCH 20/26] Rename Test to be more meaningful --- .../Magento/Customer/Controller/AuthenticationTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AuthenticationTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AuthenticationTest.php index 83f30e730e683..822b3ab8f35d1 100644 --- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AuthenticationTest.php +++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AuthenticationTest.php @@ -36,9 +36,9 @@ public function testExpectRedirectResponseWhenDispatchNotAllowedAction() } /** - * Allowed actions should be displayed + * Allowed actions should be rendered normally */ - public function testExpectPageDispatchWhenAllowedAction() + public function testExpectPageResponseWhenAllowedAction() { $this->overrideAllowedActions(['create']); From 6428b8c0f56dda13313171f1b39b2c4dbf36d0cc Mon Sep 17 00:00:00 2001 From: engcom-Echo <engcom-vendorworker-echo@adobe.com> Date: Tue, 17 Mar 2020 12:49:27 +0200 Subject: [PATCH 21/26] Fix static, test coverage --- .../Setup/Patch/Data/AddDataForItaly.php | 4 +- .../Magento/Directory/Model/RegionTest.php | 63 +++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForItaly.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForItaly.php index 44288c9f2a276..a5d4bcdc0b8be 100644 --- a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForItaly.php +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForItaly.php @@ -3,7 +3,6 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ - declare(strict_types=1); namespace Magento\Directory\Setup\Patch\Data; @@ -51,12 +50,15 @@ public function apply() $this->moduleDataSetup->getConnection(), $this->getDataForItaly() ); + + return $this; } /** * Italy states data. * * @return array + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ private function getDataForItaly() { diff --git a/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php b/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php new file mode 100644 index 0000000000000..0b47f7b0719c6 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php @@ -0,0 +1,63 @@ +<?php +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ +declare(strict_types=1); + +namespace Magento\Directory\Model\Country\Postcode\Config; + +use Magento\Directory\Model\Country; +use Magento\TestFramework\Helper\Bootstrap; +use PHPUnit\Framework\TestCase; + +class RegionTest extends TestCase +{ + /** + * @var Country + */ + protected $country; + + /** + * @inheritDoc + */ + public function setUp() + { + $this->country = Bootstrap::getObjectManager()->create(Country::class); + } + + /** + * Verify country has regions. + * + * @var string $countryId + * @dataProvider getCountryIdDataProvider + */ + public function testCountryHasRegions($countryId) + { + $country = $this->country->loadByCode($countryId); + $region = $country->getRegions()->getItems(); + + $this->assertTrue(!empty($region), 'Country ' . $countryId . ' not have regions'); + } + + /** + * Data provider for testCountryHasRegions + * + * @return array + */ + public function getCountryIdDataProvider():array + { + return [ + ['countryId' => 'US'], + ['countryId' => 'CA'], + ['countryId' => 'CN'], + ['countryId' => 'IN'], + ['countryId' => 'AU'], + ['countryId' => 'BE'], + ['countryId' => 'CO'], + ['countryId' => 'MX'], + ['countryId' => 'PL'], + ['countryId' => 'IT'] + ]; + } +} From f3a84a94e8c402df05217706e75d7d646287f1b7 Mon Sep 17 00:00:00 2001 From: Andrii Kalinich <51681435+engcom-Echo@users.noreply.github.com> Date: Tue, 17 Mar 2020 15:20:15 +0200 Subject: [PATCH 22/26] Update RegionTest.php --- .../testsuite/Magento/Directory/Model/RegionTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php b/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php index 0b47f7b0719c6..e0e790b265572 100644 --- a/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php +++ b/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php @@ -5,9 +5,8 @@ */ declare(strict_types=1); -namespace Magento\Directory\Model\Country\Postcode\Config; +namespace Magento\Directory\Model; -use Magento\Directory\Model\Country; use Magento\TestFramework\Helper\Bootstrap; use PHPUnit\Framework\TestCase; From 1e1ebd3a9ee69038841f41ebe8771b6a1fa700d6 Mon Sep 17 00:00:00 2001 From: Burlacu Vasilii <v.burlacu@atwix.com> Date: Thu, 12 Mar 2020 13:17:37 +0200 Subject: [PATCH 23/26] Fix: ORDER BY has two similar conditions in the SQL query --- app/code/Magento/Catalog/Block/Product/ListProduct.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Product/ListProduct.php b/app/code/Magento/Catalog/Block/Product/ListProduct.php index 144cb682e2d22..f1adc1d924836 100644 --- a/app/code/Magento/Catalog/Block/Product/ListProduct.php +++ b/app/code/Magento/Catalog/Block/Product/ListProduct.php @@ -475,8 +475,6 @@ private function initializeProductCollection() $layer->setCurrentCategory($origCategory); } - $this->addToolbarBlock($collection); - $this->_eventManager->dispatch( 'catalog_block_product_list_collection', ['collection' => $collection] From df35ddac0dacf30be6547a7cbad113c3ed6ed3fc Mon Sep 17 00:00:00 2001 From: Burlacu Vasilii <v.burlacu@atwix.com> Date: Wed, 18 Mar 2020 16:04:54 +0200 Subject: [PATCH 24/26] Fix failed unit test --- .../Catalog/Test/Unit/Block/Product/ListProductTest.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php index fe07f69e8046f..4653934311938 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php @@ -187,10 +187,6 @@ public function testGetIdentities() ->method('getProductCollection') ->will($this->returnValue($this->prodCollectionMock)); - $this->layoutMock->expects($this->once()) - ->method('getBlock') - ->will($this->returnValue($this->toolbarMock)); - $this->assertEquals( [$categoryTag, $productTag], $this->block->getIdentities() From 5abd3665e5f93588670a81503e6823d11d2e0d55 Mon Sep 17 00:00:00 2001 From: Abrar pathan <abrarkhan@krishtechnolabs.com> Date: Wed, 18 Mar 2020 20:08:48 +0530 Subject: [PATCH 25/26] fixed issue#27335 --- .../luma/Magento_Customer/web/css/source/_module.less | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less index 34a2dbfeca472..a0a36f55574fe 100644 --- a/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_Customer/web/css/source/_module.less @@ -348,6 +348,12 @@ position: relative; } } + + .additional-addresses { + table > thead > tr > th { + white-space: nowrap; + } + } } // From b8163347447bc8ee6636440c1d4ab522cc950af2 Mon Sep 17 00:00:00 2001 From: Eduard Chitoraga <e.chitoraga@atwix.com> Date: Thu, 19 Mar 2020 08:52:34 +0200 Subject: [PATCH 26/26] Fixing static test --- app/code/Magento/Catalog/Block/Product/ListProduct.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Catalog/Block/Product/ListProduct.php b/app/code/Magento/Catalog/Block/Product/ListProduct.php index f1adc1d924836..59f5cc1b53b26 100644 --- a/app/code/Magento/Catalog/Block/Product/ListProduct.php +++ b/app/code/Magento/Catalog/Block/Product/ListProduct.php @@ -355,6 +355,7 @@ public function getIdentities() } foreach ($this->_getProductCollection() as $item) { + // phpcs:ignore Magento2.Performance.ForeachArrayMerge $identities = array_merge($identities, $item->getIdentities()); }