Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
6 | class ManageableObjectDataExtensionTest extends SapphireTest |
||
|
|||
7 | { |
||
8 | |||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | protected static $fixture_file = 'fixtures.yml'; |
||
13 | |||
14 | /** |
||
15 | * @var array |
||
16 | */ |
||
17 | protected $extraDataObjects = [ |
||
18 | SampleManageableDataObject::class, |
||
19 | SampleManageableObjectPage::class, |
||
20 | ]; |
||
21 | |||
22 | /** |
||
23 | * Ensure any current member is logged out |
||
24 | */ |
||
25 | public function logOut() |
||
26 | { |
||
27 | if ($member = Member::currentUser()) { |
||
28 | $member->logOut(); |
||
29 | } |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * |
||
34 | */ |
||
35 | public function testGetListingPage() |
||
36 | { |
||
37 | $this->assertEquals(SampleManageableObjectPage::class, |
||
38 | Injector::inst()->get(SampleManageableDataObject::class)->getListingPage()); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * |
||
43 | */ |
||
44 | public function testGetAddLink() |
||
45 | { |
||
46 | $page = $this->objFromFixture(SampleManageableObjectPage::class, 'one'); |
||
47 | $object = $this->objFromFixture(SampleManageableDataObject::class, 'one'); |
||
48 | |||
49 | $this->logOut(); |
||
50 | $this->assertFalse($object->getAddLink()); |
||
51 | |||
52 | $this->logInWithPermission('MDO_Create'); |
||
53 | |||
54 | $this->assertEquals($page->Link('add'), $object->getAddLink()); |
||
55 | |||
56 | $this->logOut(); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * |
||
61 | */ |
||
62 | public function testGetEditLink() |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * |
||
79 | */ |
||
80 | public function testGetDeleteLink() |
||
93 | } |
||
94 | |||
95 | } |
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