@@ -23,18 +23,41 @@ class ConfigTest extends \PHPUnit\Framework\TestCase
23
23
*/
24
24
protected $ orderStatusCollectionFactoryMock ;
25
25
26
+ /**
27
+ * @var \Magento\Sales\Model\Order\StatusFactory|\PHPUnit_Framework_MockObject_MockObject
28
+ */
29
+ protected $ statusFactoryMock ;
30
+
31
+ /**
32
+ * @var \Magento\Sales\Model\Order\Status
33
+ */
34
+ protected $ orderStatusModel ;
35
+
36
+ /**
37
+ * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
38
+ */
39
+ protected $ storeManagerMock ;
40
+
26
41
protected function setUp ()
27
42
{
28
- $ orderStatusFactory = $ this ->createMock (\Magento \Sales \Model \Order \StatusFactory::class);
43
+ $ objectManager = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
44
+
45
+ $ this ->storeManagerMock = $ this ->createMock (\Magento \Store \Model \StoreManagerInterface::class);
46
+ $ this ->orderStatusModel = $ objectManager ->getObject (\Magento \Sales \Model \Order \Status::class, [
47
+ 'storeManager ' => $ this ->storeManagerMock ,
48
+ ]);
49
+ $ this ->statusFactoryMock = $ this ->getMockBuilder (\Magento \Sales \Model \Order \StatusFactory::class)
50
+ ->setMethods (['load ' , 'create ' ])
51
+ ->getMock ();
29
52
$ this ->orderStatusCollectionFactoryMock = $ this ->createPartialMock (
30
53
\Magento \Sales \Model \ResourceModel \Order \Status \CollectionFactory::class,
31
54
['create ' ]
32
55
);
33
- $ this ->salesConfig = ( new \ Magento \ Framework \ TestFramework \ Unit \ Helper \ ObjectManager ( $ this ))
56
+ $ this ->salesConfig = $ objectManager
34
57
->getObject (
35
58
\Magento \Sales \Model \Order \Config::class,
36
59
[
37
- 'orderStatusFactory ' => $ orderStatusFactory ,
60
+ 'orderStatusFactory ' => $ this -> statusFactoryMock ,
38
61
'orderStatusCollectionFactory ' => $ this ->orderStatusCollectionFactoryMock
39
62
]
40
63
);
@@ -147,6 +170,22 @@ public function testGetStatuses($state, $joinLabels, $collectionData, $expectedR
147
170
->method ('joinStates ' )
148
171
->will ($ this ->returnValue ($ collectionData ));
149
172
173
+ $ this ->statusFactoryMock ->method ('create ' )
174
+ ->willReturnSelf ();
175
+
176
+ $ this ->statusFactoryMock ->method ('load ' )
177
+ ->willReturn ($ this ->orderStatusModel );
178
+
179
+ $ storeMock = $ this ->createMock (\Magento \Store \Api \Data \StoreInterface::class);
180
+ $ storeMock ->method ('getId ' )
181
+ ->willReturn (1 );
182
+
183
+ $ this ->storeManagerMock ->method ('getStore ' )
184
+ ->with ($ this ->anything ())
185
+ ->willReturn ($ storeMock );
186
+
187
+ $ this ->orderStatusModel ->setData ('store_labels ' , [1 => 'Pending label ' ]);
188
+
150
189
$ result = $ this ->salesConfig ->getStateStatuses ($ state , $ joinLabels );
151
190
$ this ->assertSame ($ expectedResult , $ result );
152
191
0 commit comments