2013-10-29 12:06:26 +01:00
|
|
|
<?php
|
2017-12-11 00:10:56 +01:00
|
|
|
|
|
|
|
namespace SilverStripe\VersionFeed\Tests;
|
|
|
|
|
|
|
|
use Page;
|
2017-12-13 04:13:46 +01:00
|
|
|
use SilverStripe\CMS\Controllers\ContentController;
|
|
|
|
use SilverStripe\CMS\Model\SiteTree;
|
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
use SilverStripe\Versioned\Versioned;
|
2017-12-11 00:10:56 +01:00
|
|
|
use SilverStripe\VersionFeed\VersionFeed;
|
|
|
|
use SilverStripe\VersionFeed\VersionFeedController;
|
|
|
|
|
2017-12-11 21:47:35 +01:00
|
|
|
class VersionFeedTest extends SapphireTest
|
|
|
|
{
|
|
|
|
protected $usesDatabase = true;
|
|
|
|
|
|
|
|
protected static $required_extensions = [
|
|
|
|
SiteTree::class => [VersionFeed::class],
|
|
|
|
ContentController::class => [VersionFeedController::class],
|
|
|
|
];
|
|
|
|
|
|
|
|
public function testDiffedChangesExcludesRestrictedItems()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDiffedChangesIncludesFullHistory()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDiffedChangesTitle()
|
|
|
|
{
|
|
|
|
$page = new Page(['Title' => 'My Title']);
|
|
|
|
$page->write();
|
2017-12-18 04:38:16 +01:00
|
|
|
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
2017-12-11 21:47:35 +01:00
|
|
|
|
|
|
|
$page->Title = 'My Changed Title';
|
|
|
|
$page->write();
|
2017-12-18 04:38:16 +01:00
|
|
|
$page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
|
2017-12-11 21:47:35 +01:00
|
|
|
|
|
|
|
$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) {
|
2022-04-13 03:53:29 +02:00
|
|
|
return str_replace(' ', '', strip_tags($val ?? ''));
|
2017-12-11 21:47:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
$this->assertContains(
|
|
|
|
str_replace(' ', '', _t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Changed Title'),
|
2022-04-13 03:53:29 +02:00
|
|
|
array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle') ?? []),
|
2017-12-11 21:47:35 +01:00
|
|
|
'Detects published title changes'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertNotContains(
|
|
|
|
str_replace(' ', '', _t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Unpublished Changed Title'),
|
2022-04-13 03:53:29 +02:00
|
|
|
array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle') ?? []),
|
2017-12-11 21:47:35 +01:00
|
|
|
'Ignores unpublished title changes'
|
|
|
|
);
|
|
|
|
}
|
2015-03-30 00:28:42 +02:00
|
|
|
}
|