|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* (c) FSi sp. z o.o. <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
declare(strict_types=1); |
|
11
|
|
|
|
|
12
|
|
|
namespace FSi\Bundle\AdminBundle\Behat\Page; |
|
13
|
|
|
|
|
14
|
|
|
use Behat\Mink\Element\NodeElement; |
|
15
|
|
|
|
|
16
|
|
|
class AdminPanel extends Page |
|
17
|
|
|
{ |
|
18
|
|
|
protected $path = '/admin/'; |
|
19
|
|
|
|
|
20
|
|
|
public function hasMenuElement(string $name, ?string $group = null): bool |
|
21
|
|
|
{ |
|
22
|
|
|
if (null === $group) { |
|
23
|
|
|
return $this->getMenu()->has('css', sprintf('li > a:contains("%s")', $name)); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
$groupExpandButton = $this->getMenu()->find('css', sprintf('li.dropdown > a:contains("%s")', $group)); |
|
27
|
|
|
|
|
28
|
|
|
if (null !== $groupExpandButton) { |
|
29
|
|
|
return $groupExpandButton->getParent()->has('css', sprintf('ul > li > a:contains("%s")', $name)); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
return false; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function getMenuElementsCount(): int |
|
36
|
|
|
{ |
|
37
|
|
|
return count($this->getMenu()->findAll('css', 'li.admin-element')); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function getMenu(): ?NodeElement |
|
41
|
|
|
{ |
|
42
|
|
|
return $this->find('css', '#top-menu'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function getNavbarBrandText(): string |
|
46
|
|
|
{ |
|
47
|
|
|
return $this->find('css', 'a.navbar-brand')->getText(); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function getLanguageDropdownOptions(): array |
|
51
|
|
|
{ |
|
52
|
|
|
$link = $this->getLanguageDropdown(); |
|
53
|
|
|
if (null === $link) { |
|
54
|
|
|
return []; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$linkNodes = $this->findAll('css', 'li#language > ul > li'); |
|
58
|
|
|
|
|
59
|
|
|
return array_filter(array_map(function(NodeElement $element) { |
|
60
|
|
|
return $element->getText(); |
|
61
|
|
|
}, $linkNodes)); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function getLanguageDropdown(): ?NodeElement |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->find('css', 'li#language'); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|