1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-13 01:54:12 +02:00

Fix for HTML used on text_truncate(). Ignore setcookie() in CLI mode.

This commit is contained in:
Cameron
2021-01-18 07:40:17 -08:00
parent ba313c558c
commit 419a0e727a
9 changed files with 171 additions and 24 deletions

View File

@@ -988,6 +988,11 @@ class e107Test extends \Codeception\Test\Unit
$all = e107::getAddonConfig('e_url');
foreach($all as $plugin => $var)
{
if($plugin === 'gallery') // fixme - sef may be enabled or disabled each time tests are run
{
continue;
}
foreach($var as $key => $value)
{
$rows = $this->generateRows($value, $plugin);

View File

@@ -213,7 +213,7 @@
*/
public function testUserExtendedShortcode()
{
e107::setRegistry('corelan/English_user_extended_front');
// e107::setRegistry('corelan/English_user_extended_front');
foreach($this->userValues as $field => $value)
{
@@ -351,6 +351,8 @@
$sc->template = $template;
$this->assertNotEmpty($sc->template);
$result = e107::getParser()->parseTemplate('{SIGNUP_EXTENDED_USER_FIELDS}', false, $sc);
$this->assertSame($expected, $result);

View File

@@ -1162,14 +1162,39 @@ while($row = $sql->fetch())
public function testText_truncate()
{
$string = "This is a long string that will be truncated." ;
$expected = 'This is a long ... ';
$result = $this->tp->text_truncate($string, 20);
$this->assertSame($expected, $result);
$this->assertSame('This is a long ... ', $result);
$string = "This is has something & something" ;
$expected = 'This is has something & ... ';
$result = $this->tp->text_truncate($string, 29);
$this->assertSame($expected, $result);
$this->assertSame('This is has something & ... ', $result);
$string = "Can't fail me now [b]Bold[/b]";
$result = $this->tp->text_truncate($string, 25);
$this->assertSame("Can't fail me now Bold", $result);
$string = "Can't fail me now <strong class='bbcode bold bbcode-b'>Bold</strong>";
$result = $this->tp->text_truncate($string, 25);
$this->assertSame("Can't fail me now Bold", $result);
}
public function testTruncate()
{
// html
$string = "Can't fail me now <strong class='bbcode bold bbcode-b'>Bold</strong>";
$result = $this->tp->truncate($string, 25);
$this->assertSame("Can't fail me now <strong class='bbcode bold bbcode-b'>Bold</strong>", $result); // html ignored in char count.
// bbcode - stripped.
$string = "Can't fail me now [b]Bold[/b]";
$result = $this->tp->truncate($string, 25);
$this->assertSame("Can't fail me now Bold", $result);
// text
$string = "This is a long string that will be truncated." ;
$result = $this->tp->truncate($string, 20);
$this->assertSame('This is a long st...', $result);
}
/*

View File

@@ -337,7 +337,7 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit
$sc->setVars($ret[0]);
$actual = e107::getParser()->parseTemplate('{LINK_SUB}', true, $sc);
$this->assertStringContainsString('<a href="https://localhost/e107/page.php?bk=1">General</a>', $actual);
$this->assertStringContainsString('General</a>', $actual);
$this->assertStringContainsString('<li role="menuitem" class="dropdown-submenu lower">', $actual);
$this->assertStringContainsString('<li role="menuitem" class="link-depth-3">', $actual);

View File

@@ -247,6 +247,76 @@
$this->pluginUninstall('tagcloud');
}
/*
public function testThirdParty()
{
$coreList = e107::getPlug()->getCorePluginList();
$all = scandir(e_PLUGIN);
unset($all[0], $all[1]);
$diff = array_diff($all, $coreList);
foreach($diff as $plug)
{
if(!is_dir(e_PLUGIN.$plug) || !is_dir(e_PLUGIN.$plug.'/tests'))
{
continue;
}
$tests = scandir(e_PLUGIN.$plug.'/tests');
unset($tests[0], $tests[1]);
foreach($tests as $t)
{
require_once(e_PLUGIN.$plug.'/tests/'.$t);
$Codecept = new \Codeception\Codecept(array(
'steps' => true,
'verbosity' => 1,
// some other options (see Codeception docs/sources)
));
// var_export($Codecept);
$Codecept->run('unit');
// require_once '/path/to/codeception/autoload.php';
}
}
//array_intersect(
}*/
public function testVstore()
{
if(!is_dir(e_PLUGIN."vstore"))
{
return ;
}
$this->pluginInstall('vstore');
$this->pluginRefresh('vstore');
$links = e107::getDb()->retrieve('links', '*', 'link_owner = "vstore"', true);
$this->assertNotEmpty($links);
$this->assertCount(2, $links);
$this->pluginUninstall('vstore');
}
public function testplugInstalledStatus()
{
$sql = e107::getDb();
@@ -384,7 +454,10 @@
}
private function pluginRefresh($pluginDir)
{
$return_text = e107::getPlugin()->refresh($pluginDir);
}
private function pluginInstall($pluginDir)
@@ -1288,3 +1361,5 @@ DATA
);
}
}

View File

@@ -61,7 +61,7 @@
global $_E107;
$_E107['cli'] = true;
$_E107['no_theme'] = true; //FIXME unable to change to admin theme in testing environment.
// $_E107['no_theme'] = true; //FIXME unable to change to admin theme in testing environment.
foreach($list as $file)
{