Skip to content

Commit 2e0036a

Browse files
committed
#22463 cover changes with unit-test static-test-fix
1 parent bfdb18f commit 2e0036a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,8 @@ public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null)
248248
$toTimeStamp += 86400;
249249
}
250250

251-
$result = false;
252-
if (!$this->_dateTime->isEmptyDate($dateFrom) && $scopeTimeStamp < $fromTimeStamp) {
253-
} elseif (!$this->_dateTime->isEmptyDate($dateTo) && $scopeTimeStamp > $toTimeStamp) {
254-
} else {
255-
$result = true;
256-
}
257-
return $result;
251+
return !(!$this->_dateTime->isEmptyDate($dateFrom) && $scopeTimeStamp < $fromTimeStamp ||
252+
!$this->_dateTime->isEmptyDate($dateTo) && $scopeTimeStamp > $toTimeStamp);
258253
}
259254

260255
/**

lib/internal/Magento/Framework/Stdlib/Test/Unit/DateTime/TimezoneTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,4 +253,15 @@ private function scopeConfigWillReturnConfiguredTimezone($configuredTimezone)
253253
{
254254
$this->scopeConfig->method('getValue')->with('', '', null)->willReturn($configuredTimezone);
255255
}
256+
257+
public function testCheckIfScopeDateSetsTimeZone()
258+
{
259+
$scopeDate = new \DateTime('now', new \DateTimeZone('America/Vancouver'));
260+
$this->scopeConfig->method('getValue')->willReturn('America/Vancouver');
261+
262+
$this->assertEquals(
263+
$scopeDate->getTimezone(),
264+
$this->getTimezone()->scopeDate(0, $scopeDate->getTimestamp())->getTimezone()
265+
);
266+
}
256267
}

0 commit comments

Comments
 (0)