10
10
/**
11
11
* Class SuccessTest
12
12
* @package Magento\Checkout\Block\Onepage
13
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
13
14
*/
14
15
class SuccessTest extends \PHPUnit_Framework_TestCase
15
16
{
@@ -18,6 +19,11 @@ class SuccessTest extends \PHPUnit_Framework_TestCase
18
19
*/
19
20
protected $ block ;
20
21
22
+ /**
23
+ * @var \PHPUnit_Framework_MockObject_MockObject
24
+ */
25
+ protected $ layout ;
26
+
21
27
/**
22
28
* @var \Magento\Sales\Model\Order\Config | \PHPUnit_Framework_MockObject_MockObject
23
29
*/
@@ -28,21 +34,65 @@ class SuccessTest extends \PHPUnit_Framework_TestCase
28
34
*/
29
35
protected $ checkoutSession ;
30
36
37
+ /**
38
+ * @var \PHPUnit_Framework_MockObject_MockObject
39
+ */
40
+ protected $ storeManagerMock ;
41
+
31
42
protected function setUp ()
32
43
{
33
44
$ objectManager = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
34
45
35
46
$ this ->orderConfig = $ this ->getMock (\Magento \Sales \Model \Order \Config::class, [], [], '' , false );
47
+ $ this ->storeManagerMock = $ this ->getMock (\Magento \Store \Model \StoreManagerInterface::class, [], [], '' , false );
48
+
49
+ $ this ->layout = $ this ->getMockBuilder (\Magento \Framework \View \LayoutInterface::class)
50
+ ->disableOriginalConstructor ()
51
+ ->setMethods ([])
52
+ ->getMock ();
53
+
54
+ $ this ->checkoutSession = $ this ->getMockBuilder (\Magento \Checkout \Model \Session::class)
55
+ ->disableOriginalConstructor ()
56
+ ->getMock ();
36
57
37
- $ this ->checkoutSession = $ this ->getMockBuilder (
38
- \Magento \Checkout \Model \Session::class
39
- )
58
+ $ eventManager = $ this ->getMockBuilder (\Magento \Framework \Event \ManagerInterface::class)
40
59
->disableOriginalConstructor ()
60
+ ->setMethods ([])
41
61
->getMock ();
42
62
63
+ $ urlBuilder = $ this ->getMockBuilder (\Magento \Framework \UrlInterface::class)
64
+ ->disableOriginalConstructor ()
65
+ ->setMethods ([])
66
+ ->getMock ();
67
+
68
+ $ scopeConfig = $ this ->getMockBuilder (\Magento \Framework \App \Config \ScopeConfigInterface::class)
69
+ ->disableOriginalConstructor ()
70
+ ->setMethods ([])
71
+ ->getMock ();
72
+ $ scopeConfig ->expects ($ this ->any ())
73
+ ->method ('getValue ' )
74
+ ->with (
75
+ $ this ->stringContains (
76
+ 'advanced/modules_disable_output/ '
77
+ ),
78
+ \Magento \Store \Model \ScopeInterface::SCOPE_STORE
79
+ )
80
+ ->will ($ this ->returnValue (false ));
81
+
82
+ $ context = $ this ->getMockBuilder (\Magento \Framework \View \Element \Template \Context::class)
83
+ ->disableOriginalConstructor ()
84
+ ->setMethods (['getLayout ' , 'getEventManager ' , 'getUrlBuilder ' , 'getScopeConfig ' , 'getStoreManager ' ])
85
+ ->getMock ();
86
+ $ context ->expects ($ this ->any ())->method ('getLayout ' )->will ($ this ->returnValue ($ this ->layout ));
87
+ $ context ->expects ($ this ->any ())->method ('getEventManager ' )->will ($ this ->returnValue ($ eventManager ));
88
+ $ context ->expects ($ this ->any ())->method ('getUrlBuilder ' )->will ($ this ->returnValue ($ urlBuilder ));
89
+ $ context ->expects ($ this ->any ())->method ('getScopeConfig ' )->will ($ this ->returnValue ($ scopeConfig ));
90
+ $ context ->expects ($ this ->any ())->method ('getStoreManager ' )->will ($ this ->returnValue ($ this ->storeManagerMock ));
91
+
43
92
$ this ->block = $ objectManager ->getObject (
44
93
\Magento \Checkout \Block \Onepage \Success::class,
45
94
[
95
+ 'context ' => $ context ,
46
96
'orderConfig ' => $ this ->orderConfig ,
47
97
'checkoutSession ' => $ this ->checkoutSession
48
98
]
@@ -110,4 +160,13 @@ public function invisibleStatusesProvider()
110
160
[['status1 ' , 'status2 ' ], true ]
111
161
];
112
162
}
163
+
164
+ public function testGetContinueUrl ()
165
+ {
166
+ $ storeMock = $ this ->getMock (\Magento \Store \Model \Store::class, [], [], '' , false );
167
+ $ this ->storeManagerMock ->expects ($ this ->once ())->method ('getStore ' )->will ($ this ->returnValue ($ storeMock ));
168
+ $ storeMock ->expects ($ this ->once ())->method ('getBaseUrl ' )->will ($ this ->returnValue ('Expected Result ' ));
169
+
170
+ $ this ->assertEquals ('Expected Result ' , $ this ->block ->getContinueUrl ());
171
+ }
113
172
}
0 commit comments