|
23 | 23 | use Laravel\Prompts\Terminal;
|
24 | 24 | use Symfony\Component\Console\Attribute\AsCommand;
|
25 | 25 | use Symfony\Component\Finder\Finder;
|
| 26 | +use Symfony\Component\Process\Process; |
26 | 27 |
|
27 | 28 | use function Laravel\Prompts\intro;
|
28 | 29 | use function Laravel\Prompts\multiselect;
|
@@ -58,6 +59,8 @@ class InstallCommand extends Command
|
58 | 59 |
|
59 | 60 | private bool $enforceTests = true;
|
60 | 61 |
|
| 62 | + const MIN_TEST_COUNT = 6; |
| 63 | + |
61 | 64 | private string $greenTick;
|
62 | 65 |
|
63 | 66 | private string $redCross;
|
@@ -118,9 +121,9 @@ private function discoverEnvironment(): void
|
118 | 121 | private function collectInstallationPreferences(): void
|
119 | 122 | {
|
120 | 123 | $this->selectedBoostFeatures = $this->selectBoostFeatures();
|
121 |
| - $this->enforceTests = $this->determineTestEnforcement(ask: false); |
122 | 124 | $this->selectedTargetMcpClient = $this->selectTargetMcpClients();
|
123 | 125 | $this->selectedTargetAgents = $this->selectTargetAgents();
|
| 126 | + $this->enforceTests = $this->determineTestEnforcement(ask: false); |
124 | 127 | }
|
125 | 128 |
|
126 | 129 | private function performInstallation(): void
|
@@ -198,11 +201,19 @@ private function hyperlink(string $label, string $url): string
|
198 | 201 | */
|
199 | 202 | protected function determineTestEnforcement(bool $ask = true): bool
|
200 | 203 | {
|
201 |
| - $hasMinimumTests = Finder::create() |
202 |
| - ->in(base_path('tests')) |
203 |
| - ->files() |
204 |
| - ->name('*.php') |
205 |
| - ->count() > 6; |
| 204 | + $hasMinimumTests = false; |
| 205 | + |
| 206 | + if (file_exists(base_path('vendor/bin/phpunit'))) { |
| 207 | + $process = new Process([PHP_BINARY, 'artisan', 'test', '--list-tests'], base_path()); |
| 208 | + $process->run(); |
| 209 | + |
| 210 | + /** Count the number of tests - they'll always have :: between the filename and test name */ |
| 211 | + $hasMinimumTests = Str::of($process->getOutput()) |
| 212 | + ->trim() |
| 213 | + ->explode("\n") |
| 214 | + ->filter(fn ($line) => str_contains($line, '::')) |
| 215 | + ->count() >= self::MIN_TEST_COUNT; |
| 216 | + } |
206 | 217 |
|
207 | 218 | if (! $hasMinimumTests && $ask) {
|
208 | 219 | $hasMinimumTests = select(
|
|
0 commit comments