Пишу свой хелпер в котором хочу реализовать функции для последующего их вызова в тестах.
В к кон фиге codeception.yml:
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
modules:
enabled:
- Db
- PhpBrowser
config:
Db:
dsn: 'mysql:host=localhost;port=3309;dbname=db_1'
user: 'test_user'
password: 'passwd'
databases:
db2:
dsn: 'mysql:host=localhost;port=3309;dbname=db_2'
user: 'test_user'
password: 'passwd'
PhpBrowser:
url: 'http://api.localhost/'
Вот код класса:
<?php
namespace Helper;
use Codeception\Module;
class Universal extends Module
{
private $db1;
private $db2;
public function __construct()
{
$container = \Codeception\Util\Stub::make('Codeception\Lib\ModuleContainer');
$this->db1 = new Module\Db($container, $this->_getConfig('Db'));
$this->db1->_getDbh();
$this->db1->_initialize();
$this->db2 = new Module\Db($container, $this->_getConfig('db2'));
$this->db2->_getDbh();
$this->db2->_initialize();
}
}
При запуске codecept build:
PHP Notice: Undefined index: default in /home/shishmish/Work/gc/vendor/codeception/module-db/src/Codeception/Module/Db.php on line 351
PHP Notice: Undefined index: dsn in /home/shishmish/Work/gc/vendor/codeception/module-db/src/Codeception/Module/Db.php on line 552
PHP Notice: Undefined index: user in /home/shishmish/Work/gc/vendor/codeception/module-db/src/Codeception/Module/Db.php on line 552
PHP Notice: Undefined index: password in /home/shishmish/Work/gc/vendor/codeception/module-db/src/Codeception/Module/Db.php on line 552
In Db.php line 560:
Db: invalid data source name while creating PDO connection
Хочу иметь возможность подключаться к 1-й и 2-й БД по необходимости