From 4aa65f750e28379f07c1c4b75cc1b8f352733a86 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 3 Mar 2024 13:16:37 +0100 Subject: [PATCH] Add CLI test for manage redirects command, to cover validation errors --- .../Command/ManageRedirectRulesTest.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 module/CLI/test-cli/Command/ManageRedirectRulesTest.php diff --git a/module/CLI/test-cli/Command/ManageRedirectRulesTest.php b/module/CLI/test-cli/Command/ManageRedirectRulesTest.php new file mode 100644 index 00000000..3da0a767 --- /dev/null +++ b/module/CLI/test-cli/Command/ManageRedirectRulesTest.php @@ -0,0 +1,33 @@ +exec([ManageRedirectRulesCommand::NAME, 'abc123'], [ + '0', // Add new rule + 'not-a-number', // Invalid priority + '1', // Valid priority, to continue execution + 'invalid-long-url', // Invalid long URL + 'https://example.com', // Valid long URL, to continue execution + '1', // Language condition type + '', // Invalid required language + 'es-ES', // Valid language, to continue execution + 'no', // Do not add more conditions + '4', // Discard changes + ]); + + self::assertStringContainsString('The priority must be a numeric positive value', $output); + self::assertStringContainsString('The input is not valid', $output); + self::assertStringContainsString('The value is mandatory', $output); + } +}