-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mior Muhammad Zaki <[email protected]>
- Loading branch information
Showing
1 changed file
with
43 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,47 @@ | ||
<?php | ||
|
||
use Orchestra\Testbench\Dusk\Console\Commander; | ||
|
||
$APP_KEY = $_SERVER['APP_KEY'] ?? $_ENV['APP_KEY'] ?? 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF'; | ||
$DB_CONNECTION = $_SERVER['DB_CONNECTION'] ?? $_ENV['DB_CONNECTION'] ?? 'testing'; | ||
|
||
$config = ['env' => ['APP_KEY="'.$APP_KEY.'"', 'DB_CONNECTION="'.$DB_CONNECTION.'"'], 'providers' => []]; | ||
|
||
$app = (new Commander($config, realpath(__DIR__.'/../../')))->laravel(); | ||
|
||
unset($APP_KEY, $DB_CONNECTION, $config); | ||
|
||
if (file_exists(__DIR__.'/../routes/testbench.php')) { | ||
$router = $app->make('router'); | ||
|
||
require __DIR__.'/../routes/testbench.php'; | ||
} | ||
use function Orchestra\Testbench\default_environment_variables; | ||
use Orchestra\Testbench\Foundation\Application; | ||
use Orchestra\Testbench\Foundation\Bootstrap\LoadEnvironmentVariablesFromArray; | ||
use Orchestra\Testbench\Foundation\Config; | ||
use Orchestra\Testbench\Workbench\Bootstrap\StartWorkbench; | ||
|
||
/** | ||
* Create Laravel application. | ||
* | ||
* @param string $workingPath | ||
* @return \Illuminate\Foundation\Application | ||
*/ | ||
$createApp = function (string $workingPath) { | ||
$config = Config::loadFromYaml($workingPath); | ||
|
||
$hasEnvironmentFile = file_exists("{$workingPath}/.env"); | ||
|
||
return Application::create( | ||
$config['laravel'], | ||
function ($app) use ($config, $hasEnvironmentFile) { | ||
(new StartWorkbench($config))->bootstrap($app); | ||
|
||
if ($hasEnvironmentFile === false) { | ||
(new LoadEnvironmentVariablesFromArray( | ||
! empty($config['env']) ? $config['env'] : default_environment_variables() | ||
))->bootstrap($app); | ||
} | ||
}, | ||
['load_environment_variables' => $hasEnvironmentFile, 'extra' => $config->getExtraAttributes()], | ||
); | ||
}; | ||
|
||
$app = $createApp(realpath(__DIR__.'/../')); | ||
|
||
unset($createApp); | ||
|
||
/** @var \Illuminate\Routing\Router $router */ | ||
$router = $app->make('router'); | ||
|
||
collect(glob(__DIR__.'/../routes/testbench-*.php')) | ||
->each(function ($routeFile) use ($app, $router) { | ||
require $routeFile; | ||
}); | ||
|
||
return $app; |