1
0
mirror of https://github.com/e107inc/e107.git synced 2025-10-13 22:14:51 +02:00
Files
php-e107/tests/_support/Helper/Base.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

55 lines
1.6 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 Base extends \Codeception\Module
{
protected $deployer;
protected $deployer_components = ['db', 'fs'];
public function _beforeSuite($settings = array())
{
$this->deployer = $this->getModule('\Helper\DeployerFactory')->create();
if (is_object($this->deployer))
{
$this->deployer->start($this->deployer_components);
$this->_callbackDeployerStarted();
}
}
public function _afterSuite()
{
if (is_object($this->deployer))
$this->deployer->stop();
}
protected function _callbackDeployerStarted()
{
foreach ($this->deployer_components as $component)
{
$method = "_reconfigure_${component}";
$this->$method();
}
}
protected function _reconfigure_fs()
{
$url = $this->deployer->getUrl();
$this->getModule('PhpBrowser')->_reconfigure(array('url' => $url));
}
protected function _reconfigure_db()
{
$db = $this->getModule('\Helper\DelayedDb');
$Db_config = $db->getConfig();
$Db_config['dsn'] = $this->deployer->getDsn();
$Db_config['user'] = $this->deployer->getDbUsername();
$Db_config['password'] = $this->deployer->getDbPassword();
$db->_reconfigure($Db_config);
// Next line is used to make connection available to any code after this point
//$this->getModule('\Helper\DelayedDb')->_delayedInitialize();
}
}