1 | <?php |
||
6 | use SilverStripe\ORM\DataList; |
||
7 | use SilverStripe\SiteWideContentReport\SitewideContentReport; |
||
8 | use SilverStripe\Forms\GridField\GridFieldDataColumns; |
||
9 | use SilverStripe\Forms\GridField\GridFieldExportButton; |
||
10 | use SilverStripe\SiteWideContentReport\Model\SitewideContentTaxonomy; |
||
11 | use SilverStripe\Dev\SapphireTest; |
||
12 | use SilverStripe\Subsites\Model\Subsite; |
||
|
|||
13 | use SilverStripe\ContentReview\Extensions\SiteTreeContentReview; |
||
14 | |||
15 | /** |
||
16 | * Class SitewideContentReportTest |
||
17 | * @package SilverStripe\SiteWideContentReport\Tests |
||
18 | */ |
||
19 | class SitewideContentReportTest extends SapphireTest |
||
20 | { |
||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | protected static $fixture_file = 'SitewideContentReportTest.yml'; |
||
25 | |||
26 | public function setUp() |
||
27 | { |
||
28 | // This module is made to work with subsites, but will still operate |
||
29 | // without it (although presumably being of far less value). |
||
30 | // The fixture includes subsite definitions, which is a problem if |
||
31 | // the module isn't installed. So we'll use the same fixture without |
||
32 | // the subsites definitions if this is the case. |
||
33 | if (!class_exists(Subsite::class)) { |
||
34 | static::$fixture_file = 'SitewideContentReportNoSubsitesTest.yml'; |
||
35 | } |
||
36 | |||
37 | parent::setUp(); |
||
38 | |||
39 | foreach (range(1, 5) as $i) { |
||
40 | /** @var SiteTree $page */ |
||
41 | $page = $this->objFromFixture('Page', "page{$i}"); |
||
42 | |||
43 | if ($i <= 3) { |
||
44 | $page->publishRecursive(); |
||
45 | } |
||
46 | } |
||
47 | } |
||
48 | |||
49 | public function testSourceRecords() |
||
66 | } |
||
67 | |||
68 | public function testGetCMSFields() |
||
82 | } |
||
83 | } |
||
84 | |||
85 | public function testReportFields() |
||
86 | { |
||
87 | $report = SitewideContentReport::create(); |
||
88 | |||
89 | // Test pages view |
||
90 | $gridField = $report->getReportField('Pages'); |
||
91 | |||
92 | /* @var $columns GridFieldDataColumns */ |
||
93 | $columns = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class); |
||
94 | $displayed = $columns->getDisplayFields($gridField); |
||
95 | |||
96 | $this->assertArrayHasKey('Title', $displayed); |
||
97 | $this->assertArrayHasKey('Created', $displayed); |
||
98 | $this->assertArrayHasKey('LastEdited', $displayed); |
||
99 | $this->assertArrayHasKey('i18n_singular_name', $displayed); |
||
100 | $this->assertArrayHasKey('StageState', $displayed); |
||
101 | |||
102 | // Use correct link |
||
103 | $this->assertArrayHasKey('RelativeLink', $displayed); |
||
104 | $this->assertArrayNotHasKey('AbsoluteLink', $displayed); |
||
105 | |||
106 | if (class_exists(Subsite::class)) { |
||
107 | $this->assertArrayHasKey('SubsiteName', $displayed); |
||
108 | } else { |
||
109 | $this->assertArrayNotHasKey('SubsiteName', $displayed); |
||
110 | } |
||
111 | |||
112 | // Export-only fields are not in display list |
||
113 | $this->assertArrayNotHasKey('Terms', $displayed); |
||
114 | $this->assertArrayNotHasKey('OwnerNames', $displayed); |
||
115 | $this->assertArrayNotHasKey('ReviewDate', $displayed); |
||
116 | $this->assertArrayNotHasKey('MetaDescription', $displayed); |
||
117 | |||
118 | // Tests print / export field |
||
119 | /* @var $export GridFieldExportButton */ |
||
120 | $export = $gridField->getConfig()->getComponentByType(GridFieldExportButton::class); |
||
121 | $exported = $export->getExportColumns(); |
||
122 | |||
123 | // Make sure all shared columns are in this report |
||
124 | $this->assertArrayHasKey('Title', $exported); |
||
125 | $this->assertArrayHasKey('Created', $exported); |
||
126 | $this->assertArrayHasKey('LastEdited', $exported); |
||
127 | $this->assertArrayHasKey('i18n_singular_name', $exported); |
||
128 | $this->assertArrayHasKey('StageState', $exported); |
||
129 | |||
130 | // Export-only fields |
||
131 | $this->assertArrayHasKey('MetaDescription', $exported); |
||
132 | |||
133 | // Use correct link |
||
134 | $this->assertArrayHasKey('AbsoluteLink', $exported); |
||
135 | $this->assertArrayNotHasKey('RelativeLink', $exported); |
||
136 | |||
137 | if (class_exists(Subsite::class)) { |
||
138 | $this->assertArrayHasKey('SubsiteName', $exported); |
||
139 | } else { |
||
158 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths