Skip to content

Commit 602ba15

Browse files
authored
Merge pull request #3156 from magento-chaika/chaika_sept_23
[Chaika] bugfixes 2.3
2 parents 6c529ec + 526b0c0 commit 602ba15

File tree

12 files changed

+202
-55
lines changed

12 files changed

+202
-55
lines changed

app/code/Magento/Backend/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_Backend" >
9+
<module name="Magento_Backend">
1010
<sequence>
1111
<module name="Magento_Directory"/>
1212
</sequence>

app/code/Magento/Eav/etc/module.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<module name="Magento_Eav" >
1010
<sequence>
1111
<module name="Magento_Store"/>
12+
<module name="Magento_Theme"/>
1213
</sequence>
1314
</module>
1415
</config>

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

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ 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-
5851
/**
5952
* Construct
6053
*
@@ -75,8 +68,7 @@ public function __construct(
7568
}
7669

7770
/**
78-
* Initialize resource model
79-
* Get tablename from config
71+
* Initialize resource model. Get tablename from config
8072
*
8173
* @return void
8274
*/
@@ -143,24 +135,22 @@ public function loadByCustomerData(\Magento\Customer\Api\Data\CustomerInterface
143135
return $result;
144136
}
145137

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-
}
138+
$select = $this->connection
139+
->select()
140+
->from($this->getMainTable())
141+
->where('subscriber_email=:subscriber_email and store_id=:store_id');
142+
143+
$result = $this->connection
144+
->fetchRow(
145+
$select,
146+
[
147+
'subscriber_email' => $customer->getEmail(),
148+
'store_id' => $customer->getStoreId()
149+
]
150+
);
151+
152+
if ($result) {
153+
return $result;
164154
}
165155

166156
return [];

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

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
use Magento\Customer\Api\CustomerRepositoryInterface;
1010
use Magento\Framework\Exception\MailException;
1111
use Magento\Framework\Exception\NoSuchEntityException;
12+
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
13+
use Magento\Framework\Api\DataObjectHelper;
14+
use Magento\Framework\App\ObjectManager;
1215

1316
/**
1417
* Subscriber model
@@ -127,6 +130,16 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel
127130
*/
128131
protected $inlineTranslation;
129132

133+
/**
134+
* @var CustomerInterfaceFactory
135+
*/
136+
private $customerFactory;
137+
138+
/**
139+
* @var DataObjectHelper
140+
*/
141+
private $dataObjectHelper;
142+
130143
/**
131144
* Initialize dependencies.
132145
*
@@ -144,6 +157,8 @@ class Subscriber extends \Magento\Framework\Model\AbstractModel
144157
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
145158
* @param array $data
146159
* @param \Magento\Framework\Stdlib\DateTime\DateTime|null $dateTime
160+
* @param CustomerInterfaceFactory|null $customerFactory
161+
* @param DataObjectHelper|null $dataObjectHelper
147162
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
148163
*/
149164
public function __construct(
@@ -160,7 +175,9 @@ public function __construct(
160175
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
161176
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
162177
array $data = [],
163-
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime = null
178+
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime = null,
179+
CustomerInterfaceFactory $customerFactory = null,
180+
DataObjectHelper $dataObjectHelper = null
164181
) {
165182
$this->_newsletterData = $newsletterData;
166183
$this->_scopeConfig = $scopeConfig;
@@ -170,6 +187,10 @@ public function __construct(
170187
$this->dateTime = $dateTime ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
171188
\Magento\Framework\Stdlib\DateTime\DateTime::class
172189
);
190+
$this->customerFactory = $customerFactory ?: ObjectManager::getInstance()
191+
->get(CustomerInterfaceFactory::class);
192+
$this->dataObjectHelper = $dataObjectHelper ?: ObjectManager::getInstance()
193+
->get(DataObjectHelper::class);
173194
$this->customerRepository = $customerRepository;
174195
$this->customerAccountManagement = $customerAccountManagement;
175196
$this->inlineTranslation = $inlineTranslation;
@@ -346,7 +367,17 @@ public function isSubscribed()
346367
*/
347368
public function loadByEmail($subscriberEmail)
348369
{
349-
$this->addData($this->getResource()->loadByEmail($subscriberEmail));
370+
$storeId = $this->_storeManager->getStore()->getId();
371+
$customerData = ['store_id' => $storeId, 'email'=> $subscriberEmail];
372+
373+
/** @var \Magento\Customer\Api\Data\CustomerInterface $customer */
374+
$customer = $this->customerFactory->create();
375+
$this->dataObjectHelper->populateWithArray(
376+
$customer,
377+
$customerData,
378+
\Magento\Customer\Api\Data\CustomerInterface::class
379+
);
380+
$this->addData($this->getResource()->loadByCustomerData($customer));
350381
return $this;
351382
}
352383

@@ -497,7 +528,7 @@ public function subscribeCustomerById($customerId)
497528
}
498529

499530
/**
500-
* unsubscribe the customer with the id provided
531+
* Unsubscribe the customer with the id provided
501532
*
502533
* @param int $customerId
503534
* @return $this

app/code/Magento/Newsletter/Test/Unit/Model/SubscriberTest.php

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ class SubscriberTest extends \PHPUnit\Framework\TestCase
6262
*/
6363
protected $objectManager;
6464

65+
/**
66+
* @var \Magento\Framework\Api\DataObjectHelper|\PHPUnit_Framework_MockObject_MockObject
67+
*/
68+
private $dataObjectHelper;
69+
70+
/**
71+
* @var \Magento\Customer\Api\Data\CustomerInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
72+
*/
73+
private $customerFactory;
74+
6575
/**
6676
* @var \Magento\Newsletter\Model\Subscriber
6777
*/
@@ -97,6 +107,14 @@ protected function setUp()
97107
]);
98108
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
99109

