silverstripe-versionfeed/tests/VersionFeedTest.php
Mateusz Uzdowski 8a7d2ec9da NEW Refactor diff API and add managed limits.
Deprecate the getDiffedChanges method to get rid of confusing
fullHistory parameter. Add a getDiff method to fetch just a single diff
and a more versatile getDiffList method which allows specifying a limit.

We now also cap the amount of items coming from the diffing process
to a default value that we hope will result in generation times no
greater than a few seconds. This can be reconfigured by developers.
2015-03-30 11:28:42 +13:00

54 lines
1.5 KiB
PHP

<?php
class VersionFeedTest extends SapphireTest {
protected $usesDatabase = true;
protected $requiredExtensions = array(
'SiteTree' => array('VersionFeed'),
'ContentController' => array('VersionFeed_Controller'),
);
protected $illegalExtensions = array(
'SiteTree' => array('Translatable')
);
public function testDiffedChangesExcludesRestrictedItems() {
$this->markTestIncomplete();
}
public function testDiffedChangesIncludesFullHistory() {
$this->markTestIncomplete();
}
public function testDiffedChangesTitle() {
$page = new Page(array('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'
);
}
}