Skip to content

Commit 080f5b4

Browse files
authored
[13.x] Flush Str factories when tearing down test case (laravel#57296)
* reset string factory methods * reset factory state * style
1 parent b38f44a commit 080f5b4

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ protected function tearDownTheTestEnvironment(): void
184184
Queue::createPayloadUsing(null);
185185
RegisterProviders::flushState();
186186
Sleep::fake(false);
187+
Str::resetFactoryState();
187188
TrimStrings::flushState();
188189
TrustProxies::flushState();
189190
TrustHosts::flushState();

src/Illuminate/Support/Str.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,4 +2088,16 @@ public static function flushCache()
20882088
static::$camelCache = [];
20892089
static::$studlyCache = [];
20902090
}
2091+
2092+
/**
2093+
* Return all factory functions to their default state.
2094+
*
2095+
* @return void
2096+
*/
2097+
public static function resetFactoryState()
2098+
{
2099+
static::createRandomStringsNormally();
2100+
static::createUlidsNormally();
2101+
static::createUuidsNormally();
2102+
}
20912103
}

0 commit comments

Comments
 (0)