Skip to content

Commit bdc4d20

Browse files
committed
test: centralise SlowDown setter teardown to prevent static state leakage
Move per-test S3::set* restore calls into a single tearDown() so that state is always reset even if a test aborts mid-assertion.
1 parent 0fb7f43 commit bdc4d20

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

tests/Storage/Device/S3SlowDownTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ protected function setUp(): void
4040
);
4141
}
4242

43+
protected function tearDown(): void
44+
{
45+
S3::setSlowDownMaxRetries(5);
46+
S3::setSlowDownBaseDelay(100);
47+
S3::setSlowDownMaxDelay(5000);
48+
}
49+
4350
// -----------------------------------------------------------------------
4451
// isTransientError — XML body detection
4552
// -----------------------------------------------------------------------
@@ -184,14 +191,12 @@ public function testSetSlowDownMaxRetries(): void
184191
{
185192
S3::setSlowDownMaxRetries(3);
186193
$this->assertSame(3, self::getStaticProp('slowDownMaxRetries'));
187-
S3::setSlowDownMaxRetries(5); // restore default
188194
}
189195

190196
public function testSetSlowDownMaxRetriesZeroIsAllowed(): void
191197
{
192198
S3::setSlowDownMaxRetries(0);
193199
$this->assertSame(0, self::getStaticProp('slowDownMaxRetries'));
194-
S3::setSlowDownMaxRetries(5); // restore default
195200
}
196201

197202
public function testSetSlowDownMaxRetriesNegativeThrows(): void
@@ -204,7 +209,6 @@ public function testSetSlowDownBaseDelay(): void
204209
{
205210
S3::setSlowDownBaseDelay(200);
206211
$this->assertSame(200, self::getStaticProp('slowDownBaseDelayMs'));
207-
S3::setSlowDownBaseDelay(100); // restore default
208212
}
209213

210214
public function testSetSlowDownBaseDelayZeroThrows(): void
@@ -230,7 +234,6 @@ public function testSetSlowDownMaxDelay(): void
230234
{
231235
S3::setSlowDownMaxDelay(10_000);
232236
$this->assertSame(10_000, self::getStaticProp('slowDownMaxDelayMs'));
233-
S3::setSlowDownMaxDelay(5000); // restore default
234237
}
235238

236239
public function testSetSlowDownMaxDelayZeroThrows(): void

0 commit comments

Comments
 (0)