Skip to content

Commit 4faa4c9

Browse files
merge magento/2.3-develop into magento-trigger/MC-17627
2 parents a9b2f00 + 262876b commit 4faa4c9

File tree

95 files changed

+3179
-706
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+3179
-706
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminAssociateBundleProductToWebsitesTest">
12+
<annotations>
13+
<features value="Bundle"/>
14+
<stories value="Create/Edit bundle product in Admin"/>
15+
<title value="Admin should be able to associate bundle product to websites"/>
16+
<description value="Admin should be able to associate bundle product to websites"/>
17+
<testCaseId value="MC-3344"/>
18+
<severity value="CRITICAL"/>
19+
<group value="bundle"/>
20+
<group value="catalog"/>
21+
</annotations>
22+
<before>
23+
<!-- Configure Store URLs -->
24+
<magentoCLI command="config:set {{StorefrontEnableAddStoreCodeToUrls.path}} {{StorefrontEnableAddStoreCodeToUrls.value}}" stepKey="setAddStoreCodeToUrlsToYes"/>
25+
26+
<!-- Create category -->
27+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
28+
29+
<!-- Create Simple product -->
30+
<createData entity="SimpleProduct2" stepKey="createSimpleProduct"/>
31+
32+
<!-- Create Bundle product -->
33+
<createData entity="ApiBundleProductPriceViewRange" stepKey="createBundleProduct">
34+
<requiredEntity createDataKey="createCategory"/>
35+
</createData>
36+
<createData entity="DropDownBundleOption" stepKey="bundleOption">
37+
<requiredEntity createDataKey="createBundleProduct"/>
38+
</createData>
39+
<createData entity="ApiBundleLink" stepKey="createNewBundleLink">
40+
<requiredEntity createDataKey="createBundleProduct"/>
41+
<requiredEntity createDataKey="bundleOption"/>
42+
<requiredEntity createDataKey="createSimpleProduct"/>
43+
</createData>
44+
45+
<!-- Reindex -->
46+
<magentoCLI command="indexer:reindex" stepKey="reindex"/>
47+
48+
<!-- Login as admin -->
49+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
50+
51+
<!--Create website-->
52+
<actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="createSecondWebsite">
53+
<argument name="newWebsiteName" value="{{secondCustomWebsite.name}}"/>
54+
<argument name="websiteCode" value="{{secondCustomWebsite.code}}"/>
55+
</actionGroup>
56+
<!-- Create second store -->
57+
<actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="createSecondStoreGroup">
58+
<argument name="website" value="{{secondCustomWebsite.name}}"/>
59+
<argument name="storeGroupName" value="{{SecondStoreGroupUnique.name}}"/>
60+
<argument name="storeGroupCode" value="{{SecondStoreGroupUnique.code}}"/>
61+
</actionGroup>
62+
<!-- Create second store view -->
63+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createSecondStoreView">
64+
<argument name="StoreGroup" value="SecondStoreGroupUnique"/>
65+
<argument name="customStore" value="SecondStoreUnique"/>
66+
</actionGroup>
67+
</before>
68+
<after>
69+
<!-- Disabled Store URLs -->
70+
<magentoCLI command="config:set {{StorefrontDisableAddStoreCodeToUrls.path}} {{StorefrontDisableAddStoreCodeToUrls.value}}" stepKey="setAddStoreCodeToUrlsToNo"/>
71+
72+
<!-- Delete simple product -->
73+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteSimpleProduct"/>
74+
<!-- Delete bundle product -->
75+
<deleteData createDataKey="createBundleProduct" stepKey="deleteBundleProduct"/>
76+
77+
<!-- Delete second website -->
78+
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite">
79+
<argument name="websiteName" value="{{secondCustomWebsite.name}}"/>
80+
</actionGroup>
81+
82+
<actionGroup ref="NavigateToAndResetProductGridToDefaultView" stepKey="resetProductGridFilter"/>
83+
84+
<!-- Admin logout -->
85+
<actionGroup ref="logout" stepKey="adminLogout"/>
86+
</after>
87+
88+
<!-- Open product page and assign grouped project to second website -->
89+
<actionGroup ref="filterAndSelectProduct" stepKey="openAdminProductPage">
90+
<argument name="productSku" value="$$createBundleProduct.sku$$"/>
91+
</actionGroup>
92+
<actionGroup ref="AdminAssignProductInWebsiteActionGroup" stepKey="assignProductToSecondWebsite">
93+
<argument name="website" value="{{secondCustomWebsite.name}}"/>
94+
</actionGroup>
95+
<actionGroup ref="AdminUnassignProductInWebsiteActionGroup" stepKey="unassignProductFromDefaultWebsite">
96+
<argument name="website" value="{{_defaultWebsite.name}}"/>
97+
</actionGroup>
98+
<actionGroup ref="saveProductForm" stepKey="saveGroupedProduct"/>
99+
100+
<!-- Assert product is assigned to Second website -->
101+
<actionGroup ref="AssertProductIsAssignedToWebsite" stepKey="seeCustomWebsiteIsChecked">
102+
<argument name="website" value="{{secondCustomWebsite.name}}"/>
103+
</actionGroup>
104+
105+
<!-- Assert product is not assigned to Main website -->
106+
<actionGroup ref="AssertProductIsNotAssignedToWebsite" stepKey="seeMainWebsiteIsNotChecked">
107+
<argument name="website" value="{{_defaultWebsite.name}}"/>
108+
</actionGroup>
109+
110+
<!-- Go to frontend and open product on Main website -->
111+
<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openProductPage">
112+
<argument name="productUrl" value="$$createBundleProduct.custom_attributes[url_key]$$"/>
113+
</actionGroup>
114+
115+
<!-- Assert 404 page -->
116+
<actionGroup ref="StorefrontAssertPageNotFoundErrorOnProductDetailPageActionGroup" stepKey="assertPageNotFoundError">
117+
<argument name="product" value="$$createBundleProduct$$"/>
118+
</actionGroup>
119+
120+
<!-- Assert product is present at Second website -->
121+
<actionGroup ref="StorefrontOpenProductPageUsingStoreCodeInUrlActionGroup" stepKey="openProductPageUsingStoreCodeInUrl">
122+
<argument name="product" value="$$createBundleProduct$$"/>
123+
<argument name="storeView" value="SecondStoreUnique"/>
124+
</actionGroup>
125+
</test>
126+
</tests>

