Failed Conditions
Pull Request — experimental/sf (#3236)
by Kentaro
121:51 queued 107:46
created

OrderEditPage   A

Complexity

Total Complexity 21

Size/Duplication

Total Lines 149
Duplicated Lines 8.05 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 12
loc 149
rs 10
c 0
b 0
f 0
wmc 21
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:nth-child(2) > div.col > span > span > span.form-error-message';
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->scrollTo(['css' => '#orderItem > div > div.row.justify-content-between.mb-2 > div.col-6 > a.btn.btn-ec-regular.mr-2.add'], 0, -50);
113
        $this->tester->click(['css' => '#orderItem > div > div.row.justify-content-between.mb-2 > div.col-6 > a.btn.btn-ec-regular.mr-2.add']);
114
        $this->tester->waitForElement(['id' => 'addProduct']);
115
        $this->tester->wait(1);
116
        $this->tester->fillField(['id' => 'admin_search_product_id'], $value);
117
        $this->tester->click('#searchProductModalButton');
118
        $this->tester->waitForElementVisible('#searchProductModalList table');
119
        $this->tester->wait(1);
120
        return $this;
121
    }
122
123
    public function 商品検索結果_選択($rowNum)
124
    {
125
        $rowNum = $rowNum * 2;
126
        $this->tester->click("#searchProductModalList > table > tbody > tr:nth-child(${rowNum}) > td.text-right > button");
127
        return $this;
128
    }
129
130
    public function 受注情報登録()
131
    {
132
        $this->tester->click('#form1 > div.c-conversionArea > div > div > div:nth-child(2) > div > div > button');
133
        $this->tester->wait(5);
134
        return $this;
135
    }
136
137
    public function 明細の項目名を取得($row)
138
    {
139
        return $this->tester->grabTextFrom("#table-form-field > tbody > tr:nth-child({$row}) > td.align-middle.w-25.pl-3");
140
    }
141
142
    public function 明細を削除($row)
143
    {
144
        $this->tester->scrollTo(['css' => '#order-product']);
145
        $this->tester->click("#table-form-field > tbody > tr:nth-child({$row}) > td.align-middle.text-right.pr-3 > div > div > a");
146
        $this->tester->waitForElementVisible("#table-form-field > tbody > tr:nth-child({$row}) > td.align-middle.text-right.pr-3 > div > div > div.modal");
147
        return $this;
148
    }
149
150
    public function acceptDeleteModal($row)
151
    {
152
        $this->tester->click("#table-form-field > tbody > tr:nth-child({$row}) > td.align-middle.text-right.pr-3 div.modal a.delete");
153
        return $this;
154
    }
155
}
156