TenantAtlas/tests/Feature/OpsUx/CanonicalViewRunLinksTest.php

33 lines
865 B
PHP

<?php
declare(strict_types=1);
use Illuminate\Support\Facades\File;
it('routes all OperationRun view links through OperationRunLinks', function (): void {
$files = File::allFiles(app_path());
$violations = [];
foreach ($files as $file) {
$path = $file->getRealPath();
if (! is_string($path)) {
continue;
}
// OperationRunLinks is the canonical wrapper.
if (str_ends_with($path, '/Support/OperationRunLinks.php')) {
continue;
}
$contents = File::get($path);
if (preg_match("/\\bOperationRunResource::getUrl\(\\s*'view'/", $contents) === 1
|| preg_match("/route\(\s*'filament\.admin\.resources\.operations\.view'/", $contents) === 1) {
$violations[] = $path;
}
}
expect($violations)->toBeEmpty();
})->group('ops-ux');