Add text template
[MAILPOET-1571]
This commit is contained in:
@@ -84,6 +84,7 @@ class Worker {
|
||||
'subject' => sprintf(_x('Stats for email %s', 'title of an automatic email containing statistics (newsletter open rate, click rate, etc)', 'mailpoet'), $newsletter->subject),
|
||||
'body' => [
|
||||
'html' => $this->renderer->render('emails/statsNotification.html', $context),
|
||||
'text' => $this->renderer->render('emails/statsNotification.txt', $context),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@@ -119,22 +119,24 @@ class WorkerTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function testRendersTemplate() {
|
||||
$this->renderer->expects($this->once())
|
||||
->method('render')
|
||||
->with(
|
||||
$this->stringContains('statsNotification.html'),
|
||||
$this->callback(function($context){
|
||||
return is_array($context);
|
||||
}));
|
||||
$this->renderer->expects($this->exactly(2))
|
||||
->method('render');
|
||||
$this->renderer->expects($this->at(0))
|
||||
->method('render')
|
||||
->with($this->equalTo('emails/statsNotification.html'));
|
||||
|
||||
$this->renderer->expects($this->at(1))
|
||||
->method('render')
|
||||
->with($this->equalTo('emails/statsNotification.txt'));
|
||||
|
||||
$this->stats_notifications->process();
|
||||
}
|
||||
|
||||
function testAddsSubjectToContext() {
|
||||
$this->renderer->expects($this->once())
|
||||
$this->renderer->expects($this->exactly(2)) // html + text template
|
||||
->method('render')
|
||||
->with(
|
||||
$this->stringContains('statsNotification.html'),
|
||||
$this->anything(),
|
||||
$this->callback(function($context){
|
||||
return $context['subject'] === 'Email Subject1';
|
||||
}));
|
||||
@@ -143,10 +145,10 @@ class WorkerTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function testAddsPreHeaderToContext() {
|
||||
$this->renderer->expects($this->once())
|
||||
$this->renderer->expects($this->exactly(2)) // html + text template
|
||||
->method('render')
|
||||
->with(
|
||||
$this->stringContains('statsNotification.html'),
|
||||
$this->anything(),
|
||||
$this->callback(function($context){
|
||||
return $context['preheader'] === '40.00% opens, 60.00% clicks, 20.00% unsubscribes in a nutshell.';
|
||||
}));
|
||||
@@ -155,10 +157,10 @@ class WorkerTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function testAddsWPUrlsToContext() {
|
||||
$this->renderer->expects($this->once())
|
||||
$this->renderer->expects($this->exactly(2)) // html + text template
|
||||
->method('render')
|
||||
->with(
|
||||
$this->stringContains('statsNotification.html'),
|
||||
$this->anything(),
|
||||
$this->callback(function($context){
|
||||
return strpos($context['linkSettings'], 'mailpoet-settings')
|
||||
&& strpos($context['linkStats'], 'mailpoet-newsletters#/stats');
|
||||
@@ -168,10 +170,10 @@ class WorkerTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
function testAddsLinksToContext() {
|
||||
$this->renderer->expects($this->once())
|
||||
$this->renderer->expects($this->exactly(2)) // html + text template
|
||||
->method('render')
|
||||
->with(
|
||||
$this->stringContains('statsNotification.html'),
|
||||
$this->anything(),
|
||||
$this->callback(function($context){
|
||||
return ($context['topLink'] === 'Link url2')
|
||||
&& ($context['topLinkClicks'] === 2);
|
||||
|
40
views/emails/statsNotification.txt
Normal file
40
views/emails/statsNotification.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
<%= __('Your stats are in!') %>
|
||||
|
||||
<%= subject %>
|
||||
|
||||
<%= __('open rate') %>: <%= number_format_i18n(opened) %>%
|
||||
<% if opened > 30 %>
|
||||
<%= __('EXCELLENT') %>
|
||||
<% elseif opened > 10 %>
|
||||
<%= __('GOOD') %>
|
||||
<% else %>
|
||||
<%= __('BAD') %>
|
||||
<% endif %>
|
||||
|
||||
<%= __('click rate') %>: <%= number_format_i18n(clicked) %>%
|
||||
<% if clicked > 3 %>
|
||||
<%= __('EXCELLENT') %>
|
||||
<% elseif clicked > 1 %>
|
||||
<%= __('GOOD') %>
|
||||
<% else %>
|
||||
<%= __('BAD') %>
|
||||
<% endif %>
|
||||
|
||||
<% if topLinkClicks > 0 %>
|
||||
<%= __('Most clicked link') %>
|
||||
<%= topLink %>
|
||||
|
||||
<%= __('%s unique clicks')|replace({'%s': topLinkClicks}) %>
|
||||
<% endif %>
|
||||
|
||||
<% if premiumPluginActive %>
|
||||
<%= __('View all stats') %>
|
||||
<%= linkStats %>
|
||||
<% else %>
|
||||
<%= __('See Premium features') %>
|
||||
<%= premiumPage %>
|
||||
<% endif %>
|
||||
|
||||
<%= __('How to improve my open rate?') %> https://mailpoet.com/how-to-improve-open-rates
|
||||
<%= __('And my click rate?') %> https://mailpoet.com/how-to-improve-click-rates
|
||||
<%= __('Disable these emails') %> <%= linkSettings %>
|
Reference in New Issue
Block a user