Complex classes like SubTest 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 SubTest, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 17 | class SubTest extends AbstractTestCase |
||
| 18 | { |
||
| 19 | public function testSubYearsPositive() |
||
| 23 | |||
| 24 | public function testSubYearsZero() |
||
| 28 | |||
| 29 | public function testSubYearsNegative() |
||
| 33 | |||
| 34 | public function testSubYear() |
||
| 38 | |||
| 39 | public function testSubMonthsPositive() |
||
| 43 | |||
| 44 | public function testSubMonthsZero() |
||
| 48 | |||
| 49 | public function testSubMonthsNegative() |
||
| 53 | |||
| 54 | public function testSubMonth() |
||
| 58 | |||
| 59 | public function testSubDaysPositive() |
||
| 63 | |||
| 64 | public function testSubDaysZero() |
||
| 68 | |||
| 69 | public function testSubDaysNegative() |
||
| 73 | |||
| 74 | public function testSubDay() |
||
| 78 | |||
| 79 | public function testSubWeekdaysPositive() |
||
| 83 | |||
| 84 | public function testSubWeekdaysZero() |
||
| 88 | |||
| 89 | public function testSubWeekdaysNegative() |
||
| 93 | |||
| 94 | public function testSubWeekday() |
||
| 98 | |||
| 99 | public function testSubWeekdayDuringWeekend() |
||
| 103 | |||
| 104 | public function testSubWeeksPositive() |
||
| 108 | |||
| 109 | public function testSubWeeksZero() |
||
| 113 | |||
| 114 | public function testSubWeeksNegative() |
||
| 118 | |||
| 119 | public function testSubWeek() |
||
| 123 | |||
| 124 | public function testSubHoursPositive() |
||
| 128 | |||
| 129 | public function testSubHoursZero() |
||
| 133 | |||
| 134 | public function testSubHoursNegative() |
||
| 138 | |||
| 139 | public function testSubHour() |
||
| 143 | |||
| 144 | public function testSubMinutesPositive() |
||
| 148 | |||
| 149 | public function testSubMinutesZero() |
||
| 153 | |||
| 154 | public function testSubMinutesNegative() |
||
| 158 | |||
| 159 | public function testSubMinute() |
||
| 163 | |||
| 164 | public function testSubSecondsPositive() |
||
| 168 | |||
| 169 | public function testSubSecondsZero() |
||
| 173 | |||
| 174 | public function testSubSecondsNegative() |
||
| 178 | |||
| 179 | public function testSubSecond() |
||
| 183 | |||
| 184 | /***** Test non plural methods with non default args *****/ |
||
| 185 | |||
| 186 | public function testSubYearPassingArg() |
||
| 190 | |||
| 191 | public function testSubMonthPassingArg() |
||
| 195 | |||
| 196 | public function testSubMonthNoOverflowPassingArg() |
||
| 202 | |||
| 203 | public function testSubDayPassingArg() |
||
| 207 | |||
| 208 | public function testSubHourPassingArg() |
||
| 212 | |||
| 213 | public function testSubMinutePassingArg() |
||
| 217 | |||
| 218 | public function testSubSecondPassingArg() |
||
| 222 | } |
||
| 223 |