Skip to content

Commit 20f524b

Browse files
committed
feat(tests): support paratest
1 parent 22cfe96 commit 20f524b

28 files changed

+71
-54
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ packages/database.sqlite
1414
packages/database/src/database.sqlite
1515
src/Tempest/database.sqlite
1616
tests/Fixtures/database.sqlite
17+
tests/Fixtures/database*.sqlite
1718
tests/Unit/Console/test-console.log
1819
src/Tempest/Database/src/database.sqlite
1920
.env

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@
8787
"tempest/blade": "dev-main",
8888
"thenetworg/oauth2-azure": "^2.2",
8989
"twig/twig": "^3.16",
90-
"wohali/oauth2-discord-new": "^1.2"
90+
"wohali/oauth2-discord-new": "^1.2",
91+
"brianium/paratest": "^7.14"
9192
},
9293
"replace": {
9394
"tempest/auth": "self.version",

packages/container/src/HasInstance.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
trait HasInstance
88
{
9-
private static self $instance;
9+
private static ?self $instance = null;
1010

1111
public static function instance(): ?self
1212
{
1313
return self::$instance ?? null;
1414
}
1515

16-
public static function setInstance(self $instance): void
16+
public static function setInstance(?self $instance): void
1717
{
1818
self::$instance = $instance;
1919
}

src/Tempest/Framework/Testing/IntegrationTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use Tempest\Storage\Testing\StorageTester;
3838
use Throwable;
3939

40+
use function Tempest\env;
4041
use function Tempest\Support\Path\normalize;
4142
use function Tempest\Support\Path\to_absolute_path;
4243

@@ -47,6 +48,8 @@ abstract class IntegrationTest extends TestCase
4748
{
4849
protected string $root;
4950

51+
protected string $internalStorage;
52+
5053
/** @var \Tempest\Discovery\DiscoveryLocation[] */
5154
protected array $discoveryLocations = [];
5255

@@ -111,12 +114,14 @@ protected function setupKernel(): self
111114
{
112115
// We force forward slashes for consistency even on Windows.
113116
$this->root ??= normalize(realpath(getcwd()));
117+
$this->internalStorage = $this->root . '/.tempest/test_internal_storage/' . env('TEST_TOKEN', 'default');
114118

115119
$discoveryLocations = [...$this->discoveryLocations, ...$this->discoverTestLocations()];
116120

117121
$this->kernel ??= FrameworkKernel::boot(
118122
root: $this->root,
119123
discoveryLocations: $discoveryLocations,
124+
internalStorage: $this->internalStorage,
120125
);
121126

122127
/** @var GenericContainer $container */
@@ -235,6 +240,8 @@ protected function tearDown(): void
235240
unset($this->http);
236241
/** @phpstan-ignore-next-line */
237242
unset($this->oauth);
243+
244+
GenericContainer::setInstance(null);
238245
}
239246

240247
protected function assertException(string $expectedExceptionClass, Closure $handler, ?Closure $assertException = null, ?string $message = null): void

tests/Fixtures/Config/database.sqlite.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
use Tempest\Database\Config\SQLiteConfig;
66

7+
use function Tempest\env;
8+
79
return new SQLiteConfig(
8-
path: __DIR__ . '/../database.sqlite',
10+
path: __DIR__ . '/../database' . env('TEST_TOKEN', 'default') . '.sqlite',
911
);

tests/Integration/Console/Commands/MakeCommandCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ protected function setUp(): void
1919
parent::setUp();
2020

2121
$this->installer->configure(
22-
__DIR__ . '/install',
23-
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
22+
$this->internalStorage . '/install',
23+
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
2424
);
2525
}
2626

tests/Integration/Console/Commands/MakeConfigCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ protected function setUp(): void
3030
parent::setUp();
3131

3232
$this->installer->configure(
33-
__DIR__ . '/install',
34-
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
33+
$this->internalStorage . '/install',
34+
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
3535
);
3636
}
3737

tests/Integration/Console/Commands/MakeGeneratorCommandCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ protected function setUp(): void
1919
parent::setUp();
2020

2121
$this->installer->configure(
22-
__DIR__ . '/install',
23-
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
22+
$this->internalStorage . '/install',
23+
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
2424
);
2525
}
2626

tests/Integration/Console/Commands/MakeMiddlewareCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ protected function setUp(): void
2222
parent::setUp();
2323

2424
$this->installer->configure(
25-
__DIR__ . '/install',
26-
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
25+
$this->internalStorage . '/install',
26+
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
2727
);
2828
}
2929

tests/Integration/Console/Installer/ConsoleInstallerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ protected function setUp(): void
1818

1919
$this->installer
2020
->configure(
21-
__DIR__ . '/install',
22-
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
21+
$this->internalStorage . '/install',
22+
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
2323
)
24-
->setRoot(__DIR__ . '/install');
24+
->setRoot($this->internalStorage . '/install');
2525
}
2626

2727
protected function tearDown(): void

0 commit comments

Comments
 (0)