Skip to content

fix: Prevent install command from breaking when /tests doesn't exist #93

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Laravel\Prompts\Terminal;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Process\Process;

use function Laravel\Prompts\intro;
use function Laravel\Prompts\multiselect;
Expand Down Expand Up @@ -58,6 +59,8 @@ class InstallCommand extends Command

private bool $enforceTests = true;

const MIN_TEST_COUNT = 6;

private string $greenTick;

private string $redCross;
Expand Down Expand Up @@ -118,9 +121,9 @@ private function discoverEnvironment(): void
private function collectInstallationPreferences(): void
{
$this->selectedBoostFeatures = $this->selectBoostFeatures();
$this->enforceTests = $this->determineTestEnforcement(ask: false);
$this->selectedTargetMcpClient = $this->selectTargetMcpClients();
$this->selectedTargetAgents = $this->selectTargetAgents();
$this->enforceTests = $this->determineTestEnforcement(ask: false);
}

private function performInstallation(): void
Expand Down Expand Up @@ -198,11 +201,19 @@ private function hyperlink(string $label, string $url): string
*/
protected function determineTestEnforcement(bool $ask = true): bool
{
$hasMinimumTests = Finder::create()
->in(base_path('tests'))
->files()
->name('*.php')
->count() > 6;
$hasMinimumTests = false;

if (file_exists(base_path('vendor/bin/phpunit'))) {
$process = new Process([PHP_BINARY, 'artisan', 'test', '--list-tests'], base_path());
$process->run();

/** Count the number of tests - they'll always have :: between the filename and test name */
$hasMinimumTests = Str::of($process->getOutput())
->trim()
->explode("\n")
->filter(fn ($line) => str_contains($line, '::'))
->count() >= self::MIN_TEST_COUNT;
}

if (! $hasMinimumTests && $ask) {
$hasMinimumTests = select(
Expand Down