2019-02-21 01:28:52 +05:30
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace common\tests\_support;
|
|
|
|
|
|
|
|
use Codeception\Exception\ModuleConfigException;
|
|
|
|
use Codeception\Module;
|
|
|
|
use Yii;
|
|
|
|
|
|
|
|
class ApplicationRedisBridge extends Module {
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
protected array $config = [
|
2019-02-21 01:28:52 +05:30
|
|
|
'module' => 'Redis',
|
|
|
|
];
|
|
|
|
|
|
|
|
public function _initialize(): void {
|
|
|
|
if (!$this->hasModule($this->config['module'])) {
|
|
|
|
throw new ModuleConfigException($this, 'This module should be used together with Redis module');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @var \Codeception\Module\Redis $module */
|
|
|
|
$module = $this->getModule($this->config['module']);
|
|
|
|
$config = $module->_getConfig();
|
|
|
|
$config['host'] = Yii::$app->redis->hostname;
|
|
|
|
$config['port'] = Yii::$app->redis->port;
|
|
|
|
$config['database'] = Yii::$app->redis->database;
|
|
|
|
$module->_setConfig($config);
|
|
|
|
if ($module->driver !== null) {
|
|
|
|
$module->_initialize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|