44use WP_CLI \Tests \TestCase ;
55
66/**
7- * Class TestArguments
7+ * Class Test_Arguments
88 * @todo add more tests to increase coverage
99 *
1010 * @backupGlobals enabled
1111 */
12- class TestArguments extends TestCase
12+ class Test_Arguments extends TestCase
1313{
1414 /**
1515 * Array of expected settings
@@ -91,6 +91,13 @@ public function set_up()
9191 'flags ' => $ this ->flags ,
9292 'options ' => $ this ->options
9393 );
94+
95+ set_error_handler (
96+ static function ( $ errno , $ errstr ) {
97+ throw new \Exception ( $ errstr , $ errno );
98+ },
99+ E_ALL
100+ );
94101 }
95102
96103 /**
@@ -102,6 +109,7 @@ public function tear_down()
102109 $ this ->options = null ;
103110 $ this ->settings = null ;
104111 self ::clearArgv ();
112+ restore_error_handler ();
105113 }
106114
107115 /**
@@ -151,7 +159,7 @@ public function testAddOptions()
151159 *
152160 * @return array set of args and expected parsed values
153161 */
154- public function settingsWithValidOptions ()
162+ public static function settingsWithValidOptions ()
155163 {
156164 return array (
157165 array (
@@ -174,7 +182,7 @@ public function settingsWithValidOptions()
174182 *
175183 * @return array set of args and expected parsed values
176184 */
177- public function settingsWithMissingOptions ()
185+ public static function settingsWithMissingOptions ()
178186 {
179187 return array (
180188 array (
@@ -193,7 +201,7 @@ public function settingsWithMissingOptions()
193201 *
194202 * @return array set of args and expected parsed values
195203 */
196- public function settingsWithMissingOptionsWithDefault ()
204+ public static function settingsWithMissingOptionsWithDefault ()
197205 {
198206 return array (
199207 array (
@@ -207,7 +215,7 @@ public function settingsWithMissingOptionsWithDefault()
207215 );
208216 }
209217
210- public function settingsWithNoOptionsWithDefault ()
218+ public static function settingsWithNoOptionsWithDefault ()
211219 {
212220 return array (
213221 array (
@@ -259,8 +267,8 @@ public function testParseWithValidOptions($cliParams, $expectedValues)
259267 */
260268 public function testParseWithMissingOptions ($ cliParams , $ expectedValues )
261269 {
262- $ this ->expectWarning ( );
263- $ this ->expectWarningMessage ('no value given for --option1 ' );
270+ $ this ->expectException (\Exception::class );
271+ $ this ->expectExceptionMessage ('no value given for --option1 ' );
264272 $ this ->_testParse ($ cliParams , $ expectedValues );
265273 }
266274
0 commit comments