11<?php
2+ /**
3+ * Copyright 2023 Adobe
4+ * All Rights Reserved.
5+ *
6+ * NOTICE: All information contained herein is, and remains
7+ * the property of Adobe and its suppliers, if any. The intellectual
8+ * and technical concepts contained herein are proprietary to Adobe
9+ * and its suppliers and are protected by all applicable intellectual
10+ * property laws, including trade secret and copyright laws.
11+ * Dissemination of this information or reproduction of this material
12+ * is strictly forbidden unless prior written permission is obtained from
13+ * Adobe.
14+ */
15+ declare (strict_types=1 );
16+
217namespace Magento \Catalog \Test \Fixture ;
318
419use Magento \CatalogInventory \Api \StockRegistryInterface ;
520use Magento \Framework \DataObject ;
621use Magento \Framework \DataObjectFactory ;
22+ use Magento \TestFramework \Fixture \Api \DataMerger ;
723use Magento \TestFramework \Fixture \DataFixtureInterface ;
824
925class ProductStock implements DataFixtureInterface
@@ -23,24 +39,33 @@ class ProductStock implements DataFixtureInterface
2339 */
2440 protected StockRegistryInterface $ stockRegistry ;
2541
42+ /**
43+ * @var DataMerger
44+ */
45+ protected DataMerger $ dataMerger ;
46+
2647 /**
2748 * @param DataObjectFactory $dataObjectFactory
2849 * @param StockRegistryInterface $stockRegistry
50+ * @param DataMerger $dataMerger
2951 */
3052 public function __construct (
3153 DataObjectFactory $ dataObjectFactory ,
32- StockRegistryInterface $ stockRegistry
54+ StockRegistryInterface $ stockRegistry ,
55+ DataMerger $ dataMerger
3356 ) {
3457 $ this ->dataObjectFactory = $ dataObjectFactory ;
3558 $ this ->stockRegistry = $ stockRegistry ;
59+ $ this ->dataMerger = $ dataMerger ;
3660 }
3761
3862 /**
3963 * {@inheritdoc}
40- * @param array $data Parameters. Same format as ReduceProductStock ::DEFAULT_DATA
64+ * @param array $data Parameters. Same format as ProductStock ::DEFAULT_DATA
4165 */
4266 public function apply (array $ data = []): ?DataObject
4367 {
68+ $ data = $ this ->dataMerger ->merge (self ::DEFAULT_DATA , $ data );
4469 $ stockItem = $ this ->stockRegistry ->getStockItem ($ data ['prod_id ' ]);
4570 $ stockItem ->setData ('is_in_stock ' , 1 );
4671 $ stockItem ->setData ('qty ' , 90 );
0 commit comments