Complex classes like FinancialTest 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 FinancialTest, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
8 | class FinancialTest extends \PHPUnit_Framework_TestCase |
||
9 | { |
||
10 | public function setUp() |
||
14 | |||
15 | /** |
||
16 | * @dataProvider providerACCRINT |
||
17 | * @group fail19 |
||
18 | */ |
||
19 | public function testACCRINT() |
||
26 | |||
27 | public function providerACCRINT() |
||
31 | |||
32 | /** |
||
33 | * @dataProvider providerACCRINTM |
||
34 | */ |
||
35 | public function testACCRINTM() |
||
42 | |||
43 | public function providerACCRINTM() |
||
47 | |||
48 | /** |
||
49 | * @dataProvider providerAMORDEGRC |
||
50 | */ |
||
51 | public function testAMORDEGRC() |
||
58 | |||
59 | public function providerAMORDEGRC() |
||
63 | |||
64 | /** |
||
65 | * @dataProvider providerAMORLINC |
||
66 | */ |
||
67 | public function testAMORLINC() |
||
74 | |||
75 | public function providerAMORLINC() |
||
79 | |||
80 | /** |
||
81 | * @dataProvider providerCOUPDAYBS |
||
82 | */ |
||
83 | public function testCOUPDAYBS() |
||
90 | |||
91 | public function providerCOUPDAYBS() |
||
95 | |||
96 | /** |
||
97 | * @dataProvider providerCOUPDAYS |
||
98 | */ |
||
99 | public function testCOUPDAYS() |
||
106 | |||
107 | public function providerCOUPDAYS() |
||
111 | |||
112 | /** |
||
113 | * @dataProvider providerCOUPDAYSNC |
||
114 | */ |
||
115 | public function testCOUPDAYSNC() |
||
122 | |||
123 | public function providerCOUPDAYSNC() |
||
127 | |||
128 | /** |
||
129 | * @dataProvider providerCOUPNCD |
||
130 | */ |
||
131 | public function testCOUPNCD() |
||
138 | |||
139 | public function providerCOUPNCD() |
||
143 | |||
144 | /** |
||
145 | * @dataProvider providerCOUPNUM |
||
146 | */ |
||
147 | public function testCOUPNUM() |
||
154 | |||
155 | public function providerCOUPNUM() |
||
159 | |||
160 | /** |
||
161 | * @dataProvider providerCOUPPCD |
||
162 | */ |
||
163 | public function testCOUPPCD() |
||
170 | |||
171 | public function providerCOUPPCD() |
||
175 | |||
176 | /** |
||
177 | * @dataProvider providerCUMIPMT |
||
178 | */ |
||
179 | public function testCUMIPMT() |
||
186 | |||
187 | public function providerCUMIPMT() |
||
191 | |||
192 | /** |
||
193 | * @dataProvider providerCUMPRINC |
||
194 | */ |
||
195 | public function testCUMPRINC() |
||
202 | |||
203 | public function providerCUMPRINC() |
||
207 | |||
208 | /** |
||
209 | * @dataProvider providerDB |
||
210 | */ |
||
211 | public function testDB() |
||
218 | |||
219 | public function providerDB() |
||
223 | |||
224 | /** |
||
225 | * @dataProvider providerDDB |
||
226 | */ |
||
227 | public function testDDB() |
||
234 | |||
235 | public function providerDDB() |
||
239 | |||
240 | /** |
||
241 | * @dataProvider providerDISC |
||
242 | */ |
||
243 | public function testDISC() |
||
250 | |||
251 | public function providerDISC() |
||
255 | |||
256 | /** |
||
257 | * @dataProvider providerDOLLARDE |
||
258 | */ |
||
259 | public function testDOLLARDE() |
||
266 | |||
267 | public function providerDOLLARDE() |
||
271 | |||
272 | /** |
||
273 | * @dataProvider providerDOLLARFR |
||
274 | */ |
||
275 | public function testDOLLARFR() |
||
282 | |||
283 | public function providerDOLLARFR() |
||
287 | |||
288 | /** |
||
289 | * @dataProvider providerEFFECT |
||
290 | */ |
||
291 | public function testEFFECT() |
||
298 | |||
299 | public function providerEFFECT() |
||
303 | |||
304 | /** |
||
305 | * @dataProvider providerFV |
||
306 | */ |
||
307 | public function testFV() |
||
314 | |||
315 | public function providerFV() |
||
319 | |||
320 | /** |
||
321 | * @dataProvider providerFVSCHEDULE |
||
322 | */ |
||
323 | public function testFVSCHEDULE() |
||
330 | |||
331 | public function providerFVSCHEDULE() |
||
335 | |||
336 | /** |
||
337 | * @dataProvider providerINTRATE |
||
338 | */ |
||
339 | public function testINTRATE() |
||
346 | |||
347 | public function providerINTRATE() |
||
351 | |||
352 | /** |
||
353 | * @dataProvider providerIPMT |
||
354 | */ |
||
355 | public function testIPMT() |
||
362 | |||
363 | public function providerIPMT() |
||
367 | |||
368 | /** |
||
369 | * @dataProvider providerIRR |
||
370 | */ |
||
371 | public function testIRR() |
||
378 | |||
379 | public function providerIRR() |
||
383 | |||
384 | /** |
||
385 | * @dataProvider providerISPMT |
||
386 | */ |
||
387 | public function testISPMT() |
||
394 | |||
395 | public function providerISPMT() |
||
399 | |||
400 | /** |
||
401 | * @dataProvider providerMIRR |
||
402 | */ |
||
403 | public function testMIRR() |
||
410 | |||
411 | public function providerMIRR() |
||
415 | |||
416 | /** |
||
417 | * @dataProvider providerNOMINAL |
||
418 | */ |
||
419 | public function testNOMINAL() |
||
426 | |||
427 | public function providerNOMINAL() |
||
431 | |||
432 | /** |
||
433 | * @dataProvider providerNPER |
||
434 | */ |
||
435 | public function testNPER() |
||
442 | |||
443 | public function providerNPER() |
||
447 | |||
448 | /** |
||
449 | * @dataProvider providerNPV |
||
450 | */ |
||
451 | public function testNPV() |
||
458 | |||
459 | public function providerNPV() |
||
463 | |||
464 | /** |
||
465 | * @dataProvider providerPRICE |
||
466 | * @group fail19 |
||
467 | */ |
||
468 | public function testPRICE() |
||
477 | |||
478 | public function providerPRICE() |
||
482 | |||
483 | /** |
||
484 | * @dataProvider providerRATE |
||
485 | * @group fail19 |
||
486 | */ |
||
487 | public function testRATE() |
||
496 | |||
497 | public function providerRATE() |
||
501 | |||
502 | /** |
||
503 | * @dataProvider providerXIRR |
||
504 | * @group fail19 |
||
505 | */ |
||
506 | public function testXIRR() |
||
515 | |||
516 | public function providerXIRR() |
||
520 | } |
||
521 |