-
Notifications
You must be signed in to change notification settings - Fork 95
Expand file tree
/
Copy pathplugin-check-remote.feature
More file actions
90 lines (82 loc) · 2.86 KB
/
plugin-check-remote.feature
File metadata and controls
90 lines (82 loc) · 2.86 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
Feature: Test that the WP-CLI plugin check command works with remote ZIP url.
Background:
Given a WP install with the Plugin Check plugin
Scenario: Test with invalid remote ZIP url
When I try the WP-CLI command `plugin check https://example.com/non-existent-file.zip`
Then STDERR should be:
"""
Error: Downloading the zip file failed.
"""
And STDOUT should be empty
@require-wp-6.4
Scenario: Test with valid remote ZIP url but error in extracting
Given a wp-content/mu-plugins/custom-unzip.php file:
"""
<?php
/**
* Plugin Name: Custom Unzip
*/
add_filter( 'unzip_file', function() {
return new WP_Error( 'custom_unzip_error', 'Something bad happened while extracting the zip file.' );
} );
"""
When I try the WP-CLI command `plugin check https://github.com/WordPress/plugin-check/raw/trunk/tests/behat/testdata/foo-bar-wp.zip`
Then STDERR should be:
"""
Error: Something bad happened while extracting the zip file.
"""
And STDOUT should be empty
Scenario: Test with valid ZIP
When I run the WP-CLI command `plugin check https://github.com/WordPress/plugin-check/raw/trunk/tests/behat/testdata/foo-bar-wp.zip --fields=code,type --format=csv`
Then STDOUT should contain:
"""
FILE: foo-bar-wp.php
"""
And STDOUT should contain:
"""
WordPress.WP.AlternativeFunctions.rand_mt_rand,ERROR
"""
And STDOUT should contain:
"""
WordPress.Security.EscapeOutput.OutputNotEscaped,ERROR
"""
And STDOUT should contain:
"""
outdated_tested_upto_header,ERROR
"""
And STDOUT should not contain:
"""
hello.php
"""
And STDERR should be empty
Scenario: Test with valid ZIP and extra wporgapi parameter
When I run `wp eval 'echo get_temp_dir();'`
Then STDOUT should not be empty
And save STDOUT as {TEMP_DIR}
When I run the WP-CLI command `plugin check https://github.com/WordPress/plugin-check/raw/trunk/tests/behat/testdata/foo-bar-wp.zip#wporgapi:https://raw.githubusercontent.com/WordPress/plugin-check/trunk/tests/behat/testdata/user-detail.json --fields=code,type --format=csv`
Then STDOUT should contain:
"""
WordPress.WP.AlternativeFunctions.rand_mt_rand,ERROR
"""
And STDOUT should contain:
"""
WordPress.Security.EscapeOutput.OutputNotEscaped,ERROR
"""
And STDOUT should contain:
"""
outdated_tested_upto_header,ERROR
"""
And STDOUT should not contain:
"""
hello.php
"""
And STDERR should be empty
And the {TEMP_DIR}/plugin-check/plugin-info.json file should exist
And the {TEMP_DIR}/plugin-check/plugin-info.json file should be:
"""
{
"username": "johndoe",
"first_name": "John",
"last_name": "Doe"
}
"""