1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 22:27:34 +02:00

Reenforced proper module access

\Helper\DelayedDb public methods shouldn't be used as Actor methods
This commit is contained in:
Deltik
2018-02-19 15:17:31 -06:00
parent b9ddda1909
commit eed4b6b10e
5 changed files with 28 additions and 25 deletions

View File

@@ -19,12 +19,6 @@ extensions:
- Codeception\Extension\RunFailed - Codeception\Extension\RunFailed
modules: modules:
enabled: enabled:
- \Helper\DelayedDb:
dsn: 'mysql:host=%manual.db.host%;port=%manual.db.port%;dbname=%manual.db.dbname%'
user: '%manual.db.user%'
password: '%manual.db.password%'
populate: true
dump: 'tests/_data/e107_v2.1.8.sample.sql'
- \Helper\DeployerFactory: - \Helper\DeployerFactory:
secrets: secrets:
cpanel: cpanel:
@@ -32,3 +26,9 @@ modules:
hostname: '%cpanel.hostname%' hostname: '%cpanel.hostname%'
username: '%cpanel.username%' username: '%cpanel.username%'
password: '%cpanel.password%' password: '%cpanel.password%'
- \Helper\DelayedDb:
dsn: 'mysql:host=%manual.db.host%;port=%manual.db.port%;dbname=%manual.db.dbname%'
user: '%manual.db.user%'
password: '%manual.db.password%'
populate: true
dump: 'tests/_data/e107_v2.1.8.sample.sql'

View File

@@ -9,6 +9,13 @@ abstract class Base extends \Codeception\Module
protected $deployer; protected $deployer;
protected $deployer_components = ['db', 'fs']; protected $deployer_components = ['db', 'fs'];
protected $db;
public function getHelperDb()
{
return $this->db ?: $this->db = $this->getModule('\Helper\DelayedDb');
}
public function _beforeSuite($settings = array()) public function _beforeSuite($settings = array())
{ {
$this->deployer = $this->getModule('\Helper\DeployerFactory')->create(); $this->deployer = $this->getModule('\Helper\DeployerFactory')->create();
@@ -48,8 +55,8 @@ abstract class Base extends \Codeception\Module
protected function _reconfigure_db() protected function _reconfigure_db()
{ {
$db = $this->getModule('\Helper\DelayedDb'); $db = $this->getHelperDb();
$Db_config = $db->getConfig(); $Db_config = $db->_getConfig();
$Db_config['dsn'] = $this->deployer->getDsn(); $Db_config['dsn'] = $this->deployer->getDsn();
$Db_config['user'] = $this->deployer->getDbUsername(); $Db_config['user'] = $this->deployer->getDbUsername();
$Db_config['password'] = $this->deployer->getDbPassword(); $Db_config['password'] = $this->deployer->getDbPassword();

View File

@@ -18,12 +18,7 @@ class DelayedDb extends \Codeception\Module\Db
return parent::_initialize(); return parent::_initialize();
} }
public function getConfig() public function _getDbHostname()
{
return $this->config;
}
public function getDbHostname()
{ {
$matches = []; $matches = [];
$matched = preg_match('~host=([^;]+)~s', $this->config['dsn'], $matches); $matched = preg_match('~host=([^;]+)~s', $this->config['dsn'], $matches);
@@ -35,7 +30,7 @@ class DelayedDb extends \Codeception\Module\Db
return $matches[1]; return $matches[1];
} }
public function getDbName() public function _getDbName()
{ {
$matches = []; $matches = [];
$matched = preg_match('~dbname=([^;]+)~s', $this->config['dsn'], $matches); $matched = preg_match('~dbname=([^;]+)~s', $this->config['dsn'], $matches);
@@ -47,12 +42,12 @@ class DelayedDb extends \Codeception\Module\Db
return $matches[1]; return $matches[1];
} }
public function getDbUsername() public function _getDbUsername()
{ {
return $this->config['user']; return $this->config['user'];
} }
public function getDbPassword() public function _getDbPassword()
{ {
return $this->config['password']; return $this->config['password'];
} }

View File

@@ -31,10 +31,10 @@ abstract class E107Base extends Base
$db = $this->getModule('\Helper\DelayedDb'); $db = $this->getModule('\Helper\DelayedDb');
$e107_config = []; $e107_config = [];
$e107_config['mySQLserver'] = $db->getDbHostname(); $e107_config['mySQLserver'] = $db->_getDbHostname();
$e107_config['mySQLuser'] = $db->getDbUsername(); $e107_config['mySQLuser'] = $db->_getDbUsername();
$e107_config['mySQLpassword'] = $db->getDbPassword(); $e107_config['mySQLpassword'] = $db->_getDbPassword();
$e107_config['mySQLdefaultdb'] = $db->getDbName(); $e107_config['mySQLdefaultdb'] = $db->_getDbName();
$e107_config['mySQLprefix'] = $this->e107_mySQLprefix; $e107_config['mySQLprefix'] = $this->e107_mySQLprefix;
$e107_config_contents = $twig->render('e107_config.php', $e107_config); $e107_config_contents = $twig->render('e107_config.php', $e107_config);

View File

@@ -34,12 +34,13 @@ class InstallCest
{ {
$I->amOnPage('/install.php'); $I->amOnPage('/install.php');
$I->wantTo("Verify Proceed to Step 3 of the Installation"); $I->wantTo("Verify Proceed to Step 3 of the Installation");
$db = $I->getHelperDb();
$this->installStep1ToStep2($I); $this->installStep1ToStep2($I);
$I->fillField('server', $I->getDbHostname()); $I->fillField('server', $db->_getDbHostname());
$I->fillField('name', $I->getDbUsername()); $I->fillField('name', $db->_getDbUsername());
$I->fillField('password', $I->getDbPassword()); $I->fillField('password', $db->_getDbPassword());
$I->fillField('db', $I->getDbName()); $I->fillField('db', $db->_getDbName());
$I->uncheckOption('createdb'); $I->uncheckOption('createdb');
$I->click('submit'); $I->click('submit');