reject(fn (string $file): bool => $file === $helperFile) ->mapWithKeys(function (string $file) use ($projectRoot) { preg_match_all('/docker\s+(?:stop|restart)\s+--time\b/', file_get_contents($file), $matches); return [str_replace($projectRoot.DIRECTORY_SEPARATOR, '', $file) => $matches[0]]; }) ->filter(fn (array $matches): bool => $matches !== []) ->map(fn (array $matches, string $file): string => $file.': '.implode(', ', array_unique($matches))); expect($offenders->values()->implode("\n"))->toBe(''); }); it('builds application container stop commands from the stored docker version', function (string $relativePath) { $contents = file_get_contents(dockerStopDeprecatedFlagProjectRoot().DIRECTORY_SEPARATOR.$relativePath); expect($contents) ->toContain('dockerStopCommand(') ->not->toContain('docker stop --time=') ->not->toContain('docker stop -t $timeout'); })->with([ 'deployment graceful shutdown' => ['app/Jobs/ApplicationDeploymentJob.php'], 'stop application' => ['app/Actions/Application/StopApplication.php'], 'stop application on one server' => ['app/Actions/Application/StopApplicationOneServer.php'], 'stop preview containers' => ['app/Livewire/Project/Application/Previews.php'], ]); function dockerStopDeprecatedFlagProjectRoot(): string { return dirname(__DIR__, 2); } /** * @return list */ function dockerStopDeprecatedFlagPhpFiles(string $directory): array { $files = []; foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) { if ($file->isFile() && $file->getExtension() === 'php') { $files[] = $file->getPathname(); } } sort($files); return $files; }