mirror of
https://github.com/e107inc/e107.git
synced 2025-03-28 08:12:42 +01: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:
parent
eec2feb8b3
commit
48654804bd
@ -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()
|
||||
{
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user