2013-10-29 12:06:26 +01:00
|
|
|
<?php
|
2017-12-11 12:10:56 +13:00
|
|
|
|
|
|
|
namespace SilverStripe\VersionFeed\Tests;
|
|
|
|
|
|
|
|
|
|
|
|
use Page;
|
|
|
|
use SilverStripe\VersionFeed\VersionFeed;
|
|
|
|
use SilverStripe\VersionFeed\VersionFeedController;
|
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
|
|
|
|
|
2013-10-29 12:06:26 +01:00
|
|
|
class VersionFeedTest extends SapphireTest {
|
|
|
|
|
2013-10-29 12:06:34 +01:00
|
|
|
protected $usesDatabase = true;
|
|
|
|
|
2017-12-11 12:50:45 +13:00
|
|
|
protected $required_extensions = array(
|
2017-12-11 12:10:56 +13:00
|
|
|
'SiteTree' => array(VersionFeed::class),
|
|
|
|
'ContentController' => array(VersionFeedController::class),
|
2013-10-29 12:06:34 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
protected $illegalExtensions = array(
|
|
|
|
'SiteTree' => array('Translatable')
|
|
|
|
);
|
|
|
|
|
2013-10-29 12:06:26 +01:00
|
|
|
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');
|
2013-10-29 12:06:34 +01:00
|
|
|
|
2013-10-29 12:06:26 +01:00
|
|
|
$page->Title = 'My Changed Title';
|
|
|
|
$page->write();
|
|
|
|
$page->publish('Stage', 'Live');
|
|
|
|
|
|
|
|
$page->Title = 'My Unpublished Changed Title';
|
|
|
|
$page->write();
|
|
|
|
|
2014-02-18 18:43:58 +13:00
|
|
|
// Strip spaces from test output because they're not reliably maintained by the HTML Tidier
|
|
|
|
$cleanDiffOutput = function($val) {
|
|
|
|
return str_replace(' ','',strip_tags($val));
|
|
|
|
};
|
|
|
|
|
2013-10-29 12:06:26 +01:00
|
|
|
$this->assertContains(
|
2014-02-18 18:43:58 +13:00
|
|
|
str_replace(' ' ,'',_t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Changed Title'),
|
2015-03-30 11:28:42 +13:00
|
|
|
array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle')),
|
2013-10-29 12:06:26 +01:00
|
|
|
'Detects published title changes'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertNotContains(
|
2014-02-18 18:43:58 +13:00
|
|
|
str_replace(' ' ,'',_t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Unpublished Changed Title'),
|
2015-03-30 11:28:42 +13:00
|
|
|
array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle')),
|
2013-10-29 12:06:26 +01:00
|
|
|
'Ignores unpublished title changes'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-03-30 11:28:42 +13:00
|
|
|
}
|