@@ -55,22 +55,20 @@ protected function setUp()
55
55
}
56
56
57
57
/**
58
- * @param bool $isCatalogProduct
59
- * @param bool $isInMiniCart
60
- *
61
- * @dataProvider dataProviderTestAddPaypalShortcuts
58
+ * @covers \Magento\Braintree\Observer\AddPaypalShortcuts::execute()
62
59
*/
63
- public function testAddPaypalShortcuts ($ isCatalogProduct , $ isInMiniCart )
60
+ public function testAddPaypalShortcuts ()
64
61
{
65
62
$ orPosition = 'before ' ;
63
+ $ isInMiniCart = true ;
66
64
67
65
$ containerMock = $ this ->getMockBuilder ('\Magento\Catalog\Block\ShortcutButtons ' )
68
66
->disableOriginalConstructor ()
69
67
->getMock ();
70
68
71
69
$ event = new \Magento \Framework \DataObject (
72
70
[
73
- 'is_catalog_product ' => $ isCatalogProduct ,
71
+ 'is_catalog_product ' => false ,
74
72
'container ' => $ containerMock ,
75
73
'or_position ' => $ orPosition ,
76
74
]
@@ -124,21 +122,48 @@ public function testAddPaypalShortcuts($isCatalogProduct, $isInMiniCart)
124
122
}
125
123
126
124
/**
127
- * @return array
125
+ * @covers \Magento\Braintree\Observer\AddPaypalShortcuts::execute()
128
126
*/
129
- public function dataProviderTestAddPaypalShortcuts ()
127
+ public function testAddPaypalShortcutsWithoutMinicart ()
130
128
{
131
- return [
132
- ['isCatalogProduct ' => true , 'isInMiniCart ' => false ],
133
- ['isCatalogProduct ' => false , 'isInMiniCart ' => true ],
134
- ];
129
+ $ containerMock = $ this ->getMockBuilder ('\Magento\Catalog\Block\ShortcutButtons ' )
130
+ ->disableOriginalConstructor ()
131
+ ->getMock ();
132
+
133
+ $ event = new \Magento \Framework \DataObject (
134
+ [
135
+ 'is_catalog_product ' => true ,
136
+ 'container ' => $ containerMock
137
+ ]
138
+ );
139
+ $ observer = new \Magento \Framework \Event \Observer (
140
+ [
141
+ 'event ' => $ event ,
142
+ ]
143
+ );
144
+ $ this ->paypalMethodMock ->expects (static ::once ())
145
+ ->method ('isActive ' )
146
+ ->willReturn (true );
147
+ $ this ->paypalConfigMock ->expects (static ::once ())
148
+ ->method ('isShortcutCheckoutEnabled ' )
149
+ ->willReturn (true );
150
+
151
+ $ containerMock ->expects (static ::never ())
152
+ ->method ('getLayout ' );
153
+
154
+ $ this ->addPaypalShortcutsObserver ->execute ($ observer );
135
155
}
136
156
137
157
public function testAddPaypalShortcutsNotActive ()
138
158
{
159
+ $ event = new \Magento \Framework \DataObject (
160
+ [
161
+ 'is_catalog_product ' => false ,
162
+ ]
163
+ );
139
164
$ observer = new \Magento \Framework \Event \Observer (
140
165
[
141
- 'event ' => null ,
166
+ 'event ' => $ event ,
142
167
]
143
168
);
144
169
0 commit comments