2016-08-01 22:11:42 +03:00
|
|
|
<?php
|
2017-10-12 11:13:20 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-08-01 22:11:42 +03:00
|
|
|
namespace ShlinkioTest\Shlink\CLI\Command\Config;
|
|
|
|
|
2017-03-24 22:34:18 +03:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2016-08-01 22:11:42 +03:00
|
|
|
use Shlinkio\Shlink\CLI\Command\Config\GenerateCharsetCommand;
|
|
|
|
use Symfony\Component\Console\Application;
|
|
|
|
use Symfony\Component\Console\Tester\CommandTester;
|
2019-02-27 00:56:43 +03:00
|
|
|
|
2018-10-28 10:34:02 +03:00
|
|
|
use function implode;
|
|
|
|
use function sort;
|
|
|
|
use function str_split;
|
2016-08-01 22:11:42 +03:00
|
|
|
|
|
|
|
class GenerateCharsetCommandTest extends TestCase
|
|
|
|
{
|
2018-11-20 21:30:27 +03:00
|
|
|
/** @var CommandTester */
|
2018-11-20 21:37:22 +03:00
|
|
|
private $commandTester;
|
2016-08-01 22:11:42 +03:00
|
|
|
|
2019-02-16 12:53:45 +03:00
|
|
|
public function setUp(): void
|
2016-08-01 22:11:42 +03:00
|
|
|
{
|
2018-11-18 18:02:52 +03:00
|
|
|
$command = new GenerateCharsetCommand();
|
2016-08-01 22:11:42 +03:00
|
|
|
$app = new Application();
|
|
|
|
$app->add($command);
|
|
|
|
|
|
|
|
$this->commandTester = new CommandTester($command);
|
|
|
|
}
|
|
|
|
|
2019-02-17 22:28:34 +03:00
|
|
|
/** @test */
|
2016-08-01 22:11:42 +03:00
|
|
|
public function charactersAreGeneratedFromDefault()
|
|
|
|
{
|
|
|
|
$prefix = 'Character set: ';
|
|
|
|
|
2019-04-14 23:20:58 +03:00
|
|
|
$this->commandTester->execute([]);
|
2016-08-01 22:11:42 +03:00
|
|
|
$output = $this->commandTester->getDisplay();
|
|
|
|
|
|
|
|
// Both default character set and the new one should have the same length
|
2019-02-16 12:53:45 +03:00
|
|
|
$this->assertStringContainsString($prefix, $output);
|
2016-08-01 22:11:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function orderStringLetters($string)
|
|
|
|
{
|
|
|
|
$letters = str_split($string);
|
|
|
|
sort($letters);
|
|
|
|
return implode('', $letters);
|
|
|
|
}
|
|
|
|
}
|