Skip to content

Commit bc933be

Browse files
committed
Fix date tests for clamp
1 parent afceedd commit bc933be

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

tests/Php86/Php86Test.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ public function testClampSuccess(array $arguments, $result): void
2222
{
2323
[$value, $min, $max] = $arguments;
2424

25-
$this->assertSame($result, clamp($value, $min, $max));
25+
$actual = clamp($value, $min, $max);
26+
27+
if ($value instanceof \DateTimeImmutable) {
28+
$this->assertInstanceOf(\DateTimeImmutable::class, $actual);
29+
30+
$actual = $actual->format('Y-m-d');
31+
}
32+
33+
$this->assertSame($result, $actual);
2634
}
2735

2836
public function testClampNanReturn(): void
@@ -86,11 +94,11 @@ public static function provideValidClampInput(): array
8694
'2025-08-20',
8795
],
8896
[
89-
[new \DateTimeImmutable('2025-08-01'), new \DateTimeImmutable('2025-08-15'), (new \DateTimeImmutable('2025-09-15'))->format('Y-m-d')],
97+
[new \DateTimeImmutable('2025-08-01'), new \DateTimeImmutable('2025-08-15'), new \DateTimeImmutable('2025-09-15')],
9098
'2025-08-15',
9199
],
92100
[
93-
[new \DateTimeImmutable('2025-08-20'), new \DateTimeImmutable('2025-08-15'), (new \DateTimeImmutable('2025-09-15'))->format('Y-m-d')],
101+
[new \DateTimeImmutable('2025-08-20'), new \DateTimeImmutable('2025-08-15'), new \DateTimeImmutable('2025-09-15')],
94102
'2025-08-20',
95103
],
96104
[
@@ -145,11 +153,11 @@ public static function provideInvalidClampInput(): array
145153
return [
146154
[
147155
[4, NAN, 6],
148-
'clamp(): Argument #2 ($min) must be NAN',
156+
'clamp(): Argument #2 ($min) must not be NAN',
149157
],
150158
[
151159
[7, 6, NAN],
152-
'clamp(): Argument #3 ($max) must be NAN',
160+
'clamp(): Argument #3 ($max) must not be NAN',
153161
],
154162
[
155163
[1, 3, 2],

0 commit comments

Comments
 (0)