Failed Conditions
Push — modify-scrutinizeryml ( 361e25...08b4c1 )
by Kentaro
63:54 queued 57:30
created

EF06OtherCest   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 177
Duplicated Lines 32.2 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 57
loc 177
rs 10
c 0
b 0
f 0
wmc 14
lcom 1
cbo 2

11 Methods

Rating   Name   Duplication   Size   Complexity  
A _before() 0 3 1
A _after() 0 3 1
A other_ログイン正常() 9 9 1
A other_ログイン異常1() 16 16 1
A other_ログイン異常2() 16 16 1
A other_パスワード再発行() 0 40 3
A other_ログアウト() 11 11 1
A other_当サイトについて() 0 10 1
A other_プライバシーポリシー() 0 9 1
A other_特定商取引法に基づく表記() 0 8 1
A other_お問い合わせ1() 5 39 2

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
use Codeception\Util\Fixtures;
4
5
/**
6
 * @group front
7
 * @group other
8
 * @group ef6
9
 */
10
class EF06OtherCest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
11
{
12
    public function _before(\AcceptanceTester $I)
0 ignored issues
show
Unused Code introduced by
The parameter $I is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
13
    {
14
    }
15
16
    public function _after(\AcceptanceTester $I)
0 ignored issues
show
Unused Code introduced by
The parameter $I is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
    {
18
    }
19
20 View Code Duplication
    public function other_ログイン正常(\AcceptanceTester $I)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
    {
22
        $I->wantTo('EF0601-UC01-T01 ログイン 正常パターン');
23
        $I->logoutAsMember();
24
25
        $createCustomer = Fixtures::get('createCustomer');
26
        $customer = $createCustomer();
27
        $I->loginAsMember($customer->getEmail(), 'password');
28
    }
29
30 View Code Duplication
    public function other_ログイン異常1(\AcceptanceTester $I)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32
        $I->wantTo('EF0601-UC01-T02 ログイン 異常パターン(仮会員)');
33
        $I->logoutAsMember();
34
35
        $createCustomer = Fixtures::get('createCustomer');
36
        $customer = $createCustomer(null, false);
37
38
        $I->amOnPage('/mypage/login');
39
        $I->submitForm('#login_mypage', [
40
            'login_email' => $customer->getEmail(),
41
            'login_pass' => 'password'
42
        ]);
43
44
        $I->see('ログインできませんでした。', 'div.ec-login p.ec-errorMessage');
45
    }
46
47 View Code Duplication
    public function other_ログイン異常2(\AcceptanceTester $I)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49
        $I->wantTo('EF0601-UC01-T03 ログイン 異常パターン(入力ミス)');
50
        $I->logoutAsMember();
51
52
        $createCustomer = Fixtures::get('createCustomer');
53
        $customer = $createCustomer(null, false);
54
55
        $I->amOnPage('/mypage/login');
56
        $I->submitForm('#login_mypage', [
57
            'login_email' => $customer->getEmail().'.bad',
58
            'login_pass' => 'password'
59
        ]);
60
61
        $I->see('ログインできませんでした。', 'div.ec-login p.ec-errorMessage');
62
    }
63
64
    public function other_パスワード再発行(\AcceptanceTester $I)
65
    {
66
        $I->wantTo('EF0602-UC01-T01 パスワード再発行');
67
        $I->logoutAsMember();
68
        $BaseInfo = Fixtures::get('baseinfo');
69
70
        // TOPページ→ログイン(「ログイン情報をお忘れですか?」リンクを押下する)→パスワード再発行
71
        $I->amOnPage('/mypage/login');
72
        //$I->click('ログイン情報をお忘れですか', '#login_mypage #login_box .btn_area ul li a');
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
73
        $I->amOnPage('/forgot');
74
75
        // TOPページ>ログイン>パスワード再発行
76
        $I->see('パスワードの再発行', 'div.ec-pageHeader h1');
77
78
        // メールアドレスを入力する
79
        // 「次のページへ」ボタンを押下する
80
        $createCustomer = Fixtures::get('createCustomer');
81
        $customer = $createCustomer();
82
        $I->resetEmails();
83
        $I->submitForm('#form1', [
84
            'login_email' => $customer->getEmail()
85
        ]);
86
        $I->see('パスワード発行メールの送信 完了', 'div.ec-pageHeader h1');
87
88
        $I->seeEmailCount(2);
89
        foreach (array($customer->getEmail(), $BaseInfo->getEmail01()) as $email) {
90
            $I->seeInLastEmailSubjectTo($email, 'パスワード変更のご確認');
91
        }
92
        $url = $I->grabFromLastEmailTo($customer->getEmail(), '@/forgot/reset/(.*)@');
93
94
        $I->resetEmails();
95
        $I->amOnPage($url);
96
        $I->see('パスワード変更(完了ページ)', 'div.ec-pageHeader h1');
97
        $I->seeEmailCount(2);
98
        foreach (array($customer->getEmail(), $BaseInfo->getEmail01()) as $email) {
99
            $I->seeInLastEmailSubjectTo($email, 'パスワード変更のお知らせ');
100
        }
101
        $new_password = $I->grabFromLastEmailTo($customer->getEmail(), '@新しいパスワード:(.*)@');
102
        $I->loginAsMember($customer->getEmail(), trim(str_replace('新しいパスワード:', '', $new_password)));
103
    }
