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 |
||
| 21 | View Code Duplication | class ValidateTest4IsLeapYear extends \PHPUnit_Framework_TestCase |
|
| 22 | { |
||
| 23 | //------------------------------------------------------// |
||
| 24 | // テストメソッド定義 |
||
| 25 | //------------------------------------------------------// |
||
| 26 | /** |
||
| 27 | * setUp() |
||
| 28 | * |
||
| 29 | * テストに必要な準備を実施 |
||
| 30 | */ |
||
| 31 | protected function setUp() |
||
| 34 | |||
| 35 | /** |
||
| 36 | * test_IsLeapYear_InvalidArgPart1() |
||
| 37 | * |
||
| 38 | * isLeapYear()の挙動をテストする(数字2桁) |
||
| 39 | */ |
||
| 40 | public function test_IsLeapYear_InvalidArgPart1() |
||
| 46 | |||
| 47 | /** |
||
| 48 | * test_IsLeapYear_InvalidArgPart2() |
||
| 49 | * |
||
| 50 | * isLeapYear()の挙動をテストする(英字4桁) |
||
| 51 | */ |
||
| 52 | public function test_IsLeapYear_InvalidArgPart2() |
||
| 58 | |||
| 59 | /** |
||
| 60 | * test_IsLeapYear_ValidArgPart1() |
||
| 61 | * |
||
| 62 | * isLeapYear()の挙動をテストする(閏年である) |
||
| 63 | */ |
||
| 64 | public function test_IsLeapYear_ValidArgPart1() |
||
| 70 | |||
| 71 | /** |
||
| 72 | * test_IsLeapYear_ValidArgPart2() |
||
| 73 | * |
||
| 74 | * isLeapYear()の挙動をテストする(閏年でない) |
||
| 75 | */ |
||
| 76 | public function test_IsLeapYear_ValidArgPart2() |
||
| 82 | } |