Skip to content

Commit

Permalink
chore: re-enables a bunch of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Jan 23, 2025
1 parent 2bac222 commit 6187165
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 28 deletions.
9 changes: 1 addition & 8 deletions src/Adapters/Laravel/Commands/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class TestCommand extends Command
{--compact : Indicates whether the compact printer should be used}
{--coverage : Indicates whether code coverage information should be collected}
{--min= : Indicates the minimum threshold enforcement for code coverage}
{--quiet-coverage : Do not report any files where code coverage is 100%}
{--p|parallel : Indicates if the tests should run in parallel}
{--profile : Lists top 10 slowest tests}
{--recreate-databases : Indicates if the test databases should be re-created}
Expand Down Expand Up @@ -131,7 +130,7 @@ public function handle()
$this->newLine();
}

$hideFullCoverage = (bool) $this->option('quiet-coverage');
$hideFullCoverage = (bool) $this->option('compact');
$coverage = Coverage::report($this->output, $hideFullCoverage);

$exitCode = (int) ($coverage < $this->option('min'));
Expand Down Expand Up @@ -218,18 +217,13 @@ protected function phpunitArguments($options)
&& $option != '-q'
&& $option != '--quiet'
&& $option != '--coverage'
&& $option != '--quiet-coverage'
&& $option != '--compact'
&& $option != '--profile'
&& $option != '--ansi'
&& $option != '--no-ansi'
&& ! Str::startsWith($option, '--min');
}));

if (!empty(preg_grep('/^--configuration=|-c/', $options))) {
return array_merge($this->commonArguments(), $options);
}

return array_merge($this->commonArguments(), ['--configuration='.$this->getConfigurationFile()], $options);
}

