diff --git a/tests/_data/icon_64.png b/tests/_data/icon_64.png new file mode 100644 index 000000000..4c86b4cd5 Binary files /dev/null and b/tests/_data/icon_64.png differ diff --git a/tests/_support/Helper/Unit.php b/tests/_support/Helper/Unit.php index 9d27930e4..13da91507 100644 --- a/tests/_support/Helper/Unit.php +++ b/tests/_support/Helper/Unit.php @@ -21,5 +21,20 @@ class Unit extends E107Base codecept_debug("Loading ".APP_PATH."/class2.php…"); define('E107_DBG_BASIC', true); require_once(APP_PATH."/class2.php"); + + $create_dir = array(e_MEDIA,e_MEDIA_IMAGE,e_MEDIA_ICON,e_SYSTEM,e_CACHE,e_CACHE_CONTENT,e_CACHE_IMAGE, e_CACHE_DB, e_LOG, e_BACKUP, e_CACHE_URL, e_TEMP, e_IMPORT); + + foreach($create_dir as $dr) + { + if(!is_dir($dr)) + { + if(mkdir($dr, 0755)) + { + // echo "\n(Creating ".$dr.")"; + } + + } + + } } } diff --git a/tests/unit/e_admin_uiTest.php b/tests/unit/e_admin_uiTest.php index 06dd8806f..e2cf409ab 100644 --- a/tests/unit/e_admin_uiTest.php +++ b/tests/unit/e_admin_uiTest.php @@ -11,6 +11,31 @@ class e_admin_uiTest extends \Codeception\Test\Unit { + + + public function testPregReplace() + { + $tests = array( + 0 => array('text'=>"something", 'expected'=>"something"), + + ); + + + foreach($tests as $var) + { + $result = preg_replace('/[^\w-:.]/', '', $var['text']); // this pattern used in parts of the admin-ui. + $this->assertEquals($var['expected'], $result); + //var_dump($result); + } + + // echo array_flip(get_defined_constants(true)['pcre'])[preg_last_error()]; + + + } + + + + /* public function testListEcolumnsTrigger() { diff --git a/tests/unit/e_mediaTest.php b/tests/unit/e_mediaTest.php index 6abddc6b7..0bd826257 100644 --- a/tests/unit/e_mediaTest.php +++ b/tests/unit/e_mediaTest.php @@ -96,12 +96,31 @@ { } - +*/ public function testImportFile() { + $icon = codecept_data_dir()."icon_64.png"; + $dest = e_IMPORT."icon_64.png"; + copy($icon,$dest); + + if(!file_exists($dest)) + { + $this->fail("Couldn't copy icon to ".$dest); + } + + $tests = array( + 0 => array('file'=> 'icon_64.png', 'cat' => '_icon', 'expected'=>"{e_MEDIA_ICON}icon_64.png"), + ); + + foreach($tests as $var) + { + $result = $this->md->importFile($var['file'], $var['cat']); + $this->assertEquals($var['expected'],$result); + } + } - +/* public function testBrowserCarousel() { @@ -240,9 +259,10 @@ { } - +*/ public function testGetPath() { - - }*/ + $result = $this->md->getPath('image/jpeg'); + var_dump($result); + } } diff --git a/tests/unit/e_parseTest.php b/tests/unit/e_parseTest.php index cca7d5085..123341b62 100644 --- a/tests/unit/e_parseTest.php +++ b/tests/unit/e_parseTest.php @@ -81,7 +81,7 @@ TMP; public function testParseTemplateWithEnabledCoreShortcodes() { - $needle = '