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 |
||
| 17 | class phpbbdirectory_cats_test extends controller_base |
||
| 18 | { |
||
| 19 | public function getDataSet() |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Setup test environment |
||
| 26 | */ |
||
| 27 | public function setUp() |
||
| 41 | |||
| 42 | View Code Duplication | public function get_controller() |
|
| 66 | |||
| 67 | /** |
||
| 68 | * Test data for the test_display_cat_by_id() function |
||
| 69 | * |
||
| 70 | * @return array Array of test data |
||
| 71 | */ |
||
| 72 | public function display_cat_by_id_data() |
||
| 78 | |||
| 79 | /** |
||
| 80 | * Test controller display |
||
| 81 | * |
||
| 82 | * @dataProvider display_cat_by_id_data |
||
| 83 | */ |
||
| 84 | public function test_display_cat_by_id($cat_id, $page, $status_code) |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Test data for the test_display_cat_by_route() function |
||
| 95 | * |
||
| 96 | * @return array Array of test data |
||
| 97 | */ |
||
| 98 | public function display_cat_by_route_data() |
||
| 104 | |||
| 105 | /** |
||
| 106 | * Test controller display |
||
| 107 | * |
||
| 108 | * @dataProvider display_cat_by_route_data |
||
| 109 | */ |
||
| 110 | public function test_display_cat_by_route($cat_id, $page, $status_code, $page_content) |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Test data for the test_display_cat_fails() function |
||
| 125 | * |
||
| 126 | * @return array Array of test data |
||
| 127 | */ |
||
| 128 | public function display_cat_fails_data() |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Test controller display throws 404 exceptions |
||
| 137 | * |
||
| 138 | * @dataProvider display_cat_fails_data |
||
| 139 | */ |
||
| 140 | public function test_display_cat_fails($cat_id, $page, $status_code, $page_content) |
||
| 154 | |||
| 155 | /** |
||
| 156 | * Test data for the test_category_one_page() function |
||
| 157 | * |
||
| 158 | * @return array Array of test data |
||
| 159 | */ |
||
| 160 | public function category_one_page_data() |
||
| 166 | |||
| 167 | /** |
||
| 168 | * Test base case scenario |
||
| 169 | * |
||
| 170 | * @dataProvider category_one_page_data |
||
| 171 | */ |
||
| 172 | View Code Duplication | function test_category_one_page($cat_id, $cat_name, $parent_cat_id, $nb_links) |
|
| 179 | |||
| 180 | /** |
||
| 181 | * Test data for the test_category_no_links() function |
||
| 182 | * |
||
| 183 | * @return array Array of test data |
||
| 184 | */ |
||
| 185 | public function category_no_links_data() |
||
| 191 | |||
| 192 | /** |
||
| 193 | * Test base case scenario |
||
| 194 | * |
||
| 195 | * @dataProvider category_no_links_data |
||
| 196 | */ |
||
| 197 | function test_category_no_links($cat_id, $cat_name, $nb_links) |
||
| 210 | |||
| 211 | /** |
||
| 212 | * Test data for the test_category_with_pages() function |
||
| 213 | * |
||
| 214 | * @return array Array of test data |
||
| 215 | */ |
||
| 216 | View Code Duplication | public function category_with_pages_data() |
|
| 223 | |||
| 224 | /** |
||
| 225 | * Test base case scenario |
||
| 226 | * |
||
| 227 | * @dataProvider category_with_pages_data |
||
| 228 | */ |
||
| 229 | View Code Duplication | public function test_category_with_pages($cat_id, $cat_name, $parent_cat_id, $parent_cat_name, $nb_links, $page = 1, $sort_days = 0) |
|
| 236 | |||
| 237 | protected function tearDown() |
||
| 241 | } |
||
| 242 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.