Completed
Push — apply-codeceptions ( 341052...a29855 )
by Kentaro
53:23 queued 21:51
created

contentsmanagement_ページ管理()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 77

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 77
rs 8.5018
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
use Codeception\Util\Fixtures;
4
use Page\Admin\BlockEditPage;
5
use Page\Admin\BlockManagePage;
6
use Page\Admin\FileManagePage;
7
use Page\Admin\LayoutEditPage;
8
use Page\Admin\LayoutManagePage;
9
use Page\Admin\NewsManagePage;
10
use Page\Admin\NewsEditPage;
11
use Page\Admin\PageManagePage;
12
use Page\Admin\PageEditPage;
13
14
/**
15
 * @group admin
16
 * @group admin02
17
 * @group contentsmanagement
18
 * @group ea6
19
 */
20
class EA06ContentsManagementCest
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...
21
{
22
    public function _before(\AcceptanceTester $I)
23
    {
24
        // すべてのテストケース実施前にログインしておく
25
        // ログイン後は管理アプリのトップページに遷移している
26
        $I->loginAsAdmin();
27
    }
28
29
    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...
30
    {
31
    }
32
33
    public function contentsmanagement_新着情報管理(\AcceptanceTester $I)
34
    {
35
        $I->wantTo('EA0601-UC01-T01(& UC02-T01/UC02-T02/UC03-T01) 新着情報管理(作成・編集・削除)');
36
37
        NewsManagePage::go($I)->新規登録();
38
39
        NewsEditPage::of($I)
40
            ->入力_日付(date('Y-m-d'))
41
            ->入力_タイトル('news_title1')
42
            ->入力_本文('newsnewsnewsnewsnews')
43
            ->登録();
44
45
        $NewsListPage = NewsManagePage::at($I);
46
        $I->see('新着情報を保存しました。', NewsManagePage::$登録完了メッセージ);
47
48
        $NewsListPage->一覧_編集(1);
49
50
        NewsEditPage::of($I)
51
            ->入力_タイトル('news_title2')
52
            ->登録();
53
54
        $NewsListPage = NewsManagePage::at($I);
55
        $I->see('新着情報を保存しました。', NewsManagePage::$登録完了メッセージ);
56
        $I->assertEquals('news_title2', $NewsListPage->一覧_タイトル(1));
57
58
        $NewsListPage->一覧_下へ(1);
59
        $I->assertEquals('news_title2', $NewsListPage->一覧_タイトル(2));
60
61
        $NewsListPage->一覧_上へ(1);
62
        $I->assertEquals('news_title2', $NewsListPage->一覧_タイトル(1));
63
64
        $NewsListPage->一覧_削除(1);
65
        $I->acceptPopup();
66
67
        $I->assertNotEquals('news_title2', $NewsListPage->一覧_タイトル(1));
68
    }
69
70
    /**
71
     * @env firefox
72
     * @env chrome
73
     */
74
    public function contentsmanagement_ファイル管理(\AcceptanceTester $I)
75
    {
76
        $I->wantTo('EA0602-UC01-T01(& UC01-T02/UC01-T03/UC01-T04/UC01-T05/UC01-T06/UC01-T07) ファイル管理');
77
78
        /** @var FileManagePage $FileManagePage */
79
        $FileManagePage = FileManagePage::go($I)
80
            ->入力_ファイル('upload.txt')
81
            ->アップロード();
82
83
        $I->see('upload.txt', $FileManagePage->ファイル名(1));
84
85
        $FileManagePage->一覧_ダウンロード(1);
86
        $UploadedFile = $I->getLastDownloadFile('/^upload\.txt$/');
87
        $I->assertEquals('This is uploaded file.', file_get_contents($UploadedFile));
88
89
        $FileManagePage->一覧_表示(1);
90
        $I->switchToNewWindow();
91
        $I->see('This is uploaded file.');
92
93
        FileManagePage::go($I)
94
            ->一覧_削除(1)
95
            ->一覧_削除_accept(1);
0 ignored issues
show
Unused Code introduced by
The call to FileManagePage::一覧_削除_accept() has too many arguments starting with 1.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
96
        $I->dontSee('upload.txt', $FileManagePage->ファイル名(1));
97
98
        $FileManagePage = FileManagePage::go($I)
99
            ->入力_フォルダ名('folder1')
100
            ->フォルダ作成();
101
102
        $I->see('folder1', $FileManagePage->ファイル名(1));
103
104
        // Todo: breadcrumbs incomplete
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% 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...
105
//        $FileManagePage->一覧_表示(1);
106
//        $I->see('folder1', $FileManagePage->パンくず(1));
107
108
        $config = Fixtures::get('config');
109
        $I->amOnPage('/'.$config['eccube_admin_route'].'/content/file_manager');
110
        $I->see('ファイル管理コンテンツ管理', '.c-pageTitle');
111
112
        FileManagePage::go($I)
113
            ->一覧_削除(1)
114
            ->一覧_削除_accept();
115
    }
116
117
    public function contentsmanagement_ページ管理(\AcceptanceTester $I)
118
    {
119
        $I->wantTo('EA0603-UC01-T01(& UC01-T02/UC01-T03/UC01-T04/UC01-T05) ページ管理');
120
        $faker = Fixtures::get('faker');
121
        $page = 'page_'.$faker->word;
122
        PageManagePage::go($I)->新規入力();
123
124
        /* 作成 */
125
        PageEditPage::at($I)
126
            ->入力_名称($page)
127
            ->入力_ファイル名($page)
128
            ->入力_URL($page)
129
            ->入力_内容($page)
130
            ->入力_PC用レイアウト('下層ページ用レイアウト')
131
            ->登録();
132
        $I->see('登録が完了しました。', PageEditPage::$登録完了メッセージ);
133
134
        $I->amOnPage('/user_data/'.$page);
135
        $I->see($page, 'body');
136
137
        /* 編集 */
138
        PageManagePage::go($I)->ページ編集($page);
139
        PageEditPage::at($I)
140
            ->入力_内容("{% extends 'default_frame.twig' %}")
141
            ->登録();
142
        $I->see('登録が完了しました。', PageEditPage::$登録完了メッセージ);
143
144
        $I->amOnPage('/user_data/'.$page);
145
        $config = Fixtures::get('config');
0 ignored issues
show
Unused Code introduced by
$config is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
146
        $I->seeElement('div.ec-layoutRole__footer');
147
148
        /* レイアウト編集 */
149
        LayoutManagePage::go($I)->レイアウト編集('下層ページ用レイアウト');
150
        LayoutEditPage::at($I)
151
            ->ブロックを移動('新着情報', '#position_4')
152
            ->登録();
153
154
        $I->see('登録が完了しました。', LayoutEditPage::$登録完了メッセージ);
155
        $I->amOnPage('/user_data/'.$page);
156
        $I->see('新着情報', '.ec-news');
157
158
        LayoutManagePage::go($I)->レイアウト編集('下層ページ用レイアウト');
159
        LayoutEditPage::at($I)
160
            ->ブロックを移動('カゴの中', '#position_2')
161
            ->登録();
162
        LayoutEditPage::at($I)
163
            ->ブロックを移動('ログインナビ', '#position_2')
164
            ->登録();
165
        LayoutEditPage::at($I)
166
            ->ブロックを移動('商品検索', '#position_2')
167
            ->コンテキストメニューで上に移動('商品検索')
168
            ->登録();
169
        LayoutEditPage::at($I)
170
            ->コンテキストメニューで下に移動('商品検索')
171
            ->登録();
172
        LayoutEditPage::at($I)
173
            ->コンテキストメニューでセクションに移動('商品検索')
174
            ->登録();
175
        LayoutEditPage::at($I)
176
            ->コンテキストメニューでコードプレビュー(
177
                '商品検索',
178
                ['xpath' => "//*[@id='block-source-code']//div[contains(text(), 'This file is part of EC-CUBE')]"]
179
            );
180
181
        $I->getScenario()->incomplete('未実装:プレビューは未実装');
182
183
        LayoutManagePage::go($I)->レイアウト編集('下層ページ用レイアウト');
184
        LayoutEditPage::at($I)
185
            ->ブロックを移動('新着情報', '#position_0')
186
            ->プレビュー();
187
188
        $I->switchToNewWindow();
189
190
        /* 削除 */
191
        PageManagePage::go($I)->削除($page);
192
        $I->see('削除が完了しました。', PageEditPage::$登録完了メッセージ);
193
    }
194
195
    public function contentsmanagement_検索未使用ブロック(\AcceptanceTester $I)
196
    {
197
        $I->wantTo('EA0603-UC01-T06 検索未使用ブロック');
198
        $layoutName = '下層ページ用レイアウト';
199
        /* レイアウト編集 */
200
        LayoutManagePage::go($I)->レイアウト編集($layoutName);
201
        $items = $I->grabMultiple(LayoutEditPage::$未使用ブロックアイテム);
202
        LayoutEditPage::at($I)
203
            ->検索ブロック名('ギャラリー');
204
205
        $I->seeNumberOfElements(LayoutEditPage::$未使用ブロックアイテム, 1);
206
207
        LayoutManagePage::go($I)->レイアウト編集($layoutName);
208
        LayoutEditPage::at($I)
209
            ->検索ブロック名('');
210
211
        $I->seeNumberOfElements(LayoutEditPage::$未使用ブロックアイテム, count($items));
212
    }
213
214
    public function contentsmanagement_ブロック管理(\AcceptanceTester $I)
215
    {
216
        $I->wantTo('EA0603-UC01-T01(& UC01-T02/UC01-T03) ブロック管理');
217
        $faker = Fixtures::get('faker');
218
        $block = $faker->word.'_block';
219
        /* 作成 */
220
        BlockManagePage::go($I)->新規入力();
221
        BlockEditPage::at($I)
222
            ->入力_ブロック名($block)
223
            ->入力_ファイル名($block)
224
            ->入力_データ("<div id=".$block.">block1</div>")
225
            ->登録();
226
        $I->see('登録が完了しました。', BlockEditPage::$登録完了メッセージ);
227
228
        // TOPページにブロックを配置
229
        LayoutManagePage::go($I)->レイアウト編集('トップページ用レイアウト');
230
        LayoutEditPage::at($I)
231
            ->ブロックを移動($block, '#position_3')
232
            ->登録();
233
234
        $I->getScenario()->incomplete('未実装:ブロックの更新は未実装');
235
        $I->amOnPage('/');
236
        $I->see('block1', ['id' => $block]);
237
238
        /* 編集 */
239
        BlockManagePage::go($I)->編集(1);
240
        BlockEditPage::at($I)
241
            ->入力_データ("<div id=".$block.">welcome</div>")
242
            ->登録();
243
        $I->see('登録が完了しました。', BlockEditPage::$登録完了メッセージ);
244
245
        $I->amOnPage('/');
246
        $I->see('welcome', ['id' => $block]);
247
248
        /* 削除 */
249
        BlockManagePage::go($I)->削除(1);
250
        $I->acceptPopup();
251
252
        $I->amOnPage('/');
253
        $I->dontSeeElement(['id' => $block]);
254
    }
255
}
256