Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Nov 9, 2024
1 parent b2db92f commit 240927f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/Bootstrap/LoadEnvironmentVariables.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class LoadEnvironmentVariables extends \Illuminate\Foundation\Bootstrap\Lo
protected function createDotenv($app)
{
/** @phpstan-ignore method.notFound, method.notFound */
if (! file_exists(implode(DIRECTORY_SEPARATOR, [$app->environmentPath(), $app->environmentFile()]))) {
if (! file_exists(join_paths($app->environmentPath(), $app->environmentFile()))) {
return Dotenv::create(
Env::getRepository(), (string) realpath(join_paths(__DIR__, 'stubs')), '.env.testbench'
);
Expand Down
11 changes: 6 additions & 5 deletions src/Foundation/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Orchestra\Testbench\Contracts\Config as ConfigContract;
use Symfony\Component\Yaml\Yaml;

use function Orchestra\Testbench\join_paths;
use function Orchestra\Testbench\parse_environment_variables;
use function Orchestra\Testbench\transform_relative_path;

Expand Down Expand Up @@ -199,7 +200,7 @@ public static function loadFromYaml(string $workingPath, ?string $filename = 'te
yield "{$filename}.example";
yield "{$filename}.dist";
})->filter(static function ($file) use ($workingPath) {
return file_exists($workingPath.DIRECTORY_SEPARATOR.$file);
return file_exists(join_paths($workingPath, $file));
})->first();

if (! \is_null($filename)) {
Expand All @@ -208,11 +209,11 @@ public static function loadFromYaml(string $workingPath, ?string $filename = 'te
*
* @phpstan-var TOptionalConfig $config
*/
$config = Yaml::parseFile($workingPath.DIRECTORY_SEPARATOR.$filename);
$config = Yaml::parseFile(join_paths($workingPath, $filename));

$config['laravel'] = transform(Arr::get($config, 'laravel'), static function ($path) use ($workingPath) {
return transform_relative_path($path, $workingPath);
});
$config['laravel'] = transform(
Arr::get($config, 'laravel'), static fn ($path) => transform_relative_path($path, $workingPath)
);

if (isset($config['env']) && \is_array($config['env']) && Arr::isAssoc($config['env'])) {
$config['env'] = parse_environment_variables($config['env']);
Expand Down
1 change: 0 additions & 1 deletion src/Foundation/Console/Signals.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class Signals extends \Illuminate\Console\Signals
* @param callable|null $default
* @return void
*/
#[\Override]
public static function whenAvailable($callback, $default = null)
{
if (\is_null($resolver = static::$availabilityResolver)) {
Expand Down
5 changes: 2 additions & 3 deletions src/Foundation/Console/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ protected function phpunitArguments($options)
$file = $this->phpUnitConfigurationFile();

return Collection::make(parent::phpunitArguments($options))
->reject(static function ($option) {
return str_starts_with($option, '--configuration=');
})->merge(["--configuration={$file}"])
->reject(static fn ($option) => str_starts_with($option, '--configuration='))
->merge(["--configuration={$file}"])
->all();
}

Expand Down
9 changes: 3 additions & 6 deletions src/Workbench/Workbench.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ class Workbench
*/
public static function start(ApplicationContract $app, ConfigContract $config): void
{
$app->singleton(ConfigContract::class, static function () use ($config) {
return $config;
});
$app->singleton(ConfigContract::class, static fn () => $config);
}

/**
Expand Down Expand Up @@ -106,9 +104,8 @@ public static function discoverRoutes(ApplicationContract $app, ConfigContract $
$path = Collection::make([
workbench_path('lang'),
workbench_path('resources', 'lang'),
])->filter(static function ($path) {
return is_dir($path);
})->first();
])->filter(static fn ($path) => is_dir($path))
->first();

if (\is_null($path)) {
return;
Expand Down
9 changes: 3 additions & 6 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ function remote(array|string $command, array|string $env = []): Process
{
$phpBinary = transform(
\defined('PHP_BINARY') ? PHP_BINARY : (new PhpExecutableFinder)->find(),
static function ($phpBinary) {
return ProcessUtils::escapeArgument((string) $phpBinary);
}
static fn ($phpBinary) => ProcessUtils::escapeArgument((string) $phpBinary)
);

$binary = \defined('TESTBENCH_DUSK') ? 'testbench-dusk' : 'testbench';
Expand Down Expand Up @@ -177,9 +175,8 @@ function defined_environment_variables(): array
{
return Collection::make(array_merge($_SERVER, $_ENV))
->keys()
->mapWithKeys(static function (string $key) {
return [$key => Env::forward($key)];
})->unless(
->mapWithKeys(static fn (string $key) => [$key => Env::forward($key)])
->unless(
Env::has('TESTBENCH_WORKING_PATH'), static fn ($env) => $env->put('TESTBENCH_WORKING_PATH', package_path())
)->all();
}
Expand Down

0 comments on commit 240927f

Please sign in to comment.