mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
FIX: Unit test for BlogPostNotifications identified a missing %s in a sprintf statement, meaning the title of a BlogPost would not show in the subject of a notification email
This commit is contained in:
parent
694b41176a
commit
687406dea8
@ -27,6 +27,6 @@ class BlogPostNotifications extends DataExtension
|
||||
*/
|
||||
public function updateNotificationSubject(&$subject, &$comment, &$recipient)
|
||||
{
|
||||
$subject = sprintf('A new comment has been posted on ', $this->owner->Title);
|
||||
$subject = sprintf('A new comment has been posted on %s', $this->owner->Title);
|
||||
}
|
||||
}
|
||||
|
52
tests/BlogPostNotificationsTest.php
Normal file
52
tests/BlogPostNotificationsTest.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
class BlogPostNotificationsTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public static $fixture_file = 'blog.yml';
|
||||
|
||||
public function testUpdateNotificationRecipients()
|
||||
{
|
||||
if (!class_exists('CommentNotifier')) {
|
||||
$this->markTestSkipped('Comments Notification module is not installed');
|
||||
}
|
||||
|
||||
$blogPost = $this->objFromFixture('BlogPost', 'PostC');
|
||||
$comment = new Comment();
|
||||
$comment->Comment = 'This is a comment';
|
||||
$comment->write();
|
||||
$recipients = $blogPost->notificationRecipients(
|
||||
$comment
|
||||
)->toArray();
|
||||
|
||||
$segments = array();
|
||||
foreach ($recipients as $recipient) {
|
||||
array_push($segments, $recipient->URLSegment);
|
||||
}
|
||||
|
||||
sort($segments);
|
||||
$this->assertEquals(array('blog-contributor', 'blog-editor',
|
||||
'blog-writer', ), $segments);
|
||||
}
|
||||
|
||||
public function testUpdateNotificationSubject()
|
||||
{
|
||||
if (!class_exists('CommentNotifier')) {
|
||||
$this->markTestSkipped('Comments Notification module is not installed');
|
||||
}
|
||||
$blogPost = $this->objFromFixture('BlogPost', 'PostC');
|
||||
$comment = new Comment();
|
||||
$comment->Comment = 'This is a comment';
|
||||
$comment->write();
|
||||
$recipients = $blogPost->notificationRecipients(
|
||||
$comment
|
||||
)->toArray();
|
||||
$subject = $blogPost->notificationSubject($comment, $recipients[0]);
|
||||
$this->assertEquals(
|
||||
'A new comment has been posted on Third Post',
|
||||
$subject
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user