silverstripe-blog/tests/BlogPostFilterTest.php

43 lines
776 B
PHP
Raw Normal View History

2013-10-10 00:09:28 +02:00
<?php
2015-05-09 16:33:12 +02:00
/**
* @mixin PHPUnit_Framework_TestCase
*/
2013-10-10 00:09:28 +02:00
class BlogPostFilterTest extends SapphireTest {
2015-05-09 16:33:12 +02:00
/**
* @var string
*/
static $fixture_file = 'blog.yml';
2013-10-10 00:09:28 +02:00
public function setUp() {
parent::setUp();
2015-05-09 16:33:12 +02:00
SS_Datetime::set_mock_now('2013-10-10 20:00:00');
2013-10-10 00:09:28 +02:00
}
2015-02-08 08:03:55 +01:00
public function tearDown() {
SS_Datetime::clear_mock_now();
2015-05-09 16:33:12 +02:00
2015-02-08 08:03:55 +01:00
parent::tearDown();
}
2013-10-10 00:09:28 +02:00
public function testFilter() {
$member = Member::currentUser();
2015-05-09 16:33:12 +02:00
if($member) {
$member->logout();
}
2015-05-09 16:33:12 +02:00
/**
* @var Blog $blog
*/
$blog = $this->objFromFixture('Blog', 'FirstBlog');
2013-10-10 00:09:28 +02:00
2015-05-09 16:33:12 +02:00
$this->assertEquals(3, $blog->AllChildren()->Count(), 'Filtered blog posts');
2013-10-10 00:09:28 +02:00
2015-05-09 16:33:12 +02:00
SS_Datetime::set_mock_now('2020-01-01 00:00:00');
$this->assertEquals(5, $blog->AllChildren()->Count(), 'Unfiltered blog posts');
}
2013-10-10 00:09:28 +02:00
}