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 | class DoctrineDatabaseTest extends TestCase |
||
19 | { |
||
20 | /** |
||
21 | * Database gateway to test. |
||
22 | * |
||
23 | * @var \eZ\Publish\Core\Persistence\Legacy\Content\Language\Gateway\DoctrineDatabase |
||
24 | */ |
||
25 | protected $databaseGateway; |
||
26 | |||
27 | /** |
||
28 | * Inserts DB fixture. |
||
29 | */ |
||
30 | public function setUp() |
||
38 | |||
39 | /** |
||
40 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Gateway\DoctrineDatabase::__construct |
||
41 | */ |
||
42 | public function testCtor() |
||
53 | |||
54 | /** |
||
55 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Gateway\DoctrineDatabase::insertLanguage |
||
56 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Gateway\DoctrineDatabase::setCommonLanguageColumns |
||
57 | */ |
||
58 | public function testInsertLanguage() |
||
79 | |||
80 | /** |
||
81 | * Returns a Language fixture. |
||
82 | * |
||
83 | * @return \eZ\Publish\SPI\Persistence\Content\Language |
||
84 | */ |
||
85 | protected function getLanguageFixture() |
||
95 | |||
96 | /** |
||
97 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Gateway\DoctrineDatabase::updateLanguage |
||
98 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Gateway\DoctrineDatabase::setCommonLanguageColumns |
||
99 | */ |
||
100 | View Code Duplication | public function testUpdateLanguage() |
|
124 | |||
125 | /** |
||
126 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Gateway\DoctrineDatabase::loadLanguageListData |
||
127 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Gateway\DoctrineDatabase::createFindQuery |
||
128 | */ |
||
129 | public function testLoadLanguageListData() |
||
130 | { |
||
131 | $gateway = $this->getDatabaseGateway(); |
||
132 | |||
133 | $result = $gateway->loadLanguageListData([2]); |
||
134 | |||
135 | $this->assertEquals( |
||
136 | array( |
||
137 | array( |
||
138 | 'id' => '2', |
||
139 | 'locale' => 'eng-US', |
||
140 | 'name' => 'English (American)', |
||
141 | 'disabled' => '0', |
||
142 | ), |
||
143 | ), |
||
144 | $result |
||
145 | ); |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Gateway\DoctrineDatabase::loadAllLanguagesData |
||
150 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Gateway\DoctrineDatabase::createFindQuery |
||
151 | */ |
||
152 | public function testLoadAllLanguagesData() |
||
176 | |||
177 | /** |
||
178 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Gateway\DoctrineDatabase::deleteLanguage |
||
179 | */ |
||
180 | View Code Duplication | public function testDeleteLanguage() |
|
209 | |||
210 | /** |
||
211 | * Returns a ready to test DoctrineDatabase gateway. |
||
212 | * |
||
213 | * @return \eZ\Publish\Core\Persistence\Legacy\Content\Language\Gateway\DoctrineDatabase |
||
214 | */ |
||
215 | protected function getDatabaseGateway() |
||
225 | } |
||
226 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.