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 |
||
7 | class AddonBuilderTest extends SapphireTest |
||
8 | { |
||
9 | /** |
||
10 | * @var AddonBuilder |
||
11 | */ |
||
12 | protected $builder; |
||
13 | |||
14 | /** |
||
15 | * Get the test subject |
||
16 | */ |
||
17 | public function setUp() |
||
27 | |||
28 | /** |
||
29 | * Test that a GitHub repository can be identified, and have its context returned if it matches |
||
30 | * |
||
31 | * @param string $input |
||
32 | * @param string|false $expected |
||
33 | * @dataProvider repositoryContextProvider |
||
34 | */ |
||
35 | public function testGetGitHubContext($input, $expected) |
||
42 | |||
43 | public function repositoryContextProvider() |
||
52 | |||
53 | /** |
||
54 | * Test that the GitHub-ness of an addon's repository can be correctly established |
||
55 | * |
||
56 | * @param string $repository |
||
57 | * @param bool $expected |
||
58 | * @covers ::hasGitHubRepository |
||
59 | * @dataProvider hasGitHubProvider |
||
60 | */ |
||
61 | public function testHasGitHubRepository($repository, $expected) |
||
69 | |||
70 | /** |
||
71 | * @return array |
||
72 | */ |
||
73 | public function hasGitHubProvider() |
||
86 | |||
87 | /** |
||
88 | * Test that we can determine the differece between a relative-ish URI and one that isn't, so we know |
||
89 | * when to insert the GitHub repository URL into the mix. |
||
90 | * |
||
91 | * @param string $uri |
||
92 | * @param bool $expected |
||
93 | * @covers ::isRelativeUri |
||
94 | * @dataProvider uriProvider() |
||
95 | */ |
||
96 | public function testIsRelativeUri($uri, $expected) |
||
100 | |||
101 | /** |
||
102 | * @return array |
||
103 | */ |
||
104 | public function uriProvider() |
||
116 | |||
117 | /** |
||
118 | * Ensure that a HTML readme can have its relative links rewritten according to the Addon is belongs to |
||
119 | * |
||
120 | * @covers ::replaceRelativeLinks |
||
121 | */ |
||
122 | View Code Duplication | public function testRewriteRelativeLinksAndImages() |
|
146 | |||
147 | /** |
||
148 | * For non GitHub repositories, the readme input should simply be returned as is from the "replaceRelativeLinks" |
||
149 | * method |
||
150 | */ |
||
151 | View Code Duplication | public function testDoNotRewriteRelativeLinksForNonGitHubRepositories() |
|
158 | } |
||
159 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.