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 |
||
3 | class DMSDocumentCartCheckoutPageTest extends FunctionalTest |
||
|
|||
4 | { |
||
5 | protected static $fixture_file = 'DMSDocumentCartTest.yml'; |
||
6 | /** |
||
7 | * @var DMSDocumentCartCheckoutPage_Controller |
||
8 | */ |
||
9 | protected $controller; |
||
10 | |||
11 | /** |
||
12 | * @var DMSDocumentCart |
||
13 | */ |
||
14 | protected $cart; |
||
15 | |||
16 | /** |
||
17 | * @var DMSDocumentCartCheckoutPage |
||
18 | */ |
||
19 | protected $page; |
||
20 | |||
21 | public function setUp() |
||
30 | |||
31 | /** |
||
32 | * Tests DMSDocumentRequest form has a FieldList |
||
33 | */ |
||
34 | public function testDMSDocumentRequestForm() |
||
39 | |||
40 | /** |
||
41 | * Tests if the DMSDocumentRequestForm is extensible |
||
42 | */ |
||
43 | public function testDMSDocumentRequestFormIsExtensible() |
||
52 | |||
53 | /** |
||
54 | * Tests if print requests are incremented |
||
55 | */ |
||
56 | View Code Duplication | public function testTrackTimestampedPrintRequest() |
|
66 | |||
67 | /** |
||
68 | * Tests if a Cart is received |
||
69 | */ |
||
70 | public function testGetCart() |
||
74 | |||
75 | /** |
||
76 | * Tests whether the cart items are updated from the controller |
||
77 | */ |
||
78 | public function testUpdateCartItems() |
||
90 | |||
91 | /** |
||
92 | * Tests whether the recipient details are updated from the controller |
||
93 | */ |
||
94 | public function testUpdateCartReceiverInfo() |
||
108 | |||
109 | /** |
||
110 | * Tests whether emails are sent. Emails are mocked so not actually sent. |
||
111 | */ |
||
112 | public function testSend() |
||
131 | |||
132 | /** |
||
133 | * Tests whether email sending is extensible. |
||
134 | */ |
||
135 | public function testSendIsExtensible() |
||
140 | |||
141 | /** |
||
142 | * Test to see whether the cart is empty after a request is sent. |
||
143 | */ |
||
144 | public function testDoRequestSend() |
||
169 | } |
||
170 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.