diff --git a/tests/_data/e107_config.php.sample b/tests/_data/e107_config.php.sample index a1e1e8f3e..c991716ac 100644 --- a/tests/_data/e107_config.php.sample +++ b/tests/_data/e107_config.php.sample @@ -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); diff --git a/tests/_support/Helper/E107Base.php b/tests/_support/Helper/E107Base.php index 604d4a0e3..186adf16f 100644 --- a/tests/_support/Helper/E107Base.php +++ b/tests/_support/Helper/E107Base.php @@ -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() diff --git a/tests/unit/e107Test.php b/tests/unit/e107Test.php index 836743396..23a495536 100644 --- a/tests/unit/e107Test.php +++ b/tests/unit/e107Test.php @@ -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; diff --git a/tests/unit/e_formTest.php b/tests/unit/e_formTest.php index dad7684a6..0b0d6bf11 100644 --- a/tests/unit/e_formTest.php +++ b/tests/unit/e_formTest.php @@ -72,7 +72,7 @@ 'checkboxes_001' => array('title'=>'Checkboxes', 'type'=>'checkboxes', 'writeParms'=>array('optArray'=>array(1=>'Check Opt 1', 2=>'Check Opt 2', 3=>'Check Opt 3'))), 'country_001' => array('title'=>'Country', 'type'=>'country'), 'ip_001' => array('title'=>'IP', 'type'=>'ip', 'inline'=>false), - 'templates_001' => array('title'=>'Templates', 'type'=>'templates'), + 'templates_001' => array('title'=>'Templates', 'type'=>'templates', 'writeParms'=>array('plugin'=>'forum')), 'radio_001' => array('title'=>'Radio', 'type'=>'radio', 'writeParms'=>array('optArray'=>array(1=>'Radio Opt 1', 2=>'Radio Opt 2', 3=>'Radio Opt 3'))), 'tags_001' => array('title'=>'Tags', 'type'=>'tags'), 'bbarea_001' => array('title'=>'BBarea', 'type'=>'bbarea', 'inline'=>false), @@ -839,7 +839,7 @@ 'checkboxes_001' => "
", 'country_001' => "", 'ip_001' => "", - 'templates_001' => "", + 'templates_001' => "", 'radio_001' => " ", //todo check tags_001 is correct.