@@ -174,4 +174,167 @@ public function testBootstrapWithDisplayQuote(): void
174174 $ this ->assertNotContains ('COLLISION_PRINTER_COMPACT ' , array_keys ($ _SERVER ));
175175 $ this ->assertNotContains ('COLLISION_PRINTER_PROFILE ' , array_keys ($ _SERVER ));
176176 }
177+
178+ public function testItShouldBeEnabledThroughCli (): void
179+ {
180+ $ facade = $ this ->createMock (Facade::class);
181+ $ configuration = (new Builder ())->build ([]);
182+ $ parameters = ParameterCollection::fromArray ([
183+ 'displayProfiling ' => 'true ' ,
184+ 'useCompactMode ' => 'true ' ,
185+ 'displayQuote ' => 'true ' ,
186+ 'enableByDefault ' => 'false ' ,
187+ ]);
188+
189+ $ extension = new PhpUnitExtension ();
190+
191+ $ facade
192+ ->expects ($ this ->once ())
193+ ->method ('replaceOutput ' );
194+
195+ $ facade
196+ ->expects ($ this ->once ())
197+ ->method ('replaceProgressOutput ' );
198+
199+ $ facade
200+ ->expects ($ this ->once ())
201+ ->method ('replaceResultOutput ' );
202+
203+ $ facade
204+ ->expects ($ this ->once ())
205+ ->method ('registerSubscriber ' )
206+ ->with (new ApplicationFinishedSubscriber ());
207+
208+ $ _SERVER ['argv ' ][] = '--enable-pretty-print ' ;
209+
210+ $ extension ->bootstrap (
211+ $ configuration ,
212+ $ facade ,
213+ $ parameters
214+ );
215+
216+ $ this ->assertContains ('COLLISION_PRINTER_COMPACT ' , array_keys ($ _SERVER ));
217+ $ this ->assertContains ('COLLISION_PRINTER_PROFILE ' , array_keys ($ _SERVER ));
218+ }
219+
220+ public function testItShouldBeDisabledThroughCli (): void
221+ {
222+ $ facade = $ this ->createMock (Facade::class);
223+ $ configuration = (new Builder ())->build ([]);
224+ $ parameters = ParameterCollection::fromArray ([
225+ 'displayProfiling ' => 'true ' ,
226+ 'useCompactMode ' => 'true ' ,
227+ 'displayQuote ' => 'true ' ,
228+ ]);
229+
230+ $ extension = new PhpUnitExtension ();
231+
232+ $ facade
233+ ->expects ($ this ->never ())
234+ ->method ('replaceOutput ' );
235+
236+ $ facade
237+ ->expects ($ this ->never ())
238+ ->method ('replaceProgressOutput ' );
239+
240+ $ facade
241+ ->expects ($ this ->never ())
242+ ->method ('replaceResultOutput ' );
243+
244+ $ facade
245+ ->expects ($ this ->never ())
246+ ->method ('registerSubscriber ' )
247+ ->with (new ApplicationFinishedSubscriber ());
248+
249+ $ _SERVER ['argv ' ][] = '--disable-pretty-print ' ;
250+
251+ $ extension ->bootstrap (
252+ $ configuration ,
253+ $ facade ,
254+ $ parameters
255+ );
256+
257+ $ this ->assertNotContains ('COLLISION_PRINTER_COMPACT ' , array_keys ($ _SERVER ));
258+ $ this ->assertNotContains ('COLLISION_PRINTER_PROFILE ' , array_keys ($ _SERVER ));
259+ }
260+
261+ public function testItShouldBeEnabledWithParameter (): void
262+ {
263+ $ facade = $ this ->createMock (Facade::class);
264+ $ configuration = (new Builder ())->build ([]);
265+ $ parameters = ParameterCollection::fromArray ([
266+ 'displayProfiling ' => 'true ' ,
267+ 'useCompactMode ' => 'true ' ,
268+ 'displayQuote ' => 'true ' ,
269+ 'enableByDefault ' => 'true ' ,
270+ ]);
271+
272+ $ extension = new PhpUnitExtension ();
273+
274+ $ facade
275+ ->expects ($ this ->once ())
276+ ->method ('replaceOutput ' );
277+
278+ $ facade
279+ ->expects ($ this ->once ())
280+ ->method ('replaceProgressOutput ' );
281+
282+ $ facade
283+ ->expects ($ this ->once ())
284+ ->method ('replaceResultOutput ' );
285+
286+ $ facade
287+ ->expects ($ this ->once ())
288+ ->method ('registerSubscriber ' )
289+ ->with (new ApplicationFinishedSubscriber ());
290+
291+ $ extension ->bootstrap (
292+ $ configuration ,
293+ $ facade ,
294+ $ parameters
295+ );
296+
297+ $ this ->assertContains ('COLLISION_PRINTER_COMPACT ' , array_keys ($ _SERVER ));
298+ $ this ->assertContains ('COLLISION_PRINTER_PROFILE ' , array_keys ($ _SERVER ));
299+ }
300+
301+ public function testItShouldBeDisabledWithParameter (): void
302+ {
303+ $ facade = $ this ->createMock (Facade::class);
304+ $ configuration = (new Builder ())->build ([]);
305+ $ parameters = ParameterCollection::fromArray ([
306+ 'displayProfiling ' => 'true ' ,
307+ 'useCompactMode ' => 'true ' ,
308+ 'displayQuote ' => 'true ' ,
309+ 'enableByDefault ' => 'false ' ,
310+ ]);
311+
312+ $ extension = new PhpUnitExtension ();
313+
314+ $ facade
315+ ->expects ($ this ->never ())
316+ ->method ('replaceOutput ' );
317+
318+ $ facade
319+ ->expects ($ this ->never ())
320+ ->method ('replaceProgressOutput ' );
321+
322+ $ facade
323+ ->expects ($ this ->never ())
324+ ->method ('replaceResultOutput ' );
325+
326+ $ facade
327+ ->expects ($ this ->never ())
328+ ->method ('registerSubscriber ' )
329+ ->with (new ApplicationFinishedSubscriber ());
330+
331+ $ extension ->bootstrap (
332+ $ configuration ,
333+ $ facade ,
334+ $ parameters
335+ );
336+
337+ $ this ->assertNotContains ('COLLISION_PRINTER_COMPACT ' , array_keys ($ _SERVER ));
338+ $ this ->assertNotContains ('COLLISION_PRINTER_PROFILE ' , array_keys ($ _SERVER ));
339+ }
177340}
0 commit comments