104
105 View Code Duplication
    public function other_ログアウト(\AcceptanceTester $I)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
106
    {
107
        $I->wantTo('EF0603-UC01-T01 ログアウト');
108
        $I->logoutAsMember();
109
110
        $createCustomer = Fixtures::get('createCustomer');
111
        $customer = $createCustomer();
112
        $I->loginAsMember($customer->getEmail(), 'password');
113
114
        $I->logoutAsMember();
115
    }
116
117
    public function other_当サイトについて(\AcceptanceTester $I)
118
    {
119
        $I->wantTo('EF0604-UC01-T01 当サイトについて');
120
        $I->amOnPage('/');
121
122
        $I->click('.ec-footerNavi .ec-footerNavi__link:nth-child(1) a');
123
        $I->see('当サイトについて', 'div.ec-pageHeader h1');
124
        $baseinfo = Fixtures::get('baseinfo');
125
        $I->see($baseinfo->getShopName(), '#help_about_box__shop_name');
126
    }
127
128
    public function other_プライバシーポリシー(\AcceptanceTester $I)
129
    {
130
        $I->wantTo('EF0605-UC01-T01 プライバシーポリシー');
131
        $I->amOnPage('/');
132
133
        $I->click('.ec-footerNavi .ec-footerNavi__link:nth-child(2) a');
134
        $I->see('プライバシーポリシー', 'div.ec-pageHeader h1');
135
        $I->see('個人情報保護の重要性に鑑み、「個人情報の保護に関する法律」及び本プライバシーポリシーを遵守し、お客さまのプライバシー保護に努めます。', 'div.ec-layoutRole__main p:nth-child(1)');
136
    }
137
138
    public function other_特定商取引法に基づく表記(\AcceptanceTester $I)
139
    {
140
        $I->wantTo('EF0606-UC01-T01 特定商取引法に基づく表記');
141
        $I->amOnPage('/');
142
143
        $I->click('.ec-footerNavi .ec-footerNavi__link:nth-child(3) a');
144
        $I->see('特定商取引法に基づく表記', 'div.ec-pageHeader h1');
145
    }
146
147
    public function other_お問い合わせ1(\AcceptanceTester $I)
148
    {
149
        $I->wantTo('EF0607-UC01-T01 お問い合わせ');
150
        $I->amOnPage('/');
151
        $I->resetEmails();
152
        $faker = Fixtures::get('faker');
153
        $new_email = microtime(true).'.'.$faker->safeEmail;
154
        $BaseInfo = Fixtures::get('baseinfo');
155
156
        $I->click('.ec-footerNavi .ec-footerNavi__link:nth-child(4) a');
157
        $I->see('お問い合わせ', 'div.ec-pageHeader h1');
158
159
        $I->fillField(['id' => 'contact_name_name01'], '姓');
160
        $I->fillField(['id' => 'contact_name_name02'], '名');
161
        $I->fillField(['id' => 'contact_kana_kana01'], 'セイ');
162
        $I->fillField(['id' => 'contact_kana_kana02'], 'メイ');
163
        $I->fillField(['id' => 'contact_postal_code'], '530-0001');
164
        $I->selectOption(['id' => 'contact_address_pref'], ['value' => '27']);
165
        $I->fillField(['id' => 'contact_address_addr01'], '大阪市北区');
166
        $I->fillField(['id' => 'contact_address_addr02'], '梅田2-4-9 ブリーゼタワー13F');
167
        $I->fillField(['id' => 'contact_phone_number'], '111-111-111');
168
        $I->fillField(['id' => 'contact_email'], $new_email);
169
        $I->fillField(['id' => 'contact_contents'], 'お問い合わせ内容の送信');
170
        $I->click('div.ec-RegisterRole__actions button.ec-blockBtn--action');
171
172
        $I->see('お問い合わせ', 'div.ec-pageHeader h1');
173
        $I->click('div.ec-contactConfirmRole div.ec-RegisterRole__actions button.ec-blockBtn--action');
174
175
        // 完了ページ
176
        $I->see('お問い合わせ完了', 'div.ec-pageHeader h1');
177
178
        // メールチェック
179
        $I->seeEmailCount(2);
180 View Code Duplication
        foreach (array($new_email, $BaseInfo->getEmail01()) as $email) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
181
            $I->seeInLastEmailSubjectTo($email, 'お問い合わせを受け付けました');
182
            $I->seeInLastEmailTo($email, '姓 名 様');
183
            $I->seeInLastEmailTo($email, 'お問い合わせ内容の送信');
184
        }
185
    }
186
}
187