Skip to content

Commit 343f4ad

Browse files
committed
Update test to be PHP8.2 compatible
1 parent 3a57f09 commit 343f4ad

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/Storage/TimeToLiveTest.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use DateInterval;
88
use DateTimeImmutable;
99
use DateTimeZone;
10+
use mysql_xdevapi\CollectionModify;
1011
use PHPUnit\Framework\TestCase;
1112
use Stringable;
1213

@@ -26,7 +27,9 @@ public function testItDoesNotReturnTheAbsoluteInterval(): void
2627
*/
2728
public function testItCanBeInstantiatedFromDurationInput(string $input, DateInterval $expected): void
2829
{
29-
self::assertEquals($expected, TimeToLive::fromDurationString($input));
30+
$now = new DateTimeImmutable();
31+
32+
self::assertEquals($now->add($expected), $now->add(TimeToLive::fromDurationString($input)));
3033
}
3134

3235
/**
@@ -47,16 +50,25 @@ public function validDurationString(): iterable
4750
];
4851
}
4952

53+
public function testItCastToNullWithNull(): void
54+
{
55+
self::assertNull(TimeToLive::convert(null));
56+
}
57+
5058
/**
5159
* @dataProvider validDurationInt
5260
*/
53-
public function testItCanBeInstantiatedFromSeconds(int|string|Stringable|null|DateInterval $input, ?DateInterval $expected): void
61+
public function testItCanBeInstantiatedFromSeconds(int|string|Stringable|DateInterval $input, DateInterval $expected): void
5462
{
55-
self::assertEquals($expected, TimeToLive::convert($input));
63+
/** @var DateInterval $ttl */
64+
$ttl = TimeToLive::convert($input);
65+
$now = new DateTimeImmutable();
66+
67+
self::assertEquals($now->add($expected), $now->add($ttl));
5668
}
5769

5870
/**
59-
* @return iterable<string, array{input:int|string|object|null|DateInterval, expected:DateInterval|null}>
71+
* @return iterable<string, array{input:int|string|object|DateInterval, expected:DateInterval|null}>
6072
*/
6173
public function validDurationInt(): iterable
6274
{
@@ -67,11 +79,6 @@ public function validDurationInt(): iterable
6779
'expected' => $seconds,
6880
];
6981

70-
yield 'null' => [
71-
'input' => null,
72-
'expected' => null,
73-
];
74-
7582
yield 'stringable object' => [
7683
'input' => new class() {
7784
public function __toString(): string

0 commit comments

Comments
 (0)