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 ShippingEditPage extends AbstractAdminPageStyleGuide |
||
|
|
|||
| 8 | { |
||
| 9 | |||
| 10 | public static $姓_エラーメッセージ = '#shippingerInfo > div > div:nth-child(2) > div.col > span > ul > p'; |
||
| 11 | |||
| 12 | public static $登録完了メッセージ = '#page_admin_shipping_edit > div > div.c-contentsArea > div.alert.alert-success.alert-dismissible.fade.show.m-3 > span'; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * ShippingRegisterPage 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) |
||
| 37 | { |
||
| 38 | $this->tester->executeJS("document.getElementById('shipping_shipping_date').value = '{$value}'"); |
||
| 39 | return $this; |
||
| 40 | } |
||
| 41 | |||
| 42 | public function お届け先編集() |
||
| 48 | |||
| 49 | public function 入力_姓($value) |
||
| 54 | |||
| 55 | public function 入力_名($value) |
||
| 60 | |||
| 61 | public function 入力_セイ($value) |
||
| 66 | |||
| 67 | public function 入力_メイ($value) |
||
| 72 | |||
| 73 | public function 入力_郵便番号($value) |
||
| 79 | |||
| 80 | public function 入力_都道府県($value) |
||
| 85 | |||
| 86 | public function 入力_市区町村名($value) |
||
| 91 | |||
| 92 | public function 入力_番地_ビル名($value) |
||
| 97 | |||
| 98 | public function 入力_電話番号($value) |
||
| 104 | |||
| 105 | public function 入力_出荷伝票番号($value) |
||
| 110 | |||
| 111 | public function 入力_配送業者($value) |
||
| 116 | |||
| 117 | public function 入力_配達用メモ($value) |
||
| 122 | |||
| 123 | View Code Duplication | public function 商品検索($value = '') |
|
| 124 | { |
||
| 125 | $this->tester->click(['xpath' => '//*[@id="shipmentItem"]/div/div/div/button']); |
||
| 126 | $this->tester->waitForElementVisible(['id' => 'addProduct']); |
||
| 127 | $this->tester->click(['id' => 'searchItemsButton']); |
||
| 128 | return $this; |
||
| 129 | } |
||
| 130 | |||
| 131 | public function 商品検索結果_選択($rowNum) |
||
| 138 | |||
| 139 | public function 出荷情報登録() |
||
| 144 | |||
| 145 | public function 変更を確定() |
||
| 151 | } |
||
| 152 |