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

51 lines
1.2 KiB
PHP
Raw Normal View History

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;
use Zend\I18n\Translator\Translator;
class GenerateCharsetCommandTest extends TestCase
{
/**
* @var CommandTester
*/
protected $commandTester;
public function setUp()
{
$command = new GenerateCharsetCommand(Translator::factory([]));
$app = new Application();
$app->add($command);
$this->commandTester = new CommandTester($command);
}
/**
* @test
*/
public function charactersAreGeneratedFromDefault()
{
$prefix = 'Character set: ';
$this->commandTester->execute([
'command' => 'config:generate-charset',
]);
$output = $this->commandTester->getDisplay();
// Both default character set and the new one should have the same length
2017-12-28 16:59:52 +03:00
$this->assertContains($prefix, $output);
2016-08-01 22:11:42 +03:00
}
protected function orderStringLetters($string)
{
$letters = str_split($string);
sort($letters);
return implode('', $letters);
}
}