mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 17:44:44 +08:00
Migrated CliTestUtilsTrait to use PHPUnit mocks
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user