From adc857de41fec265432ae2c4877b42460a101867 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 21 May 2024 23:34:34 +0800 Subject: [PATCH] wip Signed-off-by: Mior Muhammad Zaki --- src/Foundation/Console/Concerns/InteractsWithIO.php | 4 +++- src/Foundation/Console/ServeCommand.php | 5 +++-- src/Foundation/Console/TestCommand.php | 4 ++-- src/Foundation/TestbenchServiceProvider.php | 6 +++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Foundation/Console/Concerns/InteractsWithIO.php b/src/Foundation/Console/Concerns/InteractsWithIO.php index 7526d474c..fc4b65747 100644 --- a/src/Foundation/Console/Concerns/InteractsWithIO.php +++ b/src/Foundation/Console/Concerns/InteractsWithIO.php @@ -2,6 +2,8 @@ namespace Orchestra\Testbench\Foundation\Console\Concerns; +use function Orchestra\Testbench\package_path; + /** * @deprecated */ @@ -19,7 +21,7 @@ trait InteractsWithIO protected function copyTaskCompleted(string $from, string $to, string $type, ?string $workingPath = null): void { /** @phpstan-ignore-next-line constant.notFound */ - $workingPath = $workingPath ?? TESTBENCH_WORKING_PATH; + $workingPath = $workingPath ?? package_path(); $from = str_replace($workingPath.'/', '', (string) realpath($from)); diff --git a/src/Foundation/Console/ServeCommand.php b/src/Foundation/Console/ServeCommand.php index a841ba661..4e4d446e7 100644 --- a/src/Foundation/Console/ServeCommand.php +++ b/src/Foundation/Console/ServeCommand.php @@ -9,6 +9,8 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use function Orchestra\Testbench\package_path; + class ServeCommand extends Command { /** @@ -27,8 +29,7 @@ class_exists(ComposerConfig::class, false) ComposerConfig::disableProcessTimeout(); } - /** @phpstan-ignore-next-line constant.notFound */ - $_ENV['TESTBENCH_WORKING_PATH'] = TESTBENCH_WORKING_PATH; + $_ENV['TESTBENCH_WORKING_PATH'] = package_path(); static::$passthroughVariables[] = 'TESTBENCH_WORKING_PATH'; diff --git a/src/Foundation/Console/TestCommand.php b/src/Foundation/Console/TestCommand.php index 8e23bc743..cb647f186 100644 --- a/src/Foundation/Console/TestCommand.php +++ b/src/Foundation/Console/TestCommand.php @@ -126,7 +126,7 @@ protected function phpunitEnvironmentVariables() ->merge([ 'APP_ENV' => 'testing', 'TESTBENCH_PACKAGE_TESTER' => '(true)', - 'TESTBENCH_WORKING_PATH' => TESTBENCH_WORKING_PATH, + 'TESTBENCH_WORKING_PATH' => package_path(), 'TESTBENCH_APP_BASE_PATH' => $this->laravel->basePath(), ])->merge(parent::phpunitEnvironmentVariables()) ->all(); @@ -143,7 +143,7 @@ protected function paratestEnvironmentVariables() ->merge([ 'APP_ENV' => 'testing', 'TESTBENCH_PACKAGE_TESTER' => '(true)', - 'TESTBENCH_WORKING_PATH' => TESTBENCH_WORKING_PATH, + 'TESTBENCH_WORKING_PATH' => package_path(), 'TESTBENCH_APP_BASE_PATH' => $this->laravel->basePath(), ])->merge(parent::paratestEnvironmentVariables()) ->all(); diff --git a/src/Foundation/TestbenchServiceProvider.php b/src/Foundation/TestbenchServiceProvider.php index eef95b5e8..50593b982 100644 --- a/src/Foundation/TestbenchServiceProvider.php +++ b/src/Foundation/TestbenchServiceProvider.php @@ -7,6 +7,8 @@ use Illuminate\Support\ServiceProvider; use NunoMaduro\Collision\Adapters\Laravel\Commands\TestCommand as CollisionTestCommand; +use function Orchestra\Testbench\package_path; + class TestbenchServiceProvider extends ServiceProvider { /** @@ -16,11 +18,9 @@ class TestbenchServiceProvider extends ServiceProvider */ public function register() { - $workingPath = \defined('TESTBENCH_WORKING_PATH') ? TESTBENCH_WORKING_PATH : null; - AboutCommand::add('Testbench', fn () => [ 'Core Version' => class_exists(InstalledVersions::class) ? InstalledVersions::getPrettyVersion('orchestra/testbench-core') : '-', - 'Skeleton Path' => str_replace($workingPath, '', $this->app->basePath()), + 'Skeleton Path' => str_replace(package_path(), '', $this->app->basePath()), ]); }