1616use PhpSchool \CliMenu \MenuItem \StaticItem ;
1717use PhpSchool \CliMenu \Style \DefaultStyle ;
1818use PhpSchool \Terminal \Terminal ;
19+ use PHPUnit \Framework \Attributes \DataProvider ;
1920use PHPUnit \Framework \TestCase ;
2021
2122/**
@@ -60,7 +61,7 @@ public function testModifyStyles() : void
6061 $ terminal
6162 ->expects ($ this ->any ())
6263 ->method ('getWidth ' )
63- ->will ( $ this -> returnValue ( 200 ) );
64+ ->willReturn ( 200 );
6465
6566 $ builder = new CliMenuBuilder ($ terminal );
6667 $ builder ->setBackgroundColour ('red ' );
@@ -90,7 +91,7 @@ public function testSetBorderShorthandFunction() : void
9091 $ terminal
9192 ->expects ($ this ->any ())
9293 ->method ('getWidth ' )
93- ->will ( $ this -> returnValue ( 200 ) );
94+ ->willReturn ( 200 );
9495
9596 $ style = (new CliMenuBuilder ($ terminal ))
9697 ->setBorder (2 )
@@ -641,7 +642,7 @@ public function testSubMenuInheritsParentsStyle() : void
641642 $ terminal
642643 ->expects ($ this ->any ())
643644 ->method ('getWidth ' )
644- ->will ( $ this -> returnValue ( 200 ) );
645+ ->willReturn ( 200 );
645646
646647 $ menu = (new CliMenuBuilder ($ terminal ))
647648 ->setBackgroundColour ('green ' )
@@ -671,7 +672,7 @@ public function testSplitItemSubMenuInheritsParentsStyle() : void
671672 $ terminal
672673 ->expects ($ this ->any ())
673674 ->method ('getWidth ' )
674- ->will ( $ this -> returnValue ( 200 ) );
675+ ->willReturn ( 200 );
675676
676677 $ menu = (new CliMenuBuilder ($ terminal ))
677678 ->setBackgroundColour ('green ' )
@@ -704,7 +705,7 @@ public function testSubMenuIgnoresParentsStyleIfCustomAndPassesToChildren() : vo
704705 $ terminal
705706 ->expects ($ this ->any ())
706707 ->method ('getWidth ' )
707- ->will ( $ this -> returnValue ( 200 ) );
708+ ->willReturn ( 200 );
708709
709710 $ menu = (new CliMenuBuilder ($ terminal ))
710711 ->setBackgroundColour ('green ' )
@@ -809,9 +810,7 @@ public function testThrowsExceptionWhenDisablingRootMenu() : void
809810 (new CliMenuBuilder )->disableMenu ();
810811 }
811812
812- /**
813- * @dataProvider marginBelowZeroProvider
814- */
813+ #[DataProvider('marginBelowZeroProvider ' )]
815814 public function testSetMarginThrowsExceptionIfValueIsNotZeroOrAbove (int $ value ) : void
816815 {
817816 self ::expectException (\Assert \InvalidArgumentException::class);
@@ -820,28 +819,26 @@ public function testSetMarginThrowsExceptionIfValueIsNotZeroOrAbove(int $value)
820819 (new CliMenuBuilder )->setMargin ($ value )->build ();
821820 }
822821
823- public function marginBelowZeroProvider () : array
822+ public static function marginBelowZeroProvider () : array
824823 {
825824 return [[-1 ], [-2 ], [-10 ]];
826825 }
827826
828- /**
829- * @dataProvider marginAboveZeroProvider
830- */
827+ #[DataProvider('marginAboveZeroProvider ' )]
831828 public function testSetMarginAcceptsZeroAndPositiveIntegers (int $ value ) : void
832829 {
833830 $ terminal = self ::createMock (Terminal::class);
834831 $ terminal
835832 ->expects ($ this ->any ())
836833 ->method ('getWidth ' )
837- ->will ( $ this -> returnValue ( 200 ) );
834+ ->willReturn ( 200 );
838835
839836 $ menu = (new CliMenuBuilder ($ terminal ))->setMargin ($ value )->build ();
840837
841838 self ::assertSame ($ value , $ menu ->getStyle ()->getMargin ());
842839 }
843840
844- public function marginAboveZeroProvider () : array
841+ public static function marginAboveZeroProvider () : array
845842 {
846843 return [[0 ], [1 ], [10 ], [50 ]];
847844 }
@@ -852,7 +849,7 @@ public function testSetMarginAutoAutomaticallyCalculatesMarginToCenter() : void
852849 $ terminal
853850 ->expects ($ this ->any ())
854851 ->method ('getWidth ' )
855- ->will ( $ this -> returnValue ( 200 ) );
852+ ->willReturn ( 200 );
856853
857854 $ builder = new CliMenuBuilder ($ terminal );
858855 $ menu = $ builder
@@ -869,7 +866,7 @@ public function testSetMarginAutoOverwritesSetMargin() : void
869866 $ terminal
870867 ->expects ($ this ->any ())
871868 ->method ('getWidth ' )
872- ->will ( $ this -> returnValue ( 200 ) );
869+ ->willReturn ( 200 );
873870
874871 $ builder = new CliMenuBuilder ($ terminal );
875872 $ menu = $ builder
@@ -887,7 +884,7 @@ public function testSetMarginManuallyOverwritesSetMarginAuto() : void
887884 $ terminal
888885 ->expects ($ this ->any ())
889886 ->method ('getWidth ' )
890- ->will ( $ this -> returnValue ( 200 ) );
887+ ->willReturn ( 200 );
891888
892889 $ builder = new CliMenuBuilder ($ terminal );
893890 $ menu = $ builder
0 commit comments