diff --git a/app/code/Magento/AsynchronousOperations/etc/db_schema.xml b/app/code/Magento/AsynchronousOperations/etc/db_schema.xml
index 5d49d71ee46b0..ab482d2e2c761 100644
--- a/app/code/Magento/AsynchronousOperations/etc/db_schema.xml
+++ b/app/code/Magento/AsynchronousOperations/etc/db_schema.xml
@@ -34,7 +34,7 @@
-
objectManager = Bootstrap::getObjectManager();
+ $this->publisherMock = $this->getMockForAbstractClass(BulkPublisherInterface::class);
+
+ $this->bulkManagement = $this->objectManager->create(
+ BulkManagement::class,
+ [
+ 'publisher' => $this->publisherMock
+ ]
+ );
+ $this->bulkStatus = $this->objectManager->get(BulkStatus::class);
+ $catalogProductMock = $this->createMock(Product::class);
+ $productFlatIndexerProcessorMock = $this->createMock(
+ FlatProcessor::class
+ );
+ $productPriceIndexerProcessorMock = $this->createMock(
+ PriceProcessor::class
+ );
+ $operationManagementMock = $this->createMock(
+ OperationManagementInterface::class
+ );
+ $actionMock = $this->createMock(Action::class);
+ $loggerMock = $this->createMock(LoggerInterface::class);
+ $this->serializer = $this->objectManager->get(SerializerInterface::class);
+ $entityManager = $this->objectManager->get(EntityManager::class);
+ $this->model = $this->objectManager->create(
+ Consumer::class,
+ [
+ 'catalogProduct' => $catalogProductMock,
+ 'productFlatIndexerProcessor' => $productFlatIndexerProcessorMock,
+ 'productPriceIndexerProcessor' => $productPriceIndexerProcessorMock,
+ 'operationManagement' => $operationManagementMock,
+ 'action' => $actionMock,
+ 'logger' => $loggerMock,
+ 'serializer' => $this->serializer,
+ 'entityManager' => $entityManager
+ ]
+ );
+
+ parent::setUp();
+ }
+
+ /**
+ * Testing saving bulk operation during processing operation by attribute backend consumer
+ */
+ public function testSaveOperationDuringProcess()
+ {
+ $operation = $this->prepareUpdateAttributesBulkAndOperation();
+ try {
+ $this->model->process($operation);
+ } catch (\Exception $e) {
+ $this->fail(sprintf('Operation save process failed.: %s', $e->getMessage()));
+ }
+ $operationStatus = $operation->getStatus();
+ $this->assertEquals(
+ 1,
+ $this->bulkStatus->getOperationsCountByBulkIdAndStatus(self::BULK_UUID, $operationStatus)
+ );
+ }
+
+ /**
+ * Schedules test bulk and returns operation
+ * @return OperationInterface
+ */
+ private function prepareUpdateAttributesBulkAndOperation(): OperationInterface
+ {
+ // general bulk information
+ $bulkUuid = self::BULK_UUID;
+ $bulkDescription = 'Update attributes for 2 selected products';
+ $topicName = 'product_action_attribute.update';
+ $userId = 1;
+ /** @var OperationInterfaceFactory $operationFactory */
+ $operationFactory = $this->objectManager->get(OperationInterfaceFactory::class);
+ $operation = $operationFactory->create();
+ $operation->setBulkUuid($bulkUuid)
+ ->setTopicName($topicName)
+ ->setSerializedData($this->serializer->serialize(
+ ['product_ids' => [1,3], 'attributes' => [], 'store_id' => '0']
+ ));
+ $this->bulkManagement->scheduleBulk($bulkUuid, [$operation], $bulkDescription, $userId);
+ return $operation;
+ }
+
+ /**
+ * Clear created bulk and operation
+ */
+ protected function tearDown(): void
+ {
+ $this->bulkManagement->deleteBulk(self::BULK_UUID);
+ parent::tearDown();
+ }
+}