Skip to content

Commit 109cc78

Browse files
committed
Merge branch '2.3-develop' of github.com:magento/magento2ce into MAGETWO-90971
2 parents eeeea1b + fe11b39 commit 109cc78

File tree

119 files changed

+774
-301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+774
-301
lines changed

app/code/Magento/Backend/Block/Dashboard/Bar.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ public function getTotals()
3838
*/
3939
public function addTotal($label, $value, $isQuantity = false)
4040
{
41-
/*if (!$isQuantity) {
42-
$value = $this->format($value);
43-
$decimals = substr($value, -2);
44-
$value = substr($value, 0, -2);
45-
} else {
46-
$value = ($value != '')?$value:0;
47-
$decimals = '';
48-
}*/
4941
if (!$isQuantity) {
5042
$value = $this->format($value);
5143
}
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Backup\Test\Unit\Model;
9+
10+
use Magento\Backup\Model\Db;
11+
use Magento\Backup\Model\ResourceModel\Db as DbResource;
12+
use Magento\Framework\App\ResourceConnection;
13+
use Magento\Framework\Backup\Db\BackupInterface;
14+
use Magento\Framework\DataObject;
15+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
16+
17+
class DbTest extends \PHPUnit\Framework\TestCase
18+
{
19+
/**
20+
* @var ObjectManager
21+
*/
22+
private $objectManager;
23+
24+
/**
25+
* @var Db
26+
*/
27+
private $dbModel;
28+
29+
/**
30+
* @var DbResource|\PHPUnit_Framework_MockObject_MockObject
31+
*/
32+
private $dbResourceMock;
33+
34+
/**
35+
* @var ResourceConnection|\PHPUnit_Framework_MockObject_MockObject
36+
*/
37+
private $connectionResourceMock;
38+
39+
protected function setUp()
40+
{
41+
$this->dbResourceMock = $this->getMockBuilder(DbResource::class)
42+
->disableOriginalConstructor()
43+
->getMock();
44+
$this->connectionResourceMock = $this->getMockBuilder(ResourceConnection::class)
45+
->disableOriginalConstructor()
46+
->getMock();
47+
48+
$this->objectManager = new ObjectManager($this);
49+
$this->dbModel = $this->objectManager->getObject(
50+
Db::class,
51+
[
52+
'resourceDb' => $this->dbResourceMock,
53+
'resource' => $this->connectionResourceMock
54+
]
55+
);
56+
}
57+
58+
public function testGetResource()
59+
{
60+
self::assertEquals($this->dbResourceMock, $this->dbModel->getResource());
61+
}
62+
63+
public function testGetTables()
64+
{
65+
$tables = [];
66+
$this->dbResourceMock->expects($this->once())
67+
->method('getTables')
68+
->willReturn($tables);
69+
70+
self::assertEquals($tables, $this->dbModel->getTables());
71+
}
72+
73+
public function testGetTableCreateScript()
74+
{
75+
$tableName = 'some_table';
76+
$script = 'script';
77+
$this->dbResourceMock->expects($this->once())
78+
->method('getTableCreateScript')
79+
->with($tableName, false)
80+
->willReturn($script);
81+
82+
self::assertEquals($script, $this->dbModel->getTableCreateScript($tableName, false));
83+
}
84+
85+
public function testGetTableDataDump()
86+
{
87+
$tableName = 'some_table';
88+
$dump = 'dump';
89+
$this->dbResourceMock->expects($this->once())
90+
->method('getTableDataDump')
91+
->with($tableName)
92+
->willReturn($dump);
93+
94+
self::assertEquals($dump, $this->dbModel->getTableDataDump($tableName));
95+
}
96+
97+
public function testGetHeader()
98+
{
99+
$header = 'header';
100+
$this->dbResourceMock->expects($this->once())
101+
->method('getHeader')
102+
->willReturn($header);
103+
104+
self::assertEquals($header, $this->dbModel->getHeader());
105+
}
106+
107+
public function testGetFooter()
108+
{
109+
$footer = 'footer';
110+
$this->dbResourceMock->expects($this->once())
111+
->method('getFooter')
112+
->willReturn($footer);
113+
114+
self::assertEquals($footer, $this->dbModel->getFooter());
115+
}
116+
117+
public function testRenderSql()
118+
{
119+
$header = 'header';
120+
$script = 'script';
121+
$tableName = 'some_table';
122+
$tables = [$tableName, $tableName];
123+
$dump = 'dump';
124+
$footer = 'footer';
125+
126+
$this->dbResourceMock->expects($this->once())
127+
->method('getTables')
128+
->willReturn($tables);
129+
$this->dbResourceMock->expects($this->once())
130+
->method('getHeader')
131+
->willReturn($header);
132+
$this->dbResourceMock->expects($this->exactly(2))
133+
->method('getTableCreateScript')
134+
->with($tableName, true)
135+
->willReturn($script);
136+
$this->dbResourceMock->expects($this->exactly(2))
137+
->method('getTableDataDump')
138+
->with($tableName)
139+
->willReturn($dump);
140+
$this->dbResourceMock->expects($this->once())
141+
->method('getFooter')
142+
->willReturn($footer);
143+
144+
self::assertEquals(
145+
$header . $script . $dump . $script . $dump . $footer,
146+
$this->dbModel->renderSql()
147+
);
148+
}
149+
150+
public function testCreateBackup()
151+
{
152+
/** @var BackupInterface|\PHPUnit_Framework_MockObject_MockObject $backupMock */
153+
$backupMock = $this->getMockBuilder(BackupInterface::class)->getMock();
154+
/** @var DataObject $tableStatus */
155+
$tableStatus = new DataObject();
156+
157+
$tableName = 'some_table';
158+
$tables = [$tableName];
159+
$header = 'header';
160+
$footer = 'footer';
161+
$dropSql = 'drop_sql';
162+
$createSql = 'create_sql';
163+
$beforeSql = 'before_sql';
164+
$afterSql = 'after_sql';
165+
$dataSql = 'data_sql';
166+
$foreignKeysSql = 'foreign_keys';
167+
$triggersSql = 'triggers_sql';
168+
$rowsCount = 2;
169+
$dataLength = 1;
170+
171+
$this->dbResourceMock->expects($this->once())
172+
->method('beginTransaction');
173+
$this->dbResourceMock->expects($this->once())
174+
->method('commitTransaction');
175+
$this->dbResourceMock->expects($this->once())
176+
->method('getTables')
177+
->willReturn($tables);
178+
$this->dbResourceMock->expects($this->once())
179+
->method('getTableDropSql')
180+
->willReturn($dropSql);
181+
$this->dbResourceMock->expects($this->once())
182+
->method('getTableCreateSql')
183+
->with($tableName, false)
184+
->willReturn($createSql);
185+
$this->dbResourceMock->expects($this->once())
186+
->method('getTableDataBeforeSql')
187+
->with($tableName)
188+
->willReturn($beforeSql);
189+
$this->dbResourceMock->expects($this->once())
190+
->method('getTableDataAfterSql')
191+
->with($tableName)
192+
->willReturn($afterSql);
193+
$this->dbResourceMock->expects($this->once())
194+
->method('getTableDataSql')
195+
->with($tableName, $rowsCount, 0)
196+
->willReturn($dataSql);
197+
$this->dbResourceMock->expects($this->once())
198+
->method('getTableStatus')
199+
->with($tableName)
200+
->willReturn($tableStatus);
201+
$this->dbResourceMock->expects($this->once())
202+
->method('getTables')
203+
->willReturn($createSql);
204+
$this->dbResourceMock->expects($this->once())
205+
->method('getHeader')
206+
->willReturn($header);
207+
$this->dbResourceMock->expects($this->once())
208+
->method('getTableHeader')
209+
->willReturn($header);
210+
$this->dbResourceMock->expects($this->once())
211+
->method('getFooter')
212+
->willReturn($footer);
213+
$this->dbResourceMock->expects($this->once())
214+
->method('getTableForeignKeysSql')
215+
->willReturn($foreignKeysSql);
216+
$this->dbResourceMock->expects($this->once())
217+
->method('getTableTriggersSql')
218+
->willReturn($triggersSql);
219+
$backupMock->expects($this->once())
220+
->method('open');
221+
$backupMock->expects($this->once())
222+
->method('close');
223+
224+
$tableStatus->setRows($rowsCount);
225+
$tableStatus->setDataLength($dataLength);
226+
227+
$backupMock->expects($this->any())
228+
->method('write')
229+
->withConsecutive(
230+
[$this->equalTo($header)],
231+
[$this->equalTo($header . $dropSql . "\n")],
232+
[$this->equalTo($createSql . "\n")],
233+
[$this->equalTo($beforeSql)],
234+
[$this->equalTo($dataSql)],
235+
[$this->equalTo($afterSql)],
236+
[$this->equalTo($foreignKeysSql)],
237+
[$this->equalTo($triggersSql)],
238+
[$this->equalTo($footer)]
239+
);
240+
241+
$this->dbModel->createBackup($backupMock);
242+
}
243+
}

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: 2 additions & 2 deletions
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>
@@ -45,7 +45,7 @@
4545
</span>
4646
<div class="field-tooltip-content"
4747
data-target="dropdown"
48-
translate="'We store you payment information securely on Braintree servers via SSL.'"></div>
48+
translate="'We store your payment information securely on Braintree servers via SSL.'"></div>
4949
</div>
5050
</div>
5151
<!-- /ko -->

app/code/Magento/Bundle/Test/Mftf/Test/AdminRemoveDefaultImageBundleProductTest.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@
7474
<!-- Remove image from product -->
7575
<actionGroup ref="removeProductImage" stepKey="removeProductImage"/>
7676

77-
<!-- Skip success message check when saving product because of bug MAGETWO-91177 -->
78-
<!-- actionGroup ref="saveProductForm" stepKey="saveProductFormAfterRemove"/-->
79-
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProductFormAfterRemove"/>
77+
<actionGroup ref="saveProductForm" stepKey="saveProductFormAfterRemove"/>
8078

8179
<!-- Assert product image not in admin product form -->
8280
<actionGroup ref="assertProductImageNotInAdminProductPage" stepKey="assertProductImageNotInAdminProductPage"/>

app/code/Magento/Captcha/Observer/CheckGuestCheckoutObserver.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,14 @@ public function execute(\Magento\Framework\Event\Observer $observer)
6666
$formId = 'guest_checkout';
6767
$captchaModel = $this->_helper->getCaptcha($formId);
6868
$checkoutMethod = $this->_typeOnepage->getQuote()->getCheckoutMethod();
69-
if ($checkoutMethod == \Magento\Checkout\Model\Type\Onepage::METHOD_GUEST) {
70-
if ($captchaModel->isRequired()) {
71-
$controller = $observer->getControllerAction();
72-
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))
73-
) {
74-
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
75-
$result = ['error' => 1, 'message' => __('Incorrect CAPTCHA')];
76-
$controller->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
77-
}
69+
if ($checkoutMethod == \Magento\Checkout\Model\Type\Onepage::METHOD_GUEST
70+
&& $captchaModel->isRequired()
71+
) {
72+
$controller = $observer->getControllerAction();
73+
if (!$captchaModel->isCorrect($this->captchaStringResolver->resolve($controller->getRequest(), $formId))) {
74+
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
75+
$result = ['error' => 1, 'message' => __('Incorrect CAPTCHA')];
76+
$controller->getResponse()->representJson($this->jsonHelper->jsonEncode($result));
7877
}
7978
}
8079

0 commit comments

Comments
 (0)