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 |
||
13 | abstract class AbstractApiTestCase extends AbstractTestCase |
||
14 | { |
||
15 | use DatabaseMigrations; |
||
16 | |||
17 | protected $apiUri = '/services.php'; |
||
18 | protected $guid = '{D6A33C24-DE43-D62C-A609-EF5138F33F30}'; |
||
19 | protected $success = 'Operation has succeeded'; |
||
20 | |||
21 | protected function buildUrl(string $url, array $data) : string |
||
28 | |||
29 | protected function seeSuccess() |
||
34 | |||
35 | /** |
||
36 | * Assert that a given where condition does not matches a soft deleted record |
||
37 | * From: http://stackoverflow.com/questions/33117746/laravel-unit-testing-how-to-seeindatabase-soft-deleted-row |
||
38 | * |
||
39 | * @param string $table |
||
40 | * @param array $data |
||
41 | * @param string $connection |
||
42 | * @return $this |
||
43 | */ |
||
44 | View Code Duplication | protected function seeIsNotSoftDeletedInDatabase($table, array $data, $connection = null) |
|
62 | |||
63 | /** |
||
64 | * Assert that a given where condition matches a soft deleted record |
||
65 | * From: http://stackoverflow.com/questions/33117746/laravel-unit-testing-how-to-seeindatabase-soft-deleted-row |
||
66 | * |
||
67 | * @param string $table |
||
68 | * @param array $data |
||
69 | * @param string $connection |
||
70 | * @return $this |
||
71 | */ |
||
72 | View Code Duplication | protected function seeIsSoftDeletedInDatabase($table, array $data, $connection = null) |
|
90 | } |
||
91 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.