4
4
use WP_CLI \Tests \TestCase ;
5
5
6
6
/**
7
- * Class TestArguments
7
+ * Class Test_Arguments
8
8
* @todo add more tests to increase coverage
9
9
*
10
10
* @backupGlobals enabled
11
11
*/
12
- class TestArguments extends TestCase
12
+ class Test_Arguments extends TestCase
13
13
{
14
14
/**
15
15
* Array of expected settings
@@ -91,6 +91,13 @@ public function set_up()
91
91
'flags ' => $ this ->flags ,
92
92
'options ' => $ this ->options
93
93
);
94
+
95
+ set_error_handler (
96
+ static function ( $ errno , $ errstr ) {
97
+ throw new \Exception ( $ errstr , $ errno );
98
+ },
99
+ E_ALL
100
+ );
94
101
}
95
102
96
103
/**
@@ -102,6 +109,7 @@ public function tear_down()
102
109
$ this ->options = null ;
103
110
$ this ->settings = null ;
104
111
self ::clearArgv ();
112
+ restore_error_handler ();
105
113
}
106
114
107
115
/**
@@ -151,7 +159,7 @@ public function testAddOptions()
151
159
*
152
160
* @return array set of args and expected parsed values
153
161
*/
154
- public function settingsWithValidOptions ()
162
+ public static function settingsWithValidOptions ()
155
163
{
156
164
return array (
157
165
array (
@@ -174,7 +182,7 @@ public function settingsWithValidOptions()
174
182
*
175
183
* @return array set of args and expected parsed values
176
184
*/
177
- public function settingsWithMissingOptions ()
185
+ public static function settingsWithMissingOptions ()
178
186
{
179
187
return array (
180
188
array (
@@ -193,7 +201,7 @@ public function settingsWithMissingOptions()
193
201
*
194
202
* @return array set of args and expected parsed values
195
203
*/
196
- public function settingsWithMissingOptionsWithDefault ()
204
+ public static function settingsWithMissingOptionsWithDefault ()
197
205
{
198
206
return array (
199
207
array (
@@ -207,7 +215,7 @@ public function settingsWithMissingOptionsWithDefault()
207
215
);
208
216
}
209
217
210
- public function settingsWithNoOptionsWithDefault ()
218
+ public static function settingsWithNoOptionsWithDefault ()
211
219
{
212
220
return array (
213
221
array (
@@ -259,8 +267,8 @@ public function testParseWithValidOptions($cliParams, $expectedValues)
259
267
*/
260
268
public function testParseWithMissingOptions ($ cliParams , $ expectedValues )
261
269
{
262
- $ this ->expectWarning ( );
263
- $ this ->expectWarningMessage ('no value given for --option1 ' );
270
+ $ this ->expectException (\Exception::class );
271
+ $ this ->expectExceptionMessage ('no value given for --option1 ' );
264
272
$ this ->_testParse ($ cliParams , $ expectedValues );
265
273
}
266
274
0 commit comments