Skip to content

Commit 9a735e4

Browse files
committed
Merge branch 'MAGETWO-44663' of github.corp.magento.com:magento-mpi/magento2ce into MAGETWO-44603
2 parents 783bf00 + 82c7c9d commit 9a735e4

File tree

8 files changed

+44
-420
lines changed

8 files changed

+44
-420
lines changed

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

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

app/code/Magento/Braintree/Observer/AddPaypalShortcuts.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ public function __construct(
4242
*/
4343
public function execute(\Magento\Framework\Event\Observer $observer)
4444
{
45+
$isMiniCart = !$observer->getEvent()->getIsCatalogProduct();
46+
4547
//Don't display shortcut on product view page
4648
if (!$this->methodPayPal->isActive() ||
47-
!$this->paypalConfig->isShortcutCheckoutEnabled()) {
49+
!$this->paypalConfig->isShortcutCheckoutEnabled() ||
50+
!$isMiniCart) {
4851
return;
4952
}
5053

@@ -57,7 +60,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
5760
'',
5861
[
5962
'data' => [
60-
Shortcut::MINI_CART_FLAG_KEY => !$observer->getEvent()->getIsCatalogProduct()
63+
Shortcut::MINI_CART_FLAG_KEY => $isMiniCart
6164
]
6265
]
6366
);

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/templates/PayPal/shortcut.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $paymentId = $block->getPaymentMethodNonceId();
1212
$detailsId = $block->getPaymentDetailsId();
1313
$isMiniCart = (bool)(int)$block->isInMiniCart();
1414

15-
$widgetName = $isMiniCart ? 'braintreePayPalMinicart' : 'braintreePayPal';
15+
$widgetName = 'braintreePayPalMinicart';
1616

1717
$config = [
1818
$widgetName => [

0 commit comments

Comments
 (0)