Skip to content

Commit

Permalink
[7.x] Uses Collision's printer if possible (#1038)
Browse files Browse the repository at this point in the history
* Uses collision printer if possible

* Apply fixes from StyleCI

* Update DuskCommand.php

---------

Co-authored-by: StyleCI Bot <[email protected]>
Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
3 people authored Jul 8, 2023
1 parent e864034 commit bf6d693
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/Console/DuskCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Dotenv\Dotenv;
use Illuminate\Console\Command;
use Illuminate\Support\Str;
use NunoMaduro\Collision\Adapters\Phpunit\Subscribers\EnsurePrinterIsRegisteredSubscriber;
use PHPUnit\Runner\Version;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Process\Exception\ProcessSignaledException;
Expand Down Expand Up @@ -119,6 +120,10 @@ protected function binary()
*/
protected function phpunitArguments($options)
{
if ($this->shouldUseCollisionPrinter()) {
$options[] = '--no-output';
}

$options = array_values(array_filter($options, function ($option) {
return ! Str::startsWith($option, ['--env=', '--pest']);
}));
Expand All @@ -137,9 +142,29 @@ protected function phpunitArguments($options)
*/
protected function env()
{
$variables = [];

if ($this->option('browse') && ! isset($_ENV['CI']) && ! isset($_SERVER['CI'])) {
return ['DUSK_HEADLESS_DISABLED' => true];
$variables['DUSK_HEADLESS_DISABLED'] = true;
}

if ($this->shouldUseCollisionPrinter()) {
$variables['COLLISION_PRINTER'] = 'DefaultPrinter';
}

return $variables;
}

/**
* Determine if Collision's printer should be used.
*
* @return bool
*/
protected function shouldUseCollisionPrinter()
{
return ! $this->option('pest')
&& class_exists(EnsurePrinterIsRegisteredSubscriber::class)
&& version_compare(Version::id(), '10.0', '>=');
}

/**
Expand Down

0 comments on commit bf6d693

Please sign in to comment.