Failed Conditions
Pull Request — 4.0 (#3601)
by Kiyotaka
06:20
created

ProductListPage::at()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.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
namespace Page\Front;
15
16
class ProductListPage extends AbstractFrontPage
17
{
18
    public static function at($I)
19
    {
20
        $page = new self($I);
21
        $page->tester->seeInCurrentUrl('/products/list');
22
23
        return $page;
24
    }
25
26
    public function __construct(\AcceptanceTester $I)
27
    {
28
        parent::__construct($I);
29
    }
30
31
    public function 表示件数設定($num)
32
    {
33
        $this->tester->selectOption(['css' => "select[name = 'disp_number']"], "${num}件");
34
35
        return $this;
36
    }
37
38
    public function 表示順設定($sort)
39
    {
40
        $this->tester->selectOption(['css' => "select[name = 'orderby']"], $sort);
41
42
        return $this;
43
    }
44
45
    public function 一覧件数取得()
46
    {
47
        $products = $this->tester->grabMultiple(['xpath' => "//*[@class='ec-shelfGrid__item']/a/p[1]"]);
48
49
        return count($products);
50
    }
51
52
    public function カートに入れる($index, $num = 1, $category1 = null, $category2 = null)
53
    {
54
        $this->tester->fillField(['css' => "ul.ec-shelfGrid li.ec-shelfGrid__item:nth-child(${index}) form input[name='quantity']"], $num);
55 View Code Duplication
        if (!is_null($category1)) {
56
            $this->tester->selectOption(['css' => "ul.ec-shelfGrid li.ec-shelfGrid__item:nth-child(${index}) form select[name='classcategory_id1']"], $category1);
57
            if (!is_null($category2)) {
58
                $category2_id = current(array_keys($category2));
59
                $this->tester->waitForElement(['xpath' => "//ul[@class='ec-shelfGrid']/li[@class='ec-shelfGrid__item'][${index}]//select[@name='classcategory_id2']/option[@value='${category2_id}']"]);
60
                $this->tester->selectOption(['css' => "ul.ec-shelfGrid li.ec-shelfGrid__item:nth-child(${index}) form select[name='classcategory_id2']"], $category2);
61
            }
62
        }
63
        $this->tester->click(['class' => 'add-cart']);
64
        $this->tester->waitForElementVisible(['css' => 'div.ec-modal-box']);
65
66
        return $this;
67
68
        $this->tester->click(['css' => "button[data-cartid='${productId}']"]);
0 ignored issues
show
Unused Code introduced by
$this->tester->click(arr...tid='{$productId}']")); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
69
        $this->tester->waitForElementVisible(['css' => 'div.ec-modal-box']);
70
71
        return $this;
72
    }
73
74
    public function カートへ進む()
75
    {
76
        $this->tester->click('div.ec-modal-box > div > a');
77
78
        return CartPage::at($this->tester);
79
    }
80
}
81