@@ -583,7 +583,7 @@ public function testSubMenuInheritsParentsStyle() : void
583
583
->expects ($ this ->any ())
584
584
->method ('getWidth ' )
585
585
->will ($ this ->returnValue (200 ));
586
-
586
+
587
587
$ menu = (new CliMenuBuilder ($ terminal ))
588
588
->setBackgroundColour ('green ' )
589
589
->addSubMenu ('My SubMenu ' , function (CliMenuBuilder $ b ) {
@@ -594,7 +594,9 @@ public function testSubMenuInheritsParentsStyle() : void
594
594
})
595
595
->build ();
596
596
597
+ /** @var CliMenu $subMenu1 */
597
598
$ subMenu1 = $ menu ->getItems ()[0 ]->getSubMenu ();
599
+ /** @var CliMenu $subMenu2 */
598
600
$ subMenu2 = $ subMenu1 ->getItems ()[0 ]->getSubMenu ();
599
601
600
602
self ::assertSame ('green ' , $ subMenu1 ->getStyle ()->getBg ());
@@ -604,6 +606,35 @@ public function testSubMenuInheritsParentsStyle() : void
604
606
self ::assertEquals ($ menu ->getStyle (), $ subMenu2 ->getStyle ());
605
607
}
606
608
609
+ public function testSubMenuIgnoresParentsStyleIfCustomAndPassesToChildren () : void
610
+ {
611
+ $ terminal = self ::createMock (Terminal::class);
612
+ $ terminal
613
+ ->expects ($ this ->any ())
614
+ ->method ('getWidth ' )
615
+ ->will ($ this ->returnValue (200 ));
616
+
617
+ $ menu = (new CliMenuBuilder ($ terminal ))
618
+ ->setBackgroundColour ('green ' )
619
+ ->addSubMenu ('My SubMenu ' , function (CliMenuBuilder $ b ) {
620
+ $ b ->setBackgroundColour ('yellow ' )
621
+ ->addSubMenu ('My SubSubMenu ' , function (CliMenuBuilder $ b ) {
622
+ $ b ->addItem ('Some Item ' , function () {
623
+ });
624
+ });
625
+ })
626
+ ->build ();
627
+
628
+ /** @var CliMenu $subMenu1 */
629
+ $ subMenu1 = $ menu ->getItems ()[0 ]->getSubMenu ();
630
+ /** @var CliMenu $subMenu2 */
631
+ $ subMenu2 = $ subMenu1 ->getItems ()[0 ]->getSubMenu ();
632
+
633
+ self ::assertSame ('green ' , $ menu ->getStyle ()->getBg ());
634
+ self ::assertSame ('yellow ' , $ subMenu1 ->getStyle ()->getBg ());
635
+ self ::assertSame ('yellow ' , $ subMenu2 ->getStyle ()->getBg ());
636
+ }
637
+
607
638
public function testSubMenuDoesNotInheritsParentsStyleWhenSubMenuStyleHasAlterations () : void
608
639
{
609
640
$ menu = (new CliMenuBuilder )
0 commit comments