1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Test fixes. Email arraySet() test added.

This commit is contained in:
Cameron 2020-08-11 08:30:00 -07:00
parent 0f02e9a9a2
commit 370fdb13f6
6 changed files with 156 additions and 10 deletions

View File

@ -812,8 +812,6 @@ class e107Email extends PHPMailer
$mediaParms = array();
if(strpos($eml['templateHTML']['body'], '{MEDIA') !==false )
{
// check for media sizing.
@ -905,7 +903,7 @@ class e107Email extends PHPMailer
if(!empty($eml['template'])) // @see e107_core/templates/email_template.php
{
e107::coreLan('users', true);
if($tmpl = e107::getCoreTemplate('email', $eml['template'], 'front', true)) //FIXME - Core template is failing with template 'notify'. Works with theme template. Issue with core template registry?
{
$eml['templateHTML'] = $tmpl;

View File

@ -486,12 +486,18 @@ class e_plugin
public function isValidAddonMarkup($content='')
{
if ((substr($content, 0, 5) != '<'.'?php') || ((substr($content, -2, 2) != '?'.'>') && (strrpos($content, '?'.'>') !== FALSE)))
if ((substr($content, 0, 5) != '<'.'?php'))
{
return false;
}
return true;
if ((substr($content, -2, 2) != '?'.'>') && (strrpos(substr($content, -20, 20), '?'.'>') !== false))
{
return false;
}
return true;
}
@ -2428,7 +2434,7 @@ class e107plugin
function manage_tables($action, $var)
{
$this->log("Running ".__FUNCTION__);
$sql = e107::getDB();
$sql = e107::getDb();
$mes = e107::getMessage();
if (!is_array($var))

View File

@ -340,10 +340,10 @@ class e_tohtml_linkwords
$lwClass[] = $this->word_class[$first];
}
if (!count($lwClass))
{
// if (!count($lwClass))
// {
// return $this->linksproc($sl,$first+1,$limit); // Nothing to do - move on to next word (shouldn't really get here)
}
// }
if (count($linkrel))
{

View File

@ -11,7 +11,7 @@ class siteinfo_shortcodes // must match the folder name of the plugin.
function sc_sitebutton($parm=null)
{
if($_POST['sitebutton'] && $_POST['ajax_used'])
if(!empty($_POST['sitebutton']) && !empty($_POST['ajax_used']))
{
$path = e107::getParser()->replaceConstants($_POST['sitebutton']);
}

View File

@ -0,0 +1,135 @@
<?php
/**
* e107 website system
*
* Copyright (C) 2008-2020 e107.org
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*/
class e107EmailTest extends \Codeception\Test\Unit
{
/** @var e107Email */
protected $eml;
protected function _before()
{
try
{
$this->eml = $this->make('e107Email');
}
catch(Exception $e)
{
$this->assertTrue(false, "Couldn't load e107Email object");
}
$this->eml->__construct();
}
/*
public function testAllSent()
{
}
public function testProcessShortcodes()
{
}
*/
public function testArraySet()
{
$eml = array(
'subject' => "[URGENT EXAMPLE]",
'sender_email' => "noreply@test.com",
'sender_name' => "Test Person",
'replyto' => "",
'html' => true,
'priority' => 1,
'template' => 'default',
'body' => "This is the body text",
'cc' => ''
);
$this->eml->arraySet($eml);
$this->assertStringContainsString("noreply@test.com", $this->eml->From);
$this->assertStringContainsString("Test Person", $this->eml->FromName);
$this->assertStringContainsString("e107: [URGENT EXAMPLE] ", $this->eml->Subject);
$this->assertStringContainsString("This is the body text", $this->eml->Body);
$this->assertStringContainsString("<h4 class='sitename'><a href='", $this->eml->Body);
$this->assertStringNotContainsString('{MEDIA1}', $this->eml->Body);
}
/*
public function testMakePrintableAddress()
{
}
public function testPreview()
{
}
public function testAddInlineImages()
{
}
public function testMsgHTML()
{
}
public function testSendEmail()
{
$eml = array(
'subject' => "[URGENT EXAMPLE] ",
'sender_email' => "noreply@test.com",
'sender_name' => "Test",
'replyto' => "",
'html' => true,
'priority' => 1,
'template' => 'default',
'body' => "This is the body text",
'cc' => ''
);
$this->eml->sendEmail('test@nowhere.com',"This is the subject", $eml);
}
public function testSetDebug()
{
}
public function testAddAddressList()
{
}
public function testAttach()
{
}
public function testMakeBody()
{
}
*/
}

View File

@ -298,6 +298,13 @@
public function testIsValidAddonMarkup()
{
$content = '<?php
';
$result = $this->ep->isValidAddonMarkup($content);
$this->assertTrue($result);
$content = ' <?php ';
$result = $this->ep->isValidAddonMarkup($content);
$this->assertFalse($result);