SidebarMenu   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A ensureContains() 0 12 2
A ensureDoesNotContain() 0 15 3
1
<?php
2
/**
3
 * HiPanel core package
4
 *
5
 * @link      https://hipanel.com/
6
 * @package   hipanel-core
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2014-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\tests\_support\Page;
12
13
use hipanel\helpers\Url;
14
use hipanel\tests\_support\AcceptanceTester;
15
16
class SidebarMenu extends Authenticated
17
{
18
    public function __construct(AcceptanceTester $I)
19
    {
20
        parent::__construct($I);
21
        $I->needPage(Url::to(['/']));
22
    }
23
24
    public function ensureContains(string $rootMenuName, array $items): void
25
    {
26
        $I = $this->tester;
27
28
        $I->click($rootMenuName, '.sidebar-menu');
29
        $I->waitForElement('.menu-open');
30
        foreach ($items as $name => $url) {
31
            $I->see($name, '.menu-open');
32
            $I->seeElement(['css' => '.menu-open a[href~="' . Url::to($url) . '"]']);
33
        }
34
        $I->click($rootMenuName, '.sidebar-menu');
35
    }
36
37
    public function ensureDoesNotContain(string $rootMenuName, array $items = null): void
38
    {
39
        $I = $this->tester;
40
41
        if ($items === null) {
42
            $I->dontSee($rootMenuName);
43
        } else {
44
            $I->click($rootMenuName, '.sidebar-menu');
45
            $I->waitForElement('.menu-open');
46
            foreach ($items as $name) {
47
                $I->dontSee($name, '.menu-open');
48
            }
49
            $I->click($rootMenuName, '.sidebar-menu');
50
        }
51
    }
52
}
53