2014-02-24 01:38:16 +01:00
|
|
|
<?php
|
|
|
|
|
2015-11-02 00:27:42 +01:00
|
|
|
/**
|
|
|
|
* @mixin PHPUnit_Framework_TestCase
|
|
|
|
*/
|
|
|
|
class ContentReviewNotificationTest extends SapphireTest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2015-11-17 02:17:54 +01:00
|
|
|
public static $fixture_file = 'contentreview/tests/ContentReviewTest.yml';
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
// Hack to ensure only desired siteconfig is scaffolded
|
|
|
|
$desiredID = $this->idFromFixture('SiteConfig', 'mysiteconfig');
|
|
|
|
foreach (SiteConfig::get()->exclude('ID', $desiredID) as $config) {
|
|
|
|
$config->delete();
|
|
|
|
}
|
|
|
|
}
|
2015-11-02 00:27:42 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $requiredExtensions = array(
|
2015-11-17 02:17:54 +01:00
|
|
|
'SiteTree' => array('SiteTreeContentReview'),
|
|
|
|
'Group' => array('ContentReviewOwner'),
|
|
|
|
'Member' => array('ContentReviewOwner'),
|
|
|
|
'CMSPageEditController' => array('ContentReviewCMSExtension'),
|
|
|
|
'SiteConfig' => array('ContentReviewDefaultSettings'),
|
2015-11-02 00:27:42 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
public function testContentReviewEmails()
|
|
|
|
{
|
2015-11-17 02:17:54 +01:00
|
|
|
SS_Datetime::set_mock_now('2010-02-24 12:00:00');
|
2015-11-02 00:27:42 +01:00
|
|
|
|
|
|
|
/** @var Page|SiteTreeContentReview $childParentPage */
|
2015-11-17 02:17:54 +01:00
|
|
|
$childParentPage = $this->objFromFixture('Page', 'contact');
|
|
|
|
$childParentPage->NextReviewDate = '2010-02-23';
|
2015-11-02 00:27:42 +01:00
|
|
|
$childParentPage->write();
|
|
|
|
|
|
|
|
$task = new ContentReviewEmails();
|
2015-11-17 02:17:54 +01:00
|
|
|
$task->run(new SS_HTTPRequest('GET', '/dev/tasks/ContentReviewEmails'));
|
2015-11-02 00:27:42 +01:00
|
|
|
|
2015-11-17 02:17:54 +01:00
|
|
|
// Set template variables (as per variable case)
|
|
|
|
$ToEmail = 'author@example.com';
|
|
|
|
$Subject = 'Please log in to review some content!';
|
|
|
|
$PagesCount = 3;
|
|
|
|
$ToFirstName = 'Test';
|
2015-11-02 00:27:42 +01:00
|
|
|
|
2015-11-17 02:17:54 +01:00
|
|
|
$email = $this->findEmail($ToEmail, null, $Subject);
|
2015-11-02 00:27:42 +01:00
|
|
|
$this->assertNotNull($email, "Email haven't been sent.");
|
2015-11-17 02:17:54 +01:00
|
|
|
$this->assertContains(
|
|
|
|
"<h1>$Subject</h1><p>There are $PagesCount pages that are due for review today by you, $ToFirstName.</p><p>This email was sent to $ToEmail</p>",
|
|
|
|
$email['htmlContent']
|
|
|
|
);
|
|
|
|
$this->assertContains('Staff', $email['htmlContent']);
|
|
|
|
$this->assertContains('Contact Us', $email['htmlContent']);
|
|
|
|
$this->assertContains('Contact Us Child', $email['htmlContent']);
|
2015-11-02 00:27:42 +01:00
|
|
|
|
|
|
|
SS_Datetime::clear_mock_now();
|
|
|
|
}
|
2014-02-24 01:38:16 +01:00
|
|
|
}
|