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 |
||
| 18 | abstract class GeneratorTest extends PHPUnit_Framework_TestCase |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * @var \eZ\Publish\Core\REST\Common\Output\Generator |
||
| 22 | */ |
||
| 23 | protected $generator; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @return \eZ\Publish\Core\REST\Common\Output\Generator |
||
| 27 | */ |
||
| 28 | abstract protected function getGenerator(); |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @expectedException \eZ\Publish\Core\REST\Common\Output\Exceptions\OutputGeneratorException |
||
| 32 | */ |
||
| 33 | public function testInvalidDocumentStart() |
||
| 40 | |||
| 41 | public function testValidDocumentStartAfterReset() |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @expectedException \eZ\Publish\Core\REST\Common\Output\Exceptions\OutputGeneratorException |
||
| 54 | */ |
||
| 55 | public function testInvalidDocumentNameEnd() |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @expectedException \eZ\Publish\Core\REST\Common\Output\Exceptions\OutputGeneratorException |
||
| 65 | */ |
||
| 66 | public function testInvalidOuterElementStart() |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @expectedException \eZ\Publish\Core\REST\Common\Output\Exceptions\OutputGeneratorException |
||
| 75 | */ |
||
| 76 | public function testInvalidElementEnd() |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @expectedException \eZ\Publish\Core\REST\Common\Output\Exceptions\OutputGeneratorException |
||
| 87 | */ |
||
| 88 | public function testInvalidDocumentEnd() |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @expectedException \eZ\Publish\Core\REST\Common\Output\Exceptions\OutputGeneratorException |
||
| 99 | */ |
||
| 100 | public function testInvalidAttributeOuterStart() |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @expectedException \eZ\Publish\Core\REST\Common\Output\Exceptions\OutputGeneratorException |
||
| 109 | */ |
||
| 110 | public function testInvalidAttributeDocumentStart() |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @expectedException \eZ\Publish\Core\REST\Common\Output\Exceptions\OutputGeneratorException |
||
| 120 | */ |
||
| 121 | public function testInvalidAttributeListStart() |
||
| 130 | |||
| 131 | /** |
||
| 132 | * @expectedException \eZ\Publish\Core\REST\Common\Output\Exceptions\OutputGeneratorException |
||
| 133 | */ |
||
| 134 | public function testInvalidValueElementOuterStart() |
||
| 140 | |||
| 141 | /** |
||
| 142 | * @expectedException \eZ\Publish\Core\REST\Common\Output\Exceptions\OutputGeneratorException |
||
| 143 | */ |
||
| 144 | public function testInvalidValueElementDocumentStart() |
||
| 151 | |||
| 152 | /** |
||
| 153 | * @expectedException \eZ\Publish\Core\REST\Common\Output\Exceptions\OutputGeneratorException |
||
| 154 | */ |
||
| 155 | public function testInvalidListOuterStart() |
||
| 161 | |||
| 162 | /** |
||
| 163 | * @expectedException \eZ\Publish\Core\REST\Common\Output\Exceptions\OutputGeneratorException |
||
| 164 | */ |
||
| 165 | public function testInvalidListDocumentStart() |
||
| 172 | |||
| 173 | /** |
||
| 174 | * @expectedException \eZ\Publish\Core\REST\Common\Output\Exceptions\OutputGeneratorException |
||
| 175 | */ |
||
| 176 | public function testInvalidListListStart() |
||
| 185 | |||
| 186 | public function testEmptyDocument() |
||
| 194 | |||
| 195 | public function testNonEmptyDocument() |
||
| 204 | |||
| 205 | public function testGetDocumentStackPath() |
||
| 213 | |||
| 214 | public function testGetRootStackPath() |
||
| 223 | |||
| 224 | public function testGetElementStackPath() |
||
| 234 | |||
| 235 | View Code Duplication | public function testGetListChildrenStackPath() |
|
| 248 | } |
||
| 249 |