@@ -196,7 +196,7 @@ public function testRetryBulk()
196
196
$ bulkUuid = 'bulk-001 ' ;
197
197
$ errorCodes = ['errorCode ' ];
198
198
$ connectionName = 'default ' ;
199
- $ operationId = 1 ;
199
+ $ operationId = 0 ;
200
200
$ operationTable = 'magento_operation ' ;
201
201
$ topicName = 'topic.name ' ;
202
202
$ metadata = $ this ->getMockForAbstractClass (EntityMetadataInterface::class);
@@ -216,13 +216,20 @@ public function testRetryBulk()
216
216
$ operationCollection ->expects ($ this ->once ())->method ('getItems ' )->willReturn ([$ operation ]);
217
217
$ connection ->expects ($ this ->once ())->method ('beginTransaction ' )->willReturnSelf ();
218
218
$ operation ->expects ($ this ->once ())->method ('getId ' )->willReturn ($ operationId );
219
- $ operation ->expects ($ this ->once ())->method ('setId ' )->with (null )->willReturnSelf ();
220
219
$ this ->resourceConnection ->expects ($ this ->once ())
221
220
->method ('getTableName ' )->with ($ operationTable )->willReturn ($ operationTable );
221
+ $ connection ->expects ($ this ->at (1 ))
222
+ ->method ('quoteInto ' )
223
+ ->with ('operation_key IN (?) ' , [$ operationId ])
224
+ ->willReturn ('operation_key IN ( ' . $ operationId . ') ' );
225
+ $ connection ->expects ($ this ->at (2 ))
226
+ ->method ('quoteInto ' )
227
+ ->with ('bulk_uuid = ? ' , $ bulkUuid )
228
+ ->willReturn ("bulk_uuid = ' $ bulkUuid' " );
222
229
$ connection ->expects ($ this ->once ())
223
- ->method ('quoteInto ' )-> with ( ' id IN (?) ' , [ $ operationId ])-> willReturn ( ' id IN ( ' . $ operationId . ' ) ' );
224
- $ connection -> expects ( $ this -> once () )
225
- ->method ( ' delete ' )-> with ( $ operationTable , ' id IN ( ' . $ operationId . ' ) ' )-> willReturn (1 );
230
+ ->method ('delete ' )
231
+ -> with ( $ operationTable , ' operation_key IN ( ' . $ operationId . ' ) AND bulk_uuid = \'' . $ bulkUuid . '\'' )
232
+ ->willReturn (1 );
226
233
$ connection ->expects ($ this ->once ())->method ('commit ' )->willReturnSelf ();
227
234
$ operation ->expects ($ this ->once ())->method ('getTopicName ' )->willReturn ($ topicName );
228
235
$ this ->publisher ->expects ($ this ->once ())->method ('publish ' )->with ($ topicName , [$ operation ])->willReturn (null );
@@ -239,7 +246,7 @@ public function testRetryBulkWithException()
239
246
$ bulkUuid = 'bulk-001 ' ;
240
247
$ errorCodes = ['errorCode ' ];
241
248
$ connectionName = 'default ' ;
242
- $ operationId = 1 ;
249
+ $ operationId = 0 ;
243
250
$ operationTable = 'magento_operation ' ;
244
251
$ exceptionMessage = 'Exception message ' ;
245
252
$ metadata = $ this ->getMockForAbstractClass (EntityMetadataInterface::class);
@@ -259,13 +266,19 @@ public function testRetryBulkWithException()
259
266
$ operationCollection ->expects ($ this ->once ())->method ('getItems ' )->willReturn ([$ operation ]);
260
267
$ connection ->expects ($ this ->once ())->method ('beginTransaction ' )->willReturnSelf ();
261
268
$ operation ->expects ($ this ->once ())->method ('getId ' )->willReturn ($ operationId );
262
- $ operation ->expects ($ this ->once ())->method ('setId ' )->with (null )->willReturnSelf ();
263
269
$ this ->resourceConnection ->expects ($ this ->once ())
264
270
->method ('getTableName ' )->with ($ operationTable )->willReturn ($ operationTable );
271
+ $ connection ->expects ($ this ->at (1 ))
272
+ ->method ('quoteInto ' )
273
+ ->with ('operation_key IN (?) ' , [$ operationId ])
274
+ ->willReturn ('operation_key IN ( ' . $ operationId . ') ' );
275
+ $ connection ->expects ($ this ->at (2 ))
276
+ ->method ('quoteInto ' )
277
+ ->with ('bulk_uuid = ? ' , $ bulkUuid )
278
+ ->willReturn ("bulk_uuid = ' $ bulkUuid' " );
265
279
$ connection ->expects ($ this ->once ())
266
- ->method ('quoteInto ' )->with ('id IN (?) ' , [$ operationId ])->willReturn ('id IN ( ' . $ operationId . ') ' );
267
- $ connection ->expects ($ this ->once ())
268
- ->method ('delete ' )->with ($ operationTable , 'id IN ( ' . $ operationId . ') ' )
280
+ ->method ('delete ' )
281
+ ->with ($ operationTable , 'operation_key IN ( ' . $ operationId . ') AND bulk_uuid = \'' . $ bulkUuid . '\'' )
269
282
->willThrowException (new \Exception ($ exceptionMessage ));
270
283
$ connection ->expects ($ this ->once ())->method ('rollBack ' )->willReturnSelf ();
271
284
$ this ->logger ->expects ($ this ->once ())->method ('critical ' )->with ($ exceptionMessage );
0 commit comments