|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Acquia\DFExtension\Context; |
|
4
|
|
|
|
|
5
|
|
|
use Acquia\LightningExtension\AwaitTrait; |
|
6
|
|
|
use Acquia\LightningExtension\Context\PanelsInPlaceContext; |
|
7
|
|
|
use Acquia\LightningExtension\Context\UtilityContext; |
|
8
|
|
|
use Drupal\DrupalExtension\Context\DrupalSubContextBase; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* A context with miscellaneous helpers. |
|
12
|
|
|
*/ |
|
13
|
|
|
class ModerationSidebarContext extends DrupalSubContextBase { |
|
14
|
|
|
|
|
15
|
|
|
use AwaitTrait; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Opens the moderation sidebar. |
|
19
|
|
|
* |
|
20
|
|
|
* @When I open the moderation sidebar |
|
21
|
|
|
*/ |
|
22
|
|
View Code Duplication |
public function openModerationSidebar() { |
|
|
|
|
|
|
23
|
|
|
$assert = $this->assertSession(); |
|
24
|
|
|
|
|
25
|
|
|
// Assert that the tab exists... |
|
26
|
|
|
$link = $assert->elementExists( |
|
27
|
|
|
'named', |
|
28
|
|
|
['link', 'Tasks'], |
|
29
|
|
|
$assert->elementExists('css', '.moderation-sidebar-toolbar-tab') |
|
30
|
|
|
); |
|
31
|
|
|
|
|
32
|
|
|
// ...but only open it if not already active. |
|
33
|
|
|
if ($link->hasClass('sidebar-open') == FALSE) { |
|
|
|
|
|
|
34
|
|
|
$link->click(); |
|
35
|
|
|
$this->awaitAjax(); |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Closes the moderation sidebar. |
|
41
|
|
|
* |
|
42
|
|
|
* @When I close the moderation sidebar |
|
43
|
|
|
*/ |
|
44
|
|
View Code Duplication |
public function closeModerationSidebar() { |
|
|
|
|
|
|
45
|
|
|
$assert = $this->assertSession(); |
|
46
|
|
|
|
|
47
|
|
|
// Assert that the tab exists... |
|
48
|
|
|
$link = $assert->elementExists( |
|
49
|
|
|
'named', |
|
50
|
|
|
['link', 'Tasks'], |
|
51
|
|
|
$assert->elementExists('css', '.moderation-sidebar-toolbar-tab') |
|
52
|
|
|
); |
|
53
|
|
|
|
|
54
|
|
|
// ...but only open it if already active. |
|
55
|
|
|
if ($link->hasClass('sidebar-open') == TRUE) { |
|
|
|
|
|
|
56
|
|
|
$link->click(); |
|
57
|
|
|
$this->awaitAjax(); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Selects a moderation sidebar item. |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $item |
|
65
|
|
|
* The moderation sidebar item to select. |
|
66
|
|
|
* |
|
67
|
|
|
* @Given I select the :item moderation sidebar button |
|
68
|
|
|
*/ |
|
69
|
|
View Code Duplication |
public function selectModerationSidebarButton($item) { |
|
|
|
|
|
|
70
|
|
|
$assert = $this->assertSession(); |
|
71
|
|
|
|
|
72
|
|
|
// Assert that the tab exists... |
|
73
|
|
|
$link = $assert->elementExists( |
|
74
|
|
|
'named', |
|
75
|
|
|
['button', $item], |
|
76
|
|
|
$assert->elementExists('css', '.moderation-sidebar-actions') |
|
77
|
|
|
); |
|
78
|
|
|
|
|
79
|
|
|
$link->click(); |
|
80
|
|
|
$this->awaitAjax(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Selects a moderation sidebar item. |
|
85
|
|
|
* |
|
86
|
|
|
* @param string $item |
|
87
|
|
|
* The moderation sidebar item to select. |
|
88
|
|
|
* |
|
89
|
|
|
* @Given I select the :item moderation sidebar link |
|
90
|
|
|
*/ |
|
91
|
|
View Code Duplication |
public function selectModerationSidebarLink($item) { |
|
|
|
|
|
|
92
|
|
|
$assert = $this->assertSession(); |
|
93
|
|
|
|
|
94
|
|
|
// Assert that the tab exists... |
|
95
|
|
|
$link = $assert->elementExists( |
|
96
|
|
|
'named', |
|
97
|
|
|
['link', $item], |
|
98
|
|
|
$assert->elementExists('css', '.moderation-sidebar-actions') |
|
99
|
|
|
); |
|
100
|
|
|
|
|
101
|
|
|
$link->click(); |
|
102
|
|
|
$this->awaitAjax(); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.