-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathSelectOptionOrderCest.php
More file actions
210 lines (188 loc) · 5.38 KB
/
SelectOptionOrderCest.php
File metadata and controls
210 lines (188 loc) · 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
namespace Tests\EndToEnd;
use Tests\Support\EndToEndTester;
/**
* Tests for the order of resources in select elements.
*
* @since 3.3.0
*/
class SelectOptionOrderCest
{
/**
* Run common actions before running the test functions in this class.
*
* @since 3.3.0
*
* @param EndToEndTester $I Tester.
*/
public function _before(EndToEndTester $I)
{
// Activate and Setup Kit plugin.
$I->activateKitPlugin($I);
$I->activateThirdPartyPlugin($I, 'classic-editor');
$I->setupKitPlugin($I);
$I->setupKitPluginResources($I);
// Create Custom Post Types using the Custom Post Type UI Plugin.
$I->registerCustomPostTypes($I);
}
/**
* Test that the order of the Form resources are alphabetical, with the Default and None options prepending the Forms,
* when adding a new Category.
*
* @since 3.3.0
*
* @param EndToEndTester $I Tester.
*/
public function testFormSelectOrderOnAddCategory(EndToEndTester $I)
{
// Navigate to Posts > Categories.
$I->amOnAdminPage('edit-tags.php?taxonomy=category');
// Check the order of the Form resources are alphabetical, with the Default option prepending the Forms.
$I->checkSelectFormOptionOrder(
$I,
selectElement: '#wp-convertkit-form',
prependOptions: [
'Default',
'None',
]
);
}
/**
* Test that the order of the Form resources are alphabetical, with the Default and None options prepending the Forms,
* when editing a Category.
*
* @since 3.3.0
*
* @param EndToEndTester $I Tester.
*/
public function testFormSelectOrderOnEditCategory(EndToEndTester $I)
{
// Create Category.
$termID = $I->haveTermInDatabase( 'Kit: Edit Category', 'category' );
$termID = $termID[0];
// Edit the Term.
$I->amOnAdminPage('term.php?taxonomy=category&tag_ID=' . $termID);
// Check the order of the Form resources are alphabetical, with the Default option prepending the Forms.
$I->checkSelectFormOptionOrder(
$I,
selectElement: '#wp-convertkit-form',
prependOptions: [
'Default',
'None',
]
);
}
/**
* Test that the order of the Form resources are alphabetical, with the Default and None options prepending the Forms,
* when Pages, Posts and Custom Post Types (CPTs) are added.
*
* @since 3.3.0
*
* @param EndToEndTester $I Tester.
*/
public function testFormSelectOrderOnPostTypes(EndToEndTester $I)
{
// Navigate to Pages > Add New.
$I->amOnAdminPage('post-new.php?post_type=page');
// Check the order of the Form resources are alphabetical, with the Default and None options prepending the Forms.
$I->checkSelectFormOptionOrder(
$I,
selectElement: '#wp-convertkit-form',
prependOptions: [
'Default',
'None',
]
);
// Check the order of the Landing Page resources are alphabetical, with the None option prepending the Landing Pages.
$I->checkSelectLandingPageOptionOrder(
$I,
selectElement: '#wp-convertkit-landing_page',
prependOptions: [
'None',
]
);
// Check the order of the Tag resources are alphabetical, with the None option prepending the Tags.
$I->checkSelectTagOptionOrder(
$I,
selectElement: '#wp-convertkit-tag',
prependOptions: [
'None',
]
);
// Navigate to Posts > Add New.
$I->amOnAdminPage('post-new.php?post_type=post');
// Check the order of the Form resources are alphabetical, with the Default and None options prepending the Forms.
$I->checkSelectFormOptionOrder(
$I,
selectElement: '#wp-convertkit-form',
prependOptions: [
'Default',
'None',
]
);
// Check the order of the Tag resources are alphabetical, with the None option prepending the Tags.
$I->checkSelectTagOptionOrder(
$I,
selectElement: '#wp-convertkit-tag',
prependOptions: [
'None',
]
);
// Navigate to Custom Post Type > Add New.
$I->amOnAdminPage('post-new.php?post_type=article');
// Check the order of the Form resources are alphabetical, with the Default and None options prepending the Forms.
$I->checkSelectFormOptionOrder(
$I,
selectElement: '#wp-convertkit-form',
prependOptions: [
'Default',
'None',
]
);
// Check the order of the Tag resources are alphabetical, with the None option prepending the Tags.
$I->checkSelectTagOptionOrder(
$I,
selectElement: '#wp-convertkit-tag',
prependOptions: [
'None',
]
);
}
/**
* Test that the order of the Form resources are alphabetical, with the None option prepending the Forms,
* when the Plugin Settings General screen is viewed.
*
* @since 3.3.0
*
* @param EndToEndTester $I Tester.
*/
public function testFormSelectOrderOnPluginSettingsGeneralScreen(EndToEndTester $I)
{
// Go to the Plugin's Settings Screen.
$I->loadKitSettingsGeneralScreen($I);
// Check the order of the Form resources are alphabetical, with 'None' as the first choice.
$I->checkSelectFormOptionOrder(
$I,
selectElement: '#_wp_convertkit_settings_page_form',
prependOptions: [
'None',
]
);
}
/**
* Deactivate and reset Plugin(s) after each test, if the test passes.
* We don't use _after, as this would provide a screenshot of the Plugin
* deactivation and not the true test error.
*
* @since 3.3.0
*
* @param EndToEndTester $I Tester.
*/
public function _passed(EndToEndTester $I)
{
$I->unregisterCustomPostTypes($I);
$I->deactivateThirdPartyPlugin($I, 'classic-editor');
$I->deactivateKitPlugin($I);
$I->resetKitPlugin($I);
}
}