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 |
||
| 38 | class FlexiBeeTest extends \Test\Ease\BrickTest |
||
|
|
|||
| 39 | { |
||
| 40 | /** |
||
| 41 | * @var FlexiBee |
||
| 42 | */ |
||
| 43 | protected $object; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Sets up the fixture, for example, opens a network connection. |
||
| 47 | * This method is called before a test is executed. |
||
| 48 | * @covers FlexiPeeHP\FlexiBee::__construct |
||
| 49 | */ |
||
| 50 | protected function setUp() |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Tears down the fixture, for example, closes a network connection. |
||
| 57 | * This method is called after a test is executed. |
||
| 58 | */ |
||
| 59 | protected function tearDown() |
||
| 63 | |||
| 64 | public function testCurlInit() |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @covers FlexiPeeHP\FlexiBee::setAgenda |
||
| 72 | */ |
||
| 73 | public function testSetAgenda() |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @covers FlexiPeeHP\FlexiBee::object2array |
||
| 81 | */ |
||
| 82 | public function testObject2array() |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @covers FlexiPeeHP\FlexiBee::performRequest |
||
| 95 | */ |
||
| 96 | public function testPerformRequest() |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @covers FlexiPeeHP\FlexiBee::getLastInsertedId |
||
| 125 | * @depends testInsertToFlexiBee |
||
| 126 | */ |
||
| 127 | public function testGetLastInsertedId() |
||
| 131 | |||
| 132 | /** |
||
| 133 | * @covers FlexiPeeHP\FlexiBee::xml2array |
||
| 134 | */ |
||
| 135 | public function testXml2array() |
||
| 152 | |||
| 153 | /** |
||
| 154 | * @covers FlexiPeeHP\FlexiBee::disconnect |
||
| 155 | * |
||
| 156 | * @depends testPerformRequest |
||
| 157 | * @depends testLoadFlexiData |
||
| 158 | * @depends testGetFlexiRow |
||
| 159 | * @depends testGetFlexiData |
||
| 160 | * @depends testLoadFromFlexiBee |
||
| 161 | * @depends testSaveToFlexiBee |
||
| 162 | * @depends testInsertToFlexiBee |
||
| 163 | * @depends testIdExists |
||
| 164 | * @depends testRecordExists |
||
| 165 | * @depends testGetColumnsFromFlexibee |
||
| 166 | * @depends testSearchString |
||
| 167 | */ |
||
| 168 | public function testDisconnect() |
||
| 173 | |||
| 174 | /** |
||
| 175 | * @covers FlexiPeeHP\FlexiBee::__destruct |
||
| 176 | * @depends testDisconnect |
||
| 177 | */ |
||
| 178 | public function test__destruct() |
||
| 182 | |||
| 183 | /** |
||
| 184 | * @covers FlexiPeeHP\FlexiBee::loadFlexiData |
||
| 185 | * @todo Implement testLoadFlexiData(). |
||
| 186 | */ |
||
| 187 | public function testLoadFlexiData() |
||
| 194 | |||
| 195 | /** |
||
| 196 | * @covers FlexiPeeHP\FlexiBee::getFlexiRow |
||
| 197 | */ |
||
| 198 | public function testGetFlexiRow() |
||
| 203 | |||
| 204 | /** |
||
| 205 | * @covers FlexiPeeHP\FlexiBee::getFlexiData |
||
| 206 | */ |
||
| 207 | public function testGetFlexiData() |
||
| 226 | |||
| 227 | /** |
||
| 228 | * @covers FlexiPeeHP\FlexiBee::loadFromFlexiBee |
||
| 229 | */ |
||
| 230 | public function testLoadFromFlexiBee() |
||
| 235 | |||
| 236 | /** |
||
| 237 | * @covers FlexiPeeHP\FlexiBee::saveToFlexiBee |
||
| 238 | * @todo Implement testSaveToFlexiBee(). |
||
| 239 | */ |
||
| 240 | public function testSaveToFlexiBee() |
||
| 247 | |||
| 248 | /** |
||
| 249 | * @covers FlexiPeeHP\FlexiBee::jsonizeData |
||
| 250 | */ |
||
| 251 | public function testJsonizeData() |
||
| 256 | |||
| 257 | /** |
||
| 258 | * @covers FlexiPeeHP\FlexiBee::insertToFlexiBee |
||
| 259 | * @todo Implement testInsertToFlexiBee(). |
||
| 260 | */ |
||
| 261 | public function testInsertToFlexiBee() |
||
| 268 | |||
| 269 | /** |
||
| 270 | * @covers FlexiPeeHP\FlexiBee::idExists |
||
| 271 | * @todo Implement testIdExists(). |
||
| 272 | */ |
||
| 273 | public function testIdExists() |
||
| 280 | |||
| 281 | /** |
||
| 282 | * @covers FlexiPeeHP\FlexiBee::recordExists |
||
| 283 | */ |
||
| 284 | public function testRecordExists() |
||
| 289 | |||
| 290 | /** |
||
| 291 | * @covers FlexiPeeHP\FlexiBee::getColumnsFromFlexibee |
||
| 292 | * @todo Implement testGetColumnsFromFlexibee(). |
||
| 293 | */ |
||
| 294 | public function testGetColumnsFromFlexibee() |
||
| 301 | |||
| 302 | /** |
||
| 303 | * @covers FlexiPeeHP\FlexiBee::getKod |
||
| 304 | */ |
||
| 305 | public function testGetKod() |
||
| 331 | |||
| 332 | /** |
||
| 333 | * @covers FlexiPeeHP\FlexiBee::searchString |
||
| 334 | * @todo Implement testSearchString(). |
||
| 335 | */ |
||
| 336 | public function testSearchString() |
||
| 343 | |||
| 344 | /** |
||
| 345 | * @covers FlexiPeeHP\FlexiBee::logResult |
||
| 346 | */ |
||
| 347 | public function testLogResult() |
||
| 367 | |||
| 368 | /** |
||
| 369 | * @covers FlexiPeeHP\FlexiBee::flexiUrl |
||
| 370 | */ |
||
| 371 | public function testFlexiUrl() |
||
| 378 | } |
Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.