1
0
mirror of https://github.com/e107inc/e107.git synced 2025-10-15 23:06:29 +02:00

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()
This commit is contained in:
Deltik
2018-02-12 13:17:17 -06:00
parent 495145df61
commit b18ef3f830
824 changed files with 39010 additions and 54 deletions

View File

@@ -15,7 +15,9 @@ class cPanelDeployer
protected $docroot;
protected $domain;
protected const TEST_PREFIX = 'test-';
private $skip_mysql_remote_hosts = false;
protected const TEST_PREFIX = 'test_';
protected const TARGET_RELPATH = 'public_html/';
protected const DEFAULT_COMPONENTS = ['db', 'fs'];
@@ -36,6 +38,11 @@ class cPanelDeployer
return "mysql:host=${hostname};dbname=${db_id}";
}
public function getDbName()
{
return $this->db_id;
}
public function getDbUsername()
{
return $this->db_id;
@@ -91,6 +98,11 @@ class cPanelDeployer
$valid_acceptance_test_ids = self::get_acceptance_test_ids($acceptance_tests);
self::println("Current unexpired tests: [".implode(", ", $valid_acceptance_test_ids)."]");
self::prune_inactive_acceptance_test_resources($cPanel, $valid_acceptance_test_ids);
if (!$this->skip_mysql_remote_hosts)
{
self::clean_mysql_remote_hosts($cPanel);
}
}
private function prepare()
@@ -144,6 +156,22 @@ class cPanelDeployer
$username = &$this->credentials['username'];
$run_id = &$this->run_id;
$this->db_id = $db_id = "${username}_${run_id}";
self::println("Ensuring that MySQL users allow any remote access hosts (%)…");
$remote_hosts = $cPanel->api2->MysqlFE->gethosts()->{'cpanelresult'}->{'data'};
if (!in_array('%', $remote_hosts, true))
{
$cPanel->uapi->Mysql->add_host(['host' => '%']);
register_shutdown_function(function() use ($cPanel)
{
self::clean_mysql_remote_hosts($cPanel);
});
}
else
{
$this->skip_mysql_remote_hosts = true;
}
self::println("Creating new MySQL database \"${db_id}\"");
$cPanel->uapi->Mysql->create_database(['name' => $db_id]);
@@ -182,7 +210,10 @@ class cPanelDeployer
private static function println($text = '')
{
echo("${text}\n");
codecept_debug($text);
//echo("${text}\n");
//$prefix = debug_backtrace()[1]['function'];
//echo("[\033[1m${prefix}\033[0m] ${text}\n");
}
@@ -286,6 +317,16 @@ class cPanelDeployer
}
}
private static function clean_mysql_remote_hosts($cPanel)
{
$remote_hosts = $cPanel->api2->MysqlFE->gethosts()->{'cpanelresult'}->{'data'};
if (in_array('%', $remote_hosts, true))
{
self::println("Removed cPanel MySQL remote host '%'");
$response = $cPanel->uapi->Mysql->delete_host(['host' => '%']);
}
}
private static function archive_app($path, $prefix = '')
{
$tmp_file = tmpfile();