silverstripe-blog/tests/BlogHolderTest.php
Damian Mooyman d788f6a979 BUG Fixed parsing of spaces and other whitespace in tag clouds. Fixes #59
BUG Fixed incorrect encoding of SelectedAuthor and SelectedTag; Now correctly cast for templates using the `cast` config, not within filtering.
BUG Fixed TagCloudWidget.popularities config from being incorrectly accessed as a static property
BUG Fixed TagCloudWidget::getCMSFields triggering extend('updateCMSFields') twice
BUG Fixed TagCloudWidget::getTagsCollection discarding tag label capitalisation
BUG Fixed TagCloudWidget::getTagsCollection not correctly respecting minimum tag counts (as well as maximum tag counts) when determining the popularity CSS class to assign.
Test cases for TagCloudWidget
API BlogEntry::TagNames now safely extracts tags from a blog entry as an associative 'lowercase' => 'Entered Tag' format
PHPDoc fixes
Removed trailing '?>' tags from PHP files
2014-02-28 17:07:56 +13:00

76 lines
1.8 KiB
PHP

<?php
class BlogHolderTest extends SapphireTest {
static $fixture_file = 'blog/tests/BlogTest.yml';
function testGetAllBlogEntries() {
$mainblog = $this->objFromFixture('BlogHolder', 'mainblog');
$this->assertNotNull($mainblog->Entries());
$this->assertEquals($mainblog->Entries()->Count(), 3);
}
function testEntriesByMonth() {
$mainblog = $this->objFromFixture('BlogHolder', 'mainblog');
$entries = $mainblog->Entries('', '', '2008-01');
$this->assertEquals($entries->Count(), 2);
$expectedEntries = array(
'test-post-2',
'test-post-3'
);
foreach($entries as $entry) {
$this->assertContains($entry->URLSegment, $expectedEntries);
}
}
function textEntriesByYear() {
$mainblog = $this->objFromFixture('BlogHolder', 'mainblog');
$entries = $mainblog->Entries('', '', '2007');
$this->assertEquals($entries->Count(), 1);
$expectedEntries = array(
'test-post'
);
foreach($entries as $entry) {
$this->assertContains($entry->URLSegment, $expectedEntries);
}
}
function testEntriesByTag() {
$mainblog = $this->objFromFixture('BlogHolder', 'mainblog');
$entries = $mainblog->Entries('', 'tag1');
$this->assertEquals($entries->Count(), 2);
$expectedEntries = array(
'test-post',
'test-post-3'
);
foreach($entries as $entry) {
$this->assertContains($entry->URLSegment, $expectedEntries);
}
}
function testBlogOwners() {
$mainblog = $this->objFromFixture('BlogHolder', 'mainblog');
$actualMembers = array_values($mainblog->blogOwners()->map('ID', 'Name')->toArray());
$expectedMembers = array(
'Admin One',
'Admin Two',
'ADMIN User', // test default admin
'Blog Owner One',
'Blog Owner Three',
'Blog Owner Two',
);
sort($actualMembers);
sort($expectedMembers);
$this->assertEquals($expectedMembers, $actualMembers);
}
}