1
1
<?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
+
2
17
namespace Magento \Catalog \Test \Fixture ;
3
18
4
19
use Magento \CatalogInventory \Api \StockRegistryInterface ;
5
20
use Magento \Framework \DataObject ;
6
21
use Magento \Framework \DataObjectFactory ;
22
+ use Magento \TestFramework \Fixture \Api \DataMerger ;
7
23
use Magento \TestFramework \Fixture \DataFixtureInterface ;
8
24
9
25
class ProductStock implements DataFixtureInterface
@@ -23,24 +39,33 @@ class ProductStock implements DataFixtureInterface
23
39
*/
24
40
protected StockRegistryInterface $ stockRegistry ;
25
41
42
+ /**
43
+ * @var DataMerger
44
+ */
45
+ protected DataMerger $ dataMerger ;
46
+
26
47
/**
27
48
* @param DataObjectFactory $dataObjectFactory
28
49
* @param StockRegistryInterface $stockRegistry
50
+ * @param DataMerger $dataMerger
29
51
*/
30
52
public function __construct (
31
53
DataObjectFactory $ dataObjectFactory ,
32
- StockRegistryInterface $ stockRegistry
54
+ StockRegistryInterface $ stockRegistry ,
55
+ DataMerger $ dataMerger
33
56
) {
34
57
$ this ->dataObjectFactory = $ dataObjectFactory ;
35
58
$ this ->stockRegistry = $ stockRegistry ;
59
+ $ this ->dataMerger = $ dataMerger ;
36
60
}
37
61
38
62
/**
39
63
* {@inheritdoc}
40
- * @param array $data Parameters. Same format as ReduceProductStock ::DEFAULT_DATA
64
+ * @param array $data Parameters. Same format as ProductStock ::DEFAULT_DATA
41
65
*/
42
66
public function apply (array $ data = []): ?DataObject
43
67
{
68
+ $ data = $ this ->dataMerger ->merge (self ::DEFAULT_DATA , $ data );
44
69
$ stockItem = $ this ->stockRegistry ->getStockItem ($ data ['prod_id ' ]);
45
70
$ stockItem ->setData ('is_in_stock ' , 1 );
46
71
$ stockItem ->setData ('qty ' , 90 );
0 commit comments