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:
Complex classes like LocationServiceTest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use LocationServiceTest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
26 | class LocationServiceTest extends BaseTest |
||
27 | { |
||
28 | /** |
||
29 | * Test for the newLocationCreateStruct() method. |
||
30 | * |
||
31 | * @return \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct |
||
32 | * |
||
33 | * @see \eZ\Publish\API\Repository\LocationService::newLocationCreateStruct() |
||
34 | */ |
||
35 | View Code Duplication | public function testNewLocationCreateStruct() |
|
36 | { |
||
37 | $repository = $this->getRepository(); |
||
38 | |||
39 | $parentLocationId = $this->generateId('location', 1); |
||
40 | /* BEGIN: Use Case */ |
||
41 | // $parentLocationId is the ID of an existing location |
||
42 | $locationService = $repository->getLocationService(); |
||
43 | |||
44 | $locationCreate = $locationService->newLocationCreateStruct( |
||
45 | $parentLocationId |
||
46 | ); |
||
47 | /* END: Use Case */ |
||
48 | |||
49 | $this->assertInstanceOf( |
||
50 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\LocationCreateStruct', |
||
51 | $locationCreate |
||
52 | ); |
||
53 | |||
54 | return $locationCreate; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Test for the newLocationCreateStruct() method. |
||
59 | * |
||
60 | * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $locationCreate |
||
61 | * |
||
62 | * @see \eZ\Publish\API\Repository\LocationService::newLocationCreateStruct() |
||
63 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
||
64 | */ |
||
65 | public function testNewLocationCreateStructValues(LocationCreateStruct $locationCreate) |
||
66 | { |
||
67 | $this->assertPropertiesCorrect( |
||
68 | array( |
||
69 | 'priority' => 0, |
||
70 | 'hidden' => false, |
||
71 | // remoteId should be initialized with a default value |
||
72 | //'remoteId' => null, |
||
73 | 'sortField' => Location::SORT_FIELD_NAME, |
||
74 | 'sortOrder' => Location::SORT_ORDER_ASC, |
||
75 | 'parentLocationId' => $this->generateId('location', 1), |
||
76 | ), |
||
77 | $locationCreate |
||
78 | ); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * Test for the createLocation() method. |
||
83 | * |
||
84 | * @see \eZ\Publish\API\Repository\LocationService::createLocation() |
||
85 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
||
86 | */ |
||
87 | public function testCreateLocation() |
||
88 | { |
||
89 | $repository = $this->getRepository(); |
||
90 | |||
91 | $contentId = $this->generateId('object', 41); |
||
92 | $parentLocationId = $this->generateId('location', 5); |
||
93 | /* BEGIN: Use Case */ |
||
94 | // $contentId is the ID of an existing content object |
||
95 | // $parentLocationId is the ID of an existing location |
||
96 | $contentService = $repository->getContentService(); |
||
97 | $locationService = $repository->getLocationService(); |
||
98 | |||
99 | // ContentInfo for "How to use eZ Publish" |
||
100 | $contentInfo = $contentService->loadContentInfo($contentId); |
||
101 | |||
102 | $locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
||
103 | $locationCreate->priority = 23; |
||
104 | $locationCreate->hidden = true; |
||
105 | $locationCreate->remoteId = 'sindelfingen'; |
||
106 | $locationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
||
107 | $locationCreate->sortOrder = Location::SORT_ORDER_DESC; |
||
108 | |||
109 | $location = $locationService->createLocation( |
||
110 | $contentInfo, |
||
111 | $locationCreate |
||
112 | ); |
||
113 | /* END: Use Case */ |
||
114 | |||
115 | $this->assertInstanceOf( |
||
116 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Location', |
||
117 | $location |
||
118 | ); |
||
119 | |||
120 | return array( |
||
121 | 'locationCreate' => $locationCreate, |
||
122 | 'createdLocation' => $location, |
||
123 | 'contentInfo' => $contentInfo, |
||
124 | 'parentLocation' => $locationService->loadLocation($this->generateId('location', 5)), |
||
125 | ); |
||
126 | } |
||
127 | |||
128 | /** |
||
129 | * Test for the createLocation() method. |
||
130 | * |
||
131 | * @see \eZ\Publish\API\Repository\LocationService::createLocation() |
||
132 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCreateLocation |
||
133 | */ |
||
134 | public function testCreateLocationStructValues(array $data) |
||
135 | { |
||
136 | $locationCreate = $data['locationCreate']; |
||
137 | $createdLocation = $data['createdLocation']; |
||
138 | $contentInfo = $data['contentInfo']; |
||
139 | |||
140 | $this->assertPropertiesCorrect( |
||
141 | array( |
||
142 | 'priority' => $locationCreate->priority, |
||
143 | 'hidden' => $locationCreate->hidden, |
||
144 | 'invisible' => $locationCreate->hidden, |
||
145 | 'remoteId' => $locationCreate->remoteId, |
||
146 | 'contentInfo' => $contentInfo, |
||
147 | 'parentLocationId' => $locationCreate->parentLocationId, |
||
148 | 'pathString' => '/1/5/' . $this->parseId('location', $createdLocation->id) . '/', |
||
149 | 'depth' => 2, |
||
150 | 'sortField' => $locationCreate->sortField, |
||
151 | 'sortOrder' => $locationCreate->sortOrder, |
||
152 | ), |
||
153 | $createdLocation |
||
154 | ); |
||
155 | |||
156 | $this->assertNotNull($createdLocation->id); |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * Test for the createLocation() method. |
||
161 | * |
||
162 | * @see \eZ\Publish\API\Repository\LocationService::createLocation() |
||
163 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
||
164 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
165 | */ |
||
166 | View Code Duplication | public function testCreateLocationThrowsInvalidArgumentExceptionContentAlreadyBelowParent() |
|
167 | { |
||
168 | $repository = $this->getRepository(); |
||
169 | |||
170 | $contentId = $this->generateId('object', 11); |
||
171 | $parentLocationId = $this->generateId('location', 5); |
||
172 | /* BEGIN: Use Case */ |
||
173 | // $contentId is the ID of an existing content object |
||
174 | // $parentLocationId is the ID of an existing location which already |
||
175 | // has the content assigned to one of its descendant locations |
||
176 | $contentService = $repository->getContentService(); |
||
177 | $locationService = $repository->getLocationService(); |
||
178 | |||
179 | // ContentInfo for "How to use eZ Publish" |
||
180 | $contentInfo = $contentService->loadContentInfo($contentId); |
||
181 | |||
182 | $locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
||
183 | |||
184 | // Throws exception, since content is already located at "/1/2/107/110/" |
||
185 | $locationService->createLocation( |
||
186 | $contentInfo, |
||
187 | $locationCreate |
||
188 | ); |
||
189 | /* END: Use Case */ |
||
190 | } |
||
191 | |||
192 | /** |
||
193 | * Test for the createLocation() method. |
||
194 | * |
||
195 | * @see \eZ\Publish\API\Repository\LocationService::createLocation() |
||
196 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
||
197 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
198 | */ |
||
199 | View Code Duplication | public function testCreateLocationThrowsInvalidArgumentExceptionParentIsSubLocationOfContent() |
|
200 | { |
||
201 | $repository = $this->getRepository(); |
||
202 | |||
203 | $contentId = $this->generateId('object', 4); |
||
204 | $parentLocationId = $this->generateId('location', 12); |
||
205 | /* BEGIN: Use Case */ |
||
206 | // $contentId is the ID of an existing content object |
||
207 | // $parentLocationId is the ID of an existing location which is below a |
||
208 | // location that is assigned to the content |
||
209 | $contentService = $repository->getContentService(); |
||
210 | $locationService = $repository->getLocationService(); |
||
211 | |||
212 | // ContentInfo for "How to use eZ Publish" |
||
213 | $contentInfo = $contentService->loadContentInfo($contentId); |
||
214 | |||
215 | $locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
||
216 | |||
217 | // Throws exception, since content is already located at "/1/2/" |
||
218 | $locationService->createLocation( |
||
219 | $contentInfo, |
||
220 | $locationCreate |
||
221 | ); |
||
222 | /* END: Use Case */ |
||
223 | } |
||
224 | |||
225 | /** |
||
226 | * Test for the createLocation() method. |
||
227 | * |
||
228 | * @see \eZ\Publish\API\Repository\LocationService::createLocation() |
||
229 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
||
230 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
231 | */ |
||
232 | View Code Duplication | public function testCreateLocationThrowsInvalidArgumentExceptionRemoteIdExists() |
|
233 | { |
||
234 | $repository = $this->getRepository(); |
||
235 | |||
236 | $contentId = $this->generateId('object', 41); |
||
237 | $parentLocationId = $this->generateId('location', 5); |
||
238 | /* BEGIN: Use Case */ |
||
239 | // $contentId is the ID of an existing content object |
||
240 | $contentService = $repository->getContentService(); |
||
241 | $locationService = $repository->getLocationService(); |
||
242 | |||
243 | // ContentInfo for "How to use eZ Publish" |
||
244 | $contentInfo = $contentService->loadContentInfo($contentId); |
||
245 | |||
246 | $locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
||
247 | // This remote ID already exists |
||
248 | $locationCreate->remoteId = 'f3e90596361e31d496d4026eb624c983'; |
||
249 | |||
250 | // Throws exception, since remote ID is already in use |
||
251 | $locationService->createLocation( |
||
252 | $contentInfo, |
||
253 | $locationCreate |
||
254 | ); |
||
255 | /* END: Use Case */ |
||
256 | } |
||
257 | |||
258 | /** |
||
259 | * Test for the createLocation() method. |
||
260 | * |
||
261 | * @see \eZ\Publish\API\Repository\LocationService::createLocation() |
||
262 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCreateLocation |
||
263 | */ |
||
264 | public function testCreateLocationInTransactionWithRollback() |
||
265 | { |
||
266 | $repository = $this->getRepository(); |
||
267 | |||
268 | $contentId = $this->generateId('object', 41); |
||
269 | $parentLocationId = $this->generateId('location', 5); |
||
270 | /* BEGIN: Use Case */ |
||
271 | // $contentId is the ID of an existing content object |
||
272 | // $parentLocationId is the ID of an existing location |
||
273 | $contentService = $repository->getContentService(); |
||
274 | $locationService = $repository->getLocationService(); |
||
275 | |||
276 | $repository->beginTransaction(); |
||
277 | |||
278 | try { |
||
279 | // ContentInfo for "How to use eZ Publish" |
||
280 | $contentInfo = $contentService->loadContentInfo($contentId); |
||
281 | |||
282 | $locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
||
283 | $locationCreate->remoteId = 'sindelfingen'; |
||
284 | |||
285 | $createdLocationId = $locationService->createLocation( |
||
286 | $contentInfo, |
||
287 | $locationCreate |
||
288 | )->id; |
||
289 | } catch (Exception $e) { |
||
290 | // Cleanup hanging transaction on error |
||
291 | $repository->rollback(); |
||
292 | throw $e; |
||
293 | } |
||
294 | |||
295 | $repository->rollback(); |
||
296 | |||
297 | try { |
||
298 | // Throws exception since creation of location was rolled back |
||
299 | $location = $locationService->loadLocation($createdLocationId); |
||
|
|||
300 | } catch (NotFoundException $e) { |
||
301 | return; |
||
302 | } |
||
303 | /* END: Use Case */ |
||
304 | |||
305 | $this->fail('Objects still exists after rollback.'); |
||
306 | } |
||
307 | |||
308 | /** |
||
309 | * Test for the loadLocation() method. |
||
310 | * |
||
311 | * @return \eZ\Publish\API\Repository\Values\Content\Location |
||
312 | * |
||
313 | * @see \eZ\Publish\API\Repository\LocationService::loadLocation() |
||
314 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCreateLocation |
||
315 | */ |
||
316 | View Code Duplication | public function testLoadLocation() |
|
317 | { |
||
318 | $repository = $this->getRepository(); |
||
319 | |||
320 | $locationId = $this->generateId('location', 5); |
||
321 | /* BEGIN: Use Case */ |
||
322 | // $locationId is the ID of an existing location |
||
323 | $locationService = $repository->getLocationService(); |
||
324 | |||
325 | $location = $locationService->loadLocation($locationId); |
||
326 | /* END: Use Case */ |
||
327 | |||
328 | $this->assertInstanceOf( |
||
329 | '\\eZ\\Publish\\API\\Repository\\Values\\Content\\Location', |
||
330 | $location |
||
331 | ); |
||
332 | |||
333 | return $location; |
||
334 | } |
||
335 | |||
336 | /** |
||
337 | * Test for the loadLocation() method. |
||
338 | * |
||
339 | * @see \eZ\Publish\API\Repository\LocationService::loadLocation() |
||
340 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
341 | */ |
||
342 | public function testLoadLocationRootStructValues() |
||
390 | |||
391 | /** |
||
392 | * Test for the loadLocation() method. |
||
393 | * |
||
394 | * @param \eZ\Publish\API\Repository\Values\Content\Location $location |
||
395 | * |
||
396 | * @see \eZ\Publish\API\Repository\LocationService::loadLocation() |
||
397 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
398 | */ |
||
399 | public function testLoadLocationStructValues(Location $location) |
||
423 | |||
424 | /** |
||
425 | * Test for the loadLocation() method. |
||
426 | * |
||
427 | * @see \eZ\Publish\API\Repository\LocationService::loadLocation() |
||
428 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCreateLocation |
||
429 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
430 | */ |
||
431 | public function testLoadLocationThrowsNotFoundException() |
||
444 | |||
445 | /** |
||
446 | * Test for the loadLocationByRemoteId() method. |
||
447 | * |
||
448 | * @see \eZ\Publish\API\Repository\LocationService::loadLocationByRemoteId() |
||
449 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
450 | */ |
||
451 | public function testLoadLocationByRemoteId() |
||
468 | |||
469 | /** |
||
470 | * Test for the loadLocationByRemoteId() method. |
||
471 | * |
||
472 | * @see \eZ\Publish\API\Repository\LocationService::loadLocationByRemoteId() |
||
473 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
474 | * @expectedException \eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
475 | */ |
||
476 | public function testLoadLocationByRemoteIdThrowsNotFoundException() |
||
489 | |||
490 | /** |
||
491 | * Test for the loadLocations() method. |
||
492 | * |
||
493 | * @see \eZ\Publish\API\Repository\LocationService::loadLocations() |
||
494 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCreateLocation |
||
495 | */ |
||
496 | public function testLoadLocations() |
||
515 | |||
516 | /** |
||
517 | * Test for the loadLocations() method. |
||
518 | * |
||
519 | * @see \eZ\Publish\API\Repository\LocationService::loadLocations() |
||
520 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
||
521 | */ |
||
522 | public function testLoadLocationsContent(array $locations) |
||
552 | |||
553 | /** |
||
554 | * Test for the loadLocations() method. |
||
555 | * |
||
556 | * @return \eZ\Publish\API\Repository\Values\Content\Location[] |
||
557 | * |
||
558 | * @see \eZ\Publish\API\Repository\LocationService::loadLocations($contentInfo, $rootLocation) |
||
559 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
||
560 | */ |
||
561 | public function testLoadLocationsLimitedSubtree() |
||
599 | |||
600 | /** |
||
601 | * Test for the loadLocations() method. |
||
602 | * |
||
603 | * @param \eZ\Publish\API\Repository\Values\Content\Location[] $locations |
||
604 | * |
||
605 | * @see \eZ\Publish\API\Repository\LocationService::loadLocations() |
||
606 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationsLimitedSubtree |
||
607 | */ |
||
608 | public function testLoadLocationsLimitedSubtreeContent(array $locations) |
||
617 | |||
618 | /** |
||
619 | * Test for the loadLocations() method. |
||
620 | * |
||
621 | * @see \eZ\Publish\API\Repository\LocationService::loadLocations() |
||
622 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
||
623 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
||
624 | */ |
||
625 | public function testLoadLocationsThrowsBadStateException() |
||
646 | |||
647 | /** |
||
648 | * Test for the loadLocations() method. |
||
649 | * |
||
650 | * @see \eZ\Publish\API\Repository\LocationService::loadLocations($contentInfo, $rootLocation) |
||
651 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocations |
||
652 | * @expectedException \eZ\Publish\API\Repository\Exceptions\BadStateException |
||
653 | */ |
||
654 | public function testLoadLocationsThrowsBadStateExceptionLimitedSubtree() |
||
680 | |||
681 | /** |
||
682 | * Test for the loadLocationChildren() method. |
||
683 | * |
||
684 | * @see \eZ\Publish\API\Repository\LocationService::loadLocationChildren() |
||
685 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
686 | */ |
||
687 | View Code Duplication | public function testLoadLocationChildren() |
|
707 | |||
708 | /** |
||
709 | * Test for the getLocationChildCount() method. |
||
710 | * |
||
711 | * @see \eZ\Publish\API\Repository\LocationService::getLocationChildCount() |
||
712 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
713 | */ |
||
714 | public function testGetLocationChildCount() |
||
726 | |||
727 | /** |
||
728 | * Test for the loadLocationChildren() method. |
||
729 | * |
||
730 | * @see \eZ\Publish\API\Repository\LocationService::loadLocationChildren() |
||
731 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationChildren |
||
732 | */ |
||
733 | public function testLoadLocationChildrenData(LocationList $locations) |
||
761 | |||
762 | /** |
||
763 | * Test for the loadLocationChildren() method. |
||
764 | * |
||
765 | * @return \eZ\Publish\API\Repository\Values\Content\Location[] |
||
766 | * |
||
767 | * @see \eZ\Publish\API\Repository\LocationService::loadLocationChildren($location, $offset) |
||
768 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationChildren |
||
769 | */ |
||
770 | View Code Duplication | public function testLoadLocationChildrenWithOffset() |
|
790 | |||
791 | /** |
||
792 | * Test for the loadLocationChildren() method. |
||
793 | * |
||
794 | * @param \eZ\Publish\API\Repository\Values\Content\LocationList $locations |
||
795 | * |
||
796 | * @see \eZ\Publish\API\Repository\LocationService::loadLocationChildren($location, $offset) |
||
797 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationChildrenWithOffset |
||
798 | */ |
||
799 | View Code Duplication | public function testLoadLocationChildrenDataWithOffset(LocationList $locations) |
|
825 | |||
826 | /** |
||
827 | * Test for the loadLocationChildren() method. |
||
828 | * |
||
829 | * @return \eZ\Publish\API\Repository\Values\Content\Location[] |
||
830 | * |
||
831 | * @see \eZ\Publish\API\Repository\LocationService::loadLocationChildren($location, $offset, $limit) |
||
832 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationChildren |
||
833 | */ |
||
834 | View Code Duplication | public function testLoadLocationChildrenWithOffsetAndLimit() |
|
854 | |||
855 | /** |
||
856 | * Test for the loadLocationChildren() method. |
||
857 | * |
||
858 | * @param \eZ\Publish\API\Repository\Values\Content\Location[] $locations |
||
859 | * |
||
860 | * @see \eZ\Publish\API\Repository\LocationService::loadLocationChildren($location, $offset, $limit) |
||
861 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocationChildrenWithOffsetAndLimit |
||
862 | */ |
||
863 | View Code Duplication | public function testLoadLocationChildrenDataWithOffsetAndLimit(LocationList $locations) |
|
888 | |||
889 | /** |
||
890 | * Test for the newLocationUpdateStruct() method. |
||
891 | * |
||
892 | * @see \eZ\Publish\API\Repository\LocationService::newLocationUpdateStruct() |
||
893 | */ |
||
894 | public function testNewLocationUpdateStruct() |
||
909 | |||
910 | /** |
||
911 | * Test for the updateLocation() method. |
||
912 | * |
||
913 | * @see \eZ\Publish\API\Repository\LocationService::updateLocation() |
||
914 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
915 | */ |
||
916 | public function testUpdateLocation() |
||
947 | |||
948 | /** |
||
949 | * Test for the updateLocation() method. |
||
950 | * |
||
951 | * @see \eZ\Publish\API\Repository\LocationService::updateLocation() |
||
952 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testUpdateLocation |
||
953 | */ |
||
954 | public function testUpdateLocationStructValues(array $data) |
||
977 | |||
978 | /** |
||
979 | * Test for the updateLocation() method. |
||
980 | * |
||
981 | * @see \eZ\Publish\API\Repository\LocationService::updateLocation() |
||
982 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
983 | */ |
||
984 | public function testUpdateLocationWithSameRemoteId() |
||
1012 | |||
1013 | /** |
||
1014 | * Test for the updateLocation() method. |
||
1015 | * |
||
1016 | * @see \eZ\Publish\API\Repository\LocationService::updateLocation() |
||
1017 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
1018 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
1019 | */ |
||
1020 | public function testUpdateLocationThrowsInvalidArgumentException() |
||
1040 | |||
1041 | /** |
||
1042 | * Test for the updateLocation() method. |
||
1043 | * Ref EZP-23302: Update Location fails if no change is performed with the update. |
||
1044 | * |
||
1045 | * @see \eZ\Publish\API\Repository\LocationService::updateLocation() |
||
1046 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
1047 | */ |
||
1048 | public function testUpdateLocationTwice() |
||
1071 | |||
1072 | /** |
||
1073 | * Test for the swapLocation() method. |
||
1074 | * |
||
1075 | * @see \eZ\Publish\API\Repository\LocationService::swapLocation() |
||
1076 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
1077 | */ |
||
1078 | public function testSwapLocation() |
||
1115 | |||
1116 | /** |
||
1117 | * Test for the hideLocation() method. |
||
1118 | * |
||
1119 | * @see \eZ\Publish\API\Repository\LocationService::hideLocation() |
||
1120 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
1121 | */ |
||
1122 | public function testHideLocation() |
||
1158 | |||
1159 | /** |
||
1160 | * Assert that $expectedValues are set in the subtree starting at $location. |
||
1161 | * |
||
1162 | * @param array $expectedValues |
||
1163 | * @param Location $location |
||
1164 | */ |
||
1165 | protected function assertSubtreeProperties(array $expectedValues, Location $location, $stopId = null) |
||
1185 | |||
1186 | /** |
||
1187 | * Test for the unhideLocation() method. |
||
1188 | * |
||
1189 | * @see \eZ\Publish\API\Repository\LocationService::unhideLocation() |
||
1190 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testHideLocation |
||
1191 | */ |
||
1192 | public function testUnhideLocation() |
||
1229 | |||
1230 | /** |
||
1231 | * Test for the unhideLocation() method. |
||
1232 | * |
||
1233 | * @see \eZ\Publish\API\Repository\LocationService::unhideLocation() |
||
1234 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testUnhideLocation |
||
1235 | */ |
||
1236 | public function testUnhideLocationNotUnhidesHiddenSubtree() |
||
1294 | |||
1295 | /** |
||
1296 | * Test for the deleteLocation() method. |
||
1297 | * |
||
1298 | * @see \eZ\Publish\API\Repository\LocationService::deleteLocation() |
||
1299 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
1300 | */ |
||
1301 | public function testDeleteLocation() |
||
1343 | |||
1344 | /** |
||
1345 | * Test for the deleteLocation() method. |
||
1346 | * |
||
1347 | * @see \eZ\Publish\API\Repository\LocationService::deleteLocation() |
||
1348 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testDeleteLocation |
||
1349 | */ |
||
1350 | public function testDeleteLocationDecrementsChildCountOnParent() |
||
1388 | |||
1389 | /** |
||
1390 | * Test for the deleteLocation() method. |
||
1391 | * |
||
1392 | * Related issue: EZP-21904 |
||
1393 | * |
||
1394 | * @see \eZ\Publish\API\Repository\LocationService::deleteLocation() |
||
1395 | * @expectedException eZ\Publish\API\Repository\Exceptions\NotFoundException |
||
1396 | */ |
||
1397 | public function testDeleteContentObjectLastLocation() |
||
1433 | |||
1434 | /** |
||
1435 | * Test for the copySubtree() method. |
||
1436 | * |
||
1437 | * @see \eZ\Publish\API\Repository\LocationService::copySubtree() |
||
1438 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
1439 | */ |
||
1440 | public function testCopySubtree() |
||
1485 | |||
1486 | /** |
||
1487 | * Test for the copySubtree() method. |
||
1488 | * |
||
1489 | * @see \eZ\Publish\API\Repository\LocationService::copySubtree() |
||
1490 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
1491 | */ |
||
1492 | public function testCopySubtreeWithAliases() |
||
1525 | |||
1526 | /** |
||
1527 | * Asserts that given Content has default ContentStates. |
||
1528 | * |
||
1529 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
1530 | */ |
||
1531 | View Code Duplication | private function assertDefaultContentStates(ContentInfo $contentInfo) |
|
1550 | |||
1551 | /** |
||
1552 | * Test for the copySubtree() method. |
||
1553 | * |
||
1554 | * @see \eZ\Publish\API\Repository\LocationService::copySubtree() |
||
1555 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCopySubtree |
||
1556 | */ |
||
1557 | public function testCopySubtreeUpdatesSubtreeProperties() |
||
1616 | |||
1617 | /** |
||
1618 | * Test for the copySubtree() method. |
||
1619 | * |
||
1620 | * @see \eZ\Publish\API\Repository\LocationService::copySubtree() |
||
1621 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCopySubtree |
||
1622 | */ |
||
1623 | public function testCopySubtreeIncrementsChildCountOfNewParent() |
||
1661 | |||
1662 | /** |
||
1663 | * Test for the copySubtree() method. |
||
1664 | * |
||
1665 | * @see \eZ\Publish\API\Repository\LocationService::copySubtree() |
||
1666 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
1667 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCopySubtree |
||
1668 | */ |
||
1669 | public function testCopySubtreeThrowsInvalidArgumentException() |
||
1696 | |||
1697 | /** |
||
1698 | * Test for the moveSubtree() method. |
||
1699 | * |
||
1700 | * @see \eZ\Publish\API\Repository\LocationService::moveSubtree() |
||
1701 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
||
1702 | */ |
||
1703 | public function testMoveSubtree() |
||
1746 | |||
1747 | /** |
||
1748 | * Test for the moveSubtree() method. |
||
1749 | * |
||
1750 | * @see \eZ\Publish\API\Repository\LocationService::moveSubtree() |
||
1751 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
||
1752 | */ |
||
1753 | public function testMoveSubtreeHidden() |
||
1799 | |||
1800 | /** |
||
1801 | * Test for the moveSubtree() method. |
||
1802 | * |
||
1803 | * @see \eZ\Publish\API\Repository\LocationService::moveSubtree() |
||
1804 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
||
1805 | */ |
||
1806 | public function testMoveSubtreeUpdatesSubtreeProperties() |
||
1860 | |||
1861 | /** |
||
1862 | * Test for the moveSubtree() method. |
||
1863 | * |
||
1864 | * @see \eZ\Publish\API\Repository\LocationService::moveSubtree() |
||
1865 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtreeUpdatesSubtreeProperties |
||
1866 | */ |
||
1867 | public function testMoveSubtreeUpdatesSubtreePropertiesHidden() |
||
1925 | |||
1926 | /** |
||
1927 | * Test for the moveSubtree() method. |
||
1928 | * |
||
1929 | * @see \eZ\Publish\API\Repository\LocationService::moveSubtree() |
||
1930 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
||
1931 | */ |
||
1932 | View Code Duplication | public function testMoveSubtreeIncrementsChildCountOfNewParent() |
|
1983 | |||
1984 | /** |
||
1985 | * Test for the moveSubtree() method. |
||
1986 | * |
||
1987 | * @see \eZ\Publish\API\Repository\LocationService::moveSubtree() |
||
1988 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
||
1989 | */ |
||
1990 | View Code Duplication | public function testMoveSubtreeDecrementsChildCountOfOldParent() |
|
2041 | |||
2042 | /** |
||
2043 | * Test for the moveSubtree() method. |
||
2044 | * |
||
2045 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
||
2046 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
||
2047 | */ |
||
2048 | public function testMoveSubtreeThrowsInvalidArgumentException() |
||
2077 | |||
2078 | /** |
||
2079 | * Loads properties from all locations in the $location's subtree. |
||
2080 | * |
||
2081 | * @param \eZ\Publish\API\Repository\Values\Content\Location $location |
||
2082 | * @param array $properties |
||
2083 | * |
||
2084 | * @return array |
||
2085 | */ |
||
2086 | private function loadSubtreeProperties(Location $location, array $properties = array()) |
||
2098 | |||
2099 | /** |
||
2100 | * Loads assertable properties from the given location. |
||
2101 | * |
||
2102 | * @param \eZ\Publish\API\Repository\Values\Content\Location $location |
||
2103 | * @param mixed[] $overwrite |
||
2104 | * |
||
2105 | * @return array |
||
2106 | */ |
||
2107 | private function loadLocationProperties(Location $location, array $overwrite = array()) |
||
2125 | |||
2126 | /** |
||
2127 | * Assert generated aliases to expected alias return. |
||
2128 | * |
||
2129 | * @param \eZ\Publish\API\Repository\URLAliasService $urlAliasService |
||
2130 | * @param array $expectedAliases |
||
2131 | */ |
||
2132 | protected function assertGeneratedAliases($urlAliasService, array $expectedAliases) |
||
2139 | |||
2140 | /** |
||
2141 | * @param \eZ\Publish\API\Repository\URLAliasService $urlAliasService |
||
2142 | * @param array $expectedSubItemAliases |
||
2143 | */ |
||
2144 | private function assertAliasesBeforeCopy($urlAliasService, array $expectedSubItemAliases) |
||
2155 | } |
||
2156 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.