You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 784c78e
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: features/site.feature
+193Lines changed: 193 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1087,6 +1087,199 @@ Feature: Manage sites in a multisite installation
1087
1087
1
1088
1088
"""
1089
1089
1090
+
Scenario: List sites using the WP_Site_Query arguments that take a list
1091
+
Given a WP multisite install
1092
+
1093
+
When I run `wp site create --slug=alpha --porcelain`
1094
+
Then STDOUT should be a number
1095
+
And save STDOUT as {ALPHA_ID}
1096
+
1097
+
When I run `wp site create --slug=beta --porcelain`
1098
+
Then STDOUT should be a number
1099
+
And save STDOUT as {BETA_ID}
1100
+
1101
+
# WP_Site_Query reads these through is_array(), so before they were split
1102
+
# they were skipped without a word and every site came back.
1103
+
When I run `wp site list --path__in=/alpha/,/beta/ --field=blog_id`
1104
+
Then STDOUT should be:
1105
+
"""
1106
+
{ALPHA_ID}
1107
+
{BETA_ID}
1108
+
"""
1109
+
1110
+
When I run `wp site list --path__not_in=/alpha/,/beta/ --field=blog_id`
1111
+
Then STDOUT should be:
1112
+
"""
1113
+
1
1114
+
"""
1115
+
1116
+
When I run `wp site list --domain__in=example.com --format=count`
1117
+
Then STDOUT should be:
1118
+
"""
1119
+
3
1120
+
"""
1121
+
1122
+
When I run `wp site list --domain__not_in=example.com --format=count`
1123
+
Then STDOUT should be:
1124
+
"""
1125
+
0
1126
+
"""
1127
+
1128
+
# --search_columns reaches array_intersect(), which is fatal on a string.
1129
+
When I run `wp site list --search=alpha --search_columns=path --field=blog_id`
1130
+
Then STDOUT should be:
1131
+
"""
1132
+
{ALPHA_ID}
1133
+
"""
1134
+
1135
+
When I run `wp site list --search=alpha --search_columns=domain --format=count`
1136
+
Then STDOUT should be:
1137
+
"""
1138
+
0
1139
+
"""
1140
+
1141
+
# The remaining newly documented filters.
1142
+
When I run `wp site list --network__in=1 --format=count`
1143
+
Then STDOUT should be:
1144
+
"""
1145
+
3
1146
+
"""
1147
+
1148
+
When I run `wp site list --network__not_in=1 --format=count`
1149
+
Then STDOUT should be:
1150
+
"""
1151
+
0
1152
+
"""
1153
+
1154
+
When I run `wp site list --lang__in=0 --format=count`
1155
+
Then STDOUT should be:
1156
+
"""
1157
+
3
1158
+
"""
1159
+
1160
+
When I run `wp site list --ID={ALPHA_ID} --field=blog_id`
1161
+
Then STDOUT should be:
1162
+
"""
1163
+
{ALPHA_ID}
1164
+
"""
1165
+
1166
+
When I run `wp site list --network_id=1 --format=count`
1167
+
Then STDOUT should be:
1168
+
"""
1169
+
3
1170
+
"""
1171
+
1172
+
# --date_query is a nested array, so it is given as JSON.
1173
+
When I run `wp site list --date_query='[{"column":"registered","after":"1999-01-01"}]' --format=count`
1174
+
Then STDOUT should be:
1175
+
"""
1176
+
3
1177
+
"""
1178
+
1179
+
When I run `wp site list --date_query='[{"column":"registered","before":"1999-01-01"}]' --format=count`
1180
+
Then STDOUT should be:
1181
+
"""
1182
+
0
1183
+
"""
1184
+
1185
+
# --registered narrows a --date_query of its own rather than replacing it. The
1186
+
# date on its own has to match first, or the pair below would prove nothing.
1187
+
When I run `wp site list --blog_id={ALPHA_ID} --field=registered`
1188
+
Then save STDOUT as {ALPHA_REGISTERED}
1189
+
1190
+
When I run `wp site list --blog_id={ALPHA_ID} --registered='{ALPHA_REGISTERED}' --format=count`
1191
+
Then STDOUT should be:
1192
+
"""
1193
+
1
1194
+
"""
1195
+
1196
+
When I run `wp site list --blog_id={ALPHA_ID} --date_query='[{"column":"registered","before":"1999-01-01"}]' --registered='{ALPHA_REGISTERED}' --format=count`
1197
+
Then STDOUT should be:
1198
+
"""
1199
+
0
1200
+
"""
1201
+
1202
+
# The relation of a given --date_query governs only its own clauses. Appending
1203
+
# to the same list would let an 'OR' reach the clause --registered adds and
1204
+
# match a site that satisfies neither half of what was asked for.
1205
+
When I run `wp site list --blog_id={ALPHA_ID} --date_query='{"relation":"OR","0":{"column":"registered","before":"1999-01-01"},"1":{"column":"registered","before":"1998-01-01"}}' --registered='{ALPHA_REGISTERED}' --format=count`
1206
+
Then STDOUT should be:
1207
+
"""
1208
+
0
1209
+
"""
1210
+
1211
+
When I run `wp site list --blog_id={ALPHA_ID} --field=last_updated`
1212
+
Then save STDOUT as {ALPHA_UPDATED}
1213
+
1214
+
When I run `wp site list --blog_id={ALPHA_ID} --last_updated='{ALPHA_UPDATED}' --format=count`
1215
+
Then STDOUT should be:
1216
+
"""
1217
+
1
1218
+
"""
1219
+
1220
+
When I run `wp site list --blog_id={ALPHA_ID} --date_query='{"relation":"OR","0":{"column":"last_updated","before":"1999-01-01"},"1":{"column":"last_updated","before":"1998-01-01"}}' --last_updated='{ALPHA_UPDATED}' --format=count`
1221
+
Then STDOUT should be:
1222
+
"""
1223
+
0
1224
+
"""
1225
+
1226
+
When I try `wp site list --meta_query=notjson`
1227
+
Then STDERR should contain:
1228
+
"""
1229
+
Invalid JSON passed to --meta_query.
1230
+
"""
1231
+
And the return code should be 1
1232
+
1233
+
When I try `wp site list --date_query=notjson`
1234
+
Then STDERR should contain:
1235
+
"""
1236
+
Invalid JSON passed to --date_query.
1237
+
"""
1238
+
And the return code should be 1
1239
+
1240
+
# WP_Site_Query gained the meta_* parameters, and multisite gained the site meta
1241
+
# table they read, in WordPress 5.1.
1242
+
@require-wp-5.1
1243
+
Scenario: Filter the site list by site meta
1244
+
Given a WP multisite install
1245
+
1246
+
When I run `wp site create --slug=alpha --porcelain`
1247
+
Then STDOUT should be a number
1248
+
And save STDOUT as {ALPHA_ID}
1249
+
1250
+
When I run `wp site create --slug=beta --porcelain`
1251
+
Then STDOUT should be a number
1252
+
And save STDOUT as {BETA_ID}
1253
+
1254
+
When I run `wp site meta add {ALPHA_ID} colour blue`
1255
+
Then STDOUT should not be empty
1256
+
1257
+
When I run `wp site list --meta_key=colour --meta_value=blue --field=blog_id`
1258
+
Then STDOUT should be:
1259
+
"""
1260
+
{ALPHA_ID}
1261
+
"""
1262
+
1263
+
When I run `wp site list --meta_key=colour --meta_value=red --format=count`
1264
+
Then STDOUT should be:
1265
+
"""
1266
+
0
1267
+
"""
1268
+
1269
+
# --meta_query is a nested array, so it is given as JSON.
1270
+
When I run `wp site list --meta_query='[{"key":"colour","value":"blue"}]' --field=blog_id`
1271
+
Then STDOUT should be:
1272
+
"""
1273
+
{ALPHA_ID}
1274
+
"""
1275
+
1276
+
When I run `wp site list --meta_query='[{"key":"colour","compare":"NOT EXISTS"}]' --field=blog_id`
1277
+
Then STDOUT should be:
1278
+
"""
1279
+
1
1280
+
{BETA_ID}
1281
+
"""
1282
+
1090
1283
Scenario: Existing site list filters keep working against WP_Site_Query
0 commit comments