@@ -268,42 +268,72 @@ public function testGetoptUnSetBeforeParse()
268
268
unset($ opts ->a );
269
269
$ this ->assertFalse (isset ($ opts ->a ));
270
270
}
271
-
271
+
272
+ /**
273
+ * @group GH-377
274
+ */
272
275
public function testVerifyRequiredArgument ()
273
276
{
274
- $ opts = new Zend_Console_Getopt (array ('apple|a=s ' => "First required argument " ));
275
- try {
277
+ $ opts = new Zend_Console_Getopt (
278
+ array ('apple|a=s ' => "First required argument " )
279
+ );
280
+
281
+ try {
276
282
$ opts ->parse ();
277
283
$ opts ->checkRequiredArguments ();
278
284
$ this ->fail ('Expected to catch a Zend_Console_Getopt_Exception ' );
285
+ } catch (Zend_Exception $ e ) {
286
+ $ this ->assertTrue (
287
+ $ e instanceof Zend_Console_Getopt_Exception,
288
+ 'Expected Zend_Console_Getopt_Exception, got ' . get_class ($ e )
289
+ );
290
+ $ this ->assertEquals (
291
+ 'Option "a" requires a parameter. ' , $ e ->getMessage ()
292
+ );
279
293
}
280
- catch ( Zend_Exception $ e ){
281
- $ this -> assertTrue ( $ e instanceof Zend_Console_Getopt_Exception,
282
- ' Expected Zend_Console_Getopt_Exception, got ' . get_class ( $ e ));
283
- $ this -> assertEquals ( ' Option "a" requires a parameter. ' , $ e -> getMessage ());
284
- }
285
-
286
- $ opts -> addArguments ( array ( " -a " , " apple " ) );
294
+
295
+ $ opts -> addArguments (
296
+ array (
297
+ " -a " ,
298
+ " apple "
299
+ )
300
+ );
287
301
$ opts ->parse ();
288
302
$ opts ->checkRequiredArguments ();//-> no Exception here
289
303
}
290
-
304
+
305
+ /**
306
+ * @group GH-377
307
+ */
291
308
public function testEmptyRequiredOption ()
292
- {
293
- $ opts = new Zend_Console_Getopt (array (
294
- 'apple|a=s ' =>"First required argument " ,
295
- 'banana|b=i ' =>"Second required argument "
296
- ));
297
- $ opts ->addArguments (array ("-a " ,"-b " ,"123 " ));
298
- try {
309
+ {
310
+ $ opts = new Zend_Console_Getopt (
311
+ array (
312
+ 'apple|a=s ' => "First required argument " ,
313
+ 'banana|b=i ' => "Second required argument "
314
+ )
315
+ );
316
+ $ opts ->addArguments (
317
+ array (
318
+ "-a " ,
319
+ "-b " ,
320
+ "123 "
321
+ )
322
+ );
323
+
324
+ try {
299
325
$ opts ->parse ();
300
326
$ opts ->checkRequiredArguments ();
301
- $ this ->fail ('Expected to catch a Zend_Console_Getopt_Exception ' );
302
- } catch (Zend_Exception $ e ) {
303
- $ this ->assertTrue ($ e instanceof Zend_Console_Getopt_Exception,
304
- 'Expected Zend_Console_Getopt_Exception, got ' . get_class ($ e ));
305
- $ this ->assertEquals ('Option "a" requires a parameter. ' , $ e ->getMessage ());
306
- }
327
+ $ this ->fail ('Expected to catch a Zend_Console_Getopt_Exception ' );
328
+ } catch (Zend_Exception $ e ) {
329
+ $ this ->assertTrue (
330
+ $ e instanceof Zend_Console_Getopt_Exception,
331
+ 'Expected Zend_Console_Getopt_Exception, got ' . get_class ($ e )
332
+ );
333
+ $ this ->assertEquals (
334
+ 'Option "a" requires a parameter. ' , $ e ->getMessage ()
335
+ );
336
+ }
307
337
}
308
338
309
339
/**
0 commit comments