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

Extra checks added in the signup extended user fields shortcode.

Improved renderLayout test.
This commit is contained in:
Cameron
2021-01-26 11:58:07 -08:00
parent 46cb21b025
commit 184d920514
3 changed files with 130 additions and 11 deletions

View File

@@ -469,7 +469,16 @@ class signup_shortcodes extends e_shortcode
{
if(empty($this->template['extended-user-fields']))
{
return (ADMIN) ? "SIGNUP 'extended-user-fields' template not defined" : '';
$msg = "SIGNUP 'extended-user-fields' template is not defined or empty";
trigger_error($ms);
return (ADMIN) ? $msg : '';
}
if(empty($this->template['extended-category']))
{
$msg = "SIGNUP 'extended-user-fields' template is not defined or empty";
trigger_error($ms);
return (ADMIN) ? $msg : '';
}
@@ -517,7 +526,7 @@ class signup_shortcodes extends e_shortcode
$catName = $cat['user_extended_struct_text'] ? $cat['user_extended_struct_text'] : $cat['user_extended_struct_name'];
$catName = defset($catName, $catName);
$text .= str_replace('{EXTENDED_CAT_TEXT}', $tp->toHTML($catName, false, 'emotes_off,defs'), $this->template['extended-category']);
$text .= str_replace('{EXTENDED_CAT_TEXT}', $tp->toHTML($catName, false, 'TITLE'), $this->template['extended-category']);
$done_heading = true;
}

View File

@@ -56,17 +56,122 @@ class e107Test extends \Codeception\Test\Unit
public function testRenderLayout()
{
$LAYOUT = file_get_contents(e_THEME . "bootstrap3/theme.html");
$opts = array (
'magicSC' => array(
'{---HEADER---}' => '<h3>MY HEADER</h3>',
'{---FOOTER---}' => '<h3>MY FOOTER</h3>',
),
'bodyStart' => '<script>google code</script>'
);
// test code insertion.
$LAYOUT = '<body id="page-top">
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{SITEURL}">{BOOTSTRAP_BRANDING}</a>
</div>
<div class="navbar-collapse collapse {BOOTSTRAP_NAV_ALIGN}">
{NAVIGATION=main}
{BOOTSTRAP_USERNAV: placement=top}
</div><!--/.navbar-collapse -->
</div>
</div>
<!--- Optional custom header template controlled by theme_shortcodes -->
{---HEADER---}
<!-- Page Content -->
{---LAYOUT---}
<!-- Footer -->
{SETSTYLE=default}
<footer>
<div class="container">
<div class="row">
<div>
<div class="col-lg-6">
{MENU=100}
</div>
<div class="col-lg-6">
{MENU=101}
</div>
</div>
<div>
<div class="col-sm-12 col-lg-4">
{MENU=102}
</div>
<div class="col-sm-12 col-lg-8">
{MENU=103}
</div>
</div>
<div >
<div class="col-lg-12">
{MENU=104}
</div>
</div>
<div>
<div class="col-lg-6">
{MENU=105}
{NAVIGATION=footer}
{MENU=106}
</div>
<div class="col-lg-6 text-right">
{BOOTSTRAP_USERNAV: placement=bottom&dir=up}
</div>
</div>
<div>
<div class="col-lg-12">
</div>
</div>
<div>
<div id="sitedisclaimer" class="col-lg-12 text-center">
<small >{SITEDISCLAIMER}</small>
</div>
</div>
</div> <!-- /row -->
</div> <!-- /container -->
</footer>
{---MODAL---}
<!--- Optional custom footer template controlled by theme_shortcodes -->
{---FOOTER---}
<!-- Javascripts and other information are automatically added below here -->
</body> <!-- This tag is not necessary and is ignored and replaced. Left here only as a reference -->';
ob_start();
e107::renderLayout($LAYOUT);
e107::renderLayout($LAYOUT, $opts);
$result = ob_get_clean();
$this->assertStringNotContainsString('{MENU=1}', $result);
$this->assertStringNotContainsString('{NAVIGATION=main}', $result);
$this->assertStringContainsString('<h3>MY HEADER</h3>', $result);
$this->assertStringContainsString('<h3>MY FOOTER</h3>', $result);
$this->assertStringContainsString('<script>google code</script>', $result);
$this->assertStringNotContainsString('{BOOTSTRAP_BRANDING}', $result);
// var_export($result);
}

View File

@@ -33,7 +33,6 @@
$this->assertTrue(false, "Couldn't load e107_user_extended object");
}
$this->structTypes = array(
'text' => EUF_TEXT,
'homepage' => EUF_TEXT,
@@ -170,7 +169,10 @@
'order' => 1,
);
$this->ue->user_extended_add($insertCategory);
if($this->ue->user_extended_add($insertCategory) === false)
{
trigger_error("failed to create user-extended category");
}
// Insert a User-Extended Category
$insertCategory2 = array(
@@ -183,7 +185,10 @@
'order' => 2,
);
$this->ue->user_extended_add($insertCategory2);
if($this->ue->user_extended_add($insertCategory2) === false)
{
trigger_error("failed to create user-extended category");
}
// As $_POSTED.
$this->userValues = array(
@@ -468,8 +473,8 @@
$template = array(
'extended-category' => "-- {EXTENDED_CAT_TEXT} --",
'extended-user-fields' => "<label>{EXTENDED_USER_FIELD_TEXT}{EXTENDED_USER_FIELD_REQUIRED}</label>" // {EXTENDED_USER_FIELD_EDIT}
'extended-category' => "\n-- {EXTENDED_CAT_TEXT} --\n",
'extended-user-fields' => "<label>{EXTENDED_USER_FIELD_TEXT}{EXTENDED_USER_FIELD_REQUIRED}</label>\n" // {EXTENDED_USER_FIELD_EDIT}
);
$expected = array(