Failed Conditions
Pull Request — experimental/sf (#3236)
by Kentaro
142:37 queued 134:37
created

OrderEditPage   A

Complexity

Total Complexity 24

Size/Duplication

Total Lines 168
Duplicated Lines 7.14 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 12
loc 168
rs 10
c 0
b 0
f 0
wmc 24
lcom 1
cbo 1

How to fix   Duplicated Code   

Duplicated Code

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
2
3
4
namespace Page\Admin;
5
6
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)
18
    {
19
        parent::__construct($I);
20
    }
21
22
    public static function go($I)
23
    {
24
        $page = new self($I);
25
        $page->goPage('/order/new', '受注登録受注管理');
26
        return $page;
27
    }
28
29
    public static function at($I)
30
    {
31
        $page = new self($I);
32
        $page->atPage('受注登録受注管理');
33
        return $page;
34
    }
35
36
    public function 入力_受注ステータス($value)
37
    {
38
        $this->tester->selectOption(['id' => 'order_OrderStatus'], $value);
39
        return $this;
40
    }
41
42
    public function 入力_姓($value)
43
    {
44
        $this->tester->fillField(['id' => 'order_name_name01'], $value);
45
        return $this;
46
    }
47
48
    public function 入力_名($value)
49
    {
50
        $this->tester->fillField(['id' => 'order_name_name02'], $value);
51
        return $this;
52
    }
53
54
    public function 入力_セイ($value)
55
    {
56
        $this->tester->fillField(['id' => 'order_kana_kana01'], $value);
57
        return $this;
58
    }
59
60
    public function 入力_メイ($value)
61
    {
62
        $this->tester->fillField(['id' => 'order_kana_kana02'], $value);
63
        return $this;
64
    }
65
66
    public function 入力_郵便番号($value)
67
    {
68
        $this->tester->fillField(['id' => 'order_postal_code'], $value);
69
70
        return $this;
71
    }
72
73
    public function 入力_都道府県($value)
74
    {
75
        $this->tester->selectOption(['id' => 'order_address_pref'], $value);
76
        return $this;
77
    }
78
79
    public function 入力_市区町村名($value)
80
    {
81
        $this->tester->fillField(['id' => 'order_address_addr01'], $value);
82
        return $this;
83
    }
84
85
    public function 入力_番地_ビル名($value)
86
    {
87
        $this->tester->fillField(['id' => 'order_address_addr02'], $value);
88
        return $this;
89
    }
90
91
    public function 入力_電話番号($value)
92
    {
93
        $this->tester->fillField(['id' => 'order_phone_number'], $value);
94
95
        return $this;
96
    }
97
98
    public function 入力_Eメール($value)
99
    {
100
        $this->tester->fillField(['id' => 'order_email'], $value);
101
        return $this;
102
    }
103
104
    public function 入力_支払方法($value)
105
    {
106
        $this->tester->selectOption(['id' => 'order_Payment'], $value);
107
        return $this;
108
    }
109
110
    public function 入力_配送業者($value)
111
    {
112
        $this->tester->selectOption(['id' => 'order_Shipping_Delivery'], $value);
113
        return $this;
114
    }
115
116
    public function 注文者情報をコピー()
117
    {
118
        $this->tester->click('#shippingInfo > div > div.row.mb-3 > div:nth-child(1) > button.btn.btn-ec-regular.copy-customer');
119
        return $this;
120
    }
121
122
    public function 注文者パネルを開く()
123
    {
124
        $this->tester->click('#form1 > div.c-contentsArea__cols > div > div.c-primaryCol > div:nth-child(2) > div.card-header > div > div.col-1.text-right > a');
125
        $this->tester->wait(1);
126
        return $this;
127
    }
128
129
    public function 商品検索($value = '')
130
    {
131
        $this->tester->scrollTo(['css' => '#orderItem > div > div.row.justify-content-between.mb-2 > div.col-6 > a.btn.btn-ec-regular.mr-2.add'], 0, -50);
132
        $this->tester->click(['css' => '#orderItem > div > div.row.justify-content-between.mb-2 > div.col-6 > a.btn.btn-ec-regular.mr-2.add']);
133
        $this->tester->waitForElement(['id' => 'addProduct']);
134
        $this->tester->wait(1);
135
        $this->tester->fillField(['id' => 'admin_search_product_id'], $value);
136
        $this->tester->click('#searchProductModalButton');
137
        $this->tester->waitForElementVisible('#searchProductModalList table');
138
        $this->tester->wait(1);
139
        return $this;
140
    }
141
142
    public function 商品検索結果_選択($rowNum)
143
    {
144
        $rowNum = $rowNum * 2;
145
        $this->tester->click("#searchProductModalList > table > tbody > tr:nth-child(${rowNum}) > td.text-right > button");
146
        return $this;
147
    }
148
149
    public function 受注情報登録()
150
    {
151
        $this->tester->click('#form1 > div.c-conversionArea > div > div > div:nth-child(2) > div > div > button');
152
        $this->tester->wait(5);
153
        return $this;
154
    }
155
156
    public function 明細の項目名を取得($row)
157
    {
158
        return $this->tester->grabTextFrom("#table-form-field > tbody > tr:nth-child({$row}) > td.align-middle.w-25.pl-3");
159
    }
160
161
    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)
170
    {
171
        $this->tester->click("#table-form-field > tbody > tr:nth-child({$row}) > td.align-middle.text-right.pr-3 div.modal a.delete");
172
        return $this;
173
    }
174
}
175