|
1
|
|
|
<?php |
|
2
|
|
|
namespace DNADesign\Elemental\Tests\Behat\Context; |
|
3
|
|
|
|
|
4
|
|
|
use Behat\Mink\Element\NodeElement; |
|
|
|
|
|
|
5
|
|
|
use SilverStripe\BehatExtension\Context\SilverStripeContext; |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
if (!class_exists(SilverStripeContext::class)) { |
|
8
|
|
|
return; |
|
9
|
|
|
} |
|
10
|
|
|
class FeatureContext extends SilverStripeContext |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @Then I should see a list of blocks |
|
14
|
|
|
*/ |
|
15
|
|
|
public function iShouldSeeAListOfBlocks() |
|
16
|
|
|
{ |
|
17
|
|
|
assertNotEmpty($this->getBlocks()); |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @Then I should see block :position |
|
22
|
|
|
*/ |
|
23
|
|
|
public function iShouldSeeBlock($position) |
|
24
|
|
|
{ |
|
25
|
|
|
assertNotNull($this->getSpecificBlock($position)); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @When I click on block :position |
|
30
|
|
|
*/ |
|
31
|
|
|
public function iClickOnBlock($position) |
|
32
|
|
|
{ |
|
33
|
|
|
$block = $this->getSpecificBlock($position); |
|
34
|
|
|
assertNotNull($block, 'Block ' . $position . ' was not found in the page.'); |
|
35
|
|
|
$block->click(); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @Then I should see :text as the title for block :position |
|
40
|
|
|
*/ |
|
41
|
|
|
public function iShouldSeeAsTheTitleForBlock($text, $position) |
|
42
|
|
|
{ |
|
43
|
|
|
$block = $this->getSpecificBlock($position); |
|
44
|
|
|
$title = $block->find('css', '.element-editor-header__title'); |
|
45
|
|
|
assertEquals($title->getText(), $text); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @Then I should see :text as the summary for block :position |
|
50
|
|
|
*/ |
|
51
|
|
|
public function iShouldSeeAsTheSummaryForBlock($text, $position) |
|
52
|
|
|
{ |
|
53
|
|
|
$block = $this->getSpecificBlock($position); |
|
54
|
|
|
$summary = $block->find('css', '.element-editor-summary__content'); |
|
55
|
|
|
assertEquals($summary->getText(), $text); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @Then I should see the archive button for block :position |
|
60
|
|
|
* |
|
61
|
|
|
* @param int $position |
|
62
|
|
|
*/ |
|
63
|
|
|
public function iShouldSeeArchiveButtonForBlock($position) |
|
64
|
|
|
{ |
|
65
|
|
|
$this->getArchiveButton($position); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @When I hover over block :position |
|
70
|
|
|
* |
|
71
|
|
|
* @param int $position |
|
72
|
|
|
*/ |
|
73
|
|
|
public function iHoverOverBlock($position) |
|
74
|
|
|
{ |
|
75
|
|
|
$block = $this->getSpecificBlock($position); |
|
76
|
|
|
assertNotNull($block, 'Block ' . $position . ' was not found in the page.'); |
|
77
|
|
|
$block->mouseOver(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @When I hover over the icon of block :position |
|
82
|
|
|
* |
|
83
|
|
|
* @param int $position |
|
84
|
|
|
*/ |
|
85
|
|
|
public function iHoverOverTheIconOfBlock($position) |
|
86
|
|
|
{ |
|
87
|
|
|
$block = $this->getSpecificBlock($position); |
|
88
|
|
|
assertNotNull($block, 'Block ' . $position . ' was not found in the page.'); |
|
89
|
|
|
$icon = $block->find( |
|
90
|
|
|
'css', |
|
91
|
|
|
'.element-editor-header .element-editor-header__info .element-editor-header__icon-container' |
|
92
|
|
|
); |
|
93
|
|
|
$icon->mouseOver(); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Returns the blocks from the element editor |
|
98
|
|
|
* |
|
99
|
|
|
* @param string $modifier Optional CSS selector modifier |
|
100
|
|
|
* @return NodeElement[] |
|
101
|
|
|
*/ |
|
102
|
|
|
protected function getBlocks($modifier = '') |
|
103
|
|
|
{ |
|
104
|
|
|
// Wait for the list to be visible |
|
105
|
|
|
$this->getSession()->wait(3000, 'window.jQuery(".element-editor .elemental-editor__list").length > 0'); |
|
106
|
|
|
$blocks = $this->getSession() |
|
107
|
|
|
->getPage() |
|
108
|
|
|
->findAll('css', '.elemental-editor__list .element-editor__element' . $modifier); |
|
109
|
|
|
return $blocks; |
|
110
|
|
|
} |
|
111
|
|
|
/** |
|
112
|
|
|
* Returns the selected element |
|
113
|
|
|
* |
|
114
|
|
|
* @param int $position |
|
115
|
|
|
* @return NodeElement |
|
116
|
|
|
*/ |
|
117
|
|
|
protected function getSpecificBlock($position) |
|
118
|
|
|
{ |
|
119
|
|
|
$blocks = $this->getBlocks(); |
|
120
|
|
|
/** @var NodeElement $block */ |
|
121
|
|
|
if ($blocks[$position - 1] !== false) { |
|
|
|
|
|
|
122
|
|
|
return $blocks[$position - 1]; |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* Returns the archive button for a specific block |
|
128
|
|
|
* |
|
129
|
|
|
* @param $position |
|
130
|
|
|
* @return NodeElement |
|
131
|
|
|
*/ |
|
132
|
|
|
protected function getArchiveButton($position) |
|
133
|
|
|
{ |
|
134
|
|
|
$block = $this->getSpecificBlock($position); |
|
135
|
|
|
assertNotNull($block, 'Block ' . $position . ' was not found in the page.'); |
|
136
|
|
|
|
|
137
|
|
|
$button = $block->find('css', '.element-editor__actions-archive'); |
|
138
|
|
|
assertNotNull($button, 'Archive button not found'); |
|
139
|
|
|
|
|
140
|
|
|
return $button; |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths