Skip to content

Commit

Permalink
Use defined_environment_variables()
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Nov 9, 2023
1 parent 5ce4401 commit c76cbbb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 57 deletions.
69 changes: 15 additions & 54 deletions src/Foundation/Console/TestCommand.php
Expand Up @@ -6,6 +6,7 @@
use NunoMaduro\Collision\Adapters\Laravel\Commands\TestCommand as Command;
use Orchestra\Testbench\Foundation\Env;

use function Orchestra\Testbench\defined_environment_variables;
use function Orchestra\Testbench\package_path;

class TestCommand extends Command
Expand Down Expand Up @@ -121,33 +122,13 @@ protected function paratestArguments($options)
*/
protected function phpunitEnvironmentVariables()
{
return Collection::make([
'APP_KEY',
'APP_DEBUG',
'RAY_ENABLED',
'SEND_CACHE_TO_RAY',
'SEND_DUMPS_TO_RAY',
'SEND_JOBS_TO_RAY',
'SEND_LOG_CALLS_TO_RAY',
'SEND_QUERIES_TO_RAY',
'SEND_DUPLICATE_QUERIES_TO_RAY',
'SEND_SLOW_QUERIES_TO_RAY',
'RAY_SLOW_QUERY_THRESHOLD_IN_MS',
'SEND_REQUESTS_TO_RAY',
'SEND_HTTP_CLIENT_REQUESTS_TO_RAY',
'SEND_VIEWS_TO_RAY',
'SEND_DEPRECATED_NOTICES_TO_RAY',
'RAY_HOST',
'RAY_PORT',
'RAY_REMOTE_PATH',
])->mapWithKeys(static function ($key) {
return [$key => Env::forward($key)];
})->merge([
'APP_ENV' => 'testing',
'TESTBENCH_PACKAGE_TESTER' => '(true)',
'TESTBENCH_WORKING_PATH' => TESTBENCH_WORKING_PATH,
'TESTBENCH_APP_BASE_PATH' => $this->laravel->basePath(),
])->merge(parent::phpunitEnvironmentVariables())
return Collection::make(defined_environment_variables())
->merge([
'APP_ENV' => 'testing',
'TESTBENCH_PACKAGE_TESTER' => '(true)',
'TESTBENCH_WORKING_PATH' => TESTBENCH_WORKING_PATH,
'TESTBENCH_APP_BASE_PATH' => $this->laravel->basePath(),
])->merge(parent::phpunitEnvironmentVariables())
->all();
}

Expand All @@ -158,33 +139,13 @@ protected function phpunitEnvironmentVariables()
*/
protected function paratestEnvironmentVariables()
{
return Collection::make([
'APP_KEY',
'APP_DEBUG',
'RAY_ENABLED',
'SEND_CACHE_TO_RAY',
'SEND_DUMPS_TO_RAY',
'SEND_JOBS_TO_RAY',
'SEND_LOG_CALLS_TO_RAY',
'SEND_QUERIES_TO_RAY',
'SEND_DUPLICATE_QUERIES_TO_RAY',
'SEND_SLOW_QUERIES_TO_RAY',
'RAY_SLOW_QUERY_THRESHOLD_IN_MS',
'SEND_REQUESTS_TO_RAY',
'SEND_HTTP_CLIENT_REQUESTS_TO_RAY',
'SEND_VIEWS_TO_RAY',
'SEND_DEPRECATED_NOTICES_TO_RAY',
'RAY_HOST',
'RAY_PORT',
'RAY_REMOTE_PATH',
])->mapWithKeys(static function ($key) {
return [$key => Env::forward($key)];
})->merge([
'APP_ENV' => 'testing',
'TESTBENCH_PACKAGE_TESTER' => '(true)',
'TESTBENCH_WORKING_PATH' => TESTBENCH_WORKING_PATH,
'TESTBENCH_APP_BASE_PATH' => $this->laravel->basePath(),
])->merge(parent::paratestEnvironmentVariables())
return Collection::make(defined_environment_variables())
->merge([
'APP_ENV' => 'testing',
'TESTBENCH_PACKAGE_TESTER' => '(true)',
'TESTBENCH_WORKING_PATH' => TESTBENCH_WORKING_PATH,
'TESTBENCH_APP_BASE_PATH' => $this->laravel->basePath(),
])->merge(parent::paratestEnvironmentVariables())
->all();
}
}
24 changes: 21 additions & 3 deletions src/helpers.php
Expand Up @@ -111,10 +111,28 @@ function defined_environment_variables(): array
{
return Collection::make(array_merge($_SERVER, $_ENV))
->keys()
->mapWithKeys(static function (string $key) {
->merge([
'APP_KEY',
'APP_DEBUG',
'RAY_ENABLED',
'SEND_CACHE_TO_RAY',
'SEND_DUMPS_TO_RAY',
'SEND_JOBS_TO_RAY',
'SEND_LOG_CALLS_TO_RAY',
'SEND_QUERIES_TO_RAY',
'SEND_DUPLICATE_QUERIES_TO_RAY',
'SEND_SLOW_QUERIES_TO_RAY',
'RAY_SLOW_QUERY_THRESHOLD_IN_MS',
'SEND_REQUESTS_TO_RAY',
'SEND_HTTP_CLIENT_REQUESTS_TO_RAY',
'SEND_VIEWS_TO_RAY',
'SEND_DEPRECATED_NOTICES_TO_RAY',
'RAY_HOST',
'RAY_PORT',
'RAY_REMOTE_PATH',
])->mapWithKeys(static function (string $key) {
return [$key => Env::forward($key)];
})
->put('TESTBENCH_WORKING_PATH', package_path())
})->put('TESTBENCH_WORKING_PATH', package_path())
->all();
}

Expand Down

0 comments on commit c76cbbb

Please sign in to comment.