Migrated CliTestUtilsTrait to use PHPUnit mocks

This commit is contained in:
Alejandro Celaya
2022-10-22 12:46:16 +02:00
parent 983e3c9eaa
commit 58db902084
3 changed files with 25 additions and 20 deletions

View File

@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI;
use Prophecy\Argument;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\MockObject\MockObject;
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;
@@ -14,21 +14,19 @@ use Symfony\Component\Console\Tester\CommandTester;
trait CliTestUtilsTrait
{
use ProphecyTrait;
use ProphecyTrait; // TODO Remove
/**
* @return ObjectProphecy|Command
* @return MockObject & Command
*/
private function createCommandMock(string $name): ObjectProphecy
private function createCommandMock(string $name): MockObject
{
$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 {
});
$command = $this->createMock(Command::class);
$command->method('getName')->willReturn($name);
$command->method('isEnabled')->willReturn(true);
$command->method('getAliases')->willReturn([]);
$command->method('getDefinition')->willReturn(new InputDefinition());
$command->method('setApplication')->with(Assert::isInstanceOf(Application::class));
return $command;
}