Passed
Pull Request — master (#42)
by
unknown
04:10
created

testDiffedChangesExcludesRestrictedItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace SilverStripe\VersionFeed\Tests;
4
5
6
use Page;
0 ignored issues
show
Bug introduced by
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...
7
use SilverStripe\VersionFeed\VersionFeed;
8
use SilverStripe\VersionFeed\VersionFeedController;
9
use SilverStripe\Dev\SapphireTest;
10
use SilverStripe\CMS\Model\SiteTree;
11
use SilverStripe\CMS\Controllers\ContentController;
12
13
14
class VersionFeedTest extends SapphireTest {
15
16
	protected $usesDatabase = true;
17
18
	protected static $required_extensions = [
19
		SiteTree::class => [VersionFeed::class],
20
		ContentController::class => [VersionFeedController::class],
21
	];
22
23
	protected $illegalExtensions = [
24
		'SiteTree' => ['Translatable']
25
	];
26
27
	public function testDiffedChangesExcludesRestrictedItems() {
28
		$this->markTestIncomplete();
29
	}
30
31
	public function testDiffedChangesIncludesFullHistory() {
32
		$this->markTestIncomplete();
33
	}
34
35
	public function testDiffedChangesTitle() {
36
		$page = new Page(['Title' => 'My Title']);
37
		$page->write();
38
		$page->publish('Stage', 'Live');
39
	
40
		$page->Title = 'My Changed Title';
41
		$page->write();
42
		$page->publish('Stage', 'Live');
43
44
		$page->Title = 'My Unpublished Changed Title';
45
		$page->write();
46
47
		// Strip spaces from test output because they're not reliably maintained by the HTML Tidier
48
		$cleanDiffOutput = function($val) {
49
			return str_replace(' ','',strip_tags($val));
50
		};
51
52
		$this->assertContains(
53
			str_replace(' ' ,'',_t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Changed Title'),
54
			array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle')),
55
			'Detects published title changes'
56
		);
57
58
		$this->assertNotContains(
59
			str_replace(' ' ,'',_t('RSSHistory.TITLECHANGED', 'Title has changed:') . 'My Unpublished Changed Title'),
60
			array_map($cleanDiffOutput, $page->getDiffList()->column('DiffTitle')),
61
			'Ignores unpublished title changes'
62
		);
63
	}
64
65
}
66