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 |
||
| 7 | class OrderEditPage extends AbstractAdminPageStyleGuide |
||
|
|
|||
| 8 | { |
||
| 9 | |||
| 10 | public static $姓_エラーメッセージ = '#ordererInfo > div > div > div:nth-child(1) > div:nth-child(2) > div > div > div:nth-child(1) > span'; |
||
| 11 | |||
| 12 | public static $登録完了メッセージ = 'div.c-container > div.c-contentsArea > div.alert.alert-success.alert-dismissible.fade.show.m-3 > span'; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * OrderRegisterPage constructor. |
||
| 16 | */ |
||
| 17 | public function __construct(\AcceptanceTester $I) |
||
| 21 | |||
| 22 | public static function go($I) |
||
| 28 | |||
| 29 | public static function at($I) |
||
| 35 | |||
| 36 | public function 入力_受注ステータス($value) |
||
| 41 | |||
| 42 | public function 入力_姓($value) |
||
| 47 | |||
| 48 | public function 入力_名($value) |
||
| 53 | |||
| 54 | public function 入力_セイ($value) |
||
| 59 | |||
| 60 | public function 入力_メイ($value) |
||
| 65 | |||
| 66 | public function 入力_郵便番号($value) |
||
| 72 | |||
| 73 | public function 入力_都道府県($value) |
||
| 78 | |||
| 79 | public function 入力_市区町村名($value) |
||
| 84 | |||
| 85 | public function 入力_番地_ビル名($value) |
||
| 90 | |||
| 91 | public function 入力_電話番号($value) |
||
| 97 | |||
| 98 | public function 入力_Eメール($value) |
||
| 103 | |||
| 104 | public function 入力_支払方法($value) |
||
| 109 | |||
| 110 | public function 入力_配送業者($value) |
||
| 115 | |||
| 116 | public function 注文者情報をコピー() |
||
| 121 | |||
| 122 | public function 注文者パネルを開く() |
||
| 128 | |||
| 129 | View Code Duplication | public function 商品検索($value = '') |
|
| 141 | |||
| 142 | public function 商品検索結果_選択($rowNum) |
||
| 148 | |||
| 149 | public function 受注情報登録() |
||
| 155 | |||
| 156 | public function 明細の項目名を取得($row) |
||
| 160 | |||
| 161 | View Code Duplication | public function 明細を削除($row) |
|
| 162 | { |
||
| 163 | $this->tester->scrollTo(['css' => '#order-product']); |
||
| 164 | $this->tester->click("#table-form-field > tbody > tr:nth-child({$row}) > td.align-middle.text-right.pr-3 > div > div > a"); |
||
| 165 | $this->tester->waitForElementVisible("#table-form-field > tbody > tr:nth-child({$row}) > td.align-middle.text-right.pr-3 > div > div > div.modal"); |
||
| 166 | return $this; |
||
| 167 | } |
||
| 168 | |||
| 169 | public function acceptDeleteModal($row) |
||
| 174 | |||
| 175 | View Code Duplication | public function お届け先の追加() |
|
| 182 | } |
||
| 183 |