TenantAtlas/tests/Feature/Guards/NoAdHocRetryInBulkWorkersTest.php
2026-01-19 19:01:36 +01:00

33 lines
865 B
PHP

<?php
use Illuminate\Support\Str;
it('does not use ad-hoc sleep/usleep retry loops in bulk worker jobs', function () {
$root = base_path('app/Jobs/Operations');
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($root));
$paths = collect(iterator_to_array($iterator))
->filter(fn (\SplFileInfo $file): bool => $file->isFile() && $file->getExtension() === 'php')
->map(fn (\SplFileInfo $file): string => $file->getPathname())
->values();
expect($paths)->not->toBeEmpty();
$violations = [];
foreach ($paths as $path) {
$contents = file_get_contents($path);
if ($contents === false) {
continue;
}
if (Str::contains($contents, ['sleep(', 'usleep('])) {
$violations[] = $path;
}
}
expect($violations)->toBe([]);
});