-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathcli.feature
More file actions
110 lines (94 loc) · 3.3 KB
/
cli.feature
File metadata and controls
110 lines (94 loc) · 3.3 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
Feature: `wp cli` tasks
@less-than-php-8
Scenario: Ability to detect a WP-CLI registered command
Given a WP installation
# Allow for composer/ca-bundle using `openssl_x509_parse()` which throws PHP warnings on old versions of PHP.
When I try `wp package install wp-cli/scaffold-package-command`
And I run `wp cli has-command scaffold package`
Then the return code should be 0
# Allow for composer/ca-bundle using `openssl_x509_parse()` which throws PHP warnings on old versions of PHP.
When I try `wp package uninstall wp-cli/scaffold-package-command`
And I try `wp cli has-command scaffold package`
Then the return code should be 1
Scenario: Ability to detect a command which is registered by plugin
Given a WP installation
And a wp-content/mu-plugins/test-cli.php file:
"""
<?php
// Plugin Name: Test CLI Help
class TestCommand {
}
WP_CLI::add_command( 'test-command', 'TestCommand' );
"""
When I run `wp cli has-command test-command`
Then the return code should be 0
Scenario: Dump the list of global parameters with values
Given a WP installation
When I run `wp cli param-dump --with-values | grep -o '"current":' | uniq -c | tr -d ' '`
Then STDOUT should be:
"""
19"current":
"""
And STDERR should be empty
And the return code should be 0
Scenario: Checking whether a global configuration parameter exists or not
Given a WP installation
And a custom-cmd.php file:
"""
<?php
class Custom_Command extends WP_CLI_Command {
/**
* Custom command to validate a global configuration does exist or not.
*
* <config>
* : Configuration parameter name to check for.
*
* @when after_wp_load
*/
public function __invoke( $args ) {
if ( WP_CLI::has_config( $args[0] ) ) {
WP_CLI::log( "Global configuration '{$args[0]}' does exist." );
} else {
WP_CLI::log( "Global configuration '{$args[0]}' does not exist." );
}
}
}
WP_CLI::add_command( 'custom-command', 'Custom_Command' );
"""
When I run `wp --require=custom-cmd.php custom-command url`
Then STDOUT should be:
"""
Global configuration 'url' does exist.
"""
When I run `wp --require=custom-cmd.php custom-command dummy`
Then STDOUT should be:
"""
Global configuration 'dummy' does not exist.
"""
Scenario: Dump command list with alias included
Given a WP installation
And a custom-cmd-with-alias.php file:
"""
<?php
class Custom_Alias_Command extends WP_CLI_Command {
/**
* Custom command with an alias.
*
* @alias custom-alias
* @when after_wp_load
*/
public function __invoke( $args ) {
WP_CLI::success( 'Command executed.' );
}
}
WP_CLI::add_command( 'custom-command-with-alias', 'Custom_Alias_Command' );
"""
When I run `wp --require=custom-cmd-with-alias.php cli cmd-dump`
Then STDOUT should contain:
"""
"name":"custom-command-with-alias"
"""
And STDOUT should contain:
"""
"alias":"custom-alias"
"""