Skip to content

Commit 41bc12e

Browse files
committed
Merge branch '2.3-develop' of github.com:magento/magento2ce into community-tests-migration-pr
2 parents bbf4bbc + 0ae802b commit 41bc12e

File tree

169 files changed

+6667
-1265
lines changed

Some content is hidden

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

169 files changed

+6667
-1265
lines changed

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

Lines changed: 66 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Backend\Block\Dashboard;
79

810
/**
@@ -15,7 +17,7 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard
1517
/**
1618
* Api URL
1719
*/
18-
const API_URL = 'http://chart.apis.google.com/chart';
20+
const API_URL = 'https://image-charts.com/chart';
1921

2022
/**
2123
* All series
@@ -76,6 +78,7 @@ class Graph extends \Magento\Backend\Block\Dashboard\AbstractDashboard
7678
/**
7779
* Google chart api data encoding
7880
*
81+
* @deprecated since the Google Image Charts API not accessible from March 14, 2019
7982
* @var string
8083
*/
8184
protected $_encoding = 'e';
@@ -187,11 +190,12 @@ public function getChartUrl($directUrl = true)
187190
{
188191
$params = [
189192
'cht' => 'lc',
190-
'chf' => 'bg,s,ffffff',
191-
'chco' => 'ef672f',
192193
'chls' => '7',
193-
'chxs' => '0,676056,15,0,l,676056|1,676056,15,0,l,676056',
194-
'chm' => 'h,f2ebde,0,0:1:.1,1,-1',
194+
'chf' => 'bg,s,f4f4f4|c,lg,90,ffffff,0.1,ededed,0',
195+
'chm' => 'B,f4d4b2,0,0,0',
196+
'chco' => 'db4814',
197+
'chxs' => '0,0,11|1,0,11',
198+
'chma' => '15,15,15,15'
195199
];
196200

197201
$this->_allSeries = $this->getRowsData($this->_dataRows);
@@ -279,20 +283,11 @@ public function getChartUrl($directUrl = true)
279283
$this->_axisLabels['x'] = $dates;
280284
$this->_allSeries = $datas;
281285

282-
//Google encoding values
283-
if ($this->_encoding == "s") {
284-
// simple encoding
285-
$params['chd'] = "s:";
286-
$dataDelimiter = "";
287-
$dataSetdelimiter = ",";
288-
$dataMissing = "_";
289-
} else {
290-
// extended encoding
291-
$params['chd'] = "e:";
292-
$dataDelimiter = "";
293-
$dataSetdelimiter = ",";
294-
$dataMissing = "__";
295-
}
286+
// Image-Charts Awesome data format values
287+
$params['chd'] = "a:";
288+
$dataDelimiter = ",";
289+
$dataSetdelimiter = "|";
290+
$dataMissing = "_";
296291

297292
// process each string in the array, and find the max length
298293
$localmaxvalue = [0];
@@ -306,7 +301,6 @@ public function getChartUrl($directUrl = true)
306301
$minvalue = min($localminvalue);
307302

308303
// default values
309-
$yrange = 0;
310304
$yLabels = [];
311305
$miny = 0;
312306
$maxy = 0;
@@ -321,52 +315,21 @@ public function getChartUrl($directUrl = true)
321315
$maxy = ceil($maxvalue + 1);
322316
$yLabels = range($miny, $maxy, 1);
323317
}
324-
$yrange = $maxy;
325318
$yorigin = 0;
326319
}
327320

328321
$chartdata = [];
329322

