Completed
Push — master ( 193ec3...090eb4 )
by Dmitry
33:37 queued 18:43
created

Grid::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace hipanel\tests\_support\Page\Widget;
4
5
use hipanel\tests\_support\AcceptanceTester;
6
use hipanel\tests\_support\Page\Authenticated;
7
8
class Grid extends Authenticated
9
{
10
    /**
11
     * @var string $Xpath Chropath of current grid
12
     */
13
    private $Xpath;
14
15
    public function __construct(AcceptanceTester $I, string $Xpath = "//form[contains(@id, 'bulk')]")
16
    {
17
        parent::__construct($I);
18
        $this->Xpath = $Xpath;
19
    }
20
21
    /**
22
     * @param string[] $columnNames array of column names
23
     * @param string|null $representation the representation name
24
     * @throws \Codeception\Exception\ModuleException
25
     */
26
    public function containsColumns(array $columnNames, $representation = null): void
27
    {
28
        $I = $this->tester;
29
        $formId = $I->grabAttributeFrom($this->Xpath, 'id');
30
31
        if ($representation !== null) {
32
            $I->click("//button[contains(text(), 'View:')]");
33
            $I->click("//ul/li/a[contains(text(), '$representation')]");
34
            $I->waitForPageUpdate(120);
35
        }
36
37
        foreach ($columnNames as $column) {
38
            $I->see($column, "//form[@id='$formId']//table/thead/tr/th");
39
        }
40
    }
41
}