/
plugin-check.feature
110 lines (96 loc) · 3.42 KB
/
plugin-check.feature
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
Feature: Test that the WP-CLI command works.
Scenario: Check a non-existent plugin
Given a WP install with the Plugin Check plugin
When I try the WP-CLI command `plugin check foo-bar`
Then STDERR should contain:
"""
Plugin with slug foo-bar is not installed.
"""
Scenario: Check Hello Dolly
Given a WP install with the Plugin Check plugin
When I run the WP-CLI command `plugin check hello.php`
Then STDOUT should contain:
"""
mt_rand() is discouraged.
"""
And STDOUT should not contain:
"""
no_plugin_readme
"""
And STDOUT should not contain:
"""
trademarked_term
"""
And STDOUT should contain:
"""
All output should be run through an escaping function
"""
When I run the WP-CLI command `plugin check hello.php --format=csv`
Then STDOUT should contain:
"""
line,column,type,code,message
49,31,ERROR,WordPress.WP.AlternativeFunctions.rand_mt_rand,"mt_rand() is discouraged. Use the far less predictable wp_rand() instead."
"""
When I run the WP-CLI command `plugin check hello.php --format=csv --fields=line,column,code`
Then STDOUT should contain:
"""
line,column,code
49,31,WordPress.WP.AlternativeFunctions.rand_mt_rand
"""
When I run the WP-CLI command `plugin check hello.php --format=json`
Then STDOUT should contain:
"""
{"line":49,"column":31,"type":"ERROR","code":"WordPress.WP.AlternativeFunctions.rand_mt_rand","message":"mt_rand() is discouraged. Use the far less predictable wp_rand() instead."}
"""
When I run the WP-CLI command `plugin check hello.php --ignore-errors`
Then STDOUT should be empty
When I run the WP-CLI command `plugin check hello.php --ignore-warnings`
Then STDOUT should not be empty
When I run the WP-CLI command `plugin check hello.php --checks=plugin_review_phpcs`
Then STDOUT should contain:
"""
WordPress.WP.AlternativeFunctions.rand_mt_rand
"""
And STDOUT should not contain:
"""
WordPress.Security.EscapeOutput.OutputNotEscaped
"""
When I run the WP-CLI command `plugin check hello.php --exclude-checks=late_escaping`
Then STDOUT should not contain:
"""
WordPress.Security.EscapeOutput.OutputNotEscaped
"""
And STDOUT should contain:
"""
WordPress.WP.AlternativeFunctions.rand_mt_rand
"""
When I run the WP-CLI command `plugin check hello.php --categories=security`
Then STDOUT should contain:
"""
WordPress.Security.EscapeOutput.OutputNotEscaped
"""
And STDOUT should not contain:
"""
WordPress.WP.AlternativeFunctions.rand_mt_rand
"""
When I run the WP-CLI command `plugin check hello.php --checks=plugin_review_phpcs,late_escaping --exclude-checks=late_escaping`
Then STDOUT should contain:
"""
WordPress.WP.AlternativeFunctions.rand_mt_rand
"""
And STDOUT should not contain:
"""
WordPress.Security.EscapeOutput.OutputNotEscaped
"""
Scenario: Check Akismet
Given a WP install with the Plugin Check plugin
When I run the WP-CLI command `plugin check akismet`
Then STDOUT should contain:
"""
FILE: views/config.php
"""
When I run the WP-CLI command `plugin check akismet --exclude-directories=views`
Then STDOUT should not contain:
"""
FILE: views/config.php
"""