diff --git a/.gitignore b/.gitignore index 517c2184..357264bb 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ temp/ .phpintel/ .DS_Store /.php_cs.cache +test/runtime \ No newline at end of file diff --git a/.php_cs b/.php_cs index b4804010..9ff88fcc 100644 --- a/.php_cs +++ b/.php_cs @@ -1,39 +1,34 @@ - Dariusz Rumiński -This source file is subject to the MIT license that is bundled -with this source code in the file LICENSE. + +$header = <<<'EOF' +This file is part of Swoft. + +@link https://swoft.org +@document https://doc.swoft.org +@contact group@swoft.org +@license https://github.com/swoft-cloud/swoft/blob/master/LICENSE EOF; + return PhpCsFixer\Config::create() - // ->setRiskyAllowed(true) - // ->setRules(array( - // '@Symfony' => true, - // '@Symfony:risky' => true, - // 'array_syntax' => array('syntax' => 'long'), - // 'combine_consecutive_unsets' => true, - // // one should use PHPUnit methods to set up expected exception instead of annotations - // 'general_phpdoc_annotation_remove' => array('expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp'), - // 'header_comment' => array('header' => $header), - // 'heredoc_to_nowdoc' => true, - // 'no_extra_consecutive_blank_lines' => array('break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'), - // 'no_unreachable_default_argument_value' => true, - // 'no_useless_else' => true, - // 'no_useless_return' => true, - // 'ordered_class_elements' => true, - // 'ordered_imports' => true, - // 'php_unit_strict' => true, - // 'phpdoc_add_missing_param_annotation' => true, - // 'phpdoc_order' => true, - // 'psr4' => true, - // 'strict_comparison' => true, - // 'strict_param' => true, - // )) + ->setRiskyAllowed(true) + ->setRules([ + 'header_comment' => [ + 'commentType' => 'PHPDoc', + 'header' => $header, + 'separate' => 'none' + ], + 'array_syntax' => [ + 'syntax' => 'short' + ], + 'single_quote' => true, + ]) ->setFinder( PhpCsFixer\Finder::create() - ->in('src') - ->in('test') + ->exclude('public') + ->exclude('resources') + ->exclude('config') + ->exclude('runtime') + ->exclude('vendor') + ->in(__DIR__) ) -; -?> + ->setUsingCache(false); diff --git a/composer.json b/composer.json index 066b143a..67604f36 100644 --- a/composer.json +++ b/composer.json @@ -31,11 +31,12 @@ }, "require-dev": { "eaglewu/swoole-ide-helper": "dev-master", - "phpunit/phpunit": "^5.7" + "phpunit/phpunit": "^5.7", + "friendsofphp/php-cs-fixer": "^2.10" }, "autoload-dev": { "psr-4": { - "Swoft\\Test\\": "test" + "SwoftTest\\": "test/Cases" } }, "repositories": { @@ -45,6 +46,7 @@ } }, "scripts": { - "test": "./vendor/bin/phpunit -c phpunit.xml" + "test": "./vendor/bin/phpunit -c phpunit.xml", + "cs-fix": "./vendor/bin/php-cs-fixer fix $1" } } diff --git a/src/Helper/DirHelper.php b/src/Helper/DirHelper.php index 07343bdd..3406887f 100644 --- a/src/Helper/DirHelper.php +++ b/src/Helper/DirHelper.php @@ -272,4 +272,31 @@ public static function directoryIterator( return new \RecursiveIteratorIterator($filterIterator); } + + /** + * @param string $path + * @return bool + */ + public static function deleteDirectory($path): bool + { + try { + $directoryIterator = new \DirectoryIterator($path); + foreach ($directoryIterator as $fileInfo) { + if ($fileInfo->valid() && $fileInfo->isExecutable()) { + if ($fileInfo->isDot()) { + continue; + } elseif ($fileInfo->isDir()) { + if (self::deleteDirectory($fileInfo->getPathname())) { + rmdir($fileInfo->getPathname()); + } + } elseif ($fileInfo->isFile()) { + unlink($fileInfo->getPathname()); + } + } + } + } catch (\Throwable $e) { + return false; + } + return true; + } } diff --git a/src/Helper/Functions.php b/src/Helper/Functions.php index e604e51a..4388a462 100644 --- a/src/Helper/Functions.php +++ b/src/Helper/Functions.php @@ -98,6 +98,20 @@ function bean($name) } } +if (! function_exists('alias')) { + /** + * Get alias + * + * @param string $alias + * @return string + * @throws \InvalidArgumentException + */ + function alias($alias): string + { + return \Swoft\App::getAlias($alias); + } +} + if (! function_exists('request')) { /** * Get the current Request object from RequestContext diff --git a/src/Log/Logger.php b/src/Log/Logger.php index 890bba4d..16bca79b 100644 --- a/src/Log/Logger.php +++ b/src/Log/Logger.php @@ -2,6 +2,7 @@ namespace Swoft\Log; +use Swoft\App; use Swoft\Core\Coroutine; use Swoft\Core\RequestContext; @@ -76,18 +77,17 @@ class Logger extends \Monolog\Logger /** * @var array 日志级别对应名称 */ - protected static $levels - = array( - self::DEBUG => 'debug', - self::INFO => 'info', - self::NOTICE => 'notice', - self::WARNING => 'warning', - self::ERROR => 'error', - self::CRITICAL => 'critical', - self::ALERT => 'alert', - self::EMERGENCY => 'emergency', - self::TRACE => 'trace' - ); + protected static $levels = array( + self::DEBUG => 'debug', + self::INFO => 'info', + self::NOTICE => 'notice', + self::WARNING => 'warning', + self::ERROR => 'error', + self::CRITICAL => 'critical', + self::ALERT => 'alert', + self::EMERGENCY => 'emergency', + self::TRACE => 'trace' + ); public function __construct() { @@ -99,19 +99,18 @@ public function __construct() * @param int $level 日志级别 * @param mixed $message 信息 * @param array $context 附加信息 - * * @return bool */ public function addRecord($level, $message, array $context = array()) { - if (!$this->enable) { + if (! $this->enable) { return true; } $levelName = static::getLevelName($level); - if (!static::$timezone) { - static::$timezone = new \DateTimeZone(date_default_timezone_get() ?: 'UTC'); + if (! static::$timezone) { + static::$timezone = new \DateTimeZone(date_default_timezone_get() ? : 'UTC'); } // php7.1+ always has microseconds enabled, so we do not need this hack @@ -133,7 +132,7 @@ public function addRecord($level, $message, array $context = array()) $this->messages[] = $record; - if (count($this->messages) >= $this->flushInterval) { + if (App::$isInTest || \count($this->messages) >= $this->flushInterval) { $this->flushLog(); } @@ -149,14 +148,13 @@ public function addRecord($level, $message, array $context = array()) * @param string $levelName 级别名 * @param \DateTime $ts 时间 * @param array $extra 附加信息 - * * @return array */ public function formateRecord($message, $context, $level, $levelName, $ts, $extra) { $record = array( - "logid" => RequestContext::getLogid(), - "spanid" => RequestContext::getSpanid(), + 'logid' => RequestContext::getLogid(), + 'spanid' => RequestContext::getSpanid(), 'messages' => $message, 'context' => $context, 'level' => $level, @@ -177,19 +175,19 @@ public function formateRecord($message, $context, $level, $levelName, $ts, $extr */ public function pushLog($key, $val) { - if (!$this->enable || !(is_string($key) || is_numeric($key))) { + if (! $this->enable || ! (\is_string($key) || is_numeric($key))) { return; } $key = urlencode($key); $cid = Coroutine::tid(); - if (is_array($val)) { + if (\is_array($val)) { $this->pushlogs[$cid][] = "$key=" . json_encode($val); - } elseif (is_bool($val)) { + } elseif (\is_bool($val)) { $this->pushlogs[$cid][] = "$key=" . var_export($val, true); - } elseif (is_string($val) || is_numeric($val)) { + } elseif (\is_string($val) || is_numeric($val)) { $this->pushlogs[$cid][] = "$key=" . urlencode($val); - } elseif (is_null($val)) { + } elseif (\is_null($val)) { $this->pushlogs[$cid][] = "$key="; } } @@ -201,7 +199,7 @@ public function pushLog($key, $val) */ public function profileStart($name) { - if (!$this->enable || is_string($name) == false || empty($name)) { + if (! $this->enable || \is_string($name) === false || empty($name)) { return; } $cid = Coroutine::tid(); @@ -215,20 +213,20 @@ public function profileStart($name) */ public function profileEnd($name) { - if (!$this->enable || is_string($name) == false || empty($name)) { + if (! $this->enable || \is_string($name) === false || empty($name)) { return; } $cid = Coroutine::tid(); - if (!isset($this->profiles[$cid][$name])) { + if (! isset($this->profiles[$cid][$name])) { $this->profiles[$cid][$name] = [ 'cost' => 0, 'total' => 0, ]; } - $this->profiles[$cid][$name]['cost'] += microtime(true) - $this->profileStacks[$cid][$name]['start']; - $this->profiles[$cid][$name]['total'] = $this->profiles[$cid][$name]['total'] + 1; + $this->profiles[$cid][$name]['cost'] += microtime(true) - $this->profileStacks[$cid][$name]['start']; + $this->profiles[$cid][$name]['total'] += 1; } /** @@ -238,16 +236,16 @@ public function getProfilesInfos() { $profileAry = []; $cid = Coroutine::tid(); - $profiles = $this->profiles[$cid]?? []; + $profiles = $this->profiles[$cid] ?? []; foreach ($profiles as $key => $profile) { - if (!isset($profile['cost']) || !isset($profile['total'])) { + if (! isset($profile['cost']) || ! isset($profile['total'])) { continue; } - $cost = sprintf("%.2f", $profile['cost'] * 1000); + $cost = sprintf('%.2f', $profile['cost'] * 1000); $profileAry[] = "$key=" . $cost . '(ms)/' . $profile['total']; } - return implode(",", $profileAry); + return implode(',', $profileAry); } /** @@ -259,17 +257,17 @@ public function getProfilesInfos() */ public function counting($name, $hit, $total = null) { - if (!is_string($name) || empty($name)) { + if (! \is_string($name) || empty($name)) { return; } $cid = Coroutine::tid(); - if (!isset($this->countings[$cid][$name])) { + if (! isset($this->countings[$cid][$name])) { $this->countings[$cid][$name] = ['hit' => 0, 'total' => 0]; } - $this->countings[$cid][$name]['hit'] += intval($hit); + $this->countings[$cid][$name]['hit'] += \intval($hit); if ($total !== null) { - $this->countings[$cid][$name]['total'] += intval($total); + $this->countings[$cid][$name]['total'] += \intval($total); } } @@ -279,15 +277,15 @@ public function counting($name, $hit, $total = null) public function getCountingInfo() { $cid = Coroutine::tid(); - if (!isset($this->countings[$cid]) || empty($this->countings[$cid])) { - return ""; + if (! isset($this->countings[$cid]) || empty($this->countings[$cid])) { + return ''; } $countAry = []; $countings = $this->countings[$cid]; - foreach ($countings as $name => $counter) { - if (isset($counter['hit'], $counter['total']) && $counter['total'] != 0) { - $countAry[] = "$name=" . $counter['hit'] . "/" . $counter['total']; + foreach ($countings ?? [] as $name => $counter) { + if (isset($counter['hit'], $counter['total']) && $counter['total'] !== 0) { + $countAry[] = "$name=" . $counter['hit'] . '/' . $counter['total']; } elseif (isset($counter['hit'])) { $countAry[] = "$name=" . $counter['hit']; } @@ -299,12 +297,11 @@ public function getCountingInfo() * 写入日志信息格式化 * * @param $message - * * @return string */ public function formatMessage($message) { - if (is_array($message)) { + if (\is_array($message)) { return json_encode($message); } return $message; @@ -314,13 +311,12 @@ public function formatMessage($message) * 计算调用trace * * @param $message - * * @return string */ public function getTrace($message) { $traces = debug_backtrace(); - $count = count($traces); + $count = \count($traces); $ex = ''; if ($count >= 7) { $info = $traces[6]; @@ -339,7 +335,7 @@ public function getTrace($message) } } - if (!empty($ex)) { + if (! empty($ex)) { $message = "trace[$ex] " . $message; } @@ -374,38 +370,35 @@ public function flushLog() */ public function appendNoticeLog($flush = false) { - if (!$this->enable) { + if (! $this->enable) { return; } $cid = Coroutine::tid(); $ts = $this->getLoggerTime(); // php耗时单位ms毫秒 - $timeUsed = sprintf("%.2f", (microtime(true) - $this->getRequestTime()) * 1000); + $timeUsed = sprintf('%.2f', (microtime(true) - $this->getRequestTime()) * 1000); // php运行内存大小单位M - $memUsed = sprintf("%.0f", memory_get_peak_usage() / (1024 * 1024)); + $memUsed = sprintf('%.0f', memory_get_peak_usage() / (1024 * 1024)); $profileInfo = $this->getProfilesInfos(); $countingInfo = $this->getCountingInfo(); - $pushlogs = $this->pushlogs[$cid]??[]; + $pushlogs = $this->pushlogs[$cid] ?? []; $messageAry = array( "[$timeUsed(ms)]", "[$memUsed(MB)]", "[{$this->getUri()}]", - "[" . implode(" ", $pushlogs) . "]", - "profile[" . $profileInfo . "]", - "counting[" . $countingInfo . "]" + '[' . implode(' ', $pushlogs) . ']', + 'profile[' . $profileInfo . ']', + 'counting[' . $countingInfo . ']' ); - $message = implode(" ", $messageAry); + $message = implode(' ', $messageAry); - unset($this->profiles[$cid]); - unset($this->countings[$cid]); - unset($this->pushlogs[$cid]); - unset($this->profileStacks[$cid]); + unset($this->profiles[$cid], $this->countings[$cid], $this->pushlogs[$cid], $this->profileStacks[$cid]); $levelName = self::$levels[self::NOTICE]; $message = $this->formateRecord($message, [], self::NOTICE, $levelName, $ts, []); @@ -413,7 +406,7 @@ public function appendNoticeLog($flush = false) $this->messages[] = $message; // 一个请求完成刷新一次或达到刷新的次数 - $isReached = count($this->messages) >= $this->flushInterval; + $isReached = \count($this->messages) >= $this->flushInterval; if ($this->flushRequest || $isReached || $flush) { $this->flushLog(); } @@ -426,8 +419,8 @@ public function appendNoticeLog($flush = false) */ private function getLoggerTime() { - if (!static::$timezone) { - static::$timezone = new \DateTimeZone(date_default_timezone_get() ?: 'UTC'); + if (! static::$timezone) { + static::$timezone = new \DateTimeZone(date_default_timezone_get() ? : 'UTC'); } // php7.1+ always has microseconds enabled, so we do not need this hack @@ -459,7 +452,6 @@ public function initialize() * * @param $message 日志信息 * @param array $context 附加信息 - * * @return bool */ public function addTrace($message, array $context = array()) @@ -483,7 +475,7 @@ public function setFlushInterval(int $flushInterval) private function getUri() { $contextData = RequestContext::getContextData(); - $uri = $contextData['uri']?? ""; + $uri = $contextData['uri'] ?? ''; return $uri; } @@ -495,7 +487,7 @@ private function getUri() private function getRequestTime() { $contextData = RequestContext::getContextData(); - $requestTime = $contextData['requestTime']?? 0; + $requestTime = $contextData['requestTime'] ?? 0; return $requestTime; } } diff --git a/test/Cases/AbstractTestCase.php b/test/Cases/AbstractTestCase.php new file mode 100644 index 00000000..86f08d64 --- /dev/null +++ b/test/Cases/AbstractTestCase.php @@ -0,0 +1,24 @@ + + * @copyright Copyright 2010-2017 Swoft software + * @license PHP Version 7.x {@link http://www.php.net/license/3_0.txt} + */ +class AbstractTestCase extends TestCase +{ +} diff --git a/test/Testing/Aop/AllPointAspect.php b/test/Cases/Aop/AllPointAspect.php similarity index 87% rename from test/Testing/Aop/AllPointAspect.php rename to test/Cases/Aop/AllPointAspect.php index 2bec29fa..276f5928 100644 --- a/test/Testing/Aop/AllPointAspect.php +++ b/test/Cases/Aop/AllPointAspect.php @@ -1,6 +1,13 @@ getReturn()." afterReturn2 "; + return $joinPoint->getReturn().' afterReturn2 '; } /** diff --git a/test/Testing/Aop/AnnotationAop.php b/test/Cases/Aop/AnnotationAop.php similarity index 73% rename from test/Testing/Aop/AnnotationAop.php rename to test/Cases/Aop/AnnotationAop.php index 8a65c1fc..0d386719 100644 --- a/test/Testing/Aop/AnnotationAop.php +++ b/test/Cases/Aop/AnnotationAop.php @@ -1,6 +1,13 @@ getArgs(); foreach ($args as $arg) { - $newArgs[] = $arg."-new"; + $newArgs[] = $arg.'-new'; } $tag = ' regAspect around before '; $result = $proceedingJoinPoint->proceed($newArgs); diff --git a/test/Testing/Aop/RegAspect.php b/test/Cases/Aop/RegAspect.php similarity index 73% rename from test/Testing/Aop/RegAspect.php rename to test/Cases/Aop/RegAspect.php index 742111c7..8fc280a1 100644 --- a/test/Testing/Aop/RegAspect.php +++ b/test/Cases/Aop/RegAspect.php @@ -1,6 +1,13 @@ doAop(); $this->assertEquals('do aop around-before2 before2 around-after2 afterReturn2 around-before1 before1 around-after1 afterReturn1 ', $result); @@ -53,7 +59,7 @@ public function testNewAopParams() { /* @var RegBean $annotationBean*/ $annotationBean = App::getBean(RegBean::class); - $result = $annotationBean->methodParams("a", 'b'); + $result = $annotationBean->methodParams('a', 'b'); $this->assertEquals('methodParams-a-new-b-new regAspect around before regAspect around after ', $result); } } diff --git a/test/Testing/Bean/ProxyBase.php b/test/Cases/Bean/ProxyBase.php similarity index 86% rename from test/Testing/Bean/ProxyBase.php rename to test/Cases/Bean/ProxyBase.php index 0b07f2bb..8dcd8391 100644 --- a/test/Testing/Bean/ProxyBase.php +++ b/test/Cases/Bean/ProxyBase.php @@ -1,6 +1,13 @@ logger = bean('logger'); + $this->assertInstanceOf(Logger::class, $this->logger); + } + + + /** + * Tears down the fixture, for example, close a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { + parent::tearDown(); + DirHelper::deleteDirectory(alias('@runtime')); + } + + /** + * @test + */ + public function info() + { + $infoMessage = 'Test Info Message'; + $result = $this->logger->info($infoMessage); + $this->assertTrue($result); + $this->assertContains($infoMessage, $this->getNoticeLog()); + } + + /** + * @test + */ + public function error() + { + $errorMessage = 'Test Error Message'; + $result = $this->logger->error($errorMessage . 1); + $this->assertTrue($result); + $this->assertContains($errorMessage . 1, $this->getErrorLog()); + $result = $this->logger->err($errorMessage . 2); + $this->assertTrue($result); + $this->assertContains($errorMessage . 2, $this->getErrorLog()); + } + + /** + * @return bool|string + */ + protected function getNoticeLog() + { + return file_get_contents(alias('@runtime/logs/notice.log')); + } + + /** + * @return bool|string + */ + protected function getErrorLog() + { + return file_get_contents(alias('@runtime/logs/error.log')); + } + +} \ No newline at end of file diff --git a/test/Testing/Pool/ConsulEnvConfig.php b/test/Cases/Pool/ConsulEnvConfig.php similarity index 86% rename from test/Testing/Pool/ConsulEnvConfig.php rename to test/Cases/Pool/ConsulEnvConfig.php index cd818a41..7fb3efb8 100644 --- a/test/Testing/Pool/ConsulEnvConfig.php +++ b/test/Cases/Pool/ConsulEnvConfig.php @@ -1,6 +1,13 @@ assertEquals('http://127.0.0.1:82', $pConfig->getAddress()); $this->assertEquals(2, $pConfig->getTimeout()); $this->assertEquals(2, $pConfig->getInterval()); - $this->assertEquals([1,2], $pConfig->getTags()); + $this->assertEquals([1, 2], $pConfig->getTags()); } -} \ No newline at end of file +} diff --git a/test/bootstrap.php b/test/bootstrap.php index 430179c1..171856dd 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -1,11 +1,19 @@ bootstrap(); @@ -14,5 +22,3 @@ $initApplicationContext = new \Swoft\Core\InitApplicationContext(); $initApplicationContext->init(); \Swoft\App::$isInTest = true; - - diff --git a/test/config/beans/base.php b/test/config/beans/base.php index 02a0e87f..b4cbd65d 100644 --- a/test/config/beans/base.php +++ b/test/config/beans/base.php @@ -1,7 +1,10 @@ [ - 'class' => \Swoft\Event\EventManager::class, - ], -]; +/** + * This file is part of Swoft. + * + * @link https://swoft.org + * @document https://doc.swoft.org + * @contact group@swoft.org + * @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE + */ +return []; diff --git a/test/config/beans/log.php b/test/config/beans/log.php index 5a2e1210..433cbf4b 100644 --- a/test/config/beans/log.php +++ b/test/config/beans/log.php @@ -1,31 +1,40 @@ [ - "class" => \Swoft\Log\FileHandler::class, - "logFile" => "@runtime/logs/notice.log", + 'noticeHandler' => [ + 'class' => \Swoft\Log\FileHandler::class, + 'logFile' => '@runtime/logs/notice.log', 'formatter' => '${lineFormatter}', - "levels" => [ + 'levels' => [ \Swoft\Log\Logger::NOTICE, \Swoft\Log\Logger::INFO, \Swoft\Log\Logger::DEBUG, \Swoft\Log\Logger::TRACE, ] ], - "applicationHandler" => [ - "class" => \Swoft\Log\FileHandler::class, - "logFile" => "@runtime/logs/error.log", + 'applicationHandler' => [ + 'class' => \Swoft\Log\FileHandler::class, + 'logFile' => '@runtime/logs/error.log', 'formatter' => '${lineFormatter}', - "levels" => [ + 'levels' => [ \Swoft\Log\Logger::ERROR, \Swoft\Log\Logger::WARNING ] ], - "logger" => [ - "class" => \Swoft\Log\Logger::class, - "name" => APP_NAME, - "flushInterval" => 100, - "flushRequest" => true, - "handlers" => [ + 'logger' => [ + 'class' => \Swoft\Log\Logger::class, + 'name' => APP_NAME, + 'enable' => true, + 'flushInterval' => 100, + 'flushRequest' => true, + 'handlers' => [ '${noticeHandler}', '${applicationHandler}' ] diff --git a/test/config/define.php b/test/config/define.php index e18d4172..755db072 100644 --- a/test/config/define.php +++ b/test/config/define.php @@ -1,17 +1,19 @@ BASE_PATH, '@app' => '@root/app', diff --git a/test/config/properties/app.php b/test/config/properties/app.php index 070deff9..518ff570 100644 --- a/test/config/properties/app.php +++ b/test/config/properties/app.php @@ -1,22 +1,22 @@ '1.0', - 'autoInitBean' => true, - 'beanScan' => [ - 'Swoft\\Test\\Testing' => BASE_PATH . "/Testing", + 'version' => '1.0', + 'autoInitBean' => true, + 'beanScan' => [ + 'SwoftTest\\Aop' => BASE_PATH . '/Cases/Aop', + 'SwoftTest\\Bean' => BASE_PATH . '/Cases/Bean', + 'SwoftTest\\Pool' => BASE_PATH . '/Cases/Pool', ], - 'bootScan' => [ - ], - 'I18n' => [ - 'sourceLanguage' => '@root/resources/messages/', - ], - 'env' => 'Base', - 'user.stelin.steln' => 'fafafa', - 'Service' => [ - 'user' => [ - 'timeout' => 3000 - ] - ], - 'provider' => require dirname(__FILE__).DS."provider.php", - 'test' => require dirname(__FILE__).DS."test.php", + 'bootScan' => [], + 'env' => 'Base', + 'provider' => require __DIR__ . DS . 'provider.php', + 'test' => require __DIR__ . DS . 'test.php', ]; diff --git a/test/config/properties/provider.php b/test/config/properties/provider.php index 6a57f872..62ef589f 100644 --- a/test/config/properties/provider.php +++ b/test/config/properties/provider.php @@ -1,4 +1,12 @@ [ 'address' => 'http://127.0.0.1:81', diff --git a/test/config/properties/test.php b/test/config/properties/test.php index ae399dfe..92d64620 100644 --- a/test/config/properties/test.php +++ b/test/config/properties/test.php @@ -1,31 +1,39 @@ [ - 'name' => 'test', - "uri" => [ + 'test' => [ + 'name' => 'test', + 'uri' => [ '127.0.0.1:6379', '127.0.0.1:6378', ], - "maxIdel" => 1, - "maxActive" => 1, - "maxWait" => 1, - "timeout" => 1, - "balancer" => 'b', - "useProvider" => true, + 'maxIdel' => 1, + 'maxActive' => 1, + 'maxWait' => 1, + 'timeout' => 1, + 'balancer' => 'b', + 'useProvider' => true, 'provider' => 'p', ], 'test2' => [ - 'name' => 'test2', - "uri" => [ + 'name' => 'test2', + 'uri' => [ '127.0.0.1:6379', '127.0.0.1:6378', ], - "maxIdel" => 2, - "maxActive" => 2, - "maxWait" => 2, - "timeout" => 2, - "balancer" => 'b2', - "useProvider" => true, + 'maxIdel' => 2, + 'maxActive' => 2, + 'maxWait' => 2, + 'timeout' => 2, + 'balancer' => 'b2', + 'useProvider' => true, 'provider' => 'p2', ], ]; diff --git a/test/config/server.php b/test/config/server.php index b83d5526..9de3f7ad 100644 --- a/test/config/server.php +++ b/test/config/server.php @@ -1,4 +1,12 @@ [ 'pfile' => env('PFILE', '/tmp/swoft.pid'), diff --git a/test/docker-compose.yml b/test/docker-compose.yml index a234d768..8cf7455c 100644 --- a/test/docker-compose.yml +++ b/test/docker-compose.yml @@ -2,7 +2,7 @@ version: '2' services: swoft-unittest: build: ./ - container_name: swoft-unittest + container_name: swoft-framework-unittest volumes: - ../:/var/www/swoft working_dir: /var/www/swoft/test