1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

Disabled VCS modification. Added fixed hash folder name and cleanup before/after tests.

This commit is contained in:
Cameron
2018-09-09 18:20:20 -07:00
parent 5b9e2572a4
commit 0fca5840f2
4 changed files with 88 additions and 9 deletions

View File

@@ -34,5 +34,6 @@ $HELP_DIRECTORY = 'e107_docs/help/';
$MEDIA_DIRECTORY = 'e107_media/';
$SYSTEM_DIRECTORY = 'e107_system/';
$E107_CONFIG = array('site_path' => '000000test');
define('e_MOD_REWRITE',true);

View File

@@ -9,16 +9,67 @@ abstract class E107Base extends Base
const TEST_IN_PROGRESS = 'TEST-IN-PROGRESS';
const TEST_IN_PROGRESS_FILE = APP_PATH."/".self::TEST_IN_PROGRESS;
const APP_PATH_E107_CONFIG = APP_PATH."/e107_config.php";
const TEST_HASH = '000000test'; // see e107_config.php
public $e107_mySQLprefix = 'e107_';
public function _beforeSuite($settings = array())
{
$this->backupLocalE107Config();
$this->setVcsInProgress();
$this->deleteHashDirs();
// $this->setVcsInProgress();
parent::_beforeSuite($settings);
$this->writeLocalE107Config();
}
protected function deleteHashDirs()
{
$system = APP_PATH."/e107_system/".self::TEST_HASH;
$this->deleteDir($system);
$media = APP_PATH."/e107_media/".self::TEST_HASH;
$this->deleteDir($media);
if(is_dir($system))
{
echo "Couldn't delete ".$system;
}
}
private function deleteDir($dirPath)
{
if(!is_dir($dirPath))
{
// echo ($dirPath . "must be a directory");
return null;
}
if(substr($dirPath, strlen($dirPath) - 1, 1) != '/')
{
$dirPath .= '/';
}
$files = glob($dirPath . '*', GLOB_MARK);
foreach($files as $file)
{
if(is_dir($file))
{
$this->deleteDir($file);
}
else
{
unlink($file);
}
}
if(is_dir($dirPath))
{
rmdir($dirPath);
}
}
protected function backupLocalE107Config()
{
if(file_exists(self::APP_PATH_E107_CONFIG))
@@ -140,8 +191,9 @@ abstract class E107Base extends Base
{
parent::_afterSuite();
$this->revokeLocalE107Config();
$this->unsetVcsInProgress();
// $this->unsetVcsInProgress();
$this->restoreLocalE107Config();
$this->deleteHashDirs();
}
protected function revokeLocalE107Config()

View File

@@ -12,18 +12,44 @@
class e107Test extends \Codeception\Test\Unit
{
/* public function testGetInstance()
/** @var e107 */
private $e107;
protected function _before()
{
$res = null;
$this->assertTrue($res);
try
{
$this->e107 = e107::getInstance();
}
catch (Exception $e)
{
$this->fail("Couldn't load e107 object");
}
// var_dump($this->e107);
}
public function testGetInstance()
{
// $this->e107->getInstance();
//$res = $this->e107::getInstance();
// $this->assertTrue($res);
}
public function testInitCore()
{
$res = null;
$this->assertTrue($res);
//$res = null;
require(APP_PATH.'e107_config.php'); // contains $E107_CONFIG = array('site_path' => '000000test');
$e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'DOWNLOADS_DIRECTORY','UPLOADS_DIRECTORY','SYSTEM_DIRECTORY', 'MEDIA_DIRECTORY','CACHE_DIRECTORY','LOGS_DIRECTORY', 'CORE_DIRECTORY', 'WEB_DIRECTORY');
$sql_info = compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix', 'mySQLport');
$res = $this->e107->initCore($e107_paths, e_ROOT, $sql_info, varset($E107_CONFIG, array()));
$this->assertEquals('000000test', $res->site_path);
}
/*
public function testInitInstall()
{
$res = null;

File diff suppressed because one or more lines are too long