8000 [Clock] Add PHPUnit 10 attributes · symfony/clock@ecba44b · GitHub
[go: up one dir, main page]

Skip to content

Commit ecba44b

Browse files
committed
[Clock] Add PHPUnit 10 attributes
PHPUnit 11 will complain with the following deprecation: ``` Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead. ``` If we add the attribute too, it stops complaining. So this most be a way to support PHPUnit 11 and older versions.
1 parent f487701 commit ecba44b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Test/ClockSensitiveTrait.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace Symfony\Component\Clock\Test;
1313

14+
use PHPUnit\Framework\Attributes\After;
15+
use PHPUnit\Framework\Attributes\Before;
16+
use PHPUnit\Framework\Attributes\BeforeClass;
A7CF
1417
use Psr\Clock\ClockInterface;
1518
use Symfony\Component\Clock\Clock;
1619
use Symfony\Component\Clock\MockClock;
@@ -48,6 +51,8 @@ public static function mockTime(string|\DateTimeImmutable|bool $when = true): Cl
4851
*
4952
* @internal
5053
*/
54+
#[Before]
55+
#[BeforeClass]
5156
public static function saveClockBeforeTest(bool $save = true): ClockInterface
5257
{
5358
static $originalClock;
@@ -64,6 +69,7 @@ public static function saveClockBeforeTest(bool $save = true): ClockInterface
6469
*
6570
* @internal
6671
*/
72+
#[After]
6773
protected static function restoreClockAfterTest(): void
6874
{
6975
Clock::set(self::saveClockBeforeTest(false));

0 commit comments

Comments
 (0)
0