2023-04-23 12:20:54 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace ShlinkioCliTest\Shlink\CLI\Command;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
|
|
use Shlinkio\Shlink\CLI\Command\ShortUrl\CreateShortUrlCommand;
|
|
|
|
use Shlinkio\Shlink\CLI\Command\ShortUrl\ListShortUrlsCommand;
|
2023-05-15 10:43:05 +03:00
|
|
|
use Shlinkio\Shlink\CLI\Util\ExitCode;
|
2023-04-23 12:20:54 +03:00
|
|
|
use Shlinkio\Shlink\TestUtils\CliTest\CliTestCase;
|
|
|
|
|
|
|
|
class CreateShortUrlTest extends CliTestCase
|
|
|
|
{
|
|
|
|
#[Test]
|
|
|
|
public function defaultDomainIsIgnoredWhenExplicitlyProvided(): void
|
|
|
|
{
|
|
|
|
$slug = 'testing-default-domain';
|
|
|
|
$defaultDomain = 's.test';
|
|
|
|
|
|
|
|
[$output, $exitCode] = $this->exec(
|
|
|
|
[CreateShortUrlCommand::NAME, 'https://example.com', '--domain', $defaultDomain, '--custom-slug', $slug],
|
|
|
|
);
|
|
|
|
|
2023-05-15 10:43:05 +03:00
|
|
|
self::assertEquals(ExitCode::EXIT_SUCCESS, $exitCode);
|
2023-04-23 12:20:54 +03:00
|
|
|
self::assertStringContainsString('Generated short URL: http://' . $defaultDomain . '/' . $slug, $output);
|
|
|
|
|
|
|
|
[$listOutput] = $this->exec([ListShortUrlsCommand::NAME, '--show-domain', '--search-term', $slug]);
|
|
|
|
self::assertStringContainsString('DEFAULT', $listOutput);
|
|
|
|
}
|
|
|
|
}
|