silverstripe-versionfeed/tests/VersionFeedTest.php
Dylan Wagstaff 67e112fd12 FIX: Minor functional alterations and CI improvements
FIX: PSR-2 codebase. Formatting via phpcbf
FIX: rendering bug in allchanges
FIX: update .gitattributes to not export codecov's config file
FIX: Update SiteTree_versions to the ss4 equivalent SiteTree_Versions
2017-12-12 16:12:03 +13:00

67 lines
2.0 KiB
PHP

<?php
namespace SilverStripe\VersionFeed\Tests;
use Page;
use SilverStripe\VersionFeed\VersionFeed;
use SilverStripe\VersionFeed\VersionFeedController;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\CMS\Controllers\ContentController;
class VersionFeedTest extends SapphireTest
{
protected $usesDatabase = true;
protected static $required_extensions = [
SiteTree::class => [VersionFeed::class],
ContentController::class => [VersionFeedController::class],
];
protected $illegalExtensions = [
'SiteTree' => ['Translatable']
];
public function testDiffedChangesExcludesRestrictedItems()
{
$this->markTestIncomplete();
}
public function testDiffedChangesIncludesFullHistory()
{
$this->markTestIncomplete();
}
public function testDiffedChangesTitle()
{
$page = new Page(['Title' => 'My Title']);
$page->write();
$page->publish('Stage', 'Live');
$page->Title = 'My Changed Title';
$page->write();
$page->publish('Stage', 'Live');
$page->Title = 'My Unpublished Changed Title';
$page->write();
// Strip spaces from test output because they're not reliably maintained by the HTML Tidier
$cleanDiffOutput = function ($val) {
return str_replace(' ', '', strip_tags($val));
};
$this->assertContains(
str_replace(' ', '', _t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Changed Title'),
array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle')),
'Detects published title changes'
);
$this->assertNotContains(
str_replace(' ', '', _t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Unpublished Changed Title'),
array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle')),
'Ignores unpublished title changes'
);
}
}