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:
Daniel Polito
2026-08-12 10:53:45 -03:00
committed by GitHub
parent bf7c6b3134
commit 6b7ca13660
6 changed files with 71 additions and 4 deletions
+1 -1
View File
@@ -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,
+10
View File
@@ -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
*/
+14
View File
@@ -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);