Skip to content

Commit

Permalink
set the configuration for testing for github actions (Hopefully)
Browse files Browse the repository at this point in the history
  • Loading branch information
sajed-zarrinpour committed Sep 6, 2024
1 parent 7016cb7 commit 6b26fbc
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,37 @@
if (!function_exists('config')) {
function config(string $key): string
{
$envl = new envLoader;
$envl(__DIR__ . '/../../../../..');
if(isset($_ENV['TEST']) && $_ENV['TEST'] == true)
{
$configs = [
'host' => '127.0.0.1',
'port' => '3306',
'database' => 'test_db',
'user' => 'root',
'password' => 'root',
];

if (!isset($configs[$key]))
throw new \Exception('requested config key not found');
return $configs[$key];
}
else
{

$configs = [
'host' => getenv('DB_HOST') ?? '127.0.0.1',
'port' => getenv('DB_PORT') ?? '3306',
'database' => getenv('DB_DATABASE') ?? 'laravel',
'user' => getenv('DB_USER') ?? 'dev',
'password' => getenv('DB_PASSWORD') ?? 'password',
];

if (empty($configs[$key]))
throw new \Exception('requested config key not found');
return $configs[$key];
$envl = new envLoader;
$envl(__DIR__ . '/../../../../..');

$configs = [
'host' => getenv('DB_HOST') ?? '127.0.0.1',
'port' => getenv('DB_PORT') ?? '3306',
'database' => getenv('DB_DATABASE') ?? 'laravel',
'user' => getenv('DB_USER') ?? 'dev',
'password' => getenv('DB_PASSWORD') ?? 'password',
];

if (!isset($configs[$key]))
throw new \Exception('requested config key not found');
return $configs[$key];
}
}
}

0 comments on commit 6b26fbc

Please sign in to comment.