Conditions | 5 |
Paths | 1 |
Total Lines | 71 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
35 | public function testInitialPageLocalisation(bool $publish, int $limit, array $localised, array $published): void |
||
36 | { |
||
37 | // Check base records |
||
38 | $pages = FluentState::singleton()->withState(function (FluentState $state): array { |
||
39 | $state->setLocale(null); |
||
40 | |||
41 | // Publish some base records (too much effort to set up via fixture) |
||
42 | $pagesToPublish = [ |
||
43 | 'page1', |
||
44 | 'page2', |
||
45 | ]; |
||
46 | |||
47 | foreach ($pagesToPublish as $identifier) { |
||
48 | /** @var SiteTree $page */ |
||
49 | $page = $this->objFromFixture(SiteTree::class, $identifier); |
||
50 | $page->publishRecursive(); |
||
51 | } |
||
52 | |||
53 | return SiteTree::get() |
||
54 | ->sort('Title', 'ASC') |
||
55 | ->column('Title'); |
||
56 | }); |
||
57 | |||
58 | $allPages = [ |
||
59 | 'Page1', |
||
60 | 'Page2', |
||
61 | 'Page3', |
||
62 | 'Page4', |
||
63 | ]; |
||
64 | |||
65 | $this->assertEquals($allPages, $pages); |
||
66 | |||
67 | // Check localised records (should be empty) |
||
68 | $pages = $this->getLocalisedPages(); |
||
69 | $this->assertCount(0, $pages); |
||
70 | |||
71 | $getParams = [ |
||
72 | 'publish' => $publish, |
||
73 | 'limit' => $limit, |
||
74 | ]; |
||
75 | |||
76 | // Localise pages |
||
77 | InitialPageLocalisationTask::singleton()->run(new HTTPRequest('GET', '/', $getParams)); |
||
78 | |||
79 | // Check localised records (should have all pages now) |
||
80 | $pages = $this->getLocalisedPages(); |
||
81 | $this->assertEquals($localised, $pages); |
||
82 | |||
83 | // Check published state |
||
84 | $pages = FluentState::singleton()->withState(function (FluentState $state) use ($publish): array { |
||
85 | $state->setLocale('en_NZ'); |
||
86 | $pages = SiteTree::get()->sort('Title', 'ASC'); |
||
87 | $publishedPages = []; |
||
88 | |||
89 | /** @var SiteTree|FluentSiteTreeExtension $page */ |
||
90 | foreach ($pages as $page) { |
||
91 | if (!$page->isDraftedInLocale()) { |
||
92 | continue; |
||
93 | } |
||
94 | |||
95 | if (!$page->isPublishedInLocale()) { |
||
96 | continue; |
||
97 | } |
||
98 | |||
99 | $publishedPages[] = $page->Title; |
||
100 | } |
||
101 | |||
102 | return $publishedPages; |
||
103 | }); |
||
104 | |||
105 | $this->assertEquals($published, $pages); |
||
106 | } |
||
199 |
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