Skip to content

Commit 9be7fd1

Browse files
author
Ievgen Sentiabov
committed
MAGETWO-44663: Braintree PayPal Check Out button should not be displayed on product page
- Removed unnecessary code - Updated unit tests
1 parent 3c0e81b commit 9be7fd1

File tree

6 files changed

+38
-417
lines changed

6 files changed

+38
-417
lines changed

app/code/Magento/Braintree/Controller/PayPal/GetButtonData.php

Lines changed: 0 additions & 61 deletions
This file was deleted.

app/code/Magento/Braintree/Test/Unit/Controller/PayPal/GetButtonDataTest.php

Lines changed: 0 additions & 190 deletions
This file was deleted.

app/code/Magento/Braintree/Test/Unit/Observer/AddPaypalShortcutsTest.php

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,20 @@ protected function setUp()
5555
}
5656

5757
/**
58-
* @param bool $isCatalogProduct
59-
* @param bool $isInMiniCart
60-
*
61-
* @dataProvider dataProviderTestAddPaypalShortcuts
58+
* @covers \Magento\Braintree\Observer\AddPaypalShortcuts::execute()
6259
*/
63-
public function testAddPaypalShortcuts($isCatalogProduct, $isInMiniCart)
60+
public function testAddPaypalShortcuts()
6461
{
6562
$orPosition = 'before';
63+
$isInMiniCart = true;
6664

6765
$containerMock = $this->getMockBuilder('\Magento\Catalog\Block\ShortcutButtons')
6866
->disableOriginalConstructor()
6967
->getMock();
7068

7169
$event = new \Magento\Framework\DataObject(
7270
[
73-
'is_catalog_product' => $isCatalogProduct,
71+
'is_catalog_product' => false,
7472
'container' => $containerMock,
7573
'or_position' => $orPosition,
7674
]
@@ -124,21 +122,48 @@ public function testAddPaypalShortcuts($isCatalogProduct, $isInMiniCart)
124122
}
125123

126124
/**
127-
* @return array
125+
* @covers \Magento\Braintree\Observer\AddPaypalShortcuts::execute()
128126
*/
129-
public function dataProviderTestAddPaypalShortcuts()
127+
public function testAddPaypalShortcutsWithoutMinicart()
130128
{
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);
135155
}
136156

137157
public function testAddPaypalShortcutsNotActive()
138158
{
159+
$event = new \Magento\Framework\DataObject(
160+
[
161+
'is_catalog_product' => false,
162+
]
163+
);
139164
$observer = new \Magento\Framework\Event\Observer(
140165
[
141-
'event' => null,
166+
'event' => $event,
142167
]
143168
);
144169

app/code/Magento/Braintree/view/frontend/requirejs-config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ var config = {
1111
braintreeForm: 'Magento_Braintree/js/cc-form',
1212
braintreeEditForm: 'Magento_Braintree/js/cc-edit-form',
1313
braintreePayPalMinicart: 'Magento_Braintree/js/button/braintree-paypal-minicart',
14-
braintreePayPal: 'Magento_Braintree/js/button/braintree-paypal',
1514
transparent: 'Magento_Payment/transparent'
1615
}
1716
}

app/code/Magento/Braintree/view/frontend/web/js/button/action/get-data.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)