-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathshell.feature
More file actions
115 lines (96 loc) · 2.51 KB
/
shell.feature
File metadata and controls
115 lines (96 loc) · 2.51 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
Feature: WordPress REPL
Scenario: Blank session
Given a WP install
When I run `wp shell < /dev/null`
And I run `wp shell --basic < /dev/null`
Then STDOUT should be empty
Scenario: Persistent environment
Given a WP install
And a session file:
"""
function is_empty_string( $str ) { return strlen( $str ) == 0; }
$a = get_option('home');
is_empty_string( $a );
"""
When I run `wp shell --basic < session`
Then STDOUT should contain:
"""
bool(false)
"""
Scenario: Multiline support (basic)
Given a WP install
And a session file:
"""
function is_empty_string( $str ) { \
return strlen( $str ) == 0; \
}
function_exists( 'is_empty_string' );
"""
When I run `wp shell --basic < session`
Then STDOUT should contain:
"""
bool(true)
"""
Scenario: Use custom shell path
Given a WP install
And a session file:
"""
return true;
"""
When I try `WP_CLI_CUSTOM_SHELL=/nonsense/path wp shell --basic < session`
Then STDOUT should be empty
And STDERR should contain:
"""
Error: The shell binary '/nonsense/path' is not valid.
"""
When I try `WP_CLI_CUSTOM_SHELL=/bin/bash wp shell --basic < session`
Then STDOUT should contain:
"""
bool(true)
"""
And STDERR should be empty
Scenario: Input starting with dash
Given a WP install
And a session file:
"""
-1
"""
When I run `wp shell --basic < session`
Then STDOUT should contain:
"""
int(-1)
"""
And STDERR should not contain:
"""
history: -1: invalid option
"""
Scenario: Shell with hook parameter
Given a WP install
And a session file:
"""
did_action('init');
"""
When I run `wp shell --basic --hook=init < session`
Then STDOUT should contain:
"""
int(1)
"""
Scenario: Shell with hook parameter using plugins_loaded hook
Given a WP install
And a session file:
"""
did_action('plugins_loaded');
"""
When I run `wp shell --basic --hook=plugins_loaded < session`
Then STDOUT should contain:
"""
int(1)
"""
Scenario: Shell with hook parameter for hook that hasn't fired
Given a WP install
When I try `wp shell --basic --hook=shutdown < /dev/null`
Then STDERR should contain:
"""
Error: The 'shutdown' hook has not fired yet
"""
And the return code should be 1