File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -486,6 +486,10 @@ public function open() : void
486
486
if ($ this ->isOpen ()) {
487
487
return ;
488
488
}
489
+
490
+ if (count ($ this ->items ) === 0 ) {
491
+ throw new \RuntimeException ('Menu must have at least 1 item before it can be opened ' );
492
+ }
489
493
490
494
$ this ->configureTerminal ();
491
495
$ this ->open = true ;
Original file line number Diff line number Diff line change @@ -359,11 +359,19 @@ public function testThrowsExceptionIfTerminalIsNotValidTTY() : void
359
359
->method ('isInteractive ' )
360
360
->willReturn (false );
361
361
362
- $ menu = new CliMenu ('PHP School FTW ' , [], $ terminal );
362
+ $ menu = new CliMenu ('PHP School FTW ' , [new StaticItem ( ' One ' ) ], $ terminal );
363
363
364
364
$ menu ->open ();
365
365
}
366
366
367
+ public function testOpenThrowsExceptionIfNoItemsInMenu () : void
368
+ {
369
+ $ this ->expectException (\RuntimeException::class);
370
+ $ this ->expectExceptionMessage ('Menu must have at least 1 item before it can be opened ' );
371
+
372
+ (new CliMenu ('PHP School FTW ' , [], $ this ->terminal ))->open ();
373
+ }
374
+
367
375
public function testGetTerminal () : void
368
376
{
369
377
$ menu = new CliMenu ('PHP School FTW ' , []);
You can’t perform that action at this time.
0 commit comments