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 |
||
| 22 | class SubClassDataTest extends UnitTestCase |
||
| 23 | { |
||
| 24 | //<editor-fold desc="Public Methods"> |
||
| 25 | /** |
||
| 26 | * @covers \Tfboe\FmLib\Entity\Helpers\SubClassData::addPropertyIfNotExistent |
||
| 27 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::__call |
||
| 28 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::getProperty |
||
| 29 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::hasProperty |
||
| 30 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::initSubClassData |
||
| 31 | */ |
||
| 32 | public function testAddPropertyIfNotExistent() |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @covers \Tfboe\FmLib\Entity\Helpers\SubClassData::__call |
||
| 47 | * @covers \Tfboe\FmLib\Entity\Helpers\SubClassData::getProperty |
||
| 48 | * @covers \Tfboe\FmLib\Entity\Helpers\SubClassData::setProperty |
||
| 49 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::hasProperty |
||
| 50 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::initSubClassData |
||
| 51 | */ |
||
| 52 | public function testCall() |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @covers \Tfboe\FmLib\Entity\Helpers\SubClassData::cloneSubClassDataFrom |
||
| 68 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::hasProperty |
||
| 69 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::initSubClassData |
||
| 70 | */ |
||
| 71 | public function testCloneSubClassDataFrom() |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @covers \Tfboe\FmLib\Entity\Helpers\SubClassData::initSubClassData |
||
| 87 | * @covers \Tfboe\FmLib\Entity\Helpers\SubClassData::hasProperty |
||
| 88 | */ |
||
| 89 | View Code Duplication | public function testInitSubClassDataAndHasProperty() |
|
| 116 | |||
| 117 | /** |
||
| 118 | * @covers \Tfboe\FmLib\Entity\Helpers\SubClassData::methodExists |
||
| 119 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::addPropertyIfNotExistent |
||
| 120 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::hasProperty |
||
| 121 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::initSubClassData |
||
| 122 | */ |
||
| 123 | View Code Duplication | public function testMethodExists() |
|
| 140 | |||
| 141 | /** |
||
| 142 | * @covers \Tfboe\FmLib\Entity\Helpers\SubClassData::__call |
||
| 143 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::initSubClassData |
||
| 144 | * @uses \Tfboe\FmLib\Exceptions\MethodNotExistingException::__construct |
||
| 145 | */ |
||
| 146 | View Code Duplication | public function testNotExistingMethodCall() |
|
| 155 | |||
| 156 | /** |
||
| 157 | * @covers \Tfboe\FmLib\Entity\Helpers\SubClassData::__call |
||
| 158 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::initSubClassData |
||
| 159 | * @uses \Tfboe\FmLib\Exceptions\MethodNotExistingException::__construct |
||
| 160 | */ |
||
| 161 | View Code Duplication | public function testNotExistingMethodSetterNoArgument() |
|
| 170 | |||
| 171 | /** |
||
| 172 | * @covers \Tfboe\FmLib\Entity\Helpers\SubClassData::__call |
||
| 173 | * @covers \Tfboe\FmLib\Entity\Helpers\SubClassData::getProperty |
||
| 174 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::initSubClassData |
||
| 175 | * @uses \Tfboe\FmLib\Exceptions\PropertyNotExistingException::__construct |
||
| 176 | */ |
||
| 177 | View Code Duplication | public function testNotExistingPropertyGetCall() |
|
| 187 | |||
| 188 | /** |
||
| 189 | * @covers \Tfboe\FmLib\Entity\Helpers\SubClassData::__call |
||
| 190 | * @covers \Tfboe\FmLib\Entity\Helpers\SubClassData::setProperty |
||
| 191 | * @uses \Tfboe\FmLib\Entity\Helpers\SubClassData::initSubClassData |
||
| 192 | * @uses \Tfboe\FmLib\Exceptions\PropertyNotExistingException::__construct |
||
| 193 | */ |
||
| 194 | View Code Duplication | public function testNotExistingPropertySetCall() |
|
| 204 | //</editor-fold desc="Public Methods"> |
||
| 205 | |||
| 206 | //<editor-fold desc="Private Methods"> |
||
| 207 | /** |
||
| 208 | * @return \PHPUnit_Framework_MockObject_MockObject|SubClassData |
||
| 209 | */ |
||
| 210 | private function mock(): \PHPUnit_Framework_MockObject_MockObject |
||
| 214 | //</editor-fold desc="Private Methods"> |
||
| 215 | } |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.