|
14 | 14 | */ |
15 | 15 | class TimeoutTest extends TestCase |
16 | 16 | { |
17 | | - private Carbon $nowTime; |
| 17 | + private const NOW_TIME = '2021-02-20T00:00:00+0000'; |
18 | 18 |
|
19 | | - public function setUp(): void |
| 19 | + public static function conditionProvider(): array |
20 | 20 | { |
21 | | - parent::setUp(); |
22 | | - |
23 | | - $this->nowTime = Carbon::parse('2021-02-20T00:00:00'); |
24 | | - } |
25 | | - |
26 | | - public function conditionProvider(): array |
27 | | - { |
28 | | - $this->nowTime = Carbon::parse('2021-02-20T00:00:00'); |
29 | | - Carbon::setTestNow($this->nowTime); |
| 21 | + $nowTime = Carbon::parse(self::NOW_TIME); |
| 22 | + Carbon::setTestNow($nowTime); |
30 | 23 |
|
31 | 24 | return [ |
32 | 25 | 'Carbon true' => [ |
@@ -83,13 +76,14 @@ public function conditionProvider(): array |
83 | 76 | */ |
84 | 77 | public function testCondition($timeout, Carbon $expiredAt, bool $expected): void |
85 | 78 | { |
86 | | - Carbon::setTestNow($this->nowTime); |
| 79 | + $nowTime = Carbon::parse(self::NOW_TIME); |
| 80 | + Carbon::setTestNow($nowTime); |
87 | 81 | $basePromise = new BasePromise(new TestPromise()); |
88 | 82 | $condition = new Timeout($timeout); |
89 | 83 | $expiredAtResult = $condition->getExpiredAt(); |
90 | 84 | self::assertEquals($expiredAt, $expiredAtResult); |
91 | 85 |
|
92 | | - Carbon::setTestNow($this->nowTime->addMinutes(2)); |
| 86 | + Carbon::setTestNow($nowTime->addMinutes(2)); |
93 | 87 | $result = $condition->condition($basePromise); |
94 | 88 |
|
95 | 89 | self::assertEquals($expected, $result); |
|
0 commit comments