Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ packages/database.sqlite
packages/database/src/database.sqlite
src/Tempest/database.sqlite
tests/Fixtures/database.sqlite
tests/Fixtures/database*.sqlite
tests/Unit/Console/test-console.log
src/Tempest/Database/src/database.sqlite
.env
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@
"tempest/blade": "dev-main",
"thenetworg/oauth2-azure": "^2.2",
"twig/twig": "^3.16",
"wohali/oauth2-discord-new": "^1.2"
"wohali/oauth2-discord-new": "^1.2",
"brianium/paratest": "^7.14"
},
"replace": {
"tempest/auth": "self.version",
Expand Down
4 changes: 2 additions & 2 deletions packages/container/src/HasInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

trait HasInstance
{
private static self $instance;
private static ?self $instance = null;

public static function instance(): ?self
{
return self::$instance ?? null;
}

public static function setInstance(self $instance): void
public static function setInstance(?self $instance): void
{
self::$instance = $instance;
}
Expand Down
7 changes: 7 additions & 0 deletions src/Tempest/Framework/Testing/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use Tempest\Storage\Testing\StorageTester;
use Throwable;

use function Tempest\env;
use function Tempest\Support\Path\normalize;
use function Tempest\Support\Path\to_absolute_path;

Expand All @@ -46,6 +47,8 @@ abstract class IntegrationTest extends TestCase
{
protected string $root;

protected string $internalStorage;

/** @var \Tempest\Discovery\DiscoveryLocation[] */
protected array $discoveryLocations = [];

Expand Down Expand Up @@ -110,12 +113,14 @@ protected function setupKernel(): self
{
// We force forward slashes for consistency even on Windows.
$this->root ??= normalize(realpath(getcwd()));
$this->internalStorage = $this->root . '/.tempest/test_internal_storage/' . env('TEST_TOKEN', 'default');

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

$this->kernel ??= FrameworkKernel::boot(
root: $this->root,
discoveryLocations: $discoveryLocations,
internalStorage: $this->internalStorage,
);

/** @var GenericContainer $container */
Expand Down Expand Up @@ -234,6 +239,8 @@ protected function tearDown(): void
unset($this->http);
/** @phpstan-ignore-next-line */
unset($this->oauth);

GenericContainer::setInstance(null);
}

protected function assertException(string $expectedExceptionClass, Closure $handler, ?Closure $assertException = null, ?string $message = null): void
Expand Down
4 changes: 3 additions & 1 deletion tests/Fixtures/Config/database.sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Tempest\Database\Config\SQLiteConfig;

use function Tempest\env;

return new SQLiteConfig(
path: __DIR__ . '/../database.sqlite',
path: __DIR__ . '/../database' . env('TEST_TOKEN', 'default') . '.sqlite',
);
4 changes: 2 additions & 2 deletions tests/Integration/Console/Commands/MakeCommandCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ protected function setUp(): void
parent::setUp();

$this->installer->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Console/Commands/MakeConfigCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ protected function setUp(): void
parent::setUp();

$this->installer->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ protected function setUp(): void
parent::setUp();

$this->installer->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ protected function setUp(): void
parent::setUp();

$this->installer->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/Console/Installer/ConsoleInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ protected function setUp(): void

$this->installer
->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
)
->setRoot(__DIR__ . '/install');
->setRoot($this->internalStorage . '/install');
}

protected function tearDown(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ protected function setUp(): void
parent::setUp();

$this->installer->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/Core/FrameworkInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ protected function setUp(): void

$this->installer
->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
)
->setRoot(__DIR__ . '/install');
->setRoot($this->internalStorage . '/install');
}

protected function tearDown(): void
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/Core/InstallCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ protected function setUp(): void

$this->installer
->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
)
->setRoot(__DIR__ . '/install');
->setRoot($this->internalStorage . '/install');
}

protected function tearDown(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Core/PublishesFilesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ protected function setUp(): void
parent::setUp();

$this->installer->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/Core/ViewComponentsInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ protected function setUp(): void

$this->installer
->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
)
->setRoot(__DIR__ . '/install');
->setRoot($this->internalStorage . '/install');

