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 |
||
| 8 | class NetgenOpenGraphExtensionTest extends AbstractExtensionTestCase |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @doesNotPerformAssertions |
||
| 12 | */ |
||
| 13 | public function testItSetsValidContainerParameters() |
||
| 14 | { |
||
| 15 | $this->container->setParameter('ezpublish.siteaccess.list', array()); |
||
| 16 | $this->load(); |
||
| 17 | } |
||
| 18 | |||
| 19 | protected function getContainerExtensions() |
||
| 20 | { |
||
| 21 | return array( |
||
| 22 | new NetgenOpenGraphExtension(), |
||
| 23 | ); |
||
| 24 | } |
||
| 25 | |||
| 26 | protected function getMinimalConfiguration() |
||
| 27 | { |
||
| 28 | return array( |
||
| 29 | 'system' => array( |
||
| 30 | 'default' => array( |
||
| 31 | 'content_type_handlers' => array( |
||
| 32 | 'content_type_one' => array( |
||
| 33 | array( |
||
| 34 | 'handler' => 'literal/text', |
||
| 35 | 'tag' => 'og:type', |
||
| 36 | 'params' => array( |
||
| 37 | 'one', |
||
| 38 | 'two', |
||
| 39 | 'three', |
||
| 40 | ), |
||
| 41 | ), |
||
| 42 | array( |
||
| 43 | 'handler' => 'field_type/ezstring', |
||
| 44 | 'tag' => 'og:title', |
||
| 45 | 'params' => array( |
||
| 46 | 'one', |
||
| 47 | 'two', |
||
| 48 | 'three', |
||
| 49 | ), |
||
| 50 | ), |
||
| 51 | ), |
||
| 52 | 'content_type_two' => array( |
||
| 53 | array( |
||
| 54 | 'handler' => 'field_type/ezstring', |
||
| 55 | 'tag' => 'og:title', |
||
| 56 | 'params' => array( |
||
| 57 | 'one', |
||
| 58 | 'two', |
||
| 59 | 'three', |
||
| 60 | ), |
||
| 61 | ), |
||
| 62 | ), |
||
| 63 | ), |
||
| 64 | 'global_handlers' => array( |
||
| 65 | array( |
||
| 66 | 'handler' => 'literal/text', |
||
| 67 | 'tag' => 'og:type', |
||
| 68 | 'params' => array( |
||
| 69 | 'one', |
||
| 70 | 'two', |
||
| 71 | 'three', |
||
| 72 | ), |
||
| 73 | ), |
||
| 74 | array( |
||
| 75 | 'handler' => 'field_type/ezstring', |
||
| 76 | 'tag' => 'og:title', |
||
| 77 | 'params' => array( |
||
| 78 | 'one', |
||
| 79 | 'two', |
||
| 80 | 'three', |
||
| 81 | ), |
||
| 82 | ), |
||
| 83 | ), |
||
| 84 | ), |
||
| 85 | ), |
||
| 86 | ); |
||
| 87 | } |
||
| 88 | } |
||
| 89 |