mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-02 14:25:38 +08:00
fix tests
This commit is contained in:
@@ -57,11 +57,11 @@ $options['driver'] = 'workerman';
|
|||||||
$options['worker-num'] = 1;
|
$options['worker-num'] = 1;
|
||||||
$options['private-mode'] = true;
|
$options['private-mode'] = true;
|
||||||
|
|
||||||
// TODO: optimize this, maybe abstract the application (framework)
|
$kernel = \ZM\Kernel::getInstance();
|
||||||
$bootstrappers = new ReflectionProperty(\ZM\ConsoleApplication::class, 'bootstrappers');
|
$kernel->setEnvironment('development');
|
||||||
foreach ($bootstrappers->getDefaultValue() as $bootstrapper) {
|
$kernel->setTestMode(true);
|
||||||
resolve($bootstrapper)->bootstrap($options);
|
$kernel->setConfigDir(dirname(__DIR__) . '/config');
|
||||||
}
|
$kernel->bootstrap();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
(new Framework($options))->init()->start();
|
(new Framework($options))->init()->start();
|
||||||
|
|||||||
@@ -17,10 +17,12 @@ class Kernel
|
|||||||
|
|
||||||
private string $environment;
|
private string $environment;
|
||||||
|
|
||||||
private bool $debug_mode;
|
private bool $debug_mode = false;
|
||||||
|
|
||||||
private string $log_level;
|
private string $log_level;
|
||||||
|
|
||||||
|
private bool $test_mode = false;
|
||||||
|
|
||||||
private function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
$this->registerBootstrappers([
|
$this->registerBootstrappers([
|
||||||
@@ -106,7 +108,12 @@ class Kernel
|
|||||||
|
|
||||||
public function runningUnitTests(): bool
|
public function runningUnitTests(): bool
|
||||||
{
|
{
|
||||||
return $this->environment('testing');
|
return $this->test_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTestMode(bool $test_mode): void
|
||||||
|
{
|
||||||
|
$this->test_mode = $test_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerBootstrappers(array $bootstrappers): void
|
public function registerBootstrappers(array $bootstrappers): void
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class ZMConfigTest extends TestCase
|
|||||||
try {
|
try {
|
||||||
$init_conf = require SOURCE_ROOT_DIR . '/config/config.php';
|
$init_conf = require SOURCE_ROOT_DIR . '/config/config.php';
|
||||||
$init_conf['source']['paths'] = [$this->vfs->url()];
|
$init_conf['source']['paths'] = [$this->vfs->url()];
|
||||||
$config = new ZMConfig('development', $init_conf);
|
$config = new ZMConfig($init_conf);
|
||||||
} catch (ConfigException $e) {
|
} catch (ConfigException $e) {
|
||||||
$this->fail($e->getMessage());
|
$this->fail($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user