$this->registerViewComponent(
name: 'x-vendor-a',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ protected function setUp(): void

protected function tearDown(): void
{
parent::tearDown();

Filesystem\delete_file(root_path('.env'));

parent::tearDown();
}

public function test_creates_dot_env(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ final class MakeMigrationCommandTest extends FrameworkIntegrationTestCase
#[PreCondition]
protected function configure(): void
{
$this->installer->configure(__DIR__ . '/install', new Psr4Namespace('App\\', __DIR__ . '/install/App'));
$this->installer->configure(
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
);
}

#[PostCondition]
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Database/Commands/MakeModelCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ protected function setUp(): void
parent::setUp();

$this->installer->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Database/DatabaseConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class DatabaseConfigTest extends FrameworkIntegrationTestCase
public function test_strategy_is_taken_into_account(string $strategy, string $expected): void
{
$this->container->config(new SQLiteConfig(
path: __DIR__ . '/../database.sqlite',
path: $this->internalStorage . '/../database.sqlite',
namingStrategy: new $strategy(),
));

Expand Down
8 changes: 4 additions & 4 deletions tests/Integration/Database/MultiDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ protected function setUp(): void
}

$files = [
__DIR__ . '/db-main.sqlite',
__DIR__ . '/db-backup.sqlite',
$this->internalStorage . '/db-main.sqlite',
$this->internalStorage . '/db-backup.sqlite',
];

foreach ($files as $file) {
Expand All @@ -58,12 +58,12 @@ protected function setUp(): void
$this->container->addInitializer(DatabaseInitializer::class);

$this->container->config(new SQLiteConfig(
path: __DIR__ . '/db-main.sqlite',
path: $this->internalStorage . '/db-main.sqlite',
tag: 'main',
));

$this->container->config(new SQLiteConfig(
path: __DIR__ . '/db-backup.sqlite',
path: $this->internalStorage . '/db-backup.sqlite',
tag: 'backup',
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ protected function setUp(): void
parent::setUp();

$this->installer->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Http/DatabaseSessionInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ final class DatabaseSessionInstallerTest extends FrameworkIntegrationTestCase
protected function configure(): void
{
$this->installer
->configure(__DIR__ . '/install', new Psr4Namespace('App\\', __DIR__ . '/install/App'))
->setRoot(__DIR__ . '/install');
->configure($this->internalStorage . '/install', new Psr4Namespace('App\\', $this->internalStorage . '/install/App'))
->setRoot($this->internalStorage . '/install');
}

#[PostCondition]
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Http/MakeControllerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ protected function setUp(): void
parent::setUp();

$this->installer->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Http/MakeRequestCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ protected function setUp(): void
parent::setUp();

$this->installer->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Http/MakeResponseCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ protected function setUp(): void
parent::setUp();

$this->installer->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/View/Commands/MakeViewCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ protected function setUp(): void
parent::setUp();

$this->installer->configure(
__DIR__ . '/install',
new Psr4Namespace('App\\', __DIR__ . '/install/App'),
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/App'),
);
}

Expand Down
9 changes: 6 additions & 3 deletions tests/Integration/Vite/ViteInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ final class ViteInstallerTest extends FrameworkIntegrationTestCase
#[PreCondition]
protected function configure(): void
{
$this->installer->configure(__DIR__ . '/install', new Psr4Namespace('App\\', __DIR__ . '/install/app'));
$this->installer->configure(
$this->internalStorage . '/install',
new Psr4Namespace('App\\', $this->internalStorage . '/install/app'),
);

mkdir(__DIR__ . '/install/node_modules');
mkdir($this->internalStorage . '/install/node_modules');

// force usage of npm because bun will mutate Tempest's root install otherwise
touch(__DIR__ . '/install/package-lock.json');
touch($this->internalStorage . '/install/package-lock.json');
}

#[After]
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Vite/ViteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function setUp(): void
{
parent::setUp();

$this->vite->setRootDirectory(__DIR__ . '/Fixtures/tmp');
$this->vite->setRootDirectory($this->internalStorage . '/Fixtures/tmp');
}

public function test_set_nonce(): void
Expand Down