Expand Down Expand Up @@ -263,7 +257,6 @@ protected function paratestArguments($options)
&& $option != '--ansi'
&& $option != '--no-ansi'
&& ! Str::startsWith($option, '--min')
&& ! Str::startsWith($option, '--quiet-coverage')
&& ! Str::startsWith($option, '-p')
&& ! Str::startsWith($option, '--parallel')
&& ! Str::startsWith($option, '--recreate-databases')
Expand Down
2 changes: 1 addition & 1 deletion src/Coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static function usingXdebug(): bool
* Reports the code coverage report to the
* console and returns the result in float.
*/
public static function report(OutputInterface $output, bool $hideFullCoverage): float
public static function report(OutputInterface $output, bool $hideFullCoverage = false): float
{
if (! file_exists($reportPath = self::getPath())) {
if (self::usingXdebug()) {
Expand Down
21 changes: 2 additions & 19 deletions tests/Unit/Adapters/ArtisanTestCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@ class ArtisanTestCommandTest extends TestCase
public function test_coverage(): void
{
$output = $this->runTests(['./tests/LaravelApp/artisan', 'test', '--coverage', '--group', 'coverage']);
$this->assertStringContainsString('Code Coverage:', $output);
$this->assertStringContainsString('Models/User', $output);
$this->assertStringContainsString('0.0', $output);
$this->assertStringContainsString('Http/Controllers/Controller', $output);
$this->assertStringContainsString('100.0', $output);
$this->assertStringContainsString('Total: ', $output);

/**
$output = $this->runTests(['./tests/LaravelApp/artisan', 'test', '--coverage', '--parallel', '--group', 'coverage']);
$this->assertStringContainsString('Models/User', $output);
$this->assertStringContainsString('0.0', $output);
$this->assertStringContainsString('Total: ', $output);
*/
}

#[Test]
Expand All @@ -37,27 +34,23 @@ public function test_min_coverage(): void
$this->assertStringContainsString('Total: ', $output);
$this->assertStringNotContainsString('Code coverage below expected', $output);

/**
$output = $this->runTests(['./tests/LaravelApp/artisan', 'test', '--coverage', '--min=10', '--parallel', '--group', 'coverage'], 1);
$this->assertStringContainsString('Total: ', $output);
$this->assertStringContainsString('Code coverage below expected', $output);
*/

$output = $this->runTests(['./tests/LaravelApp/artisan', 'test', '--coverage', '--min=99', '--group', 'coverage'], 1);
$this->assertStringContainsString('Total: ', $output);
$this->assertStringContainsString('Code coverage below expected', $output);

/**
$output = $this->runTests(['./tests/LaravelApp/artisan', 'test', '--coverage', '--min=99', '--parallel', '--group', 'coverage'], 1);
$this->assertStringContainsString('Total: ', $output);
$this->assertStringContainsString('Code coverage below expected', $output);
*/
}

#[Test]
public function test_hide_full_coverage(): void
{
$output = $this->runTests(['./tests/LaravelApp/artisan', 'test', '--coverage', '--quiet-coverage', '--group', 'coverage'], 0);
$this->assertStringContainsString('Code Coverage (files with full coverage not printed):', $output);
$output = $this->runTests(['./tests/LaravelApp/artisan', 'test', '--coverage', '--compact', '--group', 'coverage'], 0);
$this->assertStringContainsString('Models/User', $output);
$this->assertStringContainsString('0.0', $output);
$this->assertStringNotContainsString('Http/Controllers/Controller', $output);
Expand Down Expand Up @@ -85,11 +78,9 @@ public function test_env(): void

$this->runTests(['./tests/LaravelApp/artisan', 'test', '--group', 'environment']);

/**
$this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--group', 'environment']);
$this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--recreate-databases', '--group', 'environment']);
$this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--drop-databases', '--group', 'environment']);
*/
}

#[Test]
Expand All @@ -111,11 +102,9 @@ public function test_env_testing(): void

$this->runTests(['./tests/LaravelApp/artisan', 'test', '--group', 'environmentTesting']);

/**
$this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--group', 'environmentTesting']);
$this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--recreate-databases', '--group', 'environmentTesting']);
$this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--drop-databases', '--group', 'environmentTesting']);
*/
}

#[AfterClass]
Expand All @@ -138,29 +127,23 @@ public function test_extendable_custom_variables(): void
// Without Custom Variables (-c|--custom-argument)
$this->runTests(['./tests/LaravelApp/artisan', 'test', '--group', 'environmentNoCVPhpunit']);

/**
$this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--group', 'environmentNoCVParallel']);
$this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--recreate-databases', '--group', 'environmentNoCVParallelRecreate']);
$this->runTests(['./tests/LaravelApp/artisan', 'test', '--parallel', '--drop-databases', '--group', 'environmentNoCVParallelDrop']);
*/

// With Custom Variables (-c)
$this->runTests(['./tests/LaravelApp/artisan', 'test', '-c', '--group', 'environmentCVPhpunit']);

/**
$this->runTests(['./tests/LaravelApp/artisan', 'test', '-c', '--parallel', '--group', 'environmentCVParallel']);
$this->runTests(['./tests/LaravelApp/artisan', 'test', '-c', '--parallel', '--recreate-databases', '--group', 'environmentCVParallelRecreate']);
$this->runTests(['./tests/LaravelApp/artisan', 'test', '-c', '--parallel', '--drop-databases', '--group', 'environmentCVParallelDrop']);
*/

// With Custom Variables (--custom-argument)
$this->runTests(['./tests/LaravelApp/artisan', 'test', '--custom-argument', '--group', 'environmentCVPhpunit']);

/**
$this->runTests(['./tests/LaravelApp/artisan', 'test', '--custom-argument', '--parallel', '--group', 'environmentCVParallel']);
$this->runTests(['./tests/LaravelApp/artisan', 'test', '--custom-argument', '--parallel', '--recreate-databases', '--group', 'environmentCVParallelRecreate']);
$this->runTests(['./tests/LaravelApp/artisan', 'test', '--custom-argument', '--parallel', '--drop-databases', '--group', 'environmentCVParallelDrop']);
*/
}

private function runTests(array $arguments, int $expectedExitCode = 0): string
Expand Down

0 comments on commit 6187165

Please sign in to comment.