Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 4b88dc0

Browse files
Merge pull request #34 from magento-epam/MAGETWO-91701-V2
Magetwo 91701 v2
2 parents 91b5bf0 + e3a9ac2 commit 4b88dc0

File tree

5 files changed

+355
-16
lines changed

5 files changed

+355
-16
lines changed

app/code/Magento/Newsletter/Model/ResourceModel/Subscriber.php

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ class Subscriber extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
4848
*/
4949
protected $mathRandom;
5050

51+
/**
52+
* Guest customer id
53+
*
54+
* @var int
55+
*/
56+
private $guestCustomerId = 0;
57+
5158
/**
5259
* Construct
5360
*
@@ -136,22 +143,24 @@ public function loadByCustomerData(\Magento\Customer\Api\Data\CustomerInterface
136143
return $result;
137144
}
138145

139-
$select = $this->connection
140-
->select()
141-
->from($this->getMainTable())
142-
->where('subscriber_email=:subscriber_email and store_id=:store_id');
143-
144-
$result = $this->connection
145-
->fetchRow(
146-
$select,
147-
[
148-
'subscriber_email' => $customer->getEmail(),
149-
'store_id' => $customer->getStoreId()
150-
]
151-
);
152-
153-
if ($result) {
154-
return $result;
146+
if ($customer->getId() === $this->guestCustomerId) {
147+
$select = $this->connection
148+
->select()
149+
->from($this->getMainTable())
150+
->where('subscriber_email=:subscriber_email and store_id=:store_id');
151+
152+
$result = $this->connection
153+
->fetchRow(
154+
$select,
155+
[
156+
'subscriber_email' => $customer->getEmail(),
157+
'store_id' => $customer->getStoreId()
158+
]
159+
);
160+
161+
if ($result) {
162+
return $result;
163+
}
155164
}
156165

157166
return [];
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/actionGroupSchema.xsd">
10+
11+
<!--Go To Stores/All Stores-->
12+
<actionGroup name="GoToAllStores">
13+
<click stepKey="clickStoreItem" selector="{{Dashboard.storesItem}}"/>
14+
<waitForElementVisible selector="{{Dashboard.storesAllStoresItem}}" stepKey="waitForAllStoresItemBecomeAvailable"/>
15+
<click stepKey="clickAllStoreItem" selector="{{Dashboard.storesAllStoresItem}}"/>
16+
<waitForPageLoad stepKey="waitForStoresPageLoaded"/>
17+
</actionGroup>
18+
19+
<!--Create new website-->
20+
<actionGroup name="AdminCreateWebsite">
21+
<!--Fill required fields-->
22+
<click selector="{{AdminNewWebsiteSection.addWebSite}}" stepKey="clickOnCreateWebsiteButton"/>
23+
<waitForPageLoad stepKey="waitFormToBeOpened"/>
24+
<fillField selector="{{AdminNewWebsiteSection.name}}" userInput="{{AdminTestData.testData}}" stepKey="enterWebsiteName" />
25+
<fillField selector="{{AdminNewWebsiteSection.code}}" userInput="{{AdminTestData.testData}}" stepKey="enterWebsiteCode" />
26+
<click selector="{{AdminNewWebsiteActionsSection.saveWebsite}}" stepKey="clickSaveWebsite" />
27+
<waitForElementVisible selector="{{AdminStoresGridSection.websiteFilterTextField}}" stepKey="waitForStoreGridToReload"/>
28+
<see userInput="You saved the website." stepKey="seeSavedMessage" />
29+
</actionGroup>
30+
31+
<!--Create new store-->
32+
<actionGroup name="AdminCreateNewStore">
33+
<!--Fill required fields-->
34+
<click selector="{{AdminNewStoreGroupSection.create}}" stepKey="clickOnCreateStore"/>
35+
<waitForPageLoad stepKey="waitFormToBeOpened"/>
36+
<selectOption selector="{{AdminNewStoreGroupSection.storeGrpWebsiteDropdown}}" userInput="{{AdminTestData.testData}}" stepKey="selectWebsite" />
37+
<fillField selector="{{AdminNewStoreGroupSection.storeGrpNameTextField}}" userInput="{{AdminTestData.testData}}" stepKey="enterStoreGroupName" />
38+
<fillField selector="{{AdminNewStoreGroupSection.storeGrpCodeTextField}}" userInput="{{AdminTestData.testData}}" stepKey="enterStoreGroupCode" />
39+
<selectOption selector="{{AdminNewStoreGroupSection.storeRootCategoryDropdown}}" userInput="Default Category" stepKey="chooseRootCategory" />
40+
<click selector="{{AdminStoreGroupActionsSection.saveButton}}" stepKey="clickSaveStoreGroup" />
41+
<waitForElementVisible selector="{{AdminStoresGridSection.storeGrpFilterTextField}}" stepKey="waitForStoreGridReload"/>
42+
<see userInput="You saved the store." stepKey="seeSavedMessage" />
43+
</actionGroup>
44+
45+
<!--Create store view-->
46+
<actionGroup name="AdminCreateStoreView">
47+
<!--Fill required fields-->
48+
<click selector="{{AdminNewStoreSection.create}}" stepKey="clickOnCreateStoreView"/>
49+
<waitForPageLoad stepKey="waitFormToBeOpened"/>
50+
<selectOption selector="{{AdminNewStoreSection.storeGrpDropdown}}" userInput="{{AdminTestData.testData}}" stepKey="selectStore" />
51+
<fillField selector="{{AdminNewStoreSection.storeNameTextField}}" userInput="{{AdminTestData.testData}}" stepKey="enterStoreViewName" />
52+
<fillField selector="{{AdminNewStoreSection.storeCodeTextField}}" userInput="{{AdminTestData.testData}}" stepKey="enterStoreViewCode" />
53+
<selectOption selector="{{AdminNewStoreSection.statusDropdown}}" userInput="Enabled" stepKey="setStatus" />
54+
<click selector="{{AdminNewStoreViewActionsSection.saveButton}}" stepKey="clickSaveStoreView" />
55+
<waitForElementVisible selector="{{AdminConfirmationModalSection.ok}}" stepKey="waitForModal" />
56+
<see selector="{{AdminConfirmationModalSection.title}}" userInput="Warning message" stepKey="seeWarning" />
57+
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="dismissModal" />
58+
<waitForElementVisible selector="{{AdminStoresGridSection.storeFilterTextField}}" stepKey="waitForPageReolad"/>
59+
<waitForElementVisible selector="{{AdminStoresGridSection.storeFilterTextField}}" stepKey="waitForPageReload"/>
60+
<see userInput="You saved the store view." stepKey="seeSavedMessage" />
61+
</actionGroup>
62+
63+
<!--Go to Stores -> Configuration -> Web.-->
64+
<actionGroup name="GoToStoresConfigurationWeb">
65+
<click stepKey="againClickStoreItem" selector="{{Dashboard.storesItem}}"/>
66+
<waitForElementVisible selector="{{Dashboard.storesConfigurationItem}}" stepKey="waitForAllStoreItemExtends"/>
67+
<click stepKey="clickConfigurationItem" selector="{{Dashboard.storesConfigurationItem}}"/>
68+
<waitForPageLoad stepKey="waitForStoresConfigurationPageLoaded"/>
69+
<click stepKey="clickWebItem" selector="{{AdminStoresConfigurationSection.webItem}}"/>
70+
<waitForPageLoad stepKey="waitForStoresConfigurationWebPageLoaded"/>
71+
</actionGroup>
72+
73+
<!--Select Yes in Add Store Code to Urls field.-->
74+
<actionGroup name="SelectYesInAddStoreCodeToUrlsField">
75+
<click stepKey="clickOpenUrlOptions" selector="{{AdminStoresConfigurationSection.openUrlOptions}}"/>
76+
<click stepKey="clickUseSystemValueCheckbox" selector="{{AdminStoresConfigurationSection.useSystemValueCheckbox}}"/>
77+
<selectOption selector="{{AdminStoresConfigurationSection.addStoreCodeToUrlsDropDown}}" userInput="Yes" stepKey="setAddStoreCodeToUrlsYes" />
78+
<click stepKey="clickSaveConfigButton" selector="{{AdminStoresConfigurationSection.saveConfigButton}}"/>
79+
<waitForPageLoad stepKey="waitForSaveConfig"/>
80+
<see stepKey="seeSavedConfigurationMessage" userInput="You saved the configuration."/>
81+
</actionGroup>
82+
83+
<!--Create an Account. Check Sign Up for Newsletter checkbox -->
84+
<actionGroup name="StorefrontCreateNewAccount">
85+
<fillField selector="{{StorefrontCustomerCreateFormSection.firstNameField}}" userInput="{{CreateUserData.firstName}}" stepKey="enterFirstName" />
86+
<fillField selector="{{StorefrontCustomerCreateFormSection.lastNameField}}" userInput="{{CreateUserData.lastName}}" stepKey="enterLastName" />
87+
<click selector="{{StorefrontCustomerCreateFormSection.signUpForNewsletter}}" stepKey="selectSignUpForNewsletterCheckbox"/>
88+
<fillField selector="{{StorefrontCustomerCreateFormSection.emailField}}" userInput="{{CreateUserData.firstName}}@magento.com" stepKey="enterEmail" />
89+
<fillField selector="{{StorefrontCustomerCreateFormSection.passwordField}}" userInput="{{CreateUserData.password}}" stepKey="enterPassword" />
90+
<fillField selector="{{StorefrontCustomerCreateFormSection.confirmPasswordField}}" userInput="{{CreateUserData.password}}" stepKey="confirmPassword" />
91+
<click stepKey="clickCreateAccountButton" selector="{{StorefrontCustomerCreateFormSection.createAccountButton}}"/>
92+
<waitForPageLoad stepKey="waitForMyAccountPageLoad"/>
93+
</actionGroup>
94+
95+
<!-- Sign out -->
96+
<actionGroup name="StorefrontSignOut">
97+
<click stepKey="clickCustomerNameItem" selector="{{CustomerMyAccountPage.customerName}}"/>
98+
<click stepKey="clickSignOutButton" selector="{{CustomerMyAccountPage.customerSignOut}}"/>
99+
<waitForPageLoad stepKey="waitForSignOut"/>
100+
</actionGroup>
101+
102+
<!--Create an Account. Uncheck Sign Up for Newsletter checkbox -->
103+
<actionGroup name="StorefrontCreateNewAccountNewsletterUnchecked">
104+
<click stepKey="clickCreateNewAccountButton" selector="{{CustomerMyAccountPage.createNewAccount}}"/>
105+
<waitForPageLoad stepKey="waitForCreateNewAccountPageLoaded"/>
106+
<fillField selector="{{StorefrontCustomerCreateFormSection.firstNameField}}" userInput="{{CreateUserData.firstName}}" stepKey="enterFirstName" />
107+
<fillField selector="{{StorefrontCustomerCreateFormSection.lastNameField}}" userInput="{{CreateUserData.lastName}}" stepKey="enterLastName" />
108+
<fillField selector="{{StorefrontCustomerCreateFormSection.emailField}}" userInput="{{CreateUserData.firstName}}@magento.com" stepKey="enterEmail" />
109+
<fillField selector="{{StorefrontCustomerCreateFormSection.passwordField}}" userInput="{{CreateUserData.password}}" stepKey="enterPassword" />
110+
<fillField selector="{{StorefrontCustomerCreateFormSection.confirmPasswordField}}" userInput="{{CreateUserData.password}}" stepKey="confirmPassword" />
111+
<click stepKey="clickCreateAccountButton" selector="{{StorefrontCustomerCreateFormSection.createAccountButton}}"/>
112+
<waitForPageLoad stepKey="waitForMyAccountPageLoad"/>
113+
<see userInput="Thank you for registering with" stepKey="seeValidRegistrationMessage"/>
114+
</actionGroup>
115+
116+
<!--Delete created Website -->
117+
<actionGroup name="AdminDeleteWebsite">
118+
<fillField stepKey="fillSearchWebsiteField" selector="{{AdminStoresGridSection.websiteFilterTextField}}" userInput="{{AdminTestData.testData}}"/>
119+
<click stepKey="clickSearchButton" selector="{{AdminStoresGridSection.searchButton}}"/>
120+
<see stepKey="verifyThatCorrectWebsiteFound" selector="{{AdminStoresGridSection.websiteNameInFirstRow}}" userInput="{{AdminTestData.testData}}"/>
121+
<click stepKey="clickEditExistingStoreRow" selector="{{AdminStoresGridSection.websiteNameInFirstRow}}"/>
122+
<waitForPageLoad stepKey="waitForStoreToLoad"/>
123+
<click stepKey="clickDeleteWebsiteButtonOnEditWebsitePage" selector="{{AdminStoresMainActionsSection.deleteButton}}"/>
124+
<selectOption stepKey="setCreateDbBackupToNo" selector="{{AdminStoresDeleteStoreGroupSection.createDbBackup}}" userInput="No"/>
125+
<click stepKey="clickDeleteWebsiteButton" selector="{{AdminStoresDeleteStoreGroupSection.deleteStoreGroupButton}}"/>
126+
<waitForElementVisible stepKey="waitForStoreGridToReload" selector="{{AdminStoresGridSection.websiteFilterTextField}}"/>
127+
<see stepKey="seeSavedMessage" userInput="You deleted the website."/>
128+
</actionGroup>
129+
130+
<!--Set Default config -->
131+
<actionGroup name="AdminSetDefaultConfig">
132+
<selectOption selector="{{AdminStoresConfigurationSection.addStoreCodeToUrlsDropDown}}" userInput="No" stepKey="setAddStoreCodeToUrlsNo" />
133+
<click stepKey="disableUseSystemValueCheckbox" selector="{{AdminStoresConfigurationSection.useSystemValueCheckbox}}"/>
134+
<click stepKey="clickDefaultConfigSaveButton" selector="{{AdminStoresConfigurationSection.saveConfigButton}}"/>
135+
<waitForPageLoad stepKey="waitForSaveConfig"/>
136+
<see stepKey="saveDefaultConfig" userInput="You saved the configuration."/>
137+
<click stepKey="clickOpenUrlOptions" selector="{{AdminStoresConfigurationSection.openUrlOptions}}"/>
138+
</actionGroup>
139+
140+
<!--Delete created Customer -->
141+
<actionGroup name="AdminDeleteCreatedCustomer">
142+
<click stepKey="clickCustomerItem" selector="{{Dashboard.customer}}"/>
143+
<wait stepKey="WaitForCustomerViewOpened" time="2"/>
144+
<click stepKey="clickCustomerAllCustomerItem" selector="{{Dashboard.customerAllCustomer}}"/>
145+
<waitForPageLoad stepKey="WaitForCustomerPageIsLoaded"/>
146+
<fillField stepKey="searchToKeyword" selector="{{AdminCustomerAccountInformationSection.searchToKeyword}}" userInput="{{CreateUserData.firstName}}"/>
147+
<click stepKey="clickSearchButton" selector="{{AdminCustomerAccountInformationSection.searchButton}}"/>
148+
<waitForElementVisible stepKey="waitForFiltering" selector="{{AdminCustomerAccountInformationSection.selectCustomer}}"/>
149+
<click selector="{{AdminCustomerAccountInformationSection.selectCustomer}}" stepKey="ClickOnCustomer"/>
150+
<click selector="{{AdminCustomerAccountInformationSection.actions}}" stepKey="ClickOnActions"/>
151+
<waitForElementVisible selector="{{AdminCustomerAccountInformationSection.delete}}" stepKey="waitForDeleteButtonAppeared"/>
152+
<click selector="{{AdminCustomerAccountInformationSection.delete}}" stepKey="ClickOnDelete"/>
153+
<waitForElementVisible selector="{{AdminCustomerAccountInformationSection.confirm}}" stepKey="waitForConfirmButtonAppeared"/>
154+
<click selector="{{AdminCustomerAccountInformationSection.confirm}}" stepKey="ClickToConfirm"/>
155+
<waitForPageLoad stepKey="waitClickToConfirmButton"/>
156+
<see stepKey="seeRecordsWereDeletedMessage" userInput="A total of 2 record(s) were deleted."/>
157+
<click stepKey="clickClearAllFilterButton" selector="{{AdminCustomerAccountInformationSection.clearAll}}"/>
158+
<!-- We need this wait to make sure that Active filters is clear (waitForElementNotVisible tag doesn't wait until clearing filters)-->
159+
<wait stepKey="waitToClearAllFilters" time="2"/>
160+
</actionGroup>
161+
162+
</actionGroups>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/DataGenerator/etc/dataProfileSchema.xsd">
11+
12+
<!-- For this Test, all data is the same. -->
13+
<entity name="AdminTestData" type="data">
14+
<data key="testData" unique="suffix">store2</data>
15+
</entity>
16+
17+
<entity name="CreateUserData" type="user">
18+
<data key="firstName" unique="suffix">John</data>
19+
<data key="lastName">Smith</data>
20+
<data key="password">Admin@123</data>
21+
</entity>
22+
23+
</entities>

0 commit comments

Comments
 (0)