mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-25 08:21:11 -06:00
47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace ShlinkioTest\Shlink\CLI;
|
|
|
|
use Prophecy\Argument;
|
|
use Prophecy\PhpUnit\ProphecyTrait;
|
|
use Prophecy\Prophecy\ObjectProphecy;
|
|
use Symfony\Component\Console\Application;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputDefinition;
|
|
use Symfony\Component\Console\Tester\CommandTester;
|
|
|
|
trait CliTestUtilsTrait
|
|
{
|
|
use ProphecyTrait;
|
|
|
|
/**
|
|
* @return ObjectProphecy|Command
|
|
*/
|
|
private function createCommandMock(string $name): ObjectProphecy
|
|
{
|
|
$command = $this->prophesize(Command::class);
|
|
$command->getName()->willReturn($name);
|
|
$command->getDefinition()->willReturn($name);
|
|
$command->isEnabled()->willReturn(true);
|
|
$command->getAliases()->willReturn([]);
|
|
$command->getDefinition()->willReturn(new InputDefinition());
|
|
$command->setApplication(Argument::type(Application::class))->willReturn(function (): void {
|
|
});
|
|
|
|
return $command;
|
|
}
|
|
|
|
private function testerForCommand(Command $mainCommand, Command ...$extraCommands): CommandTester
|
|
{
|
|
$app = new Application();
|
|
$app->add($mainCommand);
|
|
foreach ($extraCommands as $command) {
|
|
$app->add($command);
|
|
}
|
|
|
|
return new CommandTester($mainCommand);
|
|
}
|
|
}
|