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

e_parse::parseTemplate() behavior clarification

New tests cover the behavior described in
https://github.com/e107inc/e107/issues/3547
This commit is contained in:
Deltik
2018-11-09 16:52:37 -06:00
parent eec2feb8b3
commit 48654804bd
2 changed files with 63 additions and 3 deletions

View File

@@ -77,12 +77,70 @@ TMP;
{
}
*/
public function testParseTemplate()
public function testParseTemplateWithEnabledCoreShortcodes()
{
$needle = '<ul class="nav navbar-nav nav-main">';
$result = $this->tp->parseTemplate('{NAVIGATION}', true);
$this->assertContains($needle, $result);
}
public function testParseTemplateWithDisabledCoreShortcodes()
{
$result = $this->tp->parseTemplate('{NAVIGATION}', false);
$this->assertEmpty($result);
}
public function testParseTemplateWithCoreAddonShortcodes()
{
e107::getPlugin()->uninstall('online');
e107::getScParser()->__construct();
$result = $this->tp->parseTemplate('{ONLINE_MEMBER_PAGE}', false);
$this->assertEmpty($result);
$result = $this->tp->parseTemplate('{ONLINE_MEMBER_PAGE}', true);
$this->assertEmpty($result);
$shortcodeObject = e107::getScBatch('online', true);
$expected = "<a href=''>lost</a>";
$result = $this->tp->parseTemplate('{ONLINE_MEMBER_PAGE}', false, $shortcodeObject);
$this->assertEquals($expected, $result);
$result = $this->tp->parseTemplate('{ONLINE_MEMBER_PAGE}', false);
$this->assertEmpty($result);
$result = $this->tp->parseTemplate('{ONLINE_MEMBER_PAGE}', true);
$this->assertEquals($expected, $result);
}
public function testParseTemplateWithNonCoreShortcodes()
{
e107::getPlugin()->uninstall('download');
e107::getScParser()->__construct();
$result = $this->tp->parseTemplate('{DOWNLOAD_CAT_SEARCH}', false);
$this->assertEmpty($result);
$result = $this->tp->parseTemplate('{DOWNLOAD_CAT_SEARCH}', true);
$this->assertEmpty($result);
$shortcodeObject = e107::getScBatch('download', true);
$needle = "<form class='form-search form-inline' ";
$result = $this->tp->parseTemplate('{DOWNLOAD_CAT_SEARCH}', false, $shortcodeObject);
$this->assertContains($needle, $result);
$result = $this->tp->parseTemplate('{DOWNLOAD_CAT_SEARCH}', false);
$this->assertEmpty($result);
$result = $this->tp->parseTemplate('{DOWNLOAD_CAT_SEARCH}', true);
$this->assertEmpty($result);
}
/*
public function testCreateConstants()
{

View File

@@ -118,6 +118,9 @@
);
}
/**
* @see https://github.com/e107inc/e107/issues/3547
*/
public function testBanner()
{
@@ -130,7 +133,6 @@
$tp = e107::getParser();
// XXX: Contradicts https://github.com/e107inc/e107/issues/3547#issuecomment-437163733
$result = $tp->parseTemplate("{BANNER=e107promo}",true);
$this->assertContains("<img class='e-banner img-responsive img-fluid'", $result);