Skip to content

Commit c0175a9

Browse files
committed
MAGETWO-63215: FedEx Shipment Tracking fails for valid tracking number
- Refactored dates parsing
1 parent 75fbb49 commit c0175a9

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

app/code/Magento/Fedex/Model/Carrier.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,19 +1731,15 @@ private function parseDate($timestamp)
17311731
return false;
17321732
}
17331733
$formats = [\DateTime::ATOM, 'Y-m-d\TH:i:s'];
1734-
$tz = date_default_timezone_get();
1735-
17361734
foreach ($formats as $format) {
17371735
// set UTC timezone for a case if timestamp does not contain any timezone
1738-
date_default_timezone_set('UTC');
1739-
$dateTime = \DateTime::createFromFormat($format, $timestamp);
1736+
$utcTimezone = new \DateTimeZone('UTC');
1737+
$dateTime = \DateTime::createFromFormat($format, $timestamp, $utcTimezone);
17401738
if ($dateTime !== false) {
1741-
date_default_timezone_set($tz);
17421739
return $dateTime;
17431740
}
17441741
}
17451742

1746-
date_default_timezone_set($tz);
17471743
return false;
17481744
}
17491745
}

app/code/Magento/Fedex/Test/Unit/Model/CarrierTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,9 @@ public function testGetTrackingErrorResponse()
393393

394394
/**
395395
* @covers \Magento\Fedex\Model\Carrier::getTracking
396-
* @param string $shipTimestamp
397-
* @param string $expectedDate
396+
* @param string $shipTimeStamp
398397
* @param string $expectedDate
398+
* @param string $expectedTime
399399
* @dataProvider shipDateDataProvider
400400
*/
401401
public function testGetTracking($shipTimeStamp, $expectedDate, $expectedTime)
@@ -480,9 +480,9 @@ public function shipDateDataProvider()
480480

481481
/**
482482
* @covers \Magento\Fedex\Model\Carrier::getTracking
483-
* @param string $shipTimestamp
484-
* @param string $expectedDate
483+
* @param string $shipTimeStamp
485484
* @param string $expectedDate
485+
* @param string $expectedTime
486486
* @dataProvider shipDateDataProvider
487487
*/
488488
public function testGetTrackingWithEvents($shipTimeStamp, $expectedDate, $expectedTime)

0 commit comments

Comments
 (0)