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 |
||
23 | class CachingLanguageHandlerTest extends TestCase |
||
24 | { |
||
25 | /** |
||
26 | * Language handler. |
||
27 | * |
||
28 | * @var \eZ\Publish\Core\Persistence\Legacy\Content\Language\Handler |
||
29 | */ |
||
30 | protected $languageHandler; |
||
31 | |||
32 | /** |
||
33 | * Inner language handler mock. |
||
34 | * |
||
35 | * @var \eZ\Publish\SPI\Persistence\Content\Language\Handler |
||
36 | */ |
||
37 | protected $innerHandlerMock; |
||
38 | |||
39 | /** |
||
40 | * Language cache mock. |
||
41 | * |
||
42 | * @var \eZ\Publish\Core\Persistence\Cache\InMemory\InMemoryCache |
||
43 | */ |
||
44 | protected $languageCacheMock; |
||
45 | |||
46 | /** |
||
47 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingHandler::__construct |
||
48 | */ |
||
49 | public function testCtorPropertyInnerHandler() |
||
59 | |||
60 | /** |
||
61 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingHandler::__construct |
||
62 | */ |
||
63 | public function testCtorPropertyLanguageCache() |
||
73 | |||
74 | /** |
||
75 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingHandler::create |
||
76 | */ |
||
77 | public function testCreate() |
||
106 | |||
107 | /** |
||
108 | * Returns a Language CreateStruct. |
||
109 | * |
||
110 | * @return \eZ\Publish\SPI\Persistence\Content\Language\CreateStruct |
||
111 | */ |
||
112 | protected function getCreateStructFixture() |
||
116 | |||
117 | /** |
||
118 | * Returns a Language. |
||
119 | * |
||
120 | * @return \eZ\Publish\SPI\Persistence\Content\Language |
||
121 | */ |
||
122 | protected function getLanguageFixture() |
||
130 | |||
131 | /** |
||
132 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingHandler::update |
||
133 | */ |
||
134 | public function testUpdate() |
||
153 | |||
154 | /** |
||
155 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingHandler::load |
||
156 | */ |
||
157 | View Code Duplication | public function testLoad() |
|
174 | |||
175 | /** |
||
176 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingHandler::load |
||
177 | */ |
||
178 | View Code Duplication | public function testLoadFailure() |
|
201 | |||
202 | /** |
||
203 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingHandler::loadByLanguageCode |
||
204 | */ |
||
205 | View Code Duplication | public function testLoadByLanguageCode() |
|
222 | |||
223 | /** |
||
224 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingHandler::loadByLanguageCode |
||
225 | */ |
||
226 | View Code Duplication | public function testLoadByLanguageCodeFailure() |
|
249 | |||
250 | /** |
||
251 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\Handler::loadAll |
||
252 | */ |
||
253 | public function testLoadAll() |
||
270 | |||
271 | /** |
||
272 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingHandler::delete |
||
273 | */ |
||
274 | public function testDelete() |
||
290 | |||
291 | /** |
||
292 | * Returns the language handler to test. |
||
293 | * |
||
294 | * @return \eZ\Publish\Core\Persistence\Legacy\Content\Language\CachingHandler |
||
295 | */ |
||
296 | protected function getLanguageHandler() |
||
307 | |||
308 | /** |
||
309 | * Returns a mock for the inner language handler. |
||
310 | * |
||
311 | * @return \eZ\Publish\SPI\Persistence\Content\Language\Handler|\PHPUnit\Framework\MockObject\MockObject |
||
312 | */ |
||
313 | protected function getInnerLanguageHandlerMock() |
||
321 | |||
322 | /** |
||
323 | * Returns a mock for the in-memory cache. |
||
324 | * |
||
325 | * @return \eZ\Publish\Core\Persistence\Cache\InMemory\InMemoryCache|\PHPUnit\Framework\MockObject\MockObject |
||
326 | */ |
||
327 | protected function getLanguageCacheMock() |
||
335 | |||
336 | /** |
||
337 | * Returns an array with 2 languages. |
||
338 | * |
||
339 | * @return \eZ\Publish\SPI\Persistence\Content\Language[] |
||
340 | */ |
||
341 | View Code Duplication | protected function getLanguagesFixture() |
|
357 | } |
||
358 |
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.