@@ -107,10 +107,36 @@ protected function setUp(): void
107
107
);
108
108
}
109
109
110
+ /**
111
+ * Variation for UserIdentities.
112
+ *
113
+ * @return array
114
+ */
115
+ public function getUserIdentitiesCases (): array
116
+ {
117
+ return [
118
+ [
119
+ 'customerId ' => 1 ,
120
+ 'visitorId ' => null
121
+ ],
122
+ [
123
+ 'customerId ' => null ,
124
+ 'visitorId ' => 33
125
+ ],
126
+ [
127
+ 'customerId ' => null ,
128
+ 'visitorId ' => null
129
+ ],
130
+ ];
131
+ }
132
+
110
133
/**
111
134
* @inheritDoc
135
+ * @param int $customerId
136
+ * @param int $visitorId
137
+ * @dataProvider getUserIdentitiesCases
112
138
*/
113
- public function testFilterProductActions (): void
139
+ public function testFilterProductActions (int $ customerId = null , int $ visitorId = null ): void
114
140
{
115
141
$ typeId = 'recently_compared_product ' ;
116
142
$ productsData = [
@@ -149,16 +175,16 @@ public function testFilterProductActions(): void
149
175
->getMock ();
150
176
$ this ->sessionMock ->expects ($ this ->any ())
151
177
->method ('getCustomerId ' )
152
- ->willReturn (1 );
178
+ ->willReturn ($ customerId );
153
179
$ this ->visitorMock ->expects ($ this ->exactly (2 ))
154
180
->method ('getId ' )
155
- ->willReturn (34 );
181
+ ->willReturn ($ visitorId );
156
182
$ this ->collectionFactoryMock ->expects ($ this ->once ())
157
183
->method ('create ' )
158
184
->willReturn ($ collection );
159
185
$ collection ->expects ($ this ->once ())
160
186
->method ('addFilterByUserIdentities ' )
161
- ->with (1 , 34 );
187
+ ->with ($ customerId , $ visitorId );
162
188
$ collection
163
189
->method ('addFieldToFilter ' )
164
190
->withConsecutive (['type_id ' , $ typeId ], ['product_id ' , [1 , 2 ]]);
@@ -175,8 +201,8 @@ public function testFilterProductActions(): void
175
201
[
176
202
[
177
203
'data ' => [
178
- 'visitor_id ' => null ,
179
- 'customer_id ' => 1 ,
204
+ 'visitor_id ' => $ visitorId ,
205
+ 'customer_id ' => $ customerId ,
180
206
'added_at ' => 12 ,
181
207
'product_id ' => 1 ,
182
208
'type_id ' => 'recently_compared_product '
@@ -186,8 +212,8 @@ public function testFilterProductActions(): void
186
212
[
187
213
[
188
214
'data ' => [
189
- 'visitor_id ' => null ,
190
- 'customer_id ' => 1 ,
215
+ 'visitor_id ' => $ visitorId ,
216
+ 'customer_id ' => $ customerId ,
191
217
'added_at ' => 13 ,
192
218
'product_id ' => 2 ,
193
219
'type_id ' => 'recently_compared_product '
0 commit comments