44
55use BlameButton \LaravelDockerBuilder \Integrations \SupportedPhpExtensions ;
66use BlameButton \LaravelDockerBuilder \Tests \TestCase ;
7+ use Illuminate \Support \Facades \File ;
78use Mockery \MockInterface ;
89
910/**
@@ -71,6 +72,8 @@ public function provideCommands(): array
7172 /** @dataProvider provideCommands */
7273 public function testItGeneratesConfigurations (array $ expected , string $ command ): void
7374 {
75+ File::deleteDirectory (base_path ('.docker ' ));
76+
7477 $ this ->mock (SupportedPhpExtensions::class, function (MockInterface $ mock ) {
7578 $ mock ->shouldReceive ('get ' )->withAnyArgs ()->andReturn ([
7679 'bcmath ' , 'pdo_mysql ' , 'pdo_pgsql ' , 'redis ' , 'apcu ' ,
@@ -86,7 +89,16 @@ public function testItGeneratesConfigurations(array $expected, string $command):
8689 }
8790 }
8891
89- public function testItAsksQuestions (): void
92+ public function provideIsInformationCorrectAnswer (): array
93+ {
94+ return [
95+ ['yes ' ],
96+ ['no ' ],
97+ ];
98+ }
99+
100+ /** @dataProvider provideIsInformationCorrectAnswer */
101+ public function testItAsksQuestions (string $ isCorrect ): void
90102 {
91103 $ this ->mock (SupportedPhpExtensions::class, function (MockInterface $ mock ) {
92104 $ mock ->shouldReceive ('get ' )->with ('8.2 ' )->once ()->andReturn (['bcmath ' , 'redis ' ]);
@@ -100,18 +112,23 @@ public function testItAsksQuestions(): void
100112 $ command ->expectsConfirmation ('Do you want to use "Alpine Linux" based images? ' , 'yes ' );
101113 $ command ->expectsChoice ('Which Node package manager do you use? ' , 'npm ' , ['npm ' , 'yarn ' , 'none ' ]);
102114 $ command ->expectsChoice ('Which Node build tool do you use? ' , 'vite ' , ['vite ' , 'mix ' ]);
103- $ command ->expectsConfirmation ('Does this look correct? ' , 'yes ' );
104- $ command ->expectsOutput ('Configuration: ' );
105- $ command ->expectsTable (['Key ' , 'Value ' ], [
106- ['PHP version ' , '8.2 ' ],
107- ['PHP extensions ' , 'bcmath, redis ' ],
108- ['Artisan Optimize ' , 'true ' ],
109- ['Alpine images ' , 'true ' ],
110- ['Node package manager ' , 'NPM ' ],
111- ['Node build tool ' , 'Vite.js ' ],
112- ]);
113- $ command ->expectsOutput ('Command to generate above configuration: ' );
114- $ command ->expectsOutput (' php artisan docker:generate -n -p 8.2 -e bcmath,redis -o -a -m npm -b vite ' );
115+ $ command ->expectsConfirmation ('Does this look correct? ' , $ isCorrect );
116+ if ($ isCorrect == 'yes ' ) {
117+ $ command ->expectsOutput ('Configuration: ' );
118+ $ command ->expectsTable (['Key ' , 'Value ' ], [
119+ ['PHP version ' , '8.2 ' ],
120+ ['PHP extensions ' , 'bcmath, redis ' ],
121+ ['Artisan Optimize ' , 'true ' ],
122+ ['Alpine images ' , 'true ' ],
123+ ['Node package manager ' , 'NPM ' ],
124+ ['Node build tool ' , 'Vite.js ' ],
125+ ]);
126+ $ command ->expectsOutput ('Command to generate above configuration: ' );
127+ $ command ->expectsOutput (' php artisan docker:generate -n -p 8.2 -e bcmath,redis -o -a -m npm -b vite ' );
128+ } else {
129+ $ command ->expectsOutput ('Exiting. ' );
130+ }
131+ $ command ->assertSuccessful ();
115132 }
116133
117134 public function provideInvalidOptions (): array
0 commit comments