Skip to content

Commit c157a06

Browse files
Merge branch '10.5' into 11.0
2 parents 1297479 + fac35fd commit c157a06

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

.psalm/baseline.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<file src="src/Event/Value/Telemetry/HRTime.php">
6969
<ImpureMethodCall>
7070
<code><![CDATA[fromSecondsAndNanoseconds]]></code>
71+
<code><![CDATA[fromSecondsAndNanoseconds]]></code>
7172
</ImpureMethodCall>
7273
</file>
7374
<file src="src/Event/Value/Telemetry/MemoryUsage.php">

ChangeLog-11.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes of the PHPUnit 11.0 release series are documented in this fi
66

77
### Fixed
88

9+
* [#5652](https://github.com/sebastianbergmann/phpunit/issues/5652): `HRTime::duration()` throws `InvalidArgumentException`
910
* `--exclude-filter` CLI option does not work
1011

1112
## [11.0.4] - 2024-02-29

src/Event/Value/Telemetry/HRTime.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ public function nanoseconds(): int
5656
return $this->nanoseconds;
5757
}
5858

59-
/**
60-
* @throws InvalidArgumentException
61-
*/
6259
public function duration(self $start): Duration
6360
{
6461
$seconds = $this->seconds - $start->seconds();
@@ -71,7 +68,7 @@ public function duration(self $start): Duration
7168
}
7269

7370
if ($seconds < 0) {
74-
throw new InvalidArgumentException('Start needs to be smaller.');
71+
return Duration::fromSecondsAndNanoseconds(0, 0);
7572
}
7673

7774
return Duration::fromSecondsAndNanoseconds(

tests/unit/Event/Value/Telemetry/HRTimeTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function testFromSecondsAndNanosecondsReturnsHRTime(): void
124124
}
125125

126126
#[DataProvider('provideStartGreaterThanEnd')]
127-
public function testDurationRejectsStartGreaterThanEnd(int $startSeconds, int $startNanoseconds, int $endSeconds, int $endNanoseconds): void
127+
public function testDurationIgnoresStartGreaterThanEnd(int $startSeconds, int $startNanoseconds, int $endSeconds, int $endNanoseconds): void
128128
{
129129
$start = HRTime::fromSecondsAndNanoseconds(
130130
$startSeconds,
@@ -136,10 +136,10 @@ public function testDurationRejectsStartGreaterThanEnd(int $startSeconds, int $s
136136
$endNanoseconds,
137137
);
138138

139-
$this->expectException(InvalidArgumentException::class);
140-
$this->expectExceptionMessage('Start needs to be smaller.');
139+
$duration = $end->duration($start);
141140

142-
$end->duration($start);
141+
$this->assertSame(0, $duration->seconds());
142+
$this->assertSame(0, $duration->nanoseconds());
143143
}
144144

145145
#[DataProvider('provideStartEndAndDuration')]

0 commit comments

Comments
 (0)