value)->toBe(0); expect(ExitCode::GENERAL_ERROR->value)->toBe(1); expect(ExitCode::USAGE_ERROR->value)->toBe(2); expect(ExitCode::COMMAND_NOT_FOUND->value)->toBe(64); expect(ExitCode::INVALID_INPUT->value)->toBe(65); expect(ExitCode::NO_INPUT->value)->toBe(66); expect(ExitCode::UNAVAILABLE->value)->toBe(69); expect(ExitCode::SOFTWARE_ERROR->value)->toBe(70); expect(ExitCode::OS_ERROR->value)->toBe(71); expect(ExitCode::OS_FILE_ERROR->value)->toBe(72); expect(ExitCode::CANT_CREATE->value)->toBe(73); expect(ExitCode::IO_ERROR->value)->toBe(74); expect(ExitCode::TEMP_FAIL->value)->toBe(75); expect(ExitCode::PROTOCOL_ERROR->value)->toBe(76); expect(ExitCode::NO_PERMISSION->value)->toBe(77); expect(ExitCode::CONFIG_ERROR->value)->toBe(78); expect(ExitCode::DATABASE_ERROR->value)->toBe(79); expect(ExitCode::RATE_LIMITED->value)->toBe(80); expect(ExitCode::PERMISSION_DENIED->value)->toBe(126); expect(ExitCode::INTERRUPTED->value)->toBe(130); }); it('provides descriptions for all exit codes', function () { expect(ExitCode::SUCCESS->getDescription())->toBe('Erfolgreich abgeschlossen'); expect(ExitCode::GENERAL_ERROR->getDescription())->toBe('Allgemeiner Fehler'); expect(ExitCode::USAGE_ERROR->getDescription())->toBe('Falsche Verwendung oder ungültige Argumente'); expect(ExitCode::COMMAND_NOT_FOUND->getDescription())->toBe('Kommando nicht gefunden'); expect(ExitCode::INVALID_INPUT->getDescription())->toBe('Ungültige Eingabedaten'); expect(ExitCode::NO_INPUT->getDescription())->toBe('Keine Eingabe vorhanden'); expect(ExitCode::UNAVAILABLE->getDescription())->toBe('Service nicht verfügbar'); expect(ExitCode::SOFTWARE_ERROR->getDescription())->toBe('Interner Software-Fehler'); expect(ExitCode::OS_ERROR->getDescription())->toBe('Betriebssystem-Fehler'); expect(ExitCode::OS_FILE_ERROR->getDescription())->toBe('Datei-/Verzeichnis-Fehler'); expect(ExitCode::CANT_CREATE->getDescription())->toBe('Kann Datei/Verzeichnis nicht erstellen'); expect(ExitCode::IO_ERROR->getDescription())->toBe('Ein-/Ausgabe-Fehler'); expect(ExitCode::TEMP_FAIL->getDescription())->toBe('Temporärer Fehler'); expect(ExitCode::PROTOCOL_ERROR->getDescription())->toBe('Protokoll-Fehler'); expect(ExitCode::NO_PERMISSION->getDescription())->toBe('Keine Berechtigung'); expect(ExitCode::CONFIG_ERROR->getDescription())->toBe('Konfigurationsfehler'); expect(ExitCode::DATABASE_ERROR->getDescription())->toBe('Datenbankfehler'); expect(ExitCode::RATE_LIMITED->getDescription())->toBe('Rate-Limit erreicht'); expect(ExitCode::PERMISSION_DENIED->getDescription())->toBe('Zugriff verweigert'); expect(ExitCode::INTERRUPTED->getDescription())->toBe('Unterbrochen durch Signal (SIGINT/SIGTERM)'); }); it('identifies success correctly', function () { expect(ExitCode::SUCCESS->isSuccess())->toBeTrue(); expect(ExitCode::SUCCESS->isError())->toBeFalse(); }); it('identifies errors correctly', function () { expect(ExitCode::GENERAL_ERROR->isSuccess())->toBeFalse(); expect(ExitCode::GENERAL_ERROR->isError())->toBeTrue(); expect(ExitCode::COMMAND_NOT_FOUND->isSuccess())->toBeFalse(); expect(ExitCode::COMMAND_NOT_FOUND->isError())->toBeTrue(); expect(ExitCode::INVALID_INPUT->isSuccess())->toBeFalse(); expect(ExitCode::INVALID_INPUT->isError())->toBeTrue(); }); it('can be used as integer value', function () { $exitCode = ExitCode::SUCCESS; expect($exitCode->value)->toBeInt(); expect($exitCode->value)->toBe(0); }); it('follows POSIX exit code standards', function () { // 0 = success expect(ExitCode::SUCCESS->value)->toBe(0); // 1 = general error expect(ExitCode::GENERAL_ERROR->value)->toBe(1); // 2 = usage error expect(ExitCode::USAGE_ERROR->value)->toBe(2); // 64-78 = sysexits.h standard codes expect(ExitCode::COMMAND_NOT_FOUND->value)->toBe(64); expect(ExitCode::INVALID_INPUT->value)->toBe(65); expect(ExitCode::NO_INPUT->value)->toBe(66); expect(ExitCode::UNAVAILABLE->value)->toBe(69); expect(ExitCode::SOFTWARE_ERROR->value)->toBe(70); expect(ExitCode::OS_ERROR->value)->toBe(71); expect(ExitCode::OS_FILE_ERROR->value)->toBe(72); expect(ExitCode::CANT_CREATE->value)->toBe(73); expect(ExitCode::IO_ERROR->value)->toBe(74); expect(ExitCode::TEMP_FAIL->value)->toBe(75); expect(ExitCode::PROTOCOL_ERROR->value)->toBe(76); expect(ExitCode::NO_PERMISSION->value)->toBe(77); expect(ExitCode::CONFIG_ERROR->value)->toBe(78); }); });