mirror of
https://github.com/e107inc/e107.git
synced 2025-08-12 09:34:54 +02:00
Closes #4919 - Enhancement: plugins may now use their own custom email templates with sendEmail();
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$this->assertTrue(false, "Couldn't load e107Email object");
|
||||
$this->fail("Couldn't load e107Email object");
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,64 @@
|
||||
$this->assertStringNotContainsString('{MEDIA1}', $this->eml->Body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test using an email template from e107_plugins/_blank/templates/_blank_template.php
|
||||
* @return void
|
||||
*/
|
||||
public function testArraySetPluginTemplate()
|
||||
{
|
||||
$eml = array(
|
||||
'subject' => "[PLUGIN TEMPLATE EXAMPLE]",
|
||||
'sender_email' => "noreply@test.com",
|
||||
'sender_name' => "Test Person",
|
||||
'replyto' => "",
|
||||
'html' => true,
|
||||
'priority' => 1,
|
||||
'template' => ['plugin'=>'_blank', 'name'=>'_blank', 'key'=>'email'],
|
||||
'body' => "This is the body text",
|
||||
'cc' => '',
|
||||
'shortcodes' => [
|
||||
'NAME' => "TestName",
|
||||
'DATE' => 'Jan 1st, 2020'
|
||||
],
|
||||
);
|
||||
|
||||
$this->eml->arraySet($eml);
|
||||
|
||||
$this->assertStringContainsString("noreply@test.com", $this->eml->From);
|
||||
$this->assertStringContainsString("Test Person", $this->eml->FromName);
|
||||
$this->assertStringContainsString("[PLUGIN TEMPLATE EXAMPLE]", $this->eml->Subject);
|
||||
|
||||
$this->assertStringContainsString('<html lang="en"><body>', $this->eml->Body);
|
||||
|
||||
$this->assertStringContainsString('<div><span>TestName</span> <small>Jan 1st, 2020</small></div><div>This is the body text</div>', $this->eml->Body);
|
||||
$this->assertStringNotContainsString('{MEDIA1}', $this->eml->Body);
|
||||
}
|
||||
|
||||
|
||||
public function testArraySetNotifyTemplate()
|
||||
{
|
||||
$eml = array(
|
||||
'subject' => "[URGENT EXAMPLE]",
|
||||
'sender_email' => "noreply@test.com",
|
||||
'sender_name' => "Test Person",
|
||||
'replyto' => "",
|
||||
'html' => true,
|
||||
'priority' => 1,
|
||||
'template' => 'notify',
|
||||
'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("<div class='unsubscribe'></div>", $this->eml->Body);
|
||||
$this->assertStringNotContainsString('{MEDIA1}', $this->eml->Body);
|
||||
}
|
||||
/*
|
||||
public function testMakePrintableAddress()
|
||||
{
|
||||
@@ -89,7 +147,7 @@
|
||||
$html = "\n
|
||||
Hi <b>Joe</b><br />
|
||||
|
||||
Check out <a href='http://e107.org'>http://e107.org</a><br />
|
||||
Check out <a href='https://e107.org'>https://e107.org</a><br />
|
||||
<br />
|
||||
Thanks,<br />
|
||||
Admin<br />
|
||||
@@ -106,7 +164,7 @@ Admin<br />
|
||||
$this->eml->MsgHTML($html);
|
||||
|
||||
$result = json_encode($this->eml->AltBody);
|
||||
$expected = '"Hi Joe\\nCheck out http:\\/\\/e107.org\\n\\nThanks,\\nAdmin\\n\\nWebsite:\\thttps:\\/\\/e107.org\\t\\nGithub:\\thttps:\\/\\/github.com\\/e107inc\\/"';
|
||||
$expected = '"Hi Joe\\nCheck out https:\\/\\/e107.org\\n\\nThanks,\\nAdmin\\n\\nWebsite:\\thttps:\\/\\/e107.org\\t\\nGithub:\\thttps:\\/\\/github.com\\/e107inc\\/"';
|
||||
$this->assertSame($expected, $result);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user