|
370 | 370 | $tenant = Tenant::create(); |
371 | 371 | $migratingOutput = 'Migrating tenant ' . $tenant->getTenantKey(); |
372 | 372 |
|
373 | | - // CI runs pest with -v, setting SHELL_VERBOSITY to 1, so in CI, the output is verbose by default |
374 | | - $shellVerbosity = getenv('SHELL_VERBOSITY'); |
375 | | - $_ENV['SHELL_VERBOSITY'] = $_SERVER['SHELL_VERBOSITY'] = 0; |
376 | | - putenv('SHELL_VERBOSITY=0'); |
377 | | - |
| 373 | + // CI runs pest with --verbose which makes Artisan::call() inherit the verbosity |
| 374 | + // so we cannot easily test commands without -v. To work around that, we temporarily |
| 375 | + // override $_ENV['SHELL_VERBOSITY'] immediately before executing the command. If this |
| 376 | + // ever stops working, try also overriding the value in $_SERVER and putenv(). |
| 377 | + $originalVerbosity = $_ENV['SHELL_VERBOSITY'] ?? 0; |
378 | 378 | try { |
| 379 | + $_ENV['SHELL_VERBOSITY'] = 0; |
379 | 380 | Artisan::call('tenants:migrate-fresh'); |
380 | 381 | $defaultOutput = Artisan::output(); |
381 | | - |
382 | | - Artisan::call('tenants:migrate-fresh -v'); |
383 | | - $verboseOutput = Artisan::output(); |
384 | 382 | } finally { |
385 | | - unset($_ENV['SHELL_VERBOSITY'], $_SERVER['SHELL_VERBOSITY']); |
386 | | - $shellVerbosity === false ? putenv('SHELL_VERBOSITY') : putenv("SHELL_VERBOSITY=$shellVerbosity"); |
| 383 | + $_ENV['SHELL_VERBOSITY'] = $originalVerbosity; |
387 | 384 | } |
388 | 385 |
|
| 386 | + Artisan::call('tenants:migrate-fresh -v'); |
| 387 | + $verboseOutput = Artisan::output(); |
| 388 | + |
389 | 389 | // The output is silent by default and only shown with the verbose option |
390 | 390 | expect($defaultOutput)->not()->toContain($migratingOutput); |
391 | 391 | expect($verboseOutput)->toContain($migratingOutput); |
|
0 commit comments