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

toIcon() test added.

This commit is contained in:
Cameron
2019-03-06 11:20:28 -08:00
parent f915d66cf8
commit ef4706c094
5 changed files with 91 additions and 8 deletions

BIN
tests/_data/icon_64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@@ -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.")";
}
}
}
}
}

View File

@@ -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()
{

View File

@@ -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);
}
}

View File

@@ -81,7 +81,7 @@ TMP;
public function testParseTemplateWithEnabledCoreShortcodes()
{
$needle = '<ul class="nav navbar-nav nav-main">';
$needle = '<ul class="nav navbar-nav nav-main ml-auto">';
$result = $this->tp->parseTemplate('{NAVIGATION}', true);
$this->assertContains($needle, $result);
}
@@ -600,12 +600,35 @@ TMP;
{
}
*/
public function testToIcon()
{
$icon = codecept_data_dir()."icon_64.png";
if(!copy($icon,e_MEDIA_IMAGE."icon_64.png"))
{
echo "Couldn't copy the icon";
}
if(!copy($icon,e_MEDIA_ICON."icon_64.png"))
{
echo "Couldn't copy the icon";
}
$tests = array(
0 => array('input'=> '{e_IMAGE}e107_icon_32.png', 'expected' => '/e107_images/e107_icon_32.png'),
1 => array('input'=> '{e_MEDIA_IMAGE}icon_64.png', 'expected' => 'thumb.php?src=e_MEDIA_IMAGE'),
2 => array('input'=> '{e_MEDIA_ICON}icon_64.png', 'expected' => '/e107_media/000000test/icons/icon_64.png'),
3 => array('input'=> '{e_PLUGIN}gallery/images/gallery_32.png', 'expected' => '/e107_plugins/gallery/images/gallery_32.png'),
);
foreach($tests as $var)
{
$result = $this->tp->toIcon($var['input']);
$this->assertContains($var['expected'],$result);
// var_dump($var['expected']);
}
}
/*
public function testToImage()
{