Conditions | 5 |
Paths | 16 |
Total Lines | 72 |
Code Lines | 44 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
66 | } |
||
67 | |||
68 | public function testGetCMSFields() |
||
69 | { |
||
70 | $report = SitewideContentReport::create(); |
||
71 | $fields = $report->getCMSFields(); |
||
72 | |||
73 | if (class_exists(Subsite::class)) { |
||
74 | $field = $fields->fieldByName('AllSubsites'); |
||
75 | $count = count(array_filter(array_keys($field->getSource()), function ($value) { |
||
76 | return is_int($value); |
||
77 | })); |
||
78 | |||
79 | $this->assertEquals(4, $count, '2 subsites plus 2 added options to filter by subsite'); |
||
80 | } else { |
||
81 | $this->assertNull($fields->fieldByName('AllSubsites')); |
||
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); |
||
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