shlink/module/CLI/test/Command/Config/GenerateCharsetCommandTest.php

48 lines
1.2 KiB
PHP
Raw Normal View History

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