Skip to content

Commit 65b4bbe

Browse files
author
Joan He
committed
Merge remote-tracking branch 'upstream/2.3-develop' into MAGETWO-92931-Html-entity-breadcrumb
2 parents 3949cdb + e08b953 commit 65b4bbe

File tree

5 files changed

+122
-12
lines changed

5 files changed

+122
-12
lines changed

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
define([
88
'jquery',
99
'underscore',
10+
'mage/utils/wrapper',
1011
'Magento_Checkout/js/view/payment/default',
1112
'Magento_Braintree/js/view/payment/adapter',
1213
'Magento_Checkout/js/model/quote',
@@ -18,6 +19,7 @@ define([
1819
], function (
1920
$,
2021
_,
22+
wrapper,
2123
Component,
2224
Braintree,
2325
quote,
@@ -218,8 +220,9 @@ define([
218220

219221
/**
220222
* Re-init PayPal Auth Flow
223+
* @param {Function} callback - Optional callback
221224
*/
222-
reInitPayPal: function () {
225+
reInitPayPal: function (callback) {
223226
if (Braintree.checkout) {
224227
Braintree.checkout.teardown(function () {
225228
Braintree.checkout = null;
@@ -228,6 +231,18 @@ define([
228231

229232
this.disableButton();
230233
this.clientConfig.paypal.amount = this.grandTotalAmount;
234+
this.clientConfig.paypal.shippingAddressOverride = this.getShippingAddress();
235+
236+
if (callback) {
237+
this.clientConfig.onReady = wrapper.wrap(
238+
this.clientConfig.onReady,
239+
function (original, checkout) {
240+
this.clientConfig.onReady = original;
241+
original(checkout);
242+
callback();
243+
}.bind(this)
244+
);
245+
}
231246

232247
Braintree.setConfig(this.clientConfig);
233248
Braintree.setup();
@@ -403,15 +418,19 @@ define([
403418
* Triggers when customer click "Continue to PayPal" button
404419
*/
405420
payWithPayPal: function () {
406-
if (additionalValidators.validate()) {
421+
this.reInitPayPal(function () {
422+
if (!additionalValidators.validate()) {
423+
return;
424+
}
425+
407426
try {
408427
Braintree.checkout.paypal.initAuthFlow();
409428
} catch (e) {
410429
this.messageContainer.addErrorMessage({
411430
message: $t('Payment ' + this.getTitle() + ' can\'t be initialized.')
412431
});
413432
}
414-
}
433+
}.bind(this));
415434
},
416435

417436
/**

app/code/Magento/Braintree/view/frontend/web/template/payment/paypal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
data-bind="attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()" />
1313
<label class="label" data-bind="attr: {'for': getCode()}">
1414
<!-- PayPal Logo -->
15-
<img data-bind="attr: {src: getPaymentAcceptanceMarkSrc(), alt: $t('Acceptance Mark')}, title: $t('Acceptance Mark')}"
15+
<img data-bind="attr: {src: getPaymentAcceptanceMarkSrc(), alt: $t('Acceptance Mark'), title: $t('Acceptance Mark')}"
1616
class="payment-icon"/>
1717
<!-- PayPal Logo -->
1818
<span text="getTitle()"></span>

app/code/Magento/Cron/Console/Command/CronCommand.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
use Symfony\Component\Console\Input\InputInterface;
1111
use Symfony\Component\Console\Output\OutputInterface;
1212
use Symfony\Component\Console\Input\InputOption;
13+
use Magento\Framework\App\ObjectManager;
1314
use Magento\Framework\App\ObjectManagerFactory;
1415
use Magento\Store\Model\Store;
1516
use Magento\Store\Model\StoreManager;
1617
use Magento\Cron\Observer\ProcessCronQueueObserver;
18+
use Magento\Framework\App\DeploymentConfig;
1719
use Magento\Framework\Console\Cli;
1820
use Magento\Framework\Shell\ComplexParameter;
1921

@@ -35,13 +37,24 @@ class CronCommand extends Command
3537
private $objectManagerFactory;
3638

3739
/**
38-
* Constructor
40+
* Application deployment configuration
3941
*
42+
* @var DeploymentConfig
43+
*/
44+
private $deploymentConfig;
45+
46+
/**
4047
* @param ObjectManagerFactory $objectManagerFactory
48+
* @param DeploymentConfig $deploymentConfig Application deployment configuration
4149
*/
42-
public function __construct(ObjectManagerFactory $objectManagerFactory)
43-
{
50+
public function __construct(
51+
ObjectManagerFactory $objectManagerFactory,
52+
DeploymentConfig $deploymentConfig = null
53+
) {
4454
$this->objectManagerFactory = $objectManagerFactory;
55+
$this->deploymentConfig = $deploymentConfig ?: ObjectManager::getInstance()->get(
56+
DeploymentConfig::class
57+
);
4558
parent::__construct();
4659
}
4760

@@ -71,10 +84,16 @@ protected function configure()
7184
}
7285

7386
/**
87+
* Runs cron jobs if cron is not disabled in Magento configurations
88+
*
7489
* {@inheritdoc}
7590
*/
7691
protected function execute(InputInterface $input, OutputInterface $output)
7792
{
93+
if (!$this->deploymentConfig->get('cron/enabled', 1)) {
94+
$output->writeln('<info>' . 'Cron is disabled. Jobs were not run.' . '</info>');
95+
return;
96+
}
7897
$omParams = $_SERVER;
7998
$omParams[StoreManager::PARAM_RUN_CODE] = 'admin';
8099
$omParams[Store::CUSTOM_ENTRY_POINT_PARAM] = true;

app/code/Magento/Cron/Test/Unit/Console/Command/CronCommandTest.php

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,74 @@
66
namespace Magento\Cron\Test\Unit\Console\Command;
77

88
use Magento\Cron\Console\Command\CronCommand;
9+
use Magento\Framework\App\DeploymentConfig;
10+
use Magento\Framework\App\ObjectManagerFactory;
11+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
912
use Symfony\Component\Console\Tester\CommandTester;
1013

1114
class CronCommandTest extends \PHPUnit\Framework\TestCase
1215
{
16+
/**
17+
* @var ObjectManagerFactory|MockObject
18+
*/
19+
private $objectManagerFactory;
20+
21+
/**
22+
* @var DeploymentConfig|MockObject
23+
*/
24+
private $deploymentConfigMock;
25+
26+
protected function setUp()
27+
{
28+
$this->objectManagerFactory = $this->createMock(ObjectManagerFactory::class);
29+
$this->deploymentConfigMock = $this->createMock(DeploymentConfig::class);
30+
}
31+
32+
/**
33+
* Test command with disables cron
34+
*
35+
* @return void
36+
*/
37+
public function testExecuteWithDisabledCrons()
38+
{
39+
$this->objectManagerFactory->expects($this->never())
40+
->method('create');
41+
$this->deploymentConfigMock->expects($this->once())
42+
->method('get')
43+
->with('cron/enabled', 1)
44+
->willReturn(0);
45+
$commandTester = new CommandTester(
46+
new CronCommand($this->objectManagerFactory, $this->deploymentConfigMock)
47+
);
48+
$commandTester->execute([]);
49+
$expectedMsg = 'Cron is disabled. Jobs were not run.' . PHP_EOL;
50+
$this->assertEquals($expectedMsg, $commandTester->getDisplay());
51+
}
52+
53+
/**
54+
* Test command with enabled cron
55+
*
56+
* @return void
57+
*/
1358
public function testExecute()
1459
{
15-
$objectManagerFactory = $this->createMock(\Magento\Framework\App\ObjectManagerFactory::class);
1660
$objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
1761
$cron = $this->createMock(\Magento\Framework\App\Cron::class);
18-
$objectManager->expects($this->once())->method('create')->willReturn($cron);
19-
$cron->expects($this->once())->method('launch');
20-
$objectManagerFactory->expects($this->once())->method('create')->willReturn($objectManager);
21-
$commandTester = new CommandTester(new CronCommand($objectManagerFactory));
62+
$objectManager->expects($this->once())
63+
->method('create')
64+
->willReturn($cron);
65+
$cron->expects($this->once())
66+
->method('launch');
67+
$this->objectManagerFactory->expects($this->once())
68+
->method('create')
69+
->willReturn($objectManager);
70+
$this->deploymentConfigMock->expects($this->once())
71+
->method('get')
72+
->with('cron/enabled', 1)
73+
->willReturn(1);
74+
$commandTester = new CommandTester(
75+
new CronCommand($this->objectManagerFactory, $this->deploymentConfigMock)
76+
);
2277
$commandTester->execute([]);
2378
$expectedMsg = 'Ran jobs by schedule.' . PHP_EOL;
2479
$this->assertEquals($expectedMsg, $commandTester->getDisplay());

dev/tests/js/jasmine/tests/app/code/Magento/Braintree/frontend/js/view/payment/method-renderer/paypal.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,24 @@ define([
2727
})
2828
},
2929
'Magento_Braintree/js/view/payment/adapter': {
30+
config: {},
31+
32+
/** Stub */
33+
onReady: function () {},
34+
35+
/** Stub */
36+
setConfig: function (config) {
37+
this.config = config;
38+
},
39+
40+
/** Stub */
41+
setup: function () {
42+
this.config.onReady(this.checkout);
43+
},
44+
3045
checkout: {
46+
/** Stub */
47+
teardown: function () {},
3148
paypal: {
3249
/** Stub */
3350
initAuthFlow: function () {}

0 commit comments

Comments
 (0)