1
0
mirror of https://github.com/e107inc/e107.git synced 2025-10-14 06:24:56 +02:00
Files
php-e107/tests/_support/Helper/E107Base.php
Deltik b18ef3f830 Ready for testing!
e107 is now ready for fully automated testing on all three test suites:

* Acceptance
* Functional
* Unit

New features:

* cPanelDeployer adds a cPanel Remote MySQL access host
* e107 database dump importer
* Unit tests now load e107

Fixes:

* Test prefixes now only use characters valid for MySQL/MariaDB without
  escaping
* Refactored a bunch of things
* All existing tests pass now

Changes:

* Deployers now provided by \Helper\DeployerFactory
* Added Twig templating for generating e107_config.php for testing
* cPanelDeployer now outputs to codecept_debug()
2018-02-12 13:17:17 -06:00

50 lines
1.3 KiB
PHP

<?php
namespace Helper;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
abstract class E107Base extends Base
{
public $e107_mySQLprefix = 'e107_';
protected const APP_PATH_E107_CONFIG = APP_PATH."/e107_config.php";
public function _beforeSuite($settings = array())
{
parent::_beforeSuite($settings);
$this->writeLocalE107Config();
}
public function _afterSuite()
{
parent::_afterSuite();
$this->revokeLocalE107Config();
}
protected function writeLocalE107Config()
{
$twig_loader = new \Twig_Loader_Array([
'e107_config.php' => file_get_contents(codecept_data_dir()."/e107_config.php.sample")
]);
$twig = new \Twig_Environment($twig_loader);
$db = $this->getModule('\Helper\DelayedDb');
$e107_config = [];
//$e107_config['mySQLserver'] = $db->getDbHostname();
$e107_config['mySQLserver'] = 'localhost';
$e107_config['mySQLuser'] = $db->getDbUsername();
$e107_config['mySQLpassword'] = $db->getDbPassword();
$e107_config['mySQLdefaultdb'] = $db->getDbName();
$e107_config['mySQLprefix'] = $this->e107_mySQLprefix;
$e107_config_contents = $twig->render('e107_config.php', $e107_config);
file_put_contents(self::APP_PATH_E107_CONFIG, $e107_config_contents);
}
protected function revokeLocalE107Config()
{
unlink(self::APP_PATH_E107_CONFIG);
}
}