diff --git a/app/code/Magento/AsynchronousOperations/Model/BulkManagement.php b/app/code/Magento/AsynchronousOperations/Model/BulkManagement.php index 6cf0611eb28ec..c7dda24ae6f6d 100644 --- a/app/code/Magento/AsynchronousOperations/Model/BulkManagement.php +++ b/app/code/Magento/AsynchronousOperations/Model/BulkManagement.php @@ -202,6 +202,7 @@ private function publishOperations(array $operations) { $operationsByTopics = []; foreach ($operations as $operation) { + $this->entityManager->save($operation); $operationsByTopics[$operation->getTopicName()][] = $operation; } foreach ($operationsByTopics as $topicName => $operations) { diff --git a/app/code/Magento/AsynchronousOperations/Test/Unit/Model/BulkManagementTest.php b/app/code/Magento/AsynchronousOperations/Test/Unit/Model/BulkManagementTest.php index 14abb41c77fc4..d2a935eaa5c31 100644 --- a/app/code/Magento/AsynchronousOperations/Test/Unit/Model/BulkManagementTest.php +++ b/app/code/Magento/AsynchronousOperations/Test/Unit/Model/BulkManagementTest.php @@ -143,7 +143,9 @@ public function testScheduleBulk() $bulkSummary->expects($this->once())->method('setUserType')->with($userType)->willReturnSelf(); $bulkSummary->expects($this->once())->method('getOperationCount')->willReturn(1); $bulkSummary->expects($this->once())->method('setOperationCount')->with(3)->willReturnSelf(); - $this->entityManager->expects($this->once())->method('save')->with($bulkSummary)->willReturn($bulkSummary); + $this->entityManager->expects($this->exactly(3))->method('save') + ->withConsecutive([$bulkSummary], [$operation], [$operation]) + ->will($this->onConsecutiveCalls($bulkSummary, $operation, $operation)); $connection->expects($this->once())->method('commit')->willReturnSelf(); $operation->expects($this->exactly(2))->method('getTopicName') ->willReturnOnConsecutiveCalls($topicNames[0], $topicNames[1]); @@ -233,6 +235,7 @@ public function testRetryBulk() $connection->expects($this->once())->method('commit')->willReturnSelf(); $operation->expects($this->once())->method('getTopicName')->willReturn($topicName); $this->publisher->expects($this->once())->method('publish')->with($topicName, [$operation])->willReturn(null); + $this->entityManager->expects($this->once())->method('save')->with($operation)->willReturn($operation); $this->assertEquals(1, $this->bulkManagement->retryBulk($bulkUuid, $errorCodes)); }