Skip to content

Commit

Permalink
环境变量读取增强 (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft authored Dec 11, 2021
1 parent 924c9d6 commit 0a3c269
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use Imi\Cli\ImiCommand;
use function Imi\env;
use function Imi\ttyExec;

require \dirname(__DIR__, 4) . '/vendor/autoload.php';
Expand All @@ -21,7 +22,7 @@ function checkHttpServerStatus(): bool
{
sleep(1);
$context = stream_context_create(['http' => ['timeout' => 1]]);
if ('imi' === @file_get_contents(imiGetEnv('HTTP_SERVER_HOST', 'http://127.0.0.1:13000/'), false, $context))
if ('imi' === @file_get_contents(env('HTTP_SERVER_HOST', 'http://127.0.0.1:13000/'), false, $context))
{
$serverStarted = true;
break;
Expand Down
16 changes: 9 additions & 7 deletions tests/unit/AppServer/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

declare(strict_types=1);

use function Imi\env;

return [
// 项目根命名空间
'namespace' => 'Imi\WorkermanGateway\Test\AppServer',
Expand Down Expand Up @@ -62,7 +64,7 @@
'mainServer' => \defined('SWOOLE_VERSION') ? [
'namespace' => 'Imi\WorkermanGateway\Test\AppServer\WebSocketServer',
'type' => \Imi\WorkermanGateway\Swoole\Server\Type::BUSINESS_WEBSOCKET,
// 'host' => imiGetEnv('SERVER_HOST', '127.0.0.1'),
// 'host' => env('SERVER_HOST', '127.0.0.1'),
// 'port' => 13002,
'mode' => \SWOOLE_BASE,
'configs' => [
Expand All @@ -82,7 +84,7 @@
'http' => [
'namespace' => 'Imi\WorkermanGateway\Test\AppServer\ApiServer',
'type' => Imi\Swoole\Server\Type::HTTP,
'host' => imiGetEnv('SERVER_HOST', '127.0.0.1'),
'host' => env('SERVER_HOST', '127.0.0.1'),
'port' => 13000,
],
] : [],
Expand All @@ -92,7 +94,7 @@
'http' => [
'namespace' => 'Imi\WorkermanGateway\Test\AppServer\ApiServer',
'type' => Imi\Workerman\Server\Type::HTTP,
'host' => imiGetEnv('SERVER_HOST', '127.0.0.1'),
'host' => env('SERVER_HOST', '127.0.0.1'),
'port' => 13000,
'configs' => [
'registerAddress' => '127.0.0.1:13004',
Expand All @@ -101,7 +103,7 @@
'register' => [
'namespace' => 'Imi\WorkermanGateway\Test\AppServer\Register',
'type' => Imi\WorkermanGateway\Workerman\Server\Type::REGISTER,
'host' => imiGetEnv('SERVER_HOST', '127.0.0.1'),
'host' => env('SERVER_HOST', '127.0.0.1'),
'port' => 13004,
'configs' => [
],
Expand Down Expand Up @@ -139,9 +141,9 @@
'defaultPool' => 'redis',
'connections' => [
'redis' => [
'host' => imiGetEnv('REDIS_SERVER_HOST', '127.0.0.1'),
'port' => imiGetEnv('REDIS_SERVER_PORT', 6379),
'password' => imiGetEnv('REDIS_SERVER_PASSWORD'),
'host' => env('REDIS_SERVER_HOST', '127.0.0.1'),
'port' => env('REDIS_SERVER_PORT', 6379),
'password' => env('REDIS_SERVER_PASSWORD'),
],
],
],
Expand Down

0 comments on commit 0a3c269

Please sign in to comment.