-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathcheck.feature
More file actions
233 lines (201 loc) · 6.27 KB
/
check.feature
File metadata and controls
233 lines (201 loc) · 6.27 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
Feature: Basic check usage
# Message "Updating to WordPress' newest minor version is strongly recommended." of type "error" appears.
@broken @require-mysql
Scenario: Use --spotlight to focus on warnings and errors
Given a WP install
And I run `wp plugin activate --all`
And I run `wp plugin update --all`
And I run `wp theme update --all`
When I run `wp doctor list --format=count`
Then save STDOUT as {CHECK_COUNT}
When I run `wp doctor check --all --spotlight`
Then STDOUT should be:
"""
Success: All {CHECK_COUNT} checks report 'success'.
"""
When I run `wp doctor check plugin-deactivated --spotlight`
Then STDOUT should be:
"""
Success: The check reports 'success'.
"""
When I run `wp doctor check --all --spotlight --format=json`
Then STDOUT should be:
"""
[]
"""
Scenario: Filter check results
Given a WP install
# Akismet requires a newer WordPress version, but we don't really need it here.
And I run `wp plugin uninstall akismet`
And I run `wp plugin activate --all`
And I run `wp plugin update --all`
And I run `wp theme update --all`
And I run `wp option update blog_public 0`
And a wp-content/uploads/foo.php file:
"""
<?php
// Simple PHP file.
"""
When I try `wp doctor check option-blog-public php-in-upload --format=csv --fields=name,status`
Then STDOUT should contain:
"""
php-in-upload,warning
"""
And STDOUT should contain:
"""
option-blog-public,error
"""
And the return code should be 1
When I try `wp doctor check option-blog-public php-in-upload --format=csv --fields=name,status --status=error`
Then STDOUT should contain:
"""
option-blog-public,error
"""
And STDOUT should not contain:
"""
php-in-upload,warning
"""
And the return code should be 1
Scenario: Use --spotlight to view warnings and errors
Given a WP install
And I run `wp option update blog_public 0`
And a wp-content/plugins/foo.php file:
"""
<?php
// Plugin Name: Foo Plugin
wp_cache_flush();
"""
When I try `wp doctor check option-blog-public php-in-upload cache-flush --format=csv --fields=name,status`
Then STDOUT should be:
"""
name,status
option-blog-public,error
php-in-upload,success
cache-flush,warning
"""
And the return code should be 1
When I run `wp doctor check php-in-upload plugin-active-count --spotlight`
Then STDOUT should be:
"""
Success: All 2 checks report 'success'.
"""
And the return code should be 0
When I run `wp doctor check plugin-active-count --spotlight`
Then STDOUT should be:
"""
Success: The check reports 'success'.
"""
And the return code should be 0
When I try `wp doctor check option-blog-public php-in-upload cache-flush --spotlight --format=csv --fields=name,status`
Then STDOUT should be:
"""
name,status
option-blog-public,error
cache-flush,warning
"""
And the return code should be 1
When I run `wp doctor check php-in-upload --spotlight --format=json`
Then STDOUT should be:
"""
[]
"""
And the return code should be 0
Scenario: Error when no checks nor --all are provided
Given a WP install
When I try `wp doctor check`
Then STDERR should be:
"""
Error: Please specify one or more checks, or use --all.
"""
And the return code should be 1
Scenario: Error when an invalid check is provided.
Given a WP install
And a config.yml file:
"""
"""
When I try `wp doctor check invalid-check`
Then STDERR should be:
"""
Error: Invalid check.
"""
And the return code should be 1
When I try `wp doctor check invalid-check invalid-check2`
Then STDERR should be:
"""
Error: Invalid checks.
"""
And the return code should be 1
When I try `wp doctor check --all --config=config.yml`
Then STDERR should be:
"""
Error: No checks registered.
"""
And the return code should be 1
Scenario: List all default checks
Given a WP install
When I run `wp doctor list --fields=name`
Then STDOUT should be a table containing rows:
| name |
| autoload-options-size |
| core-update |
| core-verify-checksums |
| plugin-deactivated |
| plugin-update |
| theme-update |
Scenario: Discard redirects emitted by WordPress
Given a WP install
And a wp-content/mu-plugins/redirect.php file:
"""
<?php
add_action( 'template_redirect', function(){
wp_redirect( 'http://google.com' );
exit;
});
"""
When I try `wp doctor check autoload-options-size --fields=name,status`
Then STDERR should contain:
"""
Warning: Incomplete check execution. Some code is trying to do a URL redirect. Backtrace:
"""
And STDOUT should be a table containing rows:
| name | status |
| autoload-options-size | success |
Scenario: Use --debug=doctor flag to see check progress
Given a WP install
When I try `wp doctor check autoload-options-size --debug=doctor`
Then STDERR should contain:
"""
Running check: autoload-options-size
"""
And STDERR should contain:
"""
Status:
"""
Scenario: Use --debug=doctor flag with multiple checks
Given a WP install
When I try `wp doctor check autoload-options-size plugin-deactivated --debug=doctor`
Then STDERR should contain:
"""
Running check: autoload-options-size
"""
And STDERR should contain:
"""
Running check: plugin-deactivated
"""
Scenario: Use --debug=doctor flag with file checks
Given a WP install
And a wp-content/plugins/foo.php file:
"""
<?php
// Plugin Name: Foo Plugin
wp_cache_flush();
"""
When I try `wp doctor check cache-flush --debug=doctor`
Then STDERR should contain:
"""
Scanning filesystem for file checks...
"""
And STDERR should contain:
"""
Running check: cache-flush
"""