scan(app_path('Domain/SchoolCore'), ['App\\Domain\\IslamicSundaySchool']); $this->assertSame([], $violations); } public function test_domain_services_do_not_accept_raw_request_or_call_auth(): void { $violations = $this->scan(app_path('Domain'), ['Illuminate\\Http\\Request', 'auth()']); $violations = array_values(array_filter($violations, fn (string $path): bool => ! str_contains($path, 'SchoolContextResolver.php'))); $this->assertSame([], $violations); } public function test_core_contracts_keep_neutral_vocabulary(): void { $violations = $this->scan(app_path('Domain/SchoolCore/Contracts'), ['masjid', 'ministry', 'bible', 'servant', 'service_day']); $this->assertSame([], $violations); } /** @param array $needles @return array */ private function scan(string $root, array $needles): array { if (! is_dir($root)) { return []; } $violations = []; foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root)) as $file) { if (! $file instanceof SplFileInfo || $file->getExtension() !== 'php') { continue; } $contents = file_get_contents($file->getPathname()) ?: ''; foreach ($needles as $needle) { if (str_contains($contents, $needle)) { $violations[] = $file->getPathname() . ' contains ' . $needle; } } } return $violations; } }