@@ -134,9 +134,13 @@ public function testUpdateCustomerTypeWithType()
134
134
}
135
135
136
136
/**
137
+ * @dataProvider getApplyLogToCollectionDataProvider
138
+ * @param null|array $storeId
139
+ * @param null|array $storeIdSelect
140
+ *
137
141
* @return void
138
142
*/
139
- public function testApplyLogToCollection ()
143
+ public function testApplyLogToCollection ($ storeId , $ storeIdSelect )
140
144
{
141
145
$ derivedSelect = 'SELECT * FROM table ' ;
142
146
$ idFieldName = 'IdFieldName ' ;
@@ -160,6 +164,7 @@ public function testApplyLogToCollection()
160
164
->willReturnSelf ();
161
165
162
166
$ collectionMock = $ this ->getMockBuilder (AbstractDb::class)
167
+ ->setMethods (['getResource ' , 'getIdFieldName ' , 'getSelect ' , 'getStoreId ' ])
163
168
->disableOriginalConstructor ()
164
169
->getMock ();
165
170
$ collectionMock
@@ -177,7 +182,7 @@ public function testApplyLogToCollection()
177
182
$ collectionMock
178
183
->expects ($ this ->any ())
179
184
->method ('getStoreId ' )
180
- ->willReturn (1 );
185
+ ->willReturn ($ storeId );
181
186
182
187
$ selectMock = $ this ->getMockBuilder (Select::class)
183
188
->disableOriginalConstructor ()
@@ -199,6 +204,16 @@ public function testApplyLogToCollection()
199
204
->expects ($ this ->any ())
200
205
->method ('__toString ' )
201
206
->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 );
202
217
203
218
$ this ->connectionMock
204
219
->expects ($ this ->once ())
@@ -213,6 +228,16 @@ public function testApplyLogToCollection()
213
228
$ this ->event ->applyLogToCollection ($ collectionMock , 1 , 1 , 1 );
214
229
}
215
230
231
+ /**
232
+ * @return array
233
+ */
234
+ public function getApplyLogToCollectionDataProvider ()
235
+ {
236
+ return [
237
+ ['storeId ' => 1 , 'storeIdSelect ' => [1 ]],
238
+ ['storeId ' => null , 'storeIdSelect ' => [1 ]],
239
+ ];
240
+ }
216
241
/**
217
242
* @return void
218
243
*/
0 commit comments