isDir() ? rmdir($item->getPathname()) : unlink($item->getPathname()); } rmdir($path); } foreach (glob(__DIR__ . '/*_test.php') ?: [] as $file) { require $file; } $failures = 0; foreach ($tests as [$name, $fn]) { try { $fn(); echo "PASS {$name}\n"; } catch (Throwable $e) { $failures++; echo "FAIL {$name}: " . $e->getMessage() . "\n"; } } test_rm_rf(TEST_TMP); if ($failures > 0) { exit(1); }