mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Add CLI test for manage redirects command, to cover validation errors
This commit is contained in:
parent
63c533fa62
commit
4aa65f750e
33
module/CLI/test-cli/Command/ManageRedirectRulesTest.php
Normal file
33
module/CLI/test-cli/Command/ManageRedirectRulesTest.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace ShlinkioCliTest\Shlink\CLI\Command;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
|
use Shlinkio\Shlink\CLI\Command\RedirectRule\ManageRedirectRulesCommand;
|
||||||
|
use Shlinkio\Shlink\TestUtils\CliTest\CliTestCase;
|
||||||
|
|
||||||
|
class ManageRedirectRulesTest extends CliTestCase
|
||||||
|
{
|
||||||
|
#[Test]
|
||||||
|
public function printsErrorsWhenPassingInvalidValues(): void
|
||||||
|
{
|
||||||
|
[$output] = $this->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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user