mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Merge pull request #403 from micmania1/fix-blog-rss-date
FIX #394 add getDate to proxy publish date in rss template
This commit is contained in:
commit
09bdf60aa4
@ -686,6 +686,17 @@ class BlogPost extends Page
|
||||
return $labels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy method for displaying the publish date in rss feeds.
|
||||
* @see https://github.com/silverstripe/silverstripe-blog/issues/394
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
return !empty($this->PublishDate) ? $this->PublishDate : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -94,4 +94,17 @@ class BlogPostTest extends SapphireTest
|
||||
$visitor = $this->objFromFixture('Member', 'Visitor');
|
||||
$this->assertFalse($blogPost->canView($visitor));
|
||||
}
|
||||
|
||||
/**
|
||||
* The purpose of getDate() is to act as a proxy for PublishDate in the default RSS
|
||||
* template, rather than copying the entire template.
|
||||
*/
|
||||
public function testGetDate()
|
||||
{
|
||||
$blogPost = $this->objFromFixture('BlogPost', 'NullPublishDate');
|
||||
$this->assertNull($blogPost->getDate());
|
||||
|
||||
$blogPost = $this->objFromFixture('BlogPost', 'PostA');
|
||||
$this->assertEquals('2012-01-09 15:00:00', $blogPost->getDate());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user