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 FlexiBeeROTest extends \Test\Ease\BrickTest |
||
|
|
|||
| 39 | { |
||
| 40 | /** |
||
| 41 | * @var FlexiBeeRO |
||
| 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\FlexiBeeRO::__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\FlexiBeeRO::setEvidence |
||
| 72 | */ |
||
| 73 | public function testSetEvidence() |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @covers FlexiPeeHP\FlexiBeeRO::object2array |
||
| 81 | */ |
||
| 82 | public function testObject2array() |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @covers FlexiPeeHP\FlexiBeeRO::performRequest |
||
| 95 | */ |
||
| 96 | public function testPerformRequest() |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @covers FlexiPeeHP\FlexiBeeRO::getLastInsertedId |
||
| 125 | * @depends testInsertToFlexiBee |
||
| 126 | */ |
||
| 127 | public function testGetLastInsertedId() |
||
| 131 | |||
| 132 | /** |
||
| 133 | * @covers FlexiPeeHP\FlexiBeeRO::xml2array |
||
| 134 | */ |
||
| 135 | public function testXml2array() |
||
| 152 | |||
| 153 | /** |
||
| 154 | * @covers FlexiPeeHP\FlexiBeeRO::disconnect |
||
| 155 | * |
||
| 156 | * @depends testPerformRequest |
||
| 157 | * @depends testLoadFlexiData |
||
| 158 | * @depends testGetFlexiRow |
||
| 159 | * @depends testGetFlexiData |
||
| 160 | * @depends testLoadFromFlexiBee |
||
| 161 | * @depends testInsertToFlexiBee |
||
| 162 | * @depends testIdExists |
||
| 163 | * @depends testRecordExists |
||
| 164 | * @depends testGetColumnsFromFlexibee |
||
| 165 | * @depends testSearchString |
||
| 166 | */ |
||
| 167 | public function testDisconnect() |
||
| 172 | |||
| 173 | /** |
||
| 174 | * @covers FlexiPeeHP\FlexiBeeRO::__destruct |
||
| 175 | * @depends testDisconnect |
||
| 176 | */ |
||
| 177 | public function test__destruct() |
||
| 181 | |||
| 182 | /** |
||
| 183 | * @covers FlexiPeeHP\FlexiBeeRO::loadFlexiData |
||
| 184 | * @todo Implement testLoadFlexiData(). |
||
| 185 | */ |
||
| 186 | public function testLoadFlexiData() |
||
| 193 | |||
| 194 | /** |
||
| 195 | * @covers FlexiPeeHP\FlexiBeeRO::getFlexiRow |
||
| 196 | */ |
||
| 197 | public function testGetFlexiRow() |
||
| 202 | |||
| 203 | /** |
||
| 204 | * @covers FlexiPeeHP\FlexiBeeRO::getFlexiData |
||
| 205 | */ |
||
| 206 | public function testGetFlexiData() |
||
| 225 | |||
| 226 | /** |
||
| 227 | * @covers FlexiPeeHP\FlexiBeeRO::loadFromFlexiBee |
||
| 228 | */ |
||
| 229 | public function testLoadFromFlexiBee() |
||
| 234 | |||
| 235 | /** |
||
| 236 | * @covers FlexiPeeHP\FlexiBeeRO::jsonizeData |
||
| 237 | */ |
||
| 238 | public function testJsonizeData() |
||
| 243 | |||
| 244 | /** |
||
| 245 | * @covers FlexiPeeHP\FlexiBeeRO::idExists |
||
| 246 | * @todo Implement testIdExists(). |
||
| 247 | */ |
||
| 248 | public function testIdExists() |
||
| 255 | |||
| 256 | /** |
||
| 257 | * @covers FlexiPeeHP\FlexiBeeRO::recordExists |
||
| 258 | */ |
||
| 259 | public function testRecordExists() |
||
| 264 | |||
| 265 | /** |
||
| 266 | * @covers FlexiPeeHP\FlexiBeeRO::getColumnsFromFlexibee |
||
| 267 | * @todo Implement testGetColumnsFromFlexibee(). |
||
| 268 | */ |
||
| 269 | public function testGetColumnsFromFlexibee() |
||
| 276 | |||
| 277 | /** |
||
| 278 | * @covers FlexiPeeHP\FlexiBeeRO::getKod |
||
| 279 | */ |
||
| 280 | public function testGetKod() |
||
| 307 | |||
| 308 | /** |
||
| 309 | * @covers FlexiPeeHP\FlexiBeeRO::searchString |
||
| 310 | * @todo Implement testSearchString(). |
||
| 311 | */ |
||
| 312 | public function testSearchString() |
||
| 319 | |||
| 320 | /** |
||
| 321 | * @covers FlexiPeeHP\FlexiBeeRO::logResult |
||
| 322 | */ |
||
| 323 | public function testLogResult() |
||
| 343 | |||
| 344 | /** |
||
| 345 | * @covers FlexiPeeHP\FlexiBeeRO::flexiUrl |
||
| 346 | */ |
||
| 347 | public function testFlexiUrl() |
||
| 354 | } |
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.