mirror of
https://github.com/pestphp/pest.git
synced 2026-09-05 22:33:35 +02:00
feat: allow configuring the TIA directory (#1787)
* feat: allow configuring the TIA directory * refactor: simplify TIA directory resolution * fix: bootstrap TIA state after configuration * chore: apply Rector to TIA storage test * fix: stabilize checks on pull requests * fix: align TIA fixture branch resolution * fix: preserve success snapshot formatting * fix: order TIA storage snapshot * chore: keep TIA directory changes scoped
This commit is contained in:
+1
-1
@@ -37,9 +37,9 @@ final class Kernel
|
||||
private const array BOOTSTRAPPERS = [
|
||||
Bootstrappers\BootOverrides::class,
|
||||
Bootstrappers\BootPhpUnitConfiguration::class,
|
||||
Plugins\Tia\Bootstrapper::class,
|
||||
Bootstrappers\BootSubscribers::class,
|
||||
Bootstrappers\BootFiles::class,
|
||||
Plugins\Tia\Bootstrapper::class,
|
||||
Bootstrappers\BootView::class,
|
||||
Bootstrappers\BootKernelDump::class,
|
||||
Bootstrappers\BootExcludeList::class,
|
||||
|
||||
@@ -11,6 +11,16 @@ use Pest\Support\Container;
|
||||
*/
|
||||
final class Configuration
|
||||
{
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function directory(string $directory): self
|
||||
{
|
||||
Storage::useDirectory($directory);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
|
||||
@@ -9,8 +9,17 @@ namespace Pest\Plugins\Tia;
|
||||
*/
|
||||
final class Storage
|
||||
{
|
||||
private static ?string $directory = null;
|
||||
|
||||
public static function tempDir(string $projectRoot): string
|
||||
{
|
||||
if (self::$directory !== null) {
|
||||
$isAbsolute = str_starts_with(self::$directory, DIRECTORY_SEPARATOR)
|
||||
|| preg_match('/^[a-z]:[\\\\\/]/i', self::$directory) === 1;
|
||||
|
||||
return $isAbsolute ? self::$directory : $projectRoot.DIRECTORY_SEPARATOR.self::$directory;
|
||||
}
|
||||
|
||||
$home = self::homeDir();
|
||||
|
||||
if ($home === null) {
|
||||
@@ -25,6 +34,11 @@ final class Storage
|
||||
.DIRECTORY_SEPARATOR.self::projectKey($projectRoot);
|
||||
}
|
||||
|
||||
public static function useDirectory(?string $directory): void
|
||||
{
|
||||
self::$directory = $directory;
|
||||
}
|
||||
|
||||
public static function purge(string $projectRoot): void
|
||||
{
|
||||
$dir = self::tempDir($projectRoot);
|
||||
|
||||
Reference in New Issue
Block a user