9
9
10
10
use Magento \CatalogRule \Model \Indexer \ProductPriceCalculator ;
11
11
use Magento \CatalogRule \Model \Indexer \ReindexRuleProductPrice ;
12
+ use Magento \CatalogRule \Model \Indexer \ReindexRuleProductsPriceProcessor ;
12
13
use Magento \CatalogRule \Model \Indexer \RuleProductPricesPersistor ;
13
14
use Magento \CatalogRule \Model \Indexer \RuleProductsSelectBuilder ;
14
15
use Magento \Framework \Stdlib \DateTime \TimezoneInterface ;
15
- use Magento \Store \Api \Data \GroupInterface ;
16
16
use Magento \Store \Api \Data \WebsiteInterface ;
17
17
use Magento \Store \Model \StoreManagerInterface ;
18
18
use PHPUnit \Framework \MockObject \MockObject ;
@@ -50,6 +50,11 @@ class ReindexRuleProductPriceTest extends TestCase
50
50
*/
51
51
private $ pricesPersistorMock ;
52
52
53
+ /**
54
+ * @var ReindexRuleProductsPriceProcessor|MockObject
55
+ */
56
+ private $ reindexRuleProductsPriceProcessorMock ;
57
+
53
58
/**
54
59
* @inheritDoc
55
60
*/
@@ -60,14 +65,16 @@ protected function setUp(): void
60
65
$ this ->productPriceCalculatorMock = $ this ->createMock (ProductPriceCalculator::class);
61
66
$ this ->localeDate = $ this ->getMockForAbstractClass (TimezoneInterface::class);
62
67
$ this ->pricesPersistorMock = $ this ->createMock (RuleProductPricesPersistor::class);
68
+ $ this ->reindexRuleProductsPriceProcessorMock = $ this ->createMock (ReindexRuleProductsPriceProcessor::class);
63
69
64
70
$ this ->model = new ReindexRuleProductPrice (
65
71
$ this ->storeManagerMock ,
66
72
$ this ->ruleProductsSelectBuilderMock ,
67
73
$ this ->productPriceCalculatorMock ,
68
74
$ this ->localeDate ,
69
75
$ this ->pricesPersistorMock ,
70
- true
76
+ true ,
77
+ $ this ->reindexRuleProductsPriceProcessorMock
71
78
);
72
79
}
73
80
@@ -77,30 +84,15 @@ protected function setUp(): void
77
84
public function testExecute (): void
78
85
{
79
86
$ websiteId = 234 ;
80
- $ defaultGroupId = 11 ;
81
- $ defaultStoreId = 22 ;
82
87
$ productId = 55 ;
83
88
84
89
$ websiteMock = $ this ->getMockForAbstractClass (WebsiteInterface::class);
85
90
$ websiteMock ->expects ($ this ->once ())
86
91
->method ('getId ' )
87
92
->willReturn ($ websiteId );
88
- $ websiteMock ->expects ($ this ->once ())
89
- ->method ('getDefaultGroupId ' )
90
- ->willReturn ($ defaultGroupId );
91
93
$ this ->storeManagerMock ->expects ($ this ->once ())
92
94
->method ('getWebsites ' )
93
95
->willReturn ([$ websiteMock ]);
94
- $ groupMock = $ this ->getMockForAbstractClass (GroupInterface::class);
95
- $ groupMock ->method ('getId ' )
96
- ->willReturn ($ defaultStoreId );
97
- $ groupMock ->expects ($ this ->once ())
98
- ->method ('getDefaultStoreId ' )
99
- ->willReturn ($ defaultStoreId );
100
- $ this ->storeManagerMock ->expects ($ this ->once ())
101
- ->method ('getGroup ' )
102
- ->with ($ defaultGroupId )
103
- ->willReturn ($ groupMock );
104
96
105
97
$ statementMock = $ this ->createMock (\Zend_Db_Statement_Interface::class);
106
98
$ this ->ruleProductsSelectBuilderMock ->expects ($ this ->once ())
@@ -117,18 +109,11 @@ public function testExecute(): void
117
109
'action_stop ' => true
118
110
];
119
111
120
- $ this ->localeDate ->expects ($ this ->once ())
121
- ->method ('scopeDate ' )
122
- ->with ($ defaultStoreId , null , true )
123
- ->willReturn (new \DateTime ());
124
-
125
112
$ statementMock
126
113
->method ('fetch ' )
127
114
->willReturnOnConsecutiveCalls ($ ruleData , false );
128
115
129
- $ this ->productPriceCalculatorMock ->expects ($ this ->atLeastOnce ())
130
- ->method ('calculate ' );
131
- $ this ->pricesPersistorMock ->expects ($ this ->once ())
116
+ $ this ->reindexRuleProductsPriceProcessorMock ->expects ($ this ->once ())
132
117
->method ('execute ' );
133
118
134
119
$ this ->assertTrue ($ this ->model ->execute (1 , $ productId , true ));
0 commit comments