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

EF01TopCest::topページ_初期表示()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 42

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 6
nop 1
dl 0
loc 42
rs 9.248
c 0
b 0
f 0
1
<?php
2
3
use Codeception\Util\Fixtures;
4
use Page\Front\TopPage;
5
6
/**
7
 * @group front
8
 * @group toppage
9
 * @group ef1
10
 */
11
class EF01TopCest
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...
12
{
13
    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...
14
    {
15
    }
16
17
    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...
18
    {
19
    }
20
21
    public function topページ_初期表示(\AcceptanceTester $I)
22
    {
23
        $I->wantTo('EF0101-UC01-T01 TOPページ 初期表示');
24
        TopPage::go($I);
25
26
        // カテゴリ選択ボックス(キーワード検索用)、キーワード検索入力欄、虫眼鏡ボタンが表示されている
27
        $I->see('全ての商品', TopPage::$検索_カテゴリ選択);
28
        $I->see('', TopPage::$検索_カテゴリ選択);
29
30
        // カテゴリ名(カテゴリ検索用)が表示されている
31
        $categories = Fixtures::get('categories');
32
        foreach ($categories as $category) {
33
            $I->see($category->getName(), '#searchform #category_id option');
34
        }
35
36
        //管理側のコンテンツ管理(新着情報管理)に設定されている情報が、順位順に表示されている
37
        $today = new DateTime();
38
        $minus1 = $today->sub(new DateInterval('P1D'));
39
        $minus2 = $today->sub(new DateInterval('P2D'));
40
41
        $createNews = Fixtures::get('createNews');
42
        $News1 = $createNews($minus1, 'タイトル1', 'コメント1');
43
        $News2 = $createNews($minus2, 'タイトル2', 'コメント2');
44
45
        $I->reloadPage();
46
47
        $findNews = Fixtures::get('findNews');
48
        $newsAll = $findNews();
49
        foreach ($newsAll as $index => $news) {
50
            $rowNum = $index + 1;
51
            $I->see($news['title'], 'div.ec-news .ec-news__item:nth-child('.$rowNum.') .ec-newsline__title');
52
            // 5件を超えるとread moreが表示される.
53
            if ($rowNum > 5) {
54
                break;
55
            }
56
        }
57
58
        $em = Fixtures::get('entityManager');
59
        $em->remove($News1);
60
        $em->remove($News2);
61
        $em->flush([$News1, $News2]);
62
    }
63
64
    public function topページ_新着情報(\AcceptanceTester $I)
65
    {
66
        $I->wantTo('EF0101-UC01-T02 TOPページ 新着情報');
67
68
        $createNews = Fixtures::get('createNews');
69
        $News = $createNews(new \DateTime(), 'タイトル1', 'コメント1', 'https://www.ec-cube.net');
70
71
        $topPage = TopPage::go($I);
72
73
        // 各新着情報の箇所を押下する
74
        // Knowhow: javascriptでclick eventハンドリングしている場合はclick('表示文字列')では探せない
75
        $topPage->新着情報選択(1);
76
77
        // 押下された新着情報のセクションが広がり、詳細情報、リンクが表示される
78
        $I->assertContains('コメント1', $topPage->新着情報詳細(1));
79
80
        // 「詳しくはこちら」リンクを押下する
81
        $I->assertContains('詳しくはこちら', $topPage->新着情報詳細(1));
82
        $topPage->新着情報リンククリック(1);
83
        $I->amOnUrl($News->getUrl());
84
85
        $em = Fixtures::get('entityManager');
86
        $em->remove($News);
87
        $em->flush($News);
88
    }
89
90 View Code Duplication
    public function topページ_カテゴリ検索(\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...
91
    {
92
        $I->wantTo('EF0101-UC02-T01 TOPページ カテゴリ検索');
93
        $topPage = TopPage::go($I);
94
95
        // カテゴリを選択、そのまま続けて子カテゴリを選択する
96
        $topPage->カテゴリ選択(['キッチンツール', '調理器具']);
97
98
        // 商品一覧の上部に、選択されたカテゴリとその親カテゴリのリンクが表示される
99
        $I->see('調理器具', '.ec-topicpath');
100
        $I->see('パーコレーター', '.ec-shelfGrid');
101
    }
102
103
    public function topページ_全件検索(\AcceptanceTester $I)
104
    {
105
        $I->wantTo('EF0101-UC03-T01 TOPページ 全件検索');
106
        $topPage = TopPage::go($I);
107
        $topPage->検索();
108
109
        // 商品一覧の上部に、選択されたカテゴリとその親カテゴリのリンクが表示される
110
        $I->see('全て', '.ec-topicpath');
111
112
        // カテゴリに分類されている商品のみ表示される
113
        $products = $I->grabMultiple('ul.ec-shelfGrid li.ec-shelfGrid__item');
114
        $I->assertTrue((count($products) >= 2));
115
    }
116
117 View Code Duplication
    public function topページ_カテゴリ絞込検索(\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...
118
    {
119
        $I->wantTo('EF0101-UC03-T02 TOPページ カテゴリ絞込検索');
120
        $topPage = TopPage::go($I);
121
122
        // カテゴリを選択する
123
        $I->selectOption(['id' => 'category_id'], '調理器具');
124
125
        // 虫眼鏡ボタンを押下する
126
        $topPage->検索();
127
128
        // 商品一覧の上部に、選択されたカテゴリとその親カテゴリのリンクが表示される
129
        $I->see('調理器具', '.ec-topicpath');
130
131
        // カテゴリに分類されている商品のみ表示される
132
        $I->see('パーコレーター', '.ec-shelfGrid');
133
        $I->dontSee('ディナーフォーク', '.ec-shelfGrid');
134
    }
135
136 View Code Duplication
    public function topページ_キーワード絞込検索(\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...
137
    {
138
        $I->wantTo('EF0101-UC03-T02 TOPページ キーワード絞込検索');
139
        $topPage = TopPage::go($I);
140
141
        // キーワードを入力する
142
        $I->fillField(['id' => 'name'], 'フォーク');
143
144
        // 虫眼鏡ボタンを押下する
145
        $topPage->検索();
146
147
        // 商品一覧の上部に、選択されたカテゴリとその親カテゴリのリンクが表示される
148
        $I->see('フォーク', '.ec-topicpath');
149
150
        // カテゴリに分類されている商品のみ表示される
151
        $I->dontSee('パーコレーター', '.ec-topicpath');
152
        $I->see('ディナーフォーク', '.ec-shelfGrid');
153
    }
154
}
155