Skip to content

Commit 900c0f5

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 900c0f5

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/Storage/Device/S3.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public static function setRetryDelay(int $delay): void
222222
*
223223
* @param int $retries Must be >= 0
224224
* @return void
225+
*
225226
* @throws \InvalidArgumentException
226227
*/
227228
public static function setSlowDownMaxRetries(int $retries): void
@@ -239,6 +240,7 @@ public static function setSlowDownMaxRetries(int $retries): void
239240
*
240241
* @param int $delayMs Must be > 0 and <= slowDownMaxDelayMs
241242
* @return void
243+
*
242244
* @throws \InvalidArgumentException
243245
*/
244246
public static function setSlowDownBaseDelay(int $delayMs): void
@@ -259,6 +261,7 @@ public static function setSlowDownBaseDelay(int $delayMs): void
259261
*
260262
* @param int $delayMs Must be > 0 and >= slowDownBaseDelayMs
261263
* @return void
264+
*
262265
* @throws \InvalidArgumentException
263266
*/
264267
public static function setSlowDownMaxDelay(int $delayMs): void

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)