44
55namespace ShlinkioTest \Shlink \Installer \Config ;
66
7+ use PHPUnit \Framework \Attributes \AllowMockObjectsWithoutExpectations ;
78use PHPUnit \Framework \Attributes \DataProvider ;
89use PHPUnit \Framework \Attributes \Test ;
910use PHPUnit \Framework \MockObject \MockObject ;
2223class ConfigGeneratorTest extends TestCase
2324{
2425 private MockObject & ConfigOptionsManagerInterface $ configOptionsManager ;
25- private MockObject & ConfigOptionInterface $ plugin ;
2626 private MockObject & StyleInterface $ io ;
2727
2828 public function setUp (): void
2929 {
3030 $ this ->configOptionsManager = $ this ->createMock (ConfigOptionsManagerInterface::class);
31- $ this ->plugin = $ this ->createMock (ConfigOptionInterface::class);
3231 $ this ->io = $ this ->createMock (StyleInterface::class);
3332 }
3433
@@ -41,12 +40,11 @@ public function configuresExpectedPlugins(
4140 $ totalPlugins = count (ArrayUtils::flatten ($ configOptionsGroups ));
4241 $ expectedQuestions = $ enabledOptions === null ? $ totalPlugins : count ($ enabledOptions );
4342
44- $ this ->plugin ->expects ($ this ->exactly ($ expectedQuestions ))->method ('shouldBeAsked ' )->willReturn (true );
45- $ this ->plugin ->expects ($ this ->exactly ($ expectedQuestions ))->method ('getEnvVar ' )->willReturn ('ENV_VAR ' );
46- $ this ->plugin ->expects ($ this ->exactly ($ expectedQuestions ))->method ('ask ' )->willReturn ('value ' );
47- $ this ->configOptionsManager ->expects ($ this ->exactly ($ expectedQuestions ))->method ('get ' )->willReturn (
48- $ this ->plugin ,
49- );
43+ $ plugin = $ this ->createMock (ConfigOptionInterface::class);
44+ $ plugin ->expects ($ this ->exactly ($ expectedQuestions ))->method ('shouldBeAsked ' )->willReturn (true );
45+ $ plugin ->expects ($ this ->exactly ($ expectedQuestions ))->method ('getEnvVar ' )->willReturn ('ENV_VAR ' );
46+ $ plugin ->expects ($ this ->exactly ($ expectedQuestions ))->method ('ask ' )->willReturn ('value ' );
47+ $ this ->configOptionsManager ->expects ($ this ->exactly ($ expectedQuestions ))->method ('get ' )->willReturn ($ plugin );
5048 $ this ->io ->expects ($ this ->exactly ($ expectedPrintTitleCalls ))->method ('title ' );
5149
5250 $ generator = new ConfigGenerator ($ this ->configOptionsManager , $ configOptionsGroups , $ enabledOptions );
@@ -69,7 +67,7 @@ public static function provideConfigOptions(): iterable
6967 yield '1 enabled ' => [$ optionsGroups , ['foo ' ], 1 ];
7068 }
7169
72- #[Test]
70+ #[Test, AllowMockObjectsWithoutExpectations ]
7371 public function pluginsAreAskedInProperOrder (): void
7472 {
7573 $ orderedAskedOptions = [];
@@ -143,7 +141,7 @@ public function getDependentOption(): string
143141 self ::assertEquals (['a ' , 'depends_on_a ' ], $ orderedAskedOptions );
144142 }
145143
146- #[Test, DataProvider('provideMigratorValues ' )]
144+ #[Test, DataProvider('provideMigratorValues ' ), AllowMockObjectsWithoutExpectations ]
147145 public function migratorPluginsAreProcessedWhenTheValuesShouldNotBeAsked (
148146 array $ oldConfig ,
149147 array $ expectedResult ,
0 commit comments