app/code/Magento/Captcha/Observer/CheckContactUsFormObserver.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Framework\App\Request\DataPersistorInterface;
1010
use Magento\Framework\App\ObjectManager;
1111

12+
/**
13+
* Class CheckContactUsFormObserver
14+
*/
1215
class CheckContactUsFormObserver implements ObserverInterface
1316
{
1417
/**
@@ -76,7 +79,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
7679
/** @var \Magento\Framework\App\Action\Action $controller */
7780
$controller = $observer->getControllerAction();
7881
if (!$captcha->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
79-
$this->messageManager->addError(__('Incorrect CAPTCHA.'));
82+
$this->messageManager->addErrorMessage(__('Incorrect CAPTCHA.'));
8083
$this->getDataPersistor()->set($formId, $controller->getRequest()->getPostValue());
8184
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
8285
$this->redirect->redirect($controller->getResponse(), 'contact/index/index');

app/code/Magento/Captcha/Observer/CheckForgotpasswordObserver.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
use Magento\Framework\Event\ObserverInterface;
99

10+
/**
11+
* Class CheckForgotpasswordObserver
12+
*/
1013
class CheckForgotpasswordObserver implements ObserverInterface
1114
{
1215
/**
@@ -69,7 +72,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
6972
/** @var \Magento\Framework\App\Action\Action $controller */
7073
$controller = $observer->getControllerAction();
7174
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
72-
$this->messageManager->addError(__('Incorrect CAPTCHA'));
75+
$this->messageManager->addErrorMessage(__('Incorrect CAPTCHA'));
7376
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
7477
$this->redirect->redirect($controller->getResponse(), '*/*/forgotpassword');
7578
}

app/code/Magento/Captcha/Observer/CheckUserCreateObserver.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
use Magento\Framework\Event\ObserverInterface;
99

10+
/**
11+
* Class CheckUserCreateObserver
12+
*
13+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
14+
*/
1015
class CheckUserCreateObserver implements ObserverInterface
1116
{
1217
/**
@@ -86,7 +91,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
8691
/** @var \Magento\Framework\App\Action\Action $controller */
8792
$controller = $observer->getControllerAction();
8893
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
89-
$this->messageManager->addError(__('Incorrect CAPTCHA'));
94+
$this->messageManager->addErrorMessage(__('Incorrect CAPTCHA'));
9095
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
9196
$this->_session->setCustomerFormData($controller->getRequest()->getPostValue());
9297
$url = $this->_urlManager->getUrl('*/*/create', ['_nosecret' => true]);

app/code/Magento/Captcha/Observer/CheckUserEditObserver.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
use Magento\Framework\App\Config\ScopeConfigInterface;
1212

1313
/**
14-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
14+
* Class CheckUserEditObserver
15+
*
16+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1517
*/
1618
class CheckUserEditObserver implements ObserverInterface
1719
{
18-
/**
19-
* Form ID
20-
*/
2120
const FORM_ID = 'user_edit';
2221

2322
/**
@@ -96,7 +95,8 @@ public function __construct(
9695
* Check Captcha On Forgot Password Page
9796
*
9897
* @param \Magento\Framework\Event\Observer $observer
99-
* @return $this
98+
* @return $this|void
99+
* @throws \Magento\Framework\Exception\SessionException
100100
*/
101101
public function execute(\Magento\Framework\Event\Observer $observer)
102102
{
@@ -119,9 +119,9 @@ public function execute(\Magento\Framework\Event\Observer $observer)
119119
'The account is locked. Please wait and try again or contact %1.',
120120
$this->scopeConfig->getValue('contact/email/recipient_email')
121121
);
122-
$this->messageManager->addError($message);
122+
$this->messageManager->addErrorMessage($message);
123123
}
124-
$this->messageManager->addError(__('Incorrect CAPTCHA'));
124+
$this->messageManager->addErrorMessage(__('Incorrect CAPTCHA'));
125125
$this->actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
126126
$this->redirect->redirect($controller->getResponse(), '*/*/edit');
127127
}

app/code/Magento/Captcha/Observer/CheckUserForgotPasswordBackendObserver.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
use Magento\Framework\Event\ObserverInterface;
99

10+
/**
11+
* Class CheckUserForgotPasswordBackendObserver
12+
*
13+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
14+
*/
1015
class CheckUserForgotPasswordBackendObserver implements ObserverInterface
1116
{
1217
/**
@@ -76,7 +81,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
7681
) {
7782
$this->_session->setEmail((string)$controller->getRequest()->getPost('email'));
7883
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
79-
$this->messageManager->addError(__('Incorrect CAPTCHA'));
84+
$this->messageManager->addErrorMessage(__('Incorrect CAPTCHA'));
8085
$controller->getResponse()->setRedirect(
8186
$controller->getUrl('*/*/forgotpassword', ['_nosecret' => true])
8287
);

app/code/Magento/Captcha/Observer/CheckUserLoginObserver.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
namespace Magento\Captcha\Observer;
88

9+
use Magento\Customer\Api\CustomerRepositoryInterface;
910
use Magento\Customer\Model\AuthenticationInterface;
1011
use Magento\Framework\Event\ObserverInterface;
1112
use Magento\Framework\Exception\NoSuchEntityException;
12-
use Magento\Customer\Api\CustomerRepositoryInterface;
1313

1414
/**
1515
* Check captcha on user login page observer.
@@ -64,6 +64,8 @@ class CheckUserLoginObserver implements ObserverInterface
6464
protected $authentication;
6565

6666
/**
67+
* CheckUserLoginObserver constructor.
68+
*
6769
* @param \Magento\Captcha\Helper\Data $helper
6870
* @param \Magento\Framework\App\ActionFlag $actionFlag
6971
* @param \Magento\Framework\Message\ManagerInterface $messageManager
@@ -125,8 +127,7 @@ private function getAuthentication()
125127
* Check captcha on user login page
126128
*
127129
* @param \Magento\Framework\Event\Observer $observer
128-
* @throws NoSuchEntityException
129-
* @return $this
130+
* @return $this|void
130131
*/
131132
public function execute(\Magento\Framework\Event\Observer $observer)
132133
{
@@ -143,10 +144,11 @@ public function execute(\Magento\Framework\Event\Observer $observer)
143144
try {
144145
$customer = $this->getCustomerRepository()->get($login);
145146
$this->getAuthentication()->processAuthenticationFailure($customer->getId());
147+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
146148
} catch (NoSuchEntityException $e) {
147149
//do nothing as customer existence is validated later in authenticate method
148150
}
149-
$this->messageManager->addError(__('Incorrect CAPTCHA'));
151+
$this->messageManager->addErrorMessage(__('Incorrect CAPTCHA'));
150152
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
151153
$this->_session->setUsername($login);
152154
$beforeUrl = $this->_session->getBeforeAuthUrl();

app/code/Magento/Captcha/Test/Unit/Observer/CheckContactUsFormObserverTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ protected function setUp()
6969
$this->messageManagerMock = $this->createMock(\Magento\Framework\Message\ManagerInterface::class);
7070
$this->redirectMock = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class);
7171
$this->captchaStringResolverMock = $this->createMock(\Magento\Captcha\Observer\CaptchaStringResolver::class);
72-
$this->sessionMock = $this->createPartialMock(\Magento\Framework\Session\SessionManager::class, ['addError']);
72+
$this->sessionMock = $this->createPartialMock(
73+
\Magento\Framework\Session\SessionManager::class,
74+
['addErrorMessage']
75+
);
7376
$this->dataPersistorMock = $this->getMockBuilder(\Magento\Framework\App\Request\DataPersistorInterface::class)
7477
->getMockForAbstractClass();
7578

@@ -116,7 +119,7 @@ public function testCheckContactUsFormWhenCaptchaIsRequiredAndValid()
116119
$this->helperMock->expects($this->any())
117120
->method('getCaptcha')
118121
->with($formId)->willReturn($this->captchaMock);
119-
$this->sessionMock->expects($this->never())->method('addError');
122+
$this->sessionMock->expects($this->never())->method('addErrorMessage');
120123

121124
$this->checkContactUsFormObserver->execute(
122125
new \Magento\Framework\Event\Observer(['controller_action' => $controller])
@@ -163,7 +166,7 @@ public function testCheckContactUsFormRedirectsCustomerWithWarningMessageWhenCap
163166
->method('getCaptcha')
164167
->with($formId)
165168
->willReturn($this->captchaMock);
166-
$this->messageManagerMock->expects($this->once())->method('addError')->with($warningMessage);
169+
$this->messageManagerMock->expects($this->once())->method('addErrorMessage')->with($warningMessage);
167170
$this->actionFlagMock->expects($this->once())
168171
->method('set')
169172
->with('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);

app/code/Magento/Captcha/Test/Unit/Observer/CheckForgotpasswordObserverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function testCheckForgotpasswordRedirects()
138138
)->will(
139139
$this->returnValue($this->_captcha)
140140
);
141-
$this->_messageManager->expects($this->once())->method('addError')->with($warningMessage);
141+
$this->_messageManager->expects($this->once())->method('addErrorMessage')->with($warningMessage);
142142
$this->_actionFlag->expects(
143143
$this->once()
144144
)->method(

app/code/Magento/Captcha/Test/Unit/Observer/CheckUserCreateObserverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function testCheckUserCreateRedirectsError()
151151
)->will(
152152
$this->returnValue($this->_captcha)
153153
);
154-
$this->_messageManager->expects($this->once())->method('addError')->with($warningMessage);
154+
$this->_messageManager->expects($this->once())->method('addErrorMessage')->with($warningMessage);
155155
$this->_actionFlag->expects(
156156
$this->once()
157157
)->method(

0 commit comments

Comments
 (0)