Skip to content

Commit 8833cd2

Browse files
committed
MC-37934: Unexpected behavior of "Manage Shopping Cart" regarding "Products in the Comparison List"
1 parent a7180c2 commit 8833cd2

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

app/code/Magento/Reports/Model/ResourceModel/Event.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ public function applyLogToCollection(
9393
$skipIds = []
9494
) {
9595
$idFieldName = $collection->getResource()->getIdFieldName();
96-
$predefinedStoreIds = ($collection->getStoreId() === null) ?: [$collection->getStoreId()];
96+
$predefinedStoreIds = ($collection->getStoreId() === null)
97+
? null
98+
: [$collection->getStoreId()];
9799

98100
$derivedSelect = $this->getConnection()
99101
->select()

app/code/Magento/Reports/Test/Unit/Model/ResourceModel/EventTest.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,13 @@ public function testUpdateCustomerTypeWithType()
134134
}
135135

136136
/**
137+
* @dataProvider getApplyLogToCollectionDataProvider
138+
* @param null|array $storeId
139+
* @param null|array $storeIdSelect
140+
*
137141
* @return void
138142
*/
139-
public function testApplyLogToCollection()
143+
public function testApplyLogToCollection($storeId, $storeIdSelect)
140144
{
141145
$derivedSelect = 'SELECT * FROM table';
142146
$idFieldName = 'IdFieldName';
@@ -160,6 +164,7 @@ public function testApplyLogToCollection()
160164
->willReturnSelf();
161165

162166
$collectionMock = $this->getMockBuilder(AbstractDb::class)
167+
->setMethods(['getResource', 'getIdFieldName', 'getSelect', 'getStoreId'])
163168
->disableOriginalConstructor()
164169
->getMock();
165170
$collectionMock
@@ -177,7 +182,7 @@ public function testApplyLogToCollection()
177182
$collectionMock
178183
->expects($this->any())
179184
->method('getStoreId')
180-
->willReturn(1);
185+
->willReturn($storeId);
181186

182187
$selectMock = $this->getMockBuilder(Select::class)
183188
->disableOriginalConstructor()
@@ -199,6 +204,16 @@ public function testApplyLogToCollection()
199204
->expects($this->any())
200205
->method('__toString')
201206
->willReturn($derivedSelect);
207+
$selectMock
208+
->expects($this->any())
209+
->method('where')
210+
->withConsecutive([
211+
['event_type_id = ?', 1],
212+
['subject_id = ?', 1],
213+
['subtype = ?', 1],
214+
['store_id IN(?)', $storeIdSelect]
215+
])
216+
->willReturn($selectMock);
202217

203218
$this->connectionMock
204219
->expects($this->once())
@@ -213,6 +228,16 @@ public function testApplyLogToCollection()
213228
$this->event->applyLogToCollection($collectionMock, 1, 1, 1);
214229
}
215230

231+
/**
232+
* @return array
233+
*/
234+
public function getApplyLogToCollectionDataProvider()
235+
{
236+
return [
237+
['storeId' => 1, 'storeIdSelect' => [1]],
238+
['storeId' => null, 'storeIdSelect' => [1]],
239+
];
240+
}
216241
/**
217242
* @return void
218243
*/

0 commit comments

Comments
 (0)