Issues (21)

tests/VersionFeedTest.php (1 issue)

1
<?php
2
3
namespace SilverStripe\VersionFeed\Tests;
4
5
use Page;
0 ignored issues
show
The type Page was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use SilverStripe\CMS\Controllers\ContentController;
7
use SilverStripe\CMS\Model\SiteTree;
8
use SilverStripe\Dev\SapphireTest;
9
use SilverStripe\Versioned\Versioned;
10
use SilverStripe\VersionFeed\VersionFeed;
11
use SilverStripe\VersionFeed\VersionFeedController;
12
13
class VersionFeedTest extends SapphireTest
14
{
15
    protected $usesDatabase = true;
16
17
    protected static $required_extensions = [
18
        SiteTree::class => [VersionFeed::class],
19
        ContentController::class => [VersionFeedController::class],
20
    ];
21
22
    public function testDiffedChangesExcludesRestrictedItems()
23
    {
24
        $this->markTestIncomplete();
25
    }
26
27
    public function testDiffedChangesIncludesFullHistory()
28
    {
29
        $this->markTestIncomplete();
30
    }
31
32
    public function testDiffedChangesTitle()
33
    {
34
        $page = new Page(['Title' => 'My Title']);
35
        $page->write();
36
        $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
37
    
38
        $page->Title = 'My Changed Title';
39
        $page->write();
40
        $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE);
41
42
        $page->Title = 'My Unpublished Changed Title';
43
        $page->write();
44
45
        // Strip spaces from test output because they're not reliably maintained by the HTML Tidier
46
        $cleanDiffOutput = function ($val) {
47
            return str_replace(' ', '', strip_tags($val));
48
        };
49
50
        $this->assertContains(
51
            str_replace(' ', '', _t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Changed Title'),
52
            array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle')),
53
            'Detects published title changes'
54
        );
55
56
        $this->assertNotContains(
57
            str_replace(' ', '', _t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Unpublished Changed Title'),
58
            array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle')),
59
            'Ignores unpublished title changes'
60
        );
61
    }
62
}
63