330323
foreach ($this->getAllSeries() as $index => $serie) {
331324
$thisdataarray = $serie;
332-
if ($this->_encoding == "s") {
333-
// SIMPLE ENCODING
334-
for ($j = 0; $j < sizeof($thisdataarray); $j++) {
335-
$currentvalue = $thisdataarray[$j];
336-
if (is_numeric($currentvalue)) {
337-
$ylocation = round(
338-
(strlen($this->_simpleEncoding) - 1) * ($yorigin + $currentvalue) / $yrange
339-
);
340-
$chartdata[] = substr($this->_simpleEncoding, $ylocation, 1) . $dataDelimiter;
341-
} else {
342-
$chartdata[] = $dataMissing . $dataDelimiter;
343-
}
344-
}
345-
} else {
346-
// EXTENDED ENCODING
347-
for ($j = 0; $j < sizeof($thisdataarray); $j++) {
348-
$currentvalue = $thisdataarray[$j];
349-
if (is_numeric($currentvalue)) {
350-
if ($yrange) {
351-
$ylocation = 4095 * ($yorigin + $currentvalue) / $yrange;
352-
} else {
353-
$ylocation = 0;
354-
}
355-
$firstchar = floor($ylocation / 64);
356-
$secondchar = $ylocation % 64;
357-
$mappedchar = substr(
358-
$this->_extendedEncoding,
359-
$firstchar,
360-
1
361-
) . substr(
362-
$this->_extendedEncoding,
363-
$secondchar,
364-
1
365-
);
366-
$chartdata[] = $mappedchar . $dataDelimiter;
367-
} else {
368-
$chartdata[] = $dataMissing . $dataDelimiter;
369-
}
325+
$count = count($thisdataarray);
326+
for ($j = 0; $j < $count; $j++) {
327+
$currentvalue = $thisdataarray[$j];
328+
if (is_numeric($currentvalue)) {
329+
$ylocation = $yorigin + $currentvalue;
330+
$chartdata[] = $ylocation . $dataDelimiter;
331+
} else {
332+
$chartdata[] = $dataMissing . $dataDelimiter;
370333
}
371334
}
372335
$chartdata[] = $dataSetdelimiter;
@@ -381,45 +344,13 @@ public function getChartUrl($directUrl = true)
381344

382345
$valueBuffer = [];
383346

384-
if (sizeof($this->_axisLabels) > 0) {
347+
if (count($this->_axisLabels) > 0) {
385348
$params['chxt'] = implode(',', array_keys($this->_axisLabels));
386349
$indexid = 0;
387350
foreach ($this->_axisLabels as $idx => $labels) {
388351
if ($idx == 'x') {
389-
/**
390-
* Format date
391-
*/
392-
foreach ($this->_axisLabels[$idx] as $_index => $_label) {
393-
if ($_label != '') {
394-
$period = new \DateTime($_label, new \DateTimeZone($timezoneLocal));
395-
switch ($this->getDataHelper()->getParam('period')) {
396-
case '24h':
397-
$this->_axisLabels[$idx][$_index] = $this->_localeDate->formatDateTime(
398-
$period->setTime($period->format('H'), 0, 0),
399-
\IntlDateFormatter::NONE,
400-
\IntlDateFormatter::SHORT
401-
);
402-
break;
403-
case '7d':
404-
case '1m':
405-
$this->_axisLabels[$idx][$_index] = $this->_localeDate->formatDateTime(
406-
$period,
407-
\IntlDateFormatter::SHORT,
408-
\IntlDateFormatter::NONE
409-
);
410-
break;
411-
case '1y':
412-
case '2y':
413-
$this->_axisLabels[$idx][$_index] = date('m/Y', strtotime($_label));
414-
break;
415-
}
416-
} else {
417-
$this->_axisLabels[$idx][$_index] = '';
418-
}
419-
}
420-
352+
$this->formatAxisLabelDate($idx, $timezoneLocal);
421353
$tmpstring = implode('|', $this->_axisLabels[$idx]);
422-
423354
$valueBuffer[] = $indexid . ":|" . $tmpstring;
424355
} elseif ($idx == 'y') {
425356
$valueBuffer[] = $indexid . ":|" . implode('|', $yLabels);
@@ -447,6 +378,46 @@ public function getChartUrl($directUrl = true)
447378
}
448379
}
449380

381+
/**
382+
* Format dates for axis labels
383+
*
384+
* @param string $idx
385+
* @param string $timezoneLocal
386+
*
387+
* @return void
388+
*/
389+
private function formatAxisLabelDate($idx, $timezoneLocal)
390+
{
391+
foreach ($this->_axisLabels[$idx] as $_index => $_label) {
392+
if ($_label != '') {
393+
$period = new \DateTime($_label, new \DateTimeZone($timezoneLocal));
394+
switch ($this->getDataHelper()->getParam('period')) {
395+
case '24h':
396+
$this->_axisLabels[$idx][$_index] = $this->_localeDate->formatDateTime(
397+
$period->setTime($period->format('H'), 0, 0),
398+
\IntlDateFormatter::NONE,
399+
\IntlDateFormatter::SHORT
400+
);
401+
break;
402+
case '7d':
403+
case '1m':
404+
$this->_axisLabels[$idx][$_index] = $this->_localeDate->formatDateTime(
405+
$period,
406+
\IntlDateFormatter::SHORT,
407+
\IntlDateFormatter::NONE
408+
);
409+
break;
410+
case '1y':
411+
case '2y':
412+
$this->_axisLabels[$idx][$_index] = date('m/Y', strtotime($_label));
413+
break;
414+
}
415+
} else {
416+
$this->_axisLabels[$idx][$_index] = '';
417+
}
418+
}
419+
}
420+
450421
/**
451422
* Get rows data
452423
*
@@ -540,6 +511,8 @@ protected function getHeight()
540511
}
541512

542513
/**
514+
* Sets data helper
515+
*
543516
* @param \Magento\Backend\Helper\Dashboard\AbstractDashboard $dataHelper
544517
* @return void
545518
*/

app/code/Magento/Braintree/Controller/Paypal/Review.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\Exception\LocalizedException;
1515
use Magento\Framework\App\Action\HttpPostActionInterface;
1616
use Magento\Framework\App\Action\HttpGetActionInterface;
17+
use Magento\Payment\Model\Method\Logger;
1718

1819
/**
1920
* Class Review
@@ -25,6 +26,11 @@ class Review extends AbstractAction implements HttpPostActionInterface, HttpGetA
2526
*/
2627
private $quoteUpdater;
2728

29+
/**
30+
* @var Logger
31+
*/
32+
private $logger;
33+
2834
/**
2935
* @var string
3036
*/
@@ -37,15 +43,18 @@ class Review extends AbstractAction implements HttpPostActionInterface, HttpGetA
3743
* @param Config $config
3844
* @param Session $checkoutSession
3945
* @param QuoteUpdater $quoteUpdater
46+
* @param Logger $logger
4047
*/
4148
public function __construct(
4249
Context $context,
4350
Config $config,
4451
Session $checkoutSession,
45-
QuoteUpdater $quoteUpdater
52+
QuoteUpdater $quoteUpdater,
53+
Logger $logger
4654
) {
4755
parent::__construct($context, $config, $checkoutSession);
4856
$this->quoteUpdater = $quoteUpdater;
57+
$this->logger = $logger;
4958
}
5059

5160
/**
@@ -57,6 +66,7 @@ public function execute()
5766
$this->getRequest()->getPostValue('result', '{}'),
5867
true
5968
);
69+
$this->logger->debug($requestData);
6070
$quote = $this->checkoutSession->getQuote();
6171

6272
try {

app/code/Magento/Braintree/Model/Paypal/Helper/QuoteUpdater.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ private function updateShippingAddress(Quote $quote, array $details)
123123
{
124124
$shippingAddress = $quote->getShippingAddress();
125125

126-
$shippingAddress->setLastname($details['lastName']);
127-
$shippingAddress->setFirstname($details['firstName']);
126+
$shippingAddress->setLastname($this->getShippingRecipientLastName($details));
127+
$shippingAddress->setFirstname($this->getShippingRecipientFirstName($details));
128128
$shippingAddress->setEmail($details['email']);
129129

130130
$shippingAddress->setCollectShippingRates(true);
@@ -188,4 +188,30 @@ private function updateAddressData(Address $address, array $addressData)
188188
$address->setSameAsBilling(false);
189189
$address->setCustomerAddressId(null);
190190
}
191+
192+
/**
193+
* Returns shipping recipient first name.
194+
*
195+
* @param array $details
196+
* @return string
197+
*/
198+
private function getShippingRecipientFirstName(array $details)
199+
{
200+
return isset($details['shippingAddress']['recipientName'])
201+
? explode(' ', $details['shippingAddress']['recipientName'], 2)[0]
202+
: $details['firstName'];
203+
}
204+
205+
/**
206+
* Returns shipping recipient last name.
207+
*
208+
* @param array $details
209+
* @return string
210+
*/
211+
private function getShippingRecipientLastName(array $details)
212+
{
213+
return isset($details['shippingAddress']['recipientName'])
214+
? explode(' ', $details['shippingAddress']['recipientName'], 2)[1]
215+
: $details['lastName'];
216+
}
191217
}

app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Braintree\Test\Unit\Controller\Paypal;
88

9+
use Magento\Payment\Model\Method\Logger;
910
use Magento\Quote\Model\Quote;
1011
use Magento\Framework\View\Layout;
1112
use Magento\Checkout\Model\Session;
@@ -65,6 +66,11 @@ class ReviewTest extends \PHPUnit\Framework\TestCase
6566
*/
6667
private $review;
6768

69+
/**
70+
* @var Logger|\PHPUnit_Framework_MockObject_MockObject
71+
*/
72+
private $loggerMock;
73+
6874
protected function setUp()
6975
{
7076
/** @var Context|\PHPUnit_Framework_MockObject_MockObject $contextMock */
@@ -88,6 +94,9 @@ protected function setUp()
8894
->getMock();
8995
$this->messageManagerMock = $this->getMockBuilder(ManagerInterface::class)
9096
->getMockForAbstractClass();
97+
$this->loggerMock = $this->getMockBuilder(Logger::class)
98+
->disableOriginalConstructor()
99+
->getMock();
91100

92101
$contextMock->expects(self::once())
93102
->method('getRequest')
@@ -103,7 +112,8 @@ protected function setUp()
103112
$contextMock,
104113
$this->configMock,
105114
$this->checkoutSessionMock,
106-
$this->quoteUpdaterMock
115+
$this->quoteUpdaterMock,
116+
$this->loggerMock
107117
);
108118
}
109119

app/code/Magento/Braintree/Test/Unit/Model/Paypal/Helper/QuoteUpdaterTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private function getDetails(): array
165165
'region' => 'IL',
166166
'postalCode' => '60618',
167167
'countryCodeAlpha2' => 'US',
168-
'recipientName' => 'John Doe',
168+
'recipientName' => 'Jane Smith',
169169
],
170170
'billingAddress' => [
171171
'streetAddress' => '123 Billing Street',
@@ -186,9 +186,9 @@ private function getDetails(): array
186186
private function updateShippingAddressStep(array $details): void
187187
{
188188
$this->shippingAddress->method('setLastname')
189-
->with($details['lastName']);
189+
->with('Smith');
190190
$this->shippingAddress->method('setFirstname')
191-
->with($details['firstName']);
191+
->with('Jane');
192192
$this->shippingAddress->method('setEmail')
193193
->with($details['email']);
194194
$this->shippingAddress->method('setCollectShippingRates')

0 commit comments

Comments
 (0)