@@ -23,18 +23,41 @@ class ConfigTest extends \PHPUnit\Framework\TestCase
2323 */
2424 protected $ orderStatusCollectionFactoryMock ;
2525
26+ /**
27+ * @var \Magento\Sales\Model\Order\Config|\PHPUnit_Framework_MockObject_MockObject
28+ */
29+ protected $ orderStatusFactoryMock ;
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+
2641 protected function setUp ()
2742 {
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 ->orderStatusFactoryMock = $ this ->getMockBuilder (\Magento \Sales \Model \Order \StatusFactory::class)
50+ ->setMethods (['load ' , 'create ' ])
51+ ->getMock ();
2952 $ this ->orderStatusCollectionFactoryMock = $ this ->createPartialMock (
3053 \Magento \Sales \Model \ResourceModel \Order \Status \CollectionFactory::class,
3154 ['create ' ]
3255 );
33- $ this ->salesConfig = ( new \ Magento \ Framework \ TestFramework \ Unit \ Helper \ ObjectManager ( $ this ))
56+ $ this ->salesConfig = $ objectManager
3457 ->getObject (
3558 \Magento \Sales \Model \Order \Config::class,
3659 [
37- 'orderStatusFactory ' => $ orderStatusFactory ,
60+ 'orderStatusFactory ' => $ this -> orderStatusFactoryMock ,
3861 'orderStatusCollectionFactory ' => $ this ->orderStatusCollectionFactoryMock
3962 ]
4063 );
@@ -147,6 +170,22 @@ public function testGetStatuses($state, $joinLabels, $collectionData, $expectedR
147170 ->method ('joinStates ' )
148171 ->will ($ this ->returnValue ($ collectionData ));
149172
173+ $ this ->orderStatusFactoryMock ->method ('create ' )
174+ ->willReturnSelf ();
175+
176+ $ this ->orderStatusFactoryMock ->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+
150189 $ result = $ this ->salesConfig ->getStateStatuses ($ state , $ joinLabels );
151190 $ this ->assertSame ($ expectedResult , $ result );
152191
0 commit comments