Completed
Push — master ( 447f14...063677 )
by Dmitry
08:18 queued 05:23
created

Dropdown::withItems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace hipanel\tests\_support\Page\Widget\Input;
4
5
use hipanel\tests\_support\AcceptanceTester;
6
7
class Dropdown extends TestableInput
8
{
9
    /**
10
     * @property string[]|null
11
     */
12
    private $items;
13
14
    /**
15
     * @param string[] $items array of items names
16
     */
17
    public function withItems(array $items): void
18
    {
19
        $this->items = $items;
20
    }
21
22
    public function isVisible(AcceptanceTester $I, string $formId): void
23
    {
24
        $I->seeElement("//form[@id='$formId']//select", ['id' => $this->name]);
25
        if ($this->items) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->items of type string[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
26
            foreach ($this->items as $item) {
27
                $I->see($item, "//form[@id='$formId']//select[@id='$this->name']/option");
28
            }
29
        }
30
    }
31
}
32