Skip to content
Open
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
9 changes: 7 additions & 2 deletions src/testbench/src/Bootstrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ protected static function createRuntimeCopy(string $sourcePath): string
{
$token = $_SERVER['TEST_TOKEN'] ?? $_ENV['TEST_TOKEN'] ?? 'default';
$pid = getmypid();
$runtimePath = sys_get_temp_dir() . "/hypervel-components-testbench-{$token}-{$pid}";
// Normalize the temp dir so that BASE_PATH matches paths derived via
// realpath() (e.g. default_skeleton_path()). On macOS, sys_get_temp_dir()
// returns /var/folders/... but glob() resolves symlinks to /private/var/...
// causing BASE_PATH to differ from app->basePath() used in test assertions.
$tempDir = realpath(sys_get_temp_dir()) ?: sys_get_temp_dir();
$runtimePath = $tempDir . "/hypervel-components-testbench-{$token}-{$pid}";

$filesystem = static::getFilesystem();

Expand All @@ -139,7 +144,7 @@ protected static function createRuntimeCopy(string $sourcePath): string
// (PPID=1, meaning the test process that spawned it exited). Orphaned
// serve processes (confirmed via hypervel.pid) are killed before their
// dirs are removed.
foreach (glob(sys_get_temp_dir() . "/hypervel-components-testbench-{$token}-*") as $staleDir) {
foreach (glob($tempDir . "/hypervel-components-testbench-{$token}-*") as $staleDir) {
if (! $filesystem->isDirectory($staleDir)) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function copyTestbenchDotEnvFile(
bool $resetOnTerminating = true
): void {
$sourcePath = $this->resolveTestbenchSourcePath($filesystem, $workingPath);
$workingPath = $filesystem->isDirectory(join_paths($sourcePath, 'workbench'))
$workingPath = ($sourcePath !== testbench_path() && $filesystem->isDirectory(join_paths($sourcePath, 'workbench')))
? join_paths($sourcePath, 'workbench')
: $sourcePath;

Expand Down
3 changes: 2 additions & 1 deletion tests/Testbench/CommanderPathResolutionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ protected function setUp(): void
{
parent::setUp();

$this->temporaryPackagePath = sys_get_temp_dir() . '/hypervel-testbench-paths-' . getmypid() . '-' . uniqid();
$tempDir = realpath(sys_get_temp_dir()) ?: sys_get_temp_dir();
$this->temporaryPackagePath = $tempDir . '/hypervel-testbench-paths-' . getmypid() . '-' . uniqid();
}

protected function tearDown(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Testbench/Integrations/EnvironmentVariablesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function itCanBeUsedWithoutHavingAnEnvironmentVariablesFile(): void

$user = UserFactory::new()->create();

$this->assertFalse(file_exists(testbench_path('workbench/.env')));
$this->assertFalse(file_exists(testbench_path('hypervel/.env')));
$this->assertFalse(file_exists(base_path('.env')));

$this->assertInstanceOf(User::class, $user);
Expand Down
Loading