110+
$this->customerFactory = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterfaceFactory::class)
111+
->setMethods(['create'])
112+
->disableOriginalConstructor()
113+
->getMock();
114+
$this->dataObjectHelper = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class)
115+
->disableOriginalConstructor()
116+
->getMock();
117+
100118
$this->subscriber = $this->objectManager->getObject(
101119
\Magento\Newsletter\Model\Subscriber::class,
102120
[
@@ -108,15 +126,31 @@ protected function setUp()
108126
'customerRepository' => $this->customerRepository,
109127
'customerAccountManagement' => $this->customerAccountManagement,
110128
'inlineTranslation' => $this->inlineTranslation,
111-
'resource' => $this->resource
129+
'resource' => $this->resource,
130+
'customerFactory' => $this->customerFactory,
131+
'dataObjectHelper' => $this->dataObjectHelper
112132
]
113133
);
114134
}
115135

116136
public function testSubscribe()
117137
{
118138
$email = 'subscriber_email@magento.com';
119-
$this->resource->expects($this->any())->method('loadByEmail')->willReturn(
139+
$storeId = 1;
140+
$customerData = ['store_id' => $storeId, 'email' => $email];
141+
$storeModel = $this->getMockBuilder(\Magento\Store\Model\Store::class)
142+
->disableOriginalConstructor()
143+
->getMock();
144+
$this->storeManager->expects($this->any())->method('getStore')->willReturn($storeModel);
145+
$storeModel->expects($this->any())->method('getId')->willReturn($storeId);
146+
$customer = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class);
147+
$this->customerFactory->expects($this->once())->method('create')->willReturn($customer);
148+
$this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with(
149+
$customer,
150+
$customerData,
151+
\Magento\Customer\Api\Data\CustomerInterface::class
152+
);
153+
$this->resource->expects($this->any())->method('loadByCustomerData')->with($customer)->willReturn(
120154
[
121155
'subscriber_status' => Subscriber::STATUS_UNSUBSCRIBED,
122156
'subscriber_email' => $email,
@@ -130,7 +164,7 @@ public function testSubscribe()
130164
$this->customerSession->expects($this->any())->method('getCustomerId')->willReturn(1);
131165
$customerDataModel->expects($this->any())->method('getEmail')->willReturn($email);
132166
$this->customerRepository->expects($this->any())->method('getById')->willReturn($customerDataModel);
133-
$customerDataModel->expects($this->any())->method('getStoreId')->willReturn(1);
167+
$customerDataModel->expects($this->any())->method('getStoreId')->willReturn($storeId);
134168
$customerDataModel->expects($this->any())->method('getId')->willReturn(1);
135169
$this->sendEmailCheck();
136170
$this->resource->expects($this->atLeastOnce())->method('save')->willReturnSelf();
@@ -141,7 +175,21 @@ public function testSubscribe()
141175
public function testSubscribeNotLoggedIn()
142176
{
143177
$email = 'subscriber_email@magento.com';
144-
$this->resource->expects($this->any())->method('loadByEmail')->willReturn(
178+
$storeId = 1;
179+
$customerData = ['store_id' => $storeId, 'email' => $email];
180+
$storeModel = $this->getMockBuilder(\Magento\Store\Model\Store::class)
181+
->disableOriginalConstructor()
182+
->getMock();
183+
$this->storeManager->expects($this->any())->method('getStore')->willReturn($storeModel);
184+
$storeModel->expects($this->any())->method('getId')->willReturn($storeId);
185+
$customer = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class);
186+
$this->customerFactory->expects($this->once())->method('create')->willReturn($customer);
187+
$this->dataObjectHelper->expects($this->once())->method('populateWithArray')->with(
188+
$customer,
189+
$customerData,
190+
\Magento\Customer\Api\Data\CustomerInterface::class
191+
);
192+
$this->resource->expects($this->any())->method('loadByCustomerData')->with($customer)->willReturn(
145193
[
146194
'subscriber_status' => Subscriber::STATUS_UNSUBSCRIBED,
147195
'subscriber_email' => $email,
@@ -155,7 +203,7 @@ public function testSubscribeNotLoggedIn()
155203
$this->customerSession->expects($this->any())->method('getCustomerId')->willReturn(1);
156204
$customerDataModel->expects($this->any())->method('getEmail')->willReturn($email);
157205
$this->customerRepository->expects($this->any())->method('getById')->willReturn($customerDataModel);
158-
$customerDataModel->expects($this->any())->method('getStoreId')->willReturn(1);
206+
$customerDataModel->expects($this->any())->method('getStoreId')->willReturn($storeId);
159207
$customerDataModel->expects($this->any())->method('getId')->willReturn(1);
160208
$this->sendEmailCheck();
161209
$this->resource->expects($this->atLeastOnce())->method('save')->willReturnSelf();

app/code/Magento/Reports/Block/Adminhtml/Grid.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ protected function _prepareCollection()
127127
* Validate from and to date
128128
*/
129129
try {
130-
$from = $this->_localeDate->scopeDate(null, $this->getFilter('report_from'), false);
131-
$to = $this->_localeDate->scopeDate(null, $this->getFilter('report_to'), false);
130+
$from = $this->_localeDate->date($this->getFilter('report_from'), null, false, false);
131+
$to = $this->_localeDate->date($this->getFilter('report_to'), null, false, false);
132132

133133
$collection->setInterval($from, $to);
134134
} catch (\Exception $e) {
@@ -215,8 +215,8 @@ public function setStoreSwitcherVisibility($visible = true)
215215

216216
/**
217217
* Return visibility of store switcher
218-
* @codeCoverageIgnore
219218
*
219+
* @codeCoverageIgnore
220220
* @return bool
221221
* @SuppressWarnings(PHPMD.BooleanGetMethodName)
222222
*/
@@ -227,8 +227,8 @@ public function getStoreSwitcherVisibility()
227227

228228
/**
229229
* Return store switcher html
230-
* @codeCoverageIgnore
231230
*
231+
* @codeCoverageIgnore
232232
* @return string
233233
*/
234234
public function getStoreSwitcherHtml()
@@ -250,8 +250,8 @@ public function setDateFilterVisibility($visible = true)
250250

251251
/**
252252
* Return visibility of date filter
253-
* @codeCoverageIgnore
254253
*
254+
* @codeCoverageIgnore
255255
* @return bool
256256
* @SuppressWarnings(PHPMD.BooleanGetMethodName)
257257
*/
@@ -262,8 +262,8 @@ public function getDateFilterVisibility()
262262

263263
/**
264264
* Return date filter html
265-
* @codeCoverageIgnore
266265
*
266+
* @codeCoverageIgnore
267267
* @return string
268268
*/
269269
public function getDateFilterHtml()
@@ -293,8 +293,8 @@ public function getDateFormat()
293293

294294
/**
295295
* Return refresh button html
296-
* @codeCoverageIgnore
297296
*
297+
* @codeCoverageIgnore
298298
* @return string
299299
*/
300300
public function getRefreshButtonHtml()
@@ -346,8 +346,8 @@ public function setSubReportSize($size)
346346

347347
/**
348348
* Return sub-report rows count
349-
* @codeCoverageIgnore
350349
*
350+
* @codeCoverageIgnore
351351
* @return int
352352
*/
353353
public function getSubReportSize()

app/code/Magento/User/etc/module.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<module name="Magento_User" >
1010
<sequence>
1111
<module name="Magento_Backend"/>
12+
<module name="Magento_Config"/>
1213
</sequence>
1314
</module>
1415
</config>

app/design/frontend/Magento/luma/Magento_Rma/web/css/source/_module.less

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@
4040
&:extend(.abs-status all);
4141
}
4242

43+
.table-wrapper.table-returns {
44+
.returns-details {
45+
&.hidden {
46+
display: none;
47+
}
48+
}
49+
}
50+
4351
.block-returns-comments {
4452
.returns-comments {
4553
dt,

dev/tests/integration/testsuite/Magento/Newsletter/Model/Plugin/PluginTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ public function testCustomerCreated()
6363
->setFirstname('Firstname')
6464
->setLastname('Lastname')
6565
->setEmail('customer_two@example.com');
66-
$this->customerRepository->save(
66+
$createdCustomer = $this->customerRepository->save(
6767
$customerDataObject,
6868
$this->accountManagement->getPasswordHash('password')
6969
);
7070

7171
$subscriber->loadByEmail('customer_two@example.com');
7272
$this->assertTrue($subscriber->isSubscribed());
73-
$this->assertEquals(0, (int)$subscriber->getCustomerId());
73+
$this->assertEquals((int)$createdCustomer->getId(), (int)$subscriber->getCustomerId());
7474
}
7575

7676
/**

0 commit comments

Comments
 (0)