Skip to content

Commit

Permalink
Make overflow tests not sensitive to DST
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed May 28, 2021
1 parent 534ac51 commit 1f38f65
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/Carbon/SettersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,9 @@ public function testSetUnitNoOverflow()
$date->$valueUnit === $modulo ||
$$valueUnit - ((int) $date->{"diffIn$unit"}($original, false)) === $value ||
($valueUnit === 'day' &&
$date->format('Y-m-d H:i:s.u') === $original->copy()->modify(($original->day + $value).' days'))
$date->format('Y-m-d H:i:s.u') === $original->copy()
->modify(($original->day + $value).' days')
->format('Y-m-d H:i:s.u'))
) {
$results['current']++;

Expand Down Expand Up @@ -707,7 +709,7 @@ public function testAddUnitNoOverflow()
if ($date->$valueUnit === $value ||
$date->$valueUnit === $modulo ||
(method_exists($date, "diffInReal$unit") && -$date->{"diffInReal$unit"}($original, false) === $value) ||
-((int) $date->{"diffIn$unit"}($original, false)) === $value
-((int) round($date->{"diffIn$unit"}($original, false))) === $value
) {
$results['current']++;

Expand Down Expand Up @@ -737,7 +739,7 @@ public function testAddUnitNoOverflow()
$overflowUnit,
$unit,
$modulo,
$$valueUnit,
$value,
);
}

Expand Down Expand Up @@ -804,7 +806,7 @@ public function testSubUnitNoOverflow()
if ($date->$valueUnit === $value ||
$date->$valueUnit === $modulo ||
(method_exists($date, "diffInReal$unit") && $date->{"diffInReal$unit"}($original, false) === $value) ||
((int) $date->{"diffIn$unit"}($original, false)) === $value
((int) round($date->{"diffIn$unit"}($original, false))) === $value
) {
$results['current']++;

Expand Down Expand Up @@ -834,7 +836,7 @@ public function testSubUnitNoOverflow()
$overflowUnit,
$unit,
$modulo,
$$valueUnit,
$value,
);
}

Expand Down

0 comments on commit 1f38f65

Please sign in to comment.