Completed
Push — 4.0 ( 268f2c...88f012 )
by Hideki
05:48 queued 10s
created

acceptance/EA06ContentsManagementCest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.ec-cube.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
use Codeception\Util\Fixtures;
15
use Page\Admin\BlockEditPage;
16
use Page\Admin\BlockManagePage;
17
use Page\Admin\FileManagePage;
18
use Page\Admin\LayoutEditPage;
19
use Page\Admin\LayoutManagePage;
20
use Page\Admin\NewsEditPage;
21
use Page\Admin\NewsManagePage;
22
use Page\Admin\PageEditPage;
23
use Page\Admin\PageManagePage;
24
use Symfony\Component\Filesystem\Filesystem;
25
use Symfony\Component\Finder\Finder;
26
27
/**
28
 * @group admin
29
 * @group admin02
30
 * @group contentsmanagement
31
 * @group ea6
32
 */
33
class EA06ContentsManagementCest
34
{
35
    public function _before(\AcceptanceTester $I)
36
    {
37
        // すべてのテストケース実施前にログインしておく
38
        // ログイン後は管理アプリのトップページに遷移している
39
        $I->loginAsAdmin();
40
    }
41
42
    public function _after(\AcceptanceTester $I)
43
    {
44
    }
45
46
    public function contentsmanagement_新着情報管理(\AcceptanceTester $I)
47
    {
48
        $I->getScenario()->incomplete('未実装:新着情報管理は未実装');
49
50
        $I->wantTo('EA0601-UC01-T01(& UC02-T01/UC02-T02/UC03-T01) 新着情報管理(作成・編集・削除)');
51
52
        NewsManagePage::go($I)->新規登録();
53
54
        NewsEditPage::of($I)
55
            ->入力_日付(date('Y-m-d'))
56
            ->入力_タイトル('news_title1')
57
            ->入力_本文('newsnewsnewsnewsnews')
58
            ->登録();
59
60
        $NewsListPage = NewsManagePage::at($I);
61
        $I->see('保存しました', NewsManagePage::$登録完了メッセージ);
62
63
        $NewsListPage->一覧_編集(2);
64
65
        NewsEditPage::of($I)
66
            ->入力_タイトル('news_title2')
67
            ->登録();
68
69
        $NewsListPage = NewsManagePage::at($I);
70
        $I->see('新着情報を保存しました。', NewsManagePage::$登録完了メッセージ);
71
        $I->assertEquals('news_title2', $NewsListPage->一覧_タイトル(2));
72
73
        $I->assertEquals('news_title2', $NewsListPage->一覧_タイトル(2));
74
75
        $I->assertEquals('news_title2', $NewsListPage->一覧_タイトル(2));
76
77
        $NewsListPage->一覧_削除(2);
78
        $NewsListPage->ポップアップを受け入れます(2);
79
80
        $I->assertNotEquals('news_title2', $NewsListPage->一覧_タイトル(2));
81
    }
82
83
    /**
84
     * @env firefox
85
     * @env chrome
86
     */
87
    public function contentsmanagement_ファイル管理(\AcceptanceTester $I)
88
    {
89
        $I->wantTo('EA0602-UC01-T01(& UC01-T02/UC01-T03/UC01-T04/UC01-T05/UC01-T06/UC01-T07) ファイル管理');
90
91
        $backupDir = sys_get_temp_dir().'/'.random_int(0, 1000);
92
        $user_data = __DIR__.'/../../html/user_data';
93
        $fs = new Filesystem();
94
        $fs->mkdir($backupDir);
95
        $fs->mirror($user_data, $backupDir);
96
        try {
97
            $files = Finder::create()
98
                ->ignoreDotFiles(false)
99
                ->in($user_data);
100
            $fs->remove($files);
0 ignored issues
show
$files is of type object<Symfony\Component\Finder\Finder>, but the function expects a string|object<Symfony\Co...nt\Filesystem\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
101
102
            /** @var FileManagePage $FileManagePage */
103
            $FileManagePage = FileManagePage::go($I)
104
                ->入力_ファイル('upload.txt')
105
                ->アップロード();
106
107
            $I->see('upload.txt', $FileManagePage->ファイル名(1));
108
109
            $FileManagePage->一覧_ダウンロード(1);
110
            $UploadedFile = $I->getLastDownloadFile('/^upload\.txt$/');
111
            $I->assertEquals('This is uploaded file.', file_get_contents($UploadedFile));
112
113
            $FileManagePage->一覧_パスをコピー(1);
114
            $I->wait(5);
115
            $returnText = $I->grabValueFrom("#fileList table > tbody > tr:nth-child(1) > td:nth-child(4) span.copy-file-path input.form-control");
116
            $I->assertEquals('/html/user_data/upload.txt', $returnText);
117
118
            $FileManagePage->一覧_表示(1);
119
            $I->switchToNewWindow();
120
            $I->see('This is uploaded file.');
121
122
            FileManagePage::go($I)
123
                ->一覧_削除(1)
124
                ->一覧_削除_accept(1);
125
            $I->dontSee('upload.txt', $FileManagePage->ファイル名(1));
126
127
            $FileManagePage = FileManagePage::go($I)
128
                ->入力_フォルダ名('folder1')
129
                ->フォルダ作成();
130
131
            $I->see('folder1', $FileManagePage->ファイル名(1));
132
133
            $FileManagePage->一覧_ファイル名_クリック(1);
134
            $I->see('folder1', $FileManagePage->パンくず(2));
135
136
            $config = Fixtures::get('config');
137
            $I->amOnPage('/'.$config['eccube_admin_route'].'/content/file_manager');
138
            $I->see('ファイル管理コンテンツ管理', '.c-pageTitle');
139
140
            FileManagePage::go($I)
141
                ->一覧_削除(1)
142
                ->一覧_削除_accept(1);
143
        } finally {
144
            $fs->mirror($backupDir, $user_data);
145
        }
146
    }
147
148
    public function contentsmanagement_ページ管理(\AcceptanceTester $I)
149
    {
150
        $I->wantTo('EA0603-UC01-T01(& UC01-T02/UC01-T03/UC01-T04/UC01-T05) ページ管理');
151
        $faker = Fixtures::get('faker');
152
        $page = 'page_'.$faker->word;
153
        PageManagePage::go($I)->新規入力();
154
155
        /* 新規作成時の初期タグ */
156
        $I->assertEquals(PageEditPage::at($I)->出力_内容(), "{% extends 'default_frame.twig' %}\n\n{% block main %}\n\n{% endblock %}");
157
158
        /* 作成 */
159
        PageEditPage::at($I)
160
            ->入力_名称($page)
161
            ->入力_ファイル名($page)
162
            ->入力_URL($page)
163
            ->入力_内容($page)
164
            ->入力_PC用レイアウト('下層ページ用レイアウト')
165
            ->登録();
166
        $I->see('保存しました', PageEditPage::$登録完了メッセージ);
167
168
        $I->amOnPage('/user_data/'.$page);
169
        $I->see($page, 'body');
170
171
        /* 編集 */
172
        PageManagePage::go($I)->ページ編集($page);
173
        PageEditPage::at($I)
174
            ->入力_内容("{% extends 'default_frame.twig' %}")
175
            ->登録();
176
        $I->see('保存しました', PageEditPage::$登録完了メッセージ);
177
178
        $I->amOnPage('/user_data/'.$page);
179
        $config = Fixtures::get('config');
180
        $I->seeElement('div.ec-layoutRole__footer');
181
182
        /* レイアウト編集 */
183
        LayoutManagePage::go($I)->レイアウト編集('下層ページ用レイアウト');
184
        LayoutEditPage::at($I)
185
            ->ブロックを移動('新着情報', '#position_4')
186
            ->登録();
187
188
        $I->see('保存しました', LayoutEditPage::$登録完了メッセージ);
189
        $I->amOnPage('/user_data/'.$page);
190
        $I->see('新着情報', '.ec-newsRole');
191
192
        LayoutManagePage::go($I)->レイアウト編集('下層ページ用レイアウト');
193
        LayoutEditPage::at($I)
194
            ->ブロックを移動('カート', '#position_2')
195
            ->登録();
196
        LayoutEditPage::at($I)
197
            ->ブロックを移動('ログインナビ(共通)', '#position_2')
198
            ->登録();
199
        LayoutEditPage::at($I)
200
            ->ブロックを移動('商品検索', '#position_2')
201
            ->コンテキストメニューで上に移動('商品検索')
202
            ->登録();
203
        LayoutEditPage::at($I)
204
            ->コンテキストメニューで下に移動('商品検索')
205
            ->登録();
206
        LayoutEditPage::at($I)
207
            ->コンテキストメニューでセクションに移動('商品検索')
208
            ->登録();
209
        LayoutEditPage::at($I)
210
            ->コンテキストメニューでコードプレビュー(
211
                '商品検索',
212
                ['xpath' => "//*[@id='block-source-code']//div[contains(text(), 'file that was distributed with this source code.')]"]
213
            );
214
215
        LayoutManagePage::go($I)->レイアウト編集('下層ページ用レイアウト');
216
        LayoutEditPage::at($I)
217
            ->ブロックを移動('カート', '#position_0')
218
            ->選択_プレビューページ('商品一覧ページ')
219
            ->プレビュー();
220
221
        $I->switchToNewWindow();
222
223
        /* 削除 */
224
        PageManagePage::go($I)->削除($page);
225
        $I->see('削除しました', PageEditPage::$登録完了メッセージ);
226
    }
227
228
    public function contentsmanagement_レイアウト管理(\AcceptanceTester $I)
229
    {
230
        // レイアウト名を未入力で登録
231
        LayoutManagePage::go($I)->新規登録();
232
        LayoutEditPage::at($I)
233
            ->登録();
234
235
        // html5のバリデーションエラーで画面遷移しないはず
236
        $I->seeInCurrentUrl('/admin/content/layout/new');
237
        $I->cantSee('入力されていません。');
238
239
        // レイアウト名を入力して登録
240
        LayoutEditPage::at($I)
241
            ->レイアウト名('あたらしいレイアウト')
242
            ->登録();
243
244
        $I->see('保存しました');
245
    }
246
247
    public function contentsmanagement_検索未使用ブロック(\AcceptanceTester $I)
248
    {
249
        $I->wantTo('EA0603-UC01-T06 検索未使用ブロック');
250
        $layoutName = '下層ページ用レイアウト';
251
        /* レイアウト編集 */
252
        LayoutManagePage::go($I)->レイアウト編集($layoutName);
253
        $items = $I->grabMultiple(LayoutEditPage::$未使用ブロックアイテム);
254
        LayoutEditPage::at($I)
255
            ->検索ブロック名('トピック');
256
257
        $I->seeNumberOfElements(LayoutEditPage::$未使用ブロックアイテム, 1);
258
259
        LayoutManagePage::go($I)->レイアウト編集($layoutName);
260
        LayoutEditPage::at($I)
261
            ->検索ブロック名('');
262
263
        $I->seeNumberOfElements(LayoutEditPage::$未使用ブロックアイテム, count($items));
264
    }
265
266
    public function contentsmanagement_ブロック管理(\AcceptanceTester $I)
267
    {
268
        $I->wantTo('EA0603-UC01-T01(& UC01-T02/UC01-T03) ブロック管理');
269
        $faker = Fixtures::get('faker');
270
        $block = $faker->word.'_block';
271
        /* 作成 */
272
        BlockManagePage::go($I)->新規入力();
273
        BlockEditPage::at($I)
274
            ->入力_ブロック名($block)
275
            ->入力_ファイル名($block)
276
            ->入力_データ('<div id='.$block.'>block1</div>')
277
            ->登録();
278
        $I->see('保存しました', BlockEditPage::$登録完了メッセージ);
279
280
        // TOPページにブロックを配置
281
        LayoutManagePage::go($I)->レイアウト編集('トップページ用レイアウト');
282
        LayoutEditPage::at($I)
283
            ->ブロックを移動($block, '#position_3')
284
            ->登録();
285
286
        $I->getScenario()->incomplete('未実装:ブロックの更新は未実装');
287
        $I->amOnPage('/');
288
        $I->see('block1', ['id' => $block]);
289
290
        /* 編集 */
291
        BlockManagePage::go($I)->編集(1);
292
        BlockEditPage::at($I)
293
            ->入力_データ('<div id='.$block.'>welcome</div>')
294
            ->登録();
295
        $I->see('保存しました', BlockEditPage::$登録完了メッセージ);
296
297
        $I->amOnPage('/');
298
        $I->see('welcome', ['id' => $block]);
299
300
        /* 削除 */
301
        BlockManagePage::go($I)->削除(1);
302
        $I->acceptPopup();
303
304
        $I->amOnPage('/');
305
        $I->dontSeeElement(['id' => $block]);
306
    }